This commit is contained in:
hujiabin 2024-01-17 16:41:41 +08:00
parent 84061729ad
commit b0d754ba2e
2 changed files with 47 additions and 26 deletions

View File

@ -2,11 +2,13 @@
namespace services;
require_once('models/Hero.php');
require_once('models/HashRate.php');
require_once('models/HashRateBattleData.php');
use models\HashRateBattleData;
use models\HashRate;
use models\Hero;
use mt\AchievementsPower;
class HashRateService extends BaseService
{
@ -23,16 +25,6 @@ class HashRateService extends BaseService
$this->hisBattleData = HashRateBattleData::getMyBattleData();
$this->hashRateData = getXVal($this->hisBattleData, 'data', array());
// $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
// if (myself()->_getDaySeconds(getXVal($this->hashRateData, 'modifytime', 0)) <
// myself()->_getDaySeconds($currentPeriod['obtain_end_time'])) {
// $this->hashRateData = array(
// 'pvpData' => array(),
// 'mobaData' => array(),
// 'createtime' => myself()->_getNowTime(),
// 'modifytime' => myself()->_getNowTime(),
// );
// }
if (!$this->hashRateData){
$this->hashRateData = array(
'pvpData' => array(),
@ -41,6 +33,15 @@ class HashRateService extends BaseService
'modifytime' => myself()->_getNowTime(),
);
}
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
if (myself()->_getDaySeconds(getXVal($this->hashRateData, 'modifytime', 0)) <
myself()->_getDaySeconds($currentPeriod['obtain_start_time'])) {
$this->hashRateData = array(
'pvpData' => array(),
'mobaData' => array(),
'modifytime' => myself()->_getNowTime(),
);
}
$this->pvpBattleData = $this->hashRateData['pvpData'];
$this->mobaBattleData = $this->hashRateData['mobaData'];
}
@ -73,12 +74,14 @@ class HashRateService extends BaseService
break;
//X分钟内结束比赛
case AchievementsPower::NOMINAL_TIME_BATTLE_END : {
//....
$taskDto['current'] = $this->getBattleData($taskMate,
'total_fiveMin_times');
}
break;
//在局内升级最快次数
case AchievementsPower::IN_BATTLE_UP_LV : {
//.....
$taskDto['current'] = $this->getBattleData($taskMate,
'total_first_Lv_up');
}
break;
//游戏场次
@ -101,12 +104,20 @@ class HashRateService extends BaseService
break;
//累计行走距离(米)
case AchievementsPower::WALKING_DISTANCE : {
//.../
$taskDto['current'] = $this->getBattleData($taskMate,
'total_walking_distance');
}
break;
//指定英雄升阶数
case AchievementsPower::HERO_UP_QUALITY : {
//..../
$condition = $taskMate['condition'];
$quality = 0;
Hero::getHeroList(function ($row) use ($condition,&$quality) {
if ($row['hero_id'] == $condition && $row['quality'] > $quality){
$quality = $row['quality'];
}
});
$taskDto['current'] = $quality;
}
break;
//拥有英雄nft数

View File

@ -1260,30 +1260,40 @@ class TameBattleDataService extends BaseService {
private function applyEx(&$battleData)
{
//战斗次数
$this->incValue($battleData, 'total_battle_times', 1);
//排名
$ranked = 0;
if (! getXVal($this->battleInfo,'is_run_away', 0)){
$this->incValue($battleData, 'total_battle_times', 1);
}
switch (getXVal($this->allInfo,'room_mode', 0)){
case self::MATCH_MODE_PVP :{
$ranked = getXVal($this->battleInfo,'pvp_team_rank', 0);
//排名
$ranked = getXVal($this->battleInfo,'pvp_personal_rank', 0);
if ($ranked == 40){
$this->incValue($battleData, 'total_last_runner_times', 1);
}
//救援次数
$this->incValue($battleData, 'total_rescue_times', getXVal($this->battleInfo,'rescue_teammate_times', 0));
//行走距离
$distance = getXVal($this->battleInfo,'move_distance', 0);
$this->incValue($battleData, 'total_walking_distance', $distance);
}
break;
case self::ROOM_MODE_MOBA :{
/*
排名
几分钟结束战斗
第一个升满级
*/
//几分钟结束战斗
$duration = getXVal($this->battleInfo,'game_duration', 0);
if ($duration && floor($duration / 60) < 5){
$this->incValue($battleData, 'total_fiveMin_times', 1);
}
//第一个升满级
$fullLv = getXVal($this->battleInfo,'full_level_idx', 0);
if ($fullLv == 1){
$this->incValue($battleData, 'total_first_Lv_up', 1);
}
}
break;
}
if ($ranked == 1){
//是否胜利
if (getXVal($this->allInfo,'victory', 0)){
$this->incValue($battleData, 'total_win_times', 1);
}
//击杀
@ -1293,4 +1303,4 @@ class TameBattleDataService extends BaseService {
$this->procWeaponsSlot($battleData);
}
}
}