diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index fdbe91a8..e01a101c 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -30,7 +30,9 @@ define('TN_DAILY_ACTIVE', 9002); define('TN_DAILY_SHOP', 9003); define('TN_DAILY_RECHARGE_UPGRADE_TIMES', 9004); 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_ACTIVE', 10002); diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 09bf4be3..d32340dc 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -43,58 +43,6 @@ class BattleController extends BaseAuthedController { 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() diff --git a/webapp/mt/Hero.php b/webapp/mt/Hero.php index a919f6db..430cabcf 100644 --- a/webapp/mt/Hero.php +++ b/webapp/mt/Hero.php @@ -71,7 +71,7 @@ class Hero { protected static function getMetaList() { if (!self::$metaList) { - self::$metaList = getMetaTable('player@player.php'); + self::$metaList = getMetaTable('hero@hero.php'); } return self::$metaList; } diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 2ea6669d..9bcb432b 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -30,9 +30,57 @@ use models\Hero; use models\Gun; 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 { private $seasonDb = array(); + private $reward = array( + 'hero' => array(), + 'weapon1' => array(), + 'weapon2' => array(), + 'items' => array() + ); + private $heroDto = null; + private $rankActivityService = null; function __construct() { @@ -46,99 +94,44 @@ class BattleDataService extends BaseService { if (!$row) { return false; } - $heroDb = Hero::toDto($row); + $this->heroDto = Hero::toDto($row); if (Hero::heroIsLocking($heroDb)) { return false; } error_log(json_encode($_REQUEST)); - error_log('updateBattleData1'); - /*if (!$this->decCost($heroDb)) { - return; - }*/ - $this->rankActivityService->updateBattleData(); - $this->rewardGold($heroDb); - error_log('updateBattleData2'); - $this->currSeasonMeta = mt\Season::getCurrentSeason(); - if (!$this->currSeasonMeta) { - return; + $matchMode = getReqVal('match_mode'); + switch ($matchMode) { + case 0: + { + //匹配赛模式 + $this->updatePvpData(); + $this->rewardCegPvp(); + $this->rewardFragmentPvp(); } - 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']); + break; + case 1: + { + //排位赛 } - if (!$this->seasonDb) { - return; + break; + case 2: + { + //pve + $this>updatePveData(); + $this->rewardCegPve(); + $this->rewardFragmentPve(); } - error_log('updateBattleData4'); - $this->updateScore(); - $hisBattleData = Battle::getMyBattleData(); - if (!isset($hisBattleData)) { - $hisBattleData = array( - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime() - ); + break; + default: + { } - $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() - ); + break; } - 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), - ) - ); - $this->addItems(); + } + + public function getReward() + { + return $this->reward; } 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) { $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) + { + + } + }