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', '');
$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' =>'',

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

View File

@ -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;
}
}

View File

@ -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()
);

View File

@ -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;
}

View File

@ -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,

View File

@ -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;

View File

@ -655,10 +655,7 @@ 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){
$items = array(
array(
'item_id' => V_ITEM_STAR,
@ -669,6 +666,7 @@ class TameBattleDataService extends BaseService {
$awardService = new services\AwardService();
myself()->_addItems($items, $awardService,$propertyChgService);
}
}
}
public function calStarNum2(&$reward,$pvp_rank){
@ -682,11 +680,12 @@ class TameBattleDataService extends BaseService {
}else{
$finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]);
}
if ($finalNum > 0){
array_push($reward['items'],array(
'item_id'=> V_ITEM_STAR,
'item_num'=>$finalNum,
));
}
}
}