增加成长任务star

This commit is contained in:
hujiabin 2023-06-02 16:11:14 +08:00
parent 5540d4f690
commit 5200c81ad7
16 changed files with 559 additions and 62 deletions

59
doc/Star.py Normal file
View File

@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
import _common
class Star(object):
def __init__(self):
self.apis_ = [
{
'desc': 'getList',
'group': 'Star',
'url': 'webapp/index.php?c=Star&a=getList',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['countdown', 0, '赛季结束时间'],
['!data', [Task()], '任务列表'],
]
},{
'desc': 'commit',
'group': 'Star',
'url': 'webapp/index.php?c=Star&a=commit',
'params': [
_common.ReqHead(),
['mission_id', 0, '任务id'],
],
'response': [
_common.RspHead(),
['award', _common.Award(), '奖励信息'],
['property_chg', _common.PropertyChg(), '属性变更'],
]
},{
'desc': 'commitAll',
'group': 'Star',
'url': 'webapp/index.php?c=Star&a=commitAll',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['award', _common.Award(), '奖励信息'],
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
]
class Task(object):
def __init__(self):
self.fields = [
['mission_id', 0, '任务id'],
['current', 0, '任务进度-当前'],
['target', 0, '任务进度-目标'],
['state', 0, '任务状态 0:任务已完成-可领取奖励 1:任务已完成-已领取奖励 -1:任务进行中-未完成(不可领取)'],
]

View File

@ -9,6 +9,7 @@ function init() {
add('season'); add('season');
add('feeback'); add('feeback');
add('rankings'); add('rankings');
add('star');
} }
exports.init = init; exports.init = init;

View File

@ -0,0 +1,31 @@
const app = require('j7/app');
const utils = require('j7/utils');
const http = require('j7/http');
const constant = require('../constant');
const url = "https://game2006api-test.kingsome.cn/webapp/index.php?&c=Star&a=resetStar "
// const url = "https://game2006api-test.cebggame.com/webapp/index.php?&c=Star&a=resetStar "
// const url = "http://james.com/webapp/index.php?&c=Star&a=resetStar "
class Star {
async start() {
console.log('Star.start');
while (true) {
http.get(url,null)
const nowTime = utils.getUtcTime();
const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE);
const sleepTime = daySeconds + 3600 * 24 - nowTime;
console.log('Damping.sleepTime:' + sleepTime, new Date(), sleepTime / 60);
await utils.sleep(sleepTime * 1000);
}
}
}
function init() {
(new Star()).start();
}
exports.init = init;

View File

