This commit is contained in:
wangwei01 2019-07-04 18:56:09 +08:00
parent 3516aa0b31
commit 15241d9ed2

View File

@ -581,16 +581,56 @@ class RoleController{
$num_array = $this->getExplode($d['num']); $num_array = $this->getExplode($d['num']);
$weight_array = $this->getExplode($d['weight']); $weight_array = $this->getExplode($d['weight']);
$i = 0; $i = 0;
$mul = 1; $item_list = array();
if ($_REQUEST['double'] != 0) {
$mul = 2;
} else {
$mul = 1;
}
foreach ($weight_array as $item) { foreach ($weight_array as $item) {
if ($item[$i][0] >= Rand(0, 10000)) { if ($item[$i][0] >= Rand(0, 10000)) {
$item_id = $item_id_array[$i][0]; $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 = new classes\AddReward();
$addreward->addReward($item_id, $item_num, $account_id); $addreward->addReward($item_id, $item_num, $account_id);
} }
@ -601,7 +641,5 @@ class RoleController{
'errmsg' => '', 'errmsg' => '',
)); ));
} }
} }
?> ?>