From 9b481b8c869a13022ec902df1d01c06dc0d7b721 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 5 Jun 2020 15:24:41 +0800 Subject: [PATCH] 1 --- webapp/bootstrap/config_loader.php | 6 ++ .../controller/GameOverController.class.php | 78 +++++++++++-------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/webapp/bootstrap/config_loader.php b/webapp/bootstrap/config_loader.php index 049e7bb..79d7b71 100644 --- a/webapp/bootstrap/config_loader.php +++ b/webapp/bootstrap/config_loader.php @@ -219,5 +219,11 @@ function getRecommendConfig($rec_table, $rec_id) $rec_id = (int)$rec_id; return array_key_exists($rec_id, $rec_table) ? $rec_table[$rec_id] : null; } + +function getRankRewardConfig($ran_table, $ran_id) +{ + $ran_id = (int)$ran_id; + return array_key_exists($ran_id, $ran_table) ? $ran_table[$ran_id] : null; +} checkMysqlConfig(); checkRedisConfig(); diff --git a/webapp/controller/GameOverController.class.php b/webapp/controller/GameOverController.class.php index a526eb4..8bca52a 100644 --- a/webapp/controller/GameOverController.class.php +++ b/webapp/controller/GameOverController.class.php @@ -93,6 +93,20 @@ class GameOverController{ } + protected function getRankReward($rank) + { + $rank_meta_table = require('../res/rankReward@rankReward.php'); + $rank_meta = getRankRewardConfig($rank_meta_table, $rank); + $d = array( + 'rank' => $rank_meta['rank'], + 'parameter' => $rank_meta['parameter'], + 'drop' => $rank_meta['drop'], + 'ad_drop' => $rank_meta['ad_drop'], + 'ad_num' => $rank_meta['ad_num'] + ); + return $d; + } + public function firstRewardInfo() { $account_id = $_REQUEST['account_id']; @@ -109,34 +123,35 @@ class GameOverController{ die(); return; } - $id = 12120; - $conn = $this->getMysql($account_id); - if (!$conn) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - die(); - return; - } - $row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:account_id;', - array( - ':account_id' => $account_id - )); - if ($row) { - $id = $row['id']; - } - $e = $this->getEquip($id); - if (!$e) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); - die(); - return; - } - $count = 3; - if ($e['upgrade_priority'] == 1) { - $count = 1; - } + $rank = $_REQUEST['rank']; + //$id = 12120; + // $conn = $this->getMysql($account_id); + // if (!$conn) { + // phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + // die(); + // return; + // } + // $row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:account_id;', + // array( + // ':account_id' => $account_id + // )); + // if ($row) { + // $id = $row['id']; + // } + // $e = $this->getEquip($id); + // if (!$e) { + // phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); + // die(); + // return; + // } + // $count = 3; + // if ($e['upgrade_priority'] == 1) { + // $count = 1; + // } //道具物品 $first_list = array(); - $first_list = $this->fixReward($first_list); - $first_list = $this->randomReward($first_list, $id, $count); + //$first_list = $this->fixReward($first_list); + $first_list = $this->randomReward($rank); $first_db = array( 'first_uuid' => $first_uuid, 'first_list' => $first_list, @@ -232,13 +247,14 @@ class GameOverController{ return $item_list; } - protected function randomReward($item_list, $id, $count) + protected function randomReward($rank) { //随机奖励 - $e = $this->getEquip($id); - $b = $this->getDrop($e['drop_id']); - - + //$e = $this->getEquip($id); + $r = $this->getRankReward($rank); + $b = $this->getDrop($r['ad_drop']); + $count = $r['ad_num']; + $item_list = array(); //$b = $this->getbox(6); //$count = 3; $item_id_array = $this->getExplode($b['item_id']);