def addTab(self, itemGroup, item):
     newTab = self.tabBar.addTab(itemGroup, command = self.setPage, extraArgs = [
         itemGroup])
     repId = WeaponGlobals.getRepId(item)
     if repId:
         iconName = ReputationGlobals.RepIcons.get(repId)
         if repId == InventoryType.FishingRep:
             icon = StoreGUI.FishingIcons.find('**/%s' % iconName)
         else:
             icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_Consumables <= item:
         pass
     elif repId or ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(item)
         icon = StoreGUI.SkillIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponCannonAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(InventoryType.CannonL1)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponGrenadeAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         itemId = InventoryType.GrenadeWeaponL1
         iconName = EconomyGlobals.getItemIcons(itemId)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_FishingLures <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         icon = StoreGUI.FishingIcons.find('**/pir_t_gui_gen_fish_lure')
     else:
         icon = None
     newTab.nameTag = DirectLabel(parent = newTab, relief = None, state = DGG.DISABLED, image = icon, image_scale = 0.40000000000000002, image_pos = (0, 0, 0.040000000000000001), pos = (0.059999999999999998, 0, -0.035000000000000003))
     self.pageNames.append(itemGroup)
Exemplo n.º 2
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
    def getItemRequirements(self, itemType, otherAdds=[]):
        if not itemType:
            return
        results = {}
        if game.process == 'client':
            paidStatus = Freebooter.getPaidStatus(self.ownerId)
        else:
            paidStatus = Freebooter.getPaidStatusAI(self.ownerId)
        rarity = ItemGlobals.getRarity(itemType)
        if rarity != ItemConstants.CRUDE and not paidStatus:
            results['paidStatus'] = (rarity != ItemConstants.CRUDE, False)
        itemClass = ItemGlobals.getClass(itemType)
        if itemClass == InventoryType.ItemTypeWeapon or itemClass == InventoryType.ItemTypeCharm:
            itemRepId = ItemGlobals.getItemRepId(itemType)
            itemRep = self.getReputation(itemRepId)
            itemLevel = ReputationGlobals.getLevelFromTotalReputation(
                itemRepId, itemRep)[0]
            weaponReq = ItemGlobals.getWeaponRequirement(itemType)
            trainingToken = EconomyGlobals.getItemTrainingReq(itemType)
            trainingAmt = self.getItemQuantity(trainingToken)
            for currAdd in otherAdds:
                otherAdd = InvItem(currAdd)
                if otherAdd.getCat(
                ) == trainingToken and otherAdd.getCount() > 0:
                    trainingAmt += otherAdd.getCount()

            weaponLevelPass = weaponReq == None or itemLevel >= weaponReq
            weaponTrainPass = trainingToken == 0 or trainingToken == None or trainingAmt > 0
            results['itemLevel'] = (weaponReq, weaponLevelPass
                                    and weaponTrainPass)
        else:
            results['itemLevel'] = (0, True)
        return results
