diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index dfed480d..31ee7993 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -1019,6 +1019,11 @@ class BattleController extends BaseAuthedController { public function useBattleItem() { $itemId = getReqVal('item_id', 0); + $itemMeta = mt\Item::get($itemId); + if (!$itemMeta) { + $this->_rspErr(2, 'config error'); + return; + } $itemCount = Bag::getItemCount($itemId); if ($itemCount > 0) { Bag::decItem($itemId, 1); @@ -1417,9 +1422,9 @@ class BattleController extends BaseAuthedController { 'return_time' => myself()->_getNowTime(), ) ); - services\BattleBoxService::incAlreadyAllocBoxNum($row['phase'], - $row['createtime'], - -max(0, $allocBoxNum - $usedNum)); + services\BattleBoxService::incAlreadyAllocNum($row['phase'], + $row['createtime'], + -max(0, $allocBoxNum - $usedNum)); myself()->_rspOk(); } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index a3796dc7..fb2ca844 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -498,11 +498,25 @@ class UserController extends BaseAuthedController { ) )) { $itemNum = myself()->_callModelStatic('Bag', 'getItemCount', $itemId); + $hasLuckySymbol = myself()->_callModelStatic('LuckySymbol', 'hasLuckySymbol'); + if ($itemMeta['type'] == mt\Item::FUNC_TYPE && + $itemMeta['sub_type'] == mt\Item::LUCKY_SYMBOL_SUBTYPE && + !$hasLuckySymbol) { + $this->_decItems(array( + array( + 'item_id' => $itemMeta['id'], + 'item_num' => 1 + ) + )); + myself()->_callModelStatic('LuckySymbol', 'add'); + $hasLuckySymbol = 1; + } myself()->_rspData(array( 'item_id' => $itemId, 'item_num' => $itemNum, 'item_type' => $itemMeta['type'], - 'item_sub_type' => $itemMeta['sub_type'] + 'item_sub_type' => $itemMeta['sub_type'], + 'has_lucky_symbol' => $hasLuckySymbol, )); } else { myself()->_rspErr(1, 'item_id not found');