diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index c37578e..961c706 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -581,16 +581,56 @@ class RoleController{ $num_array = $this->getExplode($d['num']); $weight_array = $this->getExplode($d['weight']); $i = 0; - $mul = 1; - if ($_REQUEST['double'] != 0) { - $mul = 2; - } else { - $mul = 1; - } + $item_list = array(); 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] * $mul; + $item_num = $num_array[$i][0]; + $addreward = new classes\AddReward(); + $addreward->addReward($item_id, $item_num, $account_id); + array_push($item_list, array( + 'item_id' => $item_id, + 'item_num' => $item_num + )); + } + $i++; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_list' => $item_list + )); + } + + public function collectDoubleReward() + { + $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); + $record_list = array(); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $d = $this->getDrop(24003); + if (!$d) { + phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); + return; + } + $item_id_array = $this->getExplode($d['item_id']); + $num_array = $this->getExplode($d['num']); + $weight_array = $this->getExplode($d['weight']); + $i = 0; + $item_list = array(); + 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); } @@ -601,7 +641,5 @@ class RoleController{ 'errmsg' => '', )); } - - } ?>