1
This commit is contained in:
commit
702b2ee4c3
@ -60,8 +60,56 @@ class BattleController extends BaseAuthedController {
|
|||||||
if ($data) {
|
if ($data) {
|
||||||
$teamList = $data['team_list'];
|
$teamList = $data['team_list'];
|
||||||
}
|
}
|
||||||
|
error_log(json_encode($teamList));
|
||||||
|
// $teamList = array(
|
||||||
|
// array(
|
||||||
|
// "team_id" => 10001,
|
||||||
|
// 'members' => array(
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6000_2006_test1111',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6513_2006_dYayfOVObW0KpfXhNr1enZ92rkaxmu3c',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6513_2006_6000_2006_test1111',
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// "team_id" => 10002,
|
||||||
|
// 'members' => array(
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6513_2006_oUnnMgxxU5apjZVF8tSOQnHhIXzLuAzT',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6513_2006_DmQHkZp0hoqvmSBwCvP6Z0Bru7WhU1fN',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6513_2006_1Ul37E5eNO905laoE1kA9lvC1ydplC0m',
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// "team_id" => 10003,
|
||||||
|
// 'members' => array(
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6513_2006_6jJQLHhVbdyi83FJW1k4QiGPoXs12bBD',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6000_2006_DmQHkZp0hoqvmSBwCvP6Z0Bru7WhU1fN',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6000_2006_1Ul37E5eNO905laoE1kA9lvC1ydplC0m',
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'account_id'=>'6000_2006_qqqqwwwwweeee',
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
$battleDataService = new services\BattleDataService();
|
$battleDataService = new services\BattleDataService();
|
||||||
|
$battleDataService->teamList = $teamList;
|
||||||
$battleDataService->updateBattleData();
|
$battleDataService->updateBattleData();
|
||||||
SqlHelper::insert(
|
SqlHelper::insert(
|
||||||
$this->_getSelfMysql(),
|
$this->_getSelfMysql(),
|
||||||
@ -77,10 +125,16 @@ class BattleController extends BaseAuthedController {
|
|||||||
$data = array(
|
$data = array(
|
||||||
'reward' => $battleDataService->getReward()
|
'reward' => $battleDataService->getReward()
|
||||||
);
|
);
|
||||||
if (getReqVal('match_mode', 0) == services\BattleDataService::MATCH_MODE_PVP && mt\RankSeason::getCurrentSeason()){
|
if ( getReqVal('match_mode', 0) == services\BattleDataService::MATCH_MODE_PVP
|
||||||
|
&& mt\RankSeason::getCurrentSeason()
|
||||||
|
&& myself()->_getV(TN_RANK_STATUS, 0 ) == 0 ){
|
||||||
$newRank = $userInfo['rank'];
|
$newRank = $userInfo['rank'];
|
||||||
$newScore = \services\FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST);
|
$newScore = $userInfo['score'];
|
||||||
|
$winningPro = $battleDataService->celWinningPro();
|
||||||
|
if ($winningPro){
|
||||||
|
$newScore = \services\FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST,$winningPro);
|
||||||
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
||||||
|
}
|
||||||
$scoreInfo = array(
|
$scoreInfo = array(
|
||||||
'old_rank' => $userInfo['rank'],
|
'old_rank' => $userInfo['rank'],
|
||||||
'old_score' => $userInfo['score'],
|
'old_score' => $userInfo['score'],
|
||||||
|
@ -359,11 +359,14 @@ class Chip extends BaseModel
|
|||||||
$chipIdsArr = explode('|',$chip_ids);
|
$chipIdsArr = explode('|',$chip_ids);
|
||||||
foreach ($chipIdsArr as $val){
|
foreach ($chipIdsArr as $val){
|
||||||
// $chip = self::toDto(self::getChipByIdx($val));
|
// $chip = self::toDto(self::getChipByIdx($val));
|
||||||
$chip = self::toDto(self::getChipByTokenId($val));
|
$row = self::getChipByTokenId($val);
|
||||||
|
if ($row){
|
||||||
|
$chip = self::toDto($row);
|
||||||
foreach ($chip['rand_attr'] as $v){
|
foreach ($chip['rand_attr'] as $v){
|
||||||
array_push($chipAttr,$v);
|
array_push($chipAttr,$v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$item = [];
|
$item = [];
|
||||||
foreach ($chipAttr as $k=>$v){
|
foreach ($chipAttr as $k=>$v){
|
||||||
if (!isset($item[$v['attr_id']])){
|
if (!isset($item[$v['attr_id']])){
|
||||||
|
@ -38,8 +38,10 @@ require_once('services/LogService.php');
|
|||||||
use models\Chip;
|
use models\Chip;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
use models\NftActive;
|
use models\NftActive;
|
||||||
|
use models\User;
|
||||||
use mt;
|
use mt;
|
||||||
use services;
|
use services;
|
||||||
|
use phpcommon;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\Season;
|
use models\Season;
|
||||||
use models\Battle;
|
use models\Battle;
|
||||||
@ -60,6 +62,8 @@ class BattleDataService extends BaseService {
|
|||||||
const MATCH_MODE_MATCH = 1;
|
const MATCH_MODE_MATCH = 1;
|
||||||
const MATCH_MODE_PVE = 2;
|
const MATCH_MODE_PVE = 2;
|
||||||
|
|
||||||
|
public $teamList = array();
|
||||||
|
|
||||||
private $seasonDb = array();
|
private $seasonDb = array();
|
||||||
private $heroDto = null;
|
private $heroDto = null;
|
||||||
private $heroMeta = null;
|
private $heroMeta = null;
|
||||||
@ -192,9 +196,12 @@ class BattleDataService extends BaseService {
|
|||||||
$newRank = $user['rank'];
|
$newRank = $user['rank'];
|
||||||
$newScore = $user['score'];
|
$newScore = $user['score'];
|
||||||
$match_mode = getReqVal('match_mode', 0);
|
$match_mode = getReqVal('match_mode', 0);
|
||||||
if (mt\RankSeason::getCurrentSeason() && !$match_mode && myself()->_getV(TN_RANK_STATUS, 0 ) != 1){
|
if (mt\RankSeason::getCurrentSeason() && !$match_mode && myself()->_getV(TN_RANK_STATUS, 0 ) == 0 ){
|
||||||
$newScore = FormulaService::calcBattleAfterRankScore($user,$_REQUEST); //赛后排位积分
|
$winningPro = $this->celWinningPro();
|
||||||
|
if ($winningPro){
|
||||||
|
$newScore = FormulaService::calcBattleAfterRankScore($user,$_REQUEST,$winningPro); //赛后排位积分
|
||||||
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
||||||
|
}
|
||||||
$match_mode = 1;
|
$match_mode = 1;
|
||||||
}
|
}
|
||||||
$data = array(
|
$data = array(
|
||||||
@ -219,10 +226,7 @@ class BattleDataService extends BaseService {
|
|||||||
"pve_instance_id" => getReqVal('pve_instance_id', 0),
|
"pve_instance_id" => getReqVal('pve_instance_id', 0),
|
||||||
"pve_instance_mode" => getReqVal('pve_instance_mode', 0),
|
"pve_instance_mode" => getReqVal('pve_instance_mode', 0),
|
||||||
);
|
);
|
||||||
$res = BattleHistory::add($data);
|
BattleHistory::add($data);
|
||||||
if (! $res){
|
|
||||||
error_log('############## insert Battle History failed #################');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReward()
|
public function getReward()
|
||||||
@ -464,10 +468,11 @@ class BattleDataService extends BaseService {
|
|||||||
{
|
{
|
||||||
$userInfo = myself()->_getOrmUserInfo();
|
$userInfo = myself()->_getOrmUserInfo();
|
||||||
$newRank = $userInfo['rank'];
|
$newRank = $userInfo['rank'];
|
||||||
$newScore = FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST); //赛后排位积分
|
$winningPro = $this->celWinningPro();
|
||||||
$newElo = FormulaService::calcUserEloValue($userInfo,$_REQUEST); //赛后elo积分
|
if ($winningPro){
|
||||||
|
$newScore = FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST,$winningPro); //赛后排位积分
|
||||||
|
$newElo = FormulaService::calcUserEloValue($userInfo,$_REQUEST,$winningPro); //赛后elo积分
|
||||||
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
||||||
|
|
||||||
if ( $newScore != $userInfo['score'] ) {
|
if ( $newScore != $userInfo['score'] ) {
|
||||||
myself()->_updateUserInfo(array(
|
myself()->_updateUserInfo(array(
|
||||||
'rank' => $newRank,
|
'rank' => $newRank,
|
||||||
@ -489,7 +494,73 @@ class BattleDataService extends BaseService {
|
|||||||
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
|
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function celWinningPro(){
|
||||||
|
$team_id = getReqVal('team_id', 0);
|
||||||
|
if (empty($this->teamList) || ! count($this->teamList)){
|
||||||
|
error_log('ELO1-----没获取到所有队伍信息:AllTeamList');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$userInfo = myself()->_getOrmUserInfo();
|
||||||
|
$myAvg = 0;
|
||||||
|
$opponentAvg = 0;
|
||||||
|
$teamIdHash = array();
|
||||||
|
foreach ($this->teamList as &$team){
|
||||||
|
foreach ($team['members'] as $k=>$member){
|
||||||
|
if (!empty($member['account_id'])){
|
||||||
|
$channelId = phpcommon\extractChannel($member['account_id']);
|
||||||
|
if ($channelId == SELFSDK_CHANNEL) {
|
||||||
|
unset($team['members'][$k]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
unset($team['members'][$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$teamIdHash[$team['team_id']] = $team;
|
||||||
|
}
|
||||||
|
$myTeam = array_key_exists($team_id,$teamIdHash)?$teamIdHash[$team_id]:null;
|
||||||
|
unset($teamIdHash[$team_id]);
|
||||||
|
if (!$myTeam){
|
||||||
|
error_log('ELO2-----没获取到我的队伍信息:MyTeamList');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$myTeamEloSum = 0;
|
||||||
|
foreach ($myTeam['members'] as $value){
|
||||||
|
$userDb = User::find($value['account_id']);
|
||||||
|
$myTeamEloSum+=$userDb['elo'];
|
||||||
|
}
|
||||||
|
$myAvg = $myTeamEloSum/count($myTeam['members']);
|
||||||
|
$tempSumList = array();
|
||||||
|
foreach ($teamIdHash as $k=>&$item){
|
||||||
|
if ($team_id != $item['team_id'] && count($item['members'])>0){
|
||||||
|
$tempSum = 0;
|
||||||
|
foreach ($item['members'] as $value){
|
||||||
|
$userDb = User::find($value['account_id']);
|
||||||
|
$tempSum += $userDb['elo'];
|
||||||
|
}
|
||||||
|
array_push($tempSumList,$tempSum/count($item['members']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($tempSumList) > 0){
|
||||||
|
$opponentAvg = array_sum($tempSumList)/count($tempSumList);
|
||||||
|
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
|
||||||
|
$winningPro = 1/(1+pow(10,(-(0.7*($userInfo['elo']-$opponentAvg)+0.3*($myAvg-$opponentAvg))/400)));
|
||||||
|
}else{
|
||||||
|
error_log('ELO3-----无真人敌对队伍');
|
||||||
|
$winningPro = 0.5;
|
||||||
|
}
|
||||||
|
error_log(json_encode(
|
||||||
|
array(
|
||||||
|
'myElo' =>$userInfo['elo'],
|
||||||
|
'myAvg' => $myAvg,
|
||||||
|
'myTeam' =>$myTeam,
|
||||||
|
'opponentAvg'=>$tempSumList,
|
||||||
|
'winningPro' => $winningPro,
|
||||||
|
)
|
||||||
|
));
|
||||||
|
return $winningPro;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rewardGold($heroDto)
|
private function rewardGold($heroDto)
|
||||||
@ -555,7 +626,6 @@ class BattleDataService extends BaseService {
|
|||||||
private function updatePvpData()
|
private function updatePvpData()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
error_log('updateBattleData2');
|
error_log('updateBattleData2');
|
||||||
$hisBattleData = Battle::getMyBattleData();
|
$hisBattleData = Battle::getMyBattleData();
|
||||||
if (!isset($hisBattleData)) {
|
if (!isset($hisBattleData)) {
|
||||||
@ -569,7 +639,7 @@ class BattleDataService extends BaseService {
|
|||||||
|
|
||||||
error_log('updateBattleData3');
|
error_log('updateBattleData3');
|
||||||
$this->currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
$this->currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||||
if ( $this->currSeasonMeta && myself()->_getV(TN_RANK_STATUS, 0 ) != 1) {
|
if ( $this->currSeasonMeta && myself()->_getV(TN_RANK_STATUS, 0 ) == 0) {
|
||||||
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||||
if (!$this->seasonDb) {
|
if (!$this->seasonDb) {
|
||||||
Season::add($this->currSeasonMeta['id']);
|
Season::add($this->currSeasonMeta['id']);
|
||||||
@ -580,7 +650,6 @@ class BattleDataService extends BaseService {
|
|||||||
}
|
}
|
||||||
error_log('updateBattleData4');
|
error_log('updateBattleData4');
|
||||||
$this->updateScore();
|
$this->updateScore();
|
||||||
|
|
||||||
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
||||||
if (!isset($seasonBattleData['today_data'])) {
|
if (!isset($seasonBattleData['today_data'])) {
|
||||||
$seasonBattleData['today_data'] = array(
|
$seasonBattleData['today_data'] = array(
|
||||||
|
@ -321,7 +321,7 @@ class FormulaService extends BaseService {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function calcBattleAfterRankScore($userDb,$params){
|
public static function calcBattleAfterRankScore($userDb,$params,$winningPro){
|
||||||
/**一个玩家的赛后积分 = 赛前积分+K*(胜负率-总胜率)+2K*(表现分-段位要求的及格分)*/
|
/**一个玩家的赛后积分 = 赛前积分+K*(胜负率-总胜率)+2K*(表现分-段位要求的及格分)*/
|
||||||
//胜负率=1-(排名-1)/(最大排名-1)
|
//胜负率=1-(排名-1)/(最大排名-1)
|
||||||
$ranked = getXVal($params, 'ranked');
|
$ranked = getXVal($params, 'ranked');
|
||||||
@ -329,7 +329,7 @@ class FormulaService extends BaseService {
|
|||||||
$maxRanked = $meta1 ? $meta1['param_value'] : 40; //************** parameter 参数表获取 ************
|
$maxRanked = $meta1 ? $meta1['param_value'] : 40; //************** parameter 参数表获取 ************
|
||||||
$winRate = 1-($ranked-1)/($maxRanked-1);
|
$winRate = 1-($ranked-1)/($maxRanked-1);
|
||||||
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
|
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
|
||||||
$winRateSum = 1;
|
$winRateSum = $winningPro;
|
||||||
//表现分=f(全局排名Top X%)*50%+f(PK人数排名Top X%)*30%+f(存活时间排名Top X%)*15%+f(英雄阶数排名Top X%)*3%+f(枪械阶数排名Top X%)*2% --> f(Top X%) = ROUND(1-(X/10-1)/9,2)
|
//表现分=f(全局排名Top X%)*50%+f(PK人数排名Top X%)*30%+f(存活时间排名Top X%)*15%+f(英雄阶数排名Top X%)*3%+f(枪械阶数排名Top X%)*2% --> f(Top X%) = ROUND(1-(X/10-1)/9,2)
|
||||||
$rankedTopX = getXVal($params, 'ranked_topx');
|
$rankedTopX = getXVal($params, 'ranked_topx');
|
||||||
$killsTopX = getXVal($params, 'kills_topx');
|
$killsTopX = getXVal($params, 'kills_topx');
|
||||||
@ -351,7 +351,7 @@ class FormulaService extends BaseService {
|
|||||||
return round($battleAfterScore);
|
return round($battleAfterScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function calcUserEloValue($userDb,$params){
|
public static function calcUserEloValue($userDb,$params,$winningPro){
|
||||||
/**一个玩家的赛后ELO值 = MAX(赛前ELO值+K*(胜负率-总胜率),150)*/
|
/**一个玩家的赛后ELO值 = MAX(赛前ELO值+K*(胜负率-总胜率),150)*/
|
||||||
//胜负率=1-(排名-1)/(最大排名-1)
|
//胜负率=1-(排名-1)/(最大排名-1)
|
||||||
$ranked = getXVal($params, 'ranked');
|
$ranked = getXVal($params, 'ranked');
|
||||||
@ -359,7 +359,7 @@ class FormulaService extends BaseService {
|
|||||||
$maxRanked = $meta1 ? $meta1['param_value'] : 40; //************** parameter 参数表获取 ************
|
$maxRanked = $meta1 ? $meta1['param_value'] : 40; //************** parameter 参数表获取 ************
|
||||||
$winRate = 1-($ranked-1)/($maxRanked-1);
|
$winRate = 1-($ranked-1)/($maxRanked-1);
|
||||||
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
|
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
|
||||||
$winRateSum = 1;
|
$winRateSum = $winningPro;
|
||||||
$meta2 = mt\Parameter::getByName('rank_k');
|
$meta2 = mt\Parameter::getByName('rank_k');
|
||||||
$K = $meta2 ? $meta2['param_value'] : 30; //************** parameter 参数表获取 ************
|
$K = $meta2 ? $meta2['param_value'] : 30; //************** parameter 参数表获取 ************
|
||||||
return round(max($userDb['elo']+$K*($winRate-$winRateSum),150));
|
return round(max($userDb['elo']+$K*($winRate-$winRateSum),150));
|
||||||
|
@ -593,9 +593,11 @@ class MissionService extends BaseService {
|
|||||||
}
|
}
|
||||||
$metas = mt\Task::getOfferRewardMissions
|
$metas = mt\Task::getOfferRewardMissions
|
||||||
($this->offerRewartdMission['missions']);
|
($this->offerRewartdMission['missions']);
|
||||||
|
error_log(json_encode($metas));
|
||||||
if (count($metas)<1) {
|
if (count($metas)<1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
error_log(json_encode('Mission Number ___'.count($metas)));
|
||||||
$count = count($metas)>=5 ? 5 : count($metas);
|
$count = count($metas)>=5 ? 5 : count($metas);
|
||||||
foreach (array_rand($metas, $count) as $key) {
|
foreach (array_rand($metas, $count) as $key) {
|
||||||
$meta = $metas[$key];
|
$meta = $metas[$key];
|
||||||
|
@ -50,7 +50,7 @@ class RankActivityService extends BaseService {
|
|||||||
error_log(
|
error_log(
|
||||||
json_encode(array(
|
json_encode(array(
|
||||||
'account_id' => $userDb['account_id'],
|
'account_id' => $userDb['account_id'],
|
||||||
'themeType' => $currentRankingMeta['themeType'],
|
'themeType' => $currentRankingMeta?$currentRankingMeta['themeType']:null,
|
||||||
'kill' => getReqVal('kills', 0),
|
'kill' => getReqVal('kills', 0),
|
||||||
'ranked' => getReqVal('ranked', 0),
|
'ranked' => getReqVal('ranked', 0),
|
||||||
'ceg'=>$gold
|
'ceg'=>$gold
|
||||||
|
Loading…
x
Reference in New Issue
Block a user