def decorateInBag(playerId,param): habitatId = param['map_index'] definitionId = str(param['definitionId']) propDict= db_tool.getAllProp(playerId) if propDict.has_key(definitionId) and propDict[definitionId]>0: propDict[definitionId]=propDict[definitionId]-1 addItems = db_tool.addMapItem(playerId,habitatId,param) db_tool.saveAllProp(playerId,propDict) return {'status':1,'add':addItems} else: return {'status':0,'msg':'no definitionId in bag'}
def decorateInShop(playerId,param): habitatId = param['map_index'] #买装饰物需要花费的钱 cost_money=__getCostMoney(param) player = db_tool.__getPlayerById(playerId) #比较 if (player['kb']<cost_money['kb']): return {'status':0,'msg':'not enough KB'} elif (player['gb']<cost_money['gb']): return {'status':0,'msg':'not enough GB'} #扣除 player['gb'] -=cost_money['gb'] player['kb'] -=cost_money['kb'] player['exp'] += cost_money['exp'] #添加 addItems = db_tool.addMapItem(playerId,habitatId,param) db_tool.__updatePlayer(player['id'],{'gb':player['gb'],'kb':player['kb'],'exp':player['exp']}) #add cost log if cost_money['kb']>0: player_module.addCostLog(player['id'],cost_money['kb'],'decorateInShop') return {'status':1,'buy':addItems,'player':player}