@ -67,6 +67,7 @@ CREATE TABLE `t_user` (
`guild_name` varchar(255) NOT NULL DEFAULT '' COMMENT '工会名称', `guild_name` varchar(255) NOT NULL DEFAULT '' COMMENT '工会名称',
`parachute` int(11) NOT NULL DEFAULT '0' COMMENT '降落伞ID', `parachute` int(11) NOT NULL DEFAULT '0' COMMENT '降落伞ID',
`ring_id` int(11) NOT NULL DEFAULT '0' COMMENT '戒指id', `ring_id` int(11) NOT NULL DEFAULT '0' COMMENT '戒指id',
`star_num` 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`)
@ -1069,3 +1070,23 @@ CREATE TABLE `t_rank_battle` (
KEY `value` (`value`) KEY `value` (`value`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_mission_star`
--
DROP TABLE IF EXISTS `t_mission_star`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_mission_star` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`season_id` int(11) NOT NULL DEFAULT '0' COMMENT '成长任务赛季id',
`mission_id` int(11) NOT NULL DEFAULT '0' COMMENT '成长任务id',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `account_season_mission_id` (`account_id`, `season_id`, `mission_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -10,6 +10,7 @@ define('V_ITEM_DIAMOND', 10002); //钻石
define('V_ITEM_EXP', 10003); //经验 define('V_ITEM_EXP', 10003); //经验
define('V_ITEM_ACTIVE', 10004); //活跃度 define('V_ITEM_ACTIVE', 10004); //活跃度
define('V_ITEM_BCEG', 10010); //BCEG define('V_ITEM_BCEG', 10010); //BCEG
define('V_ITEM_STAR', 10011); //星星
define('V_ITEM_REVIVE_COIN', 140001); //复活币 define('V_ITEM_REVIVE_COIN', 140001); //复活币
define('TN_BEGIN', 8001); define('TN_BEGIN', 8001);
@ -21,6 +22,7 @@ define('TN_HERO_LEVEL_UP', 8006);
define('TN_END', 8007); define('TN_END', 8007);
define('TN_HERO_MAX_LEVEL', 8008); 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', 99999); define('TN_RANK_STATUS', 99999);

View File

@ -18,6 +18,7 @@ require_once('mt/RankSeason.php');
require_once('mt/LevelUp.php'); require_once('mt/LevelUp.php');
require_once('mt/Task.php'); require_once('mt/Task.php');
require_once('mt/Drop.php'); require_once('mt/Drop.php');
require_once('mt/StarLevel.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\Bag; use models\Bag;
@ -109,8 +110,9 @@ class BaseAuthedController extends BaseController {
$controller = getReqVal('c', ''); $controller = getReqVal('c', '');
switch ($controller){ switch ($controller){
case "Chip" : { case "Chip" : {
if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_CHIP_LIMIT){ // if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_CHIP_LIMIT){
$this->_rspErr(1,'Not agreed terms. Level of need ' .\mt\LevelUp::USER_LEVEL_CHIP_LIMIT); if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_CHIP_LIMIT){
$this->_rspErr(1,'Not agreed terms. star number of need ' .\mt\StarLevel::STAR_NUM_CHIP_LIMIT);
die(); die();
} }
} }
@ -123,15 +125,17 @@ class BaseAuthedController extends BaseController {
// } // }
break; break;
case "Emoji" : { case "Emoji" : {
if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_EMOJI_LIMIT){ // if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_EMOJI_LIMIT){
$this->_rspErr(1,'Not agreed terms Level of need ' .\mt\LevelUp::USER_LEVEL_EMOJI_LIMIT); if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_EMOJI_LIMIT){
$this->_rspErr(1,'Not agreed terms star number of need ' .\mt\StarLevel::STAR_NUM_EMOJI_LIMIT);
die(); die();
} }
} }
break; break;
case "Fragment" : { case "Fragment" : {
if (getReqVal('a', '') == 'syntheticFragment' && $userDb['level'] < \mt\LevelUp::USER_LEVEL_PIECE_LIMIT){ // if (getReqVal('a', '') == 'syntheticFragment' && $userDb['level'] < \mt\LevelUp::USER_LEVEL_PIECE_LIMIT){
$this->_rspErr(1,'Not agreed terms Level of need ' .\mt\LevelUp::USER_LEVEL_PIECE_LIMIT); if (getReqVal('a', '') == 'syntheticFragment' && $userDb['star_num'] < \mt\StarLevel::STAR_NUM_PIECE_LIMIT){
$this->_rspErr(1,'Not agreed terms star number of need ' .\mt\StarLevel::STAR_NUM_PIECE_LIMIT);
die(); die();
} }
} }
@ -273,7 +277,7 @@ class BaseAuthedController extends BaseController {
public function _isVirtualItem($itemId) public function _isVirtualItem($itemId)
{ {
return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG)); return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG,V_ITEM_STAR));
} }
public function _addVirtualItem($itemId, $itemNum,$awardService,$propertyChgService) public function _addVirtualItem($itemId, $itemNum,$awardService,$propertyChgService)
@ -320,18 +324,18 @@ class BaseAuthedController extends BaseController {
$newlV = $userDb['level']; $newlV = $userDb['level'];
$newExp = $userDb['exp']+$itemNum; $newExp = $userDb['exp']+$itemNum;
\mt\LevelUp::getExpByLv($newlV,$newExp); \mt\LevelUp::getExpByLv($newlV,$newExp);
if ($newlV != $userDb['level']){ // if ($newlV != $userDb['level']){
//协议通知前端等级变更 // //协议通知前端等级变更
$propertyChgService->addUserLevelChg(); // $propertyChgService->addUserLevelChg();
//添加奖励 // //添加奖励
for ($i=$userDb['level']+1; $i<=$newlV; $i++){ // for ($i=$userDb['level']+1; $i<=$newlV; $i++){
$taskMeta = \mt\Task::findAchievementLevel($i); // $taskMeta = \mt\Task::findAchievementLevel($i);
if ($taskMeta){ // if ($taskMeta){
$dropMeta = mt\Drop::get($taskMeta['reward']); // $dropMeta = mt\Drop::get($taskMeta['reward']);
$this->_scatterDrop('mission:' . $taskMeta['id'], $dropMeta, null, $propertyChgService); // $this->_scatterDrop('mission:' . $taskMeta['id'], $dropMeta, null, $propertyChgService);
} // }
} // }
} // }
$this->_updateUserInfo(array( $this->_updateUserInfo(array(
'level' => $newlV, 'level' => $newlV,
'exp' => $newExp 'exp' => $newExp
@ -350,6 +354,15 @@ class BaseAuthedController extends BaseController {
} }
} }
break; break;
case V_ITEM_STAR:
{
$this->_updateUserInfo(array(
'star_num' => function () use($itemNum) {
return "star_num + ${itemNum}";
}
));
}
break;
default: default:
{ {
} }

View File

@ -1,4 +1,5 @@
<?php <?php
require_once('mt/StarLevel.php');
require_once('models/Chip.php'); require_once('models/Chip.php');
require_once('models/ChipPage.php'); require_once('models/ChipPage.php');
require_once('services/ChipPageService.php'); require_once('services/ChipPageService.php');
@ -44,14 +45,16 @@ class ChipPageController extends BaseAuthedController
$count = ChipPage::getCount(); $count = ChipPage::getCount();
switch ($count){ switch ($count){
case 3 : { case 3 : {
if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT){ // if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT){
if ($userInfo['star_num'] < \mt\StarLevel::STAR_NUM_CHIP_PAGE1_MATCH_LIMIT){
$this->_rspErr(1,'Not agreed terms'); $this->_rspErr(1,'Not agreed terms');
return ; return ;
} }
} }
break; break;
case 4 : { case 4 : {
if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT){ // if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT){
if ($userInfo['star_num'] < \mt\StarLevel::STAR_NUM_CHIP_PAGE2_MATCH_LIMIT){
$this->_rspErr(1,'Not agreed terms'); $this->_rspErr(1,'Not agreed terms');
return ; return ;
} }

View File

@ -0,0 +1,150 @@
<?php
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
require_once('mt/LevelUp.php');
require_once('mt/StarLevel.php');
require_once('models/MissionStar.php');
require_once('models/DynData.php');
use phpcommon\SqlHelper;
use models\MissionStar;
use models\DynData;
class StarController extends BaseAuthedController {
private $awardService = null;
private $propertyChgService = null;
private $userInfo = null;
private $currMissionSeasonMeta = null;
public function _handlePre()
{
if(getReqVal('a', '') != 'resetStar'){
parent::_handlePre();
}
DynData::preload();
$this->currMissionSeasonMeta = \mt\StarLevel::getCurrentSeason();
if (!$this->currMissionSeasonMeta) {
$this->_rspErr(10, 'server internal error');
die();
}
// $this->_setV(TN_MISSION_STAR_SEASON, 0, $this->currMissionSeasonMeta['id']);
$this->propertyChgService = new services\PropertyChgService();
$this->awardService = new services\AwardService();
$this->userInfo = $this->_safeGetOrmUserInfo();
}
public function getList(){
$list = array();
$countdown = strtotime($this->currMissionSeasonMeta['end_time']) - myself()->_getNowTime();
$defaultList = \mt\StarLevel::getDefaultList();
$lvUpMetaList = \mt\StarLevel::getListBySeason($this->currMissionSeasonMeta['id']);
$collection = array_merge($defaultList,$lvUpMetaList);
foreach ($collection as $meta){
$state = MissionStar::NOT_FINISHED_STATE;
$target = getXVal($meta, 'need_star_num', 1);
$missionStarDb = MissionStar::find($meta['season_id'],$meta['id']);
if ($this->userInfo['star_num'] >= $target && !$missionStarDb){
$state = MissionStar::RECEIVEABLE_STATE;
}
if ($this->userInfo['star_num'] >= $target && $missionStarDb){
$state = MissionStar::RECEIVED_STATE;
}
array_push($list,
array(
'mission_id' => $meta['id'],
'current' => $this->userInfo['star_num'],
'target' => $target,
'state' =>$state
)
);
}
$this->_rspData(array(
'countdown' => $countdown,
'data' => $list,
));
}
public function commit(){
$missionId = getReqVal('mission_id', 0);
$meta = mt\StarLevel::get($missionId);
if (!$meta) {
$this->_rspErr(1, 'mission_id parameter error');
return;
}
if ($this->userInfo['star_num'] < $meta['need_star_num']){
$this->_rspErr(1, 'objectives not achieved');
return;
}
$missionStarDb = MissionStar::find($meta['season_id'],$missionId);
if ($missionStarDb){
$this->_rspErr(1, "Can't get it again");
return;
}
$dropMeta = mt\Drop::get($meta['drop_id']);
if (!$dropMeta) {
$this->_rspErr(10, 'server internal error:' . $meta['drop_id']);
return;
}
$this->_scatterDrop('missionStar:' . $missionId, $dropMeta, $this->awardService, $this->propertyChgService);
MissionStar::add($meta['season_id'],$missionId);
$this->_rspData(array(
'award' => $this->awardService->toDto(),
'property_chg' => $this->propertyChgService->toDto(),
));
}
public function commitAll(){
$defaultList = \mt\StarLevel::getDefaultList();
$lvUpMetaList = \mt\StarLevel::getListBySeason($this->currMissionSeasonMeta['id']);
$collection = array_merge($defaultList,$lvUpMetaList);
foreach ($collection as $meta){
$target = getXVal($meta, 'need_star_num', 1);
$missionStarDb = MissionStar::find($meta['season_id'],$meta['id']);
if ($this->userInfo['star_num'] >= $target && !$missionStarDb){
//可领取
$dropMeta = mt\Drop::get($meta['drop_id']);
if ($dropMeta) {
$this->_scatterDrop('missionStar:' . $meta['id'], $dropMeta, $this->awardService, $this->propertyChgService);
MissionStar::add($meta['season_id'],$meta['id']);
}
}
}
$this->_rspData(array(
'award' => $this->awardService->toDto(),
'property_chg' => $this->propertyChgService->toDto(),
));
}
public function resetStar(){
error_log('request time :'.date('Y-m-d h:i:s',time()));
$season = $this->_getV(TN_MISSION_STAR_SEASON, 0,1);
if ( $this->currMissionSeasonMeta['id'] > $season){
$meta = mt\Parameter::getByName('starroad_restart_point');
$max_star_num = getXVal($meta, 'param_value',1000);
$rows = myself()->_getSelfMysql()->execQuery(
'SELECT account_id,star_num FROM t_user WHERE star_num>:star_num',
array(
"star_num"=>$max_star_num
)
);
if (count($rows) > 0){
foreach ($rows as $row){
myself()->_getSelfMysql()->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'],
)
);
}
}
$this->_setV(TN_MISSION_STAR_SEASON, 0, $this->currMissionSeasonMeta['id']);
}
}
}

View File

@ -9,6 +9,7 @@ require_once('models/HeroSkin.php');
require_once('mt/PveGemini.php'); require_once('mt/PveGemini.php');
require_once('mt/Skill.php'); require_once('mt/Skill.php');
require_once('mt/StarLevel.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
@ -52,7 +53,8 @@ class TeamController extends BaseAuthedController {
//验证pve_instance_id合法性 //验证pve_instance_id合法性
if ($pveInstanceId){ if ($pveInstanceId){
if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){ // if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_PVE_MATCH_LIMIT){
$this->_rspErr(1,'Not agreed terms'); $this->_rspErr(1,'Not agreed terms');
return; return;
} }
@ -67,7 +69,8 @@ class TeamController extends BaseAuthedController {
} }
} }
if ($matchMode == self::MATCH_MODE_RANK){ if ($matchMode == self::MATCH_MODE_RANK){
if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ // if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){
$this->_rspErr(1,'Not agreed terms'); $this->_rspErr(1,'Not agreed terms');
return; return;
} }
@ -118,7 +121,8 @@ class TeamController extends BaseAuthedController {
} }
$userDb = $this->_getOrmUserInfo(); $userDb = $this->_getOrmUserInfo();
if ($teamDb['match_mode'] == self::MATCH_MODE_RANK && if ($teamDb['match_mode'] == self::MATCH_MODE_RANK &&
$userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ // $userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){
$userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){
$this->_rspErr(1,'Not agreed terms'); $this->_rspErr(1,'Not agreed terms');
return; return;
} }
@ -139,7 +143,8 @@ class TeamController extends BaseAuthedController {
$this->_rspErr(1, 'No challenge'); $this->_rspErr(1, 'No challenge');
return; return;
} }
if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){ // if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_PVE_MATCH_LIMIT){
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_PVE_MATCH_LIMIT){
$this->_rspErr(1,'Not agreed terms'); $this->_rspErr(1,'Not agreed terms');
return; return;
} }

