From 8ebe74e81454f732a4d6f60cbe96b83ec93dca35 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 9 Jun 2023 14:20:10 +0800 Subject: [PATCH] 1 --- webapp/controller/BattleController.class.php | 2 + webapp/controller/TeamController.class.php | 21 +++++++ webapp/models/Bag.php | 2 +- webapp/models/Chip.php | 38 ++++++------ webapp/models/Gun.php | 64 +++++++++++--------- webapp/models/Hero.php | 42 ++++++------- webapp/models/User.php | 4 +- webapp/services/TameBattleDataService.php | 35 ++++++----- 8 files changed, 117 insertions(+), 91 deletions(-) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 14d347ea..038a6f75 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -223,10 +223,12 @@ class BattleController extends BaseAuthedController { $account_id = getReqVal('account_id', ''); $session_id = getReqVal('session_id', ''); $battle_uuid = getReqVal('battle_uuid', ''); + $current_get_star = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); $info = array( 'account_id' => $account_id, 'session_id' => $session_id, 'battle_uuid' => $battle_uuid, + 'current_get_star' => $current_get_star, 'rank' => 0, 'name' => '', 'level' =>'', diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index 47627dcd..1a40107b 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -110,6 +110,27 @@ class TeamController extends BaseAuthedController { )); } + public function updateTeam(){ + $teamUuid = getReqVal('team_uuid', ''); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + $userDb = $this->_getOrmUserInfo(); + $userDto = User::toPreset($userDb); + foreach ($teamDb['member_list'] as $key=>$member) { + if ($member['account_id'] == $this->_getAccountId()) { + $teamDb['member_list'][$key] = $userDto; + } + } + $this->saveTeamDb($r, $teamUuid, $teamDb); + $this->_rspData(array( + 'team_uuid' => $teamUuid + )); + } + public function joinTeam() { $teamUuid = getReqVal('team_uuid', ''); diff --git a/webapp/models/Bag.php b/webapp/models/Bag.php index 98851ac5..0424d9b3 100644 --- a/webapp/models/Bag.php +++ b/webapp/models/Bag.php @@ -26,7 +26,7 @@ class Bag extends BaseModel { if ($row) { $row['item_uniid'] = $row['idx']; if ($row['account_id'] != myself()->_getAccountId()) { - if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) { + if (!NftService::isEquipOwner(myself()->_getAddress(), $row['token_id'])) { $row = null; } } diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index a5292486..8d76fd66 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -98,19 +98,19 @@ class Chip extends BaseModel 'token_id' => $nftDb['token_id'], ) ); - if (!$row) { - $itemMeta = mt\Item::get($nftDb['item_id']); - if ($itemMeta) { - self::addNftChip($itemMeta, $nftDb['token_id']); - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_chip', - array( - 'token_id' => $nftDb['token_id'], - ) - ); - } - } +// if (!$row) { +// $itemMeta = mt\Item::get($nftDb['item_id']); +// if ($itemMeta) { +// self::addNftChip($itemMeta, $nftDb['token_id']); +// $row = SqlHelper::ormSelectOne( +// myself()->_getSelfMysql(), +// 't_chip', +// array( +// 'token_id' => $nftDb['token_id'], +// ) +// ); +// } +// } if ($row){ if (! $row['activate']){ self::activateChip($row); @@ -135,12 +135,12 @@ class Chip extends BaseModel } $randAttr = array(); $fieldsKv = array( - 'item_id' => $itemMeta['id'], - 'item_num' => 1, - 'state' => self::GETED_STATE, - 'rand_attr' => json_encode($randAttr), - 'chip_grade' => 1, - 'chip_type' => $itemMeta['sub_type'], +// 'item_id' => $itemMeta['id'], +// 'item_num' => 1, +// 'state' => self::GETED_STATE, +// 'rand_attr' => json_encode($randAttr), +// 'chip_grade' => 1, +// 'chip_type' => $itemMeta['sub_type'], 'activate' => 1, 'modifytime' => myself()->_getNowTime() ); diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index d7de13eb..ba32a7cd 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -7,6 +7,7 @@ require_once('mt/GunQuality.php'); require_once('mt/Item.php'); require_once('models/GunSkin.php'); require_once('models/ChipPlugin.php'); +require_once('models/User.php'); require_once('services/NftService.php'); require_once('services/FormulaService.php'); require_once('services/ContractConfig.php'); @@ -100,15 +101,15 @@ class Gun extends BaseModel { public static function findByAccountId($accountId, $gunUniId) { - return self::internalFind($accountId, $gunUniId); + return self::internalFind($accountId, User::findUserAddress($accountId), $gunUniId); } public static function findByUniId($gunUniId) { - return self::internalFind(myself()->_getAccountId(), $gunUniId); + return self::internalFind(myself()->_getAccountId(),myself()->_getAddress(), $gunUniId); } - private static function internalFind($accountId, $gunUniId) + private static function internalFind($accountId, $address,$gunUniId) { $row = SqlHelper::ormSelectOne( myself()->_getMysql($accountId), @@ -120,7 +121,7 @@ class Gun extends BaseModel { if ($row) { $row['gun_uniid'] = $row['idx']; if ($row['account_id'] != $accountId) { - $openId = phpcommon\extractOpenId($accountId); + $openId = $address; if (!NftService::isEquipOwner($openId, $row['token_id'])) { $row = null; } @@ -174,19 +175,19 @@ class Gun extends BaseModel { ); //将NFT表的数据同步到中心化英雄表 (以后可能删除) - 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) { +// $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){ if ( ! $row['activate']){ @@ -211,19 +212,19 @@ class Gun extends BaseModel { if (!$itemMeta) { return; } - $randAttr = array(); - { - $initQualityMeta = mt\GunQuality::getByQuality(1); - if ($initQualityMeta) { - $randAttr = mt\GunQuality::getRandAttr($initQualityMeta); - } - } +// $randAttr = array(); +// { +// $initQualityMeta = mt\GunQuality::getByQuality(1); +// if ($initQualityMeta) { +// $randAttr = mt\GunQuality::getRandAttr($initQualityMeta); +// } +// } $fieldsKv = array( - 'gun_lv' => 1, - 'quality' => 1, - 'state' => self::GETED_STATE, - 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), - 'rand_attr' => json_encode($randAttr), +// 'gun_lv' => 1, +// 'quality' => 1, +// 'state' => self::GETED_STATE, +// 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), +// 'rand_attr' => json_encode($randAttr), 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, @@ -247,6 +248,7 @@ class Gun extends BaseModel { $lockType = $row['lock_type']; $unlockTime = $row['unlock_time']; } + { $heroIds =array(); $list = HeroPreset::getByGunUid($row['idx']); @@ -258,6 +260,7 @@ class Gun extends BaseModel { } } + $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -281,13 +284,14 @@ class Gun extends BaseModel { 'tags' => isset($row['tags'])?$row['tags']:'', 'hero_ids' => $heroIds, - ); + $nft_address = ''; $contract = ContractConfig::find(ContractConfig::ERC721); if ($row['token_id']){ $nft_address = $contract ? $contract['gun'] : ""; } + $dto['nft_address'] = $nft_address; return $dto; } diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 83545969..a1a9caba 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -163,19 +163,19 @@ class Hero extends BaseModel { ); //将NFT表的数据同步到中心化英雄表 (以后可能删除) - 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) { +// $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) { if (!$row['activate']) { @@ -200,15 +200,15 @@ class Hero extends BaseModel { if (!$itemMeta) { return; } - $randAttr = array(); +// $randAttr = array(); $fieldsKv = array( - 'hero_lv' => 1, - 'quality' => 1, - 'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)), - 'state' => self::GETED_STATE, - 'skill_lv1' => 1, - 'skill_lv2' => 1, - 'rand_attr' => json_encode($randAttr), +// 'hero_lv' => 1, +// 'quality' => 1, +// 'hero_tili' => 0, +// 'state' => self::GETED_STATE, +// 'skill_lv1' => 1, +// 'skill_lv2' => 1, +// 'rand_attr' => json_encode($randAttr), 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, diff --git a/webapp/models/User.php b/webapp/models/User.php index a9115b68..6f9b05ff 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -35,10 +35,10 @@ class User extends BaseModel { public static function findUserAddress($accountId) { $row = SqlHelper::ormSelectOne - (myself()->_getMysql($targetId), + (myself()->_getMysql($accountId), 't_user', array( - 'account_id' => $targetId + 'account_id' => $accountId ) ); return $row ? $row['address'] : null; diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index e9311478..debd77c2 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -655,19 +655,17 @@ class TameBattleDataService extends BaseService { }else{ $finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]); } -// array_push($reward['items'],array( -// 'item_id'=> V_ITEM_STAR, -// 'item_num'=>$finalNum, -// )); - $items = array( - array( - 'item_id' => V_ITEM_STAR, - 'item_num' => $finalNum - ), - ); - $propertyChgService = new services\PropertyChgService(); - $awardService = new services\AwardService(); - myself()->_addItems($items, $awardService,$propertyChgService); + if ($finalNum > 0){ + $items = array( + array( + 'item_id' => V_ITEM_STAR, + 'item_num' => $finalNum + ), + ); + $propertyChgService = new services\PropertyChgService(); + $awardService = new services\AwardService(); + myself()->_addItems($items, $awardService,$propertyChgService); + } } } @@ -682,11 +680,12 @@ class TameBattleDataService extends BaseService { }else{ $finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]); } - array_push($reward['items'],array( - 'item_id'=> V_ITEM_STAR, - 'item_num'=>$finalNum, - )); - + if ($finalNum > 0){ + array_push($reward['items'],array( + 'item_id'=> V_ITEM_STAR, + 'item_num'=>$finalNum, + )); + } } }