From 7dc6645b6a78f6e44701caf5d966811693c07379 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Nov 2021 10:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90getSeason=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/FriendController.class.php | 2 +- webapp/controller/PassController.class.php | 35 ++++++-------------- webapp/controller/RankController.class.php | 4 +-- webapp/controller/RoleController.class.php | 23 +++---------- webapp/controller/SignController.class.php | 13 +------- webapp/mt/Season.php | 31 ++++++++++++++--- 6 files changed, 47 insertions(+), 61 deletions(-) diff --git a/webapp/controller/FriendController.class.php b/webapp/controller/FriendController.class.php index a88aad87..fbb6884d 100644 --- a/webapp/controller/FriendController.class.php +++ b/webapp/controller/FriendController.class.php @@ -85,7 +85,7 @@ class FriendController extends BaseAuthedController { $rank = 1; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $seaPoint['max'] == -1) { $rank = $ii; diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index f5fbc408..51066de1 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -5,6 +5,9 @@ require 'classes/AddReward.php'; require_once 'metatable/parameter.php'; require_once 'metatable/season.php'; require_once 'metatable/seasoncard.php'; + +require_once('mt/Season.php'); + class PassController extends BaseAuthedController { @@ -21,22 +24,6 @@ class PassController extends BaseAuthedController { return $arr; } - protected function getSeason($season_id) - { - $season_meta_table = require('../res/season@season.php'); - $season_meta = getSeasonConfig($season_meta_table, $season_id); - $season = array( - 'number' => $season_meta['season_number'], - 'open_time' => $season_meta['time1'], - 'end_time' => $season_meta['time2'], - 'reward' => $season_meta['season_reward'], - 'weekreward' => $season_meta['week_reward'], - 'season_overreward' => $season_meta['season_overreward'], - 'reward2' => $season_meta['season_reward2'], - ); - return $season; - } - protected function getSeasonPoint($seaPoint_id) { $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); @@ -150,7 +137,7 @@ class PassController extends BaseAuthedController { $rank_status = 0; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { @@ -278,7 +265,7 @@ class PassController extends BaseAuthedController { $season = array(); $season_meta_table = require('../res/season@season.php'); for ($i = 1; $i <= count($season_meta_table); $i++) { - $season = $this->getSeason($i); + $season = mt\Season::getOldSeason($i); if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) { break; } @@ -373,14 +360,14 @@ class PassController extends BaseAuthedController { $level = 0; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { $season = array(); $season_meta_table = require('../res/season@season.php'); for ($i = 1; $i <= count($season_meta_table); $i++) { - $season = $this->getSeason($i); + $season = mt\Season::getOldSeason($i); if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) { break; } @@ -476,7 +463,7 @@ class PassController extends BaseAuthedController { //积分结算 $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($row['season_end_score'] >= $seaPoint['min'] && $row['season_end_score'] <= $seaPoint['max'] || $row['season_end_score'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { @@ -488,7 +475,7 @@ class PassController extends BaseAuthedController { $season_meta_table = require('../res/season@season.php'); $id = 0; for ($i = 1; $i <= count($season_meta_table); $i++) { - $season = $this->getSeason($i); + $season = mt\Season::getOldSeason($i); if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) { $open_time = strtotime($season['open_time']); $end_time = strtotime($season['end_time']); @@ -496,7 +483,7 @@ class PassController extends BaseAuthedController { break; } } - $s = $this->getSeason($id); + $s = mt\Season::getOldSeason($id); if ($s) { $delim1 = '|'; @@ -684,7 +671,7 @@ class PassController extends BaseAuthedController { $season = array(); $season_meta_table = require('../res/season@season.php'); for ($i = 1; $i <= count($season_meta_table); $i++) { - $season = $this->getSeason($i); + $season = mt\Season::getOldSeason($i); if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) { break; } diff --git a/webapp/controller/RankController.class.php b/webapp/controller/RankController.class.php index 1058cea0..12f3ad80 100644 --- a/webapp/controller/RankController.class.php +++ b/webapp/controller/RankController.class.php @@ -51,7 +51,7 @@ class RankController extends BaseAuthedController { if ($row) { $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $seaPoint['max'] == -1) { $rank = $ii; @@ -188,7 +188,7 @@ class RankController extends BaseAuthedController { $rank = 0; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($integral_db[$i][8] >= $seaPoint['min'] && $integral_db[$i][8] <= $seaPoint['max'] || $integral_db[$i][8] >= $seaPoint['min'] && $seaPoint['max'] == -1) { diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index e7fd4af4..af97d057 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -7,6 +7,7 @@ require 'NTaskController.class.php'; require_once('mt/Parameter.php'); require_once('mt/Drop.php'); require_once('mt/EquipUpgrade.php'); +require_once('mt/Season.php'); class RoleController extends BaseAuthedController { @@ -23,20 +24,6 @@ class RoleController extends BaseAuthedController { return $arr; } - protected function getSeason($season_id) - { - $season_meta_table = require('../res/season@season.php'); - $season_meta = getSeasonConfig($season_meta_table, $season_id); - $season = array( - 'number' => $season_meta['season_number'], - 'open_time' => $season_meta['time1'], - 'end_time' => $season_meta['time2'], - 'reward' => $season_meta['season_reward'], - 'weekreward' => $season_meta['season_reward2'], - ); - return $season; - } - protected function getSeasonPoint($seaPoint_id) { $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); @@ -126,7 +113,7 @@ class RoleController extends BaseAuthedController { $season_time = 0; $season_meta_table = require('../res/season@season.php'); for ($i = 1; $i <= count($season_meta_table); $i++) { - $season = $this->getSeason($i); + $season = mt\Season::getOldSeason($i); if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) { $season_time = strtotime($season['end_time']); break; @@ -517,7 +504,7 @@ class RoleController extends BaseAuthedController { $season_meta_table = require('../res/season@season.php'); $end_time = 0; for ($i = 1; $i <= count($season_meta_table); $i++) { - $season = $this->getSeason($i); + $season = mt\Season::getOldSeason($i); if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) { $end_time = strtotime($season['end_time']); break; @@ -526,7 +513,7 @@ class RoleController extends BaseAuthedController { $season_point_table = require('../res/seasomPoint@seasomPoint.php'); $integral = 0; for ($j = 1; $j <= count($season_point_table); $j++) { - $seasonpoint = $this->getSeasonPoint($j); + $seasonpoint = mt\Season::getOldSeasonPoint($j); if ($rowUser['integral'] <= $seasonpoint['max'] || $seasonpoint['max'] == -1) { $integral = $seasonpoint['topoint']; @@ -789,7 +776,7 @@ class RoleController extends BaseAuthedController { $is_pro = 0; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = $this->getSeasonPoint($ii); + $seaPoint = mt\Season::getOldSeasonPoint($ii); if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { $is_pro = $seaPoint['is_protect']; diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index 04bbcb83..408e2a19 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -4,6 +4,7 @@ require 'classes/Quest.php'; require 'classes/AddReward.php'; require_once('mt/Parameter.php'); +require_once('mt/Season.php'); class SignController extends BaseAuthedController { @@ -63,18 +64,6 @@ class SignController extends BaseAuthedController { return $sh; } - protected function getSeason($season_id) - { - $season_meta_table = require('../res/season@season.php'); - $season_meta = getSeasonConfig($season_meta_table, $season_id); - $season = array( - 'number' => $season_meta['season_number'], - 'open_time' => $season_meta['time1'], - 'end_time' => $season_meta['time2'], - ); - return $season; - } - protected function getSeasonPoint($seaPoint_id) { $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); diff --git a/webapp/mt/Season.php b/webapp/mt/Season.php index 7454992f..e6afe316 100644 --- a/webapp/mt/Season.php +++ b/webapp/mt/Season.php @@ -6,13 +6,19 @@ use phpcommon; class Season { + public static function get($id) + { + return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null; + } + protected static function getMeta() { - if (!self::$meta) { - self::$meta = getMetaTable('season@season.php'); + if (!self::$metaList) { + self::$metaList = getMetaTable('season@season.php'); } - return self::$meta; + return self::$metaList; } + public static function getSeasonRewardByLv($lv) { $seasonCfg = self::getMeta(); @@ -20,12 +26,14 @@ class Season { return $seasonCfg; } + public static function getSeasonCfg() { $seasonCfg = self::getMeta(); return $seasonCfg; } + public static function getTaskCfgByID($_itemID) { $playerSkinCfg = self::getMeta(); @@ -41,7 +49,22 @@ class Season { } return $itemData; } + + public static function getOldSeason($id) + { + $meta = self::get($id); + return array( + 'number' => $meta['season_number'], + 'open_time' => $meta['time1'], + 'end_time' => $meta['time2'], + 'reward' => $meta['season_reward'], + 'weekreward' => $meta['week_reward'], + 'season_overreward' => $meta['season_overreward'], + 'reward2' => $meta['season_reward2'], + ); + } + protected static $itemArr; - protected static $meta; + protected static $metaList; }