本文整理汇总了Python中pirates.inventory.ItemGlobals.getAllConsumableIds方法的典型用法代码示例。如果您正苦于以下问题:Python ItemGlobals.getAllConsumableIds方法的具体用法?Python ItemGlobals.getAllConsumableIds怎么用?Python ItemGlobals.getAllConsumableIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pirates.inventory.ItemGlobals
的用法示例。
在下文中一共展示了ItemGlobals.getAllConsumableIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _TradableInventoryBase__runSelfTest_limits
# 需要导入模块: from pirates.inventory import ItemGlobals [as 别名]
# 或者: from pirates.inventory.ItemGlobals import getAllConsumableIds [as 别名]
def _TradableInventoryBase__runSelfTest_limits(self, itemCatFilter, verbose):
itemIds = ItemGlobals.getAllItemIds()
for currItemId in itemIds:
if itemCatFilter != None and itemCatFilter != ItemGlobals.getClass(currItemId):
continue
itemIds = ItemGlobals.getAllConsumableIds()
itemLimit = ItemGlobals.getStackLimit(currItemId)
itemCat = ItemGlobals.getClass(currItemId)
quantity = self.getItemQuantity(itemCat, currItemId)
if isStackableType(itemCat):
pass
1
if verbose:
if not itemLimit:
pass
print 'item limit for item %s:%s passed (quantity: %s limit:%s)' % (itemCat, currItemId, quantity, 1)
continue
示例2: handleBuyItem
# 需要导入模块: from pirates.inventory import ItemGlobals [as 别名]
# 或者: from pirates.inventory.ItemGlobals import getAllConsumableIds [as 别名]
def handleBuyItem(self, data, useCode):
itemId = data[0]
if not itemId:
return None
itemType = EconomyGlobals.getItemType(itemId)
if itemType <= ItemType.WAND or itemType == ItemType.POTION:
data[1] = 1
else:
data[1] = EconomyGlobals.getItemQuantity(itemId)
inventory = base.localAvatar.getInventory()
if not inventory:
return None
itemQuantity = self.purchaseInventory.getItemQuantity(itemId)
currStock = inventory.getStackQuantity(itemId)
currStockLimit = inventory.getStackLimit(itemId)
if useCode == PiratesGuiGlobals.InventoryAdd:
itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType)
trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
if trainingReq:
amt = inventory.getStackQuantity(trainingReq)
if not amt:
base.localAvatar.guiMgr.createWarning(PLocalizer.NoTrainingWarning % itemTypeName, PiratesGuiGlobals.TextFG6)
return None
itemType = EconomyGlobals.getItemType(itemId)
if itemType != ItemType.POTION:
minLvl = ItemGlobals.getWeaponRequirement(itemId)
else:
minLvl = 0
repId = WeaponGlobals.getRepId(itemId)
repAmt = inventory.getAccumulator(repId)
if minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]:
base.localAvatar.guiMgr.createWarning(PLocalizer.LevelReqWarning % (minLvl, itemTypeName), PiratesGuiGlobals.TextFG6)
return None
if itemId in ItemGlobals.getAllWeaponIds():
locatables = []
for dataInfo in self.purchaseInventory.inventory:
dataId = dataInfo[0]
if dataId in ItemGlobals.getAllWeaponIds():
locatables.append(InvItem([
InventoryType.ItemTypeWeapon,
dataId,
0]))
continue
locatables.append(InvItem([
InventoryType.ItemTypeWeapon,
itemId,
0]))
locationIds = inventory.canAddLocatables(locatables)
for locationId in locationIds:
if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION):
base.localAvatar.guiMgr.createWarning(PLocalizer.InventoryFullWarning, PiratesGuiGlobals.TextFG6)
return None
continue
elif itemId in ItemGlobals.getAllConsumableIds():
itemQuantity = self.purchaseInventory.getItemQuantity(itemId)
currStock = inventory.getItemQuantity(InventoryType.ItemTypeConsumable, itemId)
currStockLimit = inventory.getItemLimit(InventoryType.ItemTypeConsumable, itemId)
if currStock + itemQuantity >= currStockLimit:
base.localAvatar.guiMgr.createWarning(PLocalizer.TradeItemFullWarning, PiratesGuiGlobals.TextFG6)
return None
if currStock == 0:
locatables = []
dataIds = { }
for dataInfo in self.purchaseInventory.inventory:
dataId = dataInfo[0]
if dataId in ItemGlobals.getAllConsumableIds():
if dataIds.has_key(dataId):
dataIds[dataId] += 1
else:
dataIds[dataId] = 1
dataIds.has_key(dataId)
if dataIds.has_key(itemId):
dataIds[itemId] += 1
else:
dataIds[itemId] = 1
for dataId in dataIds:
locatables.append(InvItem([
InventoryType.ItemTypeConsumable,
dataId,
0,
dataIds[dataId]]))
locationIds = inventory.canAddLocatables(locatables)
for locationId in locationIds:
if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION):
base.localAvatar.guiMgr.createWarning(PLocalizer.InventoryFullWarning, PiratesGuiGlobals.TextFG6)
return None
continue
else:
#.........这里部分代码省略.........