def locatableItem(self, status, item): modification = False itemFields = InvItem(item[0]) itemLocation = itemFields.getLocation() origStatus = status if status == self.STATUS_ITEM_MODIFIED or status == self.STATUS_ITEM_MODIFIED_OVERFLOW: if itemFields[self.ITEM_CAT_IDX] == 0: status = self.STATUS_ITEM_REMOVED elif not self._locatableItems.has_key(itemLocation): status = self.STATUS_ITEM_ADDED if status == self.STATUS_ITEM_ADDED: self._locatableItems[itemLocation] = itemFields modification = True elif status == self.STATUS_ITEM_REMOVED: if self._locatableItems.has_key(itemLocation): del self._locatableItems[itemLocation] modification = True elif status == self.STATUS_ITEM_MODIFIED or status == self.STATUS_ITEM_MODIFIED_OVERFLOW: self._locatableItems.pop(itemLocation, None) self._locatableItems[itemLocation] = itemFields modification = True if modification: self.notify.debug("sending inventoryLocation message for %s" % itemLocation) messenger.send(getLocationChangeMsg(self.doId), [itemLocation]) if origStatus == self.STATUS_ITEM_MODIFIED_OVERFLOW: messenger.send(getOverflowChangeMsg(self.doId), [itemLocation]) if itemFields.getCat(): messenger.send(getCategoryChangeMsg(self.doId, itemFields.getCat()), [itemFields.getType()]) messenger.send(getCategoryQuantChangeMsg(self.doId, itemFields.getCat()), [itemFields.getCount()]) messenger.send(getAnyChangeMsg(self.doId))
def check1(tradeItems, limitChanges, stacks, locatable, accumulators, doIds, giving): listType = type([]) possibleTypes = (type(1), type(1L), listType) for i in tradeItems: for v in i: itemType = type(v) if itemType not in possibleTypes: raise AITradeException, 'element is the wrong type' if v > 4294967295L: raise itemType != listType and AITradeException, 'element is larger than unsigned long' else: t = i[TypeIndex] if InventoryId.isLimitChange(t): a = limitChanges.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 65535L: raise AITradeException, 'element is larger than unsigned short' elif InventoryId.isStackable(t): a = stacks.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 65535L: raise AITradeException, 'element is larger than unsigned short' elif isLocatable(t): inv = simbase.air.doId2do.get(self.inventoryId) theInvItem = inv and InvItem(i) theInvItemType = theInvItem.getType() if giving: equippableInfo = inv.getItemRequirements( theInvItemType, self.giving) if equippableInfo == None or filter( lambda x: equippableInfo[x][1] == False, equippableInfo): if theInvItemType and theInvItemType not in self.unequippables: self.unequippables.append(theInvItemType) if isStackableType(theInvItem.getCat()): for currLocatable in locatable: prevInvItem = InvItem(currLocatable) if prevInvItem.compare(theInvItem, excludeLoc=True): adjustedInvItem = prevInvItem.adjustCount( theInvItem.getCount()) locatable.remove(currLocatable) i = list(adjustedInvItem) break else: raise AITradeException, 'inventory not present' locatable.append(i) elif InventoryId.isAccumulator(t): a = accumulators.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 4294967295L: raise AITradeException, 'element is larger than unsigned long' elif InventoryId.isDoId(t): doIds[i[DoIdIndex]] = i return
def locatableItem(self, status, item): modification = False itemFields = InvItem(item[0]) itemLocation = itemFields.getLocation() origStatus = status if status == self.STATUS_ITEM_MODIFIED or status == self.STATUS_ITEM_MODIFIED_OVERFLOW: if itemFields[self.ITEM_CAT_IDX] == 0: status = self.STATUS_ITEM_REMOVED elif not self._locatableItems.has_key(itemLocation): status = self.STATUS_ITEM_ADDED if status == self.STATUS_ITEM_ADDED: self._locatableItems[itemLocation] = itemFields modification = True elif status == self.STATUS_ITEM_REMOVED: if self._locatableItems.has_key(itemLocation): del self._locatableItems[itemLocation] modification = True elif status == self.STATUS_ITEM_MODIFIED or status == self.STATUS_ITEM_MODIFIED_OVERFLOW: self._locatableItems.pop(itemLocation, None) self._locatableItems[itemLocation] = itemFields modification = True if modification: self.notify.debug('sending inventoryLocation message for %s' % itemLocation) messenger.send(getLocationChangeMsg(self.doId), [itemLocation]) if origStatus == self.STATUS_ITEM_MODIFIED_OVERFLOW: messenger.send(getOverflowChangeMsg(self.doId), [itemLocation]) if itemFields.getCat(): messenger.send( getCategoryChangeMsg(self.doId, itemFields.getCat()), [itemFields.getType()]) messenger.send( getCategoryQuantChangeMsg(self.doId, itemFields.getCat()), [itemFields.getCount()]) messenger.send(getAnyChangeMsg(self.doId))
def handleBuyItem(self, data, useCode): itemId = data[0] if not itemId: return 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 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 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 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])) 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 else: if 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 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 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 itemQuantity = self.purchaseInventory.getItemQuantity(itemId) currStock = inventory.getStackQuantity(itemId) currStockLimit = inventory.getStackLimit(itemId) itemCategory = EconomyGlobals.getItemCategory(itemId) if currStock + itemQuantity >= currStockLimit: base.localAvatar.guiMgr.createWarning( PLocalizer.TradeItemFullWarning, PiratesGuiGlobals.TextFG6) return self.purchaseInventory.addPanel(data) self.purchaseInventory.inventory.append(data) elif useCode == PiratesGuiGlobals.InventoryRemove: self.purchaseInventory.removePanel(data) panel = self.storeInventory.getPanel(data) if panel: self.checkPanel(panel, inventory, itemId) self.updateBalance()
def getGivingItems(self, items): weapons = [] clothes = [] consumables = [] givingItems = [] extraItems = [] inventory = base.localAvatar.getInventory() if inventory: for item in items: if item[0] in (InventoryType.ItemTypeWeapon, InventoryType.ItemTypeCharm): weapons.append([ItemGlobals.getGoldCost(item[0]), item]) elif item[0] == InventoryType.ItemTypeClothing: clothes.append([ItemGlobals.getGoldCost(item[0]), item]) elif item[0] == InventoryType.ItemTypeConsumable: consumables.append( [ItemGlobals.getGoldCost(item[0]), item]) else: givingItems.append(item) weapons.sort() clothes.sort() consumables.sort() locatables = [] for weapon in weapons: locatables.append(InvItem([weapon[1][0], weapon[1][1], 0])) invalidLocations = 0 locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): invalidLocations += 1 for i in range(0, invalidLocations): extraItems.append(weapons[i][1]) for i in range(invalidLocations, len(weapons)): givingItems.append(weapons[i][1]) locatables = [] for cloth in clothes: locatables.append(InvItem([cloth[1][0], cloth[1][1], 0, 0])) invalidLocations = 0 locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): invalidLocations += 1 for i in range(0, invalidLocations): extraItems.append(clothes[i][1]) for i in range(invalidLocations, len(clothes)): givingItems.append(clothes[i][1]) locatables = [] for consumable in consumables: locatables.append( InvItem([consumable[1][0], consumable[1][1], 0, 0])) invalidLocations = 0 locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): invalidLocations += 1 for i in range(0, invalidLocations): extraItems.append(consumables[i][1]) for i in range(invalidLocations, len(consumables)): givingItems.append(consumables[i][1]) return (givingItems, extraItems)
def takePlunderItemFromCell(self, cell, toCell=None, playSound=True): if toCell != None: pass location = 0 if toCell and toCell.slotId: location = toCell.slotId if not cell.inventoryItem: return False inventory = base.localAvatar.getInventory() if not inventory: return False if location and not inventory.locationAvailable( location) or location in Locations.RANGE_EQUIP_SLOTS: location = 0 if cell.inventoryItem.getCategory() in ( InventoryType.ItemTypeWeapon, InventoryType.ItemTypeCharm, InventoryType.ItemTypeClothing, InventoryType.ItemTypeConsumable): locatables = [ InvItem([ cell.inventoryItem.getCategory(), cell.inventoryItem.getId(), 0, 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 False item = cell.container.grabCellItem(cell) fromContainer = cell.container cell.stash() cell.inventoryItem = None category = item.getCategory() if category == InventoryCategory.WEAPON_PISTOL_AMMO: id = item.getSkillId() extraArg = item.amount elif category == InventoryCategory.CARDS: id = item.getCardId() extraArg = 1 else: if category == InventoryType.ItemTypeClothing: id = item.getId() extraArg = item.getColorId() elif category == InventoryType.ItemTypeMoney: id = item.getId() extraArg = item.amount elif category == InventoryCategory.MONEY: id = item.getId() extraArg = item.amount elif category == InventoryType.TreasureCollection: id = item.getId() extraArg = item.itemTuple[3] else: id = item.getId() extraArg = 1 if self.scoreboard: if playSound: if id == UberDogGlobals.InventoryType.ItemTypeMoney: self.takeGoldSound.play() else: self.takeNonGoldSound.play() self.scoreboard.requestItem([category, id, extraArg, location]) if self.lootContainer: if playSound: if id == UberDogGlobals.InventoryType.ItemTypeMoney: self.takeGoldSound.play() else: self.takeNonGoldSound.play() self.lootContainer.d_requestItem( [category, id, extraArg, location]) messenger.send('lootsystem-plunderContainer-Empty', []) return True
DARKFROST_BLADE = 13 SUPER_XP_POTION = 14 SCOUNDREL_HAT = 15 GOLDEN_KNUCKLES = 16 NORRINGTONS_SPYGLASS = 17 ELIXIR = 18 POTION_HEADFIRE = 19 POTION_INVIS_2 = 20 JACK_SPARROW_BLADE = 21 JACK_SPARROW_REVENGE = 22 HEART_OF_PADRES = 23 AMMO_FURY = 24 LOST_BLADE_OF_LEVIATHAN = 25 LOST_SWORD_OF_EL_PATRON = 26 BARBOSSAS_FURY = 27 SCIMITAR_42 = 28 SCIMITAR_46 = 29 SCIMITAR_47 = 30 SCIMITAR_48 = 31 POTION_SUMMON_CHICKEN = 32 POTION_SUMMON_WASP = 33 POTION_SUMMON_DOG = 34 TYPE_IDX = 0 MALE_IDX = 1 FEME_IDX = 2 QTTY_IDX = 3 DESC_IDX = 4 AWARD_ID = {AwardTypes.GOLD: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeMoney, 0)), None, None, PLocalizerEnglish.CodeRedemptionGold], AwardTypes.FREE_HAT: [CLOTHING, InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CROSSBONES_BANDANA, 0, 0)), InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CROSSBONES_BANDANA, 0, 0)), 1, PLocalizerEnglish.CodeRedemptionFreeHat], AwardTypes.KRAKEN_TATTOO: [TATTOO, InvItem((InventoryType.ItemTypeTattoo, ItemGlobals.TATTOO_ARM_OCTOPUS_SLEEVES, 0)), None, 1, PLocalizerEnglish.CodeRedemptionKrakenTattoo], AwardTypes.DARKFIRE_CUTLASS: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.DARKFIRE_CUTLASS, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionDarkfireCutlass], AwardTypes.FLATULENT_FIZZ: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_FART_2, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionFlatulentFizz], AwardTypes.BUCCANEER_HAT: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeClothing, ItemGlobals.BLACK_BUCCANEER_HAT, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionBlackBuccaneerHat], AwardTypes.SEAFANG_BLADE: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SEAFANG_BLADE, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionSeafangBlade], AwardTypes.SWORD_OF_TRITON: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SWORD_OF_TRITON, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionSwordOfTriton], AwardTypes.HAYMAKER_PISTOL: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.HAYMAKER_PISTOL, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionHaymakerPistol], AwardTypes.ZOMBIE_KABAB_BAYONET: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.ZOMBIE_KABAB_BAYONET, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionZombieKababBayonet], AwardTypes.SPECTRAL_CUTLASS: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SPECTRAL_CUTLASS, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionSpectralCutlass], AwardTypes.NEMESIS_BLADE: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.NEMESIS_BLADE, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionNemesisBlade], AwardTypes.DARKFROST_BLADE: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.DARKFROST_BLADE, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionDarkfrostBlade], AwardTypes.SUPER_XP_POTION: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_REP_COMP, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionSuperReputationPotion], AwardTypes.SCOUNDREL_HAT: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CRIMSON_BUCCANEER_HAT, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionScoundrelHat], AwardTypes.GOLDEN_KNUCKLES: [JEWELRY, InvItem((InventoryType.ItemTypeJewelry, ItemGlobals.GOLDEN_KNUCKLES, 0)), None, 1, PLocalizerEnglish.CodeRedemptionGoldenKnuckles], AwardTypes.NORRINGTONS_SPYGLASS: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeCharm, ItemGlobals.NORRINGTON_SPYGLASS, 0)), None, 1, PLocalizerEnglish.CodeRedemptionNorringtonsSpyglass], AwardTypes.ELIXIR: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.ELIXIR, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionElixir], AwardTypes.POTION_HEADFIRE: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_HEADONFIRE, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionPotionHeadOnFire], AwardTypes.POTION_INVIS_2: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_INVIS_2, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionPotionInvis2], AwardTypes.JACK_SPARROW_BLADE: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.JACK_SPARROW_BLADE, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionJackSparrowBlade], AwardTypes.JACK_SPARROW_REVENGE: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.JACK_SPARROW_REVENGE, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionJackSparrowRevenge], AwardTypes.HEART_OF_PADRES: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.HEART_OF_PADRES_DEL_FUEGO, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionHeartOfPadres], AwardTypes.AMMO_FURY: [NORMAL_INVENTORY, InvItem((InventoryType.AmmoFury, 0)), None, None, PLocalizerEnglish.CodeRedemptionAmmoFury], AwardTypes.LOST_BLADE_OF_LEVIATHAN: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.CURSED_BLADE_47, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionLostBladeOfLeviathan], AwardTypes.LOST_SWORD_OF_EL_PATRON: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.LOST_SWORD_OF_EL_PATRON, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionLostSwordOfElPatron], AwardTypes.BARBOSSAS_FURY: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.BARBOSSA_FURY, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionBarbossaFury], AwardTypes.SCIMITAR_42: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SCIMITAR_42, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionScimitar42], AwardTypes.SCIMITAR_46: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SCIMITAR_46, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionScimitar46], AwardTypes.SCIMITAR_47: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SCIMITAR_47, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionScimitar47], AwardTypes.SCIMITAR_48: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeWeapon, ItemGlobals.SCIMITAR_48, 0, [])), None, 1, PLocalizerEnglish.CodeRedemptionScimitar48], AwardTypes.POTION_SUMMON_CHICKEN: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_SUMMON_CHICKEN, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionSummonChicken], AwardTypes.POTION_SUMMON_WASP: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_SUMMON_WASP, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionSummonWasp], AwardTypes.POTION_SUMMON_DOG: [NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeConsumable, ItemGlobals.POTION_SUMMON_DOG, 0, 0)), None, 1, PLocalizerEnglish.CodeRedemptionSummonDog]}
SCIMITAR_47 = 30 SCIMITAR_48 = 31 POTION_SUMMON_CHICKEN = 32 POTION_SUMMON_WASP = 33 POTION_SUMMON_DOG = 34 TYPE_IDX = 0 MALE_IDX = 1 FEME_IDX = 2 QTTY_IDX = 3 DESC_IDX = 4 AWARD_ID = { AwardTypes.GOLD: [ NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeMoney, 0)), None, None, PLocalizerEnglish.CodeRedemptionGold ], AwardTypes.FREE_HAT: [ CLOTHING, InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CROSSBONES_BANDANA, 0, 0)), InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CROSSBONES_BANDANA, 0, 0)), 1, PLocalizerEnglish.CodeRedemptionFreeHat ], AwardTypes.KRAKEN_TATTOO: [ TATTOO, InvItem((InventoryType.ItemTypeTattoo, ItemGlobals.TATTOO_ARM_OCTOPUS_SLEEVES, 0)), None, 1, PLocalizerEnglish.CodeRedemptionKrakenTattoo
def check1(tradeItems, limitChanges, stacks, locatable, accumulators, doIds, giving): listType = type([]) possibleTypes = (type(1), type(0x1L), listType) for i in tradeItems: for v in i: itemType = type(v) if itemType not in possibleTypes: raise AITradeException, "element is the wrong type" if v > 0xFFFFFFFFL and itemType != listType: raise AITradeException, "element is larger than unsigned long" continue else: t = i[TypeIndex] if InventoryId.isLimitChange(t): a = limitChanges.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 0xFFFFL: raise AITradeException, "element is larger than unsigned short" if InventoryId.isStackable(t): a = stacks.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 0xFFFFL: raise AITradeException, "element is larger than unsigned short" a[1] > 0xFFFFL if isLocatable(t): inv = simbase.air.doId2do.get(self.inventoryId) if inv: theInvItem = InvItem(i) theInvItemType = theInvItem.getType() if giving: equippableInfo = inv.getItemRequirements(theInvItemType, self.giving) if ( ( equippableInfo == None or filter(lambda x: equippableInfo[x][1] == False, equippableInfo) ) and theInvItemType and theInvItemType not in self.unequippables ): self.unequippables.append(theInvItemType) if isStackableType(theInvItem.getCat()): for currLocatable in locatable: prevInvItem = InvItem(currLocatable) if prevInvItem.compare(theInvItem, excludeLoc=True): adjustedInvItem = prevInvItem.adjustCount(theInvItem.getCount()) locatable.remove(currLocatable) i = list(adjustedInvItem) break continue else: raise AITradeException, "inventory not present" locatable.append(i) continue if InventoryId.isAccumulator(t): a = accumulators.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 0xFFFFFFFFL: raise AITradeException, "element is larger than unsigned long" a[1] > 0xFFFFFFFFL if InventoryId.isDoId(t): doIds[i[DoIdIndex]] = i continue
SCIMITAR_46 = 29 SCIMITAR_47 = 30 SCIMITAR_48 = 31 POTION_SUMMON_CHICKEN = 32 POTION_SUMMON_WASP = 33 POTION_SUMMON_DOG = 34 TYPE_IDX = 0 MALE_IDX = 1 FEME_IDX = 2 QTTY_IDX = 3 DESC_IDX = 4 AWARD_ID = { AwardTypes.GOLD: [ NORMAL_INVENTORY, InvItem((InventoryType.ItemTypeMoney, 0)), None, None, PLocalizerEnglish.CodeRedemptionGold], AwardTypes.FREE_HAT: [ CLOTHING, InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CROSSBONES_BANDANA, 0, 0)), InvItem((InventoryType.ItemTypeClothing, ItemGlobals.CROSSBONES_BANDANA, 0, 0)), 1, PLocalizerEnglish.CodeRedemptionFreeHat], AwardTypes.KRAKEN_TATTOO: [ TATTOO, InvItem((InventoryType.ItemTypeTattoo, ItemGlobals.TATTOO_ARM_OCTOPUS_SLEEVES, 0)), None, 1, PLocalizerEnglish.CodeRedemptionKrakenTattoo],