完成getItem改造
This commit is contained in:
parent
a7df1cfcd9
commit
55706437cc
@ -7,11 +7,10 @@ require_once 'metatable/draw.php';
|
|||||||
require_once 'metatable/parameter.php';
|
require_once 'metatable/parameter.php';
|
||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class ActivityController extends BaseAuthedController {
|
class ActivityController extends BaseAuthedController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function getBox($box_id)
|
protected function getBox($box_id)
|
||||||
{
|
{
|
||||||
$box_meta_table = require('../res/box@box.php');
|
$box_meta_table = require('../res/box@box.php');
|
||||||
@ -44,20 +43,6 @@ class ActivityController extends BaseAuthedController {
|
|||||||
return $l;
|
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)
|
protected function getDrawTableConfig($id)
|
||||||
{
|
{
|
||||||
$g_conf_lot_cluster = require('../res/lotterydraw@lotterydraw.php');
|
$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');
|
$g_conf_item_cluster = require('../res/item@item.php');
|
||||||
foreach($g_conf_item_cluster as $items) {
|
foreach($g_conf_item_cluster as $items) {
|
||||||
$flag = 0;
|
$flag = 0;
|
||||||
$it = $this->getItem($items['id']);
|
$it = mt\Item::getOldItem($items['id']);
|
||||||
if ($it['id'] != 0) {
|
if ($it['id'] != 0) {
|
||||||
foreach ($id as $ids) {
|
foreach ($id as $ids) {
|
||||||
if ($it['id'] == $ids['id']) {
|
if ($it['id'] == $ids['id']) {
|
||||||
@ -1243,4 +1228,3 @@ class ActivityController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -1,22 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class AdditemController extends BaseAuthedController {
|
class AdditemController 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'],
|
|
||||||
'type' => $item_conf['fuction'],
|
|
||||||
'diamond_hour' => $item_conf['diamond_hour']
|
|
||||||
);
|
|
||||||
return $it;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getBag($bag_id)
|
protected function getBag($bag_id)
|
||||||
{
|
{
|
||||||
$g_conf_bag_cluster = require('../res/bag@bag.php');
|
$g_conf_bag_cluster = require('../res/bag@bag.php');
|
||||||
@ -47,7 +35,7 @@ class AdditemController extends BaseAuthedController {
|
|||||||
die();
|
die();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$it = $this->getItem($item_id);
|
$it = mt\Item::getOldItem($item_id);
|
||||||
if (!$it) {
|
if (!$it) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
||||||
die();
|
die();
|
||||||
@ -256,4 +244,3 @@ class AdditemController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -5,6 +5,7 @@ require 'classes/AddReward.php';
|
|||||||
require_once 'metatable/drop.php';
|
require_once 'metatable/drop.php';
|
||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class BagController extends BaseAuthedController {
|
class BagController extends BaseAuthedController {
|
||||||
|
|
||||||
@ -23,20 +24,6 @@ class BagController extends BaseAuthedController {
|
|||||||
return $b;
|
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()
|
public function getBagInfo()
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
@ -4,27 +4,10 @@ require 'classes/Quest.php';
|
|||||||
require 'classes/AddReward.php';
|
require 'classes/AddReward.php';
|
||||||
|
|
||||||
require_once('mt/Equip.php');
|
require_once('mt/Equip.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class EquipController extends BaseAuthedController {
|
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()
|
public function equipInfo()
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
@ -316,7 +299,7 @@ class EquipController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
$addreward = new classes\AddReward();
|
$addreward = new classes\AddReward();
|
||||||
foreach ($arr3 as $ar) {
|
foreach ($arr3 as $ar) {
|
||||||
$it = $this->getItem($ar[0]);
|
$it = mt\Item::getOldItem($ar[0]);
|
||||||
if (!$it) {
|
if (!$it) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
||||||
return;
|
return;
|
||||||
@ -404,7 +387,7 @@ class EquipController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$it = $this->getItem($item_id);
|
$it = mt\Item::getOldItem($item_id);
|
||||||
if (!$it) {
|
if (!$it) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
||||||
die();
|
die();
|
||||||
@ -586,7 +569,7 @@ class EquipController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$it = $this->getItem($id);
|
$it = mt\Item::getOldItem($id);
|
||||||
if (!$it) {
|
if (!$it) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
||||||
die();
|
die();
|
||||||
@ -637,7 +620,7 @@ class EquipController extends BaseAuthedController {
|
|||||||
':account_id' => $account_id,
|
':account_id' => $account_id,
|
||||||
':id' => $id
|
':id' => $id
|
||||||
));
|
));
|
||||||
$item = $this->getItem($id);
|
$item = mt\Item::getOldItem($id);
|
||||||
if (!$item || empty($item['synthesis'])) {
|
if (!$item || empty($item['synthesis'])) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2,'没有这个道具');
|
phpcommon\sendError(ERR_USER_BASE + 2,'没有这个道具');
|
||||||
return;
|
return;
|
||||||
@ -679,4 +662,3 @@ class EquipController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -5,28 +5,11 @@ require 'classes/AddReward.php';
|
|||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Drop.php');
|
require_once('mt/Drop.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class PayController extends BaseAuthedController {
|
class PayController extends BaseAuthedController {
|
||||||
|
|
||||||
private $vipTableCache = null;
|
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)
|
protected function getVip($vip_id)
|
||||||
{
|
{
|
||||||
@ -113,7 +96,7 @@ class PayController extends BaseAuthedController {
|
|||||||
$diamond_meta_table = require('../res/diamondshop@diamondshop.php');
|
$diamond_meta_table = require('../res/diamondshop@diamondshop.php');
|
||||||
for ($i = 1; $i <= count($diamond_meta_table); $i++) {
|
for ($i = 1; $i <= count($diamond_meta_table); $i++) {
|
||||||
$diamond = $this->getDiamondShop($i);
|
$diamond = $this->getDiamondShop($i);
|
||||||
$item = $this->getItem($diamond['item_id']);
|
$item = mt\Item::getOldItem($diamond['item_id']);
|
||||||
$item_list = $this->getItemInfo($item['fuctionindex']);
|
$item_list = $this->getItemInfo($item['fuctionindex']);
|
||||||
if (!$item || !$diamond) {
|
if (!$item || !$diamond) {
|
||||||
continue;
|
continue;
|
||||||
@ -144,7 +127,7 @@ class PayController extends BaseAuthedController {
|
|||||||
$open_time = '-1';
|
$open_time = '-1';
|
||||||
$end_time = '-1';
|
$end_time = '-1';
|
||||||
if ($diamond['coin_type'] != 0) {
|
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'];
|
$coin_icon = $sub_item['icon'];
|
||||||
} else {
|
} else {
|
||||||
//免费金币钻石领取次数及有效时间
|
//免费金币钻石领取次数及有效时间
|
||||||
@ -266,7 +249,7 @@ class PayController extends BaseAuthedController {
|
|||||||
|
|
||||||
protected function getVipItemInfo($id)
|
protected function getVipItemInfo($id)
|
||||||
{
|
{
|
||||||
$item = $this->getItem($id);
|
$item = mt\Item::getOldItem($id);
|
||||||
if (!$item) {
|
if (!$item) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具');
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具');
|
||||||
die();
|
die();
|
||||||
@ -560,4 +543,3 @@ class PayController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -7,33 +7,10 @@ require_once 'metatable/parameter.php';
|
|||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Drop.php');
|
require_once('mt/Drop.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class ShopController extends BaseAuthedController {
|
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)
|
protected function getItemEx(&$g_conf_item_cluster, $item_id)
|
||||||
{
|
{
|
||||||
$item_conf = getItemConfig($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']) {
|
if ($redis_goods['isdiscount']) {
|
||||||
$price = ceil($price * $redis_goods['dis_num'] / 100);
|
$price = ceil($price * $redis_goods['dis_num'] / 100);
|
||||||
}
|
}
|
||||||
$item_conf = $this->getItem($id);
|
$item_conf = mt\Item::getOldItem($id);
|
||||||
$item_fuctionindex = $item_conf['fuctionindex'];
|
$item_fuctionindex = $item_conf['fuctionindex'];
|
||||||
$drop_conf = mt\Drop::getOldDrop($item_fuctionindex);
|
$drop_conf = mt\Drop::getOldDrop($item_fuctionindex);
|
||||||
if (!$item_conf) {
|
if (!$item_conf) {
|
||||||
@ -755,7 +732,7 @@ class ShopController extends BaseAuthedController {
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$i = $this->getItem($id);
|
$i = mt\Item::getOldItem($id);
|
||||||
$price = 0;
|
$price = 0;
|
||||||
if ($i['shop_type'] == 1) {
|
if ($i['shop_type'] == 1) {
|
||||||
$row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;',
|
$row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;',
|
||||||
|
@ -6,6 +6,7 @@ require 'classes/AddReward.php';
|
|||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Season.php');
|
require_once('mt/Season.php');
|
||||||
require_once('mt/SeasonPoint.php');
|
require_once('mt/SeasonPoint.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
class SignController extends BaseAuthedController {
|
class SignController extends BaseAuthedController {
|
||||||
|
|
||||||
@ -24,21 +25,6 @@ class SignController extends BaseAuthedController {
|
|||||||
return $s;
|
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)
|
protected function getShare($share_id)
|
||||||
{
|
{
|
||||||
$share_meta_table = require('../res/share@share.php');
|
$share_meta_table = require('../res/share@share.php');
|
||||||
@ -580,7 +566,7 @@ class SignController extends BaseAuthedController {
|
|||||||
} else if ($rowUser['sign_sum'] == 7) {
|
} else if ($rowUser['sign_sum'] == 7) {
|
||||||
$item_name = '神秘宝箱';
|
$item_name = '神秘宝箱';
|
||||||
} else {
|
} else {
|
||||||
$it = $this->getItem($item['item_id']);
|
$it = mt\Item::getOldItem($item['item_id']);
|
||||||
$item_name = $it['name'];
|
$item_name = $it['name'];
|
||||||
$item_num = $item['num'];
|
$item_num = $item['num'];
|
||||||
}
|
}
|
||||||
|
40
webapp/mt/Item.php
Normal file
40
webapp/mt/Item.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace mt;
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
|
||||||
|
class Item {
|
||||||
|
|
||||||
|
public static function get($id)
|
||||||
|
{
|
||||||
|
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getOldItem($id)
|
||||||
|
{
|
||||||
|
$meta = self::get($id);
|
||||||
|
if (!$meta) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$item = array();
|
||||||
|
foreach ($meta as $key => $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;
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user