排位赛

This commit is contained in:
hujiabin 2022-10-13 15:52:13 +08:00
parent d023956d7e
commit bea29548e7
15 changed files with 392 additions and 67 deletions

View File

@ -90,6 +90,7 @@ class Battle(object):
'response': [
_common.RspHead(),
['reward', _common.BattleReward(), '武器2奖励'],
['rank_score', _common.BattleRankScore(), '排位分信息'],
]
},
{

View File

@ -30,6 +30,42 @@ class Season(object):
_common.RspHead(),
['info', _common.Season(), '赛季信息'],
]
},{
'name': 'getRankingInfo',
'desc': '获取赛季排行信息',
'group': 'Season',
'url': 'webapp/index.php?c=Season&a=getRankingInfo',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['info', _common.SeasonRank(), '赛季排行信息'],
]
},{
'name': 'getDataInfo',
'desc': '获取赛季基本信息',
'group': 'Season',
'url': 'webapp/index.php?c=Season&a=getDataInfo',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['info', _common.SeasonData(), '赛季基本信息'],
]
},{
'name': 'getHeroInfo',
'desc': '获取赛季基本信息',
'group': 'Season',
'url': 'webapp/index.php?c=Season&a=getHeroInfo',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['!info', [_common.SeasonHero()], '赛季使用英雄信息'],
]
},
{
'name': 'getMissionReward',

View File

@ -478,6 +478,32 @@ class SeasonRank(object):
['rank_sort', 0, '赛季序列排行'],
]
class SeasonData(object):
def __init__(self):
self.fields = [
['season_id', 0, '赛季id'],
['game_times', 0, '排位总场次'],
['win_times', 0, '吃鸡场次'],
['top_ten_times', 0, '挤进前十场次'],
['kill_killed', 0, '淘汰/被淘汰'],
]
class SeasonHero(object):
def __init__(self):
self.fields = [
['season_id', 0, '赛季id'],
['hero', 0, '英雄 id'],
['weapon', 0, '枪械id 例id 或 id1|id2 '],
['use_times', 0, '使用总场次'],
['win_times', 0, '吃鸡常常'],
['top_ten_times', 0, '前十场次'],
['win_rate', 0, '获胜率'],
['top_ten_rate', 0, '前十率'],
]
class RankingItem(object):
def __init__(self):
@ -852,6 +878,16 @@ class BattleReward(object):
['!items', [BattleItemReward()], '碎片奖励'],
]
class BattleRankScore(object):
def __init__(self):
self.fields = [
['old_rank', 0, '战斗前段位'],
['old_score', 0, '战斗前排位分'],
['new_rank', 0, '战斗后段位'],
['new_score', 0, '战斗后排位分'],
]
class BattleHistory(object):
def __init__(self):

View File

