From 52b14c01523cb30eeb25dfafeb751355ad770937 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 26 Aug 2019 23:10:28 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 1 + webapp/classes/AddReward.php | 3 - webapp/controller/PassController.class.php | 46 ++++++++--- webapp/controller/PayController.class.php | 24 +++--- webapp/controller/RankController.class.php | 27 +------ webapp/controller/RoleController.class.php | 6 +- .../ServerSwitchController.class.php | 6 +- webapp/controller/ShareController.class.php | 79 +++++++++++-------- webapp/controller/SignController.class.php | 14 +++- 9 files changed, 113 insertions(+), 93 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9ffc61c..a8d1bf4 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -76,6 +76,7 @@ CREATE TABLE `user` ( `season_time` int(11) NOT NULL DEFAULT '0' COMMENT '赛季结束时间', `free_coin` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费金币', `free_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费钻石', + `season_end_score` 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/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index 87fb81f..9708c67 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -61,7 +61,6 @@ class AddReward { public function addReward($item_id, $item_num, $account_id) { - error_log($item_id); $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); @@ -153,7 +152,6 @@ class AddReward { $item_id = 0; $item_num = 0; $conn = $this->getMysql($accountid); - error_log($itemid); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); die(); @@ -180,7 +178,6 @@ class AddReward { $item_id = $itemid; $item_num = 1; } else { - error_log(22222222222); $item_id = 10003; $item_num = $dprice; $this->addDiamond($item_id, $item_num, $accountid); diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index 106bc4c..d3e93e6 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -140,10 +140,12 @@ class PassController{ 'item_num' => $drop_multiply[1], )); $rank = $ii; - $max_rank_score = $seaPoint['max'] + 1; + $max_rank_score = $seaPoint['max'] + 1 - $seaPoint['min']; $rank_score = $row['integral'] - $seaPoint['min']; if ($seaPoint['max'] == -1) { $max_rank_score = $seaPoint['min']; + } else if ($seaPoint['min'] == 0) { + $max_rank_score = $seaPoint['max'] + 1; } } } @@ -156,6 +158,7 @@ class PassController{ $sum_score = 0; $pass_score = 0; $max_pass_score = 0; + $sum_point = 0; $item_list = array(); $seaReward_meta_table = require('../res/seasonReward@seasonReward.php'); for ($j = 1; $j <= count($seaReward_meta_table); $j++) { @@ -166,18 +169,33 @@ class PassController{ $drop_multiply = array(); $status = 0; $seaReward = $this->getSeasonReward($id - 1); - if ($row['score'] <= $seaReward['point']) { + $sum_point = $sum_point + $seaReward['point']; + if ($row['score'] <= $sum_point) { $level = $seaReward['level']; - $pass_score = $seaReward['point'] - $row['score']; + $pass_score = $row['score'] - $sum_point + $seaReward['point']; $max_pass_score = $seaReward['point']; - if ($id - 1 == 100) { - $pass_score = $row['score']; + if ($row['score'] == $sum_point) { + $level = $level + 1; + $s = $this->getSeasonReward($id); + $max_pass_score = $s['point']; + } else { + if ($id - 1 == 100) { + $pass_score = $row['score']; + } } break; } + + if ($seaReward['point'] == -1) { + $level = $seaReward['level']; + $pass_score = $row['score']; + $max_pass_score = $seaReward['point']; + break; + } } foreach ($seaReward_meta_table as $seaR) { //如果是最大等级,则返回上一级的最大值 + $status = 0; if ($seaR['point'] == -1) { $sea = $this->getSeasonReward($seaR['id'] - 1); $sum_score = $sea['point']; @@ -270,7 +288,7 @@ class PassController{ ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', array( ':accountid' => $account_id, - ':passid' => $$passid + ':passid' => $passid )); if ($rowPass) { if ($type == 1) { @@ -284,7 +302,7 @@ class PassController{ return; } } - $row = $conn->execQueryOne('SELECT integral, pass_status FROM user WHERE accountid=:accountid;', + $row = $conn->execQueryOne('SELECT score, pass_status FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); @@ -292,8 +310,8 @@ class PassController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } - - if ($seaReward['point'] > $row['integral']) { + $seaR = $this->getSeasonReward($passid - 1); + if ($seaR['point'] > $row['score']) { phpcommon\sendError(ERR_USER_BASE + 4, '没有达到通行证要求'); return; } @@ -322,9 +340,11 @@ class PassController{ //增加奖励 $drop_multiply = array(); if ($type == 1) { + $delim = ':'; $drop_multiply = explode($delim, $seaReward['active']); } if ($type == 2) { + $delim = ':'; $drop_multiply = explode($delim, $seaReward['honor']); } $addreward = new classes\AddReward(); @@ -386,7 +406,7 @@ class PassController{ return; } - $row = $conn->execQueryOne('SELECT integral, season_status FROM user WHERE accountid=:accountid;', + $row = $conn->execQueryOne('SELECT season_end_score, season_status FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); @@ -403,8 +423,8 @@ class PassController{ $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { $seaPoint = $this->getSeasonPoint($ii); - if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] - || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) + if ($row['season_end_score'] >= $seaPoint['min'] && $row['season_end_score'] <= $seaPoint['max'] + || $row['season_end_score'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { $delim = ':'; $drop_multiply = explode($delim, $seaPoint['reward']); @@ -418,7 +438,7 @@ class PassController{ $addreward = new classes\AddReward(); $addreward->addReward($r['item_id'], $r['item_num'], $account_id); } - $ret = $conn->execScript('UPDATE user SET integral=0, season_status=1, modify_time=:modify_time ' . + $ret = $conn->execScript('UPDATE user SET season_end_score=0, season_status=1, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index dadfaea..6ff938a 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -185,15 +185,7 @@ class PayController{ } } } - //免费金币钻石领取次数 - if ($diamond['coin_type'] == 0) { - if ($diamond['shop_type'] == 2) { - $times = $diamond['limit_num'] - $rowUser['free_coin']; - } - if ($diamond['shop_type'] == 1) { - $times = $diamond['limit_num'] - $rowUser['free_diamond']; - } - } + //开启结束时间 $sub_item = array(); $coin_icon = ''; $open_time = '-1'; @@ -201,6 +193,17 @@ class PayController{ if ($diamond['coin_type'] != 0) { $sub_item = $this->getItem($diamond['coin_type']); $coin_icon = $sub_item['icon']; + } else { + //免费金币钻石领取次数及有效时间 + if ($diamond['shop_type'] == 2) { + $times = $diamond['limit_num'] - $rowUser['free_coin']; + } + if ($diamond['shop_type'] == 1) { + $times = $diamond['limit_num'] - $rowUser['free_diamond']; + } + if ($times == 0) { + $end_time = phpcommon\getdayseconds(time()) + 24 * 3600; + } } if ($diamond['open_time'] != '-1') { if ($diamond['open_time'] != '1') { @@ -209,8 +212,7 @@ class PayController{ $open_time = $rowUser['create_time']; } $end_time = $open_time + $diamond['continue_time']; - if (time() > $end_time) { - $open_time = '-1'; + if (time() > $end_time || time() < $open_time) { $end_time = '-1'; } } diff --git a/webapp/controller/RankController.class.php b/webapp/controller/RankController.class.php index 8f79757..d13ac13 100644 --- a/webapp/controller/RankController.class.php +++ b/webapp/controller/RankController.class.php @@ -103,15 +103,6 @@ class RankController{ if ($i > 49) { break; } - /*$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); - for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); - if ($kill_db[$i][8] >= $seaPoint['min'] && $kill_db[$i][8] <= $seaPoint['max'] - || $seaPoint['max'] == -1) { - $rank = $ii; - $score = $kill_db[$i][8] - $seaPoint['min']; - } - }*/ if ($kill_db[$i][0] == $account_id) { $kill_rank = $i + 1; } @@ -124,8 +115,6 @@ class RankController{ 'harm' => $kill_db[$i][5], 'win_rate' => $kill_db[$i][6], 'win_game' => $kill_db[$i][7], - 'score' => $score, - 'level' => $rank, )); $i++; @@ -139,15 +128,6 @@ class RankController{ if ($i > 49) { break; } - /*$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); - for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); - if ($win_db[$i][8] >= $seaPoint['min'] && $win_db[$i][8] <= $seaPoint['max'] - || $seaPoint['max'] == -1) { - $rank = $ii; - $score = $win_db[$i][8] - $seaPoint['min']; - } - }*/ if ($win_db[$i][0] == $account_id) { $win_rank = $i + 1; } @@ -160,8 +140,6 @@ class RankController{ 'harm' => $win_db[$i][5], 'win_rate' => $win_db[$i][6], 'win_game' => $win_db[$i][7], - //'score' => $score, - //'level' => $rank, )); $i++; } @@ -174,14 +152,17 @@ class RankController{ if ($i > 49) { break; } + $score = 0; + $rank = 0; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { $seaPoint = $this->getSeasonPoint($ii); if ($integral_db[$i][8] >= $seaPoint['min'] && $integral_db[$i][8] <= $seaPoint['max'] - || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) + || $integral_db[$i][8] >= $seaPoint['min'] && $seaPoint['max'] == -1) { $rank = $ii; $score = $integral_db[$i][8] - $seaPoint['min']; + break; } } if ($integral_db[$i][0] == $account_id) { diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index a0e41f6..50346eb 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, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond) ' . - ' 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, 0, 0, 0, 0, 1, 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, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=0, free_coin=0, free_diamond=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, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score) ' . + ' 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, 0, 0, 0, 0, 1, 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, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=0, free_coin=0, free_diamond=0, season_end_score=0;', array( ':accountid' => $account_id, ':user_name' => $user_name, diff --git a/webapp/controller/ServerSwitchController.class.php b/webapp/controller/ServerSwitchController.class.php index e4066c3..3654055 100644 --- a/webapp/controller/ServerSwitchController.class.php +++ b/webapp/controller/ServerSwitchController.class.php @@ -28,14 +28,14 @@ class ServerSwitchController { public function getSwitch() { - if (SERVER_ENV != _ONLINE) { + /*if (SERVER_ENV != _ONLINE) { echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'payable' => 1 )); die(); - } + }*/ $payable = 0; /* 玩家第一天不开放 @@ -44,7 +44,7 @@ class ServerSwitchController { */ if (phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) { - $register_time = phpcommon\extractRegisterTimeSessionId($_REQUEST['session_id']); + $register_time = phpcommon\extractRegisterTimeFromSessionId($_REQUEST['session_id']); $nowtime = time(); if ($nowtime - $register_time > 3600 * 24) { if ($this->isForbidCity() && $nowtime - $register_time > 3600 * 24 * 2) { diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index 1b5389b..277a73b 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -105,6 +105,42 @@ class ShareController{ } } + protected function randBoxReward($drop_id, $times) + { + //随机奖励 + $item_list = array(); + for ($j = 0; $j < $times; $j++) { + $d = $this->getDrop($drop_id); + if (!$d) { + phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); + die(); + } + $item_id_array = $this->getExplode($d['item_id']); + $weight_sum = 0; + $keys = 0; + $item_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]; + } + $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; + } + } + $item_id = $item_id_array[$keys][0]; + $item_num = $item_num_array[$keys][0]; + array_push($item_list, array( + 'item_id' => $item_id, + 'item_num' => $item_num, + )); + } + return $item_list; + } public function keyBoxInfo() { @@ -122,12 +158,14 @@ class ShareController{ } $free = $_REQUEST['free']; $drop_id = 0; + //随机奖励 + $item_list = array(); if ($free != 0) { - $drop_id = 24002; $p = $this->getParameter(DIAMONDBOX10); + $item_list = $this->randBoxReward(24001, 10); } else { - $drop_id = 24001; $p = $this->getParameter(DIAMONDBOX); + $item_list = $this->randBoxReward(24001, 1); } $row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;', array( @@ -141,37 +179,6 @@ class ShareController{ $diamond_num = $p['param_value']; $this->subCoin($diamond_num, $account_id, $row['diamond_num']); $num = $row['diamond_num'] - $diamond_num; - //随机奖励 - $d = $this->getDrop($drop_id); - if (!$d) { - phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); - return; - } - $item_id_array = $this->getExplode($d['item_id']); - $weight_sum = 0; - $keys = 0; - $item_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(crc32($account_id . $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; - } - } - $item_id = $item_id_array[$keys][0]; - $item_num = $item_num_array[$keys][0]; - $item_list = array(); - array_push($item_list, array( - 'item_id' => $item_id, - 'item_num' => $item_num, - )); //保存开宝箱奖励 $boxreward_uuid = 'game2001api_boxreward_uuid:' . md5($_REQUEST['account_id']); $boxreward_list = array(); @@ -199,8 +206,10 @@ class ShareController{ $quest = new classes\Quest(); $quest->triggerQuest(71004, 1, 1, $account_id); $quest->triggerQuest(72004, 2, 1, $account_id); - $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $item_num, $account_id); + foreach ($item_list as $item) { + $addreward = new classes\AddReward(); + $addreward->addReward($item['item_id'], $item['item_num'], $account_id); + } echo json_encode(array( 'errcode' => 0, 'errmsg' => '', diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index 6323778..2237fde 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -120,6 +120,7 @@ class SignController{ if ($nowTime - phpcommon\getdayseconds($last_sign_time) > 0) { //每日刷新 $this->updateDaily($account_id); + $this->updateSeasonStatus($account_id); $passed_days = floor(($nowTime - phpcommon\getdayseconds($last_sign_time)) / (3600 * 24)); if ($passed_days > 7 - $last_sign_id) { //跨周时删除老数据 @@ -361,18 +362,27 @@ class SignController{ if (!$share_ret) { die(); } + } + protected function updateSeasonStatus($account_id) + { + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + die(); + } //刷新赛季奖励状态 - $rowUser = $conn->execQueryOne('SELECT season_time, pass_status ' . + $rowUser = $conn->execQueryOne('SELECT season_time, pass_status, integral ' . ' FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); if (time() > $rowUser['season_time']) { - $user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, modify_time=:modify_time ' . + $user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, integral=0, season_end_score=:season_end_score, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, + ':season_end_score' => $rowUser['integral'], ':modify_time' => time() )); if (!$user_ret) {