711 lines
34 KiB
PHP
711 lines
34 KiB
PHP
<?php
|
|
namespace services;
|
|
|
|
require_once('models/BattleSettlement.php');
|
|
require_once('models/Hero.php');
|
|
require_once('models/HashRate.php');
|
|
require_once('models/Season.php');
|
|
require_once('models/TicketConsumeRecord.php');
|
|
require_once('models/Circuit.php');
|
|
|
|
require_once('mt/MapMode.php');
|
|
require_once('mt/Rank.php');
|
|
require_once('mt/RankSeason.php');
|
|
require_once('mt/EconomyAttribute.php');
|
|
require_once('mt/CircuitTime.php');
|
|
require_once('mt/StakingVip.php');
|
|
require_once('mt/BattlePotion.php');
|
|
require_once('mt/Item.php');
|
|
|
|
require_once('services/AwardService.php');
|
|
require_once('services/PropertyChgService.php');
|
|
require_once('services/LogService.php');
|
|
require_once('services/BattleBoxService.php');
|
|
require_once('phpcommon/tglog.php');
|
|
|
|
use models\Circuit;
|
|
use models\TicketConsumeRecord;
|
|
use mt;
|
|
use services;
|
|
use phpcommon;
|
|
use phpcommon\SqlHelper;
|
|
use models\BattleSettlement;
|
|
use models\Hero;
|
|
use models\HashRate;
|
|
use models\Season;
|
|
use phpcommon\TGLog;
|
|
use services\LogService;
|
|
|
|
class RoomBattleDataService extends BaseService {
|
|
const ROOM_MODE_PVP = 0;
|
|
const ROOM_MODE_PVE = 1;
|
|
const ROOM_MODE_MOBA = 2;
|
|
|
|
|
|
public $teamExpScoreSort = array();
|
|
|
|
|
|
public $mapMode = 0;
|
|
public $inputData = array();
|
|
public $teamData = array();
|
|
public $battleSettlementDb = array();
|
|
public $maxKill = 0;
|
|
public $maxAssist = 0;
|
|
public $maxDamage = 0;
|
|
public $maxRecover= 0;
|
|
public $maxLevel= 0;
|
|
public $maxAlive= 0;
|
|
public $realUserCount= 0;
|
|
public $matchRoomUuid= 0;
|
|
public $logData = array();
|
|
|
|
|
|
public function settlementReward(){
|
|
error_log('settlementReward');
|
|
$realUserNum = 0;
|
|
$myTeamScore = 0;
|
|
foreach ($this->teamData['members'] as $member){
|
|
if(!myself()->_isAndroidAccountId(getXVal($member,'account_id', 0))){
|
|
$realUserNum += 1;
|
|
$myTeamScore += $this->_calBattleScore($member);
|
|
}
|
|
}
|
|
$myTeamScoreAvg = $realUserNum > 0 ? $myTeamScore / $realUserNum : 0;
|
|
$battleData = emptyReplace(json_decode($this->battleSettlementDb['data'], true), array());
|
|
if ($battleData['settlement_status'] == 1){
|
|
error_log('Cannot be resettled');
|
|
return;
|
|
}
|
|
$propertyChgService = new services\PropertyChgService();
|
|
$awardService = new services\AwardService();
|
|
foreach ($battleData['members'] as &$member){
|
|
$battleScore = $this->_calBattleScore($member);
|
|
$member['battle_score'] = round($battleScore,4);
|
|
|
|
// //验证非机器人
|
|
$this->matchRoomUuid = getXVal($member,'match_room_uuid', 0);
|
|
$teamRanked = getXVal($member,'pvp_team_rank', 0);
|
|
$winningPro = getXVal($member,'winningPro', 0);
|
|
$account = getXVal($member,'account_id', 0);
|
|
if(!myself()->_isAndroidAccountId($account)){
|
|
error_log('Real Account:'.$account);
|
|
myself()->switchAccount($account);
|
|
$userDb = myself()->_getOrmUserInfo();
|
|
$heroDb = Hero::find(getXVal($member,'hero_uniid', 0));
|
|
if ($userDb && $heroDb){
|
|
//排位模式排位分计算
|
|
if ($this->mapMode == mt\MapMode::RANKING_MODE){
|
|
$newRank=$userDb['rank'];
|
|
$ranked = $this->getMyRanked($account);
|
|
$newScore = FormulaService::calcBattleAfterRankScoreNew($userDb,$ranked,$teamRanked,$winningPro);
|
|
$newElo = FormulaService::calcUserEloValueNew($userDb,$ranked,$winningPro);
|
|
if ($newScore < $userDb['score'] && $userDb['score']< 1300){
|
|
$newScore = $userDb['score'];
|
|
}
|
|
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
|
myself()->_updateUserInfo(array(
|
|
'rank' => $newRank,
|
|
'score' => $newScore,
|
|
'elo' => $newElo,
|
|
'history_best_rank' => max($userDb['history_best_rank'], $newRank),
|
|
'history_best_score' => max($userDb['history_best_score'], $newScore),
|
|
'score_modifytime' => myself()->_getNowTime(),
|
|
'best_rank_modifytime' => $newRank > $userDb['rank'] ?
|
|
myself()->_getNowTime() : $userDb['best_rank_modifytime'],
|
|
));
|
|
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
|
if($currSeasonMeta){
|
|
Season::upsert($currSeasonMeta['id'], array(
|
|
'rank' => $newRank,
|
|
'score' => $newScore,
|
|
'elo' => $newElo,
|
|
'history_best_rank' => max($userDb['history_best_rank'], $newRank),
|
|
'score_modifytime' => myself()->_getNowTime(),
|
|
'best_rank_modifytime' => $newRank > $userDb['rank'] ?
|
|
myself()->_getNowTime() : $userDb['best_rank_modifytime'],
|
|
));
|
|
}
|
|
|
|
$member['new_rank'] = $newRank;
|
|
$member['new_score'] = $newScore;
|
|
$member['new_elo'] = $newElo;
|
|
}
|
|
//巡回模式排位分计算
|
|
if ($this->mapMode == mt\MapMode::CIRCUIT_MODE){
|
|
$circuitMeta = mt\CircuitTime::getCurrentCircuit();
|
|
$circuitStageMeta = mt\CircuitTime::getCurrentStage();
|
|
if ($circuitMeta && $circuitStageMeta){
|
|
$minScore = mt\Parameter::getVal('circuit_rank_score_min',0);
|
|
$multConstant = mt\Parameter::getVal('circuit_score_mult_constant',1);
|
|
$shiftConstant = mt\Parameter::getVal('circuit_score_shift_constant',1);
|
|
$circuitScore = $battleScore * $multConstant + $shiftConstant;
|
|
$myScore = Circuit::getMyScore($circuitMeta['circuit_season']);
|
|
$myPhaseScore = Circuit::getMyPhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase']);
|
|
$finalScore = floor(max($minScore, $myScore+$circuitScore)) ;
|
|
$finalPhaseScore = floor(max($minScore, $myPhaseScore+$circuitScore));
|
|
Circuit::updateScore($circuitMeta['circuit_season'],$finalScore);
|
|
Circuit::updatePhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase'],$finalPhaseScore);
|
|
$member['new_circuit_score'] = $finalScore;
|
|
}
|
|
}
|
|
|
|
$battleSingleDb = BattleSettlement::findSingle($this->battleSettlementDb['battle_uuid']);
|
|
if ($this->mapMode == mt\MapMode::TREASURE_BOX_MODE && $member['move_distance'] <= 2000 ){
|
|
error_log("宝箱模式:消极战斗");
|
|
}else{
|
|
$this->_getBattleRewards($battleSingleDb, $userDb,$heroDb,$battleScore,$myTeamScoreAvg,$myTeamScore,$member['reward'], $member);
|
|
myself()->_addItems($member['reward'], $awardService,$propertyChgService);
|
|
if ($this->mapMode == mt\MapMode::GOLD_MODE){
|
|
$member['today_hero_battles'] = $heroDb['idx'] . '|' .myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$heroDb['idx']);
|
|
}
|
|
}
|
|
|
|
if ($battleSingleDb){
|
|
$battleSingleData = emptyReplace(json_decode($battleSingleDb['data'], true), array());
|
|
$battleSingleData['reward'] = $member['reward'];
|
|
$battleSingleData['new_rank'] = $member['new_rank'];
|
|
$battleSingleData['new_score'] = $member['new_score'];
|
|
$battleSingleData['new_elo'] = $member['new_elo'];
|
|
$battleSingleData['new_circuit_score'] = $member['new_circuit_score'];
|
|
BattleSettlement::addSingle($battleSingleDb['battle_uuid'],$battleSingleDb['room_uuid'],$battleSingleData);
|
|
}
|
|
}else{
|
|
error_log('User :'.$account .' Error Or Hero Error');
|
|
}
|
|
|
|
}
|
|
}
|
|
$battleData['settlement_status'] = 1;
|
|
BattleSettlement::addTeam(
|
|
$this->battleSettlementDb['battle_uuid'],
|
|
$this->battleSettlementDb['room_uuid'],
|
|
$battleData
|
|
);
|
|
|
|
}
|
|
|
|
public function _getBattleRewards($battleSingleDb, $userDb,$heroDb,$battleScore,$teamScoreAvg,$teamScore,&$reward, $member){
|
|
error_log('settlementReward -> _getBattleRewards');
|
|
$mapModeMeta = mt\MapMode::findByMapMode($this->mapMode);
|
|
$teamRank = getXVal($this->teamData,'pvp_team_rank', 0);
|
|
if ($mapModeMeta){
|
|
$accountLucky = Hero::getAccountLuckyTemp();
|
|
$battleItems = getXVal($member,'battle_items', 0);
|
|
if (count($battleItems) > 0){
|
|
foreach ($battleItems as $item){
|
|
$itemMeta = mt\Item::get($item['item_id']);
|
|
if ($itemMeta['type'] == mt\Item::FUNC_TYPE && $itemMeta['sub_type'] == mt\Item::LUCKY_SYMBOL_SUBTYPE){
|
|
$potionMeta = mt\BattlePotion::find($item['item_id']);
|
|
if ($potionMeta){
|
|
$effect = explode(':',$potionMeta['effect']);
|
|
$accountLucky += $effect[1];
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
$rewardMeta = mt\BattleReward::find($mapModeMeta['rewardMode'],$accountLucky);
|
|
if (!$rewardMeta){
|
|
error_log('ERROR:'.$this->mapMode.' settlementReward,user have lucky '.$accountLucky);
|
|
return ;
|
|
}
|
|
$hashRateValue = 0;
|
|
$rightVal = 0;
|
|
if ($this->mapMode == mt\MapMode::GOLD_MODE){
|
|
$gold = $this->_goldMapModeBaseGold($heroDb,$battleScore,$teamScoreAvg,$mapModeMeta,$rewardMeta,$teamRank,$reward);
|
|
$baseGold = $gold;
|
|
$gold = $this->_hashRateBoost($userDb,$gold,$hashRateValue);
|
|
//Vip加成金币获得
|
|
$rightVal = myself()->_getVipRightsVal(mt\StakingVip::GAIN_GOLD);
|
|
if ($gold > 0 && $rightVal > 0){
|
|
$gold += $rightVal;
|
|
}
|
|
}else{
|
|
$gold = $this->_otherMapModeBaseGold($rewardMeta,$teamRank,$battleScore,$teamScore,$reward);
|
|
$baseGold = $gold;
|
|
}
|
|
|
|
if ($gold > 0){
|
|
if ($heroDb['quality'] > 1){
|
|
array_push($reward,array(
|
|
"item_id" => V_ITEM_GOLD,
|
|
"item_num" => floor($gold),
|
|
"details" => array(
|
|
'baseValue' => floor($baseGold),
|
|
'hashRateValue' => $hashRateValue,
|
|
'vipValue' => $rightVal,
|
|
)
|
|
));
|
|
myself()->_incDailyV(TN_DAILY_GATHER_GOLD,0,floor($gold));
|
|
}else{
|
|
array_push($reward,array(
|
|
"item_id" => V_ITEM_BIND_GOLD,
|
|
"item_num" => floor($gold),
|
|
"details" => array(
|
|
'baseValue' => floor($baseGold),
|
|
'hashRateValue' => $hashRateValue,
|
|
'vipValue' => $rightVal,
|
|
)
|
|
));
|
|
}
|
|
|
|
}
|
|
//宝箱掉落
|
|
$this->_dropBox($battleSingleDb, $rewardMeta,$teamRank,$reward,$member);
|
|
}
|
|
}
|
|
|
|
private function _hashRateBoost($userDb,$gold,&$hashRateValue){
|
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
|
if ($currentPeriod && myself()->_getNowTime() >= strtotime($currentPeriod['income_start_time'])){
|
|
$currentCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id']);
|
|
error_log("金币模式-算力加成:".$currentCompute);
|
|
$computeR = explode("|",mt\Parameter::getVal('economy_account_compute_R',0));
|
|
$k = 0;
|
|
for ($i=0;$i<count($computeR);$i++){
|
|
if ($currentCompute >= $computeR[$i]){
|
|
$k = $i;
|
|
}
|
|
}
|
|
$computeE = explode("|",mt\Parameter::getVal('economy_account_compute_E',0));
|
|
$powerRate = $computeE[$k];
|
|
$gold = $gold * ($powerRate + 1);
|
|
$hashRateValue = round($powerRate,4);
|
|
}
|
|
return $gold;
|
|
}
|
|
|
|
private function _otherMapModeBaseGold($rewardMeta,$teamRank,$battleScore,$teamScore,&$reward){
|
|
$gold = 0;
|
|
if (!empty($rewardMeta['goldLoot'])){
|
|
$items = LootService::dropOutItem($rewardMeta['goldLoot']);
|
|
foreach ($items as $item){
|
|
if ($item['item_id'] = V_ITEM_GOLD){
|
|
$gold += $item['item_num'];
|
|
}else{
|
|
array_push($reward,$item);
|
|
}
|
|
}
|
|
$coefficientArr = explode(";",$rewardMeta['goldParam']);
|
|
$coefficient = isset($coefficientArr[$teamRank-1]) ? $coefficientArr[$teamRank-1] : 0;
|
|
if ($this->mapMode == mt\MapMode::BET_MODE){
|
|
$ticketMeta = \mt\Item::get(900006);
|
|
$ticketNum = TicketConsumeRecord::getRecord($this->matchRoomUuid);
|
|
$gold = $ticketMeta['gold'] * $ticketNum * $coefficient * ($battleScore / $teamScore);
|
|
}
|
|
}
|
|
return $gold;
|
|
}
|
|
|
|
private function _goldMapModeBaseGold($heroDb,$battleScore,$teamScoreAvg,$mapModeMeta,$rewardMeta,$teamRank,&$reward){
|
|
$heroTimes = Hero::getDailyV($heroDb['idx']);
|
|
$goldModeTimes = myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,0);
|
|
$heroMeta = \mt\Item::get($heroDb['hero_id']);
|
|
$heroAtteMeta = mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$heroDb['quality']);
|
|
$heroTimesMax = $heroAtteMeta['roundPerDay'];
|
|
//金币模式检验
|
|
//Vip加成打金次数
|
|
$rewardsMaxTimes = $mapModeMeta['rewards_max_time'];
|
|
$rightVal = myself()->_getVipRightsVal(mt\StakingVip::ACCOUNT_TIMES);
|
|
if ($rightVal > 0){
|
|
$rewardsMaxTimes += $rightVal;
|
|
}
|
|
$gold = 0;
|
|
if ($heroDb['quality'] > 1){
|
|
if (Hero::verifyValid($heroDb) && $heroTimes < $heroTimesMax && $goldModeTimes < $rewardsMaxTimes){
|
|
$items = LootService::dropOutItem($rewardMeta['goldLoot']);
|
|
foreach ($items as $item){
|
|
if ($item['item_id'] = V_ITEM_GOLD){
|
|
$gold += $item['item_num'];
|
|
}else{
|
|
array_push($reward,$item);
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
if ($heroTimes < $heroTimesMax && $goldModeTimes < $rewardsMaxTimes){
|
|
$items = LootService::dropOutItem($rewardMeta['boundGoldLoot']);
|
|
foreach ($items as $item){
|
|
if ($item['item_id'] = V_ITEM_BIND_GOLD){
|
|
$gold += $item['item_num'];
|
|
}else{
|
|
array_push($reward,$item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($gold > 0){
|
|
Hero::incDailyV($heroDb['idx'],1);
|
|
if ($heroDb['quality'] > 1){
|
|
myself()->_incDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,0,1);
|
|
}
|
|
$coefficientArr = explode(";",$rewardMeta['goldParam']);
|
|
$coefficient = isset($coefficientArr[$teamRank-1]) ? $coefficientArr[$teamRank-1] : 0;
|
|
$gold = $gold * $coefficient * ($battleScore / $teamScoreAvg);
|
|
|
|
//财富值加成
|
|
$wealthK = mt\Parameter::getVal('economy_hero_wealth_K',0);
|
|
$wealthE = mt\Parameter::getVal('economy_hero_wealth_E',0);
|
|
$wealthRate = $wealthE * (Hero::getHeroWealth($heroDb) / (Hero::getHeroWealth($heroDb) + $wealthK));
|
|
$gold = $gold * (1 + $wealthRate);
|
|
}
|
|
return $gold;
|
|
}
|
|
|
|
private function _dropBox($battleSingleDb, $rewardMeta,$teamRank,&$reward,$member){
|
|
//宝箱掉落
|
|
$chestLootProbArr = explode(";",$rewardMeta['chestLootProb']);
|
|
$rate = isset($chestLootProbArr[$teamRank-1]) ? $chestLootProbArr[$teamRank-1] : 0;
|
|
if ($member['account_id'] == "2_2006_QmoeZ5t2ecIq6dVNyi9jQj5CzTUB0bGC"){
|
|
error_log("BoxMap:".json_encode(
|
|
array(
|
|
'rate' => $rate,
|
|
'box_num' => $member['box_num'],
|
|
'switch' => myself()->_switchIsOpen('bigEventBoxDrop'),
|
|
)
|
|
));
|
|
}
|
|
if ($rate > 0 && !empty($member['box_num']) && myself()->_switchIsOpen('bigEventBoxDrop')){
|
|
$rewardBox = array();
|
|
$realBoxNum = 0;
|
|
for ($i = 0; $i < $member['box_num']; ++$i) {
|
|
$rand = $rate * 100;
|
|
$rnd = rand(1,100);
|
|
++$realBoxNum;
|
|
if ($rnd <= $rand){
|
|
$chestItems = LootService::dropOutItem($rewardMeta['chestLoot']);
|
|
if (count($chestItems)>0){
|
|
$event = array(
|
|
'ID' => 'Box',
|
|
'SUB_ID' => 'drop',
|
|
'SUB_KEY' => 'drop_box',
|
|
'before' =>array(
|
|
'rnd' => $rnd,
|
|
'rate' => $rate,
|
|
'rewardMeta' => $rewardMeta,
|
|
),
|
|
'result' => $chestItems,
|
|
);
|
|
LogService::burialPointEvent($event);
|
|
}
|
|
|
|
foreach ($chestItems as $item){
|
|
array_push($rewardBox,$item);
|
|
}
|
|
}
|
|
}
|
|
if (count($rewardBox) > 0){
|
|
if ($battleSingleDb) {
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_box_alloc',
|
|
array(
|
|
'room_uuid' => $battleSingleDb['room_uuid'],
|
|
)
|
|
);
|
|
if ($row) {
|
|
services\BattleBoxService::incDropTotalNum($row['phase'],
|
|
$row['createtime'],
|
|
$realBoxNum);
|
|
}
|
|
}
|
|
$rewardBoxResult = myself()->_mergeAlikeItemKey($rewardBox);
|
|
foreach ($rewardBoxResult as $item){
|
|
array_push($reward,$item);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public function _getBattleRewardsOld($userDb,$heroDb,$battleScore,$teamScoreAvg,$teamScore,&$reward, $member){
|
|
error_log('settlementReward -> _getBattleRewards');
|
|
$mapModeMeta = mt\MapMode::findByMapMode($this->mapMode);
|
|
$teamRank = getXVal($this->teamData,'pvp_team_rank', 0);
|
|
if ($mapModeMeta){
|
|
$baseGold = 0;
|
|
$gold = 0;
|
|
// $accountLucky = Hero::getAccountLucky($userDb['address']);
|
|
$accountLucky = Hero::getAccountLuckyTemp();
|
|
$rewardMeta = mt\BattleReward::find($mapModeMeta['rewardMode'],$accountLucky);
|
|
if (!$rewardMeta){
|
|
return ;
|
|
}
|
|
$heroTimes = myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$heroDb['idx']);
|
|
$goldModeTimes = myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,0);
|
|
$heroMeta = \mt\Item::get($heroDb['hero_id']);
|
|
$heroAtteMeta = mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$heroDb['quality']);
|
|
$heroTimesMax = $heroAtteMeta['roundPerDay'];
|
|
error_log("Condition:".json_encode(array(
|
|
'account' => $userDb['account_id'],
|
|
'heroBattleTimes' => $heroTimes,
|
|
'goldModeTimes' => $goldModeTimes,
|
|
'validTimeBool' => Hero::verifyValid($heroDb) ? 1:0,
|
|
'heroInfo'=> $heroDb
|
|
)));
|
|
//金币模式检验
|
|
//Vip加成打金次数
|
|
$rewardsMaxTimes = $mapModeMeta['rewards_max_time'];
|
|
$rightVal = myself()->_getVipRightsVal(mt\StakingVip::ACCOUNT_TIMES);
|
|
if ($rightVal > 0){
|
|
$rewardsMaxTimes += $rightVal;
|
|
}
|
|
if ($this->mapMode == mt\MapMode::GOLD_MODE &&
|
|
// ($goldModeTimes >= $mapModeMeta['rewards_max_time'] )){
|
|
(!Hero::verifyValid($heroDb) || $heroTimes >= $heroTimesMax || $goldModeTimes >= $rewardsMaxTimes)){
|
|
error_log("金币模式:出战英雄没有打金时间或每日打金场次上限");
|
|
}else{
|
|
if (!empty($rewardMeta['goldLoot'])){
|
|
$items = LootService::dropOutItem($rewardMeta['goldLoot']);
|
|
foreach ($items as $item){
|
|
if ($item['item_id'] = V_ITEM_GOLD){
|
|
$gold += $item['item_num'];
|
|
$baseGold += $item['item_num'];
|
|
}else{
|
|
array_push($reward,$item);
|
|
}
|
|
}
|
|
}
|
|
$coefficientArr = explode(";",$rewardMeta['goldParam']);
|
|
$coefficient = isset($coefficientArr[$teamRank-1]) ? $coefficientArr[$teamRank-1] : 0;
|
|
if ($this->mapMode == mt\MapMode::GOLD_MODE){
|
|
$gold = $gold * $coefficient * ($battleScore / $teamScoreAvg);
|
|
}
|
|
if ($this->mapMode == mt\MapMode::BET_MODE){
|
|
$ticketMeta = \mt\Item::get(900006);
|
|
$baseGold = $ticketMeta['gold'];
|
|
$ticketNum = TicketConsumeRecord::getRecord($this->matchRoomUuid);
|
|
$gold = $ticketMeta['gold'] * $ticketNum * $coefficient * ($battleScore / $teamScore);
|
|
}
|
|
|
|
$baseValue = $gold;
|
|
if ($this->mapMode == mt\MapMode::GOLD_MODE){
|
|
myself()->_incDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,(int)$heroDb['idx'],1);
|
|
myself()->_incDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,0,1);
|
|
//财富值加成
|
|
$wealthK = mt\Parameter::getVal('economy_hero_wealth_K',0);
|
|
$wealthE = mt\Parameter::getVal('economy_hero_wealth_E',0);
|
|
$wealthRate = $wealthE * (Hero::getHeroWealth($heroDb) / (Hero::getHeroWealth($heroDb) + $wealthK));
|
|
$gold = $gold * (1 + $wealthRate);
|
|
// $wealthValue = round($wealthRate,4);
|
|
//基础金币获得
|
|
$baseValue = $gold;
|
|
//算力加成
|
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
|
if ($currentPeriod && myself()->_getNowTime() >= strtotime($currentPeriod['income_start_time'])){
|
|
$currentCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id']);
|
|
error_log("金币模式-算力加成:".$currentCompute);
|
|
$computeR = explode("|",mt\Parameter::getVal('economy_account_compute_R',0));
|
|
$k = 0;
|
|
for ($i=0;$i<count($computeR);$i++){
|
|
if ($currentCompute >= $computeR[$i]){
|
|
$k = $i;
|
|
}
|
|
}
|
|
$computeE = explode("|",mt\Parameter::getVal('economy_account_compute_E',0));
|
|
$powerRate = $computeE[$k];
|
|
$gold = $gold * ($powerRate + 1);
|
|
$hashRateValue = round($powerRate,4);
|
|
}
|
|
//Vip加成金币获得
|
|
$rightVal = myself()->_getVipRightsVal(mt\StakingVip::GAIN_GOLD);
|
|
if ($rightVal > 0){
|
|
$gold += $rightVal;
|
|
}
|
|
}
|
|
if ($gold > 0){
|
|
array_push($reward,array(
|
|
"item_id" => V_ITEM_GOLD,
|
|
"item_num" => floor($gold),
|
|
"details" => array(
|
|
'baseValue' => floor($baseValue),
|
|
'vipValue' => isset($rightVal) ? $rightVal : 0,
|
|
'hashRateValue' => isset($hashRateValue) ? $hashRateValue : 0,
|
|
)
|
|
));
|
|
myself()->_incDailyV(TN_DAILY_GATHER_GOLD,0,floor($gold));
|
|
}
|
|
|
|
}
|
|
|
|
//宝箱掉落
|
|
$chestLootProbArr = explode(";",$rewardMeta['chestLootProb']);
|
|
$rate = isset($chestLootProbArr[$teamRank-1]) ? $chestLootProbArr[$teamRank-1] : 0;
|
|
//error_log(json_encode($member));
|
|
if ($rate > 0 && !empty($member['box_num']) && myself()->_switchIsOpen('bigEventBoxDrop')){
|
|
$rewardBox = array();
|
|
for ($i = 0; $i < $member['box_num']; ++$i) {
|
|
$rand = $rate * 100;
|
|
$rnd = rand(1,100);
|
|
if ($rnd <= $rand){
|
|
$chestItems = LootService::dropOutItem($rewardMeta['chestLoot']);
|
|
if (count($chestItems)>0){
|
|
$event = array(
|
|
'ID' => 'Box',
|
|
'SUB_ID' => 'drop',
|
|
'SUB_KEY' => 'drop_box',
|
|
'before' =>array(
|
|
'rnd' => $rnd,
|
|
'rate' => $rate,
|
|
'rewardMeta' => $rewardMeta,
|
|
),
|
|
'result' => $chestItems,
|
|
);
|
|
LogService::burialPointEvent($event);
|
|
}
|
|
|
|
foreach ($chestItems as $item){
|
|
array_push($rewardBox,$item);
|
|
}
|
|
}
|
|
}
|
|
if (count($rewardBox) > 0){
|
|
$rewardBoxResult = myself()->_mergeAlikeItemKey($rewardBox);
|
|
foreach ($rewardBoxResult as $item){
|
|
array_push($reward,$item);
|
|
}
|
|
}
|
|
|
|
}
|
|
TGLog::writeToLog("game_2006_api","battleReport",array(
|
|
'account_id' => $userDb['account_id'],
|
|
'map_mode' => $this->mapMode,
|
|
'baseGold' => $baseGold,
|
|
'gold' => isset($baseValue) ? $baseValue : $gold,
|
|
'box_rate' => $rate,
|
|
'rewards' => $reward,
|
|
'goldInfo' => array(
|
|
'heroBattleTimes' => $heroDb['idx'] .'|' .$heroTimes,
|
|
'goldModeTimes' => $goldModeTimes,
|
|
),
|
|
'betInfo' => array(
|
|
'realUser' => $this->realUserCount,
|
|
'ticketNum' => isset($ticketNum) ? $ticketNum : 0,
|
|
'coefficient' => isset($coefficient) ? $coefficient : 0,
|
|
'battleScore' => round($battleScore,9),
|
|
'teamScore' => round($teamScore,9),
|
|
'teamScoreAvg' => round($teamScoreAvg,9),
|
|
'wealthRate' => isset($wealthRate) ? $wealthRate : 0,
|
|
)
|
|
));
|
|
}
|
|
}
|
|
|
|
public function _calBattleScore($battleInfo){
|
|
$paramMeta = mt\Parameter::getVal('performance_score_range',0);
|
|
$paramMetaMoba = mt\Parameter::getVal('performance_score_weight_4V4',0);
|
|
$paramMetaPvp = mt\Parameter::getVal('performance_score_weight_BR',0);
|
|
$paramMetaCircuit = mt\Parameter::getVal('performance_score_weight_circuit',0);
|
|
$weightMoba = explode("|",$paramMetaMoba);
|
|
$weightPvp = explode("|",$paramMetaPvp);
|
|
$weightCircuit = explode("|",$paramMetaCircuit);
|
|
$scoreParam = explode("|",$paramMeta);
|
|
if (count($scoreParam) < 2){
|
|
error_log('Parameter table error');
|
|
return 0;
|
|
}
|
|
$room_mode = getXVal($this->inputData,'room_mode', 0);
|
|
if ($this->maxKill == 0) {
|
|
$killSco = $scoreParam[0];
|
|
} else {
|
|
$kill = getXVal($battleInfo, 'pvp_kill', 0);
|
|
$killSco = ($scoreParam[1] - $scoreParam[0]) / ($this->maxKill - 0) * ($kill - 0) + $scoreParam[0];
|
|
}
|
|
if ($this->maxAssist == 0) {
|
|
$assistSco = $scoreParam[0];
|
|
} else {
|
|
$assist = getXVal($battleInfo, 'pvp_assist', 0);
|
|
$assistSco = ($scoreParam[1] - $scoreParam[0]) / ($this->maxAssist - 0) * ($assist - 0) + $scoreParam[0];
|
|
}
|
|
if ($this->maxDamage == 0) {
|
|
$damageSco = $scoreParam[0];
|
|
} else {
|
|
$damage = getXVal($battleInfo, 'pvp_damage', 0);
|
|
$damageSco = ($scoreParam[1] - $scoreParam[0]) / ($this->maxDamage - 0) * ($damage - 0) + $scoreParam[0];
|
|
}
|
|
if ($this->maxRecover == 0) {
|
|
$recoverSco = $scoreParam[0];
|
|
} else {
|
|
$recover = getXVal($battleInfo, 'pvp_recover', 0);
|
|
$recoverSco = ($scoreParam[1] - $scoreParam[0]) / ($this->maxRecover - 0) * ($recover - 0) + $scoreParam[0];
|
|
}
|
|
if ($this->maxLevel == 1) {
|
|
$levelSco = $scoreParam[0];
|
|
} else {
|
|
$level = getXVal($battleInfo, 'hero_lv', 0);
|
|
$levelSco = ($scoreParam[1] - $scoreParam[0]) / ($this->maxLevel - 0) * ($level - 0) + $scoreParam[0];
|
|
}
|
|
if ($this->maxAlive == 0) {
|
|
$aliveSco = $scoreParam[0];
|
|
} else {
|
|
$alive = getXVal($battleInfo, 'pvp_survia_time', 0) / 1000;
|
|
$aliveSco = ($scoreParam[1] - $scoreParam[0]) / ($this->maxAlive - 0) * ($alive - 0) + $scoreParam[0];
|
|
}
|
|
error_log(json_encode(array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'kill_sco' => $killSco,
|
|
'assist_sco' => $assistSco,
|
|
'damage_sco' => $damageSco,
|
|
'recover_sco' => $recoverSco,
|
|
'alive_sco' => $aliveSco,
|
|
'level_sco' => $levelSco,
|
|
'assist' => getXVal($battleInfo, 'pvp_assist', 0),
|
|
'max_assist' => $this->maxAssist,
|
|
'damage' => getXVal($battleInfo, 'pvp_damage', 0),
|
|
'max_damage' => $this->maxDamage,
|
|
'recover' => getXVal($battleInfo, 'pvp_recover', 0),
|
|
'max_recover' => $this->maxRecover,
|
|
'level' => getXVal($battleInfo, 'hero_lv', 0),
|
|
'max_level' => $this->maxLevel
|
|
)));
|
|
switch ($room_mode){
|
|
case self::ROOM_MODE_PVP: {
|
|
if (getXVal($this->inputData,'map_mode', 0) == mt\MapMode::CIRCUIT_MODE){
|
|
if (count($weightCircuit) == 5){
|
|
$killSco *= $weightCircuit[0];
|
|
$assistSco *= $weightCircuit[1];
|
|
$damageSco *= $weightCircuit[2];
|
|
$recoverSco *= $weightCircuit[3];
|
|
$aliveSco *= $weightCircuit[4];
|
|
}
|
|
}else{
|
|
if (count($weightPvp) == 5){
|
|
$killSco *= $weightPvp[0];
|
|
$assistSco *= $weightPvp[1];
|
|
$damageSco *= $weightPvp[2];
|
|
$recoverSco *= $weightPvp[3];
|
|
$aliveSco *= $weightPvp[4];
|
|
}
|
|
}
|
|
$battleScore = ($killSco + $assistSco + $damageSco + $recoverSco + $aliveSco);
|
|
}
|
|
break;
|
|
case self::ROOM_MODE_MOBA :{
|
|
if (count($weightMoba) == 5){
|
|
$killSco *= $weightMoba[0];
|
|
$assistSco *= $weightMoba[1];
|
|
$damageSco *= $weightMoba[2];
|
|
$recoverSco *= $weightMoba[3];
|
|
$levelSco *= $weightMoba[4];
|
|
}
|
|
$battleScore = ($killSco + $assistSco + $damageSco + $recoverSco + $levelSco);
|
|
}
|
|
break;
|
|
default : {
|
|
$battleScore = 0;
|
|
}
|
|
}
|
|
return $battleScore;
|
|
}
|
|
|
|
private function getMyRanked($account){
|
|
foreach ($this->teamExpScoreSort as $k=>$value){
|
|
if ($value['account_id'] == $account){
|
|
return $k+1;
|
|
}
|
|
}
|
|
return 8;
|
|
}
|
|
|
|
}
|