This commit is contained in:
hujiabin 2024-03-18 15:22:37 +08:00
parent c4a4b8b3a5
commit 42fd5e6f56

View File

@ -563,12 +563,12 @@ class UserController extends BaseAuthedController {
'game_times' => 0,
'total_kills' => 0,
'win_times' => 0,
'win_avg' => 0,
'alive_avg' => 0,
'kills_avg' => 0,
'assist_avg' => 0,
'damage_avg' => 0,
'recover_avg' => 0,
'star_win' => 0,
'star_alive' => 0,
'star_kills' => 0,
'star_assist' => 0,
'star_damage' => 0,
@ -596,7 +596,9 @@ class UserController extends BaseAuthedController {
$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; //胜率
// $winPer = $gameTimes > 0 ? intval($winTimes / $gameTimes) : 0; //胜率
$aliveTime = getXVal($dataInfo, 'total_alive_time', 0) / 1000; //生存时间
$alivePer = $gameTimes > 0 ? intval($aliveTime / $gameTimes) : 0; //胜率
$totalKills = getXVal($dataInfo, 'total_kills_times', 0); //总击杀
// $maxKills = getXVal($dataInfo, 'max_kills_times', 0); //最高击杀
$killsPer = $gameTimes > 0 ? intval($totalKills / $gameTimes) : 0; //场均击杀
@ -612,7 +614,7 @@ class UserController extends BaseAuthedController {
$pvpData['game_times'] = $gameTimes;
$pvpData['total_kills'] = $totalKills;
$pvpData['win_times'] = $winTimes;
$pvpData['win_avg'] = $winPer;
$pvpData['alive_avg'] = $alivePer;
$pvpData['kills_avg'] = $killsPer;
$pvpData['assist_avg'] = $assistPer;
$pvpData['damage_avg'] = $damagePer;
@ -644,7 +646,7 @@ class UserController extends BaseAuthedController {
if (!$userChartData){
$battlesDb = Battle::getBattleDataLimit();
$totalBattleCount = Battle::getBattleCount();
$totalWinPerPvp = 0;
$totalAlivePerPvp = 0;
$totalKillsPerPvp = 0;
$totalAssistPerPvp = 0;
$totalDamagePerPvp = 0;
@ -659,8 +661,8 @@ class UserController extends BaseAuthedController {
$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;
$aliveTimes_pvp = getXVal($pvpDataInfoEx, 'total_alive_time', 0);
$totalAlivePerPvp += $gameTimes_pvp > 0 ? intval($aliveTimes_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);
@ -684,7 +686,7 @@ class UserController extends BaseAuthedController {
$totalRecoverHpPerMoba += $gameTimes_moba > 0 ? intval($totalRecoverHp_moba / $gameTimes_moba) : 0;
}
$userChartData['pvp_server_data'] = array(
"pvp_win_avg" => intval($totalWinPerPvp / $totalBattleCount),
"pvp_alive_avg" => intval($totalAlivePerPvp / $totalBattleCount),
"pvp_kills_avg" => intval($totalKillsPerPvp / $totalBattleCount),
"pvp_assist_avg" => intval($totalAssistPerPvp / $totalBattleCount),
"pvp_damage_avg" => intval($totalDamagePerPvp / $totalBattleCount),
@ -705,8 +707,8 @@ class UserController extends BaseAuthedController {
// 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);
$t2 = intval($alivePer / $userChartData['pvp_server_data']['pvp_alive_avg']);
$pvpData['star_alive'] = 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']);