View File

@ -175,18 +175,7 @@ class ChipPage extends BaseModel
public static function addChipPage(){ public static function addChipPage(){
$data = array(); $data = array();
$userInfo = myself()->_getOrmUserInfo();
for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){ for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){
if ($i <= $userInfo['level']){
array_push(
$data,
array(
'slot_id'=>$i,
'state'=>1,
'chip_id'=>0,
)
);
}else{
array_push( array_push(
$data, $data,
array( array(
@ -196,7 +185,6 @@ class ChipPage extends BaseModel
) )
); );
} }
}
$rows = SqlHelper::ormSelect( $rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(), myself()->_getSelfMysql(),
't_chip_page', 't_chip_page',

View File

@ -0,0 +1,52 @@
<?php
namespace models;
require_once('mt/Item.php');
use mt;
use phpcommon\SqlHelper;
class MissionStar extends BaseModel
{
const RECEIVEABLE_STATE = 0;
const RECEIVED_STATE = 1;
const NOT_FINISHED_STATE = -1;
public static function find($seasonId,$missionId){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_mission_star',
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
'mission_id' => $missionId,
)
);
return $row;
}
public static function add($seasonId,$missionId){
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_mission_star',
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
'mission_id' => $missionId
),
array(
),
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
'mission_id' => $missionId,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}

