diff --git a/doc/Role.py b/doc/Role.py index 2d79c05..537d460 100644 --- a/doc/Role.py +++ b/doc/Role.py @@ -80,14 +80,18 @@ class Role(object): ] }, { - 'desc': 'getFightReward', + 'desc': '获取战斗奖励getFightReward', 'group': 'Role', 'url': 'webapp/index.php?c=Role&a=getFightReward', 'params': [ _common.ReqHead(), + ['coin_num', 0, '货币数量'], + ['reward_id', 0, '奖励id'], + ['reward_num', 0, '奖励数量'], ], 'response': [ _common.RspHead(), + ['coin_num', 0, '货币数量'], ] }, { diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index e2e4af8..458fd55 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -356,22 +356,20 @@ class RoleController extends BaseAuthedController { public function getFightReward() { - $account_id = $_REQUEST['account_id']; $coin_num = $_REQUEST['coin_num']; $reward_id = $_REQUEST['reward_id']; $reward_num = $_REQUEST['reward_num']; + + $times = mt\Parameter::getVal('gameover_reward_times', 1) - 1; //为啥-1? $addreward = new classes\AddReward(); - $p = mt\Parameter::getOldParam(GAMEOVER_REWARD_TIMES); - $times = $p['param_value'] - 1; - $addreward = new classes\AddReward(); - $val = $addreward->getVipVal($account_id, 1); + $val = $addreward->getVipVal($this->getAccountId(), 1); $coin_num = floor($coin_num + $coin_num * $val / 100); - $addreward->addReward(10001, $coin_num * $times, $account_id, 0, 0); + $addreward->addReward(V_ITEM_GOLD, $coin_num * $times, $this->getAccountId(), 0, 0); if ($reward_id != 0) { - $addreward->addReward($reward_id, $reward_num * $times, $account_id, 0, 0); + $addreward->addReward($reward_id, $reward_num * $times, $this->getAccountId(), 0, 0); } - $coin_num = $addreward->getCoinNum($account_id); - echo json_encode(array( + $coin_num = $addreward->getCoinNum($this->getAccountId()); + $this->rspRawData(array( 'errcode' => 0, 'errmsg'=> '', 'coin_nums' => $coin_num, diff --git a/webapp/mt/Parameter.php b/webapp/mt/Parameter.php index ad90b1a..96305bc 100644 --- a/webapp/mt/Parameter.php +++ b/webapp/mt/Parameter.php @@ -30,6 +30,13 @@ class Parameter { return $meta; } + public static function getVal($name, $defVal) + { + self::mustBeNameHash(); + $meta = array_key_exists($id, self::$nameHash) ? self::$nameHash[$name] : null; + return $meta ? $meta['param_value'] : $defVal; + } + public static function getListValue($meta) { $values = explode("|", $meta['param_value']);