From 8816392dd6f95ad8ac7b15628f8cc2b230e3a678 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 27 Mar 2020 14:35:23 +0800 Subject: [PATCH] 1 --- webapp/bootstrap/init.php | 1 + webapp/classes/AddReward.php | 3 - webapp/controller/RoleController.class.php | 173 ++++----------------- 3 files changed, 35 insertions(+), 142 deletions(-) diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index cd9ad86..d5c15b5 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -79,6 +79,7 @@ define('DIAMONDBOX10', 62); //钻石视频宝箱花费钻石数 define('REDLIMIT', 68); //红包上限 define('RECOMMEND_FOREVER_WEIGHT',85); //精选道具概率 define('RECOMMEND_TIME', 84); //道具精选时间 +define('GAMEOVER_REWARD_TIMES', 87); //战斗结束奖励倍数 require 'config_loader.php'; diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index b003980..23fccda 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -199,7 +199,6 @@ class AddReward { $status = $this->getStatus($item_id, $status,$accountid); } else if ($t == 1){ $status = 0; - error_log(11111111111111); $this->updateStatus($item_id, $accountid); } $ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, active_time, create_time, modify_time) ' . @@ -222,7 +221,6 @@ class AddReward { $item_id = 10003; $item_num = $price; $time = 0; - error_log(3333333333); $this->addDiamond($item_id, $item_num, $accountid); } else { $nowTime = $row['active_time']; @@ -241,7 +239,6 @@ class AddReward { $status = $this->getStatus($item_id, $status,$accountid); } else if ($t == 1){ $status = 0; - error_log(2222222222); $this->updateStatus($item_id, $accountid); } $ret = $conn->execScript('UPDATE bag SET active_time=:active_time, status=:status, modify_time=:modify_time ' . diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 0a35edd..9aa611e 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -30,6 +30,18 @@ class RoleController{ return $r; } + 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 getActivityRewardConfig($activityReward_id) { $g_conf_activityReward_cluster = require('../res/activityReward@activityReward.php'); @@ -74,19 +86,6 @@ class RoleController{ return $arr; } - - protected function getParameter($para_id) - { - $g_conf_para_cluster = require('../res/parameter@parameter.php'); - $para_conf = getParameterConfig($g_conf_para_cluster, $para_id); - $p = array( - 'id' => $para_conf['id'], - 'param_name' => $para_conf['param_name'], - 'param_value' => $para_conf['param_value'], - ); - return $p; - } - public function roleInfo() { $account_id = $_REQUEST['account_id']; @@ -261,7 +260,6 @@ class RoleController{ public function battleReport() { - error_log(111111111122222222222222221); $account_id = $_REQUEST['account_id']; //账号 $conn = $this->getMysql($account_id); if (!$conn) { @@ -417,42 +415,6 @@ class RoleController{ if ($team_status == 1) { $quest->triggerQuest(QUEST_DAY_TEAM, 1, 1, $account_id); } - //额外奖励 - $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, '没有这个奖励'); - return; - } - $skin_id_array = $this->getExplode($d['item_id']); - $weight_sum = 0; - $keys = 0; - $skin_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($room_uuid); - $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; - } - } - $extra_drop = ""; - $skin_id = $skin_id_array[$keys][0]; - $skin_num = $skin_num_array[$keys][0]; - $p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD); - if ($row['battle_re_times'] >= $p_battle_reward['param_value']) { - $extra_drop = '10001:' . $extra_coin; - } else { - $extra_drop = '10001:' . $extra_coin . '|10002:1' . '|' . $skin_id . ':' . $skin_num; - } echo json_encode(array( 'errcode' => 0, @@ -461,7 +423,6 @@ class RoleController{ 'alive_time_his' => $alive_time_his, 'harm_his' => $harm_his, 'add_HP_his' => $add_HP_his, - 'extra_drop' => $extra_drop )); } @@ -562,94 +523,6 @@ class RoleController{ )); } - public function fightReward() - { - $account_id = $_REQUEST['account_id']; - $room_uuid = $_REQUEST['room_uuid']; - //登录校验 - $login = loginVerify($account_id, $_REQUEST['session_id']); - if (!$login) { - phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); - return; - } - $conn = $this->getMysql($account_id); - $record_list = array(); - if (!$conn) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); - return; - } - $row = $conn->execQueryOne('SELECT * FROM history_record WHERE accountid=:accountid AND room_uuid=:room_uuid;', - array( - ':accountid' => $account_id, - ':room_uuid' => $room_uuid - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这场战斗记录'); - return; - } - - if ($row['status'] == 1) { - phpcommon\sendError(ERR_USER_BASE + 3, '战斗奖励已领取'); - return; - } - $coin_num = $row['coin']; - $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, '没有这个奖励'); - return; - } - $skin_id_array = $this->getExplode($d['item_id']); - $weight_sum = 0; - $keys = 0; - $skin_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($room_uuid); - $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; - } - } - $skin_id = $skin_id_array[$keys][0]; - $skin_num = $skin_num_array[$keys][0]; - $p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD); - $addreward = new classes\AddReward(); - $addreward->addReward(10001, $coin_num, $account_id); - $rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if ($rowUser['battle_re_times'] < $p_battle_reward['param_value']) { - $keys_num = $rowUser['keys_num'] + 1; - $battle_re_times = $rowUser['battle_re_times'] + 1; - $addreward->addReward($skin_id, $skin_num, $account_id); - $ret = $conn->execScript('UPDATE user SET battle_re_times=:battle_re_times, keys_num=:keys_num, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':keys_num' => $keys_num, - ':battle_re_times' => $battle_re_times, - ':modify_time' => time(), - ':accountid' => $account_id - )); - if (!$ret) { - die(); - return; - } - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - )); - } public function collectReward() { @@ -835,5 +708,27 @@ class RoleController{ $switch = json_decode($user_db_str, true); return $switch; } + + public function getFightReward() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $coin_num = $_REQUEST['coin_num']; + $addreward = new classes\AddReward(); + $p = $this->getParameter(GAMEOVER_REWARD_TIMES); + $times = $p['value'] - 1; + $addreward->addReward(10001, $coin_num * $times, $account_id, 0, 0); + $coin_num = $addreward->getCoinNum($account_id); + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + 'coin_nums' => $coin_num, + )); + } } ?>