Exemplo n.º 4
0
    def avIsReady(self, av):
        from pirates.inventory.InventoryGlobals import Locations
        inv = av.getInventory()
        if not inv:
            return False
        categoryId = ItemGlobals.getClass(self.itemId)
        if inv.getItemQuantity(categoryId, self.itemId) > 0:
            if categoryId == InventoryType.ItemTypeWeapon:
                if av.currentWeaponId == itemId:
                    return True
                else:
                    return False
            else:
                if categoryId == InventoryType.ItemTypeCharm:
                    if av.getCurrentCharm() == self.itemId:
                        return True
                    else:
                        return False
                else:
                    if categoryId == InventoryType.ItemTypeClothing:
                        locationRange = Locations.RANGE_EQUIP_CLOTHES
                    else:
                        if categoryId == InventoryType.ItemTypeJewelry:
                            locationRange = Locations.RANGE_EQUIP_JEWELRY
                        else:
                            if categoryId == InventoryType.ItemTypeTattoo:
                                locationRange = Locations.RANGE_EQUIP_TATTOO
                            else:
                                locationRange = (0, 0)
            for location in range(locationRange[0], locationRange[1] + 1):
                locatable = inv.getLocatables().get(location)
                if locatable:
                    return locatable[1] == self.itemId and True

        return False
    def avIsReady(self, av):
        Locations = Locations
        import pirates.inventory.InventoryGlobals
        inv = av.getInventory()
        if not inv:
            return False

        categoryId = ItemGlobals.getClass(self.itemId)
        if inv.getItemQuantity(categoryId, self.itemId) > 0:
            if categoryId == InventoryType.ItemTypeWeapon:
                if av.currentWeaponId == itemId:
                    return True
                else:
                    return False
            elif categoryId == InventoryType.ItemTypeCharm:
                if av.getCurrentCharm() == self.itemId:
                    return True
                else:
                    return False
            elif categoryId == InventoryType.ItemTypeClothing:
                locationRange = Locations.RANGE_EQUIP_CLOTHES
            elif categoryId == InventoryType.ItemTypeJewelry:
                locationRange = Locations.RANGE_EQUIP_JEWELRY
            elif categoryId == InventoryType.ItemTypeTattoo:
                locationRange = Locations.RANGE_EQUIP_TATTOO
            else:
                locationRange = (0, 0)
            for location in range(locationRange[0], locationRange[1] + 1):
                locatable = inv.getLocatables().get(location)
                if locatable and locatable[1] == self.itemId:
                    return True
                    continue


        return False
Exemplo n.º 6
0
 def __init__(self, uid):
     self.itemClass = ItemGlobals.getClass(uid)
     self.itemType = ItemGlobals.getType(uid)
     self.cost = ItemGlobals.getGoldCost(uid)
     SimpleItem.__init__(self, uid)
     self.holidayId = ItemGlobals.getHoliday(uid)
     if self.Icons:
         self.icon = self.Icons.find('**/%s' % ItemGlobals.getIcon(uid))
Exemplo n.º 7
0
 def __init__(self, uid):
     self.itemClass = ItemGlobals.getClass(uid)
     self.itemType = ItemGlobals.getType(uid)
     self.cost = ItemGlobals.getGoldCost(uid)
     SimpleItem.__init__(self, uid)
     self.holidayId = ItemGlobals.getHoliday(uid)
     if self.Icons:
         self.icon = self.Icons.find('**/%s' % ItemGlobals.getIcon(uid))
    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
Exemplo n.º 9
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 getStackQuantity(self, stackType):
        itemClass = None
        if isLocatable(stackType):
            itemClass = ItemGlobals.getClass(stackType)

        if itemClass:
            return self.getItemQuantity(itemClass, stackType)
        else:
            return self.getItemQuantity(stackType)
