예제 #1
0
 def __init__(self, uid):
     SimpleItem.__init__(self, uid)
     self.itemClass = EconomyGlobals.getItemCategory(uid)
     self.itemType = EconomyGlobals.getItemType(uid)
     self.cost = EconomyGlobals.getItemCost(uid)
     if not self.cost:
         self.cost = ItemGlobals.getGoldCost(uid)
예제 #2
0
 def __init__(self, uid):
     SimpleItem.__init__(self, uid)
     self.itemClass = EconomyGlobals.getItemCategory(uid)
     self.itemType = EconomyGlobals.getItemType(uid)
     self.cost = EconomyGlobals.getItemCost(uid)
     if not self.cost:
         self.cost = ItemGlobals.getGoldCost(uid)
예제 #3
0
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, pos = (0.035000000000000003, 0, 0.025000000000000001))
     self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ARight, text_wordwrap = 11, pos = (0.1225, 0, 0.014999999999999999))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(2)
     elif len(self.name) >= 35:
         textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(2)
     else:
         textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2)
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_fg = PiratesGuiGlobals.TextFG2, text_scale = textScale, text_align = TextNode.ALeft, pos = (0.13, 0, 0.014999999999999999))
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = InventoryListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.0050000000000000001, 0, 0.012500000000000001), text = str(self.price), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.014999999999999999), text_font = PiratesGlobals.getInterfaceFont())
     itemClass = EconomyGlobals.getItemCategory(itemId)
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = PurchaseListItem.fishingIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.weaponIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.CONSUMABLE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.059999999999999998
                     self.picture['geom_pos'] = (0, 0, 0)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.10000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     self.flattenStrong()
예제 #4
0
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent=self, relief=None, state=DGG.DISABLED, pos=(0.035,
                                                                                   0,
                                                                                   0.025))
     self.quantityLabel = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, text=str(self.quantity), text_fg=PiratesGuiGlobals.TextFG2, text_scale=PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align=TextNode.ARight, text_wordwrap=11, pos=(0.1225,
                                                                                                                                                                                                                                                                                0,
                                                                                                                                                                                                                                                                                0.015))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(2)
     else:
         if len(self.name) >= 35:
             textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(2)
         else:
             textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2)
         self.nameTag = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, text=self.name, text_fg=PiratesGuiGlobals.TextFG2, text_scale=textScale, text_align=TextNode.ALeft, pos=(0.13,
                                                                                                                                                                                           0,
                                                                                                                                                                                           0.015))
         self.costText = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, image=InventoryListItem.coinImage, image_scale=0.12, image_pos=Vec3(-0.005, 0, 0.0125), text=str(self.price), text_fg=PiratesGuiGlobals.TextFG2, text_scale=PiratesGuiGlobals.TextScaleSmall, text_align=TextNode.ARight, text_wordwrap=11, text_pos=(-0.03, 0, 0), pos=(self.width - 0.035, 0, 0.015), text_font=PiratesGlobals.getInterfaceFont())
         itemClass = EconomyGlobals.getItemCategory(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = PurchaseListItem.fishingIcons.find('**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = InventoryListItem.weaponIcons.find('**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         elif itemClass == ItemType.CONSUMABLE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         if InventoryType.begin_WeaponCannonAmmo <= itemId and itemId <= InventoryType.end_WeaponCannonAmmo or InventoryType.begin_WeaponPistolAmmo <= itemId and itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.06
                     self.picture['geom_pos'] = (0, 0, 0)
         if InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.1
             self.picture['geom_pos'] = (0, 0, 0)
     self.flattenStrong()
     return
예제 #5
0
 def getGeomParams(itemId):
     geomParams = { }
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         if itemType == ItemType.POTION:
             geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
         else:
             itemType = ItemGlobals.getType(itemId)
             if ItemGlobals.getIcon(itemId):
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
             
         geomParams['geom_scale'] = 0.11
         geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
     else:
         itemClass = EconomyGlobals.getItemCategory(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.fishingIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.WEAPON and itemClass == ItemType.POUCH or itemClass == ItemType.AMMO:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.CONSUMABLE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     geomParams['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     geomParams['geom_scale'] = 0.14999999999999999
                     geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             geomParams['geom'] = InventoryListItem.topGui.find('**/main_gui_ship_bottle')
             geomParams['geom_scale'] = 0.10000000000000001
             geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
         
     return geomParams
예제 #6
0
 def createGui(self):
     itemId = self.data[0]
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.16, 0, 0.105), text_font = PiratesGlobals.getInterfaceFont())
     if itemId in range(InventoryType.begin_PistolPouches, InventoryType.end_PistolPouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.InventoryItemClassNames.get(ItemType.PISTOL), 1)
     elif itemId in range(InventoryType.begin_DaggerPouches, InventoryType.end_DaggerPouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.InventoryItemClassNames.get(ItemType.DAGGER), 1)
     elif itemId in range(InventoryType.begin_GrenadePouches, InventoryType.end_GrenadePouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.GrenadeShort, 1)
     elif itemId in range(InventoryType.begin_CannonPouches, InventoryType.end_CannonPouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.ShipCannonShort, 1)
     else:
         self.itemTypeFormatted = PLocalizer.makeHeadingString(self.itemType, 1)
     self.itemTypeName = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.itemTypeFormatted, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0.16, 0, 0.065000000000000002))
     self.miscText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = '', text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.16, 0, 0.025000000000000001))
     if self.minLvl > 0:
         repId = WeaponGlobals.getRepId(itemId)
         if repId:
             self.checkLevel(repId, self.minLvl)
         
     
     self.checkFreebooter(itemId, base.localAvatar.getDoId())
     trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
     if trainingReq:
         self.checkTrainingReq(trainingReq)
     
     if EconomyGlobals.getItemCategory(itemId) == ItemType.AMMO:
         skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
         self.checkSkillReq(skillId)
     
     self.checkInfamyReq(itemId)
     if self.buy:
         self.checkPlayerInventory(itemId)
     
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = InventoryListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.01, 0, 0.01), text = str(self.price), text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.065000000000000002), text_font = PiratesGlobals.getInterfaceFont())
     if self.quantity and self.quantity > 1:
         self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), frameColor = (0, 0, 0, 1), frameSize = (-0.01, 0.02, -0.01, 0.025000000000000001), text_scale = 0.0275, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.02, 0, 0.025000000000000001), text_font = PiratesGlobals.getPirateBoldOutlineFont())
     
     geomParams = InventoryItemGui.getGeomParams(itemId)
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, geom = geomParams['geom'], geom_pos = geomParams['geom_pos'], geom_scale = geomParams['geom_scale'], pos = (0.01, 0, 0.01))
     self.flattenStrong()
