diff --git a/doc/Bag.py b/doc/Bag.py index 1d334e6c..13689b9e 100644 --- a/doc/Bag.py +++ b/doc/Bag.py @@ -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(), '属性变更'], + ] + }, + ] diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 49fd855b..dbd9991f 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -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); //活跃度 diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 66e19b1e..040f2d7f 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -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(), + )); + + } + }