diff --git a/doc/Chip.py b/doc/Chip.py index 5f7a93ef..2f9bbca7 100644 --- a/doc/Chip.py +++ b/doc/Chip.py @@ -72,7 +72,8 @@ class Chip(object): ], 'response': [ _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'] + ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'], + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'demountChip', @@ -87,7 +88,8 @@ class Chip(object): ], 'response': [ _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'] + ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'], + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'replaceChip', @@ -103,7 +105,8 @@ class Chip(object): ], 'response': [ _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'] + ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'], + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'aKeyInlayChip', @@ -157,7 +160,9 @@ class Chip(object): ], 'response': [ _common.RspHead(), - ['!data', [_common.Chip()], '芯片信息'] + ['!data', [_common.Chip()], '芯片信息'], + ['state', 0, '1 成功,0 失败'], + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'isNeedLucky', @@ -170,6 +175,7 @@ class Chip(object): ], 'response': [ _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'isNotNeedLucky', @@ -182,6 +188,7 @@ class Chip(object): ], 'response': [ _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'waitingLucky', @@ -194,6 +201,7 @@ class Chip(object): ], 'response': [ _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] },{ 'name': 'aKeySynthetic', @@ -222,7 +230,8 @@ class Chip(object): ['state', '', '1 加锁 ;0 释放锁'], ], 'response': [ - _common.RspHead() + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] }, diff --git a/doc/_common.py b/doc/_common.py index c2fdf5df..e2c08feb 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -311,7 +311,7 @@ class PropertyChg(object): def __init__(self): self.fields = [ ['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))'], - ['!container_chg', [''], '容器类数据变更(bag、hero、heroSkin、gunSkin, gun)'] + ['!container_chg', [''], '容器类数据变更(bag、hero、heroSkin、gunSkin, gun,chip,fragment)'] ] class CostInfoItem(object): diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index 9b33d810..d2dca3ad 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -6,9 +6,11 @@ require_once('models/Gun.php'); require_once('models/User.php'); require_once('mt/ChipAttr.php'); require_once('services/FormulaService.php'); +require_once('services/PropertyChgService.php'); require_once('phpcommon/tglog.php'); + use models\Chip; use models\Hero; use models\Gun; @@ -102,18 +104,28 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, 'Please enter instructions'); return; } + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); if ($type == 1){ if (! $this->_doInlayHero($unique_id,$token_id)){ return; } $hero = Hero::toDto(Hero::find($unique_id)); - $this->_rspData(['data'=>$hero]); + $propertyChgService->addHeroChg(); + $this->_rspData([ + 'data'=>$hero, + 'property_chg' => $propertyChgService->toDto(), + ]); }else{ if (! $this->_doInlayGun($unique_id,$token_id)){ return; } $gun = Gun::toDto(Gun::find($unique_id)); - $this->_rspData(['data'=>$gun]); + $propertyChgService->addGunChg(); + $this->_rspData([ + 'data'=>$gun, + 'property_chg' => $propertyChgService->toDto(), + ]); } } @@ -126,18 +138,28 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, 'Please enter instructions'); return; } + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); if ($type == 1){ if (!$this->_doDemount($unique_id,$token_id)){ return; } $hero = Hero::toDto(Hero::find($unique_id)); - $this->_rspData(['data'=>$hero]); + $propertyChgService->addHeroChg(); + $this->_rspData([ + 'data'=>$hero, + 'property_chg' => $propertyChgService->toDto(), + ]); }else{ if (! $this->_doDemountGun($unique_id,$token_id)){ return; } $gun = Gun::toDto(Gun::find($unique_id)); - $this->_rspData(['data'=>$gun]); + $propertyChgService->addGunChg(); + $this->_rspData([ + 'data'=>$gun, + 'property_chg' => $propertyChgService->toDto(), + ]); } } @@ -151,6 +173,8 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, 'Please enter instructions'); return; } + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); if ($type == 1){ if (! $this->_doDemount($unique_id,$token_id_old)){ return; @@ -159,7 +183,11 @@ class ChipController extends BaseAuthedController return; } $hero = Hero::toDto(Hero::find($unique_id)); - $this->_rspData(['data'=>$hero]); + $propertyChgService->addHeroChg(); + $this->_rspData([ + 'data'=>$hero, + 'property_chg' => $propertyChgService->toDto(), + ]); }else{ if (! $this->_doDemountGun($unique_id,$token_id_old)){ return; @@ -168,7 +196,11 @@ class ChipController extends BaseAuthedController return; } $gun = Gun::toDto(Gun::find($unique_id)); - $this->_rspData(['data'=>$gun]); + $propertyChgService->addGunChg(); + $this->_rspData([ + 'data'=>$gun, + 'property_chg' => $propertyChgService->toDto(), + ]); } } @@ -219,18 +251,28 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, 'The chip slot is full'); return; } + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); if ($type == 1){ foreach ($res as $val){ $this->_doInlayHero($unique_id,$val['token_id']); } $hero_new = Hero::toDto(Hero::find($unique_id)); - $this->_rspData(['data'=>$hero_new]); + $propertyChgService->addHeroChg(); + $this->_rspData([ + 'data'=>$hero_new, + 'property_chg' => $propertyChgService->toDto(), + ]); }else{ foreach ($res as $val){ $this->_doInlayGun($unique_id,$val['token_id']); } $gun_new = Gun::toDto(Gun::find($unique_id)); - $this->_rspData(['data'=>$gun_new]); + $propertyChgService->addGunChg(); + $this->_rspData([ + 'data'=>$gun_new, + 'property_chg' => $propertyChgService->toDto(), + ]); } } @@ -304,9 +346,14 @@ class ChipController extends BaseAuthedController Chip::deleteChip(['token_id'=>$val]); } $num = round(round(($cumulative_cost/$upgrade_cost),5)*10000); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); if ($num_rspOk(); + $this->_rspData([ + 'state' => 0, + 'property_chg' => $propertyChgService->toDto(), + ]); return; }else{ //合成成功 @@ -314,7 +361,11 @@ class ChipController extends BaseAuthedController $chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main)); $chip_new['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip_new['chip_grade'],$chip_new['lucky_temporary']); $chip_new['mint'] = \services\FormulaService::Chip_Need_Mint_Cost($chip_new['chip_grade']); - $this->_rspData(['data'=>$chip_new]); + $this->_rspData([ + 'data'=>$chip_new, + 'state' => 1, + 'property_chg' => $propertyChgService->toDto(), + ]); } } @@ -342,7 +393,12 @@ class ChipController extends BaseAuthedController } User::update(['gold'=>$user['gold']-$mint_cost]); Chip::update($chip['token_id'],$fieldsKv); - $this->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $propertyChgService->addChip(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); } public function isNotNeedLucky(){ @@ -357,7 +413,11 @@ class ChipController extends BaseAuthedController 'lucky_temporary'=>0, ]; Chip::update($chip['token_id'],$fieldsKv); - $this->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); } public function waitingLucky(){ @@ -371,7 +431,11 @@ class ChipController extends BaseAuthedController 'supper_state'=>1, ]; Chip::update($chip['token_id'],$fieldsKv); - $this->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); + $this->_rspData([ + 'property_chg' => $propertyChgService->toDto(), + ]); } public function aKeySynthetic(){ @@ -454,7 +518,11 @@ class ChipController extends BaseAuthedController }else{ Chip::update($token_id,['state'=>0]); } - $this->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); + $this->_rspData([ + 'property_chg' => $propertyChgService->toDto(), + ]); } public function test(){ @@ -479,13 +547,6 @@ class ChipController extends BaseAuthedController // } // $this->_rspOk(); -// $lucky = FormulaService::getChipLuckyValue(6); -// echo FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength(6,$lucky); -// echo FormulaService::Hero_Chip_PSA_Value(6); -// $lucky = FormulaService::Hero_Advanced_Lucky_Value(3); -// echo FormulaService::Hero_NFT_Maximum_Physical_Strength(3,$lucky); - echo FormulaService::Weapon_Advanced_Lucky_Value(1); -// echo FormulaService::Hero_NFT_Maximum_Physical_Strength(1,$lucky); } diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 9c4de8c1..92e514c9 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -491,19 +491,37 @@ class GunController extends BaseAuthedController { $this->_setV(TN_GUN_QUALITY_UP, $idx, 0); $this->_setV(TN_GUN_QUALITY_UP, (int)$idx + 1000, 0); $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addHeroChg(); + $propertyChgService->addGunChg(); $propertyChgService->addUserChg(); $nextQualityMeta = mt\GunQuality::getByQuality($gunDb['quality'] + 1); if ($nextQualityMeta) { - $rnd = rand(1, 100); - $probability = \services\FormulaService::Weapon_Advanced_Probability($gunDb['quality'] + 1)*100; - if ($rnd > $probability) { + + $costGunDb = Gun::find($costGunUniId); + if ($costGunDb['token_id']){ + SqlHelper::update( + myself()->_getMarketMysql(), + 't_nft', + ['token_id'=>$costGunDb['token_id']], + ['deleted'=>1] + ); + }else{ Gun::update($costGunUniId, array( + 'account_id' => myself()->_getAccountId() . '!!!', 'lock_type' => 0, 'unlock_time' => 0, ) ); + } + Gun::update($costGunUniId, + array( + 'lock_type' => 0, + 'unlock_time' => 0, + ) + ); + $rnd = rand(1, 100); + $probability = \services\FormulaService::Weapon_Advanced_Probability($gunDb['quality'] + 1)*100; + if ($rnd > $probability) { Gun::update($gunUniId, array( 'lock_type' => 0, @@ -537,13 +555,6 @@ class GunController extends BaseAuthedController { if ($gunDb['quality'] + 1 > myself()->_getV(TN_GUN_MAX_QUALITY, 0)) { myself()->_setV(TN_GUN_MAX_QUALITY, 0, $gunDb['quality'] + 1); } - Gun::update($costGunUniId, - array( - 'account_id' => myself()->_getAccountId() . '!!!', - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); $newGunDb = Gun::find($gunUniId); $newGun = Gun::toDto($newGunDb); error_log(json_encode(array( diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 59a0f13d..67d1affc 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -331,15 +331,30 @@ class HeroController extends BaseAuthedController { $propertyChgService->addUserChg(); $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1); if ($nextQualityMeta) { + $costHeroDb = Hero::find($costHeroUniId); + if ($costHeroDb['token_id']){ + SqlHelper::update( + myself()->_getMarketMysql(), + 't_nft', + ['token_id'=>$costHeroDb['token_id']], + ['deleted'=>1] + ); + }else{ + Hero::update($costHeroUniId, + array( + 'account_id' => myself()->_getAccountId() . '!!!', + ) + ); + } + Hero::update($costHeroUniId, + array( + 'lock_type' => 0, + 'unlock_time' => 0, + ) + ); $rnd = rand(1, 100); $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100; if ($rnd > $probability) { - Hero::update($costHeroUniId, - array( - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); Hero::update($heroUniId, array( 'advanced_count' => $heroDb['advanced_count'] + 1, @@ -377,13 +392,6 @@ class HeroController extends BaseAuthedController { if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) { myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1); } - Hero::update($costHeroUniId, - array( - 'account_id' => myself()->_getAccountId() . '!!!', - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); $newHeroDb = Hero::find($heroUniId); $newHero = Hero::toDto($newHeroDb); error_log(json_encode(array( diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index f0b22e80..e04e0e14 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -33,8 +33,23 @@ class TeamController extends BaseAuthedController { return; }*/ - $userDb = $this->_getOrmUserInfo(); +// $userDb = $this->_getOrmUserInfo(); + $userDb = User::find('6513_2006_HaABddcrIdHDoj0qg73FFwvyrYkqOsQd'); + + //验证pve_instance_id合法性 + if ($pveInstanceId){ + $pveGame = \mt\PveGemini::get($pveInstanceId); + if (!$pveGame){ + $this->_rspErr(1, 'pve_instance_id error'); + return; + } + if (!in_array($pveInstanceId,\mt\PveGemini::getAbleCombatMeta($userDb['pve_instance_id']))){ + $this->_rspErr(1, 'pve_instance_id error'); + return; + } + } $userDto = User::info($userDb); + $userDto['is_leader'] =1; $userDto['createtime'] = $userDb['createtime']; $teamDb = array( 'team_uuid' => $teamUuid, @@ -56,7 +71,6 @@ class TeamController extends BaseAuthedController { { $teamUuid = getReqVal('team_uuid', ''); $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); if (empty($teamDb)) { $this->_rspErr(1, 'The team has been disbanded'); @@ -77,7 +91,7 @@ class TeamController extends BaseAuthedController { $this->_rspErr(1, 'The team has been disbanded'); return; } - if (count($teamDb['member_list']) >= 4) { + if (count($teamDb['member_list']) >= $teamDb['slot_num']) { $this->_rspErr(2, 'The team is full'); return; } @@ -90,6 +104,14 @@ class TeamController extends BaseAuthedController { } } $userDb = User::find($this->_getAccountId()); + //验证pve_instance_id合法性 + if ($teamDb['pve_instance_id']>0){ + if (!in_array($teamDb['pve_instance_id'],\mt\PveGemini::getAbleCombatMeta($userDb['pve_instance_id']))) { + $this->_rspErr(1, 'No challenge'); + return; + } + } + $userDto = User::info($userDb); $userDto['createtime'] = $userDb['createtime']; array_push($teamDb['member_list'], $userDto); diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 1eef16a0..64711590 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -107,28 +107,30 @@ class Gun extends BaseModel { } ); foreach (NftService::getEquips(myself()->_getOpenId()) as $nftDb) { - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_gun', - array( - 'token_id' => $nftDb['token_id'], - ) - ); - if (!$row) { - $itemMeta = mt\Item::get($nftDb['item_id']); - if ($itemMeta) { - self::addNftGun($itemMeta, $nftDb['token_id']); - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_gun', - array( - 'token_id' => $nftDb['token_id'], - ) - ); + if (! $nftDb['deleted']){ + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_gun', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addNftGun($itemMeta, $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_gun', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + } + if ($row) { + $cb($row); } - } - if ($row) { - $cb($row); } } } diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 2091089b..791d650a 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -97,28 +97,30 @@ class Hero extends BaseModel { } ); foreach (NftService::getHeros(myself()->_getOpenId()) as $nftDb) { - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_hero', - array( - 'token_id' => $nftDb['token_id'], - ) - ); - if (!$row) { - $itemMeta = mt\Item::get($nftDb['item_id']); - if ($itemMeta) { - self::addNftHero($itemMeta, $nftDb['token_id']); - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_hero', - array( - 'token_id' => $nftDb['token_id'], - ) - ); + if (! $nftDb['deleted']){ + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_hero', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addNftHero($itemMeta, $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_hero', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + } + if ($row) { + $cb($row); } - } - if ($row) { - $cb($row); } } } diff --git a/webapp/models/User.php b/webapp/models/User.php index f259b1d9..cd763084 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -10,7 +10,7 @@ use phpcommon\SqlHelper; class User extends BaseModel { - public function find($targetId) + public static function find($targetId) { $row = SqlHelper::ormSelectOne (myself()->_getMysql($targetId), @@ -75,6 +75,7 @@ class User extends BaseModel { 'pve_instance_id' => $row['pve_instance_id'], 'like_count' => $row['like_count'], 'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()), + 'is_leader' => 0 ); } diff --git a/webapp/mt/PveGemini.php b/webapp/mt/PveGemini.php index a51b2aa6..4472fb1d 100644 --- a/webapp/mt/PveGemini.php +++ b/webapp/mt/PveGemini.php @@ -13,6 +13,23 @@ class PveGemini { return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null; } + public static function getAbleCombatMeta($id){ + $arr = array(); + if (!$id){ + array_push($arr,self::FIRST_INSTANCE_ID); + }else{ + foreach (self::getMetaList() as $value){ + if ($value['gemini_id']<=$id){ + array_push($arr,$value['gemini_id']); + } + } + if (self::get($id+1)){ + array_push($arr,$id+1); + } + } + return $arr; + } + protected static function getMetaList() { if (!self::$metaList) { diff --git a/webapp/services/PropertyChgService.php b/webapp/services/PropertyChgService.php index 4fbf44a8..43807daf 100644 --- a/webapp/services/PropertyChgService.php +++ b/webapp/services/PropertyChgService.php @@ -40,6 +40,10 @@ class PropertyChgService extends BaseService { { $this->internalAddChg('gun'); } + public function addChip() + { + $this->internalAddChg('chip'); + } public function addFragment() {