예제 #1
0
    def __runSelfTest_limits(self, itemCatFilter, verbose):
        itemIds = ItemGlobals.getAllItemIds()
        for currItemId in itemIds:
            if itemCatFilter != None:
                if 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
                print verbose and 'item limit for item %s:%s passed (quantity: %s limit:%s)' % (itemCat, currItemId, quantity, itemLimit or 1)

        return
예제 #2
0
 def _TradableInventoryBase__runSelfTest_limits(self, itemCatFilter,
                                                verbose):
     itemIds = ItemGlobals.getAllItemIds()
     for currItemId in itemIds:
         if itemCatFilter != None and itemCatFilter != ItemGlobals.getClass(
                 currItemId):
             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)
    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
예제 #4
0
    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 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:
                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 None

            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()