Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb
This commit is contained in:
commit
0960cb07e3
@ -680,6 +680,7 @@ class UserController extends BaseAuthedController {
|
||||
$mobaState = isset($userChartData["moba_state"]) ? $userChartData["moba_state"] : 0;
|
||||
if (!$userChartData || !$pvpState || !$mobaState){
|
||||
$battlesDb = Battle::getBattleDataLimit();
|
||||
$number = count($battlesDb);
|
||||
$totalAlivePerPvp = 0;
|
||||
$totalKillsPerPvp = 0;
|
||||
$totalAssistPerPvp = 0;
|
||||
@ -698,74 +699,89 @@ 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);
|
||||
$aliveTimes_pvp = getXVal($pvpDataInfoEx, 'total_alive_time', 0);
|
||||
$totalAlivePerPvp += $gameTimes_pvp > 0 ? intval($aliveTimes_pvp / $gameTimes_pvp) : 0;
|
||||
$aliveTimes_pvp = getXVal($pvpDataInfoEx, 'total_alive_time', 0) / 1000;
|
||||
$totalAlivePerPvp += $gameTimes_pvp > 0 ? ($aliveTimes_pvp / $gameTimes_pvp) : 0;
|
||||
$totalKills_pvp = getXVal($pvpDataInfoEx, 'total_kills_times', 0);
|
||||
$totalKillsPerPvp += $gameTimes_pvp > 0 ? intval($totalKills_pvp / $gameTimes_pvp) : 0;
|
||||
$totalKillsPerPvp += $gameTimes_pvp > 0 ? ($totalKills_pvp / $gameTimes_pvp) : 0;
|
||||
$totalAssist_pvp = getXVal($pvpDataInfoEx, 'total_assist_time', 0);
|
||||
$totalAssistPerPvp += $gameTimes_pvp > 0 ? intval($totalAssist_pvp / $gameTimes_pvp) : 0;
|
||||
$totalAssistPerPvp += $gameTimes_pvp > 0 ? ($totalAssist_pvp / $gameTimes_pvp) : 0;
|
||||
$totalDamage_pvp = getXVal($pvpDataInfoEx, 'total_damage_out', 0);
|
||||
$totalDamagePerPvp += $gameTimes_pvp > 0 ? intval($totalDamage_pvp / $gameTimes_pvp) : 0;
|
||||
$totalDamagePerPvp += $gameTimes_pvp > 0 ? ($totalDamage_pvp / $gameTimes_pvp) : 0;
|
||||
$totalRecoverHp_pvp = getXVal($pvpDataInfoEx, 'total_recover_hp', 0);
|
||||
$totalRecoverHpPerPvp += $gameTimes_pvp > 0 ? intval($totalRecoverHp_pvp / $gameTimes_pvp) : 0;
|
||||
$totalRecoverHpPerPvp += $gameTimes_pvp > 0 ? ($totalRecoverHp_pvp / $gameTimes_pvp) : 0;
|
||||
$totalGameTimesPvp += $gameTimes_pvp;
|
||||
|
||||
$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;
|
||||
$totalLevelPerMoba += $gameTimes_moba > 0 ? ($totalLevel_moba / $gameTimes_moba) : 0;
|
||||
$totalKills_moba = getXVal($mobaDataInfoEx, 'total_kills_times', 0);
|
||||
$totalKillsPerMoba += $gameTimes_moba > 0 ? intval($totalKills_moba / $gameTimes_moba) : 0;
|
||||
$totalKillsPerMoba += $gameTimes_moba > 0 ? ($totalKills_moba / $gameTimes_moba) : 0;
|
||||
$totalAssist_moba = getXVal($mobaDataInfoEx, 'total_assist_time', 0);
|
||||
$totalAssistPerMoba += $gameTimes_moba > 0 ? intval($totalAssist_moba / $gameTimes_moba) : 0;
|
||||
$totalAssistPerMoba += $gameTimes_moba > 0 ? ($totalAssist_moba / $gameTimes_moba) : 0;
|
||||
$totalDamage_moba = getXVal($mobaDataInfoEx, 'total_damage_out', 0);
|
||||
$totalDamagePerMoba += $gameTimes_moba > 0 ? intval($totalDamage_moba / $gameTimes_moba) : 0;
|
||||
$totalDamagePerMoba += $gameTimes_moba > 0 ? ($totalDamage_moba / $gameTimes_moba) : 0;
|
||||
$totalRecoverHp_moba = getXVal($mobaDataInfoEx, 'total_recover_hp', 0);
|
||||
$totalRecoverHpPerMoba += $gameTimes_moba > 0 ? intval($totalRecoverHp_moba / $gameTimes_moba) : 0;
|
||||
$totalRecoverHpPerMoba += $gameTimes_moba > 0 ? ($totalRecoverHp_moba / $gameTimes_moba) : 0;
|
||||
$totalGameTimesMoba += $gameTimes_moba;
|
||||
}
|
||||
|
||||
$userChartData['pvp_server_data'] = array(
|
||||
"pvp_alive_avg" => intval($totalAlivePerPvp / $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),
|
||||
"pvp_alive_avg" => round($totalAlivePerPvp / $number,2),
|
||||
"pvp_kills_avg" => round($totalKillsPerPvp / $number,2),
|
||||
"pvp_assist_avg" => round($totalAssistPerPvp / $number,2),
|
||||
"pvp_damage_avg" => round($totalDamagePerPvp / $number,2),
|
||||
"pvp_recover_avg" => round($totalRecoverHpPerPvp / $number,2),
|
||||
);
|
||||
$userChartData["pvp_state"] = $totalGameTimesPvp > Battle::VALID_BATTLE_COUNT ? 1 :0;
|
||||
if ($userChartData['pvp_server_data']['pvp_alive_avg'] == 0 ||
|
||||
$userChartData['pvp_server_data']['pvp_kills_avg'] == 0 ||
|
||||
$userChartData['pvp_server_data']['pvp_assist_avg'] == 0 ||
|
||||
$userChartData['pvp_server_data']['pvp_damage_avg'] == 0 ||
|
||||
$userChartData['pvp_server_data']['pvp_recover_avg'] == 0 ){
|
||||
$userChartData["pvp_state"] = 0;
|
||||
}
|
||||
$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),
|
||||
"moba_level_avg" => round($totalLevelPerMoba / $number,2),
|
||||
"moba_kills_avg" => round($totalKillsPerMoba / $number,2),
|
||||
"moba_assist_avg" => round($totalAssistPerMoba / $number,2),
|
||||
"moba_damage_avg" => round($totalDamagePerMoba / $number,2),
|
||||
"moba_recover_avg" => round($totalRecoverHpPerMoba / $number,2),
|
||||
);
|
||||
$userChartData["moba_state"] = $totalGameTimesMoba > Battle::VALID_BATTLE_COUNT ? 1 :0;
|
||||
if ( $userChartData['moba_server_data']['moba_level_avg'] == 0 ||
|
||||
$userChartData['moba_server_data']['moba_kills_avg'] == 0 ||
|
||||
$userChartData['moba_server_data']['moba_assist_avg'] == 0 ||
|
||||
$userChartData['moba_server_data']['moba_damage_avg'] == 0 ||
|
||||
$userChartData['moba_server_data']['moba_recover_avg'] == 0 ){
|
||||
$userChartData["moba_state"] = 0;
|
||||
}
|
||||
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']);
|
||||
$t1 = $userChartData['pvp_server_data']['pvp_kills_avg']>0 ? intval($killsPer / $userChartData['pvp_server_data']['pvp_kills_avg']) :0;
|
||||
$pvpData['star_kills'] = round((pow($r,$t1) - 1) / (pow($r,$t1)+$r-2),2);
|
||||
$t2 = intval($alivePer / $userChartData['pvp_server_data']['pvp_alive_avg']);
|
||||
$t2 = $userChartData['pvp_server_data']['pvp_alive_avg']>0 ? intval($alivePer / $userChartData['pvp_server_data']['pvp_alive_avg']) :0;
|
||||
$pvpData['star_alive'] = round((pow($r,$t2) - 1) / (pow($r,$t2)+$r-2),2);
|
||||
$t3 = intval($assistPer / $userChartData['pvp_server_data']['pvp_assist_avg']);
|
||||
$t3 = $userChartData['pvp_server_data']['pvp_assist_avg']>0 ? intval($assistPer / $userChartData['pvp_server_data']['pvp_assist_avg']) :0;
|
||||
$pvpData['star_assist'] = round((pow($r,$t3) - 1) / (pow($r,$t3)+$r-2),2);
|
||||
$t4 = intval($damagePer / $userChartData['pvp_server_data']['pvp_damage_avg']);
|
||||
$t4 = $userChartData['pvp_server_data']['pvp_damage_avg']>0 ? intval($damagePer / $userChartData['pvp_server_data']['pvp_damage_avg']) :0;
|
||||
$pvpData['star_damage'] = round((pow($r,$t4) - 1) / (pow($r,$t4)+$r-2),2);
|
||||
$t5 = intval($recoverHpPer / $userChartData['pvp_server_data']['pvp_recover_avg']);
|
||||
$t5 = $userChartData['pvp_server_data']['pvp_recover_avg']>0 ? intval($recoverHpPer / $userChartData['pvp_server_data']['pvp_recover_avg']) :0;
|
||||
$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']);
|
||||
$t6 = $userChartData['moba_server_data']['moba_kills_avg']>0 ? intval($killsPerMoba / $userChartData['moba_server_data']['moba_kills_avg']) :0;
|
||||
$mobaData['star_kills'] = round((pow($r,$t6) - 1) / (pow($r,$t6)+$r-2),2);
|
||||
$t8 = intval($assistPerMoba / $userChartData['moba_server_data']['moba_assist_avg']);
|
||||
$t8 = $userChartData['moba_server_data']['moba_assist_avg']>0 ? intval($assistPerMoba / $userChartData['moba_server_data']['moba_assist_avg']) :0;
|
||||
$mobaData['star_assist'] = round((pow($r,$t8) - 1) / (pow($r,$t8)+$r-2),2);
|
||||
$t9 = intval($damagePerMoba / $userChartData['moba_server_data']['moba_damage_avg']);
|
||||
$t9 = $userChartData['moba_server_data']['moba_damage_avg']>0 ? intval($damagePerMoba / $userChartData['moba_server_data']['moba_damage_avg']) :0;
|
||||
$mobaData['star_damage'] = round((pow($r,$t9) - 1) / (pow($r,$t9)+$r-2),2);
|
||||
$t10 = intval($recoverHpPerMoba / $userChartData['moba_server_data']['moba_recover_avg']);
|
||||
$t10 = $userChartData['moba_server_data']['moba_recover_avg']>0 ? intval($recoverHpPerMoba / $userChartData['moba_server_data']['moba_recover_avg']) :0;
|
||||
$mobaData['star_recover'] = round((pow($r,$t10) - 1) / (pow($r,$t10)+$r-2),2);
|
||||
|
||||
$paramMeta = mt\Parameter::getListValue("radar_moba_level");
|
||||
|
@ -8,7 +8,7 @@ use phpcommon\SqlHelper;
|
||||
class Battle extends BaseModel {
|
||||
|
||||
const VALID_GAME_TIMES = 5;
|
||||
const VALID_BATTLE_COUNT = 100;
|
||||
const VALID_BATTLE_COUNT = 1000;
|
||||
|
||||
public static function find($accountId){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
|
69
webapp/mt/BattleReward.php
Normal file
69
webapp/mt/BattleReward.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mt;
|
||||
|
||||
|
||||
class BattlePass
|
||||
{
|
||||
public static function find($id){
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
}
|
||||
|
||||
public static function all(){
|
||||
return self::getMetaList();
|
||||
}
|
||||
|
||||
public static function getExpByLv(&$lv,&$exp){
|
||||
$meta = self::getMetaList();
|
||||
if ($exp > 0){
|
||||
for ($i=1;$i<=count($meta);$i++){
|
||||
if ($exp >= $meta[count($meta)]['total_exp']){
|
||||
$exp = min($exp, $meta[count($meta)]['total_exp']);
|
||||
$lv = $meta[count($meta)]['id'];
|
||||
}else{
|
||||
if ($i<count($meta)){
|
||||
if ($exp >= $meta[$i]['total_exp'] &&
|
||||
$exp < $meta[$i+1]['total_exp'])
|
||||
{
|
||||
$lv = $meta[$i]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCurrentSeason(){
|
||||
foreach (self::getMetaCommon() as $meta) {
|
||||
if (myself()->_getNowTime() >= strtotime($meta['begin_time']) &&
|
||||
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('Battlepass@Battlepass.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static function getMetaCommon()
|
||||
{
|
||||
if (!self::$metaCommon) {
|
||||
self::$metaCommon = getMetaTable('BattlepassCommon@BattlepassCommon.php');
|
||||
}
|
||||
return self::$metaCommon;
|
||||
}
|
||||
|
||||
|
||||
protected static $metaList;
|
||||
protected static $metaCommon;
|
||||
|
||||
}
|
34
webapp/mt/MapMode.php
Normal file
34
webapp/mt/MapMode.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mt;
|
||||
|
||||
|
||||
class BattleReward
|
||||
{
|
||||
public static function find($id){
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
}
|
||||
|
||||
public static function findByMapMode($modeId){
|
||||
foreach (self::getMetaList() as $meta){
|
||||
if ($meta['mapMode'] == $modeId){
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('battleReward@battleReward.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user