View File

@ -4,6 +4,7 @@ namespace models;
require_once('mt/Item.php'); require_once('mt/Item.php');
require_once('mt/LevelUp.php'); require_once('mt/LevelUp.php');
require_once('mt/StarLevel.php');
require_once('models/UserSeasonRing.php'); require_once('models/UserSeasonRing.php');
require_once('models/Parachute.php'); require_once('models/Parachute.php');
require_once('models/Hero.php'); require_once('models/Hero.php');
@ -45,6 +46,11 @@ class User extends BaseModel {
public static function show($row) public static function show($row)
{ {
mt\LevelUp::getExpByLv($row['level'],$row['exp']); mt\LevelUp::getExpByLv($row['level'],$row['exp']);
{
$current_star_num = $row['star_num'];
$currSeasonMeta = \mt\StarLevel::getCurrentSeason();
$next_star_num = mt\StarLevel::getNextNeedStarNum($current_star_num,$currSeasonMeta['id']);
}
$heroDb = Hero::find($row['hero_id']); $heroDb = Hero::find($row['hero_id']);
if ($heroDb){ if ($heroDb){
$heroId = $heroDb['hero_id']; $heroId = $heroDb['hero_id'];
@ -90,12 +96,19 @@ class User extends BaseModel {
'parachute_list' => Parachute::getMyParachute(), 'parachute_list' => Parachute::getMyParachute(),
'ring_id' => $row['ring_id'], 'ring_id' => $row['ring_id'],
'ring_list' => UserSeasonRing::ringList($row['account_id']), 'ring_list' => UserSeasonRing::ringList($row['account_id']),
'current_star_num' => $current_star_num,
'next_star_num' => $next_star_num,
); );
} }
public static function info($row) public static function info($row)
{ {
mt\LevelUp::getExpByLv($row['level'],$row['exp']); mt\LevelUp::getExpByLv($row['level'],$row['exp']);
{
$current_star_num = $row['star_num'];
$currSeasonMeta = \mt\StarLevel::getCurrentSeason();
$next_star_num = mt\StarLevel::getNextNeedStarNum($current_star_num,$currSeasonMeta['id']);
}
$heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']); $heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']);
if ($heroDb){ if ($heroDb){
$heroId = $heroDb['hero_id']; $heroId = $heroDb['hero_id'];
@ -143,6 +156,8 @@ class User extends BaseModel {
'ring_list' => UserSeasonRing::ringList($row['account_id']), 'ring_list' => UserSeasonRing::ringList($row['account_id']),
'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute,
'parachute_list' => Parachute::getMyParachute(), 'parachute_list' => Parachute::getMyParachute(),
'current_star_num' => $current_star_num,
'next_star_num' => $next_star_num,
); );
} }

View File

@ -35,7 +35,6 @@ class LevelUp
} }
} }
} }
protected static function getMetaList() protected static function getMetaList()
{ {
if (!self::$metaList) { if (!self::$metaList) {
@ -44,6 +43,7 @@ class LevelUp
return self::$metaList; return self::$metaList;
} }
protected static $metaList; protected static $metaList;
} }

