From 30241e3cb1f771029062c05a6839fd6e197d7d8c Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 22 Apr 2024 15:16:49 +0800 Subject: [PATCH] 1 --- doc/BattleHistory.py | 26 ++++++ .../BattleHistoryController.class.php | 30 +++++++ webapp/controller/UserController.class.php | 46 ++++++---- webapp/models/BattleSettlement.php | 53 +++++++----- webapp/mt/BattleRandAttribute.php | 4 +- webapp/services/RoomBattleDataService.php | 10 ++- webapp/services/TameBattleDataService.php | 86 ++++++++++++++----- 7 files changed, 193 insertions(+), 62 deletions(-) create mode 100644 doc/BattleHistory.py create mode 100644 webapp/controller/BattleHistoryController.class.php diff --git a/doc/BattleHistory.py b/doc/BattleHistory.py new file mode 100644 index 00000000..e04c3a29 --- /dev/null +++ b/doc/BattleHistory.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import _common + +class BattleHistory(object): + + def __init__(self): + self.apis = [ + { + 'name': 'getBattleList', + 'desc': '历史战绩', + 'group': 'BattleHistory', + 'url': 'webapp/index.php?c=BattleHistory&a=getBattleList', + 'params': [ + _common.ReqHead(), + ['target_id', '', ' 用户 account'], + ['room_mode', '', ' 0:pvp 2:moba'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.BattleSettlementMembersInfo()], '战绩数据'], + ] + }, + ] + + diff --git a/webapp/controller/BattleHistoryController.class.php b/webapp/controller/BattleHistoryController.class.php new file mode 100644 index 00000000..dd6c8a6f --- /dev/null +++ b/webapp/controller/BattleHistoryController.class.php @@ -0,0 +1,30 @@ +_getAccountId(); + } + $singleList = BattleSettlement::getSingleList($accountId,$room_mode); + $historyList = BattleHistory::orderBy($singleList,'desc'); + $data = array(); + foreach ($historyList as $k=>$history){ + if ($k < 40){ + array_push($data,$history); + } + } + $this->_rspData(array( + 'data' => $data + )); + } + +} diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 4b6efd8e..8b3a3328 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -128,11 +128,6 @@ class UserController extends BaseAuthedController { 'item_id' => V_ITEM_GOLD, 'item_num' => 500000 )); - array_push($addItems, - array( - 'item_id' => V_ITEM_STAR, - 'item_num' => 400 - )); } $awardService = new services\AwardService(); @@ -815,32 +810,53 @@ class UserController extends BaseAuthedController { } $param = 0.95; $r = (2*$param-1) / (1-$param); + $h = \mt\Parameter::getVal("radar_axis_min",0.2); if ($gameTimes >= Battle::VALID_GAME_TIMES){ // t=x/u r=(2s-1)/(1-s) $t1 = $userChartData['pvp_server_data']['pvp_kills_avg']>0 ? ($killsPer / $userChartData['pvp_server_data']['pvp_kills_avg']) :0; - $pvpData['star_kills'] = round((pow($r,$t1) - 1) / (pow($r,$t1)+$r-2),2); + $y1 = (pow($r,$t1) - 1) / (pow($r,$t1)+$r-2); + $pvpData['star_kills'] = round((1-$h) * $y1 + $h ,2); +// $pvpData['star_kills'] = round((pow($r,$t1) - 1) / (pow($r,$t1)+$r-2),2); $t2 = $userChartData['pvp_server_data']['pvp_alive_avg']>0 ? ($alivePer / $userChartData['pvp_server_data']['pvp_alive_avg']) :0; - $pvpData['star_alive'] = round((pow($r,$t2) - 1) / (pow($r,$t2)+$r-2),2); + $y2 = (pow($r,$t2) - 1) / (pow($r,$t2)+$r-2) ; + $pvpData['star_alive'] = round((1-$h) * $y2 + $h ,2); +// $pvpData['star_alive'] = round((pow($r,$t2) - 1) / (pow($r,$t2)+$r-2),2); $t3 = $userChartData['pvp_server_data']['pvp_assist_avg']>0 ? ($assistPer / $userChartData['pvp_server_data']['pvp_assist_avg']) :0; - $pvpData['star_assist'] = round((pow($r,$t3) - 1) / (pow($r,$t3)+$r-2),2); + $y3 = (pow($r,$t3) - 1) / (pow($r,$t3)+$r-2) ; + $pvpData['star_assist'] = round((1-$h) * $y3 + $h ,2); +// $pvpData['star_assist'] = round((pow($r,$t3) - 1) / (pow($r,$t3)+$r-2),2); $t4 = $userChartData['pvp_server_data']['pvp_damage_avg']>0 ? ($damagePer / $userChartData['pvp_server_data']['pvp_damage_avg']) :0; - $pvpData['star_damage'] = round((pow($r,$t4) - 1) / (pow($r,$t4)+$r-2),2); + $y4 = (pow($r,$t4) - 1) / (pow($r,$t4)+$r-2); + $pvpData['star_damage'] = round((1-$h) * $y4 + $h ,2); +// $pvpData['star_damage'] = round((pow($r,$t4) - 1) / (pow($r,$t4)+$r-2),2); $t5 = $userChartData['pvp_server_data']['pvp_recover_avg']>0 ? ($recoverHpPer / $userChartData['pvp_server_data']['pvp_recover_avg']) :0; - $pvpData['star_recover'] = round((pow($r,$t5) - 1) / (pow($r,$t5)+$r-2),2); + $y5 = (pow($r,$t5) - 1) / (pow($r,$t5)+$r-2); + $pvpData['star_recover'] = round((1-$h) * $y5 + $h ,2); +// $pvpData['star_recover'] = round((pow($r,$t5) - 1) / (pow($r,$t5)+$r-2),2); } if ($gameTimesMoba >= Battle::VALID_GAME_TIMES){ $t6 = $userChartData['moba_server_data']['moba_kills_avg']>0 ? ($killsPerMoba / $userChartData['moba_server_data']['moba_kills_avg']) :0; - $mobaData['star_kills'] = round((pow($r,$t6) - 1) / (pow($r,$t6)+$r-2),2); + $y6 = (pow($r,$t6) - 1) / (pow($r,$t6)+$r-2); + $mobaData['star_kills'] = round((1-$h) * $y6 + $h ,2); +// $mobaData['star_kills'] = round((pow($r,$t6) - 1) / (pow($r,$t6)+$r-2),2); $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); + $y8 = (pow($r,$t8) - 1) / (pow($r,$t8)+$r-2); + $mobaData['star_assist'] = round((1-$h) * $y8 + $h ,2); +// $mobaData['star_assist'] = round((pow($r,$t8) - 1) / (pow($r,$t8)+$r-2),2); $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); + $y9 = (pow($r,$t9) - 1) / (pow($r,$t9)+$r-2); + $mobaData['star_damage'] = round((1-$h) * $y9 + $h ,2); +// $mobaData['star_damage'] = round((pow($r,$t9) - 1) / (pow($r,$t9)+$r-2),2); $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); + $y10 = (pow($r,$t10) - 1) / (pow($r,$t10)+$r-2); + $mobaData['star_recover'] = round((1-$h) * $y10 + $h ,2); +// $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); + $y7 = ($levelPerMoba - $paramMeta[0]) / ($paramMeta[1] - $paramMeta[0]); + $mobaData['star_level'] = round((1-$h) * $y7 + $h ,2); +// $mobaData['star_level'] = round(($levelPerMoba - $paramMeta[0]) / ($paramMeta[1] - $paramMeta[0]),2); } } diff --git a/webapp/models/BattleSettlement.php b/webapp/models/BattleSettlement.php index ea582758..4b020bad 100644 --- a/webapp/models/BattleSettlement.php +++ b/webapp/models/BattleSettlement.php @@ -10,6 +10,7 @@ class BattleSettlement extends BaseModel const ROOM_MODE_PVP = 0; // const MATCH_MODE_MATCH = 1; const ROOM_MODE_PVE = 1; + const ROOM_MODE_MOBA = 2; const MATCH_MODE_PVP = 0; const MATCH_MODE_RANK = 1; @@ -47,6 +48,18 @@ class BattleSettlement extends BaseModel return $row; } + public static function findSingle($battleUuid){ + $row = SqlHelper::ormSelectOne + (myself()->_getSelfMysql(), + 't_battle_settlement_single', + array( + 'account_id' => myself()->_getAccountId(), + 'battle_uniid' => $battleUuid, + ) + ); + return $row; + } + public static function addSingle($battleUuid, $roomUuid, $data) { SqlHelper::upsert @@ -56,7 +69,10 @@ class BattleSettlement extends BaseModel 'account_id' => myself()->_getAccountId(), 'battle_uuid' => $battleUuid, ), - array(), + array( + 'data' => json_encode($data), + 'modifytime' => myself()->_getNowTime(), + ), array( 'account_id' => myself()->_getAccountId(), 'battle_uuid' => $battleUuid, @@ -68,7 +84,7 @@ class BattleSettlement extends BaseModel ); } - public static function getSingleList($accountId,$roomMode, $matchMode) + public static function getSingleList($accountId,$roomMode) { $rows = SqlHelper::ormSelect (myself()->_getSelfMysql(), @@ -77,36 +93,27 @@ class BattleSettlement extends BaseModel 'account_id' => $accountId, ) ); - $pvpMatchList = array(); - $pvpRankList = array(); - $pveMatchList = array(); + $pvpBattleList = array(); + $mobaBattleList = array(); foreach ($rows as $row) { $data = emptyReplace(json_decode($row['data'], true), array()); - if ($data['room_mode'] == self::ROOM_MODE_PVP && $data['pvp_mode'] == self::MATCH_MODE_PVP) { - array_push($pvpMatchList, self::singleDto($row)); - } else if ($data['room_mode'] == self::ROOM_MODE_PVP && $data['pvp_mode'] == self::MATCH_MODE_RANK) { - array_push($pvpRankList, self::singleDto($row)); - } else if ($data['room_mode'] == self::ROOM_MODE_PVE) { - array_push($pveMatchList, self::singleDto($row)); + if ($data['room_mode'] == self::ROOM_MODE_PVP ) { + array_push($pvpBattleList, self::singleDto($row)); + } else if ($data['room_mode'] == self::ROOM_MODE_MOBA) { + array_push($mobaBattleList, self::singleDto($row)); } } switch ($roomMode) { case self::ROOM_MODE_PVP : { - switch ($matchMode) { - case self::MATCH_MODE_PVP : - { - return $pvpMatchList; - } - case self::MATCH_MODE_RANK : - { - return $pvpRankList; - } - } + return $pvpBattleList; } - case self::ROOM_MODE_PVE : + case self::ROOM_MODE_MOBA : { - return $pveMatchList; + return $mobaBattleList; + } + default : { + return array(); } } } diff --git a/webapp/mt/BattleRandAttribute.php b/webapp/mt/BattleRandAttribute.php index 318dbeab..5f973f1b 100644 --- a/webapp/mt/BattleRandAttribute.php +++ b/webapp/mt/BattleRandAttribute.php @@ -40,10 +40,10 @@ class BattleRandAttribute { foreach ($strs as $str){ $attrStr = explode(':', $str); $rnd = rand($attrStr[1]*100000 , $attrStr[2]*100000) / 100000; - $val = $attrStr[1] + ($attrStr[2] - $attrStr[1]) * $rnd; +// $val = $attrStr[1] + ($attrStr[2] - $attrStr[1]) * $rnd; array_push($attrArray,array( "attr_id" => $attrStr[0], - "val" => $val, + "val" => $rnd, )); } return $attrArray; diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index cfdc3f59..bc4dc032 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -135,6 +135,13 @@ class RoomBattleDataService extends BaseService { if ($userDb && $heroDb){ $this->_getBattleRewards($userDb,$heroDb,$battleScore,$member['reward']); myself()->_addItems($member['reward'], $awardService,$propertyChgService); + + $battleSingleDb = BattleSettlement::findSingle($this->battleSettlementDb['battle_uuid']); + if ($battleSingleDb){ + $battleSingleData = emptyReplace(json_decode($battleSingleDb['data'], true), array()); + $battleSingleData['reward'] = $member['reward']; + BattleSettlement::addSingle($battleSingleDb['battle_uuid'],$battleSingleDb['room_uuid'],$battleSingleData); + } } } @@ -165,7 +172,8 @@ class RoomBattleDataService extends BaseService { } //金币模式检验 if ($this->mapMode == mt\MapMode::GOLD_MODE && - (!Hero::verifyValid($heroDb) || $goldModeTimes >= $mapModeMeta['rewards_max_time'] )){ + ($goldModeTimes >= $mapModeMeta['rewards_max_time'] )){ +// (!Hero::verifyValid($heroDb) || $goldModeTimes >= $mapModeMeta['rewards_max_time'] )){ error_log("金币模式:出战英雄没有打金时间或每日打金场次上限"); }else{ if (!empty($rewardMeta['goldLoot'])){ diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index bba83d87..7e86003f 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -443,10 +443,12 @@ class TameBattleDataService extends BaseService { $battleUuid = getXVal($this->allInfo,'battle_uuid', 0); $roomUuid = getXVal($this->allInfo,'room_uuid', 0); + $oldRank = $this->userInfo['rank']; $newRank = $this->userInfo['rank']; + $oldScore = $this->userInfo['score']; $newScore = $this->userInfo['score']; + $oldElo = $this->userInfo['elo']; $newElo = $this->userInfo['elo']; - if ($pvp_mode == self::MATCH_MODE_RANK){ myself()->_setV(TN_LAST_RANKING_TIME,0,getXVal($this->battleInfo,'game_time', 0)); $winningPro = $this->celWinningPro($this->userInfo); @@ -462,30 +464,72 @@ class TameBattleDataService extends BaseService { } } +// $data = array( +// "battle_uuid" => $battleUuid, +// "account_id" => getXVal($this->battleInfo,'account_id', 0), +// "room_mode" => getXVal($this->allInfo,'room_mode', 0), +// "pvp_mode" => $pvp_mode, +// "team_mode" => getXVal($this->allInfo,'team_mode', 0), +// "battle_rank" => getXVal($this->battleInfo,'pvp_personal_rank', 0), +// "team_rank" => getXVal($this->allInfo,'pvp_team_rank', 0), +// "team_kills" => getXVal($this->allInfo,'pvp_team_kills', 0), +// "is_win" => getXVal($this->battleInfo,'pve_boss_killed', 0), +// "kills" => getXVal($this->battleInfo,'kills', 0), +// "hero_id" => getXVal($this->battleInfo,'hero_uniid', 0), +// "weapon1" => getXVal($this->battleInfo,'weapon_uuid1', 0), +// "weapon2" => getXVal($this->battleInfo,'weapon_uuid2', 0), +// "battle_end_time" => getXVal($this->battleInfo,'game_time', 0), +// "current_level_class" => $newRank, +// "current_level_class_score" => $newScore, +// "level_class_score_chg" => $newScore - $this->userInfo['score'], // 排位分改变 +// "pve_rank_score" => getXVal($this->battleInfo,'pve_score', 0), +// "pve_kill_boss" => getXVal($this->battleInfo,'pve_boss_killed', 0), +// "pve_instance_id" => getXVal($this->allInfo,'pve_instance_id', 0), +//// "pve_instance_mode" => getXVal($this->allInfo,'pve_instance_mode', 0), +// "old_elo" => $this->userInfo['elo'], +// "new_elo" => $newElo, +// 'reward' => array(), +// ); $data = array( - "battle_uuid" => $battleUuid, - "account_id" => getXVal($this->battleInfo,'account_id', 0), "room_mode" => getXVal($this->allInfo,'room_mode', 0), "pvp_mode" => $pvp_mode, "team_mode" => getXVal($this->allInfo,'team_mode', 0), - "battle_rank" => getXVal($this->battleInfo,'pvp_personal_rank', 0), - "team_rank" => getXVal($this->allInfo,'pvp_team_rank', 0), - "team_kills" => getXVal($this->allInfo,'pvp_team_kills', 0), - "is_win" => getXVal($this->battleInfo,'pve_boss_killed', 0), - "kills" => getXVal($this->battleInfo,'kills', 0), - "hero_id" => getXVal($this->battleInfo,'hero_uniid', 0), - "weapon1" => getXVal($this->battleInfo,'weapon_uuid1', 0), - "weapon2" => getXVal($this->battleInfo,'weapon_uuid2', 0), - "battle_end_time" => getXVal($this->battleInfo,'game_time', 0), - "current_level_class" => $newRank, - "current_level_class_score" => $newScore, - "level_class_score_chg" => $newScore - $this->userInfo['score'], // 排位分改变 - "pve_rank_score" => getXVal($this->battleInfo,'pve_score', 0), - "pve_kill_boss" => getXVal($this->battleInfo,'pve_boss_killed', 0), - "pve_instance_id" => getXVal($this->allInfo,'pve_instance_id', 0), -// "pve_instance_mode" => getXVal($this->allInfo,'pve_instance_mode', 0), - "old_elo" => $this->userInfo['elo'], - "new_elo" => $newElo, + "pvp_team_kills" => getXVal($this->allInfo,'pvp_team_kills', 0), + "pvp_team_rank" => getXVal($this->allInfo,'pvp_team_rank', 0), + 'account_id'=> getXVal($this->battleInfo,'account_id', 0), + 'name'=> getXVal($this->battleInfo,'name', 0), + 'head'=> getXVal($this->battleInfo,'head', 0), + 'head_frame'=> getXVal($this->battleInfo,'head_frame', 0), + 'sex'=> getXVal($this->battleInfo,'sex', 0), + 'hero_uniid'=> getXVal($this->battleInfo,'hero_uniid', 0), + 'hero_id'=> getXVal($this->battleInfo,'hero_id', 0), + 'dead'=> getXVal($this->battleInfo,'dead', 0), + 'skin_id'=> getXVal($this->battleInfo,'skin_id', 0), + 'is_mvp'=> getXVal($this->battleInfo,'is_mvp', 0), + 'old_rank'=> $oldRank, + 'new_rank'=> $newRank, + 'old_score'=> $oldScore, + 'new_score'=> $newScore, + 'old_elo'=> $oldElo, + 'new_elo'=> $newElo, + 'pvp_kill'=> getXVal($this->battleInfo,'pvp_kill', 0), + 'pvp_damage'=> getXVal($this->battleInfo,'pvp_damage', 0), + 'pvp_assist'=> getXVal($this->battleInfo,'pvp_assist', 0), + 'pvp_survia_time'=> getXVal($this->battleInfo,'pvp_survia_time', 0), + 'pvp_recover'=> getXVal($this->battleInfo,'pvp_recover', 0), + 'pvp_rescue'=> getXVal($this->battleInfo,'pvp_rescue', 0), + 'pvp_personal_rank'=> getXVal($this->battleInfo,'pvp_personal_rank', 0), + 'pve_order'=> getXVal($this->battleInfo,'pve_order', 0), + 'pve_score'=> getXVal($this->battleInfo,'pve_score', 0), + 'pve_star'=> getXVal($this->battleInfo,'pve_star', 0), + 'pve_damage'=> getXVal($this->battleInfo,'pve_damage', 0), + 'pve_revive'=> getXVal($this->battleInfo,'pve_revive', 0), + 'pve_survia_time'=> getXVal($this->battleInfo,'pve_survia_time', 0), + 'pve_wave'=> getXVal($this->battleInfo,'pve_wave', 0), + 'pve_max_wave'=> getXVal($this->battleInfo,'pve_max_wave', 0), + 'pve_boss_killed'=> getXVal($this->battleInfo,'pve_boss_killed', 0), + 'hero_lv'=> getXVal($this->battleInfo,'hero_lv', 1), + 'reward' => array(), ); BattleSettlement::addSingle($battleUuid,$roomUuid,$data); }