예제 #7
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()
예제 #8
0
    def createGui(self):
        itemId = self.data[0]
        self.picture = DirectFrame(parent=self,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   pos=(0.01, 0, 0.01))
        self.nameTag = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=self.name,
            text_scale=PiratesGuiGlobals.TextScaleSmall *
            PLocalizer.getHeadingScale(2),
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(0.050000000000000003, 0, 0.105),
            text_font=PiratesGlobals.getInterfaceFont())
        itemTypeFormatted = ''
        self.itemTypeName = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=itemTypeFormatted,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0.050000000000000003, 0, 0.065000000000000002))
        self.miscText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text='',
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=11,
            pos=(0.050000000000000003, 0, 0.025000000000000001))
        if self.minLvl > 0:
            repId = WeaponGlobals.getRepId(itemId)
            if repId:
                self.checkLevel(repId, self.minLvl)

        trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
        if trainingReq:
            self.checkTrainingReq(trainingReq)

        if EconomyGlobals.getItemCategory(itemId) == ItemType.AMMO:
            skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
            self.checkSkillReq(skillId)

        if self.buy:
            self.checkPlayerInventory(itemId)

        self.costText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            image=SongListItem.coinImage,
            image_scale=0.12,
            image_pos=Vec3(-0.01, 0, 0.01),
            text=str(self.price),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=11,
            text_pos=(-0.029999999999999999, 0, 0),
            pos=(self.width - 0.035000000000000003, 0, 0.105),
            text_font=PiratesGlobals.getInterfaceFont())
        if self.quantity and self.quantity > 1:
            self.quantityLabel = DirectLabel(
                parent=self,
                relief=None,
                state=DGG.DISABLED,
                text=str(self.quantity),
                frameColor=(0, 0, 0, 1),
                frameSize=(-0.01, 0.02, -0.01, 0.025000000000000001),
                text_scale=0.0275,
                text_align=TextNode.ACenter,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                text_wordwrap=11,
                pos=(0.02, 0, 0.025000000000000001),
                text_font=PiratesGlobals.getPirateBoldOutlineFont())

        itemClass = EconomyGlobals.getItemCategory(itemId)
        if itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = SongItemGui.weaponIcons.find('**/%s*' %
                                                                    asset)
                self.picture['geom_scale'] = 0.11
                self.picture['geom_pos'] = (0.080000000000000002, 0,
                                            0.068000000000000005)

        elif itemClass == ItemType.CONSUMABLE:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = SongItemGui.skillIcons.find('**/%s*' %
                                                                   asset)
                self.picture['geom_scale'] = 0.11
                self.picture['geom_pos'] = (0.080000000000000002, 0,
                                            0.068000000000000005)

        if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
            if (InventoryType.begin_WeaponPistolAmmo <= itemId
                    or itemId <= InventoryType.end_WeaponGrenadeAmmo
                    or InventoryType.begin_WeaponDaggerAmmo <= itemId
                ) and itemId <= InventoryType.end_WeaponDaggerAmmo:
                skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
                if skillId:
                    asset = WeaponGlobals.getSkillIcon(skillId)
                    if asset:
                        self.picture['geom'] = SongListItem.skillIcons.find(
                            '**/%s' % asset)
                        self.picture['geom_scale'] = 0.14999999999999999
                        self.picture['geom_pos'] = (0.069000000000000006, 0,
                                                    0.069000000000000006)

            elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
                self.picture['geom'] = SongListItem.topGui.find(
                    '**/main_gui_ship_bottle')
                self.picture['geom_scale'] = 0.10000000000000001
                self.picture['geom_pos'] = (0.069000000000000006, 0,
                                            0.069000000000000006)

        self.flattenStrong()
    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()
