1
This commit is contained in:
parent
8273a15e87
commit
cb315c1b0c
@ -30,7 +30,9 @@ define('TN_DAILY_ACTIVE', 9002);
|
|||||||
define('TN_DAILY_SHOP', 9003);
|
define('TN_DAILY_SHOP', 9003);
|
||||||
define('TN_DAILY_RECHARGE_UPGRADE_TIMES', 9004);
|
define('TN_DAILY_RECHARGE_UPGRADE_TIMES', 9004);
|
||||||
define('TN_DAILY_SHARE_GAMES', 9005);
|
define('TN_DAILY_SHARE_GAMES', 9005);
|
||||||
define('TN_DAILY_END', 9005);
|
define('TN_DAILY_PVE_BATTLE_TIMES', 9006);
|
||||||
|
define('TN_DAILY_PVE_GET_FRAGMENT_NUM', 9007);
|
||||||
|
define('TN_DAILY_END', 9007);
|
||||||
|
|
||||||
define('TN_WEEKLY_BEGIN', 10001);
|
define('TN_WEEKLY_BEGIN', 10001);
|
||||||
define('TN_WEEKLY_ACTIVE', 10002);
|
define('TN_WEEKLY_ACTIVE', 10002);
|
||||||
|
@ -43,58 +43,6 @@ class BattleController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function battleReportNew()
|
public function battleReportNew()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
$battleReward = array(
|
|
||||||
'hero' => array(),
|
|
||||||
'weapon1' => array(),
|
|
||||||
'weapon2' => array(),
|
|
||||||
'items' => array()
|
|
||||||
);
|
|
||||||
$onlineNum = 0;
|
|
||||||
{
|
|
||||||
//pve
|
|
||||||
$instanceLevel = 0;
|
|
||||||
$heroQuality = 0;
|
|
||||||
$instanceRank = 0;
|
|
||||||
$bossReward = 0;
|
|
||||||
$todayPveBattleTimes = 0;
|
|
||||||
$todayPveGetFragmentNum = 0;
|
|
||||||
$heroFragment = array(
|
|
||||||
0 => array(
|
|
||||||
1001 => 10 + 1, //当前时间段 + 上一时间段剩余
|
|
||||||
1002 => 10 + 1, //当前时间段 + 上一时间段剩余
|
|
||||||
9999 => 3 + 1, //当前时间段 + 上一时间段剩余, 特殊碎片,指定合成
|
|
||||||
),
|
|
||||||
1 => array(
|
|
||||||
),
|
|
||||||
);
|
|
||||||
$gunFragment = array(
|
|
||||||
0 => array(
|
|
||||||
2001 => 10 + 1, //当前时间段 + 上一时间段剩余
|
|
||||||
2002 => 10 + 1, //当前时间段 + 上一时间段剩余
|
|
||||||
9998 => 3 + 1, //当前时间段 + 上一时间段剩余, 特殊碎片,指定合成
|
|
||||||
),
|
|
||||||
1 => array(
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0);
|
|
||||||
$dropMul = 0.8 - ($instancRank - 1) * 0.25 + $bossReward * 0.2;
|
|
||||||
|
|
||||||
$instackRankRate = 0.8; //0.8 0.55 0.3;
|
|
||||||
|
|
||||||
$heroProbability = min($heroFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1);
|
|
||||||
$gunProbability = min($gunFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1);
|
|
||||||
$emptyProbability = max(1 - $heroProbability - $gunProbability, 0);
|
|
||||||
//对3者取权重
|
|
||||||
//对堕落的碎片做随机
|
|
||||||
}
|
|
||||||
{
|
|
||||||
//pvp
|
|
||||||
}
|
|
||||||
$this->_rspData($battleReward);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattleData()
|
public function getBattleData()
|
||||||
|
@ -71,7 +71,7 @@ class Hero {
|
|||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
self::$metaList = getMetaTable('player@player.php');
|
self::$metaList = getMetaTable('hero@hero.php');
|
||||||
}
|
}
|
||||||
return self::$metaList;
|
return self::$metaList;
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,57 @@ use models\Hero;
|
|||||||
use models\Gun;
|
use models\Gun;
|
||||||
use services\FormulaService;
|
use services\FormulaService;
|
||||||
|
|
||||||
|
/*
|
||||||
|
$onlineNum = 0;
|
||||||
|
{
|
||||||
|
//pve
|
||||||
|
$instanceLevel = 0;
|
||||||
|
$heroQuality = 0;
|
||||||
|
$instanceRank = 0;
|
||||||
|
$bossReward = 0;
|
||||||
|
$todayPveBattleTimes = 0;
|
||||||
|
$todayPveGetFragmentNum = 0;
|
||||||
|
$heroFragment = array(
|
||||||
|
0 => array(
|
||||||
|
1001 => 10 + 1, //当前时间段 + 上一时间段剩余
|
||||||
|
1002 => 10 + 1, //当前时间段 + 上一时间段剩余
|
||||||
|
9999 => 3 + 1, //当前时间段 + 上一时间段剩余, 特殊碎片,指定合成
|
||||||
|
),
|
||||||
|
1 => array(
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$gunFragment = array(
|
||||||
|
0 => array(
|
||||||
|
2001 => 10 + 1, //当前时间段 + 上一时间段剩余
|
||||||
|
2002 => 10 + 1, //当前时间段 + 上一时间段剩余
|
||||||
|
9998 => 3 + 1, //当前时间段 + 上一时间段剩余, 特殊碎片,指定合成
|
||||||
|
),
|
||||||
|
1 => array(
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0);
|
||||||
|
$dropMul = 0.8 - ($instancRank - 1) * 0.25 + $bossReward * 0.2;
|
||||||
|
|
||||||
|
$instackRankRate = 0.8; //0.8 0.55 0.3;
|
||||||
|
|
||||||
|
$heroProbability = min($heroFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1);
|
||||||
|
$gunProbability = min($gunFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1);
|
||||||
|
$emptyProbability = max(1 - $heroProbability - $gunProbability, 0);
|
||||||
|
//对3者取权重
|
||||||
|
//对堕落的碎片做随机
|
||||||
|
*/
|
||||||
class BattleDataService extends BaseService {
|
class BattleDataService extends BaseService {
|
||||||
|
|
||||||
private $seasonDb = array();
|
private $seasonDb = array();
|
||||||
|
private $reward = array(
|
||||||
|
'hero' => array(),
|
||||||
|
'weapon1' => array(),
|
||||||
|
'weapon2' => array(),
|
||||||
|
'items' => array()
|
||||||
|
);
|
||||||
|
private $heroDto = null;
|
||||||
|
private $rankActivityService = null;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@ -46,99 +94,44 @@ class BattleDataService extends BaseService {
|
|||||||
if (!$row) {
|
if (!$row) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$heroDb = Hero::toDto($row);
|
$this->heroDto = Hero::toDto($row);
|
||||||
if (Hero::heroIsLocking($heroDb)) {
|
if (Hero::heroIsLocking($heroDb)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
error_log(json_encode($_REQUEST));
|
error_log(json_encode($_REQUEST));
|
||||||
error_log('updateBattleData1');
|
$matchMode = getReqVal('match_mode');
|
||||||
/*if (!$this->decCost($heroDb)) {
|
switch ($matchMode) {
|
||||||
return;
|
case 0:
|
||||||
}*/
|
{
|
||||||
$this->rankActivityService->updateBattleData();
|
//匹配赛模式
|
||||||
$this->rewardGold($heroDb);
|
$this->updatePvpData();
|
||||||
error_log('updateBattleData2');
|
$this->rewardCegPvp();
|
||||||
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
$this->rewardFragmentPvp();
|
||||||
if (!$this->currSeasonMeta) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
error_log('updateBattleData3');
|
break;
|
||||||
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
case 1:
|
||||||
if (!$this->seasonDb) {
|
{
|
||||||
Season::add($this->currSeasonMeta['id']);
|
//排位赛
|
||||||
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
|
||||||
}
|
}
|
||||||
if (!$this->seasonDb) {
|
break;
|
||||||
return;
|
case 2:
|
||||||
|
{
|
||||||
|
//pve
|
||||||
|
$this>updatePveData();
|
||||||
|
$this->rewardCegPve();
|
||||||
|
$this->rewardFragmentPve();
|
||||||
}
|
}
|
||||||
error_log('updateBattleData4');
|
break;
|
||||||
$this->updateScore();
|
default:
|
||||||
$hisBattleData = Battle::getMyBattleData();
|
{
|
||||||
if (!isset($hisBattleData)) {
|
|
||||||
$hisBattleData = array(
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$this->apply($hisBattleData);
|
break;
|
||||||
Battle::add(json_encode($hisBattleData));
|
|
||||||
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
|
||||||
if (!isset($seasonBattleData['today_data'])) {
|
|
||||||
$seasonBattleData['today_data'] = array(
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!isset($seasonBattleData['season_data'])) {
|
|
||||||
$seasonBattleData['season_data'] = array(
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!isset($seasonBattleData['his_week_data'])) {
|
|
||||||
$seasonBattleData['his_week_data'] = array(
|
public function getReward()
|
||||||
);
|
{
|
||||||
}
|
return $this->reward;
|
||||||
if (!isset($seasonBattleData['this_week_data'])) {
|
|
||||||
$seasonBattleData['this_week_data'] = array(
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (myself()->_getDaySeconds($seasonBattleData['today_data']['modifytime']) <
|
|
||||||
myself()->_getNowDaySeconds()) {
|
|
||||||
$seasonBattleData['today_data'] = array(
|
|
||||||
'createtime' => $seasonBattleData['today_data']['createtime'],
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (myself()->_getDaySeconds($seasonBattleData['this_week_data']['modifytime']) <
|
|
||||||
myself()->_getMondaySeconds()) {
|
|
||||||
$seasonBattleData['this_week_data'] = array(
|
|
||||||
'createtime' => $seasonBattleData['this_week_data']['createtime'],
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$oldSeasonDataKills = getXVal($seasonBattleData['season_data'], 'total_kills_times', 0);
|
|
||||||
$this->apply($seasonBattleData['season_data']);
|
|
||||||
$newSeasonDataKills = getXVal($seasonBattleData['season_data'], 'total_kills_times', 0);
|
|
||||||
if ($newSeasonDataKills > $oldSeasonDataKills) {
|
|
||||||
Season::update($this->currSeasonMeta['id'], array(
|
|
||||||
'kills_modifytime' => myself()->_getNowTime(),
|
|
||||||
));
|
|
||||||
Battle::update(array(
|
|
||||||
'kills_modifytime' => myself()->_getNowTime(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
$this->apply($seasonBattleData['today_data']);
|
|
||||||
$this->apply($seasonBattleData['this_week_data']);
|
|
||||||
Season::update(
|
|
||||||
$this->currSeasonMeta['id'],
|
|
||||||
array(
|
|
||||||
'battle_data' => json_encode($seasonBattleData),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->addItems();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function apply(&$battleData)
|
private function apply(&$battleData)
|
||||||
@ -325,37 +318,6 @@ class BattleDataService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decCost($heroDb)
|
|
||||||
{
|
|
||||||
$costTili = mt\Parameter::getVal('cost_fatigue', 0);
|
|
||||||
if ($heroDb['hero_tili'] < $costTili) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Hero::update($heroDb['hero_uniid'], array(
|
|
||||||
'hero_tili' => function () use($costTili) {
|
|
||||||
return "GREATEST(0, hero_tili - ${costTili})";
|
|
||||||
}
|
|
||||||
));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addItems()
|
|
||||||
{
|
|
||||||
$tmpStrs1 = explode('|', getReqVal('items', ''));
|
|
||||||
error_log('addItems ' . getReqVal('items', ''));
|
|
||||||
foreach ($tmpStrs1 as $tmpStr) {
|
|
||||||
$tmpStrs2 = explode(':', $tmpStr);
|
|
||||||
if (count($tmpStrs2) >= 2) {
|
|
||||||
$itemId = $tmpStrs2[0];
|
|
||||||
$itemNum = $tmpStrs2[1];
|
|
||||||
$itemMeta = mt\Item::get($itemId);
|
|
||||||
if ($itemMeta) {
|
|
||||||
Bag::addItem($itemId, $itemNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function rewardGold($heroDto)
|
private function rewardGold($heroDto)
|
||||||
{
|
{
|
||||||
$heroMeta = mt\Item::get($heroDto['hero_id']);
|
$heroMeta = mt\Item::get($heroDto['hero_id']);
|
||||||
@ -400,4 +362,149 @@ class BattleDataService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function updatePvpData()
|
||||||
|
{
|
||||||
|
error_log('updateBattleData1');
|
||||||
|
$this->rankActivityService->updateBattleData();
|
||||||
|
error_log('updateBattleData2');
|
||||||
|
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
||||||
|
if (!$this->currSeasonMeta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log('updateBattleData3');
|
||||||
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||||
|
if (!$this->seasonDb) {
|
||||||
|
Season::add($this->currSeasonMeta['id']);
|
||||||
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||||
|
}
|
||||||
|
if (!$this->seasonDb) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log('updateBattleData4');
|
||||||
|
$this->updateScore();
|
||||||
|
$hisBattleData = Battle::getMyBattleData();
|
||||||
|
if (!isset($hisBattleData)) {
|
||||||
|
$hisBattleData = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->apply($hisBattleData);
|
||||||
|
Battle::add(json_encode($hisBattleData));
|
||||||
|
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
||||||
|
if (!isset($seasonBattleData['today_data'])) {
|
||||||
|
$seasonBattleData['today_data'] = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!isset($seasonBattleData['season_data'])) {
|
||||||
|
$seasonBattleData['season_data'] = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!isset($seasonBattleData['his_week_data'])) {
|
||||||
|
$seasonBattleData['his_week_data'] = array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!isset($seasonBattleData['this_week_data'])) {
|
||||||
|
$seasonBattleData['this_week_data'] = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (myself()->_getDaySeconds($seasonBattleData['today_data']['modifytime']) <
|
||||||
|
myself()->_getNowDaySeconds()) {
|
||||||
|
$seasonBattleData['today_data'] = array(
|
||||||
|
'createtime' => $seasonBattleData['today_data']['createtime'],
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (myself()->_getDaySeconds($seasonBattleData['this_week_data']['modifytime']) <
|
||||||
|
myself()->_getMondaySeconds()) {
|
||||||
|
$seasonBattleData['this_week_data'] = array(
|
||||||
|
'createtime' => $seasonBattleData['this_week_data']['createtime'],
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$oldSeasonDataKills = getXVal($seasonBattleData['season_data'], 'total_kills_times', 0);
|
||||||
|
$this->apply($seasonBattleData['season_data']);
|
||||||
|
$newSeasonDataKills = getXVal($seasonBattleData['season_data'], 'total_kills_times', 0);
|
||||||
|
if ($newSeasonDataKills > $oldSeasonDataKills) {
|
||||||
|
Season::update($this->currSeasonMeta['id'], array(
|
||||||
|
'kills_modifytime' => myself()->_getNowTime(),
|
||||||
|
));
|
||||||
|
Battle::update(array(
|
||||||
|
'kills_modifytime' => myself()->_getNowTime(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$this->apply($seasonBattleData['today_data']);
|
||||||
|
$this->apply($seasonBattleData['this_week_data']);
|
||||||
|
Season::update(
|
||||||
|
$this->currSeasonMeta['id'],
|
||||||
|
array(
|
||||||
|
'battle_data' => json_encode($seasonBattleData),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updatePveData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rewardFragmentPvp()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rewardFragmentPve()
|
||||||
|
{
|
||||||
|
$onlineNum = $this->getOnlineNumber();
|
||||||
|
$instanceLevel = 0;
|
||||||
|
$instanceRank = 0;
|
||||||
|
$bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0;
|
||||||
|
$todayPveBattleTimes = $this->_getDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0);
|
||||||
|
$todayPveGetFragmentNum = $this->_getDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 0);
|
||||||
|
$heroQuality = $this->heroDto['quality'];
|
||||||
|
|
||||||
|
$dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0);
|
||||||
|
$dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2;
|
||||||
|
|
||||||
|
$heroProbability = min($heroFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1);
|
||||||
|
$gunProbability = min($gunFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1);
|
||||||
|
|
||||||
|
$heroProbability = max($heroProbability, 0);
|
||||||
|
$gunProbability = max($gunProbability, 0);
|
||||||
|
$emptyProbability = max(1 - $heroProbability - $gunProbability, 0);
|
||||||
|
|
||||||
|
$dropIdx = $this.randWeight(array($heroProbability, $gunProbability, $emptyProbability));
|
||||||
|
if ($dropIdx < 0 || $dropIdx == 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rewardCegPvp()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rewardCegPve()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function getOnlineNumber()
|
||||||
|
{
|
||||||
|
return max(1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function randWeight($items)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user