103
webapp/mt/StarLevel.php Normal file
View File

@ -0,0 +1,103 @@
<?php
namespace mt;
class StarLevel
{
const STAR_NUM_CHIP_LIMIT = 40;
const STAR_NUM_EMOJI_LIMIT = 20;
const STAR_NUM_PIECE_LIMIT = 60;
const STAR_NUM_PVE_MATCH_LIMIT = 80;
const STAR_NUM_RANK_MATCH_LIMIT = 120;
const STAR_NUM_CHIP_PAGE1_MATCH_LIMIT = 160;
const STAR_NUM_CHIP_PAGE2_MATCH_LIMIT = 180;
public static function get($id){
return getXVal(self::getMetaList(), $id);
}
public static function getNextNeedStarNum($num,$season_id){
$metaList = array_merge(self::getDefaultList(),self::getListBySeason($season_id));
$maxLen = count($metaList);
for ($i=0;$i<$maxLen;$i++){
if ($num >= $metaList[$maxLen-1]['need_star_num']){
return $metaList[$maxLen-1]['need_star_num'];
}
if ($num >= $metaList[$i]['need_star_num'] &&
$num < $metaList[$i+1]['need_star_num']) {
return $metaList[$i+1]['need_star_num'];
}
}
return null;
}
public static function getCurrent($num){
$metaList = self::getDefaultList();
$maxLen = count($metaList);
for ($i=0;$i<$maxLen;$i++){
if ($num >= $metaList[$maxLen-1]['need_star_num']){
return $metaList[$maxLen-1];
}
if ($num >= $metaList[$i]['need_star_num'] &&
$num < $metaList[$i+1]['need_star_num']) {
return $metaList[$i];
}
}
}
public static function getDefaultList(){
$list = array();
foreach (self::getMetaList() as $meta){
if ($meta['season_id'] == 0){
array_push($list,$meta);
}
}
return $list;
}
public static function getListBySeason($season_id){
$list = array();
foreach (self::getMetaList() as $meta){
if ($meta['season_id'] == $season_id){
array_push($list,$meta);
}
}
return $list;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('starLevel@starLevel.php');
}
return self::$metaList;
}
public static function getCurrentSeason(){
foreach (self::getMetaListStarRoad() as $meta) {
if (myself()->_getNowTime() >= strtotime($meta['start_time']) &&
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
return $meta;
}
}
return null;
}
protected static function getMetaListStarRoad()
{
if (!self::$metaListStar) {
self::$metaListStar = getMetaTable('starRoad@starRoad.php');
}
return self::$metaListStar;
}
protected static $metaList;
protected static $metaList2;
protected static $metaListStar;
}

