1
This commit is contained in:
parent
3cff27758a
commit
a2fd250a92
@ -42,6 +42,7 @@ 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_SERVER_TASK_STATE', 8080);//服务器大事件状态 1:4v4 2:吃鸡
|
||||
|
||||
define('TN_DAILY_BEGIN', 9001);
|
||||
define('TN_DAILY_LOGINS', 9001);
|
||||
|
61
webapp/controller/ActivityController.class.php
Normal file
61
webapp/controller/ActivityController.class.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
require_once('services/HashRateService.php');
|
||||
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
require_once('mt/ServerTask.php');
|
||||
|
||||
class ActivityController extends BaseAuthedController {
|
||||
|
||||
//服务器大事件
|
||||
public function serverTask(){
|
||||
$currentMeta = \mt\ServerTaskTime::getCurrentTime();
|
||||
if (! $currentMeta){
|
||||
myself()->_setV(TN_SERVER_TASK_STATE,0,0);
|
||||
$this->_rspErr(111, 'The activity has not started yet');
|
||||
return;
|
||||
}
|
||||
$taskDtoList1 = array();
|
||||
$taskDtoList2 = array();
|
||||
$taskListMeta = \mt\ServerTask::getMetaList();
|
||||
$hashRateService = new services\HashRateService();
|
||||
$hashRateService->init();
|
||||
foreach ($taskListMeta as $taskMeta){
|
||||
if ($taskMeta['type'] == \mt\ServerTask::MOBA_TYPE){
|
||||
$taskDto = $hashRateService->serverTaskDto($taskMeta);
|
||||
array_push($taskDtoList1,$taskDto);
|
||||
}
|
||||
if ($taskMeta['type'] == \mt\ServerTask::PVP_TYPE){
|
||||
$taskDto = $hashRateService->serverTaskDto($taskMeta);
|
||||
array_push($taskDtoList2,$taskDto);
|
||||
}
|
||||
}
|
||||
$mobaCount = 0;
|
||||
$pvpCount = 0;
|
||||
foreach ($taskDtoList1 as $taskDto){
|
||||
if ($taskDto['state'] == \services\HashRateService::FINISHED_STATE){
|
||||
$mobaCount += 1;
|
||||
}
|
||||
}
|
||||
foreach ($taskDtoList2 as $taskDto){
|
||||
if ($taskDto['state'] == \services\HashRateService::FINISHED_STATE){
|
||||
$pvpCount += 1;
|
||||
}
|
||||
}
|
||||
if ($mobaCount == count($taskDtoList1)){
|
||||
myself()->_setV(TN_SERVER_TASK_STATE,0,\mt\ServerTask::ACCOMPLISH_MOBA_STATE);
|
||||
}
|
||||
if ($pvpCount == count($taskDtoList2)){
|
||||
myself()->_setV(TN_SERVER_TASK_STATE,0,\mt\ServerTask::ACCOMPLISH_PVP_STATE);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'obtain_start_time' => strtotime($currentMeta['obtain_start_time']),
|
||||
'obtain_end_time' => strtotime($currentMeta['obtain_end_time']),
|
||||
'income_start_time' => strtotime($currentMeta['income_start_time']),
|
||||
'income_end_time' => strtotime($currentMeta['income_end_time']),
|
||||
'status' => myself()->_getV(TN_SERVER_TASK_STATE,0),
|
||||
'taskDtoList1' => $taskDtoList1,
|
||||
'taskDtoList2' => $taskDtoList2,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@ -30,7 +30,7 @@ use models\User;
|
||||
use models\Parachute;
|
||||
use models\ChipPage;
|
||||
use models\Battle;
|
||||
use models\HashRateTask;
|
||||
|
||||
|
||||
class BattleController extends BaseAuthedController {
|
||||
|
||||
@ -126,6 +126,12 @@ class BattleController extends BaseAuthedController {
|
||||
// $ranked = getReqVal('pvp_personal_rank', 0);
|
||||
$teamBattleDataService = new services\TameBattleDataService();
|
||||
$teamBattleDataService->calStarNum();
|
||||
$item = array(
|
||||
"item_id" => 300001,
|
||||
"item_num" => 1,
|
||||
);
|
||||
Bag::addItem($item['item_id'],$item['item_num']);
|
||||
$this->_rspData($item);
|
||||
}
|
||||
|
||||
public function teamReport()
|
||||
|
53
webapp/mt/ServerTask.php
Normal file
53
webapp/mt/ServerTask.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class ServerTask {
|
||||
const TOTAL_BATTLE_TIMES_COND = 1; //完成游戏场次
|
||||
const TOTAL_KILL_NUM_COND = 2; //累计击败
|
||||
const TOTAL_DAMGE_OUT_COND = 3; //累计伤害
|
||||
const TOTAL_USE_SKILL_TIMES_COND = 4; //累计使用技能
|
||||
|
||||
|
||||
const MOBA_TYPE = 1;
|
||||
const PVP_TYPE = 2;
|
||||
|
||||
|
||||
const ACCOMPLISH_MOBA_STATE = 1;
|
||||
const ACCOMPLISH_PVP_STATE = 2;
|
||||
|
||||
public static function getCustomTypeMetaList($type)
|
||||
{
|
||||
$metaList = array();
|
||||
switch ($type){
|
||||
case self::MOBA_TYPE : {
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
if ($meta['type'] == self::MOBA_TYPE ) {
|
||||
array_push($metaList, $meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::PVP_TYPE : {
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
if ($meta['type'] == self::PVP_TYPE ) {
|
||||
array_push($metaList, $meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $metaList;
|
||||
}
|
||||
|
||||
public static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('ServerTask@ServerTask.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
}
|
28
webapp/mt/ServerTaskTime.php
Normal file
28
webapp/mt/ServerTaskTime.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class ServerTaskTime {
|
||||
|
||||
public static function getCurrentTime()
|
||||
{
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
if (myself()->_getNowTime() >= strtotime($meta['obtain_start_time']) &&
|
||||
myself()->_getNowTime() <= strtotime($meta['income_end_time'])) {
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('ServerTaskTime@ServerTasktime.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
}
|
@ -10,6 +10,9 @@ use models\HashRateBattleData;
|
||||
use models\HashRate;
|
||||
use models\Hero;
|
||||
use mt\AchievementsPower;
|
||||
use mt\ServerTask;
|
||||
use mt\ServerTaskTime;
|
||||
|
||||
class HashRateService extends BaseService
|
||||
{
|
||||
const FINISHED_STATE = 1;
|
||||
@ -19,12 +22,15 @@ class HashRateService extends BaseService
|
||||
private $hashRateData = array();
|
||||
private $mobaBattleData = array();
|
||||
private $pvpBattleData = array();
|
||||
private $serverTaskData = array();
|
||||
private $mobaBattleDataServerTask = array();
|
||||
private $pvpBattleDataServerTask = array();
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->hisBattleData = HashRateBattleData::getMyBattleData();
|
||||
$this->hashRateData = getXVal($this->hisBattleData, 'data', array());
|
||||
$this->hashRateData = getXVal($this->hisBattleData, 'hash_rate_data', array());
|
||||
if (!$this->hashRateData){
|
||||
$this->hashRateData = array(
|
||||
'pvpData' => array(),
|
||||
@ -44,6 +50,27 @@ class HashRateService extends BaseService
|
||||
}
|
||||
$this->pvpBattleData = $this->hashRateData['pvpData'];
|
||||
$this->mobaBattleData = $this->hashRateData['mobaData'];
|
||||
|
||||
$this->serverTaskData = getXVal($this->hisBattleData, 'server_task_data', array());
|
||||
if (!$this->serverTaskData){
|
||||
$this->serverTaskData = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
);
|
||||
}
|
||||
$currentServerTask = \mt\ServerTaskTime::getCurrentTime();
|
||||
if ($currentServerTask && myself()->_getDaySeconds(getXVal($this->serverTaskData, 'modifytime', 0)) <
|
||||
myself()->_getDaySeconds(strtotime($currentServerTask['obtain_start_time']))) {
|
||||
$this->serverTaskData = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
);
|
||||
}
|
||||
$this->pvpBattleDataServerTask = $this->serverTaskData['pvpData'];
|
||||
$this->mobaBattleDataServerTask = $this->serverTaskData['mobaData'];
|
||||
}
|
||||
|
||||
public function hashRateTaskDto($taskMate ,$currentPeriod){
|
||||
@ -185,4 +212,54 @@ class HashRateService extends BaseService
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function serverTaskDto($taskMate){
|
||||
$taskDto = array(
|
||||
'task_id' => $taskMate['id'],
|
||||
'current' => 0,
|
||||
'target' => getXVal($taskMate, 'target', 1),
|
||||
'state' => self::NOT_FINISHED_STATE,
|
||||
);
|
||||
switch ($taskMate['condition']){
|
||||
case ServerTask::TOTAL_BATTLE_TIMES_COND : {
|
||||
$taskDto['current'] = $this->getServerTaskBattleData($taskMate,"total_battle_times");
|
||||
}
|
||||
break;
|
||||
case ServerTask::TOTAL_KILL_NUM_COND :{
|
||||
$taskDto['current'] = $this->getServerTaskBattleData($taskMate,"total_kills_times");
|
||||
}
|
||||
break;
|
||||
case ServerTask::TOTAL_DAMGE_OUT_COND :{
|
||||
$taskDto['current'] = $this->getServerTaskBattleData($taskMate,"total_damage_out");
|
||||
}
|
||||
break;
|
||||
case ServerTask::TOTAL_USE_SKILL_TIMES_COND :{
|
||||
$taskDto['current'] = $this->getServerTaskBattleData($taskMate,"use_skill_times");
|
||||
}
|
||||
}
|
||||
if ($taskDto['current'] >= $taskDto['target']) {
|
||||
$taskDto['current'] = $taskDto['target'];
|
||||
$taskDto['state'] = self::FINISHED_STATE;
|
||||
}
|
||||
return $taskDto;
|
||||
}
|
||||
|
||||
private function getServerTaskBattleData($taskMate, $key)
|
||||
{
|
||||
$val = 0;
|
||||
$battleData = $this->internalGetServerTaskBattleData($taskMate);
|
||||
$val = getXVal($battleData, $key, 0);
|
||||
return $val;
|
||||
}
|
||||
|
||||
private function internalGetServerTaskBattleData($taskMate)
|
||||
{
|
||||
$battleData = null;
|
||||
if ($taskMate['type'] == ServerTask::MOBA_TYPE) {
|
||||
$battleData = $this->mobaBattleDataServerTask;
|
||||
} else if ($taskMate['type'] == ServerTask::PVP_TYPE){
|
||||
$battleData = $this->pvpBattleDataServerTask;
|
||||
}
|
||||
return $battleData ? $battleData : array();
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ require_once('mt/RankSeason.php');
|
||||
require_once('mt/LevelUp.php');
|
||||
require_once('mt/StarLevel.php');
|
||||
require_once('mt/AchievementsCycle.php');
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Battle.php');
|
||||
@ -119,7 +120,7 @@ class TameBattleDataService extends BaseService {
|
||||
}
|
||||
|
||||
//记录算力系统有效行为
|
||||
$this->_updateHashRateData();
|
||||
$this->_updateHashRateData();die;
|
||||
|
||||
switch ($matchMode) {
|
||||
//PVP模式
|
||||
@ -167,6 +168,11 @@ class TameBattleDataService extends BaseService {
|
||||
myself()->_incDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0, 1);
|
||||
}
|
||||
break;
|
||||
case self::ROOM_MODE_MOBA :
|
||||
{
|
||||
$this->updateMobaData();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
@ -413,7 +419,6 @@ class TameBattleDataService extends BaseService {
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
|
||||
|
||||
if (myself()->_getDaySeconds($hisBattleData['today_data']['modifytime']) <
|
||||
myself()->_getNowDaySeconds()) {
|
||||
$hisBattleData['today_data'] = array(
|
||||
@ -1219,44 +1224,106 @@ class TameBattleDataService extends BaseService {
|
||||
private function _updateHashRateData(){
|
||||
error_log("_addHashRateTask");
|
||||
$hisBattleData = HashRateBattleData::getMyBattleData();
|
||||
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||
if ($currentPeriod){
|
||||
if (!isset($hisBattleData['data'])) {
|
||||
$hisBattleData['data'] = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
if (myself()->_getDaySeconds($hisBattleData['data']['modifytime']) <
|
||||
myself()->_getDaySeconds(strtotime($currentPeriod['obtain_start_time']) )) {
|
||||
$hisBattleData['data'] = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => $hisBattleData['data']['createtime'],
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
if ($currentPeriod && strtotime($currentPeriod['obtain_end_time']) > myself()->_getNowTime()){
|
||||
switch (getXVal($this->allInfo,'room_mode', 0)){
|
||||
case self::MATCH_MODE_PVP :{
|
||||
$this->applyEx($hisBattleData['data']['pvpData']);
|
||||
}
|
||||
break;
|
||||
case self::ROOM_MODE_MOBA :{
|
||||
$this->applyEx($hisBattleData['data']['mobaData']);
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
$hisBattleData['data']['modifytime'] = myself()->_getNowTime();
|
||||
}
|
||||
HashRateBattleData::add(json_encode($hisBattleData));
|
||||
//算力系统任务统计
|
||||
$currentHashRate= \mt\AchievementsCycle::getCurrentPeriod();
|
||||
if (!isset($hisBattleData['hash_rate_data'])) {
|
||||
$hisBattleData['hash_rate_data'] = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
if ($currentHashRate && myself()->_getDaySeconds($hisBattleData['hash_rate_data']['modifytime']) <
|
||||
myself()->_getDaySeconds(strtotime($currentHashRate['obtain_start_time']) )) {
|
||||
$hisBattleData['hash_rate_data'] = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => $hisBattleData['hash_rate_data']['createtime'],
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
|
||||
//服务器大事件任务统计
|
||||
$server_task_state = myself()->_getV(TN_SERVER_TASK_STATE,0);
|
||||
$currentServerTask = mt\ServerTaskTime::getCurrentTime();
|
||||
if (!isset($hisBattleData['server_task_data'])) {
|
||||
$hisBattleData['server_task_data'] = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
if ($currentServerTask && myself()->_getDaySeconds($hisBattleData['server_task_data']['modifytime']) <
|
||||
myself()->_getDaySeconds(strtotime($currentServerTask['obtain_start_time']))) {
|
||||
$hisBattleData['server_task_data'] = array(
|
||||
'pvpData' => array(),
|
||||
'mobaData' => array(),
|
||||
'createtime' => $hisBattleData['server_task_data']['createtime'],
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// if ($currentHashRate && strtotime($currentHashRate['obtain_end_time']) > myself()->_getNowTime()){
|
||||
// switch (getXVal($this->allInfo,'room_mode', 0)){
|
||||
// case self::MATCH_MODE_PVP :{
|
||||
// $this->applyEx($hisBattleData['data']['pvpData']);
|
||||
// }
|
||||
// break;
|
||||
// case self::ROOM_MODE_MOBA :{
|
||||
// $this->applyEx($hisBattleData['data']['mobaData']);
|
||||
// }
|
||||
// break;
|
||||
// default:{
|
||||
//
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// $hisBattleData['data']['modifytime'] = myself()->_getNowTime();
|
||||
// }
|
||||
|
||||
switch (getXVal($this->allInfo,'room_mode', 0)){
|
||||
case self::MATCH_MODE_PVP :{
|
||||
if (myself()->_getNowTime() > strtotime($currentHashRate['obtain_start_time']) &&
|
||||
strtotime($currentHashRate['obtain_end_time']) > myself()->_getNowTime()){
|
||||
$this->applyEx($hisBattleData['hash_rate_data']['pvpData']);
|
||||
$hisBattleData['hash_rate_data']['modifytime'] = myself()->_getNowTime();
|
||||
}
|
||||
if (! $server_task_state &&
|
||||
myself()->_getNowTime() > strtotime($currentServerTask['obtain_start_time']) &&
|
||||
myself()->_getNowTime() < strtotime($currentServerTask['obtain_end_time'])) {
|
||||
$this->applyEx($hisBattleData['server_task_data']['pvpData']);
|
||||
$hisBattleData['server_task_data']['modifytime'] = myself()->_getNowTime();
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case self::ROOM_MODE_MOBA :{
|
||||
if (myself()->_getNowTime() > strtotime($currentHashRate['obtain_start_time']) && strtotime($currentHashRate['obtain_end_time']) > myself()->_getNowTime()){
|
||||
$this->applyEx($hisBattleData['hash_rate_data']['mobaData']);
|
||||
$hisBattleData['hash_rate_data']['modifytime'] = myself()->_getNowTime();
|
||||
}
|
||||
if (! $server_task_state &&
|
||||
myself()->_getNowTime() > strtotime($currentServerTask['obtain_start_time']) &&
|
||||
myself()->_getNowTime() < strtotime($currentServerTask['obtain_end_time'])) {
|
||||
$this->applyEx($hisBattleData['server_task_data']['mobaData']);
|
||||
$hisBattleData['server_task_data']['modifytime'] = myself()->_getNowTime();
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
HashRateBattleData::add(json_encode($hisBattleData));
|
||||
|
||||
}
|
||||
|
||||
private function applyEx(&$battleData)
|
||||
@ -1299,8 +1366,11 @@ class TameBattleDataService extends BaseService {
|
||||
$this->incValue($battleData, 'total_win_times', 1);
|
||||
}
|
||||
//击杀
|
||||
$kills = getXVal($this->battleInfo,'kills', 0);
|
||||
$this->incValue($battleData, 'total_kills_times', $kills);
|
||||
$this->incValue($battleData, 'total_kills_times', getXVal($this->battleInfo,'kills', 0));
|
||||
//造成伤害
|
||||
$this->incValue($battleData, 'total_damage_out', getXVal($this->battleInfo,'damage_out', 0));
|
||||
//使用技能次数
|
||||
$this->incValue($battleData, 'use_skill_times', getXVal($this->battleInfo,'use_skill_times', 0));
|
||||
//道具使用
|
||||
$this->procWeaponsSlot($battleData);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user