星星之路结算
This commit is contained in:
parent
d86af0711b
commit
4e35738a6d
84
doc/User.py
84
doc/User.py
@ -31,36 +31,6 @@ class User(object):
|
||||
_common.RspHead(),
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'beforeActive',
|
||||
'desc': '激活用户',
|
||||
'group': 'User',
|
||||
'url': 'webapp/index.php?c=User&a=beforeActive',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!before', [ ['hero','','英雄信息'],['gun','','枪械信息'],['bceg_max','','最高bceg'],['bceg','','实际bceg'] ],'转换前'],
|
||||
['!after', [ ['hero','','英雄信息'],['gun','','枪械信息'],['ceg','','ceg'] ], '转换后'],
|
||||
['cost', 0, '所需手续费'],
|
||||
]
|
||||
},{
|
||||
'name': 'activate',
|
||||
'desc': '激活用户(免费转NFT)',
|
||||
'group': 'User',
|
||||
'url': 'webapp/index.php?c=User&a=activate',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['hero_uniid', 0, '英雄唯一id'],
|
||||
['gun_uniid', '', '枪械唯一id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [ ['hero_id','','英雄id'],['gun_id','','枪械id'],['ceg','','ceg'] ], '激活成果'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'update',
|
||||
'desc': '更新用户信息',
|
||||
@ -140,47 +110,6 @@ class User(object):
|
||||
_common.RspHead(),
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'initRank',
|
||||
'desc': '排位初始化段位',
|
||||
'group': 'User',
|
||||
'url': 'webapp/index.php?c=User&a=initRank',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'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(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'getFreeItemList',
|
||||
'desc': '获取免费英雄和武器列表',
|
||||
'group': 'User',
|
||||
'url': 'webapp/index.php?c=User&a=getFreeItemList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [], '列表'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'getFreeItemList',
|
||||
'desc': '获取免费英雄和武器列表',
|
||||
@ -222,5 +151,18 @@ class User(object):
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'getUserGameTimes',
|
||||
'desc': '获取用户游戏场次',
|
||||
'group': 'User',
|
||||
'url': 'webapp/index.php?c=User&a=getUserGameTimes',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['target_id', '', 'account_id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['data', 0, '游戏场次'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -38,7 +38,7 @@ class DailyRequestController extends BaseAuthedController {
|
||||
$season = RealtimeData::getMissionSeason();
|
||||
$currMissionSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
||||
if ($currMissionSeasonMeta && $currMissionSeasonMeta['id'] > $season){
|
||||
$max_star_num = mt\Parameter::getVal('starroad_restart_point',1000);
|
||||
$max_star_num = mt\Parameter::getVal('starroad_restart_point',400);
|
||||
$rows = myself()->_getMysql('')->execQuery(
|
||||
'SELECT account_id,star_num FROM t_user WHERE star_num>:star_num',
|
||||
array(
|
||||
@ -47,13 +47,25 @@ class DailyRequestController extends BaseAuthedController {
|
||||
);
|
||||
if (count($rows) > 0){
|
||||
foreach ($rows as $row){
|
||||
myself()->_getMysql('')->execQuery(
|
||||
'UPDATE t_user SET star_num=:star_num WHERE account_id=:account_id',
|
||||
$crystalNum = round($row['star_num']/1000);
|
||||
myself()->switchAccount($row['account_id']);
|
||||
$items = array(
|
||||
array(
|
||||
"star_num"=>$max_star_num,
|
||||
"account_id"=>$row['account_id'],
|
||||
'item_id' => ComputingPower::CRYSTAL1,
|
||||
'item_num' => $crystalNum,
|
||||
)
|
||||
);
|
||||
myself()->_addItems($items, null, $this->propertyChgService);
|
||||
myself()->_updateUserInfo(array(
|
||||
'star_num' => $max_star_num,
|
||||
));
|
||||
// myself()->_getMysql('')->execQuery(
|
||||
// 'UPDATE t_user SET star_num=:star_num WHERE account_id=:account_id',
|
||||
// array(
|
||||
// "star_num"=>$max_star_num,
|
||||
// "account_id"=>$row['account_id'],
|
||||
// )
|
||||
// );
|
||||
}
|
||||
}
|
||||
error_log("DailyRequestController : Mission Star Season ".$season." Settlement Success !" . " Request Time : ". date('Y-M-D h:i:s',time()));
|
||||
|
@ -268,106 +268,6 @@ class UserController extends BaseAuthedController {
|
||||
$this->_addItems($addItems, $awardService, $propertyChgService);
|
||||
}
|
||||
|
||||
public function beforeActive(){
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
$hero = Hero::getFreeHero();
|
||||
if (!$hero){
|
||||
$this->_rspErr(1, "No free heroes");
|
||||
return;
|
||||
}
|
||||
$gun = Gun::getFreeGun();
|
||||
if (!$gun){
|
||||
$this->_rspErr(1, "No free weapons");
|
||||
return;
|
||||
}
|
||||
|
||||
$paramMeta = mt\Parameter::getByName('bceg_max');
|
||||
$bceg_max = $paramMeta?$paramMeta['param_value']:3720;
|
||||
$before = array(
|
||||
'hero' =>$hero,
|
||||
'gun' =>$gun,
|
||||
'bceg_max' => $userInfo['bceg'],
|
||||
'bceg' => min($userInfo['bceg'],$bceg_max)
|
||||
);
|
||||
$after = array(
|
||||
'hero' =>$hero,
|
||||
'gun' =>$gun,
|
||||
'ceg' => min($userInfo['bceg'],$bceg_max)
|
||||
);
|
||||
$cost = 0;
|
||||
$cost += \services\FormulaService::Calc_Hero_Convert_Cost($hero);
|
||||
$cost += \services\FormulaService::Calc_Weapon_Convert_Cost($hero);
|
||||
$cost += \services\FormulaService::Calc_BCEG_Convert_Cost($userInfo['bceg']);
|
||||
$this->_rspData(array(
|
||||
'before' => $before,
|
||||
'after' => $after,
|
||||
'cost' => $cost,
|
||||
));
|
||||
}
|
||||
|
||||
public function active()
|
||||
{
|
||||
$this->_rspOk();return;
|
||||
$hero_uniid = getReqVal('hero_uniid', 0);
|
||||
$gun_uniid = getReqVal('gun_uniid', 0);
|
||||
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
if ($userInfo['activated']) {
|
||||
$this->_rspErr(10, 'User Activated');
|
||||
return;
|
||||
}
|
||||
$heroDb = Hero::find($hero_uniid);
|
||||
if (!$heroDb || !empty($heroDb['token_id'])) {
|
||||
$this->_rspErr(1, 'Parameter error, illegal hero_uniid');
|
||||
return;
|
||||
}
|
||||
$gunDb = Gun::find($gun_uniid);
|
||||
if (!$gunDb || !empty($gunDb['token_id'])) {
|
||||
$this->_rspErr(1, 'Parameter error, illegal gun_uniid');
|
||||
return;
|
||||
}
|
||||
{
|
||||
//转换NFT的手续费(U)
|
||||
$cost = 0;
|
||||
$cost += \services\FormulaService::Calc_Hero_Convert_Cost($heroDb);
|
||||
$cost += \services\FormulaService::Calc_Weapon_Convert_Cost($gunDb);
|
||||
$cost += \services\FormulaService::Calc_BCEG_Convert_Cost($userInfo['bceg']);
|
||||
}
|
||||
$paramMeta = mt\Parameter::getByName('bceg_max');
|
||||
$bceg = $paramMeta?$paramMeta['param_value']:3720;
|
||||
$ceg = min($bceg,$userInfo['bceg']);
|
||||
$this->_updateUserInfo(array(
|
||||
'activated' => 1,
|
||||
'bceg' => 0,
|
||||
'gold' => function () use($ceg) {
|
||||
return "gold + {$ceg}";
|
||||
}
|
||||
));
|
||||
$hero_token_id = Nft::addNft(\mt\Item::get($heroDb['hero_id']));
|
||||
Hero::update($heroDb['idx'],array(
|
||||
'token_id'=>$hero_token_id,
|
||||
'account_id' => null
|
||||
));
|
||||
|
||||
$gun_token_id = Nft::addNft(\mt\Item::get($gunDb['gun_id']));
|
||||
Gun::update($gunDb['idx'],array(
|
||||
'token_id'=>$gun_token_id,
|
||||
'account_id' => null
|
||||
));
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addUserChg();
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addGunChg();
|
||||
$this->_rspData(array(
|
||||
'data'=>array(
|
||||
'hero_id' => $heroDb['hero_id'],
|
||||
'gun_id' => $gunDb['gun_id'],
|
||||
'ceg' => $ceg,
|
||||
),
|
||||
'property_chg' => $propertyChgService->toDto()
|
||||
));
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
@ -680,88 +580,6 @@ class UserController extends BaseAuthedController {
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function initRank(){
|
||||
$initRankParameterMeta = mt\Parameter::getByName($this->init_rank);
|
||||
$initRankMeta = mt\Rank::getRankById($initRankParameterMeta['param_value']);
|
||||
$initEloParameterMeta = mt\Parameter::getByName($this->init_elo);
|
||||
$fields = array(
|
||||
'rank' => $initRankMeta ? $initRankMeta['id'] : 1,
|
||||
'history_best_rank' => $initRankMeta ? $initRankMeta['id'] : 1,
|
||||
'score' => $initRankMeta ? $initRankMeta['rank_score'] : 0,
|
||||
'history_best_score' => $initRankMeta ? $initRankMeta['rank_score'] : 0,
|
||||
'elo' => $initEloParameterMeta ? $initEloParameterMeta['param_value'] : 0,
|
||||
);
|
||||
User::update($fields);
|
||||
$this->_setV(TN_RANK_STATUS, 0, 0);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addUserChg();
|
||||
$this->_rspData([
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFreeItemList(){
|
||||
$data = array();
|
||||
$heroParam = mt\Parameter::getListValue('free_hero_list');
|
||||
$gunParam = mt\Parameter::getListValue('free_weapon_list');
|
||||
if ($heroParam){
|
||||
$data['hero'] = $heroParam;
|
||||
}
|
||||
if ($gunParam){
|
||||
$data['gun'] = $gunParam;
|
||||
}
|
||||
$this->_rspData([
|
||||
'data'=>$data
|
||||
]);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
$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());
|
||||
Gun::addFreeGun($gunMeta);
|
||||
$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' => $hero_id,
|
||||
'gun_id' => $gun_id,
|
||||
),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAddressBind()
|
||||
{
|
||||
if (myself()->_getChannel() != BC_POLY_CHANNEL) {
|
||||
@ -869,6 +687,25 @@ class UserController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function getUserGameTimes(){
|
||||
$targetId = getReqVal('target_id', '');
|
||||
$userDb = User::find($targetId);
|
||||
if (!$userDb) {
|
||||
$this->_rspErr(1, 'Account does not exist');
|
||||
return;
|
||||
}
|
||||
$battleDb = Battle::find($targetId);
|
||||
$gameTimes = 0;
|
||||
if ($battleDb){
|
||||
$battleData = json_decode($battleDb['battle_data'], true);
|
||||
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array();
|
||||
$gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data' => $gameTimes
|
||||
));
|
||||
}
|
||||
|
||||
private function dampingElo($userInfo){
|
||||
//每天elo衰减
|
||||
$time_diff = myself()->_getNowTime()-$userInfo['last_login_time'];
|
||||
|
@ -15,6 +15,7 @@ require_once('mt/PveGemini.php');
|
||||
require_once('mt/PveGeminiMode.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/LevelUp.php');
|
||||
require_once('mt/StarLevel.php');
|
||||
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Battle.php');
|
||||
@ -624,7 +625,7 @@ class TameBattleDataService extends BaseService {
|
||||
{
|
||||
//pvp奖励 gold
|
||||
if ($userDb){
|
||||
$this->calStarNum2($temp['reward'],getXVal($info,'pvp_personal_rank', 0));
|
||||
$this->calStarNum2($temp['reward'],getXVal($info,'pvp_personal_rank', 0),$userDb['account_id']);
|
||||
$heroDb = Hero::findByAccountId(getXVal($info,'account_id', 0),getXVal($info,'hero_uniid', 0));
|
||||
if (!$heroDb){
|
||||
break;
|
||||
@ -672,36 +673,66 @@ class TameBattleDataService extends BaseService {
|
||||
}
|
||||
|
||||
public function calStarNum(){
|
||||
$pvp_rank = getReqVal('pvp_personal_rank', 0);
|
||||
$paramMeta = mt\Parameter::getByName('star_get_num');
|
||||
if ($paramMeta){
|
||||
$star_get_num = getXVal($paramMeta,'param_value', 0);
|
||||
$currStarMissionSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
||||
if (!$currStarMissionSeasonMeta){
|
||||
return;
|
||||
}
|
||||
$battleData = Battle::getMyBattleData();
|
||||
$data = isset($battleData) ? getXVal($battleData, 'data', array()) : array();
|
||||
$battleTimes = getXVal($data, 'total_battle_times', 0);
|
||||
$items = array();
|
||||
$totalNum = 0;
|
||||
if ($battleTimes <= 10){
|
||||
$totalNum = 10;
|
||||
array_push($items,array(
|
||||
'item_id' => V_ITEM_STAR,
|
||||
'item_num' => 10
|
||||
));
|
||||
}else{
|
||||
$pvp_rank = getReqVal('pvp_personal_rank', 0);
|
||||
$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]);
|
||||
}
|
||||
$totalNum = $finalNum;
|
||||
if ($finalNum > 0){
|
||||
$items = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_STAR,
|
||||
'item_num' => $finalNum
|
||||
),
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
myself()->_addItems($items, $awardService,$propertyChgService);
|
||||
myself()->_incV(TN_TOTAL_STAR_NUM, 0, $finalNum);
|
||||
array_push($items,array(
|
||||
'item_id' => V_ITEM_STAR,
|
||||
'item_num' => $finalNum
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
if ($items){
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
myself()->_addItems($items, $awardService,$propertyChgService);
|
||||
myself()->_incV(TN_TOTAL_STAR_NUM, 0, $totalNum);
|
||||
}
|
||||
|
||||
}
|
||||
public function calStarNum2(&$reward,$pvp_rank){
|
||||
|
||||
$paramMeta = mt\Parameter::getByName('star_get_num');
|
||||
if ($paramMeta){
|
||||
$star_get_num = getXVal($paramMeta,'param_value', 0);
|
||||
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 <= 10){
|
||||
array_push($reward['items'],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;
|
||||
@ -715,7 +746,6 @@ class TameBattleDataService extends BaseService {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function calFinalStarNum($num){
|
||||
@ -723,8 +753,7 @@ class TameBattleDataService extends BaseService {
|
||||
if ($num <= 0) {
|
||||
return $finalNum;
|
||||
}
|
||||
$paramMeta = mt\Parameter::getByName('starroad_max');
|
||||
$starMax = getXVal($paramMeta,'param_value', 0);
|
||||
$starMax = mt\Parameter::getVal('starroad_max',0);
|
||||
if ($starMax){
|
||||
$starNum = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0);
|
||||
$newNum = min($starMax,$starNum + $num);
|
||||
|
Loading…
x
Reference in New Issue
Block a user