Exemplo n.º 11
0
 def avIsReady(self, av):
     inv = av.getInventory()
     if not inv:
         return False
     categoryId = ItemGlobals.getClass(self.itemId)
     if inv.getItemQuantity(categoryId, self.itemId) > 0:
         return True
     else:
         return False
 def getStackQuantity(self, stackType):
     itemClass = None
     if isLocatable(stackType):
         itemClass = ItemGlobals.getClass(stackType)
     if itemClass:
         return self.getItemQuantity(itemClass, stackType)
     else:
         return self.getItemQuantity(stackType)
     return
    def avIsReady(self, av):
        inv = av.getInventory()
        if not inv:
            return False

        categoryId = ItemGlobals.getClass(self.itemId)
        if inv.getItemQuantity(categoryId, self.itemId) > 0:
            return True
        else:
            return False
 def cellUsed(self, cell):
     if self.manager.heldFromCell:
         itemId = self.manager.heldFromCell.inventoryItem.getId()
         itemInfo = (ItemGlobals.getClass(itemId), itemId, 0, 0)
         item = self.manager.makeLocatableItem(itemInfo)
         item.inventoryCell = self.manager.heldFromCell
         item.amount = 1
         self.manager.heldFromCell['state'] = DGG.DISABLED
         self.manager.heldFromCell.setColorScale(0.5, 0.5, 0.5, 1)
         self.putIntoCell(item, cell)
         self.callback(self.manager.heldFromCell)
    def getItemRequirements(self, itemType, otherAdds = []):
        if not itemType:
            return None

        results = { }
        if game.process == 'client':
            paidStatus = Freebooter.getPaidStatus(self.ownerId)
        else:
            paidStatus = Freebooter.getPaidStatusAI(self.ownerId)
        rarity = ItemGlobals.getRarity(itemType)
        if rarity != ItemConstants.CRUDE and not paidStatus:
            results['paidStatus'] = (rarity != ItemConstants.CRUDE, False)

        itemClass = ItemGlobals.getClass(itemType)
        if itemClass == InventoryType.ItemTypeWeapon or itemClass == InventoryType.ItemTypeCharm:
            itemRepId = ItemGlobals.getItemRepId(itemType)
            itemRep = self.getReputation(itemRepId)
            itemLevel = ReputationGlobals.getLevelFromTotalReputation(itemRepId, itemRep)[0]
            weaponReq = ItemGlobals.getWeaponRequirement(itemType)
            trainingToken = EconomyGlobals.getItemTrainingReq(itemType)
            trainingAmt = self.getItemQuantity(trainingToken)
            for currAdd in otherAdds:
                otherAdd = InvItem(currAdd)
                if otherAdd.getCat() == trainingToken and otherAdd.getCount() > 0:
                    trainingAmt += otherAdd.getCount()
                    continue

            if not weaponReq == None:
                pass
            weaponLevelPass = itemLevel >= weaponReq
            if not trainingToken == 0 and trainingToken == None:
                pass
            weaponTrainPass = trainingAmt > 0
            if weaponLevelPass:
                pass
            results['itemLevel'] = (weaponReq, weaponTrainPass)
        else:
            results['itemLevel'] = (0, True)
        return results
 def setupItems(self, itemList):
     for itemId in itemList:
         itemClass = ItemGlobals.getClass(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         itemTuple = [
             itemClass,
             itemId,
             0,
             0]
         item = None
         if itemClass == InventoryType.ItemTypeWeapon:
             item = self.manager.makeWeaponItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeCharm:
             item = self.manager.makeCharmItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeConsumable:
             itemTuple[3] = 1
             item = self.manager.makeConsumableItem(itemTuple, showMax = 0)
         elif itemClass == InventoryType.ItemTypeClothing:
             item = self.manager.makeClothingItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeMoney:
             item = self.manager.makeGoldItem(itemTuple)
         elif itemClass == InventoryType.TreasureCollection:
             item = self.manager.makeTreasureItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeJewelry:
             item = self.manager.makeJewelryItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeTattoo:
             item = self.manager.makeTattooItem(itemTuple)
         elif itemClass == InventoryCategory.CARDS:
             cardId = itemId
             itemTuple[1] -= InventoryType.begin_Cards
             item = self.manager.makeCardItem(cardId, itemTuple, imageScaleFactor = 1.8999999999999999)
         elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
             itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(itemId)
             item = self.manager.makeAmmoItem(itemId, itemTuple, showMax = 0)
         elif itemType in [
             EconomyGlobals.ItemType.DAGGERAMMO,
             EconomyGlobals.ItemType.PISTOLAMMO,
             EconomyGlobals.ItemType.GRENADEAMMO,
             EconomyGlobals.ItemType.CANNONAMMO]:
             itemTuple = [
                 0,
                 itemId,
                 0,
                 EconomyGlobals.getItemQuantity(itemId)]
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             item = self.manager.makeAmmoItem(skillId, itemTuple, showMax = 0)
         elif itemType in [
             EconomyGlobals.ItemType.PISTOL_POUCH,
             EconomyGlobals.ItemType.DAGGER_POUCH,
             EconomyGlobals.ItemType.GRENADE_POUCH,
             EconomyGlobals.ItemType.CANNON_POUCH,
             EconomyGlobals.ItemType.FISHING_POUCH]:
             item = self.manager.makePouchItem(itemTuple)
         elif itemType in (EconomyGlobals.ItemType.FISHING_LURE,):
             itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(itemId)
             itemTuple[3] = EconomyGlobals.getItemQuantity(itemId)
             item = self.manager.makeFishingItem(itemId, itemTuple, showMax = 0)
         
         if itemClass in (InventoryType.ItemTypeMoney, InventoryCategory.CARDS, InventoryType.TreasureCollection):
             self.addGridCell(self.stackImage, 1.0)
         elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
             self.addGridCell(self.stackImage2, 1.0)
         elif itemType in (EconomyGlobals.ItemType.FISHING_LURE,):
             self.addGridCell(self.stackImage, 1.0)
         else:
             self.addGridCell()
         if item:
             self.tryPutIntoFirstOpenCell(item)
         
         item.showResaleValue = False
         if self.zCount == self.gridZ:
             break
             
     
     while self.zCount < self.gridZ:
         self.addGridCell()
    def _TradableInventoryBase__runSelfTest_giving(self, itemCatFilter, itemTypeFilter = None, count = None, verbose = None):
        itemIds = ItemGlobals.getAllItemIds()
        for currItemId in itemIds:
            itemCat = ItemGlobals.getClass(currItemId)
            if itemCatFilter != None and itemCat != itemCatFilter:
                continue

            if not count and ItemGlobals.getStackLimit(currItemId):
                pass
            actualCount = None
            testItem = self.getTestItem(itemCat, currItemId, count = actualCount)
            if game.process == 'ai':

                def tradeSuccess(tradeObj):
                    if verbose:
                        print '  trade success'

                    self.testPending = False


                def tradeFail(tradeObj, reason):
                    reasonStr = reason
                    RejectCode = RejectCode
                    import otp.uberdog.RejectCode
                    for currCode in RejectCode.__dict__.keys():
                        if reason == RejectCode.__dict__[currCode]:
                            reasonStr = currCode
                            continue

                    if verbose:
                        print '  trade fail %s (%s)' % (reasonStr, tradeObj)

                    if reason == RejectCode.OVERFLOW:
                        for currGiving in tradeObj.giving:
                            checkItem = InvItem(currGiving)
                            itemCat = checkItem.getCat()
                            if not itemCat == InventoryType.ItemTypeWeapon:
                                pass
                            ranges = self.getPossibleLocations(itemCat, checkItem.getType(), itemCat == InventoryType.ItemTypeCharm)
                            for currRange in ranges:
                                minVal = currRange[0]
                                if len(currRange) > 1:
                                    maxVal = currRange[1]
                                else:
                                    maxVal = minVal
                                for currLocation in range(minVal, maxVal + 1):
                                    if not self._locatableItems.has_key(currLocation):
                                        print '    WARNING: trade %s failed with overflow when it should not have %s' % (tradeObj, currLocation)
                                        continue



                    elif reason == RejectCode.UNDERFLOW:
                        print '    WARNING: trade %s failed with underflow when it should not have' % tradeObj

                    self.testPending = False


                def tradeTimeout(tradeObj):
                    if verbose:
                        print '  trade timeout'

                    self.testPending = False

                AIMagicWordTrade = AIMagicWordTrade
                import pirates.uberdog.AIMagicWordTrade
                trade = AIMagicWordTrade(self, self.doId, self.ownerId)

                def removeSetup(tradeObj, removeCat, removeType):
                    ranges = self.getPossibleLocations(removeCat, removeType, False)
                    itemToRemove = self._locatableItems.get(ranges[0][0])
                    tradeObj.takeItem(itemToRemove)

                trade.setSuccessCallback(tradeSuccess)
                trade.setFailureCallback(tradeFail)
                trade.setTimeoutCallback(tradeTimeout)
                self.selfTestTrades.insert(0, (lambda param1 = trade, param2 = itemCat, param3 = testItem.getType(): removeSetup(param1, param2, param3), trade))
                AIGift = AIGift
                import pirates.uberdog.AIGift
                trade = AIGift(self, GiftOrigin.MAGIC_WORD, self.doId, self.ownerId)
                trade.giveItem(testItem)
                trade.setSuccessCallback(tradeSuccess)
                trade.setFailureCallback(tradeFail)
                trade.setTimeoutCallback(tradeTimeout)
                self.selfTestTrades.insert(1, (None, trade))
                continue
Exemplo n.º 18
0
 def addRewardIntoGrid(self, itemId, x, z):
     itemInfo = (ItemGlobals.getClass(itemId), itemId, 0, 0)
     item = self.manager.makeLocatableItem(itemInfo)
     self.putIntoGrid(item, x, z)
    def __runSelfTest_giving(self,
                             itemCatFilter,
                             itemTypeFilter=None,
                             count=None,
                             verbose=None):
        itemIds = ItemGlobals.getAllItemIds()
        itemIds = filter(
            lambda x: itemTypeFilter == None or itemTypeFilter == x, itemIds)
        for currItemId in itemIds:
            itemCat = ItemGlobals.getClass(currItemId)
            if itemCatFilter != None and itemCat != itemCatFilter:
                continue
            actualCount = count or ItemGlobals.getStackLimit(
                currItemId) or None
            testItem = self.getTestItem(itemCat, currItemId, count=actualCount)
            if game.process == 'ai':

                def tradeSuccess(tradeObj):
                    if verbose:
                        print '  trade success'
                    self.testPending = False

                def tradeFail(tradeObj, reason):
                    reasonStr = reason
                    from otp.uberdog.RejectCode import RejectCode
                    for currCode in RejectCode.__dict__.keys():
                        if reason == RejectCode.__dict__[currCode]:
                            reasonStr = currCode

                    if verbose:
                        print '  trade fail %s (%s)' % (reasonStr, tradeObj)
                    if reason == RejectCode.OVERFLOW:
                        for currGiving in tradeObj.giving:
                            checkItem = InvItem(currGiving)
                            itemCat = checkItem.getCat()
                            ranges = self.getPossibleLocations(
                                itemCat, checkItem.getType(),
                                itemCat == InventoryType.ItemTypeWeapon
                                or itemCat == InventoryType.ItemTypeCharm)
                            for currRange in ranges:
                                minVal = currRange[0]
                                if len(currRange) > 1:
                                    maxVal = currRange[1]
                                else:
                                    maxVal = minVal
                                for currLocation in range(minVal, maxVal + 1):
                                    if not self._locatableItems.has_key(
                                            currLocation):
                                        print '    WARNING: trade %s failed with overflow when it should not have %s' % (
                                            tradeObj, currLocation)

                    elif reason == RejectCode.UNDERFLOW:
                        print '    WARNING: trade %s failed with underflow when it should not have' % tradeObj
                    self.testPending = False

                def tradeTimeout(tradeObj):
                    if verbose:
                        print '  trade timeout'
                    self.testPending = False

                from pirates.uberdog.AIMagicWordTrade import AIMagicWordTrade
                trade = AIMagicWordTrade(self, self.doId, self.ownerId)

                def removeSetup(tradeObj, removeCat, removeType):
                    ranges = self.getPossibleLocations(removeCat, removeType,
                                                       False)
                    itemToRemove = self._locatableItems.get(ranges[0][0])
                    tradeObj.takeItem(itemToRemove)

                trade.setSuccessCallback(tradeSuccess)
                trade.setFailureCallback(tradeFail)
                trade.setTimeoutCallback(tradeTimeout)
                self.selfTestTrades.insert(
                    0, (lambda param1=trade, param2=itemCat, param3=testItem.
                        getType(): removeSetup(param1, param2, param3), trade))
                from pirates.uberdog.AIGift import AIGift
                trade = AIGift(self, GiftOrigin.MAGIC_WORD, self.doId,
                               self.ownerId)
                trade.giveItem(testItem)
                trade.setSuccessCallback(tradeSuccess)
                trade.setFailureCallback(tradeFail)
                trade.setTimeoutCallback(tradeTimeout)
                self.selfTestTrades.insert(1, (None, trade))

        return
 def addRewardIntoGrid(self, itemId, x, z):
     itemInfo = (ItemGlobals.getClass(itemId), itemId, 0, 0)
     item = self.manager.makeLocatableItem(itemInfo)
     self.putIntoGrid(item, x, z)