View File

@ -4,6 +4,8 @@
namespace services; namespace services;
require_once('models/ChipPage.php'); require_once('models/ChipPage.php');
require_once('mt/StarLevel.php');
use models\ChipPage; use models\ChipPage;
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
class ChipPageService extends BaseService class ChipPageService extends BaseService
@ -42,8 +44,10 @@ class ChipPageService extends BaseService
public function refreshSlotState($row){ public function refreshSlotState($row){
$data = emptyReplace(json_decode($row['data'], true), array()); $data = emptyReplace(json_decode($row['data'], true), array());
$userInfo = myself()->_getOrmUserInfo(); $userInfo = myself()->_getOrmUserInfo();
$starMeta = \mt\StarLevel::getCurrent($userInfo['star_num']);
if ($starMeta['unlock_chip_slot']){
foreach ($data as &$val){ foreach ($data as &$val){
if ($userInfo['level'] < $val['slot_id'] && $val['state'] == 0){ if ($starMeta['unlock_chip_slot'] < $val['slot_id'] && $val['state'] == 0){
$val['state'] = 0; $val['state'] = 0;
}else{ }else{
$val['state'] = 1; $val['state'] = 1;
@ -61,5 +65,24 @@ class ChipPageService extends BaseService
) )
); );
} }
// foreach ($data as &$val){
// if ($userInfo['level'] < $val['slot_id'] && $val['state'] == 0){
// $val['state'] = 0;
// }else{
// $val['state'] = 1;
// }
// }
//
// SqlHelper::update(
// myself()->_getSelfMysql(),
// 't_chip_page',
// array(
// 'idx' => $row['idx']
// ),
// array(
// 'data' => json_encode($data),
// )
// );
}
} }

