From d48f40660e5d438540c4be4b7dbc8a63cb3f7ede Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 6 Apr 2023 20:31:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E5=AE=9D=E7=AE=B1=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BaseAuthedController.class.php | 20 +++++++++++++++++++ webapp/controller/BattleController.class.php | 14 +------------ webapp/mt/Item.php | 2 ++ webapp/services/AwardService.php | 17 ++++++++++++---- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 58bb676e..c585717b 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -463,6 +463,11 @@ class BaseAuthedController extends BaseController { $propertyService->addChip(); } break; + case mt\Item::RANDOM_BOX_TYPE: + { + $this->_openRandomBox($itemMeta,$awardService,$propertyService); + } + break; default: { $this->_addLog('additems', 'invalid_item', array( @@ -489,6 +494,21 @@ class BaseAuthedController extends BaseController { } } + public function _openRandomBox($itemMeta,$awardService,$propertyService){ + if ($itemMeta['include_item_id']) { + $includeItemIds = explode('|', $itemMeta['include_item_id']); + $key = array_rand($includeItemIds,1); + + $items = array( + array( + 'item_id' => $includeItemIds[$key] , + 'item_num' => 1 + ) + ); + $this->_addItems($items,$awardService,$propertyService); + } + } + public function _addTryUsingItems($items) { foreach ($items as $item) { diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index f6888313..ed711803 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -186,19 +186,7 @@ class BattleController extends BaseAuthedController { // $this->_rspData($data); $this->_rspOk(); } - - public function test(){ -// echo "当前时间=>" . time() . '|' . date('Y-m-d H:i:s',time()) ; -// echo "当天时间=>" . $this->_getDaySeconds(time()) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())); -// echo "下一天时间=>" . ($this->_getDaySeconds(time())+3600*24) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())+3600*24); -// echo "当周时间=>" . $this->_getMondaySeconds() . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds()); -// echo "下周时间=>" . ($this->_getMondaySeconds() + 7*24*3600) . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds() + 7*24*3600); -// $this->switchAccount('james'); -// $user = $this->_getOrmUserInfo(); -// print_r($user); - - } - + /* http post php://input diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index 65561bbc..e88e82ad 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -94,6 +94,8 @@ class Item { const PARACHUTE_TYPE = 16; const CHIP_BOX_TYPE = 17; const RING_TYPE = 19; + const EMOJI_TYPE = 20; + const RANDOM_BOX_TYPE = 21; const FUNC_RENAME_CARD_SUBTYPE = 1; const MATERIAL_CHIP_SUBTYPE = 3; diff --git a/webapp/services/AwardService.php b/webapp/services/AwardService.php index ea7d0b9f..ed099262 100644 --- a/webapp/services/AwardService.php +++ b/webapp/services/AwardService.php @@ -2,6 +2,8 @@ namespace services; +use mt\Item; + class AwardService extends BaseService { private $items = array(); @@ -14,10 +16,17 @@ class AwardService extends BaseService { return; } } - array_push($this->items, array( - 'item_id' => $itemId, - 'item_num' => $itemNum - )); + $itemMeta = Item::get($itemId); + if (!in_array( + array( + Item::RANDOM_BOX_TYPE, + ), $itemMeta['type'])){ + array_push($this->items, array( + 'item_id' => $itemId, + 'item_num' => $itemNum + )); + } + } public function toDto()