game2006api/webapp/controller/ShopController.class.php
aozhiwei fcabb09109 1
2021-11-26 17:30:56 +08:00

74 lines
1.9 KiB
PHP

<?php
require_once('mt/Shop.php');
require_once('mt/Hero.php');
require_once('mt/Item.php');
require_once('mt/Parameter.php');
require_once('mt/Drop.php');
use phpcommon\SqlHelper;
class ShopController extends BaseAuthedController {
public function buyHero()
{
$heroId = getReqVal('hero_id', 0);
$buyType = getReqVal('buy_type', 0);
$heroMeta = mt\Hero::get($heroId);
if ($heroMeta) {
$this->_rspErr(1, 'hero_id参数错误');
return;
}
if (empty($heroMeta['itemid'])) {
$this->_rspErr(2, 'hero.item_id配置错误');
return;
}
if (!in_array($buyType, array(0, 1))) {
$this->_rspErr(1, 'buy_type参数错误');
return;
}
$shopMeta = mt\Shop::get(mt\Shop::HERO_SHOP_ID);
if (!$shopMeta) {
$this->_rspErr(2, '配置表错误');
return;
}
$goodsInfo = mt\Shop::getGoodsInfo($shopMeta, $heroMeta['itemid']);
if (empty($goodsInfo)) {
$this->_rspErr(2, '配置表错误');
return;
}
$costItems = array(
'item_id' => $goodsInfo['costItemId'],
'item_num' => $goodsInfo['costItemNum'],
);
$lackItem = null;
if (!$this->_hasEnoughItemsEx($costItems, $lackItem)) {
$this->_rspErr(3, '道具不足');
return;
}
$this->_decItems($costItems);
Hero::addHero($heroMeta);
}
public function buyHeroSkin()
{
$skinId = getReqVal('skin_id', 0);
$skinMeta = mt\Item::get($skinId);
if (!$skinMeta) {
$this->_rspErr(1, 'skin_id参数错误');
return;
}
if (!mt\Item::isType($skinMeta, mt\Item::SKIN_TYPE)){
$this->_rspErr(1, 'skin_id参数错误');
return;
}
HeroSkin::addSkin($skinId);
}
public function buyGunSkin()
{
}
}