修改组队功能
This commit is contained in:
parent
a524e73546
commit
05a5ef3db7
57
doc/Team.py
57
doc/Team.py
@ -145,5 +145,62 @@ class Team(object):
|
|||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
|
},{
|
||||||
|
'name': 'doReady',
|
||||||
|
'desc': '准备/取消',
|
||||||
|
'group': 'Team',
|
||||||
|
'url': 'webapp/index.php?c=Team&a=doReady',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['team_uuid', '', '队伍唯一id'],
|
||||||
|
['ready_state', 0, '1:准备 0:取消'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
]
|
||||||
|
},{
|
||||||
|
'name': 'setHero',
|
||||||
|
'desc': '设置出战英雄',
|
||||||
|
'group': 'Team',
|
||||||
|
'url': 'webapp/index.php?c=Team&a=setHero',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['team_uuid', '', '队伍唯一id'],
|
||||||
|
['hero_uid', 0, '英雄uniid'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
]
|
||||||
|
},{
|
||||||
|
'name': 'setPreset',
|
||||||
|
'desc': '设置备战',
|
||||||
|
'group': 'Team',
|
||||||
|
'url': 'webapp/index.php?c=Team&a=setPreset',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['team_uuid', '', '队伍唯一id'],
|
||||||
|
['hero_uid', 0, '英雄uniid'],
|
||||||
|
['chip_page', 0, '铭文页id'],
|
||||||
|
['skill_id', 0, '技能item id'],
|
||||||
|
['weapon_uid1', 0, '枪1uniid'],
|
||||||
|
['weapon_uid2', 0, '枪2uniid'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
]
|
||||||
|
},{
|
||||||
|
'name': 'setHeroSkin',
|
||||||
|
'desc': '设置英雄皮肤',
|
||||||
|
'group': 'Team',
|
||||||
|
'url': 'webapp/index.php?c=Team&a=setHeroSkin',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['team_uuid', '', '队伍唯一id'],
|
||||||
|
['hero_uid', 0, '英雄uniid'],
|
||||||
|
['skin_id', 0, '皮肤item id'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -1,41 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('mt/Shop.php');
|
|
||||||
require_once('mt/Hero.php');
|
require_once('mt/Hero.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('mt/HeroLevel.php');
|
require_once('mt/HeroLevel.php');
|
||||||
require_once('mt/HeroLevelAttr.php');
|
|
||||||
require_once('mt/HeroQuality.php');
|
|
||||||
require_once('mt/AttrHelper.php');
|
|
||||||
require_once('mt/Parameter.php');
|
|
||||||
require_once('mt/SkillCommon.php');
|
|
||||||
require_once('mt/Skill.php');
|
require_once('mt/Skill.php');
|
||||||
|
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/Bag.php');
|
|
||||||
require_once('models/HeroSkin.php');
|
require_once('models/HeroSkin.php');
|
||||||
require_once('models/Nft.php');
|
require_once('models/Nft.php');
|
||||||
require_once('models/NftUpReceive.php');
|
|
||||||
require_once('models/Transaction.php');
|
|
||||||
require_once('models/ChipPage.php');
|
require_once('models/ChipPage.php');
|
||||||
require_once('models/Gun.php');
|
require_once('models/Gun.php');
|
||||||
|
require_once('models/HeroPreset.php');
|
||||||
|
|
||||||
require_once('services/AwardService.php');
|
require_once('services/AwardService.php');
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
require_once('services/RankActivityService.php');
|
|
||||||
require_once('services/LogService.php');
|
require_once('services/LogService.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\Bag;
|
|
||||||
use models\HeroSkin;
|
use models\HeroSkin;
|
||||||
use models\ChipPage;
|
use models\ChipPage;
|
||||||
use models\Gun;
|
use models\Gun;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
use models\NftUpReceive;
|
use models\HeroPreset;
|
||||||
use models\Transaction;
|
|
||||||
use services\LogService;
|
use services\LogService;
|
||||||
|
|
||||||
class HeroController extends BaseAuthedController {
|
class HeroController extends BaseAuthedController {
|
||||||
@ -265,48 +254,13 @@ class HeroController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function presetHero(){
|
public function presetHero(){
|
||||||
$heroId = getReqVal('hero_uid',0);
|
$heroUid = getReqVal('hero_uid',0);
|
||||||
$heroDb = Hero::find($heroId);
|
$heroDb = Hero::find($heroUid);
|
||||||
if (! $heroDb){
|
if (! $heroDb){
|
||||||
$this->_rspErr(1, "You don't have the hero yet");
|
$this->_rspErr(1, "You don't have the hero yet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$row = SqlHelper::ormSelectOne(
|
$data = HeroPreset::getHeroPreset($heroUid);
|
||||||
$this->_getSelfMysql(),
|
|
||||||
't_hero_preset',
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId(),
|
|
||||||
'hero_uid' => $heroId,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if ($row){
|
|
||||||
|
|
||||||
$data = array(
|
|
||||||
'skill_id' => $row['skill_id'],
|
|
||||||
'weapon_uid1' => $row['weapon_uid1'],
|
|
||||||
'weapon_uid2' => $row['weapon_uid2'],
|
|
||||||
'chip_page' => $row['chip_page'],
|
|
||||||
'gun_id1'=>0,
|
|
||||||
'gun_id2'=>0,
|
|
||||||
);
|
|
||||||
$gunDb1 = Gun::find($row['weapon_uid1']);
|
|
||||||
$gunDb2 = Gun::find($row['weapon_uid2']);
|
|
||||||
if ($gunDb1){
|
|
||||||
$data['gun_id1'] = $gunDb1['gun_id'];
|
|
||||||
}
|
|
||||||
if ($gunDb1){
|
|
||||||
$data['gun_id2'] = $gunDb2['gun_id'];
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$data = array(
|
|
||||||
'skill_id' => \mt\Skill::DEFAULT_SKILL,
|
|
||||||
'weapon_uid1' => 0,
|
|
||||||
'weapon_uid2' => 0,
|
|
||||||
'gun_id1'=>0,
|
|
||||||
'gun_id2'=>0,
|
|
||||||
'chip_page' => 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
));
|
));
|
||||||
@ -347,32 +301,7 @@ class HeroController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1,'skill_id parameter error');
|
$this->_rspErr(1,'skill_id parameter error');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
SqlHelper::upsert
|
HeroPreset::upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2);
|
||||||
($this->_getSelfMysql(),
|
|
||||||
't_hero_preset',
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId(),
|
|
||||||
'hero_uid' => $heroId,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'skill_id' => $skillId,
|
|
||||||
'weapon_uid1' => $weaponUid1,
|
|
||||||
'weapon_uid2' => $weaponUid2,
|
|
||||||
'chip_page' => $chipPageId,
|
|
||||||
'modifytime' => $this->_getNowTime(),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId(),
|
|
||||||
'hero_uid' => $heroId,
|
|
||||||
'skill_id' => $skillId,
|
|
||||||
'weapon_uid1' => $weaponUid1,
|
|
||||||
'weapon_uid2' => $weaponUid2,
|
|
||||||
'chip_page' => $chipPageId,
|
|
||||||
'createtime' => $this->_getNowTime(),
|
|
||||||
'modifytime' => $this->_getNowTime(),
|
|
||||||
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,21 @@
|
|||||||
|
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/Gun.php');
|
||||||
|
require_once('models/ChipPage.php');
|
||||||
|
require_once('models/HeroPreset.php');
|
||||||
|
require_once('models/HeroSkin.php');
|
||||||
|
|
||||||
require_once('mt/PveGemini.php');
|
require_once('mt/PveGemini.php');
|
||||||
|
require_once('mt/Skill.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\User;
|
use models\User;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
|
use models\Gun;
|
||||||
|
use models\ChipPage;
|
||||||
|
use models\HeroPreset;
|
||||||
|
use models\HeroSkin;
|
||||||
|
|
||||||
class TeamController extends BaseAuthedController {
|
class TeamController extends BaseAuthedController {
|
||||||
|
|
||||||
@ -60,8 +69,9 @@ class TeamController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$userDto = User::info($userDb);
|
$userDto = User::toPreset($userDb);
|
||||||
$userDto['is_leader'] =1;
|
$userDto['is_leader'] = 1;
|
||||||
|
$userDto['is_ready'] = 1;
|
||||||
$userDto['createtime'] = $userDb['createtime'];
|
$userDto['createtime'] = $userDb['createtime'];
|
||||||
$teamDb = array(
|
$teamDb = array(
|
||||||
'team_uuid' => $teamUuid,
|
'team_uuid' => $teamUuid,
|
||||||
@ -69,7 +79,7 @@ class TeamController extends BaseAuthedController {
|
|||||||
'payload' => '',
|
'payload' => '',
|
||||||
'match_mode' => $matchMode,
|
'match_mode' => $matchMode,
|
||||||
'pve_instance_id' => $pveInstanceId,
|
'pve_instance_id' => $pveInstanceId,
|
||||||
'slot_num' => 1,
|
// 'slot_num' => 1,
|
||||||
'member_list' => array($userDto));
|
'member_list' => array($userDto));
|
||||||
|
|
||||||
$r = $this->_getRedis($teamUuid);
|
$r = $this->_getRedis($teamUuid);
|
||||||
@ -103,10 +113,10 @@ class TeamController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, 'The team has been disbanded');
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count($teamDb['member_list']) >= $teamDb['slot_num']) {
|
// if (count($teamDb['member_list']) >= $teamDb['slot_num']) {
|
||||||
$this->_rspErr(2, 'The team is full');
|
// $this->_rspErr(2, 'The team is full');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
foreach ($teamDb['member_list'] as $member) {
|
foreach ($teamDb['member_list'] as $member) {
|
||||||
if ($member['account_id'] == $this->_getAccountId()) {
|
if ($member['account_id'] == $this->_getAccountId()) {
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
@ -136,7 +146,7 @@ class TeamController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$userDto = User::info($userDb);
|
$userDto = User::toPreset($userDb);
|
||||||
$userDto['createtime'] = $userDb['createtime'];
|
$userDto['createtime'] = $userDb['createtime'];
|
||||||
array_push($teamDb['member_list'], $userDto);
|
array_push($teamDb['member_list'], $userDto);
|
||||||
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
@ -362,6 +372,154 @@ class TeamController extends BaseAuthedController {
|
|||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function doReady(){
|
||||||
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$readyState = getReqVal('ready_state', 0); //1:准备 0:取消
|
||||||
|
if(!in_array($readyState,array(0,1))){
|
||||||
|
$this->_rspErr(1, 'ready_state param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$r = $this->_getRedis($teamUuid);
|
||||||
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
|
if (empty($teamDb)) {
|
||||||
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($teamDb['member_list'] as &$member) {
|
||||||
|
if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] == 1){
|
||||||
|
$this->_rspErr(1, 'Captain no operation');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($member['account_id'] == $this->_getAccountId()){
|
||||||
|
$member['is_ready'] = $readyState?:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHero(){
|
||||||
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$heroUid = getReqVal('hero_uid', '');
|
||||||
|
$heroDb = Hero::find($heroUid);
|
||||||
|
if (! $heroDb){
|
||||||
|
$this->_rspErr(1, 'hero_uid param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$r = $this->_getRedis($teamUuid);
|
||||||
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
|
if (empty($teamDb)) {
|
||||||
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_updateUserInfo(array(
|
||||||
|
'hero_id' => $heroUid
|
||||||
|
));
|
||||||
|
$newUserInfo = User::toPreset($this->_getOrmUserInfo());
|
||||||
|
foreach ($teamDb['member_list'] as &$member) {
|
||||||
|
if ($member['account_id'] == $this->_getAccountId()){
|
||||||
|
$newUserInfo['is_leader'] = $member['is_leader'];
|
||||||
|
$newUserInfo['is_ready'] = $member['is_ready'];
|
||||||
|
$member = $newUserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPreset(){
|
||||||
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$heroId = getReqVal('hero_uid',0);
|
||||||
|
$chipPageId = getReqVal('chip_page',0);
|
||||||
|
$weaponUid1 = getReqVal('weapon_uid1',0);
|
||||||
|
$weaponUid2 = getReqVal('weapon_uid2',0);
|
||||||
|
$skillId = getReqVal('skill_id',0);
|
||||||
|
$r = $this->_getRedis($teamUuid);
|
||||||
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
|
if (empty($teamDb)) {
|
||||||
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$heroDb = Hero::find($heroId);
|
||||||
|
if (! $heroDb){
|
||||||
|
$this->_rspErr(1, "You don't have the hero yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$chipPageDb = ChipPage::find($chipPageId);
|
||||||
|
if (! $chipPageDb){
|
||||||
|
$this->_rspErr(1, "You don't have the chip page");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($weaponUid1){
|
||||||
|
$gunDb1 = Gun::find($weaponUid1);
|
||||||
|
if (!$gunDb1){
|
||||||
|
$this->_rspErr(1, "You don't have the gun1 yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($weaponUid2){
|
||||||
|
$gunDb2 = Gun::find($weaponUid2);
|
||||||
|
if (!$gunDb2){
|
||||||
|
$this->_rspErr(1, "You don't have the gun2 yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$skillMeta = mt\Skill::get($skillId);
|
||||||
|
if (! $skillMeta){
|
||||||
|
$this->_rspErr(1,'skill_id parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
HeroPreset::upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2);
|
||||||
|
$newUserInfo = User::toPreset($this->_getOrmUserInfo());
|
||||||
|
foreach ($teamDb['member_list'] as &$member) {
|
||||||
|
if ($member['account_id'] == $this->_getAccountId()){
|
||||||
|
$newUserInfo['is_leader'] = $member['is_leader'];
|
||||||
|
$newUserInfo['is_ready'] = $member['is_ready'];
|
||||||
|
$member = $newUserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeroSkin(){
|
||||||
|
$teamUuid = getReqVal('team_uuid', '');
|
||||||
|
$heroUniId = getReqVal('hero_uid', 0);
|
||||||
|
$skinId = getReqVal('skin_id', 0);
|
||||||
|
$r = $this->_getRedis($teamUuid);
|
||||||
|
$teamDb = $this->readTeamDb($r, $teamUuid);
|
||||||
|
if (empty($teamDb)) {
|
||||||
|
$this->_rspErr(1, 'The team has been disbanded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$heroDb = Hero::find($heroUniId);
|
||||||
|
$heroSkinDb = HeroSkin::find($skinId);
|
||||||
|
if (!$heroDb) {
|
||||||
|
$this->_rspErr(1, "You don't have the hero yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$heroSkinDb) {
|
||||||
|
$this->_rspErr(2, "You don't have the skin yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']);
|
||||||
|
$newUserInfo = User::toPreset($this->_getOrmUserInfo());
|
||||||
|
foreach ($teamDb['member_list'] as &$member) {
|
||||||
|
if ($member['account_id'] == $this->_getAccountId()){
|
||||||
|
$newUserInfo['is_leader'] = $member['is_leader'];
|
||||||
|
$newUserInfo['is_ready'] = $member['is_ready'];
|
||||||
|
$member = $newUserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->saveTeamDb($r, $teamUuid, $teamDb);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function readTeamDb($r, $teamUuid)
|
private function readTeamDb($r, $teamUuid)
|
||||||
{
|
{
|
||||||
$teamDbStr = $r->get(TEAMID_KEY . $teamUuid);
|
$teamDbStr = $r->get(TEAMID_KEY . $teamUuid);
|
||||||
|
@ -8,7 +8,6 @@ require_once('mt/HeroQuality.php');
|
|||||||
require_once('mt/HeroLevel.php');
|
require_once('mt/HeroLevel.php');
|
||||||
require_once('mt/AttrHelper.php');
|
require_once('mt/AttrHelper.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('mt/SkillCommon.php');
|
|
||||||
require_once('models/HeroSkin.php');
|
require_once('models/HeroSkin.php');
|
||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
@ -425,12 +424,14 @@ class Hero extends BaseModel {
|
|||||||
|
|
||||||
$heroList = array();
|
$heroList = array();
|
||||||
Hero::getHeroList(function ($row) use($heroId, &$heroList) {
|
Hero::getHeroList(function ($row) use($heroId, &$heroList) {
|
||||||
if ($row['state'] == self::GETED_STATE) {
|
// if ($row['state'] == self::GETED_STATE) {
|
||||||
array_push($heroList, Hero::toDto($row));
|
array_push($heroList, Hero::toDto($row));
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
$key = null;
|
||||||
$key = array_rand($heroList, 1);
|
if (count($heroList)>0){
|
||||||
|
$key = array_rand($heroList, 1);
|
||||||
|
}
|
||||||
if (!is_null($key)) {
|
if (!is_null($key)) {
|
||||||
$heroUniId = $heroList[$key]['idx'];
|
$heroUniId = $heroList[$key]['idx'];
|
||||||
$heroId = $heroList[$key]['hero_id'];
|
$heroId = $heroList[$key]['hero_id'];
|
||||||
|
80
webapp/models/HeroPreset.php
Normal file
80
webapp/models/HeroPreset.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
namespace models;
|
||||||
|
require_once('mt/Skill.php');
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class HeroPreset extends BaseModel {
|
||||||
|
|
||||||
|
public static function getHeroPreset($heroUid){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hero_preset',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'hero_uid' => $heroUid,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($row){
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'skill_id' => $row['skill_id'],
|
||||||
|
'weapon_uid1' => $row['weapon_uid1'],
|
||||||
|
'weapon_uid2' => $row['weapon_uid2'],
|
||||||
|
'chip_page' => $row['chip_page'],
|
||||||
|
'gun_id1'=>0,
|
||||||
|
'gun_id2'=>0,
|
||||||
|
);
|
||||||
|
$gunDb1 = Gun::find($row['weapon_uid1']);
|
||||||
|
$gunDb2 = Gun::find($row['weapon_uid2']);
|
||||||
|
if ($gunDb1){
|
||||||
|
$data['gun_id1'] = $gunDb1['gun_id'];
|
||||||
|
}
|
||||||
|
if ($gunDb2){
|
||||||
|
$data['gun_id2'] = $gunDb2['gun_id'];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$data = array(
|
||||||
|
'skill_id' => mt\Skill::DEFAULT_SKILL,
|
||||||
|
'weapon_uid1' => 0,
|
||||||
|
'weapon_uid2' => 0,
|
||||||
|
'gun_id1'=>0,
|
||||||
|
'gun_id2'=>0,
|
||||||
|
'chip_page' => 1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2){
|
||||||
|
SqlHelper::upsert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hero_preset',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'hero_uid' => $heroId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
'weapon_uid1' => $weaponUid1,
|
||||||
|
'weapon_uid2' => $weaponUid2,
|
||||||
|
'chip_page' => $chipPageId,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'hero_uid' => $heroId,
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
'weapon_uid1' => $weaponUid1,
|
||||||
|
'weapon_uid2' => $weaponUid2,
|
||||||
|
'chip_page' => $chipPageId,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ require_once('mt/LevelUp.php');
|
|||||||
require_once('models/UserSeasonRing.php');
|
require_once('models/UserSeasonRing.php');
|
||||||
require_once('models/Parachute.php');
|
require_once('models/Parachute.php');
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/HeroPreset.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
@ -45,9 +46,15 @@ class User extends BaseModel {
|
|||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
$heroDb = Hero::find($row['hero_id']);
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
$heroId = 0;
|
|
||||||
if ($heroDb){
|
if ($heroDb){
|
||||||
$heroId = $heroDb['hero_id'];
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}else{
|
||||||
|
$heroUniId = 0;
|
||||||
|
$heroId = 0;
|
||||||
|
Hero::randHero($heroUniId,$heroId);
|
||||||
|
self::update(array(
|
||||||
|
'hero_id' => $heroUniId
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return array(
|
return array(
|
||||||
'activated' => $row['activated'],
|
'activated' => $row['activated'],
|
||||||
@ -90,10 +97,17 @@ class User extends BaseModel {
|
|||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
$heroDb = Hero::find($row['hero_id']);
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
$heroId = 0;
|
|
||||||
if ($heroDb){
|
if ($heroDb){
|
||||||
$heroId = $heroDb['hero_id'];
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}else{
|
||||||
|
$heroUniId = 0;
|
||||||
|
$heroId = 0;
|
||||||
|
Hero::randHero($heroUniId,$heroId);
|
||||||
|
self::update(array(
|
||||||
|
'hero_id' => $heroUniId
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'activated' => $row['activated'],
|
'activated' => $row['activated'],
|
||||||
'rename_count' => $row['rename_count'],
|
'rename_count' => $row['rename_count'],
|
||||||
@ -136,10 +150,17 @@ class User extends BaseModel {
|
|||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
$heroDb = Hero::find($row['hero_id']);
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
$heroId = 0;
|
|
||||||
if ($heroDb){
|
if ($heroDb){
|
||||||
$heroId = $heroDb['hero_id'];
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}else{
|
||||||
|
$heroUniId = 0;
|
||||||
|
$heroId = 0;
|
||||||
|
Hero::randHero($heroUniId,$heroId);
|
||||||
|
self::update(array(
|
||||||
|
'hero_id' => $heroUniId
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'account_id' => $row['account_id'],
|
'account_id' => $row['account_id'],
|
||||||
'address' => phpcommon\extractOpenId($row['account_id']),
|
'address' => phpcommon\extractOpenId($row['account_id']),
|
||||||
@ -160,19 +181,50 @@ class User extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function toPreset($row){
|
||||||
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
|
$heroId = 0;
|
||||||
|
if ($heroDb){
|
||||||
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}
|
||||||
|
$preset = HeroPreset::getHeroPreset($row['hero_id']);
|
||||||
|
$skinDb = HeroSkin::findBx($heroId);
|
||||||
|
return array(
|
||||||
|
'account_id' => $row['account_id'],
|
||||||
|
'address' => phpcommon\extractOpenId($row['account_id']),
|
||||||
|
'name' => $row['name'],
|
||||||
|
// 'sex' => $row['sex'],
|
||||||
|
// 'head_id' => $row['head_id'],
|
||||||
|
// 'head_frame' => $row['head_frame'],
|
||||||
|
'level' => $row['level'],
|
||||||
|
'exp' => $row['exp'],
|
||||||
|
'rank' => $row['rank'],
|
||||||
|
'score' => $row['score'],
|
||||||
|
// 'gold' => cegFormat($row['gold']),
|
||||||
|
// 'diamond' => cecFormat($row['diamond']),
|
||||||
|
'pve_instance_id' => $row['pve_instance_id'],
|
||||||
|
// 'like_count' => $row['like_count'],
|
||||||
|
'first_fight' => $row['first_fight'],
|
||||||
|
'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute,
|
||||||
|
'hero_uniId' => $row['hero_id'],
|
||||||
|
'hero_id' => $heroId,
|
||||||
|
'hero_skin' =>$skinDb['skin_id'],
|
||||||
|
'presetInfo' => $preset,
|
||||||
|
'is_leader' => 0,
|
||||||
|
'is_ready' => 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function isValidHeadId($userInfo, $headId)
|
public static function isValidHeadId($userInfo, $headId)
|
||||||
{
|
{
|
||||||
// $headList = self::exportHeadList($userInfo);
|
|
||||||
// return in_array($headId, $headList['head_list']);
|
|
||||||
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
||||||
return in_array($headId, $headList);
|
return in_array($headId, $headList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isValidHeroId($userInfo, $heroId)
|
public static function isValidHeroId($userInfo, $heroId)
|
||||||
{
|
{
|
||||||
// $heroList = self::exportHeadList($userInfo);
|
$heroDb = Hero::findByAccountId($userInfo['account_id'],$heroId);
|
||||||
// return in_array($heroId, $heroList['hero_list']);
|
|
||||||
$heroDb = Hero::find($heroId);
|
|
||||||
return empty($heroDb) ? false : true ;
|
return empty($heroDb) ? false : true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,21 +260,6 @@ class User extends BaseModel {
|
|||||||
return $headList;
|
return $headList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function exportHeadList($userInfo){
|
|
||||||
$list = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
|
||||||
$head_list = array();
|
|
||||||
$hero_list = array();
|
|
||||||
foreach ($list as $value){
|
|
||||||
$temp = explode('|',$value);
|
|
||||||
array_push($head_list,$temp[0]);
|
|
||||||
array_push($hero_list,$temp[1]);
|
|
||||||
}
|
|
||||||
return array(
|
|
||||||
'head_list'=>$head_list,
|
|
||||||
'hero_list'=>$hero_list,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function update( $fieldsKv){
|
public static function update( $fieldsKv){
|
||||||
SqlHelper::update
|
SqlHelper::update
|
||||||
(myself()->_getSelfMysql(),
|
(myself()->_getSelfMysql(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user