예제 #10
0
 def createGui(self):
     itemId = self.data[0]
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, pos = (0.01, 0, 0.01))
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.050000000000000003, 0, 0.105), text_font = PiratesGlobals.getInterfaceFont())
     itemTypeFormatted = ''
     self.itemTypeName = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = itemTypeFormatted, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0.050000000000000003, 0, 0.065000000000000002))
     self.miscText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = '', text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.050000000000000003, 0, 0.025000000000000001))
     if self.minLvl > 0:
         repId = WeaponGlobals.getRepId(itemId)
         if repId:
             self.checkLevel(repId, self.minLvl)
         
     
     trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
     if trainingReq:
         self.checkTrainingReq(trainingReq)
     
     if EconomyGlobals.getItemCategory(itemId) == ItemType.AMMO:
         skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
         self.checkSkillReq(skillId)
     
     if self.buy:
         self.checkPlayerInventory(itemId)
     
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = SongListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.01, 0, 0.01), text = str(self.price), text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.105), text_font = PiratesGlobals.getInterfaceFont())
     if self.quantity and self.quantity > 1:
         self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), frameColor = (0, 0, 0, 1), frameSize = (-0.01, 0.02, -0.01, 0.025000000000000001), text_scale = 0.0275, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.02, 0, 0.025000000000000001), text_font = PiratesGlobals.getPirateBoldOutlineFont())
     
     itemClass = EconomyGlobals.getItemCategory(itemId)
     if itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = SongItemGui.weaponIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.11
             self.picture['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
         
     elif itemClass == ItemType.CONSUMABLE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = SongItemGui.skillIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.11
             self.picture['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
         
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = SongListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.14999999999999999
                     self.picture['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = SongListItem.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.10000000000000001
             self.picture['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
         
     self.flattenStrong()
예제 #11
0
 def checkPlayerInventory(self, itemId, extraQty = 0):
     if self.available:
         itemCategory = EconomyGlobals.getItemCategory(itemId)
         inventory = base.localAvatar.getInventory()
         currStock = inventory.getStackQuantity(itemId)
         currStockLimit = inventory.getStackLimit(itemId)
         if itemCategory == ItemType.AMMO or itemCategory == ItemType.CONSUMABLE:
             if currStock + extraQty >= currStockLimit and currStockLimit > 0:
                 self.highlightGreen(PLocalizer.InventoryFull % currStockLimit)
             else:
                 self.highlightBox(PLocalizer.InventoryCurrent % (currStock + extraQty, currStockLimit), Vec4(1, 1, 1, 1), PiratesGuiGlobals.TextFG2)
         elif itemCategory == ItemType.WEAPON:
             if currStock >= 1:
                 self.highlightGreen(PLocalizer.InventoryOwned)
             else:
                 inv = base.localAvatar.getInventory()
                 if inv is None:
                     return None
                 
                 itemRep = WeaponGlobals.getRepId(itemId)
                 if itemRep == InventoryType.CutlassRep:
                     options = [
                         InventoryType.CutlassWeaponL1,
                         InventoryType.CutlassWeaponL2,
                         InventoryType.CutlassWeaponL3,
                         InventoryType.CutlassWeaponL4,
                         InventoryType.CutlassWeaponL5,
                         InventoryType.CutlassWeaponL6]
                 elif itemRep == InventoryType.PistolRep:
                     options = [
                         InventoryType.PistolWeaponL1,
                         InventoryType.PistolWeaponL2,
                         InventoryType.PistolWeaponL3,
                         InventoryType.PistolWeaponL4,
                         InventoryType.PistolWeaponL5,
                         InventoryType.PistolWeaponL6]
                 elif itemRep == InventoryType.DaggerRep:
                     options = [
                         InventoryType.DaggerWeaponL1,
                         InventoryType.DaggerWeaponL2,
                         InventoryType.DaggerWeaponL3,
                         InventoryType.DaggerWeaponL4,
                         InventoryType.DaggerWeaponL5,
                         InventoryType.DaggerWeaponL6]
                 elif itemRep == InventoryType.GrenadeRep:
                     options = [
                         InventoryType.GrenadeWeaponL1,
                         InventoryType.GrenadeWeaponL2,
                         InventoryType.GrenadeWeaponL3,
                         InventoryType.GrenadeWeaponL4,
                         InventoryType.GrenadeWeaponL5,
                         InventoryType.GrenadeWeaponL6]
                 elif itemRep == InventoryType.DollRep:
                     options = [
                         InventoryType.DollWeaponL1,
                         InventoryType.DollWeaponL2,
                         InventoryType.DollWeaponL3,
                         InventoryType.DollWeaponL4,
                         InventoryType.DollWeaponL5,
                         InventoryType.DollWeaponL6]
                 elif itemRep == InventoryType.WandRep:
                     options = [
                         InventoryType.WandWeaponL1,
                         InventoryType.WandWeaponL2,
                         InventoryType.WandWeaponL3,
                         InventoryType.WandWeaponL4,
                         InventoryType.WandWeaponL5,
                         InventoryType.WandWeaponL6]
                 else:
                     return None
                 for idx in range(len(options)):
                     optionId = options[idx]
                     if optionId == itemId:
                         currIdx = idx
                         for weaponId in options[currIdx:]:
                             if weaponId == itemId:
                                 continue
                             
                             stackAmt = inv.getStackQuantity(weaponId)
                             if stackAmt >= 1:
                                 self.highlightRed(PLocalizer.InventoryLowLevel)
                                 return None
                                 continue
                         
                 
         elif itemCategory == ItemType.POUCH:
             inv = base.localAvatar.getInventory()
             if currStock >= 1:
                 self.highlightGreen(PLocalizer.InventoryOwned)
             else:
                 pistolPouches = [
                     InventoryType.PistolPouchL1,
                     InventoryType.PistolPouchL2,
                     InventoryType.PistolPouchL3]
                 daggerPouches = [
                     InventoryType.DaggerPouchL1,
                     InventoryType.DaggerPouchL2,
                     InventoryType.DaggerPouchL3]
                 grenadePouches = [
                     InventoryType.GrenadePouchL1,
                     InventoryType.GrenadePouchL2,
                     InventoryType.GrenadePouchL3]
                 cannonPouches = [
                     InventoryType.CannonPouchL1,
                     InventoryType.CannonPouchL2,
                     InventoryType.CannonPouchL3]
                 if itemId in pistolPouches:
                     pouchSet = pistolPouches
                 elif itemId in daggerPouches:
                     pouchSet = daggerPouches
                 elif itemId in grenadePouches:
                     pouchSet = grenadePouches
                 elif itemId in cannonPouches:
                     pouchSet = cannonPouches
                 else:
                     pouchSet = []
                 for pouchIdx in range(len(pouchSet)):
                     if pouchSet[pouchIdx] == itemId and pouchIdx + 1 < len(pouchSet):
                         for higherPouchIdx in range(pouchIdx + 1, len(pouchSet)):
                             stackAmt = inv.getStackQuantity(pouchSet[higherPouchIdx])
                             if stackAmt >= 1:
                                 self.highlightRed(PLocalizer.InventoryLowLevel)
                                 return None
                                 continue