View File

@ -144,6 +144,8 @@ class TameBattleDataService extends BaseService {
//记录战斗数据的排行榜 //记录战斗数据的排行榜
$this->recordBattleRanking(); $this->recordBattleRanking();
//结算用户star数量
// $this->calStarNum();
} }
break; break;
//PVE模式 //PVE模式
@ -166,6 +168,35 @@ class TameBattleDataService extends BaseService {
} }
//每局战斗结算star数量
private function calStarNum(){
$paramMeta = mt\Parameter::getByName('star_get_num');
if ($paramMeta){
$star_get_num = getXVal($paramMeta,'param_value', 0);
$num_arr = explode('|',$star_get_num);
$rank = getXVal($this->battleInfo,'pvp_personal_rank', 0);
if ($rank>count($num_arr) || $rank<1){
$items = array(
array(
'item_id'=>V_ITEM_STAR,
'item_num'=>0
)
);
}else{
$items = array(
array(
'item_id'=>V_ITEM_STAR,
'item_num'=>$num_arr[$rank-1]
)
);
}
$propertyChgService = new services\PropertyChgService();
$awardService = new services\AwardService();
myself()->_addItems($items, $awardService,$propertyChgService);
}
}
//记录战斗数据的排行榜 //记录战斗数据的排行榜
private function recordBattleRanking(){ private function recordBattleRanking(){
$account = getXVal($this->battleInfo,'account_id', 0); $account = getXVal($this->battleInfo,'account_id', 0);