_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() { } }