diff --git a/sql/gamedb.sql b/sql/gamedb.sql index f157a94..a1f0870 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -121,8 +121,8 @@ CREATE TABLE `supplybox` ( `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', `box_id` int(11) NOT NULL COMMENT '补给箱id', - `box_num` int(11) NOT NULL COMMENT '补给箱数量', - `buy_times` int(11) NOT NULL COMMENT '购买次数', + `buy_times` int(11) NOT NULL COMMENT '购买次数', + `free_times` int(11) NOT NULL COMMENT '免费获得次数', `last_buy_time` varchar(50) NOT NULL DEFAULT '最后一次购买', `create_time` int(11) NOT NULL COMMENT '创建时间', `modify_time` int(11) NOT NULL COMMENT '修改时间', diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index 68107e2..998cdd4 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -15,9 +15,8 @@ define('QUEST_DAY_RANK', 71007); define('QUEST_DAY_ALIVE', 71008); define('QUEST_DAY_HARM', 71009); define('QUEST_DAY_KILL', 71010); -define('QUEST_DAY_GAME', 71011); -define('QUEST_DAY_HELP', 71012); -define('QUEST_DAY_COMPLETE', 71013); +define('QUEST_DAY_HELP', 71011); +define('QUEST_DAY_COMPLETE', 71012); //成就 define('QUEST_SUM_LOGIN', 72001); define('QUEST_SUM_SHARE', 72002); @@ -34,8 +33,7 @@ define('QUEST_SUM_SNIPEKILL', 72012); define('QUEST_SUM_RIFLEKILL', 72013); define('QUEST_SUM_PISTOLKILL', 72014); define('QUEST_SUM_SUBMACKILL', 72015); -define('QUEST_SUM_GAME', 72016); -define('QUEST_SUM_HELP', 72017); +define('QUEST_SUM_HELP', 72016); //活动 define('QUEST_ACTIVITY_LOGIN', 83001); define('QUEST_ACTIVITY_GAME', 83002); @@ -67,6 +65,7 @@ define('DOUBLE_GOLD', 22); //免费金币翻倍率 define('DOUBLE_SIGN_IN', 23); //每日签到翻倍率 define('DOUBLE_END_WAR', 24); //战斗结束翻倍率 define('DOUBLE_BOX', 25); //抽箱子奖励翻倍率 +define('FREE_DRESS_MAX_TIME', 30); //免费获取皮肤次数上限 require 'config_loader.php'; diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index f9bc2df..8c93a48 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -141,6 +141,10 @@ class ActivityController{ ':act_share_status' => $receive_status, ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } } //任务活动 $rows = $conn->execQuery('SELECT * FROM quest WHERE accountid=:accountid AND quest_type=:quest_type;', @@ -217,6 +221,10 @@ class ActivityController{ ':fragment_num' => $item_num + $rowSkin['fragment_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } break; } case 2: //活动皮肤兑换 diff --git a/webapp/controller/EquipController.class.php b/webapp/controller/EquipController.class.php index d4547b7..2c4d584 100644 --- a/webapp/controller/EquipController.class.php +++ b/webapp/controller/EquipController.class.php @@ -73,6 +73,9 @@ class EquipController{ ':coin_num' => $rowCoin['coin_num'] - $e['equip_cost'], ':modify_time' => time() )); + if (!$ret) { + die(); + } return $e; } diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php index 13d0231..a0db4a4 100644 --- a/webapp/controller/HangController.class.php +++ b/webapp/controller/HangController.class.php @@ -63,7 +63,7 @@ class HangController{ $item_id = 10001; $p_num = $this->getParameter(GOLD); $p_time_limit = $this->getParameter(TIME_LIMIT); - $num = time() - $row['hang_time'] / 5 * $p_num['param_value']; + $num = floor((time() - $row['hang_time']) / 5 * $p_num['param_value']); if ($num >= $p_time_limit['param_value']) { $num = $p_time_limit['param_value'] / 5 * $p_num['param_value']; } @@ -82,6 +82,10 @@ class HangController{ ':coin_num' => $num + $row['coin_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } } echo json_encode(array( 'errcode' => 0, @@ -128,7 +132,7 @@ class HangController{ } else { $p_num = $this->getParameter(GOLD); $p_time_limit = $this->getParameter(TIME_LIMIT); - $num = time() - $row['hang_time'] / 5 * $p_num['param_value']; + $num = floor((time() - $row['hang_time']) / 5 * $p_num['param_value']); if ($num >= $p_time_limit['param_value']) { $num = $p_time_limit['param_value'] / 5 * $p_num['param_value']; } diff --git a/webapp/controller/QuestController.class.php b/webapp/controller/QuestController.class.php index 240f925..cbe8a37 100644 --- a/webapp/controller/QuestController.class.php +++ b/webapp/controller/QuestController.class.php @@ -87,6 +87,9 @@ class QuestController{ ':create_time' => time(), ':modify_time' => time() )); + if (!$ret) { + die(); + } } } @@ -114,7 +117,6 @@ class QuestController{ )); if (!$ret) { die(); - return; } } @@ -139,7 +141,6 @@ class QuestController{ )); if (!$ret) { die(); - return; } } } @@ -156,6 +157,9 @@ class QuestController{ ':active_sum' => 0, ':modify_time' => time() )); + if (!$ret) { + die(); + } } else if ($flag == 1) { $ret = $conn->execScript('UPDATE active SET num_time=:num_time, active_num=:active_num, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', @@ -165,6 +169,9 @@ class QuestController{ ':active_num' => 0, ':modify_time' => time() )); + if (!$ret) { + die(); + } } $ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state, modify_time=:modify_time ' . ' WHERE accountid=:accountid AND quest_type=:quest_type AND quest_id<:quest_id;', @@ -175,6 +182,9 @@ class QuestController{ ':quest_state' => 0, ':modify_time' => time() )); + if (!$ret) { + die(); + } } public function questInfo() @@ -370,6 +380,10 @@ class QuestController{ ':coin_num' => $item_num + $row1['coin_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } } } else { $q = $this->getQuest($quest_id); @@ -389,6 +403,10 @@ class QuestController{ ':coin_num' => $reward + $row1['coin_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } } if ($row['quest_type'] == 1) { $active = $conn->execQueryOne('SELECT active_num, active_sum FROM active WHERE accountid=:accountid;', @@ -411,6 +429,10 @@ class QuestController{ ':create_time' => time(), ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } $this->updateActive($account_id, $q['active_value'], $q['active_value']); } else { $active['active_num'] = $q['active_value'] + $active['active_num']; @@ -423,6 +445,10 @@ class QuestController{ ':active_sum' => $active['active_sum'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } $this->updateActive($account_id, $active['active_num'], $active['active_sum']); } } diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index d35daf3..5847ce9 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -246,13 +246,11 @@ class RoleController{ $quest->triggerQuest(QUEST_DAY_ALIVE, 1, (int)($alive_time / 1000 / 60), $account_id); $quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id); $quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id); - $quest->triggerQuest(QUEST_DAY_GAME, 1, 1, $account_id); $quest->triggerQuest(QUEST_DAY_HELP, 1, $rescue_member, $account_id); $quest->triggerQuest(QUEST_SUM_FIGHT, 2, 1, $account_id); $quest->triggerQuest(QUEST_SUM_ALIVE, 2, (int)($alive_time / 1000 / 60), $account_id); $quest->triggerQuest(QUEST_SUM_HARM, 2, $harm, $account_id); $quest->triggerQuest(QUEST_SUM_KILL, 2, $kills, $account_id); - $quest->triggerQuest(QUEST_SUM_GAME, 2, 1, $account_id); $quest->triggerQuest(QUEST_SUM_HELP, 2, $rescue_member, $account_id); $quest->triggerQuest(QUEST_SUM_SNIPEKILL, 2, $snipe_kill, $account_id); $quest->triggerQuest(QUEST_SUM_RIFLEKILL, 2, $rifle_kill, $account_id); @@ -277,9 +275,9 @@ class RoleController{ $nowTime = phpcommon\getdayseconds(time()); $start_time = $array[0][0] * 3600 + $array[0][1] * 60 + $nowTime; $end_time = $array[1][0] * 3600 + $array[1][1] * 60 + $nowTime; - //if (time() >= $start_time && time() < $start_time) { + if (time() >= $start_time && time() < $start_time) { $quest->triggerQuest(QUEST_ACTIVITY_GAME, 3, 1, $account_id); - //} + } echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -431,6 +429,10 @@ class RoleController{ ':coin_num' => $coin_num + $rowUser['coin_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } echo json_encode(array( 'errcode' => 0, diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index c1b50e9..0b3a8dd 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -184,10 +184,10 @@ class SignController{ ':fragment_status' => 0, ':modify_time' => time() )); - } - if (!$ret) { - die(); - return; + if (!$ret) { + die(); + return; + } } } } else { @@ -227,6 +227,9 @@ class SignController{ ':fragment_num' => $item_num + $rowSkin['fragment_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + } } public function signReward() @@ -288,6 +291,10 @@ class SignController{ ':coin_num' => $num + $row2['coin_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + return; + } } else if($item_id > 13000 && $item_id < 14000){ $this->addReward($item_id, $num, $account_id); } diff --git a/webapp/controller/SupplyBoxController.class.php b/webapp/controller/SupplyBoxController.class.php index 196ffb2..4e1b939 100644 --- a/webapp/controller/SupplyBoxController.class.php +++ b/webapp/controller/SupplyBoxController.class.php @@ -98,12 +98,11 @@ class SupplyBoxController{ )); foreach ($rows as $row) { if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['last_buy_time']) > 0) { - $ret = $conn->execScript('UPDATE supplybox SET buy_times=:buy_times, last_buy_time=:time, modify_time=:modify_time ' . + $ret = $conn->execScript('UPDATE supplybox SET free_times=0, buy_times=0, last_buy_time=:time, modify_time=:modify_time ' . ' WHERE accountid=:accountid AND box_id=:box_id;', array( ':accountid' => $account_id, ':box_id' => $row['box_id'], - ':buy_times' => 0, ':time' => time(), ':modify_time' => time() )); @@ -114,8 +113,8 @@ class SupplyBoxController{ } array_push($box_list, array( 'box_id' => $row['box_id'], - 'box_num' => $row['box_num'], - 'buy_times' => $row['buy_times'] + 'buy_times' => $row['buy_times'], + 'free_times' => $row['free_times'] )); } } @@ -170,12 +169,13 @@ class SupplyBoxController{ phpcommon\sendError(ERR_USER_BASE + 2, '没有这个宝箱'); return; } else if ($free_open == 1) { - $ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time, create_time, modify_time) ' . - ' VALUES(:accountid, :box_id, 0, 0, 0, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, box_id=:box_id, box_num=0, buy_times=0, last_buy_time=0, modify_time=:modify_time;', + $ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, buy_times, free_times, last_buy_time, create_time, modify_time) ' . + ' VALUES(:accountid, :box_id, 0, 1, :last_buy_time, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:accountid, box_id=:box_id, buy_times=0, free_times=1, last_buy_time=:last_buy_time, modify_time=:modify_time;', array( ':accountid' => $account_id, ':box_id' => $box_id, + ':last_buy_time' => time(), ':create_time' => time(), ':modify_time' => time() )); @@ -185,18 +185,21 @@ class SupplyBoxController{ } } } - if ($free_open == 0) { - if ($row['box_num'] <= 0) { - phpcommon\sendError(ERR_USER_BASE + 3, '宝箱数量不足'); + 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; } - $box_num = $row['box_num'] - 1; - $ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num, modify_time=:modify_time ' . + $free_times = $row['free_times'] + 1; + $ret = $conn->execScript('UPDATE supplybox SET free_times=:free_times, last_buy_time=:last_buy_time, modify_time=:modify_time ' . ' WHERE accountid=:accountid AND box_id=:box_id;', array( ':accountid' => $account_id, ':box_id' => $box_id, - ':box_num' => $box_num, + ':free_times' => $free_times, + ':last_buy_time' => time(), ':modify_time' => time() )); if (!$ret) { @@ -312,14 +315,12 @@ class SupplyBoxController{ ':coin_num' => $row['coin_num'] - $s['price'], ':modify_time' => time() )); - $ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time, create_time, modify_time) ' . - ' VALUES(:accountid, :box_id, :box_num, :buy_times, :last_buy_time, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, box_id=:box_id, box_num=:box_num, buy_times=:buy_times, last_buy_time=0, modify_time=:modify_time;', + $ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, buy_times, free_times, last_buy_time, create_time, modify_time) ' . + ' VALUES(:accountid, :box_id, 1, 0, :last_buy_time, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:accountid, box_id=:box_id, buy_times=1, free_times=0, last_buy_time=0, modify_time=:modify_time;', array( ':accountid' => $account_id, ':box_id' => $box_id, - ':box_num' => 1, - ':buy_times' => 1, ':last_buy_time' => time(), ':create_time' => time(), ':modify_time' => time() @@ -345,15 +346,12 @@ class SupplyBoxController{ ':coin_num' => $row1['coin_num'] - ($s['price'] * pow($s['parameter'], ($row['buy_times']))), ':modify_time' => time() )); - $buy_times = $row['buy_times'] + 1; - $box_num = $row['box_num'] + 1; - $ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num, buy_times=:buy_times, last_buy_time=:time, modify_time=:modify_time ' . + $ret = $conn->execScript('UPDATE supplybox SET buy_times=:buy_times, last_buy_time=:time, modify_time=:modify_time ' . ' WHERE accountid=:accountid AND box_id=:box_id;', array( ':accountid' => $account_id, ':box_id' => $box_id, - ':box_num' => $box_num, - ':buy_times' => $buy_times, + ':buy_times' => $row['buy_times'] + 1, ':time' => time(), ':modify_time' => time() )); @@ -388,6 +386,9 @@ class SupplyBoxController{ ':fragment_num' => $item_num + $rowSkin['fragment_num'], ':modify_time' => time() )); + if (!$ret) { + die(); + } } public function supplyReward() @@ -429,7 +430,7 @@ class SupplyBoxController{ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - )); + )); } } ?> diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index 24d8e22..029f138 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -93,29 +93,29 @@ class teamController{ $user_db_str = $r->get(TEAMID_KEY.$team_uuid); - if (empty($user_db_str)){ + if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } $user_db = json_decode($user_db_str, true); - if (empty($user_db)){ + if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1, 'session失效2'); return; } $member_num = count($user_db['member_list']); - if ($member_num >= 4){ + if ($member_num >= 4) { phpcommon\sendError(ERR_USER_BASE + 2,'队伍人数已满'); return; } $flag = 0; foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['account_id']){ + if ($member['account_id'] == $_REQUEST['account_id']) { $flag = 1; - break; + break; } } - if ($flag == 1){ + if ($flag == 1) { phpcommon\sendError(ERR_USER_BASE + 3,'已在队伍中'); return; } @@ -139,28 +139,28 @@ class teamController{ { $team_uuid = $_REQUEST['team_uuid']; $r = $this->getRedis($team_uuid); - if (!$r){ + if (!$r) { echo 'is null'; - }else{ + } else { $user_db_str = $r->get(TEAMID_KEY . $team_uuid); - if (empty($user_db_str)){ + if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } $user_db = json_decode($user_db_str, true); - if (empty($user_db)){ + if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效2'); return; } $flag = 0; foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['account_id']){ - if($member['idx'] != 1){ + if ($member['account_id'] == $_REQUEST['account_id']) { + if ($member['idx'] != 1) { phpcommon\sendError(ERR_USER_BASE + 4,'你不是队长'); return; } foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['member_id']){ + if ($member['account_id'] == $_REQUEST['member_id']) { $flag = $member['idx'] - 1; break; } @@ -173,7 +173,7 @@ class teamController{ $user_db['member_list'] = array_values($user_db['member_list']); $i = 1; - foreach ($user_db['member_list'] as &$memberlist){ + foreach ($user_db['member_list'] as &$memberlist) { $memberlist['idx'] = $i; $i++; } @@ -192,22 +192,22 @@ class teamController{ $team_uuid = $_REQUEST['team_uuid']; $r = $this->getRedis($team_uuid); - if (!$r){ + if (!$r) { echo 'is null'; - }else{ + } else { $user_db_str = $r->get(TEAMID_KEY . $team_uuid); - if (empty($user_db_str)){ + if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } $user_db = json_decode($user_db_str, true); - if (empty($user_db)){ + if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效2'); return; } $flag = 0; foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['account_id']){ + if ($member['account_id'] == $_REQUEST['account_id']) { $flag = $member['idx'] - 1; break; } @@ -216,7 +216,7 @@ class teamController{ $user_db['member_list'] = array_values($user_db['member_list']); $i = 1; - foreach ($user_db['member_list'] as &$memberlist){ + foreach ($user_db['member_list'] as &$memberlist) { $memberlist['idx'] = $i; $i++; } @@ -237,20 +237,20 @@ class teamController{ if (!$r){ echo 'is null'; - }else{ + } else { $user_db_str = $r->get(TEAMID_KEY . $team_uuid); - if (empty($user_db_str)){ + if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } $user_db = json_decode($user_db_str, true); - if (empty($user_db)){ + if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效2'); return; } foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['account_id']){ + if ($member['account_id'] == $_REQUEST['account_id']) { if($member['idx'] != 1){ phpcommon\sendError(ERR_USER_BASE + 4,'你不是队长'); return; @@ -272,23 +272,23 @@ class teamController{ $team_uuid = $_REQUEST['team_uuid']; $r = $this->getRedis($team_uuid); - if (!$r){ + if (!$r) { echo 'is null'; - }else{ + } else { $user_db_str = $r->get(TEAMID_KEY . $team_uuid); - if (empty($user_db_str)){ + if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return; } $user_db = json_decode($user_db_str, true); - if (empty($user_db)){ + if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效2'); return; } foreach ($user_db['member_list'] as $member) { - if ($member['account_id'] == $_REQUEST['account_id']){ - if($member['idx'] != 1){ + if ($member['account_id'] == $_REQUEST['account_id']) { + if($member['idx'] != 1) { phpcommon\sendError(ERR_USER_BASE + 4,'你不是队长'); return; }