添加使用礼包
This commit is contained in:
parent
b4eda8b18b
commit
1d35055236
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
|
require_once('mt/Drop.php');
|
||||||
|
|
||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
|
|
||||||
@ -54,10 +55,7 @@ class BagController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, '配置表错误');
|
$this->_rspErr(2, '配置表错误');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($itemMeta['type'] != mt\Item::FUNC_TYPE) {
|
if ($itemMeta['type'] == mt\Item::FUNC_TYPE) {
|
||||||
$this->_rspErr(3, '该道具为不可使用道具');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch ($itemMeta['sub_type']) {
|
switch ($itemMeta['sub_type']) {
|
||||||
case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
|
case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
|
||||||
{
|
{
|
||||||
@ -71,6 +69,11 @@ class BagController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if ($itemMeta['type'] == mt\Item::GIFT_PACKAGE_TYPE) {
|
||||||
|
$this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
|
||||||
|
} else {
|
||||||
|
$this->_rspErr(4, '该道具功能暂未实现');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rename()
|
public function rename()
|
||||||
@ -174,4 +177,35 @@ class BagController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3)
|
||||||
|
{
|
||||||
|
$dropMeta = mt\Drop::get($itemMeta['drop']);
|
||||||
|
if (!$dropMeta) {
|
||||||
|
$this->_rspErr(1, '配置表错误');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$costItems = mt\Item::getUseCostItems($itemMeta);
|
||||||
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
$this->_decItems(array(
|
||||||
|
array(
|
||||||
|
'item_id' => $itemMeta['id'],
|
||||||
|
'item_num' => 1
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$this->_scatterDrop('gift_package:' . $itemMeta['id'],
|
||||||
|
$dropMeta,
|
||||||
|
$this->awardService,
|
||||||
|
$this->propertyChgService);
|
||||||
|
$this->propertyChgService->addBagChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'award' => $this->awardService->toDto(),
|
||||||
|
'property_chg' => $this->propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,22 @@ class Item {
|
|||||||
return $costItems;
|
return $costItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUseCostItems($itemMeta)
|
||||||
|
{
|
||||||
|
$costItems = array();
|
||||||
|
$tmpStrs1 = splitStr1($itemMeta['use_cost']);
|
||||||
|
foreach ($tmpStrs1 as $tmpStr1) {
|
||||||
|
$tmpStrs2 = splitStr2($tmpStr1);
|
||||||
|
if (count($tmpStrs2) >= 2) {
|
||||||
|
array_push($costItems, array(
|
||||||
|
'item_id' => $tmpStrs2[0],
|
||||||
|
'item_num' => $tmpStrs2[1]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $costItems;
|
||||||
|
}
|
||||||
|
|
||||||
public static function isBagItem($type, $subType)
|
public static function isBagItem($type, $subType)
|
||||||
{
|
{
|
||||||
return in_array($type, array(
|
return in_array($type, array(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user