From 9a7a8bf4015b928a1f5d48aba176997a99e3b3bd Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Nov 2021 10:41:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90Drop=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GameOverController.class.php | 22 ++--------- webapp/controller/PayController.class.php | 21 ++--------- webapp/controller/QuestController.class.php | 19 ++-------- webapp/controller/RoleController.class.php | 21 ++--------- webapp/controller/ShareController.class.php | 17 +-------- webapp/controller/ShopController.class.php | 22 ++--------- webapp/mt/Drop.php | 37 +++++++++++++++++++ 7 files changed, 54 insertions(+), 105 deletions(-) create mode 100644 webapp/mt/Drop.php diff --git a/webapp/controller/GameOverController.class.php b/webapp/controller/GameOverController.class.php index a0ea0457..89374a4f 100644 --- a/webapp/controller/GameOverController.class.php +++ b/webapp/controller/GameOverController.class.php @@ -5,12 +5,10 @@ require 'classes/AddReward.php'; require_once 'metatable/parameter.php'; require_once('mt/Parameter.php'); +require_once('mt/Drop.php'); class GameOverController extends BaseAuthedController { - - - protected function getBox($box_id) { $box_meta_table = require('../res/box@box.php'); @@ -58,20 +56,6 @@ class GameOverController extends BaseAuthedController { return $e; } - protected function getDrop($drop_id) - { - $drop_meta_table = require('../res/drop@drop.php'); - $drop_meta = getDropConfig($drop_meta_table, $drop_id); - $d = array( - 'drop_id' => $drop_meta['drop_id'], - 'item_id' => $drop_meta['item_id'], - 'num' => $drop_meta['num'], - 'weight' => $drop_meta['weight'], - 'type' => $drop_meta['type'] - ); - return $d; - } - protected function getRankReward($rank) { $rank_meta_table = require('../res/rankReward@rankReward.php'); @@ -278,10 +262,10 @@ class GameOverController extends BaseAuthedController { { //随机奖励 $r = $this->getRankReward($rank); - $b = $this->getDrop($r['ad_drop']); + $b = mt\Drop::getOldDrop($r['ad_drop']); $count = $r['ad_num']; if ($type == 1) { - $b = $this->getDrop($r['js_drop']); + $b = mt\Drop::getOldDrop($r['js_drop']); $count = $r['js_num']; } $item_list = array(); diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index d2ce15b5..f2ba8bf3 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -4,6 +4,7 @@ require 'classes/Quest.php'; require 'classes/AddReward.php'; require_once('mt/Parameter.php'); +require_once('mt/Drop.php'); class PayController extends BaseAuthedController { @@ -64,22 +65,6 @@ class PayController extends BaseAuthedController { return $diamond; } - - protected function getDrop($drop_id) - { - $drop_meta_table = require('../res/drop@drop.php'); - $drop_meta = getDropConfig($drop_meta_table, $drop_id); - $d = array( - 'drop_id' => $drop_meta['drop_id'], - 'item_id' => $drop_meta['item_id'], - 'num' => $drop_meta['num'], - 'weight' => $drop_meta['weight'], - 'type' => $drop_meta['type'], - 'time' => $drop_meta['time'], - ); - return $d; - } - protected function getExplode($string) { $delim = "|"; @@ -95,7 +80,7 @@ class PayController extends BaseAuthedController { protected function getItemInfo($itemid) { - $d = $this->getDrop($itemid); + $d = mt\Drop::getOldDrop($itemid); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); die(); @@ -311,7 +296,7 @@ class PayController extends BaseAuthedController { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); die(); } - $d = $this->getDrop($item['fuctionindex']); + $d = mt\Drop::getOldDrop($item['fuctionindex']); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); die(); diff --git a/webapp/controller/QuestController.class.php b/webapp/controller/QuestController.class.php index ef334065..58bb13f1 100644 --- a/webapp/controller/QuestController.class.php +++ b/webapp/controller/QuestController.class.php @@ -3,6 +3,8 @@ require 'classes/Quest.php'; require 'classes/AddReward.php'; +require_once('mt/Drop.php'); + class QuestController extends BaseAuthedController { @@ -33,21 +35,6 @@ class QuestController extends BaseAuthedController { return $arr; } - protected function getDrop($drop_id) - { - $g_conf_drop_cluster = require('../res/drop@drop.php'); - $drop_conf = getDropConfig($g_conf_drop_cluster, $drop_id); - $d = array( - 'drop_id' => $drop_conf['drop_id'], - 'item_id' => $drop_conf['item_id'], - 'num' => $drop_conf['num'], - 'weight' => $drop_conf['weight'], - 'type' => $drop_conf['type'] - ); - return $d; - } - - public function questInfo() { $account_id = $_REQUEST['account_id']; @@ -115,7 +102,7 @@ class QuestController extends BaseAuthedController { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务'); return; } - $d = $this->getDrop($t['reward']); + $d = mt\Drop::getOldDrop($t['reward']); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); return; diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index f5fe6e0d..8d536d2c 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -5,23 +5,10 @@ require 'classes/AddReward.php'; require 'NTaskController.class.php'; require_once('mt/Parameter.php'); +require_once('mt/Drop.php'); class RoleController extends BaseAuthedController { - protected function getDrop($drop_id) - { - $g_conf_drop_cluster = require('../res/drop@drop.php'); - $drop_conf = getDropConfig($g_conf_drop_cluster, $drop_id); - $d = array( - 'drop_id' => $drop_conf['drop_id'], - 'item_id' => $drop_conf['item_id'], - 'num' => $drop_conf['num'], - 'weight' => $drop_conf['weight'], - 'type' => $drop_conf['type'] - ); - return $d; - } - protected function getEquipUp($equipUp_id) { $g_conf_equipUp_cluster = require('../res/equipUpgrade@equipUpgrade.php'); @@ -1063,7 +1050,7 @@ class RoleController extends BaseAuthedController { die(); return; } - $d = $this->getDrop(24003); + $d = mt\Drop::getOldDrop(24003); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); return; @@ -1108,7 +1095,7 @@ class RoleController extends BaseAuthedController { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } - $d = $this->getDrop(24003); + $d = mt\Drop::getOldDrop(24003); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); return; @@ -1311,7 +1298,7 @@ class RoleController extends BaseAuthedController { } - $d = $this->getDrop($reward_id); + $d = mt\Drop::getOldDrop($reward_id); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); return; diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index f3807112..033a5d69 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -4,25 +4,10 @@ require 'classes/AddReward.php'; require 'classes/Quest.php'; require_once('mt/Parameter.php'); +require_once('mt/Drop.php'); class ShareController extends BaseAuthedController { - - - protected function getDrop($drop_id) - { - $drop_meta_table = require('../res/drop@drop.php'); - $drop_meta = getDropConfig($drop_meta_table, $drop_id); - $d = array( - 'drop_id' => $drop_meta['drop_id'], - 'item_id' => $drop_meta['item_id'], - 'num' => $drop_meta['num'], - 'weight' => $drop_meta['weight'], - 'type' => $drop_meta['type'] - ); - return $d; - } - protected function getBox($box_id) { $box_meta_table = require('../res/box@box.php'); diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index b349a1bf..bbaed755 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -6,6 +6,7 @@ require_once 'metatable/shopGoods.php'; require_once 'metatable/parameter.php'; require_once('mt/Parameter.php'); +require_once('mt/Drop.php'); class ShopController extends BaseAuthedController { @@ -51,23 +52,6 @@ class ShopController extends BaseAuthedController { return $it; } - protected function getDrop($drop_id) - { - $drop_meta_table = require('../res/drop@drop.php'); - $drop_meta = getDropConfig($drop_meta_table, $drop_id); - if (!$drop_meta) { - return null; - } - $d = array( - 'drop_id' => $drop_meta['drop_id'], - 'item_id' => $drop_meta['item_id'], - 'num' => $drop_meta['num'], - 'weight' => $drop_meta['weight'], - 'type' => $drop_meta['type'] - ); - return $d; - } - protected function getExplode($string) { $delim = "|"; @@ -521,7 +505,7 @@ class ShopController extends BaseAuthedController { } $item_conf = $this->getItem($id); $item_fuctionindex = $item_conf['fuctionindex']; - $drop_conf = $this->getDrop($item_fuctionindex); + $drop_conf = mt\Drop::getOldDrop($item_fuctionindex); if (!$item_conf) { phpcommon\sendError(ERR_USER_BASE + 5,'没有这个道具'); return; @@ -594,7 +578,7 @@ class ShopController extends BaseAuthedController { { $airReward_list = array(); //随机奖励 - $d = $this->getDrop($drop_id); + $d = mt\Drop::getOldDrop($drop_id); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); die(); diff --git a/webapp/mt/Drop.php b/webapp/mt/Drop.php new file mode 100644 index 00000000..4f186148 --- /dev/null +++ b/webapp/mt/Drop.php @@ -0,0 +1,37 @@ + $meta['drop_id'], + 'item_id' => $meta['item_id'], + 'num' => $meta['num'], + 'weight' => $meta['weight'], + 'type' => $meta['type'], + 'time' => $meta['time'], + ); + } + + protected static function getMetaList() + { + if (!self::$metaList) { + self::$metaList = getMetaTable('drop@drop.php'); + } + return self::$metaList; + } + + protected static $metaList; + +}