完成Drop改造

This commit is contained in:
aozhiwei 2021-11-22 10:41:52 +08:00
parent 30793b9f5d
commit 9a7a8bf401
7 changed files with 54 additions and 105 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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');

View File

@ -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();

37
webapp/mt/Drop.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace mt;
use phpcommon;
class Drop {
public static function get($id)
{
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
}
public static function getOldDrop($id)
{
$meta = self::get($id);
return array(
'drop_id' => $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;
}