This commit is contained in:
aozhiwei 2024-10-14 15:04:41 +08:00
parent 84c2c23ecd
commit 2c0f27156c

View File

@ -967,16 +967,7 @@ class BattleController extends BaseAuthedController {
} }
} }
if (count($member['battle_items']) > 0) { if (count($member['battle_items']) > 0) {
$hasBattleItems = true; $this->decBattleItems($r, $roomUuid, $info, $member);
$info['items'] = array();
array_push($info['items'], array(
'item_id' => 900007,
'item_num' => 10,
));
array_push($info['items'], array(
'item_id' => 902101,
'item_num' => 10,
));
} }
} }
array_push($teamInfo['members'], $info); array_push($teamInfo['members'], $info);
@ -991,7 +982,7 @@ class BattleController extends BaseAuthedController {
myself()->_rspData($data); myself()->_rspData($data);
} }
private function decBattleItem($r, $roomUuid, &$info, $member) private function decBattleItems($r, $roomUuid, &$info, $member)
{ {
$key = 'dec.battle.item.' . $roomUuid . ':' . myself()->_getAccountId(); $key = 'dec.battle.item.' . $roomUuid . ':' . myself()->_getAccountId();
$data = $r->get($key); $data = $r->get($key);
@ -1000,8 +991,10 @@ class BattleController extends BaseAuthedController {
foreach ($member['battle_items'] as $item) { foreach ($member['battle_items'] as $item) {
$itemCount = Bag::getItemCount($item['item_id']); $itemCount = Bag::getItemCount($item['item_id']);
if ($itemCount >= $item['item_num']) { if ($itemCount >= $item['item_num']) {
$data['item_id'] = $item['item_id']; array_push($data, array(
$data['item_num'] = $item['item_num']; 'item_id' => $item['item_id'],
'item_num' => $item['item_num'],
));
myself()->_decItems(array( myself()->_decItems(array(
array( array(
'item_id' => $item['item_id'], 'item_id' => $item['item_id'],
@ -1009,14 +1002,18 @@ class BattleController extends BaseAuthedController {
) )
)); ));
} else { } else {
$data['item_id'] = $item['item_id']; array_push($data, array(
$data['item_num'] = 0; 'item_id' => $item['item_id'],
'item_num' => 0,
));
} }
} }
$r->setPx($key, json_encode($data), 1000 * 60 * 30); $r->setPx($key, json_encode($data), 1000 * 60 * 30);
$info['items'] = $data;
} else { } else {
$info['items'] = json_decode($data, true); $info['items'] = json_decode($data, true);
} }
error_log(json_encode($info['items']));
} }
public function getMobaBattleData() public function getMobaBattleData()