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