选择免费英雄枪械
This commit is contained in:
parent
475fc2494f
commit
403781da69
@ -46,5 +46,32 @@ class Ranking(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['ranking_list', _common.RankingListEx(), '排行榜数据']
|
['ranking_list', _common.RankingListEx(), '排行榜数据']
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'getRankStatus',
|
||||||
|
'desc': '获得排位的状态',
|
||||||
|
'group': 'Ranking',
|
||||||
|
'url': 'webapp/index.php?c=Ranking&a=getRankStatus',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['status', 0, '0:常规状态 1:引导初始排位 2:赛季初,需结算上个赛季'],
|
||||||
|
['is_rank', 0, '赛季是否空挡期 1:是 0:不是']
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'resetRankGainAward',
|
||||||
|
'desc': '重置段位获取赛季奖励',
|
||||||
|
'group': 'Ranking',
|
||||||
|
'url': 'webapp/index.php?c=Ranking&a=resetRankGainAward',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
14
doc/User.py
14
doc/User.py
@ -134,5 +134,19 @@ class User(object):
|
|||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
|
},{
|
||||||
|
'name': 'selectFreeItem',
|
||||||
|
'desc': '选择免费英雄和武器',
|
||||||
|
'group': 'User',
|
||||||
|
'url': 'webapp/index.php?c=User&a=selectFreeItem',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['hero_id', '', '英雄 item id']
|
||||||
|
['gun_id', '', '枪械 item id']
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||||
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -59,6 +59,7 @@ CREATE TABLE `t_user` (
|
|||||||
`best_rank_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT 'bestrank修改时间',
|
`best_rank_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT 'bestrank修改时间',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
`last_login_time` int(11) NOT NULL DEFAULT '0' COMMENT '上次登录时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `account_id` (`account_id`),
|
UNIQUE KEY `account_id` (`account_id`),
|
||||||
KEY `channel` (`channel`)
|
KEY `channel` (`channel`)
|
||||||
|
@ -22,6 +22,7 @@ define('TN_HERO_MAX_LEVEL', 8008);
|
|||||||
define('TN_GUN_MAX_LEVEL', 80008);
|
define('TN_GUN_MAX_LEVEL', 80008);
|
||||||
define('TN_HERO_MAX_QUALITY', 8009);
|
define('TN_HERO_MAX_QUALITY', 8009);
|
||||||
define('TN_GUN_MAX_QUALITY', 80009);
|
define('TN_GUN_MAX_QUALITY', 80009);
|
||||||
|
define('TN_RANK_STATUS', 99999);
|
||||||
define('TN_END', 8007);
|
define('TN_END', 8007);
|
||||||
|
|
||||||
define('TN_DAILY_BEGIN', 9001);
|
define('TN_DAILY_BEGIN', 9001);
|
||||||
|
@ -11,13 +11,14 @@ require_once('services/PropertyChgService.php');
|
|||||||
require_once('services/LogService.php');
|
require_once('services/LogService.php');
|
||||||
require_once('services/SeasonService.php');
|
require_once('services/SeasonService.php');
|
||||||
|
|
||||||
|
require_once('models/Season.php');
|
||||||
|
|
||||||
use models\Chip;
|
use models\Chip;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\Gun;
|
use models\Gun;
|
||||||
use models\User;
|
use models\User;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
|
use models\Season;
|
||||||
use services\FormulaService;
|
use services\FormulaService;
|
||||||
use services\LogService;
|
use services\LogService;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
@ -576,7 +577,6 @@ class ChipController extends BaseAuthedController
|
|||||||
|
|
||||||
// $this->chipDetails();
|
// $this->chipDetails();
|
||||||
// $arr = [30900=>2,31000=>6,31100=>4];
|
// $arr = [30900=>2,31000=>6,31100=>4];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
|
require_once('models/Season.php');
|
||||||
|
|
||||||
require_once('mt/RankActivity.php');
|
require_once('mt/RankActivity.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
use models\User;
|
use models\User;
|
||||||
|
use models\Season;
|
||||||
|
|
||||||
class RankingController extends BaseAuthedController {
|
class RankingController extends BaseAuthedController {
|
||||||
|
|
||||||
|
public function getRankStatus(){
|
||||||
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||||
|
if($currSeasonMeta){
|
||||||
|
$this->_setV(TN_RANK_STATUS, 1, 1);
|
||||||
|
if ($currSeasonMeta['id'] != $userInfo['last_season_id']){
|
||||||
|
$this->_setV(TN_RANK_STATUS, 0, 2);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$this->_setV(TN_RANK_STATUS, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$rank_status = $this->_getV(TN_RANK_STATUS, 0 );
|
||||||
|
$is_rank = $this->_getV(TN_RANK_STATUS, 1 );
|
||||||
|
$this->_rspData(array(
|
||||||
|
'status' => $rank_status, // 0:常规状态 1:引导初始排位 2:赛季初,需结算上个赛季
|
||||||
|
'is_rank' => $is_rank //赛季是否空挡期
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function rankingList()
|
public function rankingList()
|
||||||
{
|
{
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
@ -89,6 +111,39 @@ class RankingController extends BaseAuthedController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resetRankGainAward(){
|
||||||
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||||
|
if ($currSeasonMeta && $currSeasonMeta['id'] > $userInfo['last_season_id']) {
|
||||||
|
$rank = $userInfo['rank'];
|
||||||
|
for ($i=$userInfo['last_season_id'];$i<$currSeasonMeta['id'];$i++){
|
||||||
|
$currRankMeta = mt\Rank::getRankById($rank);
|
||||||
|
$dropRankMeta = mt\Rank::getRankById($currRankMeta ? $currRankMeta['next_season'] : 1);
|
||||||
|
$rank= $dropRankMeta['id'];
|
||||||
|
$award = Season::seasonReward($currRankMeta);
|
||||||
|
}
|
||||||
|
//掉段
|
||||||
|
if ($dropRankMeta) {
|
||||||
|
myself()->_updateUserInfo(array(
|
||||||
|
'rank' => $dropRankMeta['id'],
|
||||||
|
'score' => $dropRankMeta['rank_score'],
|
||||||
|
'last_season_id' => $currSeasonMeta['id'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$awardService = new services\AwardService();
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addUserChg();
|
||||||
|
$propertyChgService->addBagChg();
|
||||||
|
if ($award){
|
||||||
|
$this->_addItems($award,$awardService,$propertyChgService);
|
||||||
|
}
|
||||||
|
$this->_setV(TN_RANK_STATUS, 0, 0);
|
||||||
|
$this->_rspData([
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function internalGetActivityRankData($type)
|
private function internalGetActivityRankData($type)
|
||||||
{
|
{
|
||||||
$channel = 6516;
|
$channel = 6516;
|
||||||
|
@ -4,6 +4,7 @@ require_once('models/User.php');
|
|||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/Season.php');
|
require_once('models/Season.php');
|
||||||
require_once('models/Nft.php');
|
require_once('models/Nft.php');
|
||||||
|
require_once('models/Gun.php');
|
||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Drop.php');
|
require_once('mt/Drop.php');
|
||||||
@ -20,6 +21,7 @@ require_once('services/NameService.php');
|
|||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\User;
|
use models\User;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
|
use models\Gun;
|
||||||
use models\Season;
|
use models\Season;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
|
|
||||||
@ -38,16 +40,33 @@ class UserController extends BaseAuthedController {
|
|||||||
$avatarUrl = '18003';
|
$avatarUrl = '18003';
|
||||||
|
|
||||||
$userInfo = $this->_safeGetOrmUserInfo();
|
$userInfo = $this->_safeGetOrmUserInfo();
|
||||||
if (!$userInfo) {
|
if (SERVER_ENV == _ONLINE) {
|
||||||
$this->createNewUser($userName, $avatarUrl);
|
//测试服
|
||||||
|
if (!$userInfo) {
|
||||||
$this->addChip();
|
$this->createNewUserV2($userName);
|
||||||
|
$this->addChip(); //测试需要,上线要删除
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
}
|
$this->_setV(TN_RANK_STATUS, 0, 1);
|
||||||
if (!$this->loginCheck($userInfo)) {
|
}
|
||||||
|
//elo 衰减
|
||||||
|
$this->checkElo($userInfo);
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
//跟新登录时间
|
||||||
|
$this->_updateUserInfo(array(
|
||||||
|
'last_login_time'=>myself()->_getNowTime(),
|
||||||
|
));
|
||||||
|
}else{
|
||||||
|
if (!$userInfo) {
|
||||||
|
$this->createNewUser($userName, $avatarUrl);
|
||||||
|
$this->addChip(); //测试需要,上线要删除
|
||||||
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
$this->_setV(TN_RANK_STATUS, 0, 1);
|
||||||
|
}
|
||||||
|
if (!$this->loginCheck($userInfo)) {
|
||||||
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'info' => User::show($userInfo)
|
'info' => User::show($userInfo)
|
||||||
));
|
));
|
||||||
@ -225,6 +244,7 @@ class UserController extends BaseAuthedController {
|
|||||||
'best_rank_modifytime' => $this->_getNowTime(),
|
'best_rank_modifytime' => $this->_getNowTime(),
|
||||||
'createtime' => $this->_getNowTime(),
|
'createtime' => $this->_getNowTime(),
|
||||||
'modifytime' => $this->_getNowTime(),
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
'last_login_time' => $this->_getNowTime(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$awardService = new services\AwardService();
|
$awardService = new services\AwardService();
|
||||||
@ -398,8 +418,8 @@ class UserController extends BaseAuthedController {
|
|||||||
$reqVal = getReqVal($key, '');
|
$reqVal = getReqVal($key, '');
|
||||||
if (!empty($reqVal)) {
|
if (!empty($reqVal)) {
|
||||||
if (isset($field['valid_func'])) {
|
if (isset($field['valid_func'])) {
|
||||||
if (!$field['valid_func']($reqVal, $errCode, $errMsg)) {
|
if (!$field['valid_func']($reqVal, $errCod, $errMsg)) {
|
||||||
$this->_rspErr($errCode, $errMsg);
|
$this->_rspErr($errCod, $errMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$fieldsKv[$field['field_name']] = $field['val_func']($reqVal);
|
$fieldsKv[$field['field_name']] = $field['val_func']($reqVal);
|
||||||
@ -571,7 +591,97 @@ class UserController extends BaseAuthedController {
|
|||||||
'elo' => $initEloParameterMeta ? $initEloParameterMeta['param_value'] : 0,
|
'elo' => $initEloParameterMeta ? $initEloParameterMeta['param_value'] : 0,
|
||||||
);
|
);
|
||||||
User::update($fields);
|
User::update($fields);
|
||||||
|
$this->_setV(TN_RANK_STATUS, 0, 0);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function selectFreeItem(){
|
||||||
|
$hero_id = getReqVal('hero_id', '');
|
||||||
|
$gun_id = getReqVal('gun_id', '');
|
||||||
|
if (!$hero_id || !$gun_id){
|
||||||
|
$this->_rspErr(1, 'param is error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$heroMeta = mt\Item::get($hero_id);
|
||||||
|
if (! $heroMeta){
|
||||||
|
$this->_rspErr(1, 'hero_id is error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$gunMeta = mt\Item::get($gun_id);
|
||||||
|
if (! $gunMeta){
|
||||||
|
$this->_rspErr(1, 'gun_id is error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$temp = explode('|',$heroMeta['normal_gift']);
|
||||||
|
$headList = array();
|
||||||
|
if ($heroMeta['normal_gift']){
|
||||||
|
array_push($headList,$heroMeta['normal_gift']);
|
||||||
|
}
|
||||||
|
Hero::addHero($heroMeta);
|
||||||
|
Gun::addGun($gunMeta);
|
||||||
|
$fields = array(
|
||||||
|
'hero_id' => $temp ? $temp[1] : 0,
|
||||||
|
'head_id' => $temp ? $temp[0] : 0,
|
||||||
|
'head_frame' => 60000,
|
||||||
|
'head_list' => json_encode($headList),
|
||||||
|
'head_frame_list' => json_encode(array(60000)),
|
||||||
|
);
|
||||||
|
User::update($fields);
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addUserChg();
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
$propertyChgService->addGunChg();
|
||||||
|
$this->_rspData([
|
||||||
|
'data'=>array(
|
||||||
|
'hero_id' => $hero_id,
|
||||||
|
'gun_id' => $gun_id,
|
||||||
|
),
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkElo($userInfo){
|
||||||
|
$time_diff = myself()->_getNowTime()-$userInfo['last_login_time'];
|
||||||
|
if ($userInfo['elo'] > 1500 && floor($time_diff/86400) > 0){
|
||||||
|
$newElo = min(round(pow(log10(floor($time_diff/86400)),1.5)*350),450);
|
||||||
|
$this->_updateUserInfo(array(
|
||||||
|
'elo' => $userInfo['elo'] - $newElo
|
||||||
|
));
|
||||||
|
// $userInfo = $this->_getOrmUserInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createNewUserV2($userName){
|
||||||
|
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||||
|
if (!$currSeasonMeta){
|
||||||
|
$time = $this->_getNowTime() + (86400*10);
|
||||||
|
$currSeasonMeta = mt\RankSeason::getSeasonByTime($time);
|
||||||
|
}
|
||||||
|
SqlHelper::upsert
|
||||||
|
($this->_getSelfMysql(),
|
||||||
|
't_user',
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'channel' => $this->_getChannel(),
|
||||||
|
'name' => $userName,
|
||||||
|
'sex' => rand() % 2,
|
||||||
|
'gold' => 0,
|
||||||
|
'diamond' => 0,
|
||||||
|
'level' => 1,
|
||||||
|
'exp' => 0,
|
||||||
|
'last_season_id' => $currSeasonMeta ? $currSeasonMeta['id'] : 0,
|
||||||
|
'score_modifytime' => $this->_getNowTime(),
|
||||||
|
'best_rank_modifytime' => $this->_getNowTime(),
|
||||||
|
'createtime' => $this->_getNowTime(),
|
||||||
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
'last_login_time' => $this->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ class Season extends BaseModel {
|
|||||||
foreach ($rewards as $reward){
|
foreach ($rewards as $reward){
|
||||||
$temp = explode(',',$reward);
|
$temp = explode(',',$reward);
|
||||||
array_push($rewardList,array(
|
array_push($rewardList,array(
|
||||||
'reward_id' => $temp[0],
|
'item_id' => $temp[0],
|
||||||
'reward_num' => $temp[1],
|
'item_num' => $temp[1],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return $rewardList;
|
return $rewardList;
|
||||||
|
@ -30,6 +30,17 @@ class RankSeason
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getSeasonByTime($time)
|
||||||
|
{
|
||||||
|
foreach (self::getMetaList() as $meta) {
|
||||||
|
if ($time >= strtotime($meta['start_time']) &&
|
||||||
|
$time <= strtotime($meta['end_time'])) {
|
||||||
|
return $meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static $metaList;
|
protected static $metaList;
|
||||||
}
|
}
|
@ -5,9 +5,11 @@ namespace services;
|
|||||||
require_once('mt/Rank.php');
|
require_once('mt/Rank.php');
|
||||||
require_once('mt/Season.php');
|
require_once('mt/Season.php');
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
|
require_once('models/Season.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use models\User;
|
use models\User;
|
||||||
|
use models\Season;
|
||||||
|
|
||||||
class SeasonService extends BaseService {
|
class SeasonService extends BaseService {
|
||||||
|
|
||||||
@ -28,12 +30,31 @@ class SeasonService extends BaseService {
|
|||||||
}
|
}
|
||||||
if ($initRankMeta && $userInfo['rank'] < $initRankMeta['rank']) {
|
if ($initRankMeta && $userInfo['rank'] < $initRankMeta['rank']) {
|
||||||
myself()->_updateUserInfo(array(
|
myself()->_updateUserInfo(array(
|
||||||
'rank' => $initRankMeta['rank'],
|
'rank' => $initRankMeta['rank'],
|
||||||
'score' => $initRankMeta['min_score'],
|
'score' => $initRankMeta['min_score'],
|
||||||
));
|
));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//赛季结束后奖励及重置排位段位
|
||||||
|
public function seasonAward($userInfo){
|
||||||
|
$currRankMeta = mt\Rank::getRankById($userInfo['rank']);
|
||||||
|
$dropRankMeta = mt\Rank::getRankById($currRankMeta ? $currRankMeta['next_season'] : 1);
|
||||||
|
$award =array();
|
||||||
|
if ($currRankMeta){
|
||||||
|
$award = Season::seasonReward($currRankMeta);
|
||||||
|
if ($dropRankMeta) {
|
||||||
|
myself()->_updateUserInfo(array(
|
||||||
|
'rank' => $dropRankMeta['id'],
|
||||||
|
'score' => $dropRankMeta['rank_score'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $award;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user