This commit is contained in:
hujiabin 2023-06-05 12:02:34 +08:00
parent f3d5a2e26a
commit dc9a232395
3 changed files with 35 additions and 48 deletions

View File

@ -83,12 +83,19 @@ class StarController extends BaseAuthedController {
$this->_rspErr(1, "Can't get it again"); $this->_rspErr(1, "Can't get it again");
return; return;
} }
$dropMeta = mt\Drop::get($meta['drop_id']); $items = array(
if (!$dropMeta) { array(
$this->_rspErr(10, 'server internal error:' . $meta['drop_id']); 'item_id' => $meta['item_id'],
return; 'item_num' => $meta['item_num'],
} )
$this->_scatterDrop('missionStar:' . $missionId, $dropMeta, $this->awardService, $this->propertyChgService); );
$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); MissionStar::add($meta['season_id'],$missionId);
$this->_rspData(array( $this->_rspData(array(
'award' => $this->awardService->toDto(), 'award' => $this->awardService->toDto(),
@ -105,11 +112,19 @@ class StarController extends BaseAuthedController {
$missionStarDb = MissionStar::find($meta['season_id'],$meta['id']); $missionStarDb = MissionStar::find($meta['season_id'],$meta['id']);
if ($this->userInfo['star_num'] >= $target && !$missionStarDb){ if ($this->userInfo['star_num'] >= $target && !$missionStarDb){
//可领取 //可领取
$dropMeta = mt\Drop::get($meta['drop_id']); $items = array(
if ($dropMeta) { array(
$this->_scatterDrop('missionStar:' . $meta['id'], $dropMeta, $this->awardService, $this->propertyChgService); 'item_id' => $meta['item_id'],
'item_num' => $meta['item_num'],
)
);
$this->_addItems($items,$this->awardService, $this->propertyChgService);
MissionStar::add($meta['season_id'],$meta['id']); 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( $this->_rspData(array(

View File

@ -34,18 +34,16 @@ class StarLevel
return null; return null;
} }
public static function getCurrent($num){ public static function getMaxSlot($num){
$metaList = self::getDefaultList(); $metaList = self::getDefaultList();
$maxLen = count($metaList); $maxSlot = 1;
for ($i=0;$i<$maxLen;$i++){ foreach ($metaList as $meta){
if ($num >= $metaList[$maxLen-1]['need_star_num']){ if ($num >= $meta['need_star_num'] && $meta['unlock_chip_slot']){
return $metaList[$maxLen-1]; $maxSlot = $meta['unlock_chip_slot'];
}
if ($num >= $metaList[$i]['need_star_num'] &&
$num < $metaList[$i+1]['need_star_num']) {
return $metaList[$i];
} }
} }
return $maxSlot;
} }
public static function getDefaultList(){ public static function getDefaultList(){
@ -97,7 +95,6 @@ class StarLevel
protected static $metaList; protected static $metaList;
protected static $metaList2;
protected static $metaListStar; protected static $metaListStar;
} }

View File

@ -29,11 +29,6 @@ class ChipPageService extends BaseService
'account_id'=> myself()->_getAccountId() 'account_id'=> myself()->_getAccountId()
) )
); );
// if (!$rows){
// for ($i=0;$i<self::INIT_CHIP_PAGE_NUM;$i++){
// ChipPage::addChipPage();
// }
// }
if ($rows){ if ($rows){
foreach ($rows as $row){ foreach ($rows as $row){
$this->refreshSlotState($row); $this->refreshSlotState($row);
@ -44,15 +39,13 @@ class ChipPageService extends BaseService
public function refreshSlotState($row){ public function refreshSlotState($row){
$data = emptyReplace(json_decode($row['data'], true), array()); $data = emptyReplace(json_decode($row['data'], true), array());
$userInfo = myself()->_getOrmUserInfo(); $userInfo = myself()->_getOrmUserInfo();
$starMeta = \mt\StarLevel::getCurrent($userInfo['star_num']); $maxSlot = \mt\StarLevel::getMaxSlot($userInfo['star_num']);
if ($starMeta['unlock_chip_slot']){
foreach ($data as &$val){ 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; $val['state'] = 0;
}else{ }else{
$val['state'] = 1; $val['state'] = 1;
} }
}
SqlHelper::update( SqlHelper::update(
myself()->_getSelfMysql(), 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),
// )
// );
} }
} }