@ -40,6 +40,7 @@ CREATE TABLE `t_user` (
`history_best_rank` int(11) NOT NULL DEFAULT '0' COMMENT '历史最高段位',
`score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
`history_best_score` int(11) NOT NULL DEFAULT '0' COMMENT '历史最高积分',
`elo` int(11) NOT NULL DEFAULT '0' COMMENT '隐藏ELO积分',
`gold` double NOT NULL DEFAULT '0' COMMENT '金币',
`diamond` double NOT NULL DEFAULT '0' COMMENT '钻石',
`hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '当前上阵英雄id',
@ -457,6 +458,7 @@ CREATE TABLE `t_season` (
`card_exp` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册经验',
`rank` int(11) NOT NULL DEFAULT '0' COMMENT '段位',
`score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
`elo` int(11) NOT NULL DEFAULT '0' COMMENT '隐藏ELO积分',
`history_best_rank` int(11) NOT NULL DEFAULT '0' COMMENT '历史最高段位',
`gift_state1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买状态 0:未购 1:已购',
`gift_buytime1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买时间',

View File

@ -35,6 +35,7 @@ define('TN_DAILY_PVE_GET_FRAGMENT_NUM', 9007);
define('TN_DAILY_PVP_BATTLE_TIMES', 9008);
define('TN_DAILY_PVP_GET_FRAGMENT_NUM', 9009);
define('TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE', 9010);
define('TN_DAILY_RANK_BATTLE_TIMES', 9011);
define('TN_DAILY_END', 9009);
define('TN_WEEKLY_BEGIN', 10001);

View File

@ -5,6 +5,7 @@ require_once('models/Gun.php');
require_once('models/Chip.php');
require_once('models/BattleHistory.php');
require_once('services/BattleDataService.php');
require_once('services/FormulaService.php');
use phpcommon\SqlHelper;
use models\Hero;
@ -40,9 +41,22 @@ class BattleController extends BaseAuthedController {
)
);
error_log(json_encode($battleDataService->getReward()));
$this->_rspData(array(
$data = array(
'reward' => $battleDataService->getReward()
));
);
if (getReqVal('match_mode', 0) == services\BattleDataService::MATCH_MODE_MATCH){
$newRank = $userInfo['rank'];
$newScore = \services\FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST);
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
$scoreInfo = array(
'old_rank' => $userInfo['rank'],
'old_score' => $userInfo['score'],
'new_rank' => $newRank,
'new_score' => $newScore,
);
$data['score_info'] = $scoreInfo;
}
$this->_rspData($data);
}
public function getBattleData()

View File

@ -573,7 +573,8 @@ class ChipController extends BaseAuthedController
// }
// $this->_rspOk();
$this->chipDetails();
// $this->chipDetails();
// $arr = [30900=>2,31000=>6,31100=>4];
}

View File

@ -78,6 +78,8 @@ class SeasonController extends BaseAuthedController {
public function infoNew()
{
$this->getHeroInfo();
die;
$rankMeta = mt\Rank::getRankById($this->userInfo['rank']);
$nextRankMeta = mt\Rank::getNextRankById($this->userInfo['rank']);
if (!$nextRankMeta){
@ -93,7 +95,6 @@ class SeasonController extends BaseAuthedController {
'season_reward' => Season::seasonReward($rankMeta)
);
// $rank_param = getReqVal('rank',$this->userInfo['rank']);
$users = User::orderBy(User::getUserByRank($this->userInfo['rank']));
$season_rank = array();
if (count($users)>0){
@ -130,6 +131,84 @@ class SeasonController extends BaseAuthedController {
$this->_rspData(['info'=>$season_rank]);
}
public function getDataInfo(){
$seasonDb = Season::find($this->currRankSeasonMeta['id']);
$currRankSeasonHistory = array();
if ($seasonDb){
$battleData = json_decode($seasonDb['battle_data'], true);
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array();
$gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
$winTimes = getXVal($seasonBattleData, 'total_win_times', 0);
$topTenTimes = getXVal($seasonBattleData, 'total_top_ten_times', 0);
$totalKills = getXVal($seasonBattleData, 'total_kills_times', 0);
array_push($currRankSeasonHistory,
array(
'season_id' => $seasonDb['season_id'],
// 'total_kills' => $totalKills,
'game_times' => $gameTimes,
'win_times' => $winTimes,
'top_ten_times' => $topTenTimes,
'kill_killed' => round($totalKills/($gameTimes-$winTimes),2),
));
}
if (!$currRankSeasonHistory){
array_push($currRankSeasonHistory,
array(
'season_id' => $this->currRankSeasonMeta['id'],
// 'total_kills' => $totalKills,
'game_times' => 0,
'win_times' => 0,
'top_ten_times' => 0,
'kill_killed' => 0,
));
}
$this->_rspData(['info'=>$currRankSeasonHistory]);
}
public function getHeroInfo(){
$seasonDb = Season::find($this->currRankSeasonMeta['id']);
$currHeroSeasonHistory = array();
if ($seasonDb) {
$battleData = json_decode($seasonDb['battle_data'], true);
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array();
$seasonHeroInfo = isset($seasonBattleData) ? getXVal($seasonBattleData, 'hero_info', array()) : array();
$heroSort = array();
foreach ($seasonHeroInfo as $key=>$heroInfo){
$heroSort[$key]['use_times'] = isset($heroInfo['use_times']) ? $heroInfo['use_times'] : 0;
$heroSort[$key]['weapon'] = isset($heroInfo['weapon']) ? $heroInfo['weapon'] : array();
$heroSort[$key]['win_times'] = isset($heroInfo['win_times']) ? $heroInfo['win_times'] : 0;
$heroSort[$key]['top_ten_times'] = isset($heroInfo['top_ten_times']) ? $heroInfo['top_ten_times'] : 0;
$heroSort[$key]['hero'] = $key;
arsort($heroSort[$key]['weapon']);
$heroSort[$key]['weapon'] = array_keys($heroSort[$key]['weapon']);
$heroSort[$key]['weapon'] = implode('|',array_slice($heroSort[$key]['weapon'],0,2));
}
arsort($heroSort);
$heroSort = array_slice($heroSort,0,3);
foreach ($heroSort as &$value){
$value['season_id'] = $seasonDb['season_id'];
$value['win_rate'] = round($value['win_times']/$value['use_times'],2);
$value['top_ten_rate'] = round($value['top_ten_times']/$value['use_times'],2);
}
$currHeroSeasonHistory = $heroSort;
}
// if (!$currHeroSeasonHistory){
// array_push($currHeroSeasonHistory,
// array(
// 'season_id' => $this->currRankSeasonMeta['id'],
// 'use_times' => 0,
// 'weapon' => 0,
// 'win_times' => 0,
// 'top_ten_times' => 0,
// 'hero_id' => 0,
// 'win_rate' => 0,
// 'top_ten_rate' => 0,
// ));
// }
$this->_rspData(['info'=>$currHeroSeasonHistory]);
}
public function getMissionReward()
{
$mission = $this->getMissionInfo();

View File

@ -25,6 +25,7 @@ use models\Nft;
class UserController extends BaseAuthedController {
private $init_rank = 'rank_init_rank';
private $init_elo = 'rank_init_elo';
public function login()
{
@ -561,11 +562,13 @@ class UserController extends BaseAuthedController {
public function initRank(){
$initRankParameterMeta = mt\Parameter::getByName($this->init_rank);
$initRankMeta = mt\Rank::getRankById($initRankParameterMeta['param_value']);
$initEloParameterMeta = mt\Parameter::getByName($this->init_elo);
$fields = array(
'rank' => $initRankMeta ? $initRankMeta['id'] : 1,
'history_best_rank' => $initRankMeta ? $initRankMeta['id'] : 1,
'score' => $initRankMeta ? $initRankMeta['rank_score'] : 0,
'history_best_score' => $initRankMeta ? $initRankMeta['rank_score'] : 0,
'elo' => $initEloParameterMeta ? $initEloParameterMeta['param_value'] : 0,
);
User::update($fields);
$this->_rspOk();

View File

@ -14,7 +14,7 @@ class BattleHistory extends BaseModel
{
public static function add($data)
{
SqlHelper::insert
return SqlHelper::insert
(myself()->_getSelfMysql(),
't_battle_history',
$data

View File

@ -35,24 +35,43 @@ class Rank {
return self::get(1);
}
public static function calcNewRankAndScore($oldRank, $oldScore, &$newRank, &$newScore, $addScore)
public static function calcNewRankAndScore( &$newRank, &$newScore)
{
$currRankMeta = self::get($oldRank);
if ($currRankMeta && $currRankMeta['max_score'] > 0) {
$newScore = min($oldScore, $currRankMeta['max_score']) + $addScore;
do {
if ($newScore > $currRankMeta['max_score']) {
++$newRank;
$currRankMeta = self::get($newRank);
if ($currRankMeta['max_score'] < 0) {
$newScore = $currRankMeta['min_score'];
break;
}
} else {
break;
$meta = self::getMetaListNew();
for ($i=1;$i<=count($meta);$i++){
if ($i==1){
$newScore = max($newScore,$meta[$i]['rank_score']);
}
if ($i == count($meta)){
$newScore = min($newScore,$meta[$i]['rank_score']);
}
if ($meta[$i+1]){
if($newScore>=$meta[$i]['rank_score'] && $newScore<$meta[$i+1]['rank_score']){
$newRank = $meta[$i]['id'];
}
} while ($currRankMeta);
}else{
if($newScore>=$meta[$i]['rank_score']){
$newRank = $meta[$i]['id'];
}
}
}
// $currRankMeta = self::get($oldRank);
// if ($currRankMeta && $currRankMeta['max_score'] > 0) {
// $newScore = min($oldScore, $currRankMeta['max_score']) + $addScore;
// do {
// if ($newScore > $currRankMeta['max_score']) {
// ++$newRank;
// $currRankMeta = self::get($newRank);
// if ($currRankMeta['max_score'] < 0) {
// $newScore = $currRankMeta['min_score'];
// break;
// }
// } else {
// break;
// }
// } while ($currRankMeta);
// }
}
protected static function getMetaList()
@ -66,7 +85,7 @@ class Rank {
protected static function getMetaListNew()
{
if (!self::$metaListNew) {
self::$metaListNew = getMetaTable('pveGeminiMode@rankRank.php');
self::$metaListNew = getMetaTable('rankRank@rankRank.php');
}
return self::$metaListNew;
}

View File

@ -14,7 +14,7 @@ class RankSeason
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('pveGeminiMode@rankSeason.php');
self::$metaList = getMetaTable('rankSeason@rankSeason.php');
}
return self::$metaList;
}
@ -30,5 +30,6 @@ class RankSeason
return null;
}
protected static $metaList;
}

View File

@ -14,6 +14,7 @@ require_once('mt/HeroQuality.php');
require_once('mt/AttrHelper.php');
require_once('mt/PveGemini.php');
require_once('mt/PveGeminiMode.php');
require_once('mt/RankSeason.php');
require_once('models/Season.php');
require_once('models/Battle.php');
@ -58,6 +59,7 @@ class BattleDataService extends BaseService {
private $heroMeta = null;
private $weapon1Dto = null;
private $weapon2Dto = null;
private $currSeasonMeta = null;
private $reward = array(
'hero' => array(
@ -137,7 +139,7 @@ class BattleDataService extends BaseService {
}
}
//录入战斗记录
$this->saveBattleHistory();
// $this->saveBattleHistory();
switch ($matchMode) {
case self::MATCH_MODE_PVP:
@ -152,6 +154,16 @@ class BattleDataService extends BaseService {
case self::MATCH_MODE_MATCH:
{
//排位赛
$this->updateSeasonData();
myself()->_incDailyV(TN_DAILY_RANK_BATTLE_TIMES, 0, 1);
/*$userInfo = myself()->_getOrmUserInfo();
$newScore = FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST);
$newRank = $userInfo['rank'];
$newScore = 789;
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
print_r($newRank.':'.$newScore);die;*/
}
break;
case self::MATCH_MODE_PVE:
@ -197,7 +209,10 @@ class BattleDataService extends BaseService {
"pve_instance_id" => getReqVal('pve_instance_id', 0),
"pve_instance_mode" => getReqVal('pve_instance_mode', 0),
);
BattleHistory::add($data);
$res = BattleHistory::add($data);
if (! $res){
error_log('############## insert Battle History failed #################');
}
}
public function getReward()
@ -207,51 +222,82 @@ class BattleDataService extends BaseService {
private function apply(&$battleData)
{
//战斗次数
$this->incValue($battleData, 'total_battle_times', 1);
if (getReqVal('team_mode', 0) == 0) {
//单人模式战斗次数
$this->incValue($battleData, 'total_single_battle_times', 1);
//单人模式最高排名
$this->minValue($battleData, 'single_battle_rank', getReqVal('ranked', 0));
} else {
//组队模式战斗次数
$this->minValue($battleData, 'team_battle_rank', getReqVal('ranked', 0));
//组队模式最高排名
$this->incValue($battleData, 'total_team_battle_times', 1);
}
if (getReqVal('ranked', 0) == 1) {
$ranked = getReqVal('ranked', 0);
if ($ranked == 1) {
//吃鸡次数
$this->incValue($battleData, 'total_win_times', 1);
}
if ($ranked <= 10){
//排名前十 总次数
$this->incValue($battleData, 'total_top_ten_times', 1);
}
$kills = getReqVal('kills', 0);
if ($kills > 0) {
//击杀总次数
$this->incValue($battleData, 'total_kills_times', $kills);
//单局最大击杀数
$this->maxValue($battleData, 'max_kills_times', $kills);
}
$damageOut = getReqVal('damage_out', 0);
if ($damageOut > 0) {
//伤害输出总量
$this->incValue($battleData, 'total_damage_out', $damageOut);
//单局最大伤害输出
$this->maxValue($battleData, 'max_damage_out', $damageOut);
}
$damageIn = getReqVal('damage_in', 0);
if ($damageIn > 0) {
//受到伤害总量
$this->incValue($battleData, 'total_damage_in', $damageIn);
//单局最大受到伤害量
$this->maxValue($battleData, 'max_damage_in', $damageIn);
}
$recoverHp = getReqVal('recover_hp', 0);
if ($recoverHp > 0) {
//自疗总量
$this->incValue($battleData, 'total_recover_hp', $recoverHp);
//单局最大自疗量
$this->maxValue($battleData, 'max_recover_hp', $recoverHp);
}
$aliveTime = getReqVal('alive_time', 0);
if ($aliveTime > 0) {
//总存活时间
$this->incValue($battleData, 'total_alive_time', $aliveTime);
//单局最大存活时间
$this->maxValue($battleData, 'max_alive_time', $aliveTime);
}
//救援次数
$this->incValue($battleData, 'rescue_teammate_times', getReqVal('rescue_teammate_times', 0));
//潜水次数
$this->incValue($battleData, 'diving_times', getReqVal('diving_times', 0));
//开启空投次数
$this->incValue($battleData, 'open_airdrop_times', getReqVal('open_airdrop_times', 0));
//使用药品次数
$this->incValue($battleData, 'use_medicine_times', getReqVal('use_medicine_times', 0));
//击毁机甲次数
$this->incValue($battleData, 'destory_car_times', getReqVal('destory_car_times', 0));
//使用伪装次数
$this->incValue($battleData, 'use_camouflage_times', getReqVal('use_camouflage_times', 0));
//使用技能次数
$this->incValue($battleData, 'use_skill_times', getReqVal('use_skill_times', 0));
//驾驶机甲移动距离
$this->incValue($battleData, 'ride_car_move_distance', getReqVal('ride_car_move_distance', 0));
//驾驶机甲击杀数
$this->incValue($battleData, 'ride_car_kills', getReqVal('ride_car_kills', 0));
//使用的英雄最高等级
$this->maxValue($battleData, 'max_single_battle_hero_lv', getReqVal('max_single_battle_hero_lv', 0));
$this->procWeaponsEquip($battleData);
$this->procWeaponsSlot($battleData);
@ -267,6 +313,7 @@ class BattleDataService extends BaseService {
if (!isset($battleData['weapons_type_data'])) {
$battleData['weapons_type_data'] = array();
}
//武器类型数据
$weaponsTypeDb = &$battleData['weapons_type_data'];
{
$tmpStrs1 = explode('|', getReqVal('weapons_type', ''));
@ -280,8 +327,11 @@ class BattleDataService extends BaseService {
if (!isset($weaponsTypeDb[$key])) {
$weaponsTypeDb[$key] = array();
}
//使用此种类型武器击杀数
$this->incValue($weaponsTypeDb, 'kills', $kills);
$this->incValue($weaponsTypeDb, 'damage_out', $damage_out);
//使用此种武器伤害输出
$this->incValue($weaponsTypeDb, 'damage_out', $damageOut);
//战斗中获得此种武器数量
$this->incValue($weaponsTypeDb, 'obtain_count', $obtainCount);
}
}
@ -294,6 +344,7 @@ class BattleDataService extends BaseService {
if (!isset($battleData['weapons_slot_data'])) {
$battleData['weapons_slot_data'] = array();
}
//武器槽位数据
$weaponsSlotDb = &$battleData['weapons_slot_data'];
{
$tmpStrs1 = explode('|', getReqVal('weapons_slot', ''));
@ -307,7 +358,8 @@ class BattleDataService extends BaseService {
if (!isset($weaponsSlotDb[$key])) {
$weaponsSlotDb[$key] = array();
}
$this->incValue($weaponsSlotDb, 'use_times', $kills);
//使用次数
$this->incValue($weaponsSlotDb, 'use_times', $use_times);
}
}
}
@ -319,6 +371,7 @@ class BattleDataService extends BaseService {
if (!isset($battleData['hero_data'])) {
$battleData['hero_data'] = array();
}
//英雄数据
$heroDb = &$battleData['hero_data'];
{
$tmpStrs1 = explode('|', getReqVal('heros', ''));
@ -332,12 +385,52 @@ class BattleDataService extends BaseService {
if (!isset($heroDb[$key])) {
$heroDb[$key] = array();
}
//最大技能等级
$this->maxValue($heroDb, 'skill_lv', $skillLv);
//最大武器等级
$this->maxValue($heroDb, 'weapon_lv', $weaponLv);
}
}
}
}
//统计使用的英雄及枪械的信息
if (!isset($battleData['hero_info'])) {
$battleData['hero_info'] = array();
}
$heroInfo = &$battleData['hero_info'];
{
$hero_uniid = getReqVal('hero_uniid', '');
$hero = Hero::find($hero_uniid);
if ($hero){
if (!isset($heroInfo[$hero['hero_id']])){
$heroInfo[$hero['hero_id']] = array();
}
$this->incValue($heroInfo[$hero['hero_id']], "use_times", 1); //每个英雄使用次数
$ranked = getReqVal('ranked', 0);
if ($ranked == 1) {
//吃鸡次数
$this->incValue($heroInfo[$hero['hero_id']], 'win_times', 1);//使用该英雄吃鸡获胜次数
}
if ($ranked <= 10){
//排名前十 总次数
$this->incValue($heroInfo[$hero['hero_id']], 'top_ten_times', 1);//使用该英雄进前十次数
}
if (!$heroInfo[$hero['hero_id']]['weapon']){
$heroInfo[$hero['hero_id']]['weapon'] = array();
}
$weapon_uuid1 = getReqVal('weapon_uuid1', '');
$weapon1 = Gun::find($weapon_uuid1);
if ($weapon1){
$this->incValue($heroInfo[$hero['hero_id']]['weapon'], $weapon1['gun_id'], 1);//该英雄下选用每个武器的次数
}
$weapon_uuid2 = getReqVal('weapon_uuid2', '');
$weapon2 = Gun::find($weapon_uuid2);
if ($weapon2){
$this->incValue($heroInfo[$hero['hero_id']]['weapon'], $weapon2['gun_id'], 1);//该英雄下选用每个武器的次数
}
}
}
}
private function incValue(&$battleData, $key, $val)
@ -359,35 +452,33 @@ class BattleDataService extends BaseService {
private function updateScore()
{
if (getReqVal('room_mode', 0) == 0) {
$userInfo = myself()->_getOrmUserInfo();
$rankScore = getReqVal('rank_score', 0);
if ($rankScore > 0) {
$newRank = $userInfo['rank'];
$newScore = $userInfo['score'];
mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore);
if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) {
myself()->_updateUserInfo(array(
'rank' => $newRank,
'score' => $newScore,
'history_best_rank' => max($userInfo['rank'], $newRank),
'history_best_score' => max($userInfo['score'], $newScore),
'score_modifytime' => myself()->_getNowTime(),
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
));
Season::update($this->currSeasonMeta['id'], array(
'rank' => $newRank,
'score' => $newScore,
'history_best_rank' => max($userInfo['rank'], $newRank),
'score_modifytime' => myself()->_getNowTime(),
'score_modifytime' => myself()->_getNowTime(),
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
));
}
$newRank = $userInfo['rank'];
$newScore = FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST); //赛后排位积分
$newElo = FormulaService::calcUserEloValue($userInfo,$_REQUEST); //赛后elo积分
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
if ( $newScore != $userInfo['score'] ) {
myself()->_updateUserInfo(array(
'rank' => $newRank,
'score' => $newScore,
'elo' => $newElo,
'history_best_rank' => max($userInfo['rank'], $newRank),
'history_best_score' => max($userInfo['score'], $newScore),
'score_modifytime' => myself()->_getNowTime(),
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
));
Season::update($this->currSeasonMeta['id'], array(
'rank' => $newRank,
'score' => $newScore,
'elo' => $newElo,
'history_best_rank' => max($userInfo['rank'], $newRank),
'score_modifytime' => myself()->_getNowTime(),
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
));
}
}
}
private function rewardGold($heroDto)
@ -452,10 +543,11 @@ class BattleDataService extends BaseService {
private function updateSeasonData()
{
error_log('updateBattleData1');
$this->rankActivityService->updateBattleData();
error_log('updateBattleData2');
$this->currSeasonMeta = mt\Season::getCurrentSeason();
$this->currSeasonMeta = mt\RankSeason::getCurrentSeason();
if (!$this->currSeasonMeta) {
return;
}

View File

@ -316,6 +316,46 @@ class FormulaService extends BaseService {
return 0;
}
public static function calcBattleAfterRankScore($userDb,$params){
/**一个玩家的赛后积分 = 赛前积分+K*(胜负率-总胜率)+2K*(表现分-段位要求的及格分)*/
//胜负率=1-(排名-1)/(最大排名-1)
$ranked = getXVal($params, 'ranked');
$maxRanked = mt\Parameter::getByName('rank_order_max')['param_value']; //************** parameter 参数表获取 ************
$winRate = 1-($ranked-1)/($maxRanked-1);
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
$winRateSum = 1;
//表现分=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');
$killsTopX = getXVal($params, 'kills_topx');
$heroTopX = getXVal($params, 'hero_topx');
$weaponTopX = getXVal($params, 'weapon_topx');
$survivalTopX = getXVal($params, 'survival_topx');
$expreScore = ROUND(1-($rankedTopX/10-1)/9,2) * 0.5 +
ROUND(1-($killsTopX/10-1)/9,2) * 0.3 +
ROUND(1-($survivalTopX/10-1)/9,2) * 0.15 +
ROUND(1-($heroTopX/10-1)/9,2) * 0.03 +
ROUND(1-($weaponTopX/10-1)/9,2) * 0.02;
//不同段位的及格分 = ROUND(1-(大段位排名-1)/(MAX(10)-1),2)
$topRanking = mt\Rank::getRankById($userDb['rank'])['rank_order']; //************** rankRank 参数表获取 ************
$askedScore = round(1-($topRanking-1)/(10-1),2);
//一个玩家的赛后积分 = 赛前积分+K*(胜负率-总胜率)+2K*(表现分-段位要求的及格分)
$K = mt\Parameter::getByName('rank_k')['param_value']; //************** parameter 参数表获取 ************
$battleAfterScore = $userDb['score'] + $K * ($winRate-$winRateSum) + (2*$K) * ($expreScore-$askedScore);
return round($battleAfterScore);
}
public static function calcUserEloValue($userDb,$params){
/**一个玩家的赛后ELO值 = MAX(赛前ELO值+K*(胜负率-总胜率),150)*/
//胜负率=1-(排名-1)/(最大排名-1)
$ranked = getXVal($params, 'ranked');
$maxRanked = mt\Parameter::getByName('rank_order_max')['param_value']; //************** parameter 参数表获取 ************
$winRate = 1-($ranked-1)/($maxRanked-1);
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
$winRateSum = 1;
$K = mt\Parameter::getByName('rank_k')['param_value']; //************** parameter 参数表获取 ************
return round(max($userDb['elo']+$K*($winRate-$winRateSum),150));
}
/**
-------------------------------------------------新公式-----------------------------------------------------------
*/
@ -390,7 +430,7 @@ class FormulaService extends BaseService {
//CEG动态价格
public static function CEG_Dynamic_Price(){
return 1;
return 0.1;
}
//CEG调整系数
@ -419,7 +459,7 @@ class FormulaService extends BaseService {
//CEC动态价格
public static function CEC_Dynamic_Price(){
return 1;
return 0.5;
}
//CEC调整系数
@ -458,7 +498,7 @@ class FormulaService extends BaseService {
//英雄芯片劳力值
public static function Hero_Chip_Labor_Value(){
return 3;
return 1;
}
//武器芯片劳力值

View File

@ -869,15 +869,15 @@ class MissionService extends BaseService {
'item_num' => $boost_ceg
)
));
$dropMeta = mt\Drop::get($missionMeta['reward']);
if (!$dropMeta) {
myself()->_rspErr(10, 'server internal error:' . $missionMeta['reward']);
return;
}
myself()->_scatterDrop('mission:' . $missionId,
$dropMeta,
$awardService,
$propertyChgService);
// $dropMeta = mt\Drop::get($missionMeta['reward']);
// if (!$dropMeta) {
// myself()->_rspErr(10, 'server internal error:' . $missionMeta['reward']);
// return;
// }
// myself()->_scatterDrop('mission:' . $missionId,
// $dropMeta,
// $awardService,
// $propertyChgService);
$this->receiveOfferRewardMission($missionId,
$awardService,
$propertyChgService);