算了功能完善
This commit is contained in:
parent
505f542488
commit
ff53737c30
@ -37,6 +37,18 @@ class HashRate(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['!award', [_common.AwardItem()], '奖励'],
|
['!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(),
|
||||||
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -32,20 +32,13 @@ define('TN_SHOP', 8003);
|
|||||||
define('TN_RECHARGE_UPGRADE_TIMES', 8004);
|
define('TN_RECHARGE_UPGRADE_TIMES', 8004);
|
||||||
define('TN_SHARE_GAMES', 8005);
|
define('TN_SHARE_GAMES', 8005);
|
||||||
define('TN_HERO_LEVEL_UP', 8006);
|
define('TN_HERO_LEVEL_UP', 8006);
|
||||||
define('TN_END', 8007);
|
|
||||||
define('TN_HERO_MAX_LEVEL', 8008);
|
|
||||||
define('TN_LAST_RANKING_TIME', 8009);
|
define('TN_LAST_RANKING_TIME', 8009);
|
||||||
define('TN_MISSION_STAR_SEASON', 8010);
|
|
||||||
define('TN_RANK_STATUS', 8011);
|
define('TN_RANK_STATUS', 8011);
|
||||||
define('TN_FIRST_TUPOP_STATUS', 8012);
|
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_DIAMOND_CONSUME', 8016);//钻石消耗
|
||||||
define('TN_TOTAL_CEG_CONSUME', 8017);//ceg消耗
|
define('TN_TOTAL_CEG_CONSUME', 8017);//ceg消耗
|
||||||
define('TN_TOTAL_GATHER_GOLD', 8018);//收集金币
|
define('TN_END', 8018);
|
||||||
define('TN_TOTAL_LOOT_TIMES', 8019);//掉落包操作计数 0总计数 1循环计数
|
|
||||||
define('TN_TOTAL_HASH_RATE_REWARD', 8020);
|
|
||||||
|
|
||||||
define('TN_DAILY_BEGIN', 9001);
|
define('TN_DAILY_BEGIN', 9001);
|
||||||
define('TN_DAILY_LOGINS', 9001);
|
define('TN_DAILY_LOGINS', 9001);
|
||||||
|
@ -45,12 +45,6 @@ class GMController extends BaseAuthedController {
|
|||||||
'.additem' => function () use($params) {
|
'.additem' => function () use($params) {
|
||||||
$this->addItem($params);
|
$this->addItem($params);
|
||||||
},
|
},
|
||||||
'.addnft' => function () use($params) {
|
|
||||||
$this->addNft($params);
|
|
||||||
},
|
|
||||||
'.addtili' => function () use($params) {
|
|
||||||
$this->addTili($params);
|
|
||||||
},
|
|
||||||
'.getsystime' => function () use($params) {
|
'.getsystime' => function () use($params) {
|
||||||
$this->getSysTime($params);
|
$this->getSysTime($params);
|
||||||
},
|
},
|
||||||
@ -60,9 +54,6 @@ class GMController extends BaseAuthedController {
|
|||||||
'.reset_mission' => function () use($params) {
|
'.reset_mission' => function () use($params) {
|
||||||
$this->resetMission($params);
|
$this->resetMission($params);
|
||||||
},
|
},
|
||||||
'.addtest' => function () use($params) {
|
|
||||||
$this->addDyndata($params);
|
|
||||||
},
|
|
||||||
'.addhero' => function () use($params) {
|
'.addhero' => function () use($params) {
|
||||||
$this->addHero($params);
|
$this->addHero($params);
|
||||||
},
|
},
|
||||||
@ -87,11 +78,9 @@ class GMController extends BaseAuthedController {
|
|||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'text' => <<<END
|
'text' => <<<END
|
||||||
.additem 道具id 道具数量 //添加道具
|
.additem 道具id 道具数量 //添加道具
|
||||||
.addtili 英雄id 体力值 //添加英雄体力
|
|
||||||
.getsystime //获取服务器时间
|
.getsystime //获取服务器时间
|
||||||
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
|
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
|
||||||
.reset_mission //重置任务
|
.reset_mission //重置任务
|
||||||
.addtest //添加测试数据 1:击杀数 2:星星数 3:升段数
|
|
||||||
.loot 索引ID 次数 //测试掉落系统数据,示例:.loot 1030 10
|
.loot 索引ID 次数 //测试掉落系统数据,示例:.loot 1030 10
|
||||||
END
|
END
|
||||||
));
|
));
|
||||||
@ -145,60 +134,6 @@ END
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addNft($params)
|
|
||||||
{
|
|
||||||
$itemId = getXVal($params, 0, 0);
|
|
||||||
$propertyChgService = new services\PropertyChgService();
|
|
||||||
$awardService = new services\AwardService();
|
|
||||||
|
|
||||||
$itemMeta = mt\Item::get($itemId);
|
|
||||||
if ($itemMeta) {
|
|
||||||
$tokenType = Nft::getTokenType($itemMeta);
|
|
||||||
if ($tokenType == Nft::NONE_TYPE) {
|
|
||||||
myself()->_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)
|
private function getSysTime($params)
|
||||||
{
|
{
|
||||||
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
||||||
@ -235,27 +170,6 @@ END
|
|||||||
myself()->_rspOk();
|
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){
|
private function lootTest($params){
|
||||||
|
|
||||||
|
@ -19,42 +19,6 @@ class HashRateController extends BaseAuthedController
|
|||||||
$this->hashRateService->init();
|
$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(){
|
public function taskList(){
|
||||||
$type = getReqVal('type', 1);
|
$type = getReqVal('type', 1);
|
||||||
$taskDtoList1 = array();
|
$taskDtoList1 = array();
|
||||||
@ -64,6 +28,7 @@ class HashRateController extends BaseAuthedController
|
|||||||
$income_start_time = 0;
|
$income_start_time = 0;
|
||||||
$income_end_time = 0;
|
$income_end_time = 0;
|
||||||
$state = 0;
|
$state = 0;
|
||||||
|
$myHashRate = 0;
|
||||||
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
if ($currentPeriod){
|
if ($currentPeriod){
|
||||||
$mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService);
|
$mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService);
|
||||||
@ -72,7 +37,7 @@ class HashRateController extends BaseAuthedController
|
|||||||
$taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
$taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
||||||
array_push($taskDtoList1, $taskDto);
|
array_push($taskDtoList1, $taskDto);
|
||||||
}
|
}
|
||||||
$mateList2 = \mt\AchievementsPower::getListByType(0);
|
$mateList2 = \mt\AchievementsPower::getListByType(\mt\AchievementsPower::TYPE5);
|
||||||
foreach ($mateList2 as $mate) {
|
foreach ($mateList2 as $mate) {
|
||||||
$taskDb = HashRate::find($mate['id'],$currentPeriod['id']);
|
$taskDb = HashRate::find($mate['id'],$currentPeriod['id']);
|
||||||
$taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
$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){
|
}elseif (myself()->_getNowTime() >= $income_start_time && myself()->_getNowTime() <= $income_end_time){
|
||||||
$state = 2;
|
$state = 2;
|
||||||
}
|
}
|
||||||
|
$myHashRate = HashRate::getMyHashRate( $currentPeriod['id']);
|
||||||
}
|
}
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'task_list1' => $taskDtoList1,
|
'task_list1' => $taskDtoList1,
|
||||||
@ -97,7 +63,7 @@ class HashRateController extends BaseAuthedController
|
|||||||
'income_end_time' => $income_end_time,
|
'income_end_time' => $income_end_time,
|
||||||
'state' => $state,
|
'state' => $state,
|
||||||
'refresh_times' => myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0),
|
'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");
|
$this->_rspErr(2, "Can't get it again");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if ($taskDto['state'] == \services\HashRateService::NOT_FINISHED_STATE) {
|
if ($taskDto['state'] == \services\HashRateService::NOT_FINISHED_STATE) {
|
||||||
// $this->_rspErr(3, 'task not achieved');
|
$this->_rspErr(3, 'task not achieved');
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
$lootIndex = $taskMeta['Reward_Loot'];
|
$lootIndex = $taskMeta['Reward_Loot'];
|
||||||
$reward = \services\LootService::dropOutItem($lootIndex);
|
$reward = \services\LootService::dropOutItem($lootIndex);
|
||||||
$rewardNum = $reward[0]['item_num'];
|
$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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/DressAttribute.php');
|
require_once('mt/DressAttribute.php');
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/HeroSkin.php');
|
require_once('models/HeroSkin.php');
|
||||||
@ -75,6 +76,27 @@ class HeroSkinController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, "You don't have the hero skin yet");
|
$this->_rspErr(1, "You don't have the hero skin yet");
|
||||||
return;
|
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']){
|
if ($heroDb['skin_id']){
|
||||||
HeroSkin::update($heroDb['skin_id'],array(
|
HeroSkin::update($heroDb['skin_id'],array(
|
||||||
'used'=>HeroSkin::NO_USE,
|
'used'=>HeroSkin::NO_USE,
|
||||||
@ -98,7 +120,11 @@ class HeroSkinController extends BaseAuthedController {
|
|||||||
'hero_uniid'=>$heroUniid,
|
'hero_uniid'=>$heroUniid,
|
||||||
'modifytime'=>myself()->_getNowTime(),
|
'modifytime'=>myself()->_getNowTime(),
|
||||||
));
|
));
|
||||||
$this->_rspOk();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function demountSkin(){
|
public function demountSkin(){
|
||||||
@ -112,6 +138,17 @@ class HeroSkinController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, "Useless operation");
|
$this->_rspErr(1, "Useless operation");
|
||||||
return;
|
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(
|
Hero::update($heroUniid,array(
|
||||||
'skin_id' => 0,
|
'skin_id' => 0,
|
||||||
'modifytime'=>myself()->_getNowTime()
|
'modifytime'=>myself()->_getNowTime()
|
||||||
@ -122,7 +159,11 @@ class HeroSkinController extends BaseAuthedController {
|
|||||||
'hero_uniid'=>0,
|
'hero_uniid'=>0,
|
||||||
'modifytime'=>myself()->_getNowTime(),
|
'modifytime'=>myself()->_getNowTime(),
|
||||||
));
|
));
|
||||||
$this->_rspOk();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function synSkin(){
|
public function synSkin(){
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
require_once('services/ServerSwitch.php');
|
require_once('services/ServerSwitch.php');
|
||||||
|
require_once('services/HashRateService.php');
|
||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('mt/HashRateCommon.php');
|
require_once('mt/HashRateCommon.php');
|
||||||
require_once('mt/ActivityRewards.php');
|
require_once('mt/ActivityRewards.php');
|
||||||
@ -109,9 +110,9 @@ class OtherController extends BaseAuthedController {
|
|||||||
case self::HASH_RATE :{
|
case self::HASH_RATE :{
|
||||||
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
if ($currentPeriod){
|
if ($currentPeriod){
|
||||||
$myHashRate = HashRate::getMyHashRate($currentPeriod['id']);
|
$hashRateService = new services\HashRateService();
|
||||||
$rewardNum = myself()->_getV(TN_TOTAL_HASH_RATE_REWARD,$currentPeriod['id']);
|
$hashRateService->init();
|
||||||
if ($rewardNum>0 && $rewardNum>$myHashRate){
|
if ($hashRateService->_isHaveRedTag($currentPeriod['id'])){
|
||||||
$state = 1;
|
$state = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,11 +193,7 @@ class OtherController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::HASH_RATE :{
|
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;
|
break;
|
||||||
case self::HERO_SKIN :{
|
case self::HERO_SKIN :{
|
||||||
|
@ -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){
|
public static function add($taskId,$period){
|
||||||
SqlHelper::upsert(
|
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){
|
public static function rewardAdd($period,$reward){
|
||||||
SqlHelper::upsert(
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -36,6 +36,7 @@ class AchievementsPower {
|
|||||||
const TYPE2 = 2;
|
const TYPE2 = 2;
|
||||||
const TYPE3 = 3;
|
const TYPE3 = 3;
|
||||||
const TYPE4 = 4;
|
const TYPE4 = 4;
|
||||||
|
const TYPE5 = 5;
|
||||||
|
|
||||||
const REFRESH_STATE = 1;
|
const REFRESH_STATE = 1;
|
||||||
const NOT_REFRESH_STATE = 0;
|
const NOT_REFRESH_STATE = 0;
|
||||||
|
@ -377,6 +377,22 @@ class HashRateService extends BaseService
|
|||||||
myself()->_incDailyV(TN_HASH_DAILY_REFRESH_TIMES,0,1);
|
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){
|
public function serverTaskDto($taskMate){
|
||||||
|
@ -6,8 +6,10 @@ namespace services;
|
|||||||
require_once('mt/LootConfig.php');
|
require_once('mt/LootConfig.php');
|
||||||
require_once('mt/ServerTaskTime.php');
|
require_once('mt/ServerTaskTime.php');
|
||||||
require_once('models/ServerTaskBattleCount.php');
|
require_once('models/ServerTaskBattleCount.php');
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
|
||||||
use models\ServerTaskBattleCount;
|
use models\ServerTaskBattleCount;
|
||||||
|
use models\Hero;
|
||||||
use mt;
|
use mt;
|
||||||
|
|
||||||
class LootService
|
class LootService
|
||||||
@ -49,6 +51,22 @@ class LootService
|
|||||||
error_log("An endless loop occurs in the program. Terminate the program");
|
error_log("An endless loop occurs in the program. Terminate the program");
|
||||||
return ;
|
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']){
|
switch ($lootMeta['method']){
|
||||||
// case self::EMPTY_DROP_TYPE: {
|
// case self::EMPTY_DROP_TYPE: {
|
||||||
//
|
//
|
||||||
|
@ -227,20 +227,20 @@ class RoomBattleDataService extends BaseService {
|
|||||||
//算力加成
|
//算力加成
|
||||||
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
if ($currentPeriod && myself()->_getNowTime() >= strtotime($currentPeriod['income_start_time'])){
|
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']);
|
$currentCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id']);
|
||||||
$s = mt\Parameter::getVal('economy_account_compute_s',0);
|
$computeR = explode("|",mt\Parameter::getVal('economy_account_compute_R',0));
|
||||||
$totalCompute = $currentCompute + $s * $lastCompute;
|
$k = 0;
|
||||||
$computeParam = mt\Parameter::getVal('economy_account_compute_K',0);
|
for ($i=0;$i<count($computeR);$i++){
|
||||||
$computeMaxEffect = mt\Parameter::getVal('economy_account_compute_E',0);
|
if ($currentCompute >= $computeR[$i]){
|
||||||
$powerRate = $totalCompute / ($totalCompute + $computeParam) * $computeMaxEffect;
|
$k = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$computeE = explode("|",mt\Parameter::getVal('economy_account_compute_E',0));
|
||||||
|
$powerRate = $computeE[$k];
|
||||||
$gold = $gold * ($powerRate + 1);
|
$gold = $gold * ($powerRate + 1);
|
||||||
$compute = ($totalCompute / ($totalCompute + $computeParam) * $computeMaxEffect + 1);
|
|
||||||
|
|
||||||
$hashRateValue = round($powerRate,4);
|
$hashRateValue = round($powerRate,4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($gold > 0){
|
if ($gold > 0){
|
||||||
array_push($reward,array(
|
array_push($reward,array(
|
||||||
|
@ -115,7 +115,7 @@ class TameBattleDataService extends BaseService {
|
|||||||
{
|
{
|
||||||
//匹配赛模式
|
//匹配赛模式
|
||||||
$this->updatePvpData();
|
$this->updatePvpData();
|
||||||
// $this->settlementReward();
|
|
||||||
myself()->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0, 1);
|
myself()->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -125,7 +125,6 @@ class TameBattleDataService extends BaseService {
|
|||||||
$this->updatePvpData();
|
$this->updatePvpData();
|
||||||
$this->updateRankData();
|
$this->updateRankData();
|
||||||
// $this->updateScore();
|
// $this->updateScore();
|
||||||
// $this->settlementReward();
|
|
||||||
myself()->_incDailyV(TN_DAILY_RANK_BATTLE_TIMES, 0, 1);
|
myself()->_incDailyV(TN_DAILY_RANK_BATTLE_TIMES, 0, 1);
|
||||||
}
|
}
|
||||||
break;
|
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()
|
private function updateRankData()
|
||||||
{
|
{
|
||||||
error_log('updateRankData');
|
error_log('updateRankData');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user