diff --git a/doc/Gun.py b/doc/Gun.py index 7fafbc3..ff6c2e6 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -58,19 +58,4 @@ class Gun(object): ['data', _common.GunSkinInfo(), '枪支皮肤信息'] ] }, - { - 'desc': '购买枪支皮肤buyGunSkin', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=buyGunSkin', - 'params': [ - _common.ReqHead(), - ['gun_id', 0, '枪支id'], - ['skin_id', 0, '皮肤id'], - ['goodsID', 0, '商品id'], - ], - 'response': [ - _common.RspHead(), - ['data', _common.GunSkinInfo(), '枪支皮肤信息'] - ] - }, ] diff --git a/doc/Hero.py b/doc/Hero.py index 970d10b..d5ee007 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -32,33 +32,6 @@ class Hero(object): ['!skin_list', _common.HeroSkin, '英雄皮肤列表'] ] }, - { - 'name': 'buyHero', - 'desc': '购买英雄', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=buyHero', - 'params': [ - _common.ReqHead(), - ['hero_id', '', '英雄id'], - ['buy_type', '', '购买类型0:指购买英雄 1:购买英雄和皮肤'], - ], - 'response': [ - _common.RspHead(), - ['award', _common.Award, '奖励信息'], - ] - }, - { - 'name': 'buySkin', - 'desc': '购买皮肤', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=buySkin', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, { 'name': 'takeonSkin', 'desc': '穿戴皮肤', diff --git a/doc/Shop.py b/doc/Shop.py index ee5fa77..d17ea3c 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -6,48 +6,46 @@ class Shop(object): def __init__(self): self.apis_ = [ - { - 'desc': 'newShopInfo', - 'group': 'Shop', - 'url': 'webapp/index.php?c=Shop&a=newShopInfo', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'flushShopItem', - 'group': 'Shop', - 'url': 'webapp/index.php?c=Shop&a=flushShopItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'newBuyShopItem', - 'group': 'Shop', - 'url': 'webapp/index.php?c=Shop&a=newBuyShopItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'shopBuyMore', - 'group': 'Shop', - 'url': 'webapp/index.php?c=Shop&a=shopBuyMore', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, + { + 'name': 'buyHero', + 'desc': '购买英雄', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=buyHero', + 'params': [ + _common.ReqHead(), + ['hero_id', '', '英雄id'], + ['buy_type', '', '购买类型0:指购买英雄 1:购买英雄和皮肤'], + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award, '奖励信息'], + ] + }, + { + 'name': 'buySkin', + 'desc': '购买皮肤', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=buySkin', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'desc': '购买枪支皮肤buyGunSkin', + 'group': 'Shop', + 'url': 'webapp/index.php?c=Shop&a=buyGunSkin', + 'params': [ + _common.ReqHead(), + ['gun_id', 0, '枪支id'], + ['skin_id', 0, '皮肤id'], + ['goodsID', 0, '商品id'], + ], + 'response': [ + _common.RspHead(), + ['data', _common.GunSkinInfo(), '枪支皮肤信息'] + ] + }, ] diff --git a/doc/User.py b/doc/User.py index c84db89..7f90949 100644 --- a/doc/User.py +++ b/doc/User.py @@ -31,21 +31,6 @@ class User(object): _common.RspHead(), ] }, - { - 'name': 'getRobotInfo', - 'desc': '获取机器人信息', - 'group': 'User', - 'url': 'webapp/index.php?c=User&a=getRobotInfo', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!member_list', _common.RobotInfo(), '机器人数据'], - ['!sin_member', _common.RobotMetaInfo(), '机器人列表'], - ['num', 0, '货币数量'], - ] - }, ] self.internalApis = [ { diff --git a/doc/_common.py b/doc/_common.py index a8d2539..0b808aa 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -81,23 +81,6 @@ class Item(object): ['try_expire_at', 0, '试用到期时间(utc时间)'], ] -class RobotInfo(object): - - def __init__(self): - self.fields = [ - ['account_id', '', '机器人account_id'], - ['name', '', '机器人名字'], - ['avatar_url', '', '机器人头像'], - ] - -class RobotMetaInfo(object): - - def __init__(self): - self.fields = [ - ['name', 0, '机器人名字'], - ['avatar_url', 0, '机器人头像'], - ] - class Award(object): def __init__(self): diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 3832bdb..2fffd43 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -49,61 +49,6 @@ class HeroController 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 buySkin() - { - $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 takeonSkin() { $heroId = getReqVal('hero_id', 0); diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 306aae0..88d3e44 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1,9 +1,68 @@ _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); + } + } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 0800ca8..798442b 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -268,15 +268,4 @@ class UserController extends BaseAuthedController { )); } - public function getRobotInfo() - { - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'member_list' => array(mt\Robot::getRandMember()), - 'sin_member' => mt\Robot::getSinMembers(), - 'num' => Rand(1, 100) * 0.01 - )); - } - }