1
This commit is contained in:
parent
9fec70c834
commit
42eeaca699
15
doc/Gun.py
15
doc/Gun.py
@ -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(), '枪支皮肤信息']
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
27
doc/Hero.py
27
doc/Hero.py
@ -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': '穿戴皮肤',
|
||||||
|
52
doc/Shop.py
52
doc/Shop.py
@ -7,9 +7,25 @@ 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',
|
||||||
|
'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': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
],
|
],
|
||||||
@ -18,36 +34,18 @@ class Shop(object):
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'desc': 'flushShopItem',
|
'desc': '购买枪支皮肤buyGunSkin',
|
||||||
'group': 'Shop',
|
'group': 'Shop',
|
||||||
'url': 'webapp/index.php?c=Shop&a=flushShopItem',
|
'url': 'webapp/index.php?c=Shop&a=buyGunSkin',
|
||||||
'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': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
|
['gun_id', 0, '枪支id'],
|
||||||
|
['skin_id', 0, '皮肤id'],
|
||||||
|
['goodsID', 0, '商品id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
['data', _common.GunSkinInfo(), '枪支皮肤信息']
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
15
doc/User.py
15
doc/User.py
@ -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 = [
|
||||||
{
|
{
|
||||||
|
@ -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):
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user