修改获取战斗的数据
This commit is contained in:
parent
3507da323d
commit
1c8f6dc18a
@ -107,13 +107,44 @@ class Battle(object):
|
||||
['rank_score', _common.BattleRankScore(), '排位分信息'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'desc': '获取战斗数据(客户端不用处理)getBattleData',
|
||||
'group': 'Battle',
|
||||
'url': 'webapp/index.php?c=Battle&a=getBattleData',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['account_id', '', 'account_id'],
|
||||
['session_id', '', 'session_id'],
|
||||
['battle_uuid', '', 'battle_uuid'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['account_id','','account_id'],
|
||||
['session_id','','session_id'],
|
||||
['battle_uuid','','battle_uuid'],
|
||||
['match_mode',0,'0:匹配 1:排位 2:pve'],
|
||||
['name','','用户名字'],
|
||||
['level',0,'用户等级'],
|
||||
['revive_coin',0,'复活币'],
|
||||
['hero_uniid',0,'英雄 uniid'],
|
||||
['hero_id',0,'英雄 item id'],
|
||||
['weapon_uuid1',0,'武器1 uniid'],
|
||||
['weapon_uuid2',0,'武器2 uniid'],
|
||||
['parachute',0,'降落伞 item id'],
|
||||
['hero_skin',0,'英雄皮肤 item id'],
|
||||
['skill_id',0,'备战技能 item id'],
|
||||
['chip_page',_common.Attr(),'铭文页属性'],
|
||||
['hero_dto','','英雄详情'],
|
||||
['weapon_dto1','','武器1详情'],
|
||||
['weapon_dto2','','武器2详情'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'desc': '获取战斗数据(客户端不用处理)getBattleDataNew',
|
||||
'group': 'Battle',
|
||||
'url': 'webapp/index.php?c=Battle&a=getBattleDataNew',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
|
||||
['!members', _common.BattleMember(), '成员数据']
|
||||
],
|
||||
'response': [
|
||||
|
@ -10,6 +10,7 @@ require_once('models/BattleSettlement.php');
|
||||
require_once('models/BattleHistory.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Parachute.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('services/BattleDataService.php');
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
@ -24,6 +25,7 @@ use models\BattleHistory;
|
||||
use models\BattleSettlement;
|
||||
use models\User;
|
||||
use models\Parachute;
|
||||
use models\ChipPage;
|
||||
|
||||
class BattleController extends BaseAuthedController {
|
||||
|
||||
@ -127,67 +129,98 @@ class BattleController extends BaseAuthedController {
|
||||
|
||||
public function getBattleData()
|
||||
{
|
||||
$mode = getReqVal('mode', '');
|
||||
$members = json_decode(getReqVal('members', ''), true);
|
||||
|
||||
error_log(json_encode($_REQUEST));
|
||||
$data = array(
|
||||
'members' => array()
|
||||
);
|
||||
error_log(json_encode($_REQUEST));
|
||||
error_log(json_encode($members));
|
||||
foreach ($members as $member) {
|
||||
$user = User::find($member['account_id']);
|
||||
$info = array(
|
||||
'account_id' => $member['account_id'],
|
||||
'session_id' => $member['session_id'],
|
||||
'hero_uniid' => $member['hero_uniid'],
|
||||
'weapon_uuid1' => $member['weapon_uuid1'],
|
||||
'weapon_uuid2' => $member['weapon_uuid2'],
|
||||
'battle_uuid' => $member['battle_uuid'],
|
||||
'hero_dto' => '',
|
||||
'weapon_dto1' => '',
|
||||
'weapon_dto2' => '',
|
||||
'level' =>$user['level'],
|
||||
$currSeason = mt\RankSeason::getCurrentSeason();
|
||||
$account_id = getReqVal('account_id', '');
|
||||
$session_id = getReqVal('session_id', '');
|
||||
$battle_uuid = getReqVal('battle_uuid', '');
|
||||
$info = array(
|
||||
'account_id' => $account_id,
|
||||
'session_id' => $session_id,
|
||||
'battle_uuid' => $battle_uuid,
|
||||
'name' => '',
|
||||
'level' =>'',
|
||||
'hero_uniid' => '',
|
||||
'hero_id' => '',
|
||||
'weapon_uuid1' => '',
|
||||
'weapon_uuid2' => '',
|
||||
'parachute' => '',
|
||||
'hero_skin' => '',
|
||||
'skill_id' => '',
|
||||
'chip_page' => array(),
|
||||
|
||||
'is_valid_battle' => 0,
|
||||
'payload' => json_encode($member['cmjoin']),
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
);
|
||||
if (!phpcommon\isValidSessionId($member['account_id'], $member['session_id'])) {
|
||||
$info['errcode'] = 50;
|
||||
$info['errmsg'] = 'invalid session_id';
|
||||
} else {
|
||||
{
|
||||
$heroDb = Hero::findByAccountId($member['account_id'],
|
||||
$member['hero_uniid']);
|
||||
if ($heroDb) {
|
||||
$info['is_valid_battle'] = 1;
|
||||
$info['hero_dto'] = Hero::toDto($heroDb);
|
||||
{//选用皮肤id
|
||||
$skinDb = HeroSkin::findBx($heroDb['hero_id']);
|
||||
if ($skinDb){
|
||||
$info['hero_dto']['skin_id'] = $skinDb['skin_id'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
}
|
||||
'hero_dto' => '',
|
||||
'weapon_dto1' => '',
|
||||
'weapon_dto2' => '',
|
||||
'is_valid_battle' => 0,
|
||||
//'payload' => json_encode($member['cmjoin']),
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
);
|
||||
if (!phpcommon\isValidSessionId($account_id, $session_id)) {
|
||||
$info['errcode'] = 50;
|
||||
$info['errmsg'] = 'invalid session_id';
|
||||
}else{
|
||||
{
|
||||
$userDb = User::find($account_id);
|
||||
if ($userDb){
|
||||
$userPresetInfo = User::toPreset($userDb);
|
||||
$info['name'] = $userPresetInfo['name'];
|
||||
$info['level'] = $userPresetInfo['level'];
|
||||
$info['parachute'] = $userPresetInfo['parachute'];
|
||||
$info['hero_uniid'] = $userPresetInfo['hero_uniId'];
|
||||
$info['hero_id'] = $userPresetInfo['hero_id'];
|
||||
$info['hero_skin'] = $userPresetInfo['hero_skin'];
|
||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']);
|
||||
$info['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||
|
||||
}else{
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
}
|
||||
{
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
$gunDb = Gun::findByAccountId($member['account_id'],
|
||||
$member['weapon_uuid' . $i]);
|
||||
}
|
||||
|
||||
{
|
||||
$heroDb = Hero::findByAccountId($account_id,$info['hero_uniid']);
|
||||
if ($heroDb) {
|
||||
$info['is_valid_battle'] = 1;
|
||||
$info['hero_dto'] = Hero::toDto($heroDb);
|
||||
} else {
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if (isset($info['weapon_uuid' . $i])) {
|
||||
$gunDb = Gun::findByAccountId($account_id, $info['weapon_uuid' . $i]);
|
||||
if ($gunDb) {
|
||||
$info['weapon_dto' . $i] = Gun::toDto($gunDb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($data['members'], $info);
|
||||
|
||||
{
|
||||
$itemDb = Bag::findEx($account_id, V_ITEM_REVIVE_COIN);
|
||||
$info['revive_coin'] = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0;
|
||||
}
|
||||
|
||||
{
|
||||
$info['match_mode'] = 0;
|
||||
if ($currSeason && DynData::getVEx($account_id, TN_RANK_STATUS, 0) == 0){
|
||||
$info['match_mode'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
error_log(json_encode($data));
|
||||
array_push($data['members'], $info);
|
||||
myself()->_rspData($data);
|
||||
}
|
||||
|
||||
@ -244,7 +277,7 @@ class BattleController extends BaseAuthedController {
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if (isset($member['weapon_uuid' . $i])) {
|
||||
$gunDb = Gun::findByAccountId($member['account_id'],
|
||||
$member['weapon_uuid' . $i]);
|
||||
$member['weapon_uuid' . $i]);
|
||||
if ($gunDb) {
|
||||
$info['weapon_dto' . $i] = Gun::toDto($gunDb);
|
||||
}
|
||||
@ -267,6 +300,7 @@ class BattleController extends BaseAuthedController {
|
||||
}
|
||||
// $attr = Hero::getChipAttr($info['hero_dto']['chip_ids']);
|
||||
myself()->_rspData($data);
|
||||
|
||||
}
|
||||
|
||||
public function getBattleHistory(){
|
||||
|
@ -99,6 +99,47 @@ class ChipPage extends BaseModel
|
||||
return $info;
|
||||
}
|
||||
|
||||
public static function toDtoBattle($row){
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
foreach ($data as &$value){
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
if ( !$chipDb ) {
|
||||
$value['chip_id'] = 0;
|
||||
}
|
||||
}
|
||||
self::update($row['page_id'],array(
|
||||
'data' => json_encode($data)
|
||||
));
|
||||
$newRow = self::find($row['page_id']);
|
||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||
$attrs = array();
|
||||
foreach ($newData as $key=>$value){
|
||||
$newData[$key]['item_id'] = 0;
|
||||
if ($value['chip_id']){
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
$newData[$key]['item_id'] = $chipDb['item_id'];
|
||||
$chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']);
|
||||
$rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
|
||||
array_push($attrs,array(
|
||||
'attr_id'=>$chipAttrMeta['attr_id'],
|
||||
'val'=>$chipAttrMeta['lv'.$chipDb['chip_grade']],
|
||||
));
|
||||
foreach ($rand_attr as $val){
|
||||
array_push($attrs,$val);
|
||||
}
|
||||
}
|
||||
}
|
||||
$item = [];
|
||||
foreach ($attrs as $k=>$v){
|
||||
if (!isset($item[$v['attr_id']])){
|
||||
$item[$v['attr_id']] = $v;
|
||||
}else{
|
||||
$item[$v['attr_id']]['val']+= $v['val'];
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function updatePage($page,$slot_id,$chip_id){
|
||||
$row = self::find($page);
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
|
Loading…
x
Reference in New Issue
Block a user