用户五维图修改
This commit is contained in:
parent
8b90fe7e5a
commit
a2a1c09648
15
doc/User.py
15
doc/User.py
@ -110,6 +110,21 @@ class User(object):
|
||||
['info',_common.UserDetailInfo(), '用户信息(详细)'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'chartInfo',
|
||||
'desc': '用户五维图信息',
|
||||
'group': 'User',
|
||||
'url': 'webapp/index.php?c=User&a=chartInfo',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['target_id', '', '用户account_id(如果要获取自己的就传自己的account_id)']
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['pvpInfo',_common.UserChartInfo(), '4v4数据'],
|
||||
['mobaInfo',_common.UserChartInfo(), 'moba数据'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'like',
|
||||
'desc': '点赞',
|
||||
|
@ -231,27 +231,27 @@ class UserDetailInfo(object):
|
||||
['guild_id', '', '工会id'],
|
||||
['guild_job', 0, '工会职位'],
|
||||
['guild_name', '', '工会名称'],
|
||||
['!history_seasons', [UserHisSeason()], '历史打过的赛季列表'],
|
||||
]
|
||||
|
||||
class UserHisSeason(object):
|
||||
class UserChartInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['season_id', 0, '赛季'],
|
||||
['total_kills', 0, '击杀总数(个人信息)'],
|
||||
['game_times', 0, '游戏场次(个人信息)'],
|
||||
['win_times', 0, '胜利场次(个人信息)'],
|
||||
['win_rate', 0, '胜率(个人信息,百分比数值整数部分)'],
|
||||
['max_kills', 0, '最高击杀(游戏信息)'],
|
||||
['avg_kills', 0, '平均击杀(游戏信息)'],
|
||||
['max_damage_out', 0, '最高伤害输出(游戏信息)'],
|
||||
['avg_damage_out', 0, '平均伤害输出(游戏信息)'],
|
||||
['kills_avg', 0, '场均击杀'],
|
||||
['assist_avg', 0, '场均助攻'],
|
||||
['damage_avg', 0, '场均伤害'],
|
||||
['recover_avg', 0, '场均恢复'],
|
||||
['win_avg', 0, '场均胜率(4v4模式下才有)'],
|
||||
['level_avg', 0, '场均等级(moba模式下才有)'],
|
||||
['star_kills', 0, '击败(5纬图-击败, 百分比数值整数部分)'],
|
||||
['star_damage', 0, '伤害(5纬图-伤害, 百分比数值整数部分)'],
|
||||
['star_alive', 0, '生存(5纬图-生存, 百分比数值整数部分)'],
|
||||
['star_recover', 0, '治疗(5纬图-治疗, 百分比数值整数部分)'],
|
||||
['star_win', 0, '胜利(5纬图-胜利, 百分比数值整数部分)'],
|
||||
['star_win', 0, '胜利(5纬图-胜利, 百分比数值整数部分,4v4模式下才有)'],
|
||||
['star_level', 0, '等级(5纬图-胜利, 百分比数值整数部分,moba模式下才有)'],
|
||||
]
|
||||
|
||||
class Hero(object):
|
||||
|
@ -10,6 +10,7 @@ require_once('models/Chip.php');
|
||||
require_once('models/Battle.php');
|
||||
require_once('models/SignLog.php');
|
||||
require_once('models/UserHonor.php');
|
||||
require_once('models/GlobalData.php');
|
||||
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
@ -38,6 +39,7 @@ use models\UserSeasonRing;
|
||||
use models\Battle;
|
||||
use models\SignLog;
|
||||
use models\UserHonor;
|
||||
use models\GlobalData;
|
||||
|
||||
class UserController extends BaseAuthedController {
|
||||
private $init_rank = 'rank_init_rank';
|
||||
@ -510,6 +512,192 @@ class UserController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function chartInfo(){
|
||||
$targetId = getReqVal('target_id', '');
|
||||
$userDb = User::find($targetId);
|
||||
if (!$userDb) {
|
||||
$this->_rspErr(1, 'Account does not exist');
|
||||
return;
|
||||
}
|
||||
$pvpData = array(
|
||||
'game_times' => 0,
|
||||
'total_kills' => 0,
|
||||
'win_times' => 0,
|
||||
'win_avg' => 0,
|
||||
'kills_avg' => 0,
|
||||
'assist_avg' => 0,
|
||||
'damage_avg' => 0,
|
||||
'recover_avg' => 0,
|
||||
'star_win' => 0,
|
||||
'star_kills' => 0,
|
||||
'star_assist' => 0,
|
||||
'star_damage' => 0,
|
||||
'star_recover' => 0,
|
||||
);
|
||||
$mobaData = array(
|
||||
'game_times' => 0,
|
||||
'total_kills' => 0,
|
||||
'win_times' => 0,
|
||||
'level_avg' => 0,
|
||||
'kills_avg' => 0,
|
||||
'assist_avg' => 0,
|
||||
'damage_avg' => 0,
|
||||
'recover_avg' => 0,
|
||||
'star_level' => 0,
|
||||
'star_kills' => 0,
|
||||
'star_assist' => 0,
|
||||
'star_damage' => 0,
|
||||
'star_recover' => 0,
|
||||
);
|
||||
$battleDb = Battle::find($targetId);
|
||||
if ($battleDb){
|
||||
$battleData = json_decode($battleDb['battle_data'], true);
|
||||
$dataInfo = isset($battleData) ? getXVal($battleData, 'data', array()) : array();
|
||||
$gameTimes = getXVal($dataInfo, 'total_battle_times', 0); //游戏场次
|
||||
$winTimes = getXVal($dataInfo, 'total_win_times', 0); //胜利场次
|
||||
// $maxWin = $winTimes > 0 ? 1 : 0; //最高胜利
|
||||
$winPer = $gameTimes > 0 ? intval($winTimes / $gameTimes) : 0; //胜率
|
||||
$totalKills = getXVal($dataInfo, 'total_kills_times', 0); //总击杀
|
||||
// $maxKills = getXVal($dataInfo, 'max_kills_times', 0); //最高击杀
|
||||
$killsPer = $gameTimes > 0 ? intval($totalKills / $gameTimes) : 0; //场均击杀
|
||||
$totalAssist = getXVal($dataInfo, 'total_assist_time', 0); //总助攻
|
||||
// $maxAssist = getXVal($dataInfo, 'max_assist_time', 0); //最高助攻
|
||||
$assistPer = $gameTimes > 0 ? intval($totalAssist / $gameTimes) : 0; //场均助攻
|
||||
$totalDamage = getXVal($dataInfo, 'total_damage_out', 0); //总伤害
|
||||
// $maxDamage = getXVal($dataInfo, 'max_damage_out', 0); //最高伤害
|
||||
$damagePer = $gameTimes > 0 ? intval($totalDamage / $gameTimes) : 0; //场均伤害
|
||||
$totalRecoverHp = getXVal($dataInfo, 'total_recover_hp', 0); //总回复
|
||||
// $maxRecoverHp = getXVal($dataInfo, 'max_recover_hp', 0); //最高回复
|
||||
$recoverHpPer = $gameTimes > 0 ? intval($totalRecoverHp / $gameTimes) : 0; //场均回复
|
||||
$pvpData['game_times'] = $gameTimes;
|
||||
$pvpData['total_kills'] = $totalKills;
|
||||
$pvpData['win_times'] = $winTimes;
|
||||
$pvpData['win_avg'] = $winPer;
|
||||
$pvpData['kills_avg'] = $killsPer;
|
||||
$pvpData['assist_avg'] = $assistPer;
|
||||
$pvpData['damage_avg'] = $damagePer;
|
||||
$pvpData['recover_avg'] = $recoverHpPer;
|
||||
|
||||
$mobaDataInfo = isset($battleData) ? getXVal($battleData, 'moba_data', array()) : array();
|
||||
$gameTimesMoba = getXVal($mobaDataInfo, 'total_battle_times', 0);
|
||||
$winTimesMoba = getXVal($mobaDataInfo, 'total_win_times', 0);
|
||||
$totalLevelMoba = getXVal($mobaDataInfo, 'total_level', 0);
|
||||
$levelPerMoba = $gameTimesMoba > 0 ? intval($totalLevelMoba / $gameTimesMoba) : 0;
|
||||
$totalKillsMoba = getXVal($mobaDataInfo, 'total_kills_times', 0);
|
||||
$killsPerMoba = $gameTimesMoba > 0 ? intval($totalKillsMoba / $gameTimesMoba) : 0;
|
||||
$totalAssistMoba = getXVal($mobaDataInfo, 'total_assist_time', 0);
|
||||
$assistPerMoba = $gameTimesMoba > 0 ? intval($totalAssistMoba / $gameTimesMoba) : 0;
|
||||
$totalDamageMoba = getXVal($mobaDataInfo, 'total_damage_out', 0);
|
||||
$damagePerMoba = $totalDamageMoba > 0 ? intval($totalDamageMoba / $totalDamageMoba) : 0;
|
||||
$totalRecoverHpMoba = getXVal($mobaDataInfo, 'total_recover_hp', 0);
|
||||
$recoverHpPerMoba = $totalDamageMoba > 0 ? intval($totalRecoverHpMoba / $totalDamageMoba) : 0;
|
||||
$mobaData['game_times'] = $gameTimesMoba;
|
||||
$mobaData['total_kills'] = $totalKillsMoba;
|
||||
$mobaData['win_times'] = $winTimesMoba;
|
||||
$mobaData['level_avg'] = $levelPerMoba;
|
||||
$mobaData['kills_avg'] = $killsPerMoba;
|
||||
$mobaData['assist_avg'] = $assistPerMoba;
|
||||
$mobaData['damage_avg'] = $damagePerMoba;
|
||||
$mobaData['recover_avg'] = $recoverHpPerMoba;
|
||||
if (Battle::getBattleCount() >= Battle::VALID_BATTLE_COUNT){
|
||||
$userChartData = GlobalData::getUserChartData();
|
||||
if (!$userChartData){
|
||||
$battlesDb = Battle::getBattleDataLimit();
|
||||
$totalBattleCount = Battle::getBattleCount();
|
||||
$totalWinPerPvp = 0;
|
||||
$totalKillsPerPvp = 0;
|
||||
$totalAssistPerPvp = 0;
|
||||
$totalDamagePerPvp = 0;
|
||||
$totalRecoverHpPerPvp = 0;
|
||||
|
||||
$totalKillsPerMoba = 0;
|
||||
$totalAssistPerMoba = 0;
|
||||
$totalDamagePerMoba = 0;
|
||||
$totalRecoverHpPerMoba = 0;
|
||||
$totalLevelPerMoba = 0;
|
||||
foreach ($battlesDb as $battle){
|
||||
$battleDataEx = json_decode($battle['battle_data'], true);
|
||||
$pvpDataInfoEx = isset($battleDataEx) ? getXVal($battleDataEx, 'data', array()) : array();
|
||||
$gameTimes_pvp = getXVal($pvpDataInfoEx, 'total_battle_times', 0);
|
||||
$winTimes_pvp = getXVal($pvpDataInfoEx, 'total_win_times', 0);
|
||||
$totalWinPerPvp += $gameTimes_pvp > 0 ? intval($winTimes_pvp / $gameTimes_pvp) : 0;
|
||||
$totalKills_pvp = getXVal($pvpDataInfoEx, 'total_kills_times', 0);
|
||||
$totalKillsPerPvp += $gameTimes_pvp > 0 ? intval($totalKills_pvp / $gameTimes_pvp) : 0;
|
||||
$totalAssist_pvp = getXVal($pvpDataInfoEx, 'total_assist_time', 0);
|
||||
$totalAssistPerPvp += $gameTimes_pvp > 0 ? intval($totalAssist_pvp / $gameTimes_pvp) : 0;
|
||||
$totalDamage_pvp = getXVal($pvpDataInfoEx, 'total_damage_out', 0);
|
||||
$totalDamagePerPvp += $gameTimes_pvp > 0 ? intval($totalDamage_pvp / $gameTimes_pvp) : 0;
|
||||
$totalRecoverHp_pvp = getXVal($pvpDataInfoEx, 'total_recover_hp', 0);
|
||||
$totalRecoverHpPerPvp += $gameTimes_pvp > 0 ? intval($totalRecoverHp_pvp / $gameTimes_pvp) : 0;
|
||||
|
||||
$mobaDataInfoEx = isset($battleData) ? getXVal($battleDataEx, 'moba_data', array()) : array();
|
||||
$gameTimes_moba = getXVal($mobaDataInfoEx, 'total_battle_times', 0);
|
||||
$totalLevel_moba = getXVal($mobaDataInfoEx, 'total_level', 0);
|
||||
$totalLevelPerMoba += $gameTimes_moba > 0 ? intval($totalLevel_moba / $gameTimes_moba) : 0;
|
||||
$totalKills_moba = getXVal($mobaDataInfoEx, 'total_kills_times', 0);
|
||||
$totalKillsPerMoba += $gameTimes_moba > 0 ? intval($totalKills_moba / $gameTimes_moba) : 0;
|
||||
$totalAssist_moba = getXVal($mobaDataInfoEx, 'total_assist_time', 0);
|
||||
$totalAssistPerMoba += $gameTimes_moba > 0 ? intval($totalAssist_moba / $gameTimes_moba) : 0;
|
||||
$totalDamage_moba = getXVal($mobaDataInfoEx, 'total_damage_out', 0);
|
||||
$totalDamagePerMoba += $gameTimes_moba > 0 ? intval($totalDamage_moba / $gameTimes_moba) : 0;
|
||||
$totalRecoverHp_moba = getXVal($mobaDataInfoEx, 'total_recover_hp', 0);
|
||||
$totalRecoverHpPerMoba += $gameTimes_moba > 0 ? intval($totalRecoverHp_moba / $gameTimes_moba) : 0;
|
||||
}
|
||||
$userChartData['pvp_server_data'] = array(
|
||||
"pvp_win_avg" => intval($totalWinPerPvp / $totalBattleCount),
|
||||
"pvp_kills_avg" => intval($totalKillsPerPvp / $totalBattleCount),
|
||||
"pvp_assist_avg" => intval($totalAssistPerPvp / $totalBattleCount),
|
||||
"pvp_damage_avg" => intval($totalDamagePerPvp / $totalBattleCount),
|
||||
"pvp_recover_avg" => intval($totalRecoverHpPerPvp / $totalBattleCount),
|
||||
);
|
||||
$userChartData['moba_server_data'] = array(
|
||||
"moba_level_avg" => intval($totalLevelPerMoba / $totalBattleCount),
|
||||
"moba_kills_avg" => intval($totalKillsPerMoba / $totalBattleCount),
|
||||
"moba_assist_avg" => intval($totalAssistPerMoba / $totalBattleCount),
|
||||
"moba_damage_avg" => intval($totalDamagePerMoba / $totalBattleCount),
|
||||
"moba_recover_avg" => intval($totalRecoverHpPerMoba / $totalBattleCount),
|
||||
);
|
||||
GlobalData::addUserChartData($userChartData);
|
||||
}
|
||||
$param = 0.95;
|
||||
$r = (2*$param-1) / (1-$param);
|
||||
if ($gameTimes >= Battle::VALID_GAME_TIMES){
|
||||
// t=x/u r=(2s-1)/(1-s)
|
||||
$t1 = intval($killsPer / $userChartData['pvp_server_data']['pvp_kills_avg']);
|
||||
$pvpData['star_kills'] = round((pow($r,$t1) - 1) / (pow($r,$t1)+$r-2),2);
|
||||
$t2 = intval($winPer / $userChartData['pvp_server_data']['pvp_win_avg']);
|
||||
$pvpData['star_win'] = round((pow($r,$t2) - 1) / (pow($r,$t2)+$r-2),2);
|
||||
$t3 = intval($assistPer / $userChartData['pvp_server_data']['pvp_assist_avg']);
|
||||
$pvpData['star_assist'] = round((pow($r,$t3) - 1) / (pow($r,$t3)+$r-2),2);
|
||||
$t4 = intval($damagePer / $userChartData['pvp_server_data']['pvp_damage_avg']);
|
||||
$pvpData['star_damage'] = round((pow($r,$t4) - 1) / (pow($r,$t4)+$r-2),2);
|
||||
$t5 = intval($recoverHpPer / $userChartData['pvp_server_data']['pvp_recover_avg']);
|
||||
$pvpData['star_recover'] = round((pow($r,$t5) - 1) / (pow($r,$t5)+$r-2),2);
|
||||
}
|
||||
|
||||
if ($gameTimesMoba >= Battle::VALID_GAME_TIMES){
|
||||
$t6 = intval($killsPerMoba / $userChartData['moba_server_data']['moba_kills_avg']);
|
||||
$mobaData['star_kills'] = round((pow($r,$t6) - 1) / (pow($r,$t6)+$r-2),2);
|
||||
$t8 = intval($assistPerMoba / $userChartData['moba_server_data']['moba_assist_avg']);
|
||||
$mobaData['star_assist'] = round((pow($r,$t8) - 1) / (pow($r,$t8)+$r-2),2);
|
||||
$t9 = intval($damagePerMoba / $userChartData['moba_server_data']['moba_damage_avg']);
|
||||
$mobaData['star_damage'] = round((pow($r,$t9) - 1) / (pow($r,$t9)+$r-2),2);
|
||||
$t10 = intval($recoverHpPerMoba / $userChartData['moba_server_data']['moba_recover_avg']);
|
||||
$mobaData['star_recover'] = round((pow($r,$t10) - 1) / (pow($r,$t10)+$r-2),2);
|
||||
|
||||
$paramMeta = mt\Parameter::getListValue("radar_moba_level");
|
||||
$mobaData['star_level'] = round(($levelPerMoba - $paramMeta[0]) / ($paramMeta[1] - $paramMeta[0]),2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rspData(array(
|
||||
'pvpInfo' => $pvpData,
|
||||
'mobaInfo' => $mobaData,
|
||||
));
|
||||
}
|
||||
|
||||
public function detailInfo()
|
||||
{
|
||||
$targetId = getReqVal('target_id', '');
|
||||
@ -522,66 +710,6 @@ class UserController extends BaseAuthedController {
|
||||
$userDto['current_rank'] = $userDb['rank'];
|
||||
$userDto['current_rank_score'] = $userDb['score'];
|
||||
$userDto['history_best_rank_score'] = $userDb['history_best_score'];
|
||||
$userDto['history_seasons'] = array();
|
||||
$seasonDbs = Season::getHistorySeasons($targetId);
|
||||
$battleDb = Battle::find($targetId);
|
||||
// foreach ($seasonDbs as $seasonDb) {
|
||||
// $battleData = json_decode($seasonDb['battle_data'], true);
|
||||
if ($battleDb){
|
||||
$battleData = json_decode($battleDb['battle_data'], true);
|
||||
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array();
|
||||
$gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
|
||||
$winTimes = getXVal($seasonBattleData, 'total_win_times', 0);
|
||||
$winRate = $gameTimes > 0 ? intval($winTimes / $gameTimes * 100) : 0;
|
||||
$totalKills = getXVal($seasonBattleData, 'total_kills_times', 0);
|
||||
$totalDamage = getXVal($seasonBattleData, 'total_damage_out', 0);
|
||||
$totalAlive = getXVal($seasonBattleData, 'total_alive_time', 0);
|
||||
$totalRecoverHp = getXVal($seasonBattleData, 'total_recover_hp', 0);
|
||||
$avgDamage = $gameTimes > 0 ? intval($totalDamage / $gameTimes) : 0;
|
||||
$avgKills = $gameTimes > 0 ? intval($totalKills / $gameTimes) : 0;
|
||||
$starKills = $gameTimes > 0 ? intval($totalKills / $gameTimes / 10 *100) : 0;
|
||||
$starDamage = $gameTimes > 0 ? intval($totalDamage / $gameTimes / 1500 * 100) : 0;
|
||||
$starAlive = $gameTimes > 0 ? intval($totalAlive / $gameTimes / 300 * 0.1) : 0;
|
||||
$starRecover = $gameTimes > 0 ? intval($totalRecoverHp / $gameTimes / 300 * 100) : 0;
|
||||
$starWin = $gameTimes > 0 ? intval($winTimes / $gameTimes / 0.5 * 100) : 0;
|
||||
array_push($userDto['history_seasons'],
|
||||
array(
|
||||
// 'season_id' => $seasonDb['season_id'],
|
||||
'total_kills' => $totalKills,
|
||||
'game_times' => $gameTimes,
|
||||
'win_times' => $winTimes,
|
||||
'win_rate' => $winRate,
|
||||
'max_kills' => getXVal($seasonBattleData, 'max_kills_times', 0),
|
||||
'avg_kills' => $avgKills,
|
||||
'max_damage_out' => getXVal($seasonBattleData, 'max_damage_out', 0),
|
||||
'avg_damage_out' => $avgDamage,
|
||||
'star_kills' => min(100, $starKills),
|
||||
'star_damage' => min(100, $starDamage),
|
||||
'star_alive' => min(100, $starAlive),
|
||||
'star_recover' => min(100, $starRecover),
|
||||
'star_win' => min(100, $starWin),
|
||||
));
|
||||
}
|
||||
if (count($userDto['history_seasons']) <= 0) {
|
||||
// $currSeasonMeta = mt\Season::getCurrentSeason();
|
||||
array_push($userDto['history_seasons'],
|
||||
array(
|
||||
// 'season_id' => $currSeasonMeta['id'],
|
||||
'total_kills' => 0,
|
||||
'game_times' => 0,
|
||||
'win_times' => 0,
|
||||
'win_rate' => 0,
|
||||
'max_kills' => 0,
|
||||
'avg_kills' => 0,
|
||||
'max_damage_out' => 0,
|
||||
'avg_damage_out' => 0,
|
||||
'star_kills' => min(100, 0),
|
||||
'star_damage' => min(100, 0),
|
||||
'star_alive' => min(100, 0),
|
||||
'star_recover' => min(100, 0),
|
||||
'star_win' => min(100, 0),
|
||||
));
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'info' => $userDto
|
||||
));
|
||||
|
@ -1,67 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class Battle extends BaseModel {
|
||||
|
||||
public static function find($accountId){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
)
|
||||
);
|
||||
return $row ? $row : null;
|
||||
}
|
||||
|
||||
public static function getMyBattleData()
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
return $row ? json_decode($row['battle_data'], true) : array();
|
||||
}
|
||||
|
||||
public static function add($battleData)
|
||||
{
|
||||
SqlHelper::upsert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
),
|
||||
array(
|
||||
'battle_data' => $battleData,
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'battle_data' => $battleData,
|
||||
'kills_modifytime' => myself()->_getNowTime(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function update($fieldsKv)
|
||||
{
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class Battle extends BaseModel {
|
||||
|
||||
const VALID_GAME_TIMES = 10;
|
||||
const VALID_BATTLE_COUNT = 10000;
|
||||
|
||||
public static function find($accountId){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
)
|
||||
);
|
||||
return $row ? $row : null;
|
||||
}
|
||||
|
||||
public static function getMyBattleData()
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
return $row ? json_decode($row['battle_data'], true) : array();
|
||||
}
|
||||
|
||||
public static function add($battleData)
|
||||
{
|
||||
SqlHelper::upsert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
),
|
||||
array(
|
||||
'battle_data' => $battleData,
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'battle_data' => $battleData,
|
||||
'kills_modifytime' => myself()->_getNowTime(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function update($fieldsKv)
|
||||
{
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
public static function getBattleCount(){
|
||||
|
||||
$row = myself()->_getSelfMysql()->execQueryOne("SELECT COUNT(idx) AS battle_num FROM t_battle ");
|
||||
return $row && $row['battle_num'] ? $row['battle_num'] : 0;
|
||||
}
|
||||
|
||||
public static function getBattleDataLimit(){
|
||||
$limit = self::VALID_BATTLE_COUNT;
|
||||
return myself()->_getSelfMysql()->execQuery("SELECT idx,account_id,battle_data FROM t_battle LIMIT {$limit}");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,4 +58,13 @@ class GlobalData extends BaseModel
|
||||
return $row ? $row : '';
|
||||
}
|
||||
|
||||
public static function addUserChartData($battleData){
|
||||
self::internalGetAdd("user_chart_data",json_encode($battleData));
|
||||
}
|
||||
|
||||
public static function getUserChartData(){
|
||||
$db = self::internalGet('user_chart_data');
|
||||
return $db ? json_decode($db['data'], true) : array();
|
||||
}
|
||||
|
||||
}
|
@ -144,7 +144,7 @@ class TameBattleDataService extends BaseService {
|
||||
break;
|
||||
case self::ROOM_MODE_MOBA :
|
||||
{
|
||||
// $this->updateMobaData();
|
||||
$this->updateMobaData();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -417,6 +417,19 @@ class TameBattleDataService extends BaseService {
|
||||
Battle::add(json_encode($hisBattleData));
|
||||
}
|
||||
|
||||
private function updateMobaData(){
|
||||
error_log('updateMobaData');
|
||||
$hisBattleData = Battle::getMyBattleData();
|
||||
if (!isset($hisBattleData['moba_data'])) {
|
||||
$hisBattleData['moba_data'] = array(
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
$this->apply($hisBattleData['moba_data']);
|
||||
Battle::add(json_encode($hisBattleData));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function addBattleSettlementSingle()
|
||||
@ -1033,7 +1046,22 @@ class TameBattleDataService extends BaseService {
|
||||
//单局最大存活时间
|
||||
$this->maxValue($battleData, 'max_alive_time', $aliveTime);
|
||||
}
|
||||
|
||||
//助攻次数
|
||||
$assistTime = getXVal($this->battleInfo,'pvp_assist', 0);
|
||||
if ($assistTime > 0) {
|
||||
//总助攻次数
|
||||
$this->incValue($battleData, 'total_assist_time', $assistTime);
|
||||
//单局最大助攻次数
|
||||
$this->maxValue($battleData, 'max_assist_time', $assistTime);
|
||||
}
|
||||
//等级
|
||||
$level = getXVal($this->battleInfo,'level', 0);
|
||||
if ($level > 0) {
|
||||
//总等级
|
||||
$this->incValue($battleData, 'total_level', $level);
|
||||
//单局最大等级
|
||||
$this->maxValue($battleData, 'max_level', $level);
|
||||
}
|
||||
//救援次数
|
||||
$this->incValue($battleData, 'rescue_teammate_times', getXVal($this->battleInfo,'rescue_teammate_times', 0));
|
||||
//潜水次数
|
||||
|
Loading…
x
Reference in New Issue
Block a user