From 969e60793aba9a74dcd45fbad704fa393e30a963 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2019 13:37:28 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 1 + tools/rankserver/app.py | 9 +- webapp/bootstrap/config_loader.php | 6 + webapp/bootstrap/init.php | 1 + webapp/classes/AddReward.php | 38 ++++-- .../controller/ActivityController.class.php | 69 ++++++++--- webapp/controller/EquipController.class.php | 7 -- webapp/controller/HangController.class.php | 19 +-- webapp/controller/QuestController.class.php | 83 ++++++++++++- webapp/controller/RoleController.class.php | 115 +++++++++++++----- webapp/controller/ShareController.class.php | 23 +++- webapp/controller/ShopController.class.php | 59 ++++++++- webapp/controller/SignController.class.php | 39 +++--- webapp/controller/SkinController.class.php | 73 +++++------ webapp/controller/TeamController.class.php | 2 +- 15 files changed, 380 insertions(+), 164 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 7e58503..aa1fd7c 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -64,6 +64,7 @@ CREATE TABLE `user` ( `shop_flush_times` int(11) NOT NULL DEFAULT '0' COMMENT '每日商店刷新次数', `kefu_status` int(11) NOT NULL DEFAULT '0' COMMENT '客服奖励状态(0:未领取,1:已领取)', `sign_sum` int(11) NOT NULL DEFAULT '0' COMMENT '签到总天数', + `box_num` int(11) NOT NULL DEFAULT '0' COMMENT '空投宝箱数量', PRIMARY KEY (`idx`), UNIQUE KEY `accountid` (`accountid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index 901fa86..d5ee69a 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -144,7 +144,6 @@ def dayReadMysqlData(rushtime): ' harm, win_times, game_times, idx FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx)) has_data = False - print(kill_list) for row in cursor: refreshData(row, kill_list, alive_list, harm_list, rate_list, win_list) temp_idx = int(row[8]) @@ -211,8 +210,6 @@ def readMysqlData(rushtime): ' harm, win_times, game_times, idx, modify_time FROM user ' ' WHERE modify_time > %s AND idx > %s LIMIT 0, 1000' % (time.time() - 300, last_idx)) has_data = False - print(3333333) - print(kill_list) for row in cursor: for rowKill in kill_list: if (rowKill[0] == row[0]): @@ -257,8 +254,8 @@ if __name__ == "__main__": lambda : readMysqlData(conf['rushtime']) ) - conf['rushtime'] = 17 * 3600 - tornado.ioloop.IOLoop.current().call_later(getDaySeconds(time.time(), 1) + conf['rushtime'], - lambda : dayReadMysqlData(conf['rushtime']) + conf['day_rushtime'] = 17 * 3600 + tornado.ioloop.IOLoop.current().call_later(getDaySeconds(time.time(), 1) + conf['day_rushtime'], + lambda : dayReadMysqlData(conf['day_rushtime']) ) tornado.ioloop.IOLoop.current().start() diff --git a/webapp/bootstrap/config_loader.php b/webapp/bootstrap/config_loader.php index 4766583..202d993 100644 --- a/webapp/bootstrap/config_loader.php +++ b/webapp/bootstrap/config_loader.php @@ -152,5 +152,11 @@ function getRandrewardConfig($re_table, $re_id) $re_id = (int)$re_id; return array_key_exists($re_id, $re_table) ? $re_table[$re_id] : null; } + +function getRobotConfig($robot_table, $robot_id) +{ + $robot_id = (int)$robot_id; + return array_key_exists($robot_id, $robot_table) ? $robot_table[$robot_id] : null; +} checkMysqlConfig(); checkRedisConfig(); diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index 4e6a08c..dbb6649 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -71,6 +71,7 @@ define('MAX_BATTLE_REWARD', 40); //战斗额外奖励次数 define('MAX_SHOP_REFRESH', 41); //每日商店刷新次数 define('FREELOTTERY_TIME', 45); //免费抽奖次数 define('VIDEOLOTTERY_TIME', 46); //视频抽奖次数 +define('REWARD_TIMES', 54); //看视频奖励倍数 require 'config_loader.php'; diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index 3ed8ac0..d510a85 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -46,16 +46,34 @@ class AddReward { ':accountid' => $account_id, ':fragment_id' => $item_id )); - $ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, modify_time=:modify_time ' . - ' WHERE accountid=:accountid AND fragment_id=:fragment_id;', - array( - ':accountid' => $account_id, - ':fragment_id' => $item_id, - ':fragment_num' => $item_num + $rowSkin['fragment_num'], - ':modify_time' => time() - )); - if (!$ret) { - die(); + if (!$rowSkin) { + $ret = $conn->execScript('INSERT INTO skin(accountid, skin_id, skin_status, fragment_id, fragment_num, active_time, fragment_status, skin_type, skin_level, skin_experience_level, skin_experience_type, create_time, modify_time) ' . + ' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, 0, 0, 0, :skin_type, 1, 0, 0, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, skin_id=:skin_id, skin_status=:skin_status, fragment_id=:fragment_id, fragment_num=0, active_time=0, fragment_status=0, skin_type=:skin_type, skin_level=1, skin_experience_level=0, skin_experience_type=0, modify_time=:modify_time;', + array( + ':account_id' => $account_id, + ':skin_id' => $item_id + 1000, + ':skin_status' => 2, + ':fragment_id' => $item_id, + ':skin_type' => 1, + ':create_time' => time(), + ':modify_time' => time() + )); + if(!$ret){ + die(); + } + } else { + $ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid AND fragment_id=:fragment_id;', + array( + ':accountid' => $account_id, + ':fragment_id' => $item_id, + ':fragment_num' => $item_num + $rowSkin['fragment_num'], + ':modify_time' => time() + )); + if (!$ret) { + die(); + } } } else if ($item_id == 10002) { $rowkey = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;', diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 7f9d082..14bb278 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -79,6 +79,7 @@ class ActivityController{ 'item_id' => $lot_conf['item_id'], 'num' => $lot_conf['num'], 'weight' => $lot_conf['weight'], + 'quailty' => $lot_conf['quailty'], 'jilv' => $lot_conf['jilv'], ); return $l; @@ -160,6 +161,7 @@ class ActivityController{ $r -> set($draw_uuid, json_encode($draw_db)); $r -> pexpire($draw_uuid, 1000 * 3600 * 24); } else { + $draw_db = json_decode($user_db_str, true); $rowTime = $conn->execQueryOne('SELECT modify_time FROM activity WHERE accountid=:accountid;', array( ':accountid' => $account_id @@ -182,6 +184,7 @@ class ActivityController{ array_push($draw_list, array( 'item_id' => $draw['item_id'], 'item_num' => $draw['item_num'], + 'quailty' => $draw['quailty'], )); } } @@ -229,7 +232,8 @@ class ActivityController{ } $random = Rand(0, $weight_sum); $weight = 0; - for ($ii = 0; $ii < count($g_conf_lot_cluster); $ii++) { + $key = 0; + for ($ii = 1; $ii <= count($g_conf_lot_cluster); $ii++) { $l = $this->getLottery($ii); $weight += $l['jilv']; if ($weight > $random) { @@ -253,7 +257,7 @@ class ActivityController{ return; } foreach ($user_db['draw_list'] as $draw) { - if ($draw['key'] == $key + 1) { + if ($draw['key'] == $key - 1) { $item_id = $draw['item_id']; $item_num = $draw['item_num']; $flag = 1; @@ -308,14 +312,6 @@ class ActivityController{ //增加奖励 $addreward = new classes\AddReward(); $addreward->addReward($item_id, $item_num, $account_id); - //刷新奖励 - $draw_list = $this->randomReward(); - $draw_db = array( - 'draw_uuid' => $draw_uuid, - 'draw_list' => $draw_list, - ); - $r -> set($draw_uuid, json_encode($draw_db)); - $r -> pexpire($draw_uuid, 1000 * 3600 * 24); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', @@ -347,8 +343,10 @@ class ActivityController{ return; } //增加奖励 + $p = $this->getParameter(REWARD_TIMES); + $times = $p['value'] - 1; $addreward = new classes\AddReward(); - $addreward->addReward($row['item_id'], $row['item_num'], $account_id); + $addreward->addReward($row['item_id'], $row['item_num'] * $times, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', @@ -381,12 +379,15 @@ class ActivityController{ } $item_id_array = $this->getExplode($l['item_id']); $num_array = $this->getExplode($l['num']); + $quailty_array = $this->getExplode($l['quailty']); $item_id = $item_id_array[$key][0]; $item_num = $num_array[$key][0]; + $quailty = $quailty_array[$key][0]; array_push($draw_list, array( - 'key' => $i, + 'key' => $i - 1, 'item_id' => $item_id, 'item_num' => $item_num, + 'quailty' => $quailty, )); } return $draw_list; @@ -467,6 +468,7 @@ class ActivityController{ } foreach ($user_db['randreward_list'] as $randreward) { //增加奖励 + error_log($randreward['item_num']); $addreward = new classes\AddReward(); $addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id); } @@ -501,10 +503,12 @@ class ActivityController{ phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } + $p = $this->getParameter(REWARD_TIMES); + $times = $p['value']; foreach ($user_db['randreward_list'] as $randreward) { //增加奖励 $addreward = new classes\AddReward(); - $addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id); + $addreward->addReward($randreward['item_id'], $randreward['item_num'] * $times, $account_id); } echo json_encode(array( 'errcode' => 0, @@ -557,7 +561,23 @@ class ActivityController{ phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } - + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $row = $conn->execQueryOne('SELECT box_num FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + if ($row['box_num'] <= 0) { + phpcommon\sendError(ERR_USER_BASE + 2, '今日开箱子次数已用完'); + return; + } $airReward_uuid = 'game2001api_airReward_uuid:' . md5($_REQUEST['account_id']); $airReward_list = array(); $r = $this->getRedis($airReward_uuid); @@ -566,6 +586,8 @@ class ActivityController{ return; } $user_db_str = $r->get($airReward_uuid); + $airReward_num = 0; + $last_time = 0; if (empty($user_db_str)) { $airReward_list = $this->getRandomAirReward(); $airReward_db = array( @@ -575,6 +597,8 @@ class ActivityController{ $r -> set($airReward_uuid, json_encode($airReward_db)); $r -> pexpire($airReward_uuid, 1000 * 60); } else { + $user_db = json_decode($user_db_str, true); + unset($user_db['airReward_list']); $airReward_list = $this->getRandomAirReward(); $airReward_db = array( 'airReward_uuid' => $airReward_uuid, @@ -583,6 +607,17 @@ class ActivityController{ $r -> set($airReward_uuid, json_encode($airReward_db)); $r -> pexpire($airReward_uuid, 1000 * 60); } + $ret = $conn->execScript('UPDATE user SET box_num=:box_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':box_num' => $row['box_num'] - 1, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } foreach ($airReward_list as $airReward) { //增加奖励 $addreward = new classes\AddReward(); @@ -605,7 +640,6 @@ class ActivityController{ phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } - $airReward_uuid = 'game2001api_airReward_uuid:' . md5($_REQUEST['account_id']); $airReward_list = array(); $r = $this->getRedis($airReward_uuid); @@ -623,15 +657,16 @@ class ActivityController{ phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } + $p = $this->getParameter(REWARD_TIMES); + $times = $p['value'] - 1; foreach ($user_db['airReward_list'] as $airReward) { //增加奖励 $addreward = new classes\AddReward(); - $addreward->addReward($airReward['item_id'], $airReward['item_num'], $account_id); + $addreward->addReward($airReward['item_id'], $airReward['item_num'] * $times, $account_id); } echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', - 'item_list' => $airReward_list )); } diff --git a/webapp/controller/EquipController.class.php b/webapp/controller/EquipController.class.php index 1c08865..30d6ca2 100644 --- a/webapp/controller/EquipController.class.php +++ b/webapp/controller/EquipController.class.php @@ -218,10 +218,6 @@ class EquipController{ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - /*'equip_id' => $equip_id, - 'equip_level' => $equip_level, - 'equip_time' => 0, - 'coin_num' => -($e['equip_cost'] * ceil($equip_level / 5) + $e['cost_int'])*/ )); } @@ -288,9 +284,6 @@ class EquipController{ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - /*'equip_id' => $equip_id, - 'equip_level' => $e['max_lv'], - 'equip_time' => time() + $time,*/ )); } } diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php index 9e4f2dc..f722a3e 100644 --- a/webapp/controller/HangController.class.php +++ b/webapp/controller/HangController.class.php @@ -68,7 +68,8 @@ class HangController{ $num = floor($p_time_limit['param_value'] / 5 * $p_num['param_value']); } if ($weight != 0) { - $times = $this->getRewardTimes($num); + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; $num = $num * $times; } $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', @@ -145,21 +146,5 @@ class HangController{ 'num' => $num )); } - - protected function getRewardTimes($coin_num) - { - $g_conf_reward_cluster = require('../res/rewardTimes@rewardTimes.php'); - $times = 1; - $reward_conf = array(); - for ($i = 0; $i < 4; $i++) { - $reward_id = $i + 91000; - $reward_conf = getRewardTimesConfig($g_conf_reward_cluster, $reward_id); - if ((int)$coin_num >= $reward_conf['minGold'] && (int)$coin_num <= $reward_conf['maxGold']) { - $times = $reward_conf['times']; - break; - } - } - return $times; - } } ?> diff --git a/webapp/controller/QuestController.class.php b/webapp/controller/QuestController.class.php index 3fe51b5..2bf3309 100644 --- a/webapp/controller/QuestController.class.php +++ b/webapp/controller/QuestController.class.php @@ -33,6 +33,18 @@ class QuestController{ return $q; } + protected function getParameter($para_id) + { + $parameter_meta_cluster = require('../res/parameter@parameter.php'); + $parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id); + $p = array( + 'id' => $parameter_meta['id'], + 'name' => $parameter_meta['param_name'], + 'value' => $parameter_meta['param_value'], + ); + return $p; + } + protected function getTaskReward($taskReward_id) { $g_conf_taskReward_cluster = require('../res/taskReward@taskReward.php'); @@ -292,6 +304,70 @@ class QuestController{ )); } + public function doubleQuestReward() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $quest_id = $_REQUEST['quest_id']; + $quest_type = $_REQUEST['type']; + $p = $this->getParameter(REWARD_TIMES); + $times = $p['value'] - 1; + //发奖励 + if ($quest_type == 0) { + $t = $this->getTaskReward($quest_id); + if (!$t) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务'); + return; + } + $d = $this->getDrop($t['reward']); + if (!$d) { + phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); + return; + } + $weight_sum = 0; + $weight_array = $this->getExplode($d['weight']); + for ($i = 0; $i < count($weight_array); $i++) { + $weight_sum += $weight_array[$i][0]; + } + + $random = Rand(0, $weight_sum); + $weight = 0; + for ($i = 0; $i < count($weight_array); $i++) { + $weight += $weight_array[$i][0]; + if ($weight > $random) { + $key = $i; + break; + } + } + $item_id_array = $this->getExplode($d['item_id']); + $num_array = $this->getExplode($d['num']); + $item_id = $item_id_array[$key][0]; + $item_num = $num_array[$key][0] * $times; + $addreward = new classes\AddReward(); + $addreward->addReward($item_id, $item_num, $account_id); + } else { + $q = $this->getQuest($quest_id); + if (!$q) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务'); + return; + } + $array = $this->getExplode($q['reward']); + $reward_id = $array[0][0]; + $reward_num = $array[0][1] * $times; + $addreward = new classes\AddReward(); + $addreward->addReward($reward_id, $reward_num, $account_id); + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } + public function submitQuest() { $account_id = $_REQUEST['account_id']; @@ -303,11 +379,6 @@ class QuestController{ } $quest_id = $_REQUEST['quest_id']; $quest_type = $_REQUEST['type']; - $double = $_REQUEST['double']; - $reward_times = 1; - if ($double == 1) { - $reward_times = 2; - } $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); @@ -369,7 +440,7 @@ class QuestController{ $item_id_array = $this->getExplode($d['item_id']); $num_array = $this->getExplode($d['num']); $item_id = $item_id_array[$key][0]; - $item_num = $num_array[$key][0] * $reward_times; + $item_num = $num_array[$key][0]; array_push($item_list, array( 'item_id' => $item_id, 'item_num' => $item_num, diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 2e3a6d7..28537a4 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -100,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, battle_re_times, shop_flush_times, kefu_status, sign_sum) ' . - ' 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, 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, shop_flush_times=0, kefu_status=0, sign_sum=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, shop_flush_times, kefu_status, sign_sum, box_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, 0, 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, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0;', array( ':accountid' => $account_id, ':user_name' => $user_name, @@ -129,7 +129,8 @@ class RoleController{ 'first_fight' => 0, 'collect_status' => 0, 'keys_num' => 0, - 'kefu_status' => 0 + 'kefu_status' => 0, + 'box_num' => 0 )); } else { echo json_encode(array( @@ -148,6 +149,7 @@ class RoleController{ 'collect_status' => $row['collect_status'], 'keys_num' => $row['keys_num'], 'kefu_status' => $row['kefu_status'], + 'box_num' => $row['box_num'] )); } } @@ -190,7 +192,6 @@ class RoleController{ if (!$map_tpl_name) { $map_tpl_name = ''; } - $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id @@ -214,7 +215,12 @@ class RoleController{ if ($add_HP_his < $row['add_HP_his']) { $add_HP_his = $row['add_HP_his']; } - $ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, integral=:integral, modify_time=:modify_time, first_fight=1 ' . + //添加空投箱 + $box_num = $row['box_num']; + if ($row['box_num'] + 1 <= 20) { + $box_num = $row['box_num'] + 1; + } + $ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, integral=:integral, modify_time=:modify_time, first_fight=1, box_num=:box_num ' . ' WHERE accountid=:accountid;', array( ':game_times' => $row['game_times'] + 1, @@ -230,7 +236,8 @@ class RoleController{ ':accountid' => $account_id, ':coin_num' => $row['coin_num'] + $coin_num, ':integral' => $row['integral'] + $integral, - ':modify_time' => time() + ':modify_time' => time(), + ':box_num' => $box_num )); if (!$ret) { die(); @@ -291,8 +298,9 @@ class RoleController{ } } //额外奖励 - $times = $this->getRewardTimes($coin_num); - $extra_coin = $coin_num * ($times - 1); + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; + $extra_coin = $coin_num * $times; $d = $this->getDrop(24004); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); @@ -325,6 +333,7 @@ class RoleController{ } else { $extra_drop = '10001:' . $extra_coin . '|10002:1' . '|' . $skin_id . ':' . $skin_num; } + echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -465,8 +474,9 @@ class RoleController{ return; } $coin_num = $row['coin']; - $times = $this->getRewardTimes($coin_num); - $coin_num = $row['coin'] * ($times - 1); + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; + $coin_num = $row['coin'] * $times; $d = $this->getDrop(24004); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); @@ -522,22 +532,6 @@ class RoleController{ )); } - protected function getRewardTimes($coin_num) - { - $g_conf_reward_cluster = require('../res/rewardTimes@rewardTimes.php'); - $times = 1; - $reward_conf = array(); - for ($i = 0; $i < 4; $i++) { - $reward_id = $i + 91100; - $reward_conf = getRewardTimesConfig($g_conf_reward_cluster, $reward_id); - if ((int)$coin_num >= $reward_conf['minGold'] && (int)$coin_num <= $reward_conf['maxGold']) { - $times = $reward_conf['times']; - break; - } - } - return $times; - } - public function collectReward() { $account_id = $_REQUEST['account_id']; @@ -618,12 +612,14 @@ class RoleController{ $weight_array = $this->getExplode($d['weight']); $i = 0; $item_list = array(); + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; foreach ($weight_array as $item) { if ($item[$i][0] >= Rand(0, 10000)) { $item_id = $item_id_array[$i][0]; $item_num = $num_array[$i][0]; $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $item_num, $account_id); + $addreward->addReward($item_id, $item_num * $times, $account_id); } $i++; } @@ -632,5 +628,68 @@ class RoleController{ 'errmsg' => '', )); } + + public function getPreSettlementInfo() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $conn = $this->getMysql($account_id); + $pre_settlement_info = ''; + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'pre_settlement_info' => $pre_settlement_info + )); + } + + public function getRobotInfo() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $member_list = array(); + for ($i = 1; $i <= 100; $i++) { + $num = 1; + $robot_id = 1000 + $i; + $rob = $this->getRobot($robot_id, $num); + array_push ($member_list, array( + 'account_id' => $rob['id'], + 'name' => $rob['name'], + 'avatar_url' => $rob['avatar_url'], + )); + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'member_list' => $member_list + )); + } + + protected function getRobot($robot_id, $num) + { + $address = '../res/robot@robot' . $num . '.php'; + $robot_meta_cluster = require($address); + $robot_meta = getRobotConfig($robot_meta_cluster, $robot_id); + $rob = array( + 'id' => $robot_meta['id'], + 'name' => $robot_meta['name'], + 'avatar_url' => $robot_meta['avatar_url'], + 'sex' => $robot_meta['sex'] + ); + return $rob; + } } ?> diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index 4d0c789..f41a781 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -130,7 +130,8 @@ class ShareController{ for ($i = 0; $i < count($weight_array); $i++) { $weight_sum += $weight_array[$i][0]; } - srand(crc32($account_id . $row['keys_num'])); + $keys = $row['keys_num'] - 1; + srand(crc32($account_id . $keys)); $random = Rand(0, $weight_sum); $weight = 0; for ($i = 0; $i < count($weight_array); $i++) { @@ -162,6 +163,7 @@ class ShareController{ public function keyBoxReward() { + error_log('keyBoxReward'); $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); @@ -174,6 +176,7 @@ class ShareController{ phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } + $double = $_REQUEST['double']; $row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id @@ -183,6 +186,12 @@ class ShareController{ return; } //随机奖励 + $p = $this->getParameter(REWARD_TIMES); + $times = 1; + if ($double == 1) { + $times = $p['param_value'] - 1; + + } $free = $_REQUEST['free']; $drop_id = 0; if ($free != 0) { @@ -216,7 +225,7 @@ class ShareController{ $item_id = $item_id_array[$keys][0]; $item_num = $item_num_array[$keys][0]; $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $item_num, $account_id); + $addreward->addReward($item_id, $item_num * $times, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -369,7 +378,7 @@ class ShareController{ )); } - public function shareDoubleReward() + public function shareDobleReward() { $account_id = $_REQUEST['account_id']; //登录校验 @@ -411,8 +420,10 @@ class ShareController{ return; } $array = $this->getExplode($sh['rewards']); + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; $addreward = new classes\AddReward(); - $addreward->addReward($array[0][0], $array[0][1], $account_id); + $addreward->addReward($array[0][0], $array[0][1] * $times, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -540,8 +551,10 @@ class ShareController{ } $item_id = $item_id_array[$keys][0]; $item_num = $item_num_array[$keys][0]; + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $item_num, $account_id); + $addreward->addReward($item_id, $item_num * $times, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index f78c655..5151060 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -211,6 +211,61 @@ class ShopController{ )); } + + public function buyDoubleItem() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $shop_id = $_REQUEST['shop_id']; + $shop_uuid = $_REQUEST['shop_uuid']; + $item_id = 0; + $item_num = 0; + $price = 0; + $status = 0; + $flag = 0; + $r = $this->getRedis($shop_uuid); + $user_db_str = $r->get($shop_uuid); + if (empty($user_db_str)) { + phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); + return; + } + $user_db = json_decode($user_db_str, true); + if (empty($user_db)) { + phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); + return; + } + foreach ($user_db['shop_list'] as $shop) { + if ($shop['shop_id'] == $shop_id) { + $item_id = $shop['item_id']; + $item_num = $shop['item_num']; + $price = $shop['price']; + $status = $shop['status']; + $flag = 1; + break; + } + } + if ($flag == 0) { + phpcommon\sendError(ERR_USER_BASE + 3, '没有这个商品'); + return; + } + //增加奖励 + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value'] - 1; + $addreward = new classes\AddReward(); + $addreward->addReward($item_id, $item_num * $times, $account_id); + + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + )); + } + + public function flushShop() { $account_id = $_REQUEST['account_id']; @@ -314,8 +369,8 @@ class ShopController{ //确定折扣和价格 $it = $this->getItem($item_id); if ($s['tip'] != 3) { - $discount = $s['discount']; - $price = $it['price']; + $discount = 0; + $price = 0; } else { $keys = 0; $weight_sum = 0; diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index fa620f2..b0d8abb 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -88,7 +88,7 @@ class SignController{ return; } $conn = $this->getMysql($account_id); - $sign_days = 0; + $last_sign_id = 0; if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; @@ -100,30 +100,29 @@ class SignController{ )); $nowTime = phpcommon\getdayseconds(time()); if (!$rows) { - $sign_days = 1; + $last_sign_id = 1; //插入签到列表 - $this->insertSign($account_id, $sign_days); + $this->insertSign($account_id, $last_sign_id); //更新签到总天数 - $this->updateSignSum($account_id, $sign_days); + $this->updateSignSum($account_id, $last_sign_id); //完成签到任务 $quest = new classes\Quest(); $quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id); $quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id); } else { - $sign_time = 0; + $last_sign_time = 0; foreach ($rows as $row) { - if ($row['sign_time'] > $sign_time) { - $sign_time = $row['sign_time']; - $sign_days = $row['sign_id']; + if ($row['sign_id'] > $last_sign_id) { + $last_sign_time = $row['sign_time']; + $last_sign_id = $row['sign_id']; } } - if ($nowTime - phpcommon\getdayseconds($sign_time) > 0) { + if ($nowTime - phpcommon\getdayseconds($last_sign_time) > 0) { //每日刷新 - error_log($sign_days); $this->updateDaily($account_id); - $sign_num = floor(($nowTime - phpcommon\getdayseconds($sign_time)) / (3600 * 24)); - if ($sign_num > 7 - $sign_days) { - //每周更新一次 + $passed_days = floor(($nowTime - phpcommon\getdayseconds($last_sign_time)) / (3600 * 24)); + if ($passed_days > 7 - $last_sign_id) { + //跨周时删除老数据 $ret = $conn->execScript('DELETE from sign WHERE accountid=:accountid;', array( ':accountid' => $account_id, @@ -132,20 +131,19 @@ class SignController{ die(); return; } - $num = ($sign_num - 7 + $sign_days) % 7; - for ($i = $sign_days + 1; $i < $num + $sign_days + 1; $i++) { + $num = ($passed_days - 7 + $last_sign_id) % 7; + for ($i = $last_sign_id + 1; $i < $num + $last_sign_id + 1; $i++) { //插入补签列表 $this->insertSign($account_id, $i); } } else { - error_log($sign_num); - for ($i = $sign_days + 1; $i < $sign_num + $sign_days + 1; $i++) { + for ($i = $last_sign_id + 1; $i < $passed_days + $last_sign_id + 1; $i++) { //插入补签列表 $this->insertSign($account_id, $i); } } //更新签到总天数 - $this->updateSignSum($account_id, $sign_num); + $this->updateSignSum($account_id, $passed_days); //完成签到任务 $quest = new classes\Quest(); $quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id); @@ -224,9 +222,10 @@ class SignController{ $s = $this->getSign($day + 90000); $item_id = $s['item_id']; $num = $s['num']; + $p = $this->getParameter(REWARD_TIMES); + $times = $p['param_value']; if ($double == 1) { - $p_gold = $this->getParameter(DOUBLE_SIGN_IN); - $num = $num * $p_gold['param_value']; + $num = $num * $times; } $addreward = new classes\AddReward(); $addreward->addReward($item_id, $num, $account_id); diff --git a/webapp/controller/SkinController.class.php b/webapp/controller/SkinController.class.php index de10bbb..ec891ba 100644 --- a/webapp/controller/SkinController.class.php +++ b/webapp/controller/SkinController.class.php @@ -342,33 +342,9 @@ class SkinController{ die(); return; } - /*$skin_list = array(); - array_push($skin_list, array( - 'skin_id' => $row['skin_id'], - 'skin_status' => $skin_status, - 'fragment_num' => $row['fragment_num'], - 'active_time' => $row['active_time'], - 'skin_level' => $row['skin_level'], - 'skin_experience_type' => $row['skin_experience_type'] - )); - $row_exchange = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND skin_id=:skin_id;', - array( - ':accountid' => $account_id, - ':skin_id' => $exchangeskin_id, - )); - array_push($skin_list, array( - 'skin_id' => $row_exchange['skin_id'], - 'skin_status' => 0, - 'fragment_num' => $row_exchange['fragment_num'], - 'active_time' => $row_exchange['active_time'], - 'skin_level' => $row_exchange['skin_level'], - 'skin_experience_type' => $row_exchange['skin_experience_type'] - )); - */ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - //"skin_list" => $skin_list, )); } @@ -383,15 +359,6 @@ class SkinController{ } $conn = $this->getMysql($account_id); $skin_id = $_REQUEST['skin_id']; - $row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND skin_id=:skin_id;', - array( - ':accountid' => $account_id, - ':skin_id' => $skin_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 1,'没有这个角色'); - return; - } if(!$conn){ phpcommon\sendError(ERR_USER_BASE + 1,'没有这个角色'); return; @@ -401,6 +368,34 @@ class SkinController{ phpcommon\sendError(ERR_USER_BASE + 2,'没有这个皮肤'); return; } + $rowSkin = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND skin_id=:skin_id;', + array( + ':accountid' => $account_id, + ':skin_id' => $skin_id, + )); + if (!$rowSkin) { + $ret = $conn->execScript('INSERT INTO skin(accountid, skin_id, skin_status, fragment_id, fragment_num, active_time, fragment_status, skin_type, skin_level, skin_experience_level, skin_experience_type, create_time, modify_time) ' . + ' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, 0, 0, 0, :skin_type, 1, 0, 0, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, skin_id=:skin_id, skin_status=:skin_status, fragment_id=:fragment_id, fragment_num=0, active_time=0, fragment_status=0, skin_type=:skin_type, skin_level=1, skin_experience_level=0, skin_experience_type=0, modify_time=:modify_time;', + array( + ':account_id' => $account_id, + ':skin_id' => $skin_id, + ':skin_status' => 2, + ':fragment_id' => $skin_id - 1000, + ':skin_type' => 1, + ':create_time' => time(), + ':modify_time' => time() + )); + if(!$ret){ + die(); + return; + } + } + $row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND skin_id=:skin_id;', + array( + ':accountid' => $account_id, + ':skin_id' => $skin_id, + )); $time = 0; $ex_level = 0; $ex_type = 0; @@ -432,12 +427,6 @@ class SkinController{ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - /*'skin_id' => $row['skin_id'], - 'skin_status' => $row['skin_status'], - 'fragment_num' => $row['fragment_num'], - 'active_time' => time() + $time, - 'skin_level' => $ex_level, - 'skin_experience_type' => 2*/ )); } @@ -499,12 +488,6 @@ class SkinController{ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - /*'skin_id' => $row['skin_id'], - 'skin_status' => $row['skin_status'], - 'fragment_num' => $row['fragment_num'] - $debris_num, - 'active_time' => $row['active_time'], - 'skin_level' => $row['skin_level'] + 1, - 'skin_experience_type' => $row['skin_experience_type']*/ )); } } diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index b65b233..99102df 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -93,7 +93,7 @@ class TeamController{ $user_db_str = $r->get(TEAMID_KEY.$team_uuid); - + error_log($team_uuid); if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效1'); return;