From dc9a232395ea8560af28f9dbeca00728cd709d6f Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 5 Jun 2023 12:02:34 +0800 Subject: [PATCH] 1 --- webapp/controller/StarController.class.php | 37 +++++++++++++++------- webapp/mt/StarLevel.php | 17 ++++------ webapp/services/ChipPageService.php | 29 ++--------------- 3 files changed, 35 insertions(+), 48 deletions(-) diff --git a/webapp/controller/StarController.class.php b/webapp/controller/StarController.class.php index 4b112152..9bf9cddc 100644 --- a/webapp/controller/StarController.class.php +++ b/webapp/controller/StarController.class.php @@ -83,12 +83,19 @@ class StarController extends BaseAuthedController { $this->_rspErr(1, "Can't get it again"); return; } - $dropMeta = mt\Drop::get($meta['drop_id']); - if (!$dropMeta) { - $this->_rspErr(10, 'server internal error:' . $meta['drop_id']); - return; - } - $this->_scatterDrop('missionStar:' . $missionId, $dropMeta, $this->awardService, $this->propertyChgService); + $items = array( + array( + 'item_id' => $meta['item_id'], + 'item_num' => $meta['item_num'], + ) + ); + $this->_addItems($items,$this->awardService, $this->propertyChgService); +// $dropMeta = mt\Drop::get($meta['drop_id']); +// if (!$dropMeta) { +// $this->_rspErr(10, 'server internal error:' . $meta['drop_id']); +// return; +// } +// $this->_scatterDrop('missionStar:' . $missionId, $dropMeta, $this->awardService, $this->propertyChgService); MissionStar::add($meta['season_id'],$missionId); $this->_rspData(array( 'award' => $this->awardService->toDto(), @@ -105,11 +112,19 @@ class StarController extends BaseAuthedController { $missionStarDb = MissionStar::find($meta['season_id'],$meta['id']); if ($this->userInfo['star_num'] >= $target && !$missionStarDb){ //可领取 - $dropMeta = mt\Drop::get($meta['drop_id']); - if ($dropMeta) { - $this->_scatterDrop('missionStar:' . $meta['id'], $dropMeta, $this->awardService, $this->propertyChgService); - MissionStar::add($meta['season_id'],$meta['id']); - } + $items = array( + array( + 'item_id' => $meta['item_id'], + 'item_num' => $meta['item_num'], + ) + ); + $this->_addItems($items,$this->awardService, $this->propertyChgService); + MissionStar::add($meta['season_id'],$meta['id']); +// $dropMeta = mt\Drop::get($meta['drop_id']); +// if ($dropMeta) { +// $this->_scatterDrop('missionStar:' . $meta['id'], $dropMeta, $this->awardService, $this->propertyChgService); +// MissionStar::add($meta['season_id'],$meta['id']); +// } } } $this->_rspData(array( diff --git a/webapp/mt/StarLevel.php b/webapp/mt/StarLevel.php index a47b19be..a27bd386 100644 --- a/webapp/mt/StarLevel.php +++ b/webapp/mt/StarLevel.php @@ -34,18 +34,16 @@ class StarLevel return null; } - public static function getCurrent($num){ + public static function getMaxSlot($num){ $metaList = self::getDefaultList(); - $maxLen = count($metaList); - for ($i=0;$i<$maxLen;$i++){ - if ($num >= $metaList[$maxLen-1]['need_star_num']){ - return $metaList[$maxLen-1]; - } - if ($num >= $metaList[$i]['need_star_num'] && - $num < $metaList[$i+1]['need_star_num']) { - return $metaList[$i]; + $maxSlot = 1; + foreach ($metaList as $meta){ + if ($num >= $meta['need_star_num'] && $meta['unlock_chip_slot']){ + $maxSlot = $meta['unlock_chip_slot']; + } } + return $maxSlot; } public static function getDefaultList(){ @@ -97,7 +95,6 @@ class StarLevel protected static $metaList; - protected static $metaList2; protected static $metaListStar; } \ No newline at end of file diff --git a/webapp/services/ChipPageService.php b/webapp/services/ChipPageService.php index 1cbe96c8..3372be54 100644 --- a/webapp/services/ChipPageService.php +++ b/webapp/services/ChipPageService.php @@ -29,11 +29,6 @@ class ChipPageService extends BaseService 'account_id'=> myself()->_getAccountId() ) ); -// if (!$rows){ -// for ($i=0;$irefreshSlotState($row); @@ -44,15 +39,13 @@ class ChipPageService extends BaseService public function refreshSlotState($row){ $data = emptyReplace(json_decode($row['data'], true), array()); $userInfo = myself()->_getOrmUserInfo(); - $starMeta = \mt\StarLevel::getCurrent($userInfo['star_num']); - if ($starMeta['unlock_chip_slot']){ + $maxSlot = \mt\StarLevel::getMaxSlot($userInfo['star_num']); foreach ($data as &$val){ - if ($starMeta['unlock_chip_slot'] < $val['slot_id'] && $val['state'] == 0){ + if ($maxSlot < $val['slot_id'] && $val['state'] == 0){ $val['state'] = 0; }else{ $val['state'] = 1; } - } SqlHelper::update( myself()->_getSelfMysql(), @@ -65,24 +58,6 @@ class ChipPageService extends BaseService ) ); } -// foreach ($data as &$val){ -// if ($userInfo['level'] < $val['slot_id'] && $val['state'] == 0){ -// $val['state'] = 0; -// }else{ -// $val['state'] = 1; -// } -// } -// -// SqlHelper::update( -// myself()->_getSelfMysql(), -// 't_chip_page', -// array( -// 'idx' => $row['idx'] -// ), -// array( -// 'data' => json_encode($data), -// ) -// ); } } \ No newline at end of file