This commit is contained in:
aozhiwei 2021-11-26 17:28:48 +08:00
parent 9fec70c834
commit 42eeaca699
8 changed files with 102 additions and 185 deletions

View File

@ -58,19 +58,4 @@ class Gun(object):
['data', _common.GunSkinInfo(), '枪支皮肤信息'] ['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(), '枪支皮肤信息']
]
},
] ]

View File

@ -32,33 +32,6 @@ class Hero(object):
['!skin_list', _common.HeroSkin, '英雄皮肤列表'] ['!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', 'name': 'takeonSkin',
'desc': '穿戴皮肤', 'desc': '穿戴皮肤',

View File

@ -6,48 +6,46 @@ class Shop(object):
def __init__(self): def __init__(self):
self.apis_ = [ self.apis_ = [
{ {
'desc': 'newShopInfo', 'name': 'buyHero',
'group': 'Shop', 'desc': '购买英雄',
'url': 'webapp/index.php?c=Shop&a=newShopInfo', 'group': 'Hero',
'params': [ 'url': 'webapp/index.php?c=Hero&a=buyHero',
_common.ReqHead(), 'params': [
], _common.ReqHead(),
'response': [ ['hero_id', '', '英雄id'],
_common.RspHead(), ['buy_type', '', '购买类型0指购买英雄 1购买英雄和皮肤'],
] ],
}, 'response': [
{ _common.RspHead(),
'desc': 'flushShopItem', ['award', _common.Award, '奖励信息'],
'group': 'Shop', ]
'url': 'webapp/index.php?c=Shop&a=flushShopItem', },
'params': [ {
_common.ReqHead(), 'name': 'buySkin',
], 'desc': '购买皮肤',
'response': [ 'group': 'Hero',
_common.RspHead(), 'url': 'webapp/index.php?c=Hero&a=buySkin',
] 'params': [
}, _common.ReqHead(),
{ ],
'desc': 'newBuyShopItem', 'response': [
'group': 'Shop', _common.RspHead(),
'url': 'webapp/index.php?c=Shop&a=newBuyShopItem', ]
'params': [ },
_common.ReqHead(), {
], 'desc': '购买枪支皮肤buyGunSkin',
'response': [ 'group': 'Shop',
_common.RspHead(), 'url': 'webapp/index.php?c=Shop&a=buyGunSkin',
] 'params': [
}, _common.ReqHead(),
{ ['gun_id', 0, '枪支id'],
'desc': 'shopBuyMore', ['skin_id', 0, '皮肤id'],
'group': 'Shop', ['goodsID', 0, '商品id'],
'url': 'webapp/index.php?c=Shop&a=shopBuyMore', ],
'params': [ 'response': [
_common.ReqHead(), _common.RspHead(),
], ['data', _common.GunSkinInfo(), '枪支皮肤信息']
'response': [ ]
_common.RspHead(), },
]
},
] ]

View File

@ -31,21 +31,6 @@ class User(object):
_common.RspHead(), _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 = [ self.internalApis = [
{ {

View File

@ -81,23 +81,6 @@ class Item(object):
['try_expire_at', 0, '试用到期时间(utc时间)'], ['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): class Award(object):
def __init__(self): def __init__(self):

View File

@ -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() public function takeonSkin()
{ {
$heroId = getReqVal('hero_id', 0); $heroId = getReqVal('hero_id', 0);

View File

@ -1,9 +1,68 @@
<?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/Parameter.php');
require_once('mt/Drop.php'); require_once('mt/Drop.php');
require_once('mt/Item.php');
use phpcommon\SqlHelper;
class ShopController extends BaseAuthedController { 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);
}
} }

View File

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