1
This commit is contained in:
parent
49c8085b29
commit
c6b602ebf2
35
doc/HashRate.py
Normal file
35
doc/HashRate.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import _common
|
||||||
|
|
||||||
|
class HashRate(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.apis = [
|
||||||
|
{
|
||||||
|
'name': 'info',
|
||||||
|
'desc': '获取算力信息',
|
||||||
|
'group': 'ComputingPower',
|
||||||
|
'url': 'webapp/index.php?c=ComputingPower&a=info',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['!list', [HashRateList()], '行为列表'],
|
||||||
|
['obtain_end_time', 0, '获得期结束时间'],
|
||||||
|
['income_end_time', 0, '盈利期结束时间'],
|
||||||
|
['state', 0, '0:获得期 1:盈利期'],
|
||||||
|
['myHashRate', 0, '我的算力'],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class HashRateList(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.fields = [
|
||||||
|
['task_id', 0, '任务id'],
|
||||||
|
['current', 0, '当前进度'],
|
||||||
|
['target', 0, '目标进度'],
|
||||||
|
['state', 0, '1:完成 0:未完成'],
|
||||||
|
]
|
@ -1707,4 +1707,4 @@ CREATE TABLE `t_hash_rate_task` (
|
|||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `account_task_id` (`account_id`, `task_id`)
|
UNIQUE KEY `account_task_id` (`account_id`, `task_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
begin;
|
|
||||||
|
|
||||||
CREATE TABLE `t_hash_rate_task` (
|
|
||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
|
||||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
|
||||||
`task_id` int(11) NOT NULL COMMENT '配置表HashRateTask',
|
|
||||||
`season` int(11) NOT NULL DEFAULT '0' COMMENT 'taskId 为10003可用',
|
|
||||||
`record_total` int(64) NOT NULL DEFAULT '0' COMMENT '记录总数据',
|
|
||||||
`claim_day` int(64) NOT NULL DEFAULT '0' COMMENT '当天领取数据',
|
|
||||||
`claim_total` int(64) NOT NULL DEFAULT '0' COMMENT '领取总数据',
|
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
|
||||||
PRIMARY KEY (`idx`),
|
|
||||||
UNIQUE KEY `account_task_id` (`account_id`, `task_id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
||||||
|
|
||||||
insert into version (version) values(2023092001);
|
|
||||||
|
|
||||||
commit;
|
|
26
sql/gamedb2006_migrate_231228_01.sql
Normal file
26
sql/gamedb2006_migrate_231228_01.sql
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
CREATE TABLE `t_hash_rate_task` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`task_id` int(11) NOT NULL COMMENT '配置表id',
|
||||||
|
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
||||||
|
`total_num` int(64) NOT NULL DEFAULT '0' COMMENT '记录数据',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `account_task_id` (`account_id`, `task_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
CREATE TABLE `t_hash_rate_battle_data` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`battle_data` mediumblob COMMENT 'battle_data',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
insert into version (version) values(2023122801);
|
||||||
|
|
||||||
|
commit;
|
@ -419,7 +419,6 @@ class BaseAuthedController extends BaseController {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
$this->_incDailyV(TN_DAILY_GET_STAR_NUM, 0,$itemNum);
|
$this->_incDailyV(TN_DAILY_GET_STAR_NUM, 0,$itemNum);
|
||||||
HashRateTask::incRecordNum(HashRateTask::STAR_TYPE,$itemNum);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
41
webapp/controller/HashRateController.class.php
Normal file
41
webapp/controller/HashRateController.class.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
require_once('services/HashRateService.php');
|
||||||
|
|
||||||
|
require_once('mt/AchievementsPower.php');
|
||||||
|
require_once('mt/AchievementsCycle.php');
|
||||||
|
|
||||||
|
class HashRateController extends BaseAuthedController
|
||||||
|
{
|
||||||
|
private $hashRateService = null;
|
||||||
|
|
||||||
|
public function _handlePre()
|
||||||
|
{
|
||||||
|
parent::_handlePre();
|
||||||
|
$this->hashRateService = new services\HashRateService();
|
||||||
|
$this->hashRateService->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function info(){
|
||||||
|
$mateList = \mt\AchievementsPower::getMetaList();
|
||||||
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
|
$hashRateDtoList = array();
|
||||||
|
foreach ($mateList as $mate) {
|
||||||
|
$temp = $this->hashRateService->hashRateTaskDto($mate);
|
||||||
|
array_push($hashRateDtoList, $temp);
|
||||||
|
}
|
||||||
|
$obtain_end_time = strtotime($currentPeriod['obtain_end_time']);
|
||||||
|
$income_end_time = strtotime($currentPeriod['income_end_time']);
|
||||||
|
$state = 0;
|
||||||
|
if ($obtain_end_time < myself()->_getNowTime()){
|
||||||
|
$state = 1;
|
||||||
|
}
|
||||||
|
$this->_rspData(array(
|
||||||
|
'list' => $hashRateDtoList,
|
||||||
|
'obtain_end_time' => $obtain_end_time,
|
||||||
|
'income_end_time' => $income_end_time,
|
||||||
|
'state' => $state,
|
||||||
|
'myHashRate' => 0,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -56,7 +56,7 @@ class UserController extends BaseAuthedController {
|
|||||||
$this->createNewUserV2($userName);
|
$this->createNewUserV2($userName);
|
||||||
$this->_addFreeItem();
|
$this->_addFreeItem();
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
$this->_setBattleHero($userInfo);
|
// $this->_setBattleHero($userInfo);
|
||||||
// $this->_setV(TN_RANK_STATUS, 0, 1);
|
// $this->_setV(TN_RANK_STATUS, 0, 1);
|
||||||
//初始化芯片页
|
//初始化芯片页
|
||||||
$chipPageObj = new services\ChipPageService();
|
$chipPageObj = new services\ChipPageService();
|
||||||
@ -666,7 +666,6 @@ class UserController extends BaseAuthedController {
|
|||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
));
|
));
|
||||||
error_log(11111111111111111111111111);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUserHonor(){
|
public function setUserHonor(){
|
||||||
@ -708,6 +707,54 @@ class UserController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFreeItemList(){
|
||||||
|
$freeHero = mt\Parameter::getListValue('free_hero_list');
|
||||||
|
$this->_rspData([
|
||||||
|
'data'=>$freeHero
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectFreeItem(){
|
||||||
|
$itemId = getReqVal('itemId', '');
|
||||||
|
if (!$itemId){
|
||||||
|
$this->_rspErr(1, 'param is error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$heroMeta = mt\Item::get($itemId);
|
||||||
|
if (! $heroMeta || $heroMeta['type'] != \mt\Item::HERO_TYPE){
|
||||||
|
$this->_rspErr(1, 'itemId is error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
||||||
|
if ($heroMeta['hero_head'] && !in_array($heroMeta['hero_head'],$headList)){
|
||||||
|
array_push($headList,$heroMeta['hero_head']);
|
||||||
|
}
|
||||||
|
Hero::addFreeHero($heroMeta);
|
||||||
|
$heroUid = SqlHelper::getLastInsertId($this->_getSelfMysql());
|
||||||
|
$fields = array(
|
||||||
|
'hero_id' => $heroUid,
|
||||||
|
'head_id' => $heroMeta['hero_head'],
|
||||||
|
'head_frame' => 60000,
|
||||||
|
'head_list' => json_encode($headList),
|
||||||
|
'head_frame_list' => json_encode(array(60000)),
|
||||||
|
'is_gain_item' => 1,
|
||||||
|
);
|
||||||
|
User::update($fields);
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addUserChg();
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
$propertyChgService->addGunChg();
|
||||||
|
$this->_rspData([
|
||||||
|
'data'=>array(
|
||||||
|
'hero_id' => $itemId,
|
||||||
|
),
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function dampingElo($userInfo){
|
private function dampingElo($userInfo){
|
||||||
//每天elo衰减
|
//每天elo衰减
|
||||||
$time_diff = myself()->_getNowTime()-$userInfo['last_login_time'];
|
$time_diff = myself()->_getNowTime()-$userInfo['last_login_time'];
|
||||||
|
46
webapp/models/HashRateBattleData.php
Normal file
46
webapp/models/HashRateBattleData.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class HashRateBattleData extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public static function getMyBattleData()
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_battle_data',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row ? json_decode($row['battle_data'], true) : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function add($battleData)
|
||||||
|
{
|
||||||
|
SqlHelper::upsert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_battle_data',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'battle_data' => $battleData,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'battle_data' => $battleData,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -19,6 +19,27 @@ class HashRateTask extends BaseModel
|
|||||||
const VS_FOUR_BATTLE_WIN_TYPE = 10006;
|
const VS_FOUR_BATTLE_WIN_TYPE = 10006;
|
||||||
const DAMAGE_TYPE = 10007;
|
const DAMAGE_TYPE = 10007;
|
||||||
|
|
||||||
|
const MOBA_WIN_ID = 1;
|
||||||
|
const MOBA_KILL_ID = 2;
|
||||||
|
const MOBA_GATHER_GRENADE_ID = 3;
|
||||||
|
const MOBA_GATHER_BURNING_ID = 4;
|
||||||
|
const MOBA_GATHER_BLOOD_ID = 5;
|
||||||
|
const MOBA_BATTLE_END_ID =6;
|
||||||
|
const MOBA_FAST_UP_ID =7;
|
||||||
|
const MOBA_BATTLE_TIMES_ID =8;
|
||||||
|
const PVP_WIN_ID =9;
|
||||||
|
const PVP_LAST_RUNNER_ID =10;
|
||||||
|
const PVP_KILL_ID =11;
|
||||||
|
const PVP_GATHER_GRENADE_ID =12;
|
||||||
|
const PVP_GATHER_BURNING_ID =13;
|
||||||
|
const PVP_GATHER_BLOOD_ID =14;
|
||||||
|
const PVP_WALKING_DISTANCE_ID =16;
|
||||||
|
const PVP_BATTLE_TIMES_ID =17;
|
||||||
|
const HERO_UP_QUALITY_ID =18;
|
||||||
|
const OWN_HERO_NFT_ID =19;
|
||||||
|
const OWN_CHIP_NFT_ID =20;
|
||||||
|
const OWN_GOLD_ID =21;
|
||||||
|
|
||||||
public static function find(){
|
public static function find(){
|
||||||
$rows = SqlHelper::ormSelect(
|
$rows = SqlHelper::ormSelect(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
@ -50,24 +71,26 @@ class HashRateTask extends BaseModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function incRecordNum($taskId,$num){
|
public static function incRecordNum($period,$taskId,$num){
|
||||||
SqlHelper::upsert
|
SqlHelper::upsert
|
||||||
(myself()->_getSelfMysql(),
|
(myself()->_getSelfMysql(),
|
||||||
't_hash_rate_task',
|
't_hash_rate_task',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'period' => $period,
|
||||||
'task_id' => $taskId,
|
'task_id' => $taskId,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'record_total' => function () use($num) {
|
'total_num' => function () use($num) {
|
||||||
return "record_total + ${num}";
|
return "total_num + ${num}";
|
||||||
},
|
},
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'period' => $period,
|
||||||
'task_id' => $taskId,
|
'task_id' => $taskId,
|
||||||
'record_total' => $num,
|
'total_num' => $num,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
)
|
||||||
|
30
webapp/mt/AchievementsCycle.php
Normal file
30
webapp/mt/AchievementsCycle.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace mt;
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
|
||||||
|
class AchievementsCycle {
|
||||||
|
|
||||||
|
public static function getCurrentPeriod()
|
||||||
|
{
|
||||||
|
foreach (self::getMetaList() as $meta) {
|
||||||
|
if (myself()->_getNowTime() >= strtotime($meta['obtain_start_time']) &&
|
||||||
|
myself()->_getNowTime() <= strtotime($meta['income_end_time'])) {
|
||||||
|
return $meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMetaList()
|
||||||
|
{
|
||||||
|
if (!self::$metaList) {
|
||||||
|
self::$metaList = getMetaTable('AchievementsCycle@AchievementsCycle.php');
|
||||||
|
}
|
||||||
|
return self::$metaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static $metaList;
|
||||||
|
|
||||||
|
}
|
51
webapp/mt/AchievementsPower.php
Normal file
51
webapp/mt/AchievementsPower.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace mt;
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
|
||||||
|
class AchievementsPower {
|
||||||
|
const TOTAL_WINS_TIMES = 1; //获得胜利
|
||||||
|
const TOTAL_KILL_TIMES= 2; //击杀人数
|
||||||
|
const USE_ITEM_TIMES = 3; //使用X道具
|
||||||
|
const NOMINAL_TIME_BATTLE_END = 4; //X分钟内结算比赛
|
||||||
|
const IN_BATTLE_UP_LV= 5; //在局内升级最快次数
|
||||||
|
const TOTAL_BATTLE_TIMES = 6; //游戏场次
|
||||||
|
const TOTAL_LAST_RUNNER = 7; //最后一名次数
|
||||||
|
const RESCUE_TEAMMATE_TIMES = 8; //救援队友数
|
||||||
|
const WALKING_DISTANCE = 9; //累计行走距离(米)
|
||||||
|
const HERO_UP_QUALITY = 10; //指定英雄升阶数
|
||||||
|
const OWN_HERO_NFT_NUM = 11; //拥有英雄nft数
|
||||||
|
const OWN_CHIP_NFT_NUM = 12; //拥有芯片nft数
|
||||||
|
const OWN_GOLD_NUM = 13; //拥有金币数
|
||||||
|
|
||||||
|
const MOBA_SCENE = 1;
|
||||||
|
const PVP_SCENE = 2;
|
||||||
|
|
||||||
|
public static function find($id){
|
||||||
|
return getXVal(self::getMetaList(), $id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getListByType($type){
|
||||||
|
$mateList = array();
|
||||||
|
foreach (self::getMetaList() as $mate){
|
||||||
|
if ($mate['type'] == $type){
|
||||||
|
array_push($mateList,$mate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $mateList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function getMetaList()
|
||||||
|
{
|
||||||
|
if (!self::$metaList) {
|
||||||
|
self::$metaList = getMetaTable('AchievementsPower@AchievementsPower.php');
|
||||||
|
}
|
||||||
|
return self::$metaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static $metaList;
|
||||||
|
|
||||||
|
}
|
@ -1,93 +1,97 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace mt;
|
namespace mt;
|
||||||
|
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
|
|
||||||
class Equip {
|
class Equip {
|
||||||
|
|
||||||
public static function get($id)
|
const GRENADE_ID = 30202;
|
||||||
{
|
const INCENDIARY_GRENADE_ID = 30204;
|
||||||
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
|
// const INCENDIARY_GRENADE_ID = 30204;
|
||||||
}
|
|
||||||
|
public static function get($id)
|
||||||
public static function getGunBaseAttrs($id){
|
{
|
||||||
$mate = self::get($id);
|
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
|
||||||
$attr = array();
|
}
|
||||||
if ($mate){
|
|
||||||
$fields = [
|
public static function getGunBaseAttrs($id){
|
||||||
[//攻击力-固定值
|
$mate = self::get($id);
|
||||||
'attr_id' => kHAT_Atk,
|
$attr = array();
|
||||||
'type' => kHAT_ABS_VAL,
|
if ($mate){
|
||||||
'field_name' => 'atk'
|
$fields = [
|
||||||
],[//射速-固定值
|
[//攻击力-固定值
|
||||||
'attr_id' => kHAT_FireRate,
|
'attr_id' => kHAT_Atk,
|
||||||
'type' => kHAT_ABS_VAL,
|
'type' => kHAT_ABS_VAL,
|
||||||
'field_name' => 'fire_rate'
|
'field_name' => 'atk'
|
||||||
],[//弹夹-固定值
|
],[//射速-固定值
|
||||||
'attr_id' => kHAT_Volume,
|
'attr_id' => kHAT_FireRate,
|
||||||
'type' => kHAT_ABS_VAL,
|
'type' => kHAT_ABS_VAL,
|
||||||
'field_name' => 'clip_volume'
|
'field_name' => 'fire_rate'
|
||||||
],[//换弹-固定值
|
],[//弹夹-固定值
|
||||||
'attr_id' => kHAT_ReloadTime,
|
'attr_id' => kHAT_Volume,
|
||||||
'type' => kHAT_ABS_VAL,
|
'type' => kHAT_ABS_VAL,
|
||||||
'field_name' => 'reload_time'
|
'field_name' => 'clip_volume'
|
||||||
],[//射程-固定值
|
],[//换弹-固定值
|
||||||
'attr_id' => kHAT_ShotRange,
|
'attr_id' => kHAT_ReloadTime,
|
||||||
'type' => kHAT_ABS_VAL,
|
'type' => kHAT_ABS_VAL,
|
||||||
'field_name' => 'range'
|
'field_name' => 'reload_time'
|
||||||
],[//攻击吸血-百分比
|
],[//射程-固定值
|
||||||
'attr_id' => kHAT_BrainLifePct,
|
'attr_id' => kHAT_ShotRange,
|
||||||
'type' => kHAT_RATE_VAL,
|
'type' => kHAT_ABS_VAL,
|
||||||
'field_name' => 'brain_life_pct'
|
'field_name' => 'range'
|
||||||
],[//子弹飞行速度-固定值
|
],[//攻击吸血-百分比
|
||||||
'attr_id' => kHAT_BulletSpeed,
|
'attr_id' => kHAT_BrainLifePct,
|
||||||
'type' => kHAT_ABS_VAL,
|
'type' => kHAT_RATE_VAL,
|
||||||
'field_name' => 'bullet_speed'
|
'field_name' => 'brain_life_pct'
|
||||||
],
|
],[//子弹飞行速度-固定值
|
||||||
];
|
'attr_id' => kHAT_BulletSpeed,
|
||||||
foreach ($fields as $field) {
|
'type' => kHAT_ABS_VAL,
|
||||||
array_push($attr, array(
|
'field_name' => 'bullet_speed'
|
||||||
'attr_id' => $field['attr_id'],
|
],
|
||||||
'type' => $field['type'],
|
];
|
||||||
'val' => $mate[$field['field_name']]
|
foreach ($fields as $field) {
|
||||||
));
|
array_push($attr, array(
|
||||||
}
|
'attr_id' => $field['attr_id'],
|
||||||
}
|
'type' => $field['type'],
|
||||||
return $attr;
|
'val' => $mate[$field['field_name']]
|
||||||
}
|
));
|
||||||
|
}
|
||||||
public static function getOldEquip($id)
|
}
|
||||||
{
|
return $attr;
|
||||||
$meta = self::get($id);
|
}
|
||||||
return array(
|
|
||||||
'id' => $equip_conf['id'],
|
public static function getOldEquip($id)
|
||||||
'upgrade_priority' => $equip_conf['upgrade_priority'],
|
{
|
||||||
'equip_upgrade' => $equip_conf['equip_upgrade'],
|
$meta = self::get($id);
|
||||||
'level_gold_cost' => $equip_conf['level_gold_cost'],
|
return array(
|
||||||
'max_level' => $equip_conf['max_level'],
|
'id' => $equip_conf['id'],
|
||||||
'equip_upgradematerial' => $equip_conf['equip_upgradematerial'],
|
'upgrade_priority' => $equip_conf['upgrade_priority'],
|
||||||
'equip_upgradetime' => $equip_conf['equip_upgradetime'],
|
'equip_upgrade' => $equip_conf['equip_upgrade'],
|
||||||
'diamond_cost' => $equip_conf['diamond_cost'],
|
'level_gold_cost' => $equip_conf['level_gold_cost'],
|
||||||
'drop_id' => $equip_conf['drop_id'],
|
'max_level' => $equip_conf['max_level'],
|
||||||
'reduce_time' => $equip_conf['reduce_time'],
|
'equip_upgradematerial' => $equip_conf['equip_upgradematerial'],
|
||||||
'diamond_time' => $equip_conf['diamond_time'],
|
'equip_upgradetime' => $equip_conf['equip_upgradetime'],
|
||||||
'upgrade_gold' => $equip_conf['upgrade_gold'],
|
'diamond_cost' => $equip_conf['diamond_cost'],
|
||||||
'promote_gold' => $equip_conf['promote_gold'],
|
'drop_id' => $equip_conf['drop_id'],
|
||||||
'promote_material' => $equip_conf['promote_material'],
|
'reduce_time' => $equip_conf['reduce_time'],
|
||||||
'real_index_id' => $equip_conf['real_index_id'],
|
'diamond_time' => $equip_conf['diamond_time'],
|
||||||
'promote_gold' => $equip_conf['promote_gold'],
|
'upgrade_gold' => $equip_conf['upgrade_gold'],
|
||||||
);
|
'promote_gold' => $equip_conf['promote_gold'],
|
||||||
}
|
'promote_material' => $equip_conf['promote_material'],
|
||||||
|
'real_index_id' => $equip_conf['real_index_id'],
|
||||||
protected static function getMetaList()
|
'promote_gold' => $equip_conf['promote_gold'],
|
||||||
{
|
);
|
||||||
if (!self::$metaList) {
|
}
|
||||||
self::$metaList = getMetaTable('equip@equip.php');
|
|
||||||
}
|
protected static function getMetaList()
|
||||||
return self::$metaList;
|
{
|
||||||
}
|
if (!self::$metaList) {
|
||||||
|
self::$metaList = getMetaTable('equip@equip.php');
|
||||||
protected static $metaList;
|
}
|
||||||
|
return self::$metaList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static $metaList;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -11,11 +11,14 @@ require_once('models/Bag.php');
|
|||||||
require_once('models/CrystalRecord.php');
|
require_once('models/CrystalRecord.php');
|
||||||
require_once('models/Staking.php');
|
require_once('models/Staking.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRateTask.php');
|
||||||
|
require_once('models/HashRateBattleData.php');
|
||||||
|
|
||||||
use models\Bag;
|
use models\Bag;
|
||||||
use models\CrystalRecord;
|
use models\CrystalRecord;
|
||||||
|
use models\HashRateBattleData;
|
||||||
use models\Staking;
|
use models\Staking;
|
||||||
use models\HashRateTask;
|
use models\HashRateTask;
|
||||||
|
use mt\AchievementsPower;
|
||||||
use mt\HashRate;
|
use mt\HashRate;
|
||||||
use mt\Parameter;
|
use mt\Parameter;
|
||||||
use mt\Rank;
|
use mt\Rank;
|
||||||
@ -23,9 +26,161 @@ use mt\RankSeason;
|
|||||||
|
|
||||||
class HashRateService extends BaseService
|
class HashRateService extends BaseService
|
||||||
{
|
{
|
||||||
|
const FINISHED_STATE = 1;
|
||||||
|
const NOT_FINISHED_STATE = 0;
|
||||||
|
|
||||||
|
private $hisBattleData = array();
|
||||||
|
private $hashRateData = array();
|
||||||
|
private $mobaBattleData = array();
|
||||||
|
private $pvpBattleData = array();
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->hisBattleData = HashRateBattleData::getMyBattleData();
|
||||||
|
$this->hashRateData = getXVal($this->hisBattleData, 'data', array());
|
||||||
|
// $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
|
// if (myself()->_getDaySeconds(getXVal($this->hashRateData, 'modifytime', 0)) <
|
||||||
|
// myself()->_getDaySeconds($currentPeriod['obtain_end_time'])) {
|
||||||
|
// $this->hashRateData = array(
|
||||||
|
// 'pvpData' => array(),
|
||||||
|
// 'mobaData' => array(),
|
||||||
|
// 'createtime' => myself()->_getNowTime(),
|
||||||
|
// 'modifytime' => myself()->_getNowTime(),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
if (!$this->hashRateData){
|
||||||
|
$this->hashRateData = array(
|
||||||
|
'pvpData' => array(),
|
||||||
|
'mobaData' => array(),
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->pvpBattleData = $this->hashRateData['pvpData'];
|
||||||
|
$this->mobaBattleData = $this->hashRateData['mobaData'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hashRateTaskDto($taskMate){
|
||||||
|
$taskDto = array(
|
||||||
|
'task_id' => $taskMate['id'],
|
||||||
|
'current' => 0,
|
||||||
|
'target' => getXVal($taskMate, 'Completed_quantity', 1),
|
||||||
|
'state' => self::NOT_FINISHED_STATE,
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($taskMate['Completion_type']){
|
||||||
|
//吃鸡或4v4获得胜利
|
||||||
|
case AchievementsPower::TOTAL_WINS_TIMES : {
|
||||||
|
$taskDto['current'] = $this->getBattleData($taskMate,
|
||||||
|
'total_win_times');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//击杀人数
|
||||||
|
case AchievementsPower::TOTAL_KILL_TIMES : {
|
||||||
|
$taskDto['current'] = $this->getBattleData($taskMate,
|
||||||
|
'total_kills_times');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//使用X道具
|
||||||
|
case AchievementsPower::USE_ITEM_TIMES : {
|
||||||
|
$taskDto['current'] = $this->getWeaponsSlotData($taskMate);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//X分钟内结束比赛
|
||||||
|
case AchievementsPower::NOMINAL_TIME_BATTLE_END : {
|
||||||
|
//....
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//在局内升级最快次数
|
||||||
|
case AchievementsPower::IN_BATTLE_UP_LV : {
|
||||||
|
//.....
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//游戏场次
|
||||||
|
case AchievementsPower::TOTAL_BATTLE_TIMES : {
|
||||||
|
$taskDto['current'] = $this->getBattleData($taskMate,
|
||||||
|
'total_battle_times');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//最后一名次数
|
||||||
|
case AchievementsPower::TOTAL_LAST_RUNNER : {
|
||||||
|
$taskDto['current'] = $this->getBattleData($taskMate,
|
||||||
|
'total_last_runner_times');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//救援队友数
|
||||||
|
case AchievementsPower::RESCUE_TEAMMATE_TIMES : {
|
||||||
|
$taskDto['current'] = $this->getBattleData($taskMate,
|
||||||
|
'total_rescue_times');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//累计行走距离(米)
|
||||||
|
case AchievementsPower::WALKING_DISTANCE : {
|
||||||
|
//.../
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//指定英雄升阶数
|
||||||
|
case AchievementsPower::HERO_UP_QUALITY : {
|
||||||
|
//..../
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//拥有英雄nft数
|
||||||
|
case AchievementsPower::OWN_HERO_NFT_NUM : {
|
||||||
|
//...../
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//拥有芯片nft数
|
||||||
|
case AchievementsPower::OWN_CHIP_NFT_NUM : {
|
||||||
|
//....../
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//拥有金币数
|
||||||
|
case AchievementsPower::OWN_GOLD_NUM : {
|
||||||
|
//......./
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($taskDto['current'] >= $taskDto['target']) {
|
||||||
|
$taskDto['current'] = $taskDto['target'];
|
||||||
|
}
|
||||||
|
return $taskDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getBattleData($taskMate, $key)
|
||||||
|
{
|
||||||
|
$val = 0;
|
||||||
|
$battleData = $this->internalGetBattleData($taskMate);
|
||||||
|
$val = getXVal($battleData, $key, 0);
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function internalGetBattleData($taskMate)
|
||||||
|
{
|
||||||
|
$battleData = null;
|
||||||
|
if ($taskMate['scene'] == AchievementsPower::PVP_SCENE) {
|
||||||
|
$battleData = $this->pvpBattleData;
|
||||||
|
} else if ($taskMate['scene'] == AchievementsPower::MOBA_SCENE){
|
||||||
|
$battleData = $this->mobaBattleData;
|
||||||
|
}
|
||||||
|
return $battleData ? $battleData : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getWeaponsSlotData($taskMate){
|
||||||
|
$val = 0;
|
||||||
|
$battleData = $this->internalGetBattleData($taskMate);
|
||||||
|
$slotData = $battleData['weapons_slot_data'] ? $battleData['weapons_slot_data'] : array();
|
||||||
|
if (array_key_exists($taskMate['condition'],$slotData)){
|
||||||
|
$val = $slotData[$taskMate['condition']];
|
||||||
|
}
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------以下弃用---------------------------
|
||||||
const NONE_STATE = 0;
|
const NONE_STATE = 0;
|
||||||
const RECEIVED_STATE = 1;
|
const RECEIVED_STATE = 1;
|
||||||
const EXCHANGE_RATE = 10;
|
const EXCHANGE_RATE = 10;
|
||||||
|
//弃用
|
||||||
public function getCrystalDto($crystalMeta,&$crystalDto){
|
public function getCrystalDto($crystalMeta,&$crystalDto){
|
||||||
$crystalDto = array(
|
$crystalDto = array(
|
||||||
'item_id' => $crystalMeta['id'],
|
'item_id' => $crystalMeta['id'],
|
||||||
@ -107,6 +262,7 @@ class HashRateService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//弃用
|
||||||
public function getCrystalValue(){
|
public function getCrystalValue(){
|
||||||
$chaimNum = 0;
|
$chaimNum = 0;
|
||||||
$playing = array();
|
$playing = array();
|
||||||
|
@ -16,6 +16,7 @@ require_once('mt/PveGeminiMode.php');
|
|||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('mt/LevelUp.php');
|
require_once('mt/LevelUp.php');
|
||||||
require_once('mt/StarLevel.php');
|
require_once('mt/StarLevel.php');
|
||||||
|
require_once('mt/AchievementsCycle.php');
|
||||||
|
|
||||||
require_once('models/Season.php');
|
require_once('models/Season.php');
|
||||||
require_once('models/Battle.php');
|
require_once('models/Battle.php');
|
||||||
@ -32,6 +33,7 @@ require_once('models/FragmentRecord.php');
|
|||||||
require_once('models/BattleSettlement.php');
|
require_once('models/BattleSettlement.php');
|
||||||
require_once('models/RankBattle.php');
|
require_once('models/RankBattle.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRateTask.php');
|
||||||
|
require_once('models/HashRateBattleData.php');
|
||||||
|
|
||||||
require_once('services/RankActivityService.php');
|
require_once('services/RankActivityService.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
@ -54,6 +56,7 @@ use phpcommon;
|
|||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\Season;
|
use models\Season;
|
||||||
use models\Battle;
|
use models\Battle;
|
||||||
|
use models\HashRateBattleData;
|
||||||
use models\Bag;
|
use models\Bag;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\Gun;
|
use models\Gun;
|
||||||
@ -69,6 +72,7 @@ class TameBattleDataService extends BaseService {
|
|||||||
|
|
||||||
const ROOM_MODE_PVP = 0;
|
const ROOM_MODE_PVP = 0;
|
||||||
const ROOM_MODE_PVE = 1;
|
const ROOM_MODE_PVE = 1;
|
||||||
|
const ROOM_MODE_MOBA = 2;
|
||||||
|
|
||||||
const MATCH_MODE_PVP = 0;
|
const MATCH_MODE_PVP = 0;
|
||||||
const MATCH_MODE_RANK = 1;
|
const MATCH_MODE_RANK = 1;
|
||||||
@ -115,7 +119,7 @@ class TameBattleDataService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//记录算力系统有效行为
|
//记录算力系统有效行为
|
||||||
$this->_addHashRateTask();
|
$this->_updateHashRateData();
|
||||||
|
|
||||||
switch ($matchMode) {
|
switch ($matchMode) {
|
||||||
//PVP模式
|
//PVP模式
|
||||||
@ -1221,20 +1225,81 @@ class TameBattleDataService extends BaseService {
|
|||||||
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
|
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _addHashRateTask(){
|
private function _updateHashRateData(){
|
||||||
error_log("_addHashRateTask");
|
error_log("_addHashRateTask");
|
||||||
//击杀
|
$hisBattleData = HashRateBattleData::getMyBattleData();
|
||||||
HashRateTask::incRecordNum(HashRateTask::KILL_TYPE,getXVal($this->battleInfo,'kills', 0));
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
//存活时间、战斗时长
|
if (!isset($hisBattleData['data'])) {
|
||||||
HashRateTask::incRecordNum(HashRateTask::BATTLE_TIME_TYPE,getXVal($this->battleInfo,'alive_time', 0));
|
$hisBattleData['data'] = array(
|
||||||
//吃鸡、4v4吃鸡
|
'pvpData' => array(),
|
||||||
$ranked = getXVal($this->battleInfo,'pvp_team_rank', 0);
|
'mobaData' => array(),
|
||||||
if ($ranked == 1){
|
'createtime' => myself()->_getNowTime(),
|
||||||
HashRateTask::incRecordNum(HashRateTask::BATTLE_WIN_TYPE,1);
|
'modifytime' => myself()->_getNowTime()
|
||||||
// HashRateTask::incRecordNum(HashRateTask::VS_FOUR_BATTLE_WIN_TYPE,1);
|
);
|
||||||
}
|
}
|
||||||
//承伤
|
if (myself()->_getDaySeconds($hisBattleData['data']['modifytime']) <
|
||||||
HashRateTask::incRecordNum(HashRateTask::DAMAGE_TYPE,getXVal($this->battleInfo,'damage_in', 0));
|
myself()->_getDaySeconds($currentPeriod['obtain_end_time'])) {
|
||||||
|
$hisBattleData['data'] = array(
|
||||||
|
'pvpData' => array(),
|
||||||
|
'mobaData' => array(),
|
||||||
|
'createtime' => $hisBattleData['data']['createtime'],
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($currentPeriod && $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));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyEx(&$battleData)
|
||||||
|
{
|
||||||
|
//战斗次数
|
||||||
|
$this->incValue($battleData, 'total_battle_times', 1);
|
||||||
|
//排名
|
||||||
|
$ranked = 0;
|
||||||
|
switch (getXVal($this->allInfo,'room_mode', 0)){
|
||||||
|
case self::MATCH_MODE_PVP :{
|
||||||
|
$ranked = getXVal($this->battleInfo,'pvp_team_rank', 0);
|
||||||
|
if ($ranked == 40){
|
||||||
|
$this->incValue($battleData, 'total_last_runner_times', 1);
|
||||||
|
}
|
||||||
|
//救援次数
|
||||||
|
$this->incValue($battleData, 'total_rescue_times', getXVal($this->battleInfo,'rescue_teammate_times', 0));
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case self::ROOM_MODE_MOBA :{
|
||||||
|
/*
|
||||||
|
排名
|
||||||
|
几分钟结束战斗
|
||||||
|
第一个升满级
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($ranked == 1){
|
||||||
|
$this->incValue($battleData, 'total_win_times', 1);
|
||||||
|
}
|
||||||
|
//击杀
|
||||||
|
$kills = getXVal($this->battleInfo,'kills', 0);
|
||||||
|
$this->incValue($battleData, 'total_kills_times', $kills);
|
||||||
|
//道具使用
|
||||||
|
$this->procWeaponsSlot($battleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user