From 5200c81ad7d4b576c084651053241f81fa7ec244 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 2 Jun 2023 16:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=88=90=E9=95=BF=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1star?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Star.py | 59 +++++++ server/game2006service/tasks/factory.js | 1 + server/game2006service/tasks/star.js | 31 ++++ sql/gamedb.sql | 21 +++ webapp/bootstrap/constant.php | 2 + .../controller/BaseAuthedController.class.php | 51 +++--- .../controller/ChipPageController.class.php | 7 +- webapp/controller/StarController.class.php | 150 ++++++++++++++++++ webapp/controller/TeamController.class.php | 13 +- webapp/models/ChipPage.php | 28 +--- webapp/models/MissionStar.php | 52 ++++++ webapp/models/User.php | 15 ++ webapp/mt/LevelUp.php | 2 +- webapp/mt/StarLevel.php | 103 ++++++++++++ webapp/services/ChipPageService.php | 55 +++++-- webapp/services/TameBattleDataService.php | 31 ++++ 16 files changed, 559 insertions(+), 62 deletions(-) create mode 100644 doc/Star.py create mode 100644 server/game2006service/tasks/star.js create mode 100644 webapp/controller/StarController.class.php create mode 100644 webapp/models/MissionStar.php create mode 100644 webapp/mt/StarLevel.php diff --git a/doc/Star.py b/doc/Star.py new file mode 100644 index 00000000..55ea5f9f --- /dev/null +++ b/doc/Star.py @@ -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:任务进行中-未完成(不可领取)'], + ] diff --git a/server/game2006service/tasks/factory.js b/server/game2006service/tasks/factory.js index 2c73b3b9..a8635c2c 100644 --- a/server/game2006service/tasks/factory.js +++ b/server/game2006service/tasks/factory.js @@ -9,6 +9,7 @@ function init() { add('season'); add('feeback'); add('rankings'); + add('star'); } exports.init = init; diff --git a/server/game2006service/tasks/star.js b/server/game2006service/tasks/star.js new file mode 100644 index 00000000..6dcc50dd --- /dev/null +++ b/server/game2006service/tasks/star.js @@ -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; diff --git a/sql/gamedb.sql b/sql/gamedb.sql index d62337f4..0f974c89 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -67,6 +67,7 @@ CREATE TABLE `t_user` ( `guild_name` varchar(255) NOT NULL DEFAULT '' COMMENT '工会名称', `parachute` 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`), UNIQUE KEY `account_id` (`account_id`), KEY `channel` (`channel`) @@ -1069,3 +1070,23 @@ CREATE TABLE `t_rank_battle` ( KEY `value` (`value`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!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 */; \ No newline at end of file diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index dd1aad4d..28c45cee 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -10,6 +10,7 @@ define('V_ITEM_DIAMOND', 10002); //钻石 define('V_ITEM_EXP', 10003); //经验 define('V_ITEM_ACTIVE', 10004); //活跃度 define('V_ITEM_BCEG', 10010); //BCEG +define('V_ITEM_STAR', 10011); //星星 define('V_ITEM_REVIVE_COIN', 140001); //复活币 define('TN_BEGIN', 8001); @@ -21,6 +22,7 @@ define('TN_HERO_LEVEL_UP', 8006); define('TN_END', 8007); define('TN_HERO_MAX_LEVEL', 8008); define('TN_LAST_RANKING_TIME', 8009); +define('TN_MISSION_STAR_SEASON', 8010); define('TN_RANK_STATUS', 99999); diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 5c53bb33..78227b4c 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -18,6 +18,7 @@ require_once('mt/RankSeason.php'); require_once('mt/LevelUp.php'); require_once('mt/Task.php'); require_once('mt/Drop.php'); +require_once('mt/StarLevel.php'); use phpcommon\SqlHelper; use models\Bag; @@ -109,8 +110,9 @@ class BaseAuthedController extends BaseController { $controller = getReqVal('c', ''); switch ($controller){ case "Chip" : { - 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['level'] < \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(); } } @@ -123,15 +125,17 @@ class BaseAuthedController extends BaseController { // } break; case "Emoji" : { - 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['level'] < \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(); } } break; case "Fragment" : { - 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['level'] < \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(); } } @@ -273,7 +277,7 @@ class BaseAuthedController extends BaseController { 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) @@ -320,18 +324,18 @@ class BaseAuthedController extends BaseController { $newlV = $userDb['level']; $newExp = $userDb['exp']+$itemNum; \mt\LevelUp::getExpByLv($newlV,$newExp); - if ($newlV != $userDb['level']){ - //协议通知前端等级变更 - $propertyChgService->addUserLevelChg(); - //添加奖励 - for ($i=$userDb['level']+1; $i<=$newlV; $i++){ - $taskMeta = \mt\Task::findAchievementLevel($i); - if ($taskMeta){ - $dropMeta = mt\Drop::get($taskMeta['reward']); - $this->_scatterDrop('mission:' . $taskMeta['id'], $dropMeta, null, $propertyChgService); - } - } - } +// if ($newlV != $userDb['level']){ +// //协议通知前端等级变更 +// $propertyChgService->addUserLevelChg(); +// //添加奖励 +// for ($i=$userDb['level']+1; $i<=$newlV; $i++){ +// $taskMeta = \mt\Task::findAchievementLevel($i); +// if ($taskMeta){ +// $dropMeta = mt\Drop::get($taskMeta['reward']); +// $this->_scatterDrop('mission:' . $taskMeta['id'], $dropMeta, null, $propertyChgService); +// } +// } +// } $this->_updateUserInfo(array( 'level' => $newlV, 'exp' => $newExp @@ -350,6 +354,15 @@ class BaseAuthedController extends BaseController { } } break; + case V_ITEM_STAR: + { + $this->_updateUserInfo(array( + 'star_num' => function () use($itemNum) { + return "star_num + ${itemNum}"; + } + )); + } + break; default: { } diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php index 6b3548b9..fdf6caf7 100644 --- a/webapp/controller/ChipPageController.class.php +++ b/webapp/controller/ChipPageController.class.php @@ -1,4 +1,5 @@ _rspErr(1,'Not agreed terms'); return ; } } break; 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'); return ; } diff --git a/webapp/controller/StarController.class.php b/webapp/controller/StarController.class.php new file mode 100644 index 00000000..4b112152 --- /dev/null +++ b/webapp/controller/StarController.class.php @@ -0,0 +1,150 @@ +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']); + } + + + } + +} \ No newline at end of file diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index 694fb08ff..47627dcd 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -9,6 +9,7 @@ require_once('models/HeroSkin.php'); require_once('mt/PveGemini.php'); require_once('mt/Skill.php'); +require_once('mt/StarLevel.php'); require_once('services/PropertyChgService.php'); @@ -52,7 +53,8 @@ class TeamController extends BaseAuthedController { //验证pve_instance_id合法性 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'); return; } @@ -67,7 +69,8 @@ class TeamController extends BaseAuthedController { } } 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'); return; } @@ -118,7 +121,8 @@ class TeamController extends BaseAuthedController { } $userDb = $this->_getOrmUserInfo(); 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'); return; } @@ -139,7 +143,8 @@ class TeamController extends BaseAuthedController { $this->_rspErr(1, 'No challenge'); 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'); return; } diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php index 2377e140..00c3146e 100644 --- a/webapp/models/ChipPage.php +++ b/webapp/models/ChipPage.php @@ -175,27 +175,15 @@ class ChipPage extends BaseModel public static function addChipPage(){ $data = array(); - $userInfo = myself()->_getOrmUserInfo(); 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( - $data, - array( - 'slot_id'=>$i, - 'state'=>0, - 'chip_id'=>0, - ) - ); - } + array_push( + $data, + array( + 'slot_id'=>$i, + 'state'=>0, + 'chip_id'=>0, + ) + ); } $rows = SqlHelper::ormSelect( myself()->_getSelfMysql(), diff --git a/webapp/models/MissionStar.php b/webapp/models/MissionStar.php new file mode 100644 index 00000000..84790f75 --- /dev/null +++ b/webapp/models/MissionStar.php @@ -0,0 +1,52 @@ +_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() + ) + ); + } + +} \ No newline at end of file diff --git a/webapp/models/User.php b/webapp/models/User.php index dc9032e1..9c42d200 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -4,6 +4,7 @@ namespace models; require_once('mt/Item.php'); require_once('mt/LevelUp.php'); +require_once('mt/StarLevel.php'); require_once('models/UserSeasonRing.php'); require_once('models/Parachute.php'); require_once('models/Hero.php'); @@ -45,6 +46,11 @@ class User extends BaseModel { public static function show($row) { 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']); if ($heroDb){ $heroId = $heroDb['hero_id']; @@ -90,12 +96,19 @@ class User extends BaseModel { 'parachute_list' => Parachute::getMyParachute(), 'ring_id' => $row['ring_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) { 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']); if ($heroDb){ $heroId = $heroDb['hero_id']; @@ -143,6 +156,8 @@ class User extends BaseModel { 'ring_list' => UserSeasonRing::ringList($row['account_id']), 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'parachute_list' => Parachute::getMyParachute(), + 'current_star_num' => $current_star_num, + 'next_star_num' => $next_star_num, ); } diff --git a/webapp/mt/LevelUp.php b/webapp/mt/LevelUp.php index 564b296b..c74aee77 100644 --- a/webapp/mt/LevelUp.php +++ b/webapp/mt/LevelUp.php @@ -35,7 +35,6 @@ class LevelUp } } } - protected static function getMetaList() { if (!self::$metaList) { @@ -44,6 +43,7 @@ class LevelUp return self::$metaList; } + protected static $metaList; } \ No newline at end of file diff --git a/webapp/mt/StarLevel.php b/webapp/mt/StarLevel.php new file mode 100644 index 00000000..46ddb4b0 --- /dev/null +++ b/webapp/mt/StarLevel.php @@ -0,0 +1,103 @@ += $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; + +} \ No newline at end of file diff --git a/webapp/services/ChipPageService.php b/webapp/services/ChipPageService.php index 5bad3b30..1cbe96c8 100644 --- a/webapp/services/ChipPageService.php +++ b/webapp/services/ChipPageService.php @@ -4,6 +4,8 @@ namespace services; require_once('models/ChipPage.php'); +require_once('mt/StarLevel.php'); + use models\ChipPage; use phpcommon\SqlHelper; class ChipPageService extends BaseService @@ -42,24 +44,45 @@ class ChipPageService extends BaseService public function refreshSlotState($row){ $data = emptyReplace(json_decode($row['data'], true), array()); $userInfo = myself()->_getOrmUserInfo(); - foreach ($data as &$val){ - if ($userInfo['level'] < $val['slot_id'] && $val['state'] == 0){ - $val['state'] = 0; - }else{ - $val['state'] = 1; + $starMeta = \mt\StarLevel::getCurrent($userInfo['star_num']); + if ($starMeta['unlock_chip_slot']){ + foreach ($data as &$val){ + if ($starMeta['unlock_chip_slot'] < $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), - ) - ); + SqlHelper::update( + myself()->_getSelfMysql(), + 't_chip_page', + array( + 'idx' => $row['idx'] + ), + array( + 'data' => json_encode($data), + ) + ); + } +// 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), +// ) +// ); } } \ No newline at end of file diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index ca110938..d0ff55bd 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -144,6 +144,8 @@ class TameBattleDataService extends BaseService { //记录战斗数据的排行榜 $this->recordBattleRanking(); + //结算用户star数量 +// $this->calStarNum(); } break; //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(){ $account = getXVal($this->battleInfo,'account_id', 0);