1
This commit is contained in:
parent
88fdadd28c
commit
1c584f0d64
@ -60,6 +60,7 @@ CREATE TABLE `user` (
|
||||
`first_fight` int(11) NOT NULL COMMENT '是否是第一次战斗',
|
||||
`collect_status` int(11) NOT NULL COMMENT '收藏状态',
|
||||
`keys_num` int(11) NOT NULL COMMENT '钥匙数量',
|
||||
`battle_re_times` int(11) NOT NULL COMMENT '每日战斗奖励次数',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
@ -134,5 +134,11 @@ function getItemConfig($item_table, $item_id)
|
||||
$item_id = (int)$item_id;
|
||||
return array_key_exists($item_id, $item_table) ? $item_table[$item_id] : null;
|
||||
}
|
||||
|
||||
function getShareConfig($share_table, $share_id)
|
||||
{
|
||||
$share_id = (int)$share_id;
|
||||
return array_key_exists($share_id, $share_table) ? $share_table[$share_id] : null;
|
||||
}
|
||||
checkMysqlConfig();
|
||||
checkRedisConfig();
|
||||
|
@ -67,7 +67,7 @@ define('DOUBLE_END_WAR', 24); //战斗结束翻倍率
|
||||
define('DOUBLE_BOX', 25); //抽箱子奖励翻倍率
|
||||
define('FREE_DRESS_MAX_TIME', 30); //免费获取皮肤次数上限
|
||||
define('RAND_SHOP_GOLD', 39); //商店金币刷新价格
|
||||
|
||||
define('MAX_BATTLE_REWARD', 40); //战斗额外奖励次数
|
||||
require 'config_loader.php';
|
||||
|
||||
|
||||
|
@ -35,6 +35,19 @@ class RoleController{
|
||||
return $act;
|
||||
}
|
||||
|
||||
protected function getDrop($drop_id)
|
||||
{
|
||||
$g_conf_drop_cluster = require('../res/drop@drop.php');
|
||||
$drop_conf = getDropConfig($g_conf_drop_cluster, $drop_id);
|
||||
$d = array(
|
||||
'drop_id' => $drop_conf['drop_id'],
|
||||
'item_id' => $drop_conf['item_id'],
|
||||
'num' => $drop_conf['num'],
|
||||
'weight' => $drop_conf['weight'],
|
||||
'type' => $drop_conf['type']
|
||||
);
|
||||
return $d;
|
||||
}
|
||||
|
||||
protected function getExplode($string)
|
||||
{
|
||||
@ -87,9 +100,9 @@ class RoleController{
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0;',
|
||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
@ -287,12 +300,38 @@ class RoleController{
|
||||
//额外奖励
|
||||
$times = $this->getRewardTimes($coin_num);
|
||||
$extra_coin = $coin_num * ($times - 1);
|
||||
$skin_id = 13002;
|
||||
$skin_num = 6;
|
||||
$d = $this->getDrop(24004);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
return;
|
||||
}
|
||||
$skin_id_array = $this->getExplode($d['item_id']);
|
||||
$weight_sum = 0;
|
||||
$keys = 0;
|
||||
$skin_num_array = $this->getExplode($d['num']);
|
||||
$weight_array = $this->getExplode($d['weight']);
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$weight_sum += $weight_array[$i][0];
|
||||
}
|
||||
srand($room_uuid);
|
||||
$randnum = Rand(0,100);
|
||||
error_log($randnum);
|
||||
$extra_drop = '10001:' . $extra_coin . '|10002:1' . '|' . $skin_id . ':' . $skin_num;
|
||||
$random = Rand(0, $weight_sum);
|
||||
$weight = 0;
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$weight += $weight_array[$i][0];
|
||||
if ($weight > $random) {
|
||||
$keys = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$extra_drop = "";
|
||||
$skin_id = $skin_id_array[$keys][0];
|
||||
$skin_num = $skin_num_array[$keys][0];
|
||||
$p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD);
|
||||
if ($row['battle_re_times'] >= $p_battle_reward['param_value']) {
|
||||
$extra_drop = '10001:' . $extra_coin;
|
||||
} else {
|
||||
$extra_drop = '10001:' . $extra_coin . '|10002:1' . '|' . $skin_id . ':' . $skin_num;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -435,21 +474,55 @@ class RoleController{
|
||||
$coin_num = $row['coin'];
|
||||
$times = $this->getRewardTimes($coin_num);
|
||||
$coin_num = $row['coin'] * ($times - 1);
|
||||
$d = $this->getDrop(24004);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
return;
|
||||
}
|
||||
$skin_id_array = $this->getExplode($d['item_id']);
|
||||
$weight_sum = 0;
|
||||
$keys = 0;
|
||||
$skin_num_array = $this->getExplode($d['num']);
|
||||
$weight_array = $this->getExplode($d['weight']);
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$weight_sum += $weight_array[$i][0];
|
||||
}
|
||||
srand($room_uuid);
|
||||
$random = Rand(0, $weight_sum);
|
||||
$weight = 0;
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$weight += $weight_array[$i][0];
|
||||
if ($weight > $random) {
|
||||
$keys = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$skin_id = $skin_id_array[$keys][0];
|
||||
$skin_num = $skin_num_array[$keys][0];
|
||||
$p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD);
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward(10001, $coin_num, $account_id);
|
||||
$rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $coin_num + $rowUser['coin_num'],
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
if ($rowUser['battle_re_times'] < $p_battle_reward['param_value']) {
|
||||
$keys_num = $rowUser['keys_num'] + 1;
|
||||
$battle_re_times = $rowUser['battle_re_times'] + 1;
|
||||
$addreward->addReward($skin_id, $skin_num, $account_id);
|
||||
$ret = $conn->execScript('UPDATE user SET battle_re_times=:battle_re_times, keys_num=:keys_num, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':keys_num' => $keys_num,
|
||||
':battle_re_times' => $battle_re_times,
|
||||
':modify_time' => time(),
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -487,10 +560,11 @@ class RoleController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET collect_status=1, modify_time=:modify_time, ' .
|
||||
$ret = $conn->execScript('UPDATE user SET collect_status=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':modify_time' => time()
|
||||
':modify_time' => time(),
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
@ -526,18 +600,6 @@ class RoleController{
|
||||
));
|
||||
}
|
||||
|
||||
protected function getDrop($drop_id)
|
||||
{
|
||||
$g_conf_drop_cluster = require('../res/drop@drop.php');
|
||||
$drop_conf = getDropConfig($g_conf_drop_cluster, $drop_id);
|
||||
$d = array(
|
||||
'drop_id' => $drop_conf['drop_id'],
|
||||
'item_id' => $drop_conf['item_id'],
|
||||
'num' => $drop_conf['num'],
|
||||
'weight' => $drop_conf['weight'],
|
||||
'type' => $drop_conf['type']
|
||||
);
|
||||
return $d;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -192,7 +192,6 @@ class SupplyBoxController{
|
||||
}
|
||||
if ($free_open == 1) {
|
||||
$p_times = $this->getParameter(FREE_DRESS_MAX_TIME);
|
||||
$p_times['param_value'];
|
||||
if ($row['free_times'] >= $p_times['param_value']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '免费次数不足');
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user