From 55706437ccc1aa42cf90efd68fc55340d922b765 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Nov 2021 13:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90getItem=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActivityController.class.php | 20 +--------- webapp/controller/AdditemController.class.php | 17 +------- webapp/controller/BagController.class.php | 15 +------ webapp/controller/EquipController.class.php | 28 +++---------- webapp/controller/PayController.class.php | 26 ++---------- webapp/controller/ShopController.class.php | 29 ++------------ webapp/controller/SignController.class.php | 18 +-------- webapp/mt/Item.php | 40 +++++++++++++++++++ 8 files changed, 59 insertions(+), 134 deletions(-) create mode 100644 webapp/mt/Item.php diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index fbc4f11..19e0e05 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -7,11 +7,10 @@ require_once 'metatable/draw.php'; require_once 'metatable/parameter.php'; require_once('mt/Parameter.php'); +require_once('mt/Item.php'); class ActivityController extends BaseAuthedController { - - protected function getBox($box_id) { $box_meta_table = require('../res/box@box.php'); @@ -44,20 +43,6 @@ class ActivityController extends BaseAuthedController { return $l; } - protected function getItem($item_id) - { - $g_conf_item_cluster = require('../res/item@item.php'); - $item_conf = getItemConfig($g_conf_item_cluster, $item_id); - $it = array( - 'id' => $item_conf['id'], - 'diamond' => $item_conf['diamond'], - 'type' => $item_conf['fuction'], - 'diamond_hour' => $item_conf['diamond_hour'], - 'pool_weight' => $item_conf['pool_weight'], - ); - return $it; - } - protected function getDrawTableConfig($id) { $g_conf_lot_cluster = require('../res/lotterydraw@lotterydraw.php'); @@ -741,7 +726,7 @@ class ActivityController extends BaseAuthedController { $g_conf_item_cluster = require('../res/item@item.php'); foreach($g_conf_item_cluster as $items) { $flag = 0; - $it = $this->getItem($items['id']); + $it = mt\Item::getOldItem($items['id']); if ($it['id'] != 0) { foreach ($id as $ids) { if ($it['id'] == $ids['id']) { @@ -1243,4 +1228,3 @@ class ActivityController extends BaseAuthedController { )); } } -?> diff --git a/webapp/controller/AdditemController.class.php b/webapp/controller/AdditemController.class.php index 2846b1a..1004799 100644 --- a/webapp/controller/AdditemController.class.php +++ b/webapp/controller/AdditemController.class.php @@ -1,22 +1,10 @@ $item_conf['id'], - 'diamond' => $item_conf['diamond'], - 'type' => $item_conf['fuction'], - 'diamond_hour' => $item_conf['diamond_hour'] - ); - return $it; - } - protected function getBag($bag_id) { $g_conf_bag_cluster = require('../res/bag@bag.php'); @@ -47,7 +35,7 @@ class AdditemController extends BaseAuthedController { die(); return; } - $it = $this->getItem($item_id); + $it = mt\Item::getOldItem($item_id); if (!$it) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); die(); @@ -256,4 +244,3 @@ class AdditemController extends BaseAuthedController { } } } -?> diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index dc83345..215b63e 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -5,6 +5,7 @@ require 'classes/AddReward.php'; require_once 'metatable/drop.php'; require_once('mt/Parameter.php'); +require_once('mt/Item.php'); class BagController extends BaseAuthedController { @@ -23,20 +24,6 @@ class BagController extends BaseAuthedController { return $b; } - protected function getItem($item_id) - { - $g_conf_item_cluster = require('../res/item@item.php'); - $item_conf = getItemConfig($g_conf_item_cluster, $item_id); - $it = array( - 'id' => $item_conf['id'], - 'diamond' => $item_conf['diamond'], - 'dprice' => $item_conf['dprice'], - 'type' => $item_conf['fuction'], - 'diamond_hour' => $item_conf['diamond_hour'] - ); - return $it; - } - public function getBagInfo() { $account_id = $_REQUEST['account_id']; diff --git a/webapp/controller/EquipController.class.php b/webapp/controller/EquipController.class.php index a2d2b84..a371041 100644 --- a/webapp/controller/EquipController.class.php +++ b/webapp/controller/EquipController.class.php @@ -4,27 +4,10 @@ require 'classes/Quest.php'; require 'classes/AddReward.php'; require_once('mt/Equip.php'); +require_once('mt/Item.php'); class EquipController extends BaseAuthedController { - - protected function getItem($item_id) - { - $g_conf_item_cluster = require('../res/item@item.php'); - $item_conf = getItemConfig($g_conf_item_cluster, $item_id); - $it = array( - 'id' => $item_conf['id'], - 'diamond' => $item_conf['diamond'], - //'dprice' => $item_conf['dprice'], - 'type' => $item_conf['fuction'], - 'diamond_hour' => $item_conf['diamond_hour'], - 'synthesis' => $item_conf['synthesis'], - 'needid' => $item_conf['needid'], - 'cost' => $item_conf['cost'], - ); - return $it; - } - public function equipInfo() { $account_id = $_REQUEST['account_id']; @@ -316,7 +299,7 @@ class EquipController extends BaseAuthedController { } $addreward = new classes\AddReward(); foreach ($arr3 as $ar) { - $it = $this->getItem($ar[0]); + $it = mt\Item::getOldItem($ar[0]); if (!$it) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); return; @@ -404,7 +387,7 @@ class EquipController extends BaseAuthedController { return; } - $it = $this->getItem($item_id); + $it = mt\Item::getOldItem($item_id); if (!$it) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); die(); @@ -586,7 +569,7 @@ class EquipController extends BaseAuthedController { return; } - $it = $this->getItem($id); + $it = mt\Item::getOldItem($id); if (!$it) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); die(); @@ -637,7 +620,7 @@ class EquipController extends BaseAuthedController { ':account_id' => $account_id, ':id' => $id )); - $item = $this->getItem($id); + $item = mt\Item::getOldItem($id); if (!$item || empty($item['synthesis'])) { phpcommon\sendError(ERR_USER_BASE + 2,'没有这个道具'); return; @@ -679,4 +662,3 @@ class EquipController extends BaseAuthedController { )); } } -?> diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index 5107c48..d3744fd 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -5,28 +5,11 @@ require 'classes/AddReward.php'; require_once('mt/Parameter.php'); require_once('mt/Drop.php'); +require_once('mt/Item.php'); class PayController extends BaseAuthedController { private $vipTableCache = null; - private $itemTableCache = null; - protected function getItem($item_id) - { - if ($this->itemTableCache == null) { - $this->itemTableCache = require('../res/item@item.php'); - } - $item_meta = getItemConfig($this->itemTableCache, $item_id); - $item = array( - 'id' => $item_meta['id'], - 'name' => $item_meta['name'], - //'price' => $item_meta['price'], - 'icon' => $item_meta['icon'], - 'fuction' => $item_meta['fuction'], - 'fuctionindex' => $item_meta['fuctionindex'], - //'dprice' => $item_meta['dprice'], - ); - return $item; - } protected function getVip($vip_id) { @@ -113,7 +96,7 @@ class PayController extends BaseAuthedController { $diamond_meta_table = require('../res/diamondshop@diamondshop.php'); for ($i = 1; $i <= count($diamond_meta_table); $i++) { $diamond = $this->getDiamondShop($i); - $item = $this->getItem($diamond['item_id']); + $item = mt\Item::getOldItem($diamond['item_id']); $item_list = $this->getItemInfo($item['fuctionindex']); if (!$item || !$diamond) { continue; @@ -144,7 +127,7 @@ class PayController extends BaseAuthedController { $open_time = '-1'; $end_time = '-1'; if ($diamond['coin_type'] != 0) { - $sub_item = $this->getItem($diamond['coin_type']); + $sub_item = mt\Item::getOldItem($diamond['coin_type']); $coin_icon = $sub_item['icon']; } else { //免费金币钻石领取次数及有效时间 @@ -266,7 +249,7 @@ class PayController extends BaseAuthedController { protected function getVipItemInfo($id) { - $item = $this->getItem($id); + $item = mt\Item::getOldItem($id); if (!$item) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); die(); @@ -560,4 +543,3 @@ class PayController extends BaseAuthedController { } } -?> diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 87bb881..9215276 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -7,33 +7,10 @@ require_once 'metatable/parameter.php'; require_once('mt/Parameter.php'); require_once('mt/Drop.php'); +require_once('mt/Item.php'); class ShopController extends BaseAuthedController { - - protected function getItem($item_id) - { - $g_conf_item_cluster = require('../res/item@item.php'); - $item_conf = getItemConfig($g_conf_item_cluster, $item_id); - if (!$item_conf) { - return null; - } - $it = array( - 'id' => $item_conf['id'], - 'price' => $item_conf['gold'], - 'dprice' => $item_conf['diamond_price'], - 'discount' => $item_conf['discount'], - 'shop_type' => $item_conf['shop_type'], - 'type' => $item_conf['fuction'], - 'bug_groupnum' => $item_conf['bug_groupnum'], - 'shop_list' => $item_conf['shop_list'], - 'bug_groupnum' => $item_conf['bug_groupnum'], - 'Isbug_again' => $item_conf['Isbug_again'], - 'fuctionindex' => $item_conf['fuctionindex'], - ); - return $it; - } - protected function getItemEx(&$g_conf_item_cluster, $item_id) { $item_conf = getItemConfig($g_conf_item_cluster, $item_id); @@ -472,7 +449,7 @@ class ShopController extends BaseAuthedController { if ($redis_goods['isdiscount']) { $price = ceil($price * $redis_goods['dis_num'] / 100); } - $item_conf = $this->getItem($id); + $item_conf = mt\Item::getOldItem($id); $item_fuctionindex = $item_conf['fuctionindex']; $drop_conf = mt\Drop::getOldDrop($item_fuctionindex); if (!$item_conf) { @@ -755,7 +732,7 @@ class ShopController extends BaseAuthedController { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } - $i = $this->getItem($id); + $i = mt\Item::getOldItem($id); $price = 0; if ($i['shop_type'] == 1) { $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index b0516d7..f16cf8f 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -6,6 +6,7 @@ require 'classes/AddReward.php'; require_once('mt/Parameter.php'); require_once('mt/Season.php'); require_once('mt/SeasonPoint.php'); +require_once('mt/Item.php'); class SignController extends BaseAuthedController { @@ -24,21 +25,6 @@ class SignController extends BaseAuthedController { return $s; } - protected function getItem($item_id) - { - $g_conf_item_cluster = require('../res/item@item.php'); - $item_conf = getItemConfig($g_conf_item_cluster, $item_id); - $it = array( - 'id' => $item_conf['id'], - 'diamond' => $item_conf['diamond'], - 'type' => $item_conf['fuction'], - 'diamond_hour' => $item_conf['diamond_hour'], - 'pool_weight' => $item_conf['pool_weight'], - 'name' => $item_conf['name'] - ); - return $it; - } - protected function getShare($share_id) { $share_meta_table = require('../res/share@share.php'); @@ -580,7 +566,7 @@ class SignController extends BaseAuthedController { } else if ($rowUser['sign_sum'] == 7) { $item_name = '神秘宝箱'; } else { - $it = $this->getItem($item['item_id']); + $it = mt\Item::getOldItem($item['item_id']); $item_name = $it['name']; $item_num = $item['num']; } diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php new file mode 100644 index 0000000..075498c --- /dev/null +++ b/webapp/mt/Item.php @@ -0,0 +1,40 @@ + $val) { + $item[$key] = $val; + } + $item['type'] = $item['fuction']; + $item['price'] = $item['gold']; + $item['dprice'] = $item['diamond_price']; + return $item; + } + + protected static function getMetaList() + { + if (!self::$metaList) { + self::$metaList = getMetaTable('item@item.php'); + } + return self::$metaList; + } + + protected static $metaList; + +}