历史战绩
This commit is contained in:
parent
1bb5b01e16
commit
16b8525f5f
@ -91,4 +91,18 @@ class Battle(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'desc': '历史战绩',
|
||||||
|
'group': 'Battle',
|
||||||
|
'url': 'webapp/index.php?c=Battle&a=getBattleHistory',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
|
||||||
|
['mode', _common.BattleMember(), '0:pvp 1:排位 2:pve']
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['!data', _common.BattleHistory(), '战绩数据'],
|
||||||
|
]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
@ -820,3 +820,29 @@ class BattleReward(object):
|
|||||||
['weapon2', BattleCegReward(), '武器2奖励'],
|
['weapon2', BattleCegReward(), '武器2奖励'],
|
||||||
['!items', [BattleItemReward()], '碎片奖励'],
|
['!items', [BattleItemReward()], '碎片奖励'],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class BattleHistory(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.fields = [
|
||||||
|
['idx', 0, '唯一id'],
|
||||||
|
['battle_uniid', 0, '战斗记录唯一id'],
|
||||||
|
['account_id', '', '用户 account_id'],
|
||||||
|
['match_mode', 0, '0: 匹配 pvp 1: 排位赛 2: pve'],
|
||||||
|
['team_mode',0, '0:单人 1:组队'],
|
||||||
|
['battle_rank', 0, '战斗排名'],
|
||||||
|
['team_rank',0, '团队排名'],
|
||||||
|
['is_win', 0, 'pve冒险是否胜利'],
|
||||||
|
['kills',0, '击杀数'],
|
||||||
|
['hero_id',0, '英雄 id'],
|
||||||
|
['weapon1', 0, '枪械1 id'],
|
||||||
|
['weapon2', 0, '枪械2 id'],
|
||||||
|
['damage', 0, '伤害'],
|
||||||
|
['battle_end_time', 0, '战斗结束时间'],
|
||||||
|
['current_level_class', '', '当前用户段位'],
|
||||||
|
['current_level_class_score', 0, '当前用户排位分'],
|
||||||
|
['level_class_score_chg', 0, '排位分改变'],
|
||||||
|
['pve_rank_score', 0, 'pve冒险积分'],
|
||||||
|
['pve_kill_boss', 0, 'pve冒险是否击杀BOSS'],
|
||||||
|
['battle_foreign_key', 0, '结算外键'],
|
||||||
|
]
|
@ -3,12 +3,13 @@
|
|||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/Gun.php');
|
require_once('models/Gun.php');
|
||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
|
require_once('models/BattleHistory.php');
|
||||||
require_once('services/BattleDataService.php');
|
require_once('services/BattleDataService.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\Gun;
|
use models\Gun;
|
||||||
use models\Chip;
|
use models\BattleHistory;
|
||||||
|
|
||||||
class BattleController extends BaseAuthedController {
|
class BattleController extends BaseAuthedController {
|
||||||
|
|
||||||
@ -159,4 +160,19 @@ class BattleController extends BaseAuthedController {
|
|||||||
myself()->_rspData($data);
|
myself()->_rspData($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBattleHistory(){
|
||||||
|
$mode = getReqVal('mode', 0);
|
||||||
|
$historyList = BattleHistory::getMyBattleHistory();
|
||||||
|
$data = array();
|
||||||
|
foreach ($historyList as $history){
|
||||||
|
if ($history['match_mode'] == $mode){
|
||||||
|
array_push($data,BattleHistory::toDto($history));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$list = BattleHistory::orderBy($data,'desc');
|
||||||
|
$this->_rspData(array(
|
||||||
|
'data' => $list
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
namespace models;
|
namespace models;
|
||||||
|
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/Gun.php');
|
||||||
|
|
||||||
|
require_once('mt/Hero.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
class BattleHistory extends BaseModel
|
class BattleHistory extends BaseModel
|
||||||
@ -28,4 +33,46 @@ class BattleHistory extends BaseModel
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function toDto($row){
|
||||||
|
if ($row['hero_id']){
|
||||||
|
$row['hero_id'] = Hero::find($row['hero_id'])['hero_id'];
|
||||||
|
}
|
||||||
|
if ($row['weapon1']){
|
||||||
|
$row['weapon1'] = Gun::find($row['weapon1'])['gun_id'];
|
||||||
|
}
|
||||||
|
if ($row['weapon2']){
|
||||||
|
$row['weapon2'] = Gun::find($row['weapon2'])['gun_id'];
|
||||||
|
}
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function orderBy($data,$order){
|
||||||
|
$len = count($data);
|
||||||
|
if ($len<=1){
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
if ($order == 'desc'){
|
||||||
|
for ($i = 0; $i < $len - 1; $i++) {
|
||||||
|
for ($j = $i + 1; $j < $len; $j++) {
|
||||||
|
if ($data[$i]['idx'] < $data[$j]['idx']) {
|
||||||
|
$tmp = $data[$i];
|
||||||
|
$data[$i] = $data[$j];
|
||||||
|
$data[$j] = $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for ($i = 0; $i < $len - 1; $i++) {
|
||||||
|
for ($j = $i + 1; $j < $len; $j++) {
|
||||||
|
if ($data[$i]['idx'] > $data[$j]['idx']) {
|
||||||
|
$tmp = $data[$i];
|
||||||
|
$data[$i] = $data[$j];
|
||||||
|
$data[$j] = $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user