This commit is contained in:
hujiabin 2023-06-09 14:20:10 +08:00
parent 8ba7d42e8f
commit 8ebe74e814
8 changed files with 117 additions and 91 deletions

View File

@ -223,10 +223,12 @@ class BattleController extends BaseAuthedController {
$account_id = getReqVal('account_id', ''); $account_id = getReqVal('account_id', '');
$session_id = getReqVal('session_id', ''); $session_id = getReqVal('session_id', '');
$battle_uuid = getReqVal('battle_uuid', ''); $battle_uuid = getReqVal('battle_uuid', '');
$current_get_star = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0);
$info = array( $info = array(
'account_id' => $account_id, 'account_id' => $account_id,
'session_id' => $session_id, 'session_id' => $session_id,
'battle_uuid' => $battle_uuid, 'battle_uuid' => $battle_uuid,
'current_get_star' => $current_get_star,
'rank' => 0, 'rank' => 0,
'name' => '', 'name' => '',
'level' =>'', 'level' =>'',

View File

@ -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() public function joinTeam()
{ {
$teamUuid = getReqVal('team_uuid', ''); $teamUuid = getReqVal('team_uuid', '');

View File

@ -26,7 +26,7 @@ class Bag extends BaseModel {
if ($row) { if ($row) {
$row['item_uniid'] = $row['idx']; $row['item_uniid'] = $row['idx'];
if ($row['account_id'] != myself()->_getAccountId()) { if ($row['account_id'] != myself()->_getAccountId()) {
if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) { if (!NftService::isEquipOwner(myself()->_getAddress(), $row['token_id'])) {
$row = null; $row = null;
} }
} }

View File

@ -98,19 +98,19 @@ class Chip extends BaseModel
'token_id' => $nftDb['token_id'], 'token_id' => $nftDb['token_id'],
) )
); );
if (!$row) { // if (!$row) {
$itemMeta = mt\Item::get($nftDb['item_id']); // $itemMeta = mt\Item::get($nftDb['item_id']);
if ($itemMeta) { // if ($itemMeta) {
self::addNftChip($itemMeta, $nftDb['token_id']); // self::addNftChip($itemMeta, $nftDb['token_id']);
$row = SqlHelper::ormSelectOne( // $row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(), // myself()->_getSelfMysql(),
't_chip', // 't_chip',
array( // array(
'token_id' => $nftDb['token_id'], // 'token_id' => $nftDb['token_id'],
) // )
); // );
} // }
} // }
if ($row){ if ($row){
if (! $row['activate']){ if (! $row['activate']){
self::activateChip($row); self::activateChip($row);
@ -135,12 +135,12 @@ class Chip extends BaseModel
} }
$randAttr = array(); $randAttr = array();
$fieldsKv = array( $fieldsKv = array(
'item_id' => $itemMeta['id'], // 'item_id' => $itemMeta['id'],
'item_num' => 1, // 'item_num' => 1,
'state' => self::GETED_STATE, // 'state' => self::GETED_STATE,
'rand_attr' => json_encode($randAttr), // 'rand_attr' => json_encode($randAttr),
'chip_grade' => 1, // 'chip_grade' => 1,
'chip_type' => $itemMeta['sub_type'], // 'chip_type' => $itemMeta['sub_type'],
'activate' => 1, 'activate' => 1,
'modifytime' => myself()->_getNowTime() 'modifytime' => myself()->_getNowTime()
); );

View File

@ -7,6 +7,7 @@ require_once('mt/GunQuality.php');
require_once('mt/Item.php'); require_once('mt/Item.php');
require_once('models/GunSkin.php'); require_once('models/GunSkin.php');
require_once('models/ChipPlugin.php'); require_once('models/ChipPlugin.php');
require_once('models/User.php');
require_once('services/NftService.php'); require_once('services/NftService.php');
require_once('services/FormulaService.php'); require_once('services/FormulaService.php');
require_once('services/ContractConfig.php'); require_once('services/ContractConfig.php');
@ -100,15 +101,15 @@ class Gun extends BaseModel {
public static function findByAccountId($accountId, $gunUniId) public static function findByAccountId($accountId, $gunUniId)
{ {
return self::internalFind($accountId, $gunUniId); return self::internalFind($accountId, User::findUserAddress($accountId), $gunUniId);
} }
public static function findByUniId($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( $row = SqlHelper::ormSelectOne(
myself()->_getMysql($accountId), myself()->_getMysql($accountId),
@ -120,7 +121,7 @@ class Gun extends BaseModel {
if ($row) { if ($row) {
$row['gun_uniid'] = $row['idx']; $row['gun_uniid'] = $row['idx'];
if ($row['account_id'] != $accountId) { if ($row['account_id'] != $accountId) {
$openId = phpcommon\extractOpenId($accountId); $openId = $address;
if (!NftService::isEquipOwner($openId, $row['token_id'])) { if (!NftService::isEquipOwner($openId, $row['token_id'])) {
$row = null; $row = null;
} }
@ -174,19 +175,19 @@ class Gun extends BaseModel {
); );
//将NFT表的数据同步到中心化英雄表 (以后可能删除) //将NFT表的数据同步到中心化英雄表 (以后可能删除)
if (!$row) { // if (!$row) {
$itemMeta = mt\Item::get($nftDb['item_id']); // $itemMeta = mt\Item::get($nftDb['item_id']);
if ($itemMeta) { // if ($itemMeta) {
self::addNftGun($itemMeta, $nftDb['token_id']); // self::addNftGun($itemMeta, $nftDb['token_id']);
$row = SqlHelper::ormSelectOne( // $row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(), // myself()->_getSelfMysql(),
't_gun', // 't_gun',
array( // array(
'token_id' => $nftDb['token_id'], // 'token_id' => $nftDb['token_id'],
) // )
); // );
} // }
} // }
if ($row){ if ($row){
if ( ! $row['activate']){ if ( ! $row['activate']){
@ -211,19 +212,19 @@ class Gun extends BaseModel {
if (!$itemMeta) { if (!$itemMeta) {
return; return;
} }
$randAttr = array(); // $randAttr = array();
{ // {
$initQualityMeta = mt\GunQuality::getByQuality(1); // $initQualityMeta = mt\GunQuality::getByQuality(1);
if ($initQualityMeta) { // if ($initQualityMeta) {
$randAttr = mt\GunQuality::getRandAttr($initQualityMeta); // $randAttr = mt\GunQuality::getRandAttr($initQualityMeta);
} // }
} // }
$fieldsKv = array( $fieldsKv = array(
'gun_lv' => 1, // 'gun_lv' => 1,
'quality' => 1, // 'quality' => 1,
'state' => self::GETED_STATE, // 'state' => self::GETED_STATE,
'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), // 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)),
'rand_attr' => json_encode($randAttr), // 'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK, 'lock_type' => self::NO_LOCK,
'unlock_time' => 0, 'unlock_time' => 0,
'unlock_trade_time' => 0, 'unlock_trade_time' => 0,
@ -247,6 +248,7 @@ class Gun extends BaseModel {
$lockType = $row['lock_type']; $lockType = $row['lock_type'];
$unlockTime = $row['unlock_time']; $unlockTime = $row['unlock_time'];
} }
{ {
$heroIds =array(); $heroIds =array();
$list = HeroPreset::getByGunUid($row['idx']); $list = HeroPreset::getByGunUid($row['idx']);
@ -258,6 +260,7 @@ class Gun extends BaseModel {
} }
} }
$dto = array( $dto = array(
'idx' => $row['idx'], 'idx' => $row['idx'],
'token_id' => $row['token_id'], 'token_id' => $row['token_id'],
@ -281,13 +284,14 @@ class Gun extends BaseModel {
'tags' => isset($row['tags'])?$row['tags']:'', 'tags' => isset($row['tags'])?$row['tags']:'',
'hero_ids' => $heroIds, 'hero_ids' => $heroIds,
); );
$nft_address = ''; $nft_address = '';
$contract = ContractConfig::find(ContractConfig::ERC721); $contract = ContractConfig::find(ContractConfig::ERC721);
if ($row['token_id']){ if ($row['token_id']){
$nft_address = $contract ? $contract['gun'] : ""; $nft_address = $contract ? $contract['gun'] : "";
} }
$dto['nft_address'] = $nft_address; $dto['nft_address'] = $nft_address;
return $dto; return $dto;
} }

View File

@ -163,19 +163,19 @@ class Hero extends BaseModel {
); );
//将NFT表的数据同步到中心化英雄表 (以后可能删除) //将NFT表的数据同步到中心化英雄表 (以后可能删除)
if (!$row) { // if (!$row) {
$itemMeta = mt\Item::get($nftDb['item_id']); // $itemMeta = mt\Item::get($nftDb['item_id']);
if ($itemMeta) { // if ($itemMeta) {
self::addNftHero($itemMeta, $nftDb['token_id']); // self::addNftHero($itemMeta, $nftDb['token_id']);
$row = SqlHelper::ormSelectOne( // $row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(), // myself()->_getSelfMysql(),
't_hero', // 't_hero',
array( // array(
'token_id' => $nftDb['token_id'], // 'token_id' => $nftDb['token_id'],
) // )
); // );
} // }
} // }
if ($row) { if ($row) {
if (!$row['activate']) { if (!$row['activate']) {
@ -200,15 +200,15 @@ class Hero extends BaseModel {
if (!$itemMeta) { if (!$itemMeta) {
return; return;
} }
$randAttr = array(); // $randAttr = array();
$fieldsKv = array( $fieldsKv = array(
'hero_lv' => 1, // 'hero_lv' => 1,
'quality' => 1, // 'quality' => 1,
'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)), // 'hero_tili' => 0,
'state' => self::GETED_STATE, // 'state' => self::GETED_STATE,
'skill_lv1' => 1, // 'skill_lv1' => 1,
'skill_lv2' => 1, // 'skill_lv2' => 1,
'rand_attr' => json_encode($randAttr), // 'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK, 'lock_type' => self::NO_LOCK,
'unlock_time' => 0, 'unlock_time' => 0,
'unlock_trade_time' => 0, 'unlock_trade_time' => 0,

View File

@ -35,10 +35,10 @@ class User extends BaseModel {
public static function findUserAddress($accountId) public static function findUserAddress($accountId)
{ {
$row = SqlHelper::ormSelectOne $row = SqlHelper::ormSelectOne
(myself()->_getMysql($targetId), (myself()->_getMysql($accountId),
't_user', 't_user',
array( array(
'account_id' => $targetId 'account_id' => $accountId
) )
); );
return $row ? $row['address'] : null; return $row ? $row['address'] : null;

View File

@ -655,19 +655,17 @@ class TameBattleDataService extends BaseService {
}else{ }else{
$finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]); $finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]);
} }
// array_push($reward['items'],array( if ($finalNum > 0){
// 'item_id'=> V_ITEM_STAR, $items = array(
// 'item_num'=>$finalNum, array(
// )); 'item_id' => V_ITEM_STAR,
$items = array( 'item_num' => $finalNum
array( ),
'item_id' => V_ITEM_STAR, );
'item_num' => $finalNum $propertyChgService = new services\PropertyChgService();
), $awardService = new services\AwardService();
); myself()->_addItems($items, $awardService,$propertyChgService);
$propertyChgService = new services\PropertyChgService(); }
$awardService = new services\AwardService();
myself()->_addItems($items, $awardService,$propertyChgService);
} }
} }
@ -682,11 +680,12 @@ class TameBattleDataService extends BaseService {
}else{ }else{
$finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]); $finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]);
} }
array_push($reward['items'],array( if ($finalNum > 0){
'item_id'=> V_ITEM_STAR, array_push($reward['items'],array(
'item_num'=>$finalNum, 'item_id'=> V_ITEM_STAR,
)); 'item_num'=>$finalNum,
));
}
} }
} }