From 5a52e8e8b8a31aab5244b4b24850478094158451 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 12 Aug 2024 19:21:37 +0800 Subject: [PATCH] 1 --- doc/_common.py | 3 +- .../controller/BaseAuthedController.class.php | 277 +++++++++--------- .../controller/HashRateController.class.php | 1 + webapp/controller/HeroController.class.php | 9 +- webapp/models/Chip.php | 1 + webapp/models/Hero.php | 14 +- webapp/mt/Item.php | 6 + webapp/services/AddItemsService.php | 187 ++++++++++++ webapp/services/AwardService.php | 14 + webapp/services/HashRateService.php | 14 + webapp/services/callback/MintNftHero.php | 13 +- 11 files changed, 397 insertions(+), 142 deletions(-) create mode 100644 webapp/services/AddItemsService.php diff --git a/doc/_common.py b/doc/_common.py index 01355ebd..4909c329 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -377,7 +377,8 @@ class Award(object): def __init__(self): self.fields = [ ['!items', [AwardItem()], '奖励物品列表'], - ['!heros', [Hero()], '英雄信息'] + ['!heros', [Hero()], '英雄信息'], + ['!chips', [Chip()], '芯片信息'], ] class PropertyChg(object): diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 29bc69e5..2b3aacb2 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -1,5 +1,6 @@ _checkS(); - $heads = array(); - $headFrames = array(); - foreach ($items as $item) { - //道具产出埋点 - LogService::productItem($item); - if ($awardService){ - $awardService->addItem($item['item_id'], $item['item_num']); - } - if ($this->_isVirtualItem($item['item_id'])) { - $this->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService); - $propertyService->addUserChg(); - } else { - $itemMeta = mt\Item::get($item['item_id']); - if ($itemMeta) { - if (mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) { - Bag::addItem($item['item_id'], $item['item_num']); - $propertyService->addBagChg(); - } else { - for ($i=0; $i<$item['item_num']; $i++){ - switch ($itemMeta['type']) { - case mt\Item::HERO_TYPE: - { - $heroMeta = \mt\Hero::get($itemMeta['id']); - $res = Hero::addHero($heroMeta); - if ($res){ - $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); - $awardService->addHero($item['item_id'],$lastIdx); - } - $propertyService->addHeroChg(); - $propertyService->addUserChg(); - } - break; - case mt\Item::HERO_SKIN_TYPE: - { - HeroSkin::addSkin($itemMeta); - $propertyService->addHeroSkinChg(); - } - break; - case mt\Item::HEAD_TYPE: - { - array_push($heads, $itemMeta['id']); - $propertyService->addUserChg(); - } - break; - case mt\Item::HEAD_FRAME_TYPE: - { - array_push($headFrames, $itemMeta['id']); - $propertyService->addUserChg(); - } - break; - case mt\Item::GUN_TYPE: - { - Gun::addGun($itemMeta); - $propertyService->addGunChg(); - } - break; - case mt\Item::GUN_SKIN_TYPE: - { - GunSkin::addSkin($itemMeta['id']); - $propertyService->addGunSkinChg(); - } - break; - case mt\Item::FRAGMENT_BOX_TYPE: - { - Bag::addItem($item['item_id'], $item['item_num']); - $propertyService->addBagChg(); - } - break; - case mt\Item::RING_TYPE: - { - UserSeasonRing::addRing($itemMeta); - $propertyService->addUserChg(); - } - break; - case mt\Item::PARACHUTE_TYPE: - { - Parachute::addParachute($itemMeta); - $propertyService->addUserChg(); - } - break; - case mt\Item::CHIP_TYPE: - { - Chip::addChip($itemMeta); - $propertyService->addChip(); - } - break; - case mt\Item::RANDOM_BOX_TYPE: - { - $this->_openRandomBox($itemMeta,$awardService,$propertyService); - } - break; - case mt\Item::AVATAR_TYPE: - { - Avatar::addAvatar($itemMeta); - } - break; - case mt\Item::TIMING_PROP_TYPE: - { - $timingObj = new \services\TimingPropService(); - $timingObj->handleProp($itemMeta); - } - break; - default: - { - $this->_addLogEx($this->_getAccountId(), - 'additems', 'invalid_item', - array( - 'param1' => $item['item_id'], - 'param2' => $item['item_num'], - )); - } - break; - } - } - - } - } - } - }//end foreach - if (!empty($heads) || !empty($headFrames)) { - $userInfo = $this->_getOrmUserInfo(); - $headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array()); - $headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array()); - $heads = array_unique(array_merge($heads, $headsDb)); - $headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb))); - $this->_updateUserInfo(array( - 'head_list' => json_encode($heads), - 'head_frame_list' => json_encode($headFrames), - )); - } + public function _addItems($items, $awardService, $propertyService){ + $obj = new services\AddItemsService(); + $obj->addItems($items, $awardService, $propertyService); } +// public function _addItems($items, $awardService, $propertyService) +// { +// myself()->_checkS(); +// $heads = array(); +// $headFrames = array(); +// foreach ($items as $item) { +// //道具产出埋点 +// LogService::productItem($item); +// if ($awardService){ +// $awardService->addItem($item['item_id'], $item['item_num']); +// } +// if ($this->_isVirtualItem($item['item_id'])) { +// $this->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService); +// $propertyService->addUserChg(); +// } else { +// $itemMeta = mt\Item::get($item['item_id']); +// if ($itemMeta) { +// if (mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) { +// Bag::addItem($item['item_id'], $item['item_num']); +// $propertyService->addBagChg(); +// } else { +// for ($i=0; $i<$item['item_num']; $i++){ +// switch ($itemMeta['type']) { +// case mt\Item::HERO_TYPE: +// { +// $heroMeta = \mt\Hero::get($itemMeta['id']); +// $res = Hero::addHero($heroMeta); +// if ($res){ +// $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); +// $awardService->addHero($item['item_id'],$lastIdx); +// } +// $propertyService->addHeroChg(); +// $propertyService->addUserChg(); +// } +// break; +// case mt\Item::HERO_SKIN_TYPE: +// { +// HeroSkin::addSkin($itemMeta); +// $propertyService->addHeroSkinChg(); +// } +// break; +// case mt\Item::HEAD_TYPE: +// { +// array_push($heads, $itemMeta['id']); +// $propertyService->addUserChg(); +// } +// break; +// case mt\Item::HEAD_FRAME_TYPE: +// { +// array_push($headFrames, $itemMeta['id']); +// $propertyService->addUserChg(); +// } +// break; +// case mt\Item::GUN_TYPE: +// { +// Gun::addGun($itemMeta); +// $propertyService->addGunChg(); +// } +// break; +// case mt\Item::GUN_SKIN_TYPE: +// { +// GunSkin::addSkin($itemMeta['id']); +// $propertyService->addGunSkinChg(); +// } +// break; +// case mt\Item::FRAGMENT_BOX_TYPE: +// { +// Bag::addItem($item['item_id'], $item['item_num']); +// $propertyService->addBagChg(); +// } +// break; +// case mt\Item::RING_TYPE: +// { +// UserSeasonRing::addRing($itemMeta); +// $propertyService->addUserChg(); +// } +// break; +// case mt\Item::PARACHUTE_TYPE: +// { +// Parachute::addParachute($itemMeta); +// $propertyService->addUserChg(); +// } +// break; +// case mt\Item::CHIP_TYPE: +// { +// Chip::addChip($itemMeta); +// $propertyService->addChip(); +// } +// break; +// case mt\Item::RANDOM_BOX_TYPE: +// { +// $this->_openRandomBox($itemMeta,$awardService,$propertyService); +// } +// break; +// case mt\Item::AVATAR_TYPE: +// { +// Avatar::addAvatar($itemMeta); +// } +// break; +// case mt\Item::TIMING_PROP_TYPE: +// { +// $timingObj = new \services\TimingPropService(); +// $timingObj->handleProp($itemMeta); +// } +// break; +// case mt\Item::APPOINT_PROP_TYPE: +// { +// +// } +// break; +// default: +// { +// $this->_addLogEx($this->_getAccountId(), +// 'additems', 'invalid_item', +// array( +// 'param1' => $item['item_id'], +// 'param2' => $item['item_num'], +// )); +// } +// break; +// } +// } +// +// } +// } +// } +// }//end foreach +// if (!empty($heads) || !empty($headFrames)) { +// $userInfo = $this->_getOrmUserInfo(); +// $headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array()); +// $headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array()); +// $heads = array_unique(array_merge($heads, $headsDb)); +// $headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb))); +// $this->_updateUserInfo(array( +// 'head_list' => json_encode($heads), +// 'head_frame_list' => json_encode($headFrames), +// )); +// } +// } + public function _openRandomBox($itemMeta,$awardService,$propertyService){ if ($itemMeta['include_item_id']) { $includeItemIds = explode('|', $itemMeta['include_item_id']); diff --git a/webapp/controller/HashRateController.class.php b/webapp/controller/HashRateController.class.php index f05cf849..a9754d6a 100644 --- a/webapp/controller/HashRateController.class.php +++ b/webapp/controller/HashRateController.class.php @@ -138,6 +138,7 @@ class HashRateController extends BaseAuthedController // if ($taskMeta['is_refresh'] == \mt\AchievementsPower::REFRESH_STATE && $refreshTimes < $refreshTimesMax){ // $this->hashRateService->refreshHashRateTask($taskMeta,$currentPeriod['id']); // } + $this->hashRateService->resetCurrentGoal($taskMeta); $this->_rspData(array( 'award' => $reward, )); diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index d31fce11..45bd9639 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -105,9 +105,14 @@ class HeroController extends BaseAuthedController { //消耗材料 $this->_decItems($costItems); $propertyChgService = new services\PropertyChgService(); + $awardService = new services\AwardService(); $propertyChgService->addBagChg(); for ($i=0; $i<$number; $i++){ - Hero::addSyntheticHero($heroMeta,2); + $res= Hero::addSyntheticHero($heroMeta,2); + if ($res){ + $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); + $awardService->addChip($itemId,$lastIdx); + } } $propertyChgService->addHeroChg(); // $this->_incPeriodV(TN_HASH_RATE_SYN_HERO_TIMES, 0, $number); @@ -124,7 +129,7 @@ class HeroController extends BaseAuthedController { ); LogService::burialPointEvent($event); $this->_rspData(array( - 'item_id' => $heroMeta['id'], + 'award' => $awardService->toDto(), 'property_chg' => $propertyChgService->toDto(), )); diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 96ff7f5f..927b0a4d 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -292,6 +292,7 @@ class Chip extends BaseModel 'item_id'=>$itemMeta['id'], 'item_num'=>1, )); + return true; } public static function getChipByTokenId($token_ids){ diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index dd3b72af..298fa736 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -746,10 +746,18 @@ class Hero extends BaseModel { $attr = array(); $basicMeta = mt\BattleBasicAttribute::get($heroId); if ($basicMeta) { - $randMeta = mt\BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$quality); - if ($randMeta) { - $attr = mt\BattleRandAttribute::getRandAttr($randMeta); + for ($i=1;$i<=$quality;$i++){ + $randMeta = mt\BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$i); + if ($randMeta) { + $result = mt\BattleRandAttribute::getRandAttr($randMeta); + if ($result){ + foreach ($result as $value){ + array_push($attr,$value); + } + } + } } + } return $attr; } diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index b9984881..77d1234c 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -112,6 +112,7 @@ class Item { const GOLD_SYN = 31; const BATTLE_REWARD_BOX = 32; const TIMING_PROP_TYPE = 33; + const APPOINT_PROP_TYPE = 40; const FUNC_RENAME_CARD_SUBTYPE = 1; const FUNC_GUILD_CARD_SUBTYPE = 3; @@ -127,6 +128,11 @@ class Item { const SKIN_FRAGMENT_SUBTYPE = 4; + const APPOINT_HERO_SUBTYPE = 1; + const APPOINT_CHIP_SUBTYPE = 2; + const APPOINT_SKIN_SUBTYPE = 3; + + public static function get($id) { return getXVal(self::getMetaList(), $id, null); diff --git a/webapp/services/AddItemsService.php b/webapp/services/AddItemsService.php new file mode 100644 index 00000000..2d222ea5 --- /dev/null +++ b/webapp/services/AddItemsService.php @@ -0,0 +1,187 @@ +_checkS(); + $heads = array(); + $headFrames = array(); + foreach ($items as $item) { + //道具产出埋点 + LogService::productItem($item); + if ($awardService){ + $awardService->addItem($item['item_id'], $item['item_num']); + } + if (myself()->_isVirtualItem($item['item_id'])) { + myself()->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService); + $propertyService->addUserChg(); + } else { + $itemMeta = Item::get($item['item_id']); + if ($itemMeta) { + if (Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) { + Bag::addItem($item['item_id'], $item['item_num']); + $propertyService->addBagChg(); + } else { + for ($i=0; $i<$item['item_num']; $i++){ + switch ($itemMeta['type']) { + case Item::HERO_TYPE: + { + $heroMeta = \mt\Hero::get($itemMeta['id']); + $res = Hero::addHero($heroMeta); + if ($res){ + $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); + $awardService->addHero($item['item_id'],$lastIdx); + } + $propertyService->addHeroChg(); + $propertyService->addUserChg(); + } + break; + case Item::HERO_SKIN_TYPE: + { + HeroSkin::addSkin($itemMeta); + $propertyService->addHeroSkinChg(); + } + break; + case Item::HEAD_TYPE: + { + array_push($heads, $itemMeta['id']); + $propertyService->addUserChg(); + } + break; + case Item::HEAD_FRAME_TYPE: + { + array_push($headFrames, $itemMeta['id']); + $propertyService->addUserChg(); + } + break; + case Item::GUN_TYPE: + { + Gun::addGun($itemMeta); + $propertyService->addGunChg(); + } + break; + case Item::GUN_SKIN_TYPE: + { + GunSkin::addSkin($itemMeta['id']); + $propertyService->addGunSkinChg(); + } + break; + case Item::FRAGMENT_BOX_TYPE: + { + Bag::addItem($item['item_id'], $item['item_num']); + $propertyService->addBagChg(); + } + break; + case Item::RING_TYPE: + { + UserSeasonRing::addRing($itemMeta); + $propertyService->addUserChg(); + } + break; + case Item::PARACHUTE_TYPE: + { + Parachute::addParachute($itemMeta); + $propertyService->addUserChg(); + } + break; + case Item::CHIP_TYPE: + { + $res = Chip::addChip($itemMeta); + if ($res){ + $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); + $awardService->addChip($item['item_id'],$lastIdx); + } + $propertyService->addChip(); + } + break; + case Item::RANDOM_BOX_TYPE: + { + myself()->_openRandomBox($itemMeta,$awardService,$propertyService); + } + break; + case Item::AVATAR_TYPE: + { + Avatar::addAvatar($itemMeta); + } + break; + case Item::TIMING_PROP_TYPE: + { + $timingObj = new \services\TimingPropService(); + $timingObj->handleProp($itemMeta); + } + break; + case Item::APPOINT_PROP_TYPE: + { + switch ($itemMeta['sub_type']){ + case Item::APPOINT_HERO_SUBTYPE :{ + $heroMeta = \mt\Hero::get($itemMeta['relationship']); + $res = Hero::addSyntheticHero($heroMeta,$itemMeta['quality']); + if ($res){ + $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); + $awardService->addHero($heroMeta['id'],$lastIdx); + } + $propertyService->addHeroChg(); + } + break; + case Item::APPOINT_CHIP_SUBTYPE :{ + $chipMeta = Item::get($itemMeta['relationship']); + $res = Chip::addSyntheticChip($chipMeta,$itemMeta['quality']); + if ($res){ + $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); + $awardService->addChip($chipMeta['id'],$lastIdx); + } + $propertyService->addChip(); + } + break; + case Item::APPOINT_SKIN_SUBTYPE :{ + + } + break; + } + } + break; + default: + { + myself()->_addLogEx(myself()->_getAccountId(), + 'additems', 'invalid_item', + array( + 'param1' => $item['item_id'], + 'param2' => $item['item_num'], + )); + } + break; + } + } + + } + } + } + }//end foreach + if (!empty($heads) || !empty($headFrames)) { + $userInfo = myself()->_getOrmUserInfo(); + $headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array()); + $headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array()); + $heads = array_unique(array_merge($heads, $headsDb)); + $headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb))); + myself()->_updateUserInfo(array( + 'head_list' => json_encode($heads), + 'head_frame_list' => json_encode($headFrames), + )); + } + } + +} \ No newline at end of file diff --git a/webapp/services/AwardService.php b/webapp/services/AwardService.php index c424df5a..020df966 100644 --- a/webapp/services/AwardService.php +++ b/webapp/services/AwardService.php @@ -2,6 +2,7 @@ namespace services; +use models\Chip; use models\Hero; use mt\Item; @@ -9,6 +10,7 @@ class AwardService extends BaseService { private $items = array(); private $heros = array(); + private $chips = array(); public function addItem($itemId, $itemNum) { @@ -44,11 +46,23 @@ class AwardService extends BaseService { } } + public function addChip($itemId,$unnid) + { + $itemMeta = Item::get($itemId); + if (!$itemMeta){ + return; + } + if ($itemMeta['type'] == Item::CHIP_TYPE){ + array_push($this->chips,Chip::toDto(Chip::find($unnid))); + } + } + public function toDto() { return array( 'items' => $this->items, 'heros' => $this->heros, + 'chips' => $this->chips, ); } diff --git a/webapp/services/HashRateService.php b/webapp/services/HashRateService.php index 0ef183ce..f5434b5d 100644 --- a/webapp/services/HashRateService.php +++ b/webapp/services/HashRateService.php @@ -400,6 +400,20 @@ class HashRateService extends BaseService myself()->_incDailyV(TN_HASH_DAILY_REFRESH_TIMES,0,1); } + public function resetCurrentGoal($taskMate){ + if ($taskMate['task_type'] == AchievementsPower::TYPE5){ + return; + } + $taskList = $this->getHashRateTasks($taskMate['task_type']); + foreach ($taskList as &$task){ + if ($task['task_id'] == $taskMate['id']){ + $task['current'] = 0; + } + } + $this->hashRateTask['task'.$taskMate['task_type']] = $taskList; + $this->saveHashRateTask(); + } + public function _isHaveRedTag($period){ foreach ($this->hashRateTask as $item){ if (is_array($item)){ diff --git a/webapp/services/callback/MintNftHero.php b/webapp/services/callback/MintNftHero.php index 30e0d348..05de1bb6 100644 --- a/webapp/services/callback/MintNftHero.php +++ b/webapp/services/callback/MintNftHero.php @@ -154,9 +154,16 @@ class MintNftHero $attr = array(); $basicMeta = BattleBasicAttribute::get($heroId); if ($basicMeta) { - $randMeta = BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$quality); - if ($randMeta) { - $attr = BattleRandAttribute::getRandAttr($randMeta); + for ($i=1;$i<=$quality;$i++){ + $randMeta = BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$i); + if ($randMeta) { + $result = BattleRandAttribute::getRandAttr($randMeta); + if ($result){ + foreach ($result as $value){ + array_push($attr,$value); + } + } + } } } return $attr;