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

@ -66,5 +66,18 @@ class Bag(object):
_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(),
));
}
}