diff --git a/doc/HashRate.py b/doc/HashRate.py index 63ce307e..3f83989a 100644 --- a/doc/HashRate.py +++ b/doc/HashRate.py @@ -37,6 +37,18 @@ class HashRate(object): _common.RspHead(), ['!award', [_common.AwardItem()], '奖励'], ] + },{ + 'name': 'refreshTask', + 'desc': '刷新任务行为', + 'group': 'HashRate', + 'url': 'webapp/index.php?c=HashRate&a=refreshTask', + 'params': [ + _common.ReqHead(), + ['task_id', 0, '任务id'], + ], + 'response': [ + _common.RspHead(), + ] }, ] diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 6e215811..ae41a81c 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -32,20 +32,13 @@ define('TN_SHOP', 8003); define('TN_RECHARGE_UPGRADE_TIMES', 8004); define('TN_SHARE_GAMES', 8005); define('TN_HERO_LEVEL_UP', 8006); -define('TN_END', 8007); -define('TN_HERO_MAX_LEVEL', 8008); define('TN_LAST_RANKING_TIME', 8009); -define('TN_MISSION_STAR_SEASON', 8010); define('TN_RANK_STATUS', 8011); define('TN_FIRST_TUPOP_STATUS', 8012); -define('TN_TOTAL_KILLS_NUM', 8013); -define('TN_TOTAL_STAR_NUM', 8014); -define('TN_TOTAL_RANK_NUM', 8015); define('TN_TOTAL_DIAMOND_CONSUME', 8016);//钻石消耗 define('TN_TOTAL_CEG_CONSUME', 8017);//ceg消耗 -define('TN_TOTAL_GATHER_GOLD', 8018);//收集金币 -define('TN_TOTAL_LOOT_TIMES', 8019);//掉落包操作计数 0总计数 1循环计数 -define('TN_TOTAL_HASH_RATE_REWARD', 8020); +define('TN_END', 8018); + define('TN_DAILY_BEGIN', 9001); define('TN_DAILY_LOGINS', 9001); diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index 66a27f08..5f1cdec3 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -45,12 +45,6 @@ class GMController extends BaseAuthedController { '.additem' => function () use($params) { $this->addItem($params); }, - '.addnft' => function () use($params) { - $this->addNft($params); - }, - '.addtili' => function () use($params) { - $this->addTili($params); - }, '.getsystime' => function () use($params) { $this->getSysTime($params); }, @@ -60,9 +54,6 @@ class GMController extends BaseAuthedController { '.reset_mission' => function () use($params) { $this->resetMission($params); }, - '.addtest' => function () use($params) { - $this->addDyndata($params); - }, '.addhero' => function () use($params) { $this->addHero($params); }, @@ -87,11 +78,9 @@ class GMController extends BaseAuthedController { $this->_rspData(array( 'text' => <<_rspErr(1, 'param item_id error'); - return; - } else { - SqlHelper::insert( - myself()->_getMarketMysql(), - 't_nft', - array( - 'token_id' => Nft::genTempTokenId(), - 'token_type' => $tokenType, - 'game_id' => 2006, - 'item_id' => $itemId, - 'owner_address' => myself()->_getAddress(), - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ) - ); - } - } else { - myself()->_rspErr(1, 'param item_id error'); - return; - } - - $this->_rspData(array( - 'text' => 'add nft success', - 'award' => $awardService->toDto(), - 'property_chg' => $propertyChgService->toDto(), - )); - } - - private function addTili($params) - { - $heroId = getXVal($params, 0, 0); - $tili = getXVal($params, 1, 0); - Hero::update($heroId, array( - 'hero_tili' => "hero_tili + ${tili}" - )); - $propertyChgService->addHeroChg(); - $this->_rspData(array( - 'text' => 'add item success', - 'award' => $awardService->toDto(), - 'property_chg' => $propertyChgService->toDto(), - )); - } - private function getSysTime($params) { $sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime()); @@ -235,27 +170,6 @@ END myself()->_rspOk(); } - private function addDyndata($params){ - $type = getXVal($params, 0, 0); - $num = getXVal($params, 1, 0); - switch ($type){ - case 1 : { - myself()->_incV(TN_TOTAL_KILLS_NUM,0,$num); - } - break; - case 2 : { - myself()->_incV(TN_TOTAL_STAR_NUM,0,$num); - } - break; - case 3 : { - myself()->_incV(TN_TOTAL_DIAMOND_CONSUME,0,$num); - } - break; - case 4 : { - myself()->_incV(TN_TOTAL_CEG_CONSUME,0,$num); - } - } - } private function lootTest($params){ diff --git a/webapp/controller/HashRateController.class.php b/webapp/controller/HashRateController.class.php index a7ac613d..60204d77 100644 --- a/webapp/controller/HashRateController.class.php +++ b/webapp/controller/HashRateController.class.php @@ -19,42 +19,6 @@ class HashRateController extends BaseAuthedController $this->hashRateService->init(); } - public function info(){ - $mateList = \mt\AchievementsPower::getMetaList(); - $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); - $info = array( - 'list' => array(), - 'obtain_start_time' => 0, - 'obtain_end_time' => 0, - 'income_start_time' => 0, - 'income_end_time' => 0, - 'state' => 0, - 'myHashRate' => 0, - ); - - if ($currentPeriod){ - foreach ($mateList as $mate) { - $temp = $this->hashRateService->hashRateTaskDto($mate); - array_push($info['list'], $temp); - } - $obtain_start_time = strtotime($currentPeriod['obtain_start_time']); - $obtain_end_time = strtotime($currentPeriod['obtain_end_time']); - $income_start_time = strtotime($currentPeriod['income_start_time']); - $income_end_time = strtotime($currentPeriod['income_end_time']); - $info['obtain_start_time'] = $obtain_start_time; - $info['obtain_end_time'] = $obtain_end_time; - $info['income_start_time'] = $income_start_time; - $info['income_end_time'] = $income_end_time; - if(myself()->_getNowTime() >= $obtain_start_time && myself()->_getNowTime() <= $obtain_end_time){ - $info['state'] = 1; - }elseif (myself()->_getNowTime() >= $income_start_time && myself()->_getNowTime() <= $income_end_time){ - $info['state'] = 2; - } - $info['myHashRate'] = HashRate::getMyHashRate( $currentPeriod['id']); - } - $this->_rspData($info); - } - public function taskList(){ $type = getReqVal('type', 1); $taskDtoList1 = array(); @@ -64,6 +28,7 @@ class HashRateController extends BaseAuthedController $income_start_time = 0; $income_end_time = 0; $state = 0; + $myHashRate = 0; $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); if ($currentPeriod){ $mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService); @@ -72,7 +37,7 @@ class HashRateController extends BaseAuthedController $taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb); array_push($taskDtoList1, $taskDto); } - $mateList2 = \mt\AchievementsPower::getListByType(0); + $mateList2 = \mt\AchievementsPower::getListByType(\mt\AchievementsPower::TYPE5); foreach ($mateList2 as $mate) { $taskDb = HashRate::find($mate['id'],$currentPeriod['id']); $taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb); @@ -87,6 +52,7 @@ class HashRateController extends BaseAuthedController }elseif (myself()->_getNowTime() >= $income_start_time && myself()->_getNowTime() <= $income_end_time){ $state = 2; } + $myHashRate = HashRate::getMyHashRate( $currentPeriod['id']); } $this->_rspData(array( 'task_list1' => $taskDtoList1, @@ -97,7 +63,7 @@ class HashRateController extends BaseAuthedController 'income_end_time' => $income_end_time, 'state' => $state, 'refresh_times' => myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0), - 'myHashRate' => 0, + 'myHashRate' => $myHashRate, )); } @@ -124,10 +90,10 @@ class HashRateController extends BaseAuthedController $this->_rspErr(2, "Can't get it again"); return; } -// if ($taskDto['state'] == \services\HashRateService::NOT_FINISHED_STATE) { -// $this->_rspErr(3, 'task not achieved'); -// return; -// } + if ($taskDto['state'] == \services\HashRateService::NOT_FINISHED_STATE) { + $this->_rspErr(3, 'task not achieved'); + return; + } $lootIndex = $taskMeta['Reward_Loot']; $reward = \services\LootService::dropOutItem($lootIndex); $rewardNum = $reward[0]['item_num']; @@ -144,6 +110,32 @@ class HashRateController extends BaseAuthedController )); } + public function refreshTask(){ + $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); + if (! $currentPeriod){ + $this->_rspErr(1, 'Already ended'); + return; + } + $taskId = getReqVal('task_id', 0); + $taskMeta = \mt\AchievementsPower::find($taskId); + if (!$taskMeta) { + $this->_rspErr(1, 'task_id error'); + return; + } + if ($taskMeta['is_refresh'] == \mt\AchievementsPower::NOT_REFRESH_STATE){ + $this->_rspErr(1, 'Unable to refresh'); + return; + } + $refreshTimes = myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0); + $refreshTimesMax = \mt\Parameter::getVal('economy_account_compute_refresh_max',5); + if ( $refreshTimes >= $refreshTimesMax){ + $this->_rspErr(1, 'The number of refreshes was exhausted today'); + return; + } + $this->hashRateService->refreshHashRateTask($taskMeta,$currentPeriod['id']); + $this->_rspOk(); + } + } \ No newline at end of file diff --git a/webapp/controller/HeroSkinController.class.php b/webapp/controller/HeroSkinController.class.php index cc5434f0..5bed965f 100644 --- a/webapp/controller/HeroSkinController.class.php +++ b/webapp/controller/HeroSkinController.class.php @@ -1,5 +1,6 @@ _rspErr(1, "You don't have the hero skin yet"); return; } + $removeNum = 0; + if ($heroDb['skin_id']){ + $removeNum += 1; + } + if ($heroSkinDb['hero_uniid']){ + $removeNum += 1; + } + if ($removeNum > 0){ + $goldNum = \mt\Parameter::getVal('hero_dress_remove_price',200); + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $goldNum * $removeNum + ) + ); + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + } if ($heroDb['skin_id']){ HeroSkin::update($heroDb['skin_id'],array( 'used'=>HeroSkin::NO_USE, @@ -98,7 +120,11 @@ class HeroSkinController extends BaseAuthedController { 'hero_uniid'=>$heroUniid, 'modifytime'=>myself()->_getNowTime(), )); - $this->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); } public function demountSkin(){ @@ -112,6 +138,17 @@ class HeroSkinController extends BaseAuthedController { $this->_rspErr(1, "Useless operation"); return; } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => \mt\Parameter::getVal('hero_dress_remove_price',200) + ), + ); + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); Hero::update($heroUniid,array( 'skin_id' => 0, 'modifytime'=>myself()->_getNowTime() @@ -122,7 +159,11 @@ class HeroSkinController extends BaseAuthedController { 'hero_uniid'=>0, 'modifytime'=>myself()->_getNowTime(), )); - $this->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); } public function synSkin(){ diff --git a/webapp/controller/OtherController.class.php b/webapp/controller/OtherController.class.php index b629d701..2ac82258 100644 --- a/webapp/controller/OtherController.class.php +++ b/webapp/controller/OtherController.class.php @@ -2,6 +2,7 @@ require_once('services/PropertyChgService.php'); require_once('services/ServerSwitch.php'); +require_once('services/HashRateService.php'); require_once('mt/RankSeason.php'); require_once('mt/HashRateCommon.php'); require_once('mt/ActivityRewards.php'); @@ -109,9 +110,9 @@ class OtherController extends BaseAuthedController { case self::HASH_RATE :{ $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); if ($currentPeriod){ - $myHashRate = HashRate::getMyHashRate($currentPeriod['id']); - $rewardNum = myself()->_getV(TN_TOTAL_HASH_RATE_REWARD,$currentPeriod['id']); - if ($rewardNum>0 && $rewardNum>$myHashRate){ + $hashRateService = new services\HashRateService(); + $hashRateService->init(); + if ($hashRateService->_isHaveRedTag($currentPeriod['id'])){ $state = 1; } } @@ -192,11 +193,7 @@ class OtherController extends BaseAuthedController { } break; case self::HASH_RATE :{ - $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); - if ($currentPeriod) { - $myHashRate = HashRate::getMyHashRate($currentPeriod['id']); - myself()->_setV(TN_TOTAL_HASH_RATE_REWARD,$currentPeriod['id'], $myHashRate); - } + } break; case self::HERO_SKIN :{ diff --git a/webapp/models/HashRate.php b/webapp/models/HashRate.php index b7f4d3d1..d2061b4d 100644 --- a/webapp/models/HashRate.php +++ b/webapp/models/HashRate.php @@ -19,33 +19,6 @@ class HashRate extends BaseModel ); } - public static function all($period) - { - $rows = SqlHelper::ormSelect( - myself()->_getSelfMysql(), - 't_hash_rate', - array( - 'account_id' => myself()->_getAccountId(), - 'period' => $period, - ) - ); - return array_map(function($row) { - $nowDaySeconds = myself()->_getNowDaySeconds(); - $mondaySeconds = myself()->_getMondaySeconds(); - return $row; - }, $rows); - } - - public static function allToHash($period) - { - $rows = self::all($period); - $taskHash = array(); - array_walk($rows, function ($row) use(&$taskHash) { - $taskHash[$row['task_id']] = $row; - }); - return $taskHash; - } - public static function add($taskId,$period){ SqlHelper::upsert( @@ -69,41 +42,6 @@ class HashRate extends BaseModel ); } - public static function getMyHashRate($period){ - $rows = SqlHelper::ormSelect( - myself()->_getSelfMysql(), - 't_hash_rate', - array( - 'account_id' => myself()->_getAccountId(), - 'period' => $period, - ) - ); - $myHashRate = 0; - if ($rows){ - foreach ($rows as $row){ - $myHashRate += $row['reward']; - } - } - return $myHashRate; - } - - public static function getTotalByAccount($accountId,$period){ - $rows = SqlHelper::ormSelect( - myself()->_getSelfMysql(), - 't_hash_rate', - array( - 'account_id' => $accountId, - 'period' => $period, - ) - ); - $totalHashRate = 0; - if ($rows){ - foreach ($rows as $row){ - $totalHashRate += $row['reward']; - } - } - return $totalHashRate; - } public static function rewardAdd($period,$reward){ SqlHelper::upsert( @@ -129,4 +67,37 @@ class HashRate extends BaseModel ); } + public static function getMyHashRate($period){ + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_hash_rate_reward', + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + ) + ); + $myHashRate = 0; + if ($row){ + $myHashRate = $row['reward']; + } + return $myHashRate; + } + + public static function getTotalByAccount($accountId,$period){ + $row = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_hash_rate_reward', + array( + 'account_id' => $accountId, + 'period' => $period, + ) + ); + $totalHashRate = 0; + if ($row){ + $totalHashRate = $row['reward']; + } + return $totalHashRate; + } + + } \ No newline at end of file diff --git a/webapp/mt/AchievementsPower.php b/webapp/mt/AchievementsPower.php index ee4d7856..62e2c35b 100644 --- a/webapp/mt/AchievementsPower.php +++ b/webapp/mt/AchievementsPower.php @@ -36,6 +36,7 @@ class AchievementsPower { const TYPE2 = 2; const TYPE3 = 3; const TYPE4 = 4; + const TYPE5 = 5; const REFRESH_STATE = 1; const NOT_REFRESH_STATE = 0; diff --git a/webapp/services/HashRateService.php b/webapp/services/HashRateService.php index 406aa7db..378e889a 100644 --- a/webapp/services/HashRateService.php +++ b/webapp/services/HashRateService.php @@ -377,6 +377,22 @@ class HashRateService extends BaseService myself()->_incDailyV(TN_HASH_DAILY_REFRESH_TIMES,0,1); } + public function _isHaveRedTag($period){ + foreach ($this->hashRateTask as $item){ + if (is_array($item)){ + foreach ($item as $task){ + $taskMeta = AchievementsPower::find($task['task_id']); + $taskDb = HashRate::find($task['task_id'],$period); + $taskDto = $this->hashRateTaskDto($taskMeta,$taskDb); + if ($taskDto['state'] == self::FINISHED_STATE){ + return true; + } + } + } + } + return false; + } + public function serverTaskDto($taskMate){ diff --git a/webapp/services/LootService.php b/webapp/services/LootService.php index 150c34ea..9c653bb2 100644 --- a/webapp/services/LootService.php +++ b/webapp/services/LootService.php @@ -6,8 +6,10 @@ namespace services; require_once('mt/LootConfig.php'); require_once('mt/ServerTaskTime.php'); require_once('models/ServerTaskBattleCount.php'); +require_once('models/Hero.php'); use models\ServerTaskBattleCount; +use models\Hero; use mt; class LootService @@ -49,6 +51,22 @@ class LootService error_log("An endless loop occurs in the program. Terminate the program"); return ; } + if ($lootMeta['isAffected']){ + $lucky = Hero::getAccountLuckyTemp(); + $luckyParam = \mt\Parameter::getVal('economy_account_luck_K',0); + $rangeArr = explode("|",\mt\Parameter::getVal('economy_account_luck_range',0)); + $rate = ($rangeArr[1]-$rangeArr[0]) * $lucky/($lucky+$luckyParam) + $rangeArr[0]; + $rnd = rand() / (mt_getrandmax() + 1); + if ($rnd <= $rate){ + self::doMethod($lootMeta,$depth,$items); + } + }else{ + self::doMethod($lootMeta,$depth,$items); + } + + } + + private static function doMethod($lootMeta,&$depth,&$items){ switch ($lootMeta['method']){ // case self::EMPTY_DROP_TYPE: { // @@ -57,23 +75,23 @@ class LootService case self::WHERE_DROP_TYPE: { //暂定 } - break; + break; case self::ORDER_DROP_TYPE: { self::disposeDropContent1($lootMeta,$depth,$items); } - break; + break; case self::HAVE_RAND_DROP_TYPE: { self::disposeDropContent2($lootMeta,$depth,$items); } - break; + break; case self::NOT_HAVE_RAND_DROP_TYPE: { self::disposeDropContent3($lootMeta,$depth,$items); } - break; + break; case self::DYN_RAND_DROP_TYPE: { self::disposeDropContent4($lootMeta,$depth,$items); } - break; + break; } } diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index 8fee71ea..572a3dd9 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -227,20 +227,20 @@ class RoomBattleDataService extends BaseService { //算力加成 $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); if ($currentPeriod && myself()->_getNowTime() >= strtotime($currentPeriod['income_start_time'])){ - $lastCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id'] - 1); $currentCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id']); - $s = mt\Parameter::getVal('economy_account_compute_s',0); - $totalCompute = $currentCompute + $s * $lastCompute; - $computeParam = mt\Parameter::getVal('economy_account_compute_K',0); - $computeMaxEffect = mt\Parameter::getVal('economy_account_compute_E',0); - $powerRate = $totalCompute / ($totalCompute + $computeParam) * $computeMaxEffect; + $computeR = explode("|",mt\Parameter::getVal('economy_account_compute_R',0)); + $k = 0; + for ($i=0;$i= $computeR[$i]){ + $k = $i; + } + } + $computeE = explode("|",mt\Parameter::getVal('economy_account_compute_E',0)); + $powerRate = $computeE[$k]; $gold = $gold * ($powerRate + 1); - $compute = ($totalCompute / ($totalCompute + $computeParam) * $computeMaxEffect + 1); - $hashRateValue = round($powerRate,4); } - } if ($gold > 0){ array_push($reward,array( diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index 27067e2a..7a1d9a88 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -115,7 +115,7 @@ class TameBattleDataService extends BaseService { { //匹配赛模式 $this->updatePvpData(); -// $this->settlementReward(); + myself()->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0, 1); } break; @@ -125,7 +125,6 @@ class TameBattleDataService extends BaseService { $this->updatePvpData(); $this->updateRankData(); // $this->updateScore(); -// $this->settlementReward(); myself()->_incDailyV(TN_DAILY_RANK_BATTLE_TIMES, 0, 1); } break; @@ -735,185 +734,6 @@ class TameBattleDataService extends BaseService { ); } - public function calBattleReward($userDb,$heroDb,&$reward){ - $room_mode = getXVal($this->allInfo,'map_mode', 0); - $teamRank = getXVal($this->allInfo,'pvp_team_rank', 0); - $mapModeMeta = mt\MapMode::findByMapMode($room_mode); - if ($mapModeMeta){ - $gold = 0; -// $accountLucky = Hero::getAccountLucky($userDb['address']); - $accountLucky = Hero::getAccountLuckyTemp(); - $rewardMeta = mt\BattleReward::find($mapModeMeta['rewardMode'],$accountLucky); - if (!$rewardMeta){ - return ; - } - //验证英雄是否有效期内 - if (Hero::verifyValid($heroDb)){ - 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); - } - } - } - if ($gold > 0){ - $strArr = explode("|",$rewardMeta['goldParam']); - $coefficientArr = explode(";",$strArr[0]); - $coefficient = isset($coefficientArr[$teamRank-1]) ? $coefficientArr[$teamRank-1] : 0; - $gold = $gold * $coefficient; - - } - - //财富值加成 - $wealthK = mt\Parameter::getVal('economy_hero_wealth_K',0); - $wealthE = mt\Parameter::getVal('economy_hero_wealth_E',0); - $gold = $gold * (1 + $wealthE * (Hero::getHeroWealth($heroDb) / (Hero::getHeroWealth($heroDb) + $wealthK))); - - //算力加成 - $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); - $lastCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id'] - 1); - $currentCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id']); - $s = mt\Parameter::getVal('economy_account_compute_s',0); - $totalCompute = $currentCompute + $s * $lastCompute; - $computeParam = mt\Parameter::getVal('economy_account_compute_K',0); - $computeMaxEffect = mt\Parameter::getVal('economy_account_compute_E',0); - $gold = intval( $gold * ($totalCompute / ($totalCompute + $computeParam) * $computeMaxEffect + 1)); - if ($gold > 0){ - array_push($reward,array( - "item_id" => V_ITEM_GOLD, - "item_num" => $gold, - )); - } - } - - //宝箱掉落 - $rand = $rewardMeta['chestLootProb'] * 100; - $rnd = rand(1,100); - if ($rnd <= $rand){ - $chestItems = LootService::dropOutItem($rewardMeta['chestLoot']); - foreach ($chestItems as $item){ - array_push($reward,$item); - } - } - - - } - } - - private function rewardGoldPvp(&$reward,$heroDto,$userRank) - { - $heroPvpGold = FormulaService::calcHeroPvpGold($heroDto, $this->allInfo,$userRank); - if ($heroPvpGold > 0) { - $heroPvpGold = Hero::gainGoldPvp($heroDto, $heroPvpGold); - $reward['hero']['curr_gold'] = '' . ($heroDto['current_get_gold'] + $heroPvpGold); - $reward['hero']['obtain_gold'] = '' . ($heroDto['current_get_gold'] + $heroPvpGold); - } - if ($heroPvpGold > 0) { - array_push($reward['items'],array( - 'item_id'=> V_ITEM_GOLD, - 'item_num'=>$heroPvpGold, - )); - } - } - - public function calStarNum2(&$reward,$pvp_rank,$account_id){ - $currStarMissionSeasonMeta = \mt\StarLevel::getCurrentSeason(); - if (!$currStarMissionSeasonMeta){ - return; - } - $battleDb = Battle::find($account_id); - $battleTimes = 0; - if ($battleDb){ - $battleData = json_decode($battleDb['battle_data'], true); - $seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array(); - $battleTimes = getXVal($seasonBattleData, 'total_battle_times', 0); - } - if ($battleTimes <= mt\Parameter::getVal('rookie_map_counts',10)){ - array_push($reward,array( - 'item_id' => V_ITEM_STAR, - 'item_num' => 10 - )); - }else{ - $star_get_num = mt\Parameter::getVal('star_get_num',0); - $num_arr = explode('|',$star_get_num); - if ($pvp_rank>count($num_arr) || $pvp_rank<1){ - $finalNum = 0; - }else{ - $finalNum = $this->calFinalStarNum($num_arr[$pvp_rank-1]); - } - - if ($finalNum > 0){ - array_push($reward,array( - 'item_id'=> V_ITEM_STAR, - 'item_num'=>$finalNum, - )); - } - } - } - - private function calFinalStarNum($num){ - $finalNum = 0; - if ($num <= 0) { - return $finalNum; - } - $starMax = mt\Parameter::getVal('starroad_max',0); - if ($starMax){ - $starNum = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0); - $newNum = min($starMax,$starNum + $num); - $finalNum = max(0,$newNum-$starNum); - } - return $finalNum; - } - - private function settlementReward(){ - error_log('settlementReward'); - $battle_uuid = getXVal($this->allInfo,'battle_uuid', 0); - $room_uuid = getXVal($this->allInfo,'room_uuid', 0); - $propertyChgService = new services\PropertyChgService(); - $awardService = new services\AwardService(); - $db = BattleSettlement::findTeam($battle_uuid,$room_uuid); - if ($db){ - $data = emptyReplace(json_decode($db['data'], true), array()); - if ($data){ - foreach ($data['members'] as $member){ - if ($member['account_id'] == myself()->_getAccountId()){ - if (! empty($member['reward'])){ - $gold= 0; - $items = array(); - foreach ($member['reward'] as $value){ - if ($value['item_id'] == V_ITEM_GOLD){ - $gold = $value['item_num']; - } - if ($value['item_id'] != V_ITEM_STAR){ - array_push($items,$value); - } - } - myself()->_addItems($items, $awardService,$propertyChgService); - if ($gold > 0){ - //埋点 - $event = [ - 'name' => LogService::BATTLE_AWARD_PVP, - 'val' => $gold - ]; - LogService::productGold($event); - } - } -// if ($member['reward']['hero']['hero_uniid']){ -// Hero::update($member['reward']['hero']['hero_uniid'], -// array( -// 'today_get_gold' => $member['reward']['hero']['curr_gold'] * 100, -// 'last_get_gold_time' => myself()->_getNowTime() -// )); -// } - } - } - } - } - } - private function updateRankData() { error_log('updateRankData');