This commit is contained in:
hujiabin 2024-01-18 16:40:32 +08:00
parent e888ef4268
commit 3cff27758a
3 changed files with 140 additions and 70 deletions

View File

@ -1,70 +1,83 @@
# -*- coding: utf-8 -*-
import _common
class Bag(object):
def __init__(self):
self.apis = [
{
'name': 'itemList',
'desc': '获取背包物品列表',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=itemList',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['!item_list', [_common.Item()], '物品列表']
]
},
{
'name': 'useItem',
'desc': '使用道具',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=useItem',
'params': [
_common.ReqHead(),
['item_uniid', 0, '道具唯一id'],
['item_num', 0, '道具数量'],
['param1', '', '参数1(当使用的是改名卡时param1=新的角色名)'],
['param2', '', '参数2(当使用的是改名卡时param2=签名)'],
['param3', '', '参数3'],
],
'response': [
_common.RspHead(),
['award', _common.Award(), '奖励信息'],
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
{
'name': 'rename',
'desc': '改名(优先扣改名卡没有则扣钻石)',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=rename',
'params': [
_common.ReqHead(),
['name', '', '新的角色名'],
['name_sign', '', '名字签名)'],
],
'response': [
_common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
{
'name': 'buyItem',
'desc': '购买道具(目前只一次购买改名卡)',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=buyItem',
'params': [
_common.ReqHead(),
['item_id', '', '道具id'],
],
'response': [
_common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
]
# -*- coding: utf-8 -*-
import _common
class Bag(object):
def __init__(self):
self.apis = [
{
'name': 'itemList',
'desc': '获取背包物品列表',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=itemList',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['!item_list', [_common.Item()], '物品列表']
]
},
{
'name': 'useItem',
'desc': '使用道具',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=useItem',
'params': [
_common.ReqHead(),
['item_uniid', 0, '道具唯一id'],
['item_num', 0, '道具数量'],
['param1', '', '参数1(当使用的是改名卡时param1=新的角色名)'],
['param2', '', '参数2(当使用的是改名卡时param2=签名)'],
['param3', '', '参数3'],
],
'response': [
_common.RspHead(),
['award', _common.Award(), '奖励信息'],
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
{
'name': 'rename',
'desc': '改名(优先扣改名卡没有则扣钻石)',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=rename',
'params': [
_common.ReqHead(),
['name', '', '新的角色名'],
['name_sign', '', '名字签名)'],
],
'response': [
_common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
{
'name': 'buyItem',
'desc': '购买道具(目前只一次购买改名卡)',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=buyItem',
'params': [
_common.ReqHead(),
['item_id', '', '道具id'],
],
'response': [
_common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
]
},{
'name': 'syntheticGold',
'desc': '金币合成',
'group': 'Bag',
'url': 'webapp/index.php?c=Bag&a=syntheticGold',
'params': [
_common.ReqHead(),
['item_id', '', '合成的道具id'],
],
'response': [
_common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
]

View File

@ -10,6 +10,8 @@ define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:');
define('MATCH_OK_KEY', 'match:ok:');
define('V_ITEM_GOLD', 10001); //金币
define('V_ITEM_GOLDS', 10017); //金堆
define('V_ITEM_GOLDBRICK', 10018); //金砖
define('V_ITEM_DIAMOND', 10014); //钻石
define('V_ITEM_EXP', 10003); //经验
define('V_ITEM_ACTIVE', 10004); //活跃度

View File

@ -427,4 +427,59 @@ class BagController extends BaseAuthedController {
// ));
}
public function syntheticGold(){
$itemId = getReqVal('item_id', 0);
$paramMeta = mt\Parameter::getVal('gold_synthesis_rank',0);
if (!$paramMeta){
$this->_rspErr(1,"config error");
return ;
}
$consume = explode("|",$paramMeta);
switch ($itemId){
case V_ITEM_GOLDS :{
$costItems = array(
array(
'item_id' => V_ITEM_GOLD,
'item_num' => $consume[0]
)
);
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return;
}
$this->_decItems($costItems);
Bag::addItem(V_ITEM_GOLDS,1);
}
break;
case V_ITEM_GOLDBRICK :{
$costItems = array(
array(
'item_id' => V_ITEM_GOLD,
'item_num' => $consume[1]
)
);
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return;
}
$this->_decItems($costItems);
Bag::addItem(V_ITEM_GOLDBRICK,1);
}
break;
default:{
$this->_rspErr(1,"param error");
return ;
}
}
$propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg();
$propertyChgService->addBagChg();
$this->_rspData(array(
'property_chg' => $propertyChgService->toDto(),
));
}
}