Ejemplo n.º 1
0
 def onAmmoClick(self, skillId):
     button = self.buttons[skillId]
     if button.isLocked():
         if not Freebooter.getPaidStatus(base.localAvatar.doId) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
             localAvatar.guiMgr.showNonPayer()
         
         return None
     
     if button.canPurchase(self._bankNotes):
         if self.addAmmoSkill(skillId):
             self._bankNotes -= button.cost
             self.updateBankNoteText()
             button.disablePurchase()
             if self.sfxAmmoBought:
                 base.playSfx(self.sfxAmmoBought)
             
         elif not self.hasSkill(skillId):
             button.flash()
             self.msgMgr.showNoAmmoSlot()
             if self.sfxAmmoDeny:
                 base.playSfx(self.sfxAmmoDeny)
             
         
     elif not self.hasSkill(skillId):
         button.flash()
         self.msgMgr.showNotEnoughBankNotes()
         if self.sfxAmmoDeny:
             base.playSfx(self.sfxAmmoDeny)
         
     
     if self.hasSkill(skillId):
         base.localAvatar.guiMgr.combatTray.skillTray.updateSkillTray(InventoryType.DefenseCannonRep, WeaponGlobals.DEFENSE_CANNON, hideFirst = False)
         base.localAvatar.guiMgr.combatTray.triggerSkillTraySkill(skillId)
         self.cannon.cgui.showCannonControls()
         self.updateQuantities()
Ejemplo n.º 2
0
 def checkLevel(self, repId, minLvl):
     inv = localAvatar.getInventory()
     if inv:
         repAmt = inv.getAccumulator(repId)
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             item, quantity = self.data
             if item not in [ItemId.INTERCEPTOR_L1, ItemId.MERCHANT_L1, ItemId.WARSHIP_L1, ItemId.BRIG_L1]:
                 if not self.miscText:
                     self.miscText = DirectLabel(parent=self, relief=None, text='', text_scale=PiratesGuiGlobals.TextScaleSmall, text_align=TextNode.ALeft, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_wordwrap=11, text_pos=(0.05,
                                                                                                                                                                                                                                                                     0,
                                                                                                                                                                                                                                                                     0), pos=(0.16,
                                                                                                                                                                                                                                                                              0,
                                                                                                                                                                                                                                                                              0.025))
                 self['image_color'] = Vec4(1, 0.5, 0.5, 1)
                 self.miscText['text_fg'] = PiratesGuiGlobals.TextFG8
                 self.miscText['text'] = PLocalizer.noFreebooterCap
                 subCard = loader.loadModel('models/gui/toplevel_gui')
                 appendMe = DirectFrame(parent=self, relief=None, pos=(self.width - 0.405, 0, -0.015), state=DGG.DISABLED, geom=subCard.find('**/pir_t_gui_gen_key_subscriber'), geom_scale=0.12, geom_pos=(0.06,
                                                                                                                                                                                                            0,
                                                                                                                                                                                                            0.06))
                 subCard.removeNode()
         elif minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]:
             if not self.miscText:
                 self.miscText = DirectLabel(parent=self, relief=None, 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.025))
             self['image_color'] = Vec4(1, 0.5, 0.25, 1)
             self['state'] = DGG.DISABLED
             self.miscText['text_fg'] = PiratesGuiGlobals.TextFG8
             self.miscText['text'] = PLocalizer.LevelRequirement % minLvl
     return
Ejemplo n.º 3
0
 def showHolidayMessage(self, holidayId, msgType):
     self.notify.debug('showHolidayMessage-holidayId:' + str(holidayId))
     taskMgr.remove('showHolidayMessage-holidayId:' + str(holidayId))
     if not hasattr(base, 'localAvatar'):
         return
     paidStatus = Freebooter.getPaidStatus(localAvatar.getDoId(), checkHoliday=False)
     if base.localAvatar.getTutorialState() < PiratesGlobals.TUT_MET_JOLLY_ROGER or self.inNewsWorld() == None:
         taskMgr.doMethodLater(15, self.showHolidayMessage, 'showHolidayMessage-holidayId:' + str(holidayId), extraArgs=[holidayId, msgType])
         return
     if msgType == 1:
         hours, minutes = self.getTimeRemaining(holidayId)
         message = HolidayGlobals.getHolidayStartMsg(holidayId, paidStatus)
         if message:
             if re.findall('%\\(hours\\)s', message) and re.findall('%\\(minutes\\)s', message):
                 message = message % {'hours': hours, 'minutes': minutes}
             chatMessage = HolidayGlobals.getHolidayStartChatMsg(holidayId, paidStatus)
             chatMessage = chatMessage and re.findall('%\\(hours\\)s', chatMessage) and re.findall('%\\(minutes\\)s', chatMessage) and chatMessage % {'hours': hours, 'minutes': minutes}
     else:
         if msgType == 0:
             message = HolidayGlobals.getHolidayEndMsg(holidayId, paidStatus)
             chatMessage = HolidayGlobals.getHolidayEndChatMsg(holidayId, paidStatus)
     if message:
         base.localAvatar.guiMgr.messageStack.addModalTextMessage(message, seconds=45, priority=0, color=PiratesGuiGlobals.TextFG14, icon=(HolidayGlobals.getHolidayIcon(holidayId), ''), modelName='general_frame_f')
     if chatMessage:
         base.talkAssistant.receiveGameMessage(chatMessage)
     return
 def canLocalUseItem(self, itemTuple):
     canUse = 1
     reason = ItemConstants.REASON_NONE
     itemCat = itemTuple[0]
     itemId = itemTuple[1]
     rarity = ItemGlobals.getRarity(itemId)
     if rarity != ItemConstants.CRUDE and not Freebooter.getPaidStatus(
             base.localAvatar.getDoId()):
         canUse = 0
         reason = ItemConstants.REASON_VELVETROPE
         return (canUse, reason)
     elif itemCat == InventoryType.ItemTypeClothing:
         gender = localAvatar.style.getGender()
         if gender == 'm' and ItemGlobals.getMaleModelId(itemId) == -1:
             canUse = 0
             reason = ItemConstants.REASON_GENDER
             return (canUse, reason)
         elif gender == 'f' and ItemGlobals.getFemaleModelId(itemId) == -1:
             canUse = 0
             reason = ItemConstants.REASON_GENDER
             return (canUse, reason)
     elif itemCat in [
             InventoryType.ItemTypeWeapon, InventoryType.ItemTypeCharm
     ]:
         inv = localAvatar.getInventory()
         if not inv:
             canUse = 0
             reason = ItemConstants.REASON_INVENTORY
             return (canUse, reason)
         reqs = localAvatar.getInventory().getItemRequirements(itemId)
         if reqs == None or filter(lambda x: reqs[x][1] == False, reqs):
             canUse = 0
             reason = ItemConstants.REASON_LEVEL
             return (canUse, reason)
     return (canUse, reason)
Ejemplo n.º 5
0
    def requestInteraction(self, avId, interactType=0):
        if self.buildingUid == LocationIds.KINGSHEAD_OUTER_DOOR and not Freebooter.getPaidStatus(localAvatar.getDoId()):
            localAvatar.guiMgr.showNonPayer(quest="Restricted_Location", focus=0)
            return None

        print "requestinteraction", 0
        if avId == localAvatar.doId:
            self.fadeOut()
            return None

        if self.questNeeded:
            questHistory = localAvatar.getQuestLadderHistory()
            currentQuests = localAvatar.getQuests()
            container = QuestLadderDB.getContainer(self.questNeeded)
            canEnter = False
            for quest in currentQuests:
                if container.getQuestId() == quest.getQuestId() or container.hasQuest(quest.getQuestId()):
                    canEnter = True
                    continue

            if not canEnter:
                if self.buildingUid == LocationIds.UNDEAD_POKER_SHACK:
                    localAvatar.guiMgr.createWarning(PLocalizer.ClubheartsQuestWarning, PiratesGuiGlobals.TextFG6)

                return None

        print "requestinteraction", 2
        DistributedInteractive.DistributedInteractive.requestInteraction(self, avId, interactType)
    def startHoliday(self, holidayId):
        if holidayId not in self.holidayIdList:
            self.notify.debug('setHolidayId: Starting Holiday %s' % holidayId)
            self.holidayIdList.append(holidayId)
            self.setHoliday(holidayId, 1)
            SimpleStoreGUI.SimpleStoreGUI.holidayIdList.append(holidayId)
            AccessoriesStoreGUI.AccessoriesStoreGUI.holidayIdList.append(holidayId)
            JewelryStoreGUI.JewelryStoreGUI.holidayIdList.append(holidayId)
            BarberStoreGUI.BarberStoreGUI.holidayIdList.append(holidayId)
            TattooStoreGUI.TattooStoreGUI.holidayIdList.append(holidayId)
            localAvatar.chatMgr.emoteEntry.updateEmoteList()
            self.showHolidayMessage(holidayId, 1)
            if holidayId == HolidayGlobals.JOLLYROGERCURSE:
                currentTime = base.cr.timeOfDayManager.getCurrentIngameTime()
                if currentTime > 18.0 or currentTime < 1.0:
                    self.displayMessage(3)
                else:
                    self.displayMessage(2)

            if holidayId == HolidayGlobals.ALLACCESSWEEKEND:
                Freebooter.setAllAccess(True)
                localAvatar.guiMgr.stashPrevPanel()

            if holidayId == HolidayGlobals.APRILFOOLS:
                messenger.send('moustacheFlip', [
                    1])

            if holidayId == HolidayGlobals.HALFOFFCUSTOMIZATION:
                paidStatus = Freebooter.getPaidStatus(localAvatar.getDoId())
                if paidStatus:
                    self.divideAllAccessories(2)


            messenger.send('HolidayStarted', [
                HolidayGlobals.getHolidayName(holidayId)])
 def __init__(self, callback, skillId, skillRank):
     if not AmmoPanelButton.SkillIcons:
         AmmoPanelButton.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
         AmmoPanelButton.Image = (AmmoPanelButton.SkillIcons.find('**/base'), AmmoPanelButton.SkillIcons.find('**/base_down'), AmmoPanelButton.SkillIcons.find('**/base_over'))
     
     self.locked = True
     self.purchaseable = True
     self.cost = CannonDefenseGlobals.getDefenseCannonAmmoCost(skillId)
     self.amount = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
     if self.amount == -1:
         self.amount = PLocalizer.Unlimited
     
     self.skillId = skillId
     self.skillRank = skillRank
     self.infoBox = None
     self.flashIval = None
     asset = RadialMenu.getSkillIconName(skillId, 0)
     geom = AmmoPanelButton.SkillIcons.find('**/%s' % asset)
     self.geom = geom
     if self.locked:
         asset = None
         geom = None
     
     DirectButton.__init__(self, relief = None, pos = (0, 0, 0), text = '?', text_scale = 0.10000000000000001, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_pos = (0.0050000000000000001, -0.035000000000000003), text_align = TextNode.ACenter, image = AmmoPanelButton.Image, image_scale = 0.12, geom = geom, geom_scale = 0.12, command = callback, textMayChange = 1, sortOrder = 70, extraArgs = [
         skillId])
     self.initialiseoptions(AmmoPanelButton)
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.lockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
     if not Freebooter.getPaidStatus(base.localAvatar.doId) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
         self.lock = DirectFrame(parent = self, relief = None, image = self.lockIcon, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, -0.025000000000000001), sortOrder = 99)
     
     self.bind(DGG.ENTER, self.showDetails)
     self.bind(DGG.EXIT, self.hideDetails)
Ejemplo n.º 8
0
 def enableStatsOV(self, shipOV):
     self.snapShot = ShipSnapshot(self,
                                  shipOV,
                                  self['siegeTeam'],
                                  pos=self['snapShotPos'])
     typeStr = ''
     if self['siegeTeam']:
         hp = shipOV.maxHp
         sp = shipOV.maxSp
     else:
         hp = shipOV.Hp
         sp = shipOV.Sp
     if hp <= 0:
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.DeployShip
         stateStr = '\x01Ired\x01%s\x02' % PLocalizer.ShipSunk
         self['shipColorScale'] = VBase4(1, 0.4, 0.4, 1)
         self.button['image3_color'] = VBase4(
             *PiratesGuiGlobals.ButtonColor3[2])
         self.button['geom3_color'] = VBase4(0.4, 0.4, 0.4, 0.4)
         self.button['text3_color'] = VBase4(0.4, 0.4, 0.4, 0.4)
         self.button['helpText'] = PLocalizer.ShipSunk
     else:
         if len(shipOV.crew) >= shipOV.maxCrew:
             self.button['state'] = DGG.DISABLED
             self.button['text'] = PLocalizer.BoardShip
             self.button['helpText'] = PLocalizer.ShipFull
             stateStr = '\x01red\x01%s\x02' % (PLocalizer.ShipFull, )
             self['shipColorScale'] = VBase4(0.4, 0.4, 0.4, 1)
         elif localAvatar.getActiveShipId(
         ) and shipOV.doId != localAvatar.getActiveShipId():
             self.button['state'] = DGG.DISABLED
             self.button['text'] = PLocalizer.DeployShip
             self.button['helpText'] = PLocalizer.OtherShipOut
             stateStr = '\x01Ired\x01%s\x02' % PLocalizer.OtherShipOut
             self['shipColorScale'] = VBase4(0.4, 0.4, 0.4, 1)
         elif shipOV.state in 'Off':
             self.button['state'] = DGG.NORMAL
             self.button['text'] = PLocalizer.DeployShip
             stateStr = PLocalizer.ShipInBottle
             self.button['helpText'] = PLocalizer.ShipInBottle
         else:
             self.button['state'] = DGG.NORMAL
             self.button['text'] = PLocalizer.BoardShip
             stateStr = PLocalizer.ShipAtSea
             self.button['helpText'] = PLocalizer.ShipAtSea
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId(
         )) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
             self.button['command'] = base.localAvatar.guiMgr.showNonPayer
             self.button['extraArgs'] = ['Restricted_ShipFrame_Deploy', 3]
             self.button['text'] = PLocalizer.Locked
             subgui = loader.loadModel('models/gui/toplevel_gui')
             if subgui:
                 self.button['geom'] = subgui.find(
                     '**/pir_t_gui_gen_key_subscriber')
                 self.button['geom_scale'] = 0.15
                 self.button['geom_color'] = Vec4(0.7, 0.7, 0.7, 1.0)
                 subgui.removeNode()
         if typeStr:
             self.typeLabel['text'] = '\x01smallCaps\x01(%s)\x02' % typeStr
    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
Ejemplo n.º 10
0
    def addOwnShip(self, shipId, callback):
        shipOV = base.cr.getOwnerView(shipId)
        if (not shipOV or self._siegeTeam) and localAvatar.getSiegeTeam(
        ) and localAvatar.getSiegeTeam() != self._siegeTeam:
            return None

        shipFrame = self.getFrame(shipId)
        if not shipFrame:
            mastInfo = ShipGlobals.getMastSetup(shipOV.shipClass)
            shipFrame = ShipFrameDeploy(parent=None,
                                        shipId=shipId,
                                        shipName=shipOV.name,
                                        shipClass=shipOV.shipClass,
                                        mastInfo=mastInfo,
                                        shipType=ShipFrameDeploy.STOwn,
                                        siegeTeam=self._siegeTeam,
                                        command=callback,
                                        extraArgs=[shipId])
            shipFrame.enableStatsOV(shipOV)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId(
            )) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
                shipFrame.nameLabel['text'] = PLocalizer.noFreebooterCap
                shipFrame.nameLabel['text_fg'] = (1, 0.69999999999999996,
                                                  0.69999999999999996, 1)

        self.addFrameOwn(shipFrame)
    def checkLevel(self, repId, minLvl):
        inv = localAvatar.getInventory()
        if inv:
            repAmt = inv.getAccumulator(repId)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                (item, quantity) = self.data
                if item != ItemId.INTERCEPTOR_L1 and item != ItemId.MERCHANT_L1:
                    if not self.miscText:
                        self.miscText = DirectLabel(parent = self, relief = None, text = '', text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, text_pos = (0.050000000000000003, 0, 0), pos = (0.16, 0, 0.025000000000000001))

                    self['image_color'] = Vec4(1, 0.5, 0.5, 1)
                    self.miscText['text_fg'] = PiratesGuiGlobals.TextFG8
                    self.miscText['text'] = PLocalizer.noFreebooterCap
                    subCard = loader.loadModel('models/gui/toplevel_gui')
                    appendMe = DirectFrame(parent = self, relief = None, pos = (self.width - 0.40500000000000003, 0, -0.014999999999999999), state = DGG.DISABLED, geom = subCard.find('**/pir_t_gui_gen_key_subscriber'), geom_scale = 0.12, geom_pos = (0.059999999999999998, 0, 0.059999999999999998))
                    subCard.removeNode()

            elif minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]:
                if not self.miscText:
                    self.miscText = DirectLabel(parent = self, relief = None, 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))

                self['image_color'] = Vec4(1, 0.5, 0.25, 1)
                self['state'] = DGG.DISABLED
                self.miscText['text_fg'] = PiratesGuiGlobals.TextFG8
                self.miscText['text'] = PLocalizer.LevelRequirement % minLvl
    def endHoliday(self, holidayId):
        if holidayId in self.holidayIdList:
            self.notify.debug('setHolidayId: Ending Holiday %s' % holidayId)
            self.holidayIdList.remove(holidayId)
            self.setHoliday(holidayId, 0)
            SimpleStoreGUI.SimpleStoreGUI.holidayIdList.remove(holidayId)
            AccessoriesStoreGUI.AccessoriesStoreGUI.holidayIdList.remove(holidayId)
            JewelryStoreGUI.JewelryStoreGUI.holidayIdList.remove(holidayId)
            BarberStoreGUI.BarberStoreGUI.holidayIdList.remove(holidayId)
            TattooStoreGUI.TattooStoreGUI.holidayIdList.remove(holidayId)
            localAvatar.chatMgr.emoteEntry.updateEmoteList()
            self.showHolidayMessage(holidayId, 0)
            if holidayId == HolidayGlobals.HALFOFFCUSTOMIZATION:
                paidStatus = Freebooter.getPaidStatus(localAvatar.getDoId())
                if paidStatus:
                    self.multiplyAllAccessories(2)


            if holidayId == HolidayGlobals.ALLACCESSWEEKEND:
                Freebooter.setAllAccess(False)

            if holidayId == HolidayGlobals.APRILFOOLS:
                messenger.send('moustacheFlip', [
                    0])

            messenger.send('HolidayEnded', [
                HolidayGlobals.getHolidayName(holidayId)])
 def handleCommitPurchase(self):
     if self.purchaseInventory == [] and self.sellInventory == []:
         base.localAvatar.guiMgr.createWarning(PLocalizer.EmptyPurchaseWarning, PiratesGuiGlobals.TextFG6)
         return None
     
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if self.purchaseInventory[0][0] != ItemId.INTERCEPTOR_L1 and self.purchaseInventory[0][0] != ItemId.MERCHANT_L1:
             base.localAvatar.guiMgr.showNonPayer('Purchase_Restriction', 3)
             return None
         
     
     inventory = base.localAvatar.getInventory()
     if inventory:
         if inventory.getGoldInPocket() < self.balance:
             base.localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughMoneyWarning, PiratesGuiGlobals.TextFG6)
             return None
         
         if self.balance < 0 and inventory.getGoldInPocket() + self.balance > InventoryGlobals.GOLD_CAP:
             base.localAvatar.guiMgr.createWarning(PLocalizer.CannotHoldGoldWarning, PiratesGuiGlobals.TextFG6)
             return None
         
         if len(inventory.getShipDoIdList()) >= inventory.getCategoryLimit(InventoryCategory.SHIPS):
             base.localAvatar.guiMgr.createWarning(PLocalizer.CannotHoldShipWarning, PiratesGuiGlobals.TextFG6)
             return None
         
     
     nameData = [
         PLocalizer.PirateShipPrefix.keys(),
         PLocalizer.PirateShipSuffix.keys()]
     self.namePanel = NamePanelGui.NamePanelGui(PLocalizer.NamePanelTitle, nameData)
     self.namePanel.setPos(0.20000000000000001, 0, 0)
     self.lockStore()
     self.acceptOnce('returnStore', self.unlockStore)
     self.acceptOnce('nameChosen', self.handleCommitPurchasePart2)
 def selectPrev(self):
     if len(self.items) < 1:
         return None
     
     self.show()
     if len(self.items) > 1:
         keepTrying = True
     else:
         keepTrying = False
     while keepTrying:
         keepTrying = False
         self.choice = self.choice - 1
         if self.choice < 0 or self.choice > len(self.items) - 1:
             self.choice = len(self.items) - 1
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if self.items[self.choice]:
                 category = WeaponGlobals.getRepId(self.items[self.choice][0])
                 if not Freebooter.allowedFreebooterWeapon(category):
                     keepTrying = True
                 
             else:
                 keepTrying = True
         self.items[self.choice]
     self.cursor.setPos(self.ICON_WIDTH * self.choice + 0.080000000000000002, 0, 0.071999999999999995)
     taskMgr.remove('BarSelectHideTask' + str(self.getParent()))
     self.hideTask = taskMgr.doMethodLater(self.SelectionDelay, self.confirmSelection, 'BarSelectHideTask' + str(self.getParent()), extraArgs = [])
Ejemplo n.º 15
0
    def __init__(self,
                 skillId,
                 slotId,
                 callback,
                 quantity=0,
                 skillRank=0,
                 showQuantity=False,
                 showHelp=False,
                 showRing=False,
                 hotkey=None,
                 name='',
                 showIcon=True,
                 showLock=False,
                 rechargeSkillId=False,
                 assocAmmo=[]):
        if skillId in [
                InventoryType.DefenseCannonRoundShot,
                InventoryType.DefenseCannonEmpty
        ]:
            showQuantity = False

        if not Freebooter.getPaidStatus(
                base.localAvatar.doId
        ) and slotId >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS:
            showLock = True

        SkillButton.SkillButton.__init__(self, skillId, callback, quantity,
                                         skillRank, showQuantity, showHelp,
                                         showRing, hotkey, name, showIcon,
                                         showLock, rechargeSkillId, assocAmmo)
        self.toggleFrame['image_scale'] = 0.55000000000000004
        self.toolTipBox = None
        self.slotId = slotId
        self._initButtons()
        self.updateSkillId(skillId)
Ejemplo n.º 16
0
    def requestInteraction(self, avId, interactType=0):
        if self.buildingUid == LocationIds.KINGSHEAD_OUTER_DOOR and not Freebooter.getPaidStatus(
                localAvatar.getDoId()):
            localAvatar.guiMgr.showNonPayer(quest='Restricted_Location',
                                            focus=0)
            return
        print 'requestinteraction', 0
        if avId == localAvatar.doId:
            self.fadeOut()
            return
        if self.questNeeded:
            questHistory = localAvatar.getQuestLadderHistory()
            currentQuests = localAvatar.getQuests()
            container = QuestLadderDB.getContainer(self.questNeeded)
            canEnter = False
            for quest in currentQuests:
                if container.getQuestId() == quest.getQuestId(
                ) or container.hasQuest(quest.getQuestId()):
                    canEnter = True

            if not canEnter:
                if self.buildingUid == LocationIds.UNDEAD_POKER_SHACK:
                    localAvatar.guiMgr.createWarning(
                        PLocalizer.ClubheartsQuestWarning,
                        PiratesGuiGlobals.TextFG6)
                return
        print 'requestinteraction', 2
        DistributedInteractive.DistributedInteractive.requestInteraction(
            self, avId, interactType)
Ejemplo n.º 17
0
    def selectNext(self):
        if len(self.items) < 1:
            return None

        self.show()
        if len(self.items) > 1:
            keepTrying = True
        else:
            keepTrying = False
        while keepTrying:
            keepTrying = False
            self.choice = self.choice + 1
            if self.choice > len(self.items) - 1:
                self.choice = 0

            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                category = WeaponGlobals.getRepId(self.items[self.choice][0])
                if not Freebooter.allowedFreebooterWeapon(category):
                    keepTrying = True

            Freebooter.allowedFreebooterWeapon(category)
        self.cursor.setPos(
            self.ICON_WIDTH * self.choice + 0.080000000000000002, 0,
            0.071999999999999995)
        taskMgr.remove('BarSelectHideTask' + str(self.getParent()))
        self.hideTask = taskMgr.doMethodLater(self.SelectionDelay,
                                              self.confirmSelection,
                                              'BarSelectHideTask' +
                                              str(self.getParent()),
                                              extraArgs=[])
Ejemplo n.º 18
0
 def __init__(self, callback, skillId, skillRank):
     if not AmmoPanelButton.SkillIcons:
         AmmoPanelButton.SkillIcons = loader.loadModel(
             'models/textureCards/skillIcons')
         AmmoPanelButton.Image = (
             AmmoPanelButton.SkillIcons.find('**/base'),
             AmmoPanelButton.SkillIcons.find('**/base_down'),
             AmmoPanelButton.SkillIcons.find('**/base_over'))
     self.locked = True
     self.purchaseable = True
     self.cost = CannonDefenseGlobals.getDefenseCannonAmmoCost(skillId)
     self.amount = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
     if self.amount == -1:
         self.amount = PLocalizer.Unlimited
     self.skillId = skillId
     self.skillRank = skillRank
     self.infoBox = None
     self.flashIval = None
     asset = RadialMenu.getSkillIconName(skillId, 0)
     geom = AmmoPanelButton.SkillIcons.find('**/%s' % asset)
     self.geom = geom
     if self.locked:
         asset = None
         geom = None
     DirectButton.__init__(self,
                           relief=None,
                           pos=(0, 0, 0),
                           text='?',
                           text_scale=0.1,
                           text_fg=PiratesGuiGlobals.TextFG2,
                           text_shadow=PiratesGuiGlobals.TextShadow,
                           text_pos=(0.005, -0.035),
                           text_align=TextNode.ACenter,
                           image=AmmoPanelButton.Image,
                           image_scale=0.12,
                           geom=geom,
                           geom_scale=0.12,
                           command=callback,
                           textMayChange=1,
                           sortOrder=70,
                           extraArgs=[skillId])
     self.initialiseoptions(AmmoPanelButton)
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.lockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
     if not Freebooter.getPaidStatus(
             base.localAvatar.doId
     ) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
         self.lock = DirectFrame(parent=self,
                                 relief=None,
                                 image=self.lockIcon,
                                 image_scale=0.14,
                                 image_pos=(0.05, 0, -0.025),
                                 sortOrder=99)
     self.bind(DGG.ENTER, self.showDetails)
     self.bind(DGG.EXIT, self.hideDetails)
     return
Ejemplo n.º 19
0
 def enableStatsOV(self, shipOV):
     self.snapShot = ShipSnapshot(self, shipOV, self['siegeTeam'], pos = self['snapShotPos'])
     typeStr = ''
     if self['siegeTeam']:
         hp = shipOV.maxHp
         sp = shipOV.maxSp
     else:
         hp = shipOV.Hp
         sp = shipOV.Sp
     if hp <= 0:
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.DeployShip
         stateStr = '\x01Ired\x01%s\x02' % PLocalizer.ShipSunk
         self['shipColorScale'] = VBase4(1, 0.40000000000000002, 0.40000000000000002, 1)
         self.button['image3_color'] = VBase4(*PiratesGuiGlobals.ButtonColor3[2])
         self.button['geom3_color'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 0.40000000000000002)
         self.button['text3_color'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 0.40000000000000002)
         self.button['helpText'] = PLocalizer.ShipSunk
     elif len(shipOV.crew) >= shipOV.maxCrew:
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.BoardShip
         self.button['helpText'] = PLocalizer.ShipFull
         stateStr = '\x01red\x01%s\x02' % (PLocalizer.ShipFull,)
         self['shipColorScale'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1)
     elif localAvatar.getActiveShipId() and shipOV.doId != localAvatar.getActiveShipId():
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.DeployShip
         self.button['helpText'] = PLocalizer.OtherShipOut
         stateStr = '\x01Ired\x01%s\x02' % PLocalizer.OtherShipOut
         self['shipColorScale'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1)
     elif shipOV.state in 'Off':
         self.button['state'] = DGG.NORMAL
         self.button['text'] = PLocalizer.DeployShip
         stateStr = PLocalizer.ShipInBottle
         self.button['helpText'] = PLocalizer.ShipInBottle
     else:
         self.button['state'] = DGG.NORMAL
         self.button['text'] = PLocalizer.BoardShip
         stateStr = PLocalizer.ShipAtSea
         self.button['helpText'] = PLocalizer.ShipAtSea
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
         self.button['command'] = base.localAvatar.guiMgr.showNonPayer
         self.button['extraArgs'] = [
             'Restricted_ShipFrame_Deploy',
             3]
         self.button['text'] = PLocalizer.Locked
         subgui = loader.loadModel('models/gui/toplevel_gui')
         if subgui:
             self.button['geom'] = subgui.find('**/pir_t_gui_gen_key_subscriber')
             self.button['geom_scale'] = 0.14999999999999999
             self.button['geom_color'] = Vec4(0.69999999999999996, 0.69999999999999996, 0.69999999999999996, 1.0)
             subgui.removeNode()
         
     
     if typeStr:
         self.typeLabel['text'] = '\x01smallCaps\x01(%s)\x02' % typeStr
Ejemplo n.º 20
0
 def updateAmountText(self):
     if self.cell and self.cell.container and self.cell.container.containerType == CONTAINER_PLUNDER and base.cr.newsManager and (
             base.cr.newsManager.getHoliday(
                 HolidayGlobals.DOUBLEGOLDHOLIDAYPAID)
             and Freebooter.getPaidStatus(base.localAvatar.getDoId())
             or base.cr.newsManager.getHoliday(
                 HolidayGlobals.DOUBLEGOLDHOLIDAY)):
         self['text'] = str(self.amount / 2) + '+' + str(self.amount / 2)
     else:
         InventoryUIStackItem.InventoryUIStackItem.updateAmountText(self)
    def __makeButtons(self, guiParent, tree):
        i = 0
        for node, indent in self.__graphWalker(tree):
            if not node.questId:
                continue
            if node.hideButton:
                continue
            isContainer = isinstance(node.questDNA,
                                     QuestLadderDNA.QuestContainerDNA)
            text = self.__getText(indent, node.questId, isContainer)
            text_scale = PiratesGuiGlobals.TextScaleLarge
            frameSize = (0, 0.92, 0, 0.042)
            text_pos = (0.06, 0.01)
            textFg = PiratesGuiGlobals.TextFG1
            if indent == 0:
                text_pos = (0.01, 0.01)
            button = DirectButton(parent=guiParent,
                                  relief=None,
                                  frameSize=frameSize,
                                  borderWidth=(0.005, 0.005),
                                  text=text,
                                  text_fg=textFg,
                                  text_scale=text_scale,
                                  text_align=TextNode.ALeft,
                                  text_shadow=PiratesGuiGlobals.TextShadow,
                                  text_pos=text_pos,
                                  command=self.select,
                                  extraArgs=[node.questId])
            questDNA = QuestDB.QuestDict.get(node.questId)
            if questDNA:
                if questDNA.getVelvetRoped():
                    if not Freebooter.getPaidStatus(
                            base.localAvatar.getDoId()):
                        subCard = loader.loadModel('models/gui/toplevel_gui')
                        appendMe = DirectFrame(
                            parent=button,
                            relief=None,
                            pos=(self.width - 0.98, 0, -0.03),
                            state=DGG.DISABLED,
                            geom=subCard.find(
                                '**/pir_t_gui_gen_key_subscriber'),
                            geom_scale=0.1,
                            geom_pos=(0.06, 0, 0.06))
                        subCard.removeNode()
            button.accept('press-wheel_up-%s' % button.guiId,
                          self.mouseWheelUp)
            button.accept('press-wheel_down-%s' % button.guiId,
                          self.mouseWheelDown)
            button.indent = indent
            button.questId = node.questId
            self.updateButton(button)
            self.buttons.append(button)
            i += 1

        return
Ejemplo n.º 22
0
    def addAmmoSkill(self, skillId):
        index = -1
        for i in range(len(PiratesGlobals.CANNON_DEFENSE_SKILLS)):
            if PiratesGlobals.CANNON_DEFENSE_SKILLS[i] == InventoryType.DefenseCannonEmpty:
                index = i
                break

        if index < 0 or not Freebooter.getPaidStatus(base.localAvatar.doId) and index >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS:
            return False
        PiratesGlobals.CANNON_DEFENSE_SKILLS.remove(InventoryType.DefenseCannonEmpty)
        PiratesGlobals.CANNON_DEFENSE_SKILLS.insert(index, skillId)
        self.ammoQuantities[skillId] = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
        return True
Ejemplo n.º 23
0
 def checkFreebooter(self, itemId, avId):
     if ItemGlobals.getRarity(itemId) == ItemGlobals.CRUDE:
         return None
     
     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:
             return None
         
     if itemId in [
         InventoryType.RegularLure]:
         return None
     
     if not Freebooter.getPaidStatus(avId):
         self.highlightRed(PLocalizer.FreebooterDisallow)
 def loadWeaponButtons(self):
     for hotkey in self.hotkeys:
         hotkey.destroy()
     
     self.hotkeys = []
     for icon in self.icons:
         icon.destroy()
     
     self.icons = []
     for repMeter in self.repMeters:
         repMeter.destroy()
     
     self.repMeters = []
     self['frameSize'] = (0, self.ICON_WIDTH * len(self.items) + 0.040000000000000001, 0, self.HEIGHT)
     self.setX(-((self.ICON_WIDTH * len(self.items) + 0.040000000000000001) / 2.0))
     topGui = loader.loadModel('models/gui/toplevel_gui')
     kbButton = topGui.find('**/keyboard_button')
     for i in range(len(self.items)):
         if self.items[i]:
             category = WeaponGlobals.getRepId(self.items[i][0])
             icon = DirectFrame(parent = self, state = DGG.DISABLED, relief = None, frameSize = (0, 0.080000000000000002, 0, 0.080000000000000002), pos = (self.ICON_WIDTH * i + 0.080000000000000002, 0, 0.082000000000000003))
             icon.setTransparency(1)
             hotkeyText = 'F%s' % self.items[i][1]
             hotkey = DirectFrame(parent = icon, state = DGG.DISABLED, relief = None, text = hotkeyText, text_align = TextNode.ACenter, text_scale = 0.044999999999999998, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, image = kbButton, image_scale = 0.059999999999999998, image_pos = (0, 0, 0.01), image_color = (0.5, 0.5, 0.34999999999999998, 1), pos = (0, 0, 0.080000000000000002))
             self.hotkeys.append(hotkey)
             category = WeaponGlobals.getRepId(self.items[i][0])
             if Freebooter.getPaidStatus(base.localAvatar.getDoId()) or Freebooter.allowedFreebooterWeapon(category):
                 asset = ItemGlobals.getIcon(self.items[i][0])
                 if asset:
                     texCard = self.card.find('**/%s' % asset)
                     icon['geom'] = texCard
                     icon['geom_scale'] = 0.080000000000000002
                 
                 icon.resetFrameSize()
                 self.icons.append(icon)
             else:
                 texCard = topGui.find('**/pir_t_gui_gen_key_subscriber*')
                 icon['geom'] = texCard
                 icon['geom_scale'] = 0.20000000000000001
                 icon.resetFrameSize()
                 self.icons.append(icon)
             repMeter = DirectWaitBar(parent = icon, relief = DGG.SUNKEN, state = DGG.DISABLED, borderWidth = (0.002, 0.002), range = 0, value = 0, frameColor = (0.23999999999999999, 0.23999999999999999, 0.20999999999999999, 1), barColor = (0.80000000000000004, 0.80000000000000004, 0.69999999999999996, 1), pos = (-0.050000000000000003, 0, -0.052499999999999998), hpr = (0, 0, 0), frameSize = (0.0050000000000000001, 0.095000000000000001, 0, 0.012500000000000001))
             self.repMeters.append(repMeter)
             inv = base.localAvatar.getInventory()
             if inv:
                 repValue = inv.getReputation(category)
                 (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(category, repValue)
                 max = ReputationGlobals.getReputationNeededToLevel(category, level)
                 repMeter['range'] = max
                 repMeter['value'] = leftoverValue
 def __init__(self, skillId, slotId, callback, quantity = 0, skillRank = 0, showQuantity = False, showHelp = False, showRing = False, hotkey = None, name = '', showIcon = True, showLock = False, rechargeSkillId = False, assocAmmo = []):
     if skillId in [
         InventoryType.DefenseCannonRoundShot,
         InventoryType.DefenseCannonEmpty]:
         showQuantity = False
     
     if not Freebooter.getPaidStatus(base.localAvatar.doId) and slotId >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS:
         showLock = True
     
     SkillButton.SkillButton.__init__(self, skillId, callback, quantity, skillRank, showQuantity, showHelp, showRing, hotkey, name, showIcon, showLock, rechargeSkillId, assocAmmo)
     self.toggleFrame['image_scale'] = 0.55000000000000004
     self.toolTipBox = None
     self.slotId = slotId
     self._initButtons()
     self.updateSkillId(skillId)
 def addAmmoSkill(self, skillId):
     index = -1
     for i in range(len(PiratesGlobals.CANNON_DEFENSE_SKILLS)):
         if PiratesGlobals.CANNON_DEFENSE_SKILLS[i] == InventoryType.DefenseCannonEmpty:
             index = i
             break
             continue
     
     if (index < 0 or not Freebooter.getPaidStatus(base.localAvatar.doId)) and index >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS:
         return False
     
     PiratesGlobals.CANNON_DEFENSE_SKILLS.remove(InventoryType.DefenseCannonEmpty)
     PiratesGlobals.CANNON_DEFENSE_SKILLS.insert(index, skillId)
     self.ammoQuantities[skillId] = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
     return True
    def changeAmmo(self, amt=1):
        if amt == 0:
            return None

        keepChanging = True
        ammoSkillId = self.getAmmoSkillId()
        while keepChanging:
            ammoSkillId += amt
            if ammoSkillId > InventoryType.CannonGrappleHook:
                ammoSkillId = InventoryType.CannonRoundShot

            if ammoSkillId < InventoryType.begin_WeaponSkillCannon + 1:
                ammoSkillId = InventoryType.CannonGrappleHook

            inv = base.localAvatar.getInventory()
            if ammoSkillId > InventoryType.CannonBullet:
                keepChanging = False

            if inv and inv.getStackQuantity(ammoSkillId) >= 2:
                keepChanging = False

            if WeaponGlobals.isInfiniteAmmo(
                    ammoSkillId) or WeaponGlobals.canUseInfiniteAmmo(
                        localAvatar.getCurrentCharm(), ammoSkillId):
                keepChanging = False

            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(ammoSkillId):
                    keepChanging = True

            WeaponGlobals.canFreeUse(ammoSkillId)
        self.setAmmoSkillId(ammoSkillId)
        del ammoSkillId
        if WeaponGlobals.isInfiniteAmmo(
                self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(
                    localAvatar.getCurrentCharm(), self.getAmmoSkillId()):
            self.cgui.setAmmoLeft(-1, -1)
        elif inv:
            ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(
                self.getAmmoSkillId())
            self.numShots = inv.getStackQuantity(ammoInvId)
            maxShots = inv.getStackLimit(ammoInvId)
            self.cgui.setAmmoLeft(self.numShots, maxShots)

        self.cgui.setAmmoId(self.getAmmoSkillId())
        self.updateCannonDressing()
        self.hideCannonDressing()
        self.setVolley(0)
 def updateProfile(self):
     imageName = self.ShipIconTable.get(self.purchaseInventory[0][0])
     myTexCard = self.card.find('**/' + imageName + '*')
     myTex = myTexCard.findAllTextures()[0]
     self.purchaseTitle['text'] = PLocalizer.InventoryTypeNames[self.purchaseInventory[0][0]]
     self.descText['text'] = (PLocalizer.ShipDescriptions[self.purchaseInventory[0][0]],)
     self.shipImage['image'] = myTex
     self.shipImage['image_scale'] = 0.25
     self.updateStats()
     self.shipStats.refreshBars(self.statData)
     self.updateBalance()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if self.purchaseInventory[0][0] != ItemId.INTERCEPTOR_L1 and self.purchaseInventory[0][0] != ItemId.MERCHANT_L1:
             self.lock.show()
         else:
             self.lock.hide()
Ejemplo n.º 29
0
    def displayHolidayStatus(self):
        anyMessages = False
        paidStatus = Freebooter.getPaidStatus(localAvatar.getDoId())
        for holidayId in self.holidayIdList:
            h, m = self.getTimeRemaining(holidayId)
            message = HolidayGlobals.getHolidayStatusMsg(holidayId, paidStatus)
            if message:
                anyMessages = True
                try:
                    base.talkAssistant.receiveGameMessage(message % (h, m))
                except TypeError:
                    base.talkAssistant.receiveGameMessage(message)

        if not anyMessages:
            base.talkAssistant.receiveGameMessage(PLocalizer.NO_CURRENT_HOLIDAYS)
            return
Ejemplo n.º 30
0
 def addOwnShip(self, shipId, callback):
     shipOV = base.cr.getOwnerView(shipId)
     if (not shipOV or self._siegeTeam) and localAvatar.getSiegeTeam() and localAvatar.getSiegeTeam() != self._siegeTeam:
         return None
     
     shipFrame = self.getFrame(shipId)
     if not shipFrame:
         mastInfo = ShipGlobals.getMastSetup(shipOV.shipClass)
         shipFrame = ShipFrameDeploy(parent = None, shipId = shipId, shipName = shipOV.name, shipClass = shipOV.shipClass, mastInfo = mastInfo, shipType = ShipFrameDeploy.STOwn, siegeTeam = self._siegeTeam, command = callback, extraArgs = [
             shipId])
         shipFrame.enableStatsOV(shipOV)
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
             shipFrame.nameLabel['text'] = PLocalizer.noFreebooterCap
             shipFrame.nameLabel['text_fg'] = (1, 0.69999999999999996, 0.69999999999999996, 1)
         
     
     self.addFrameOwn(shipFrame)
Ejemplo n.º 31
0
    def handleCommitPurchase(self):
        if self.purchaseInventory == [] and self.sellInventory == []:
            base.localAvatar.guiMgr.createWarning(
                PLocalizer.EmptyPurchaseWarning, PiratesGuiGlobals.TextFG6)
            return None

        if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
            if self.purchaseInventory[0][
                    0] != ItemId.INTERCEPTOR_L1 and self.purchaseInventory[0][
                        0] != ItemId.MERCHANT_L1:
                base.localAvatar.guiMgr.showNonPayer('Purchase_Restriction', 3)
                return None

        inventory = base.localAvatar.getInventory()
        if inventory:
            if inventory.getGoldInPocket() < self.balance:
                base.localAvatar.guiMgr.createWarning(
                    PLocalizer.NotEnoughMoneyWarning,
                    PiratesGuiGlobals.TextFG6)
                return None

            if self.balance < 0 and inventory.getGoldInPocket(
            ) + self.balance > InventoryGlobals.GOLD_CAP:
                base.localAvatar.guiMgr.createWarning(
                    PLocalizer.CannotHoldGoldWarning,
                    PiratesGuiGlobals.TextFG6)
                return None

            if len(inventory.getShipDoIdList()) >= inventory.getCategoryLimit(
                    InventoryCategory.SHIPS):
                base.localAvatar.guiMgr.createWarning(
                    PLocalizer.CannotHoldShipWarning,
                    PiratesGuiGlobals.TextFG6)
                return None

        nameData = [
            PLocalizer.PirateShipPrefix.keys(),
            PLocalizer.PirateShipSuffix.keys()
        ]
        self.namePanel = NamePanelGui.NamePanelGui(PLocalizer.NamePanelTitle,
                                                   nameData)
        self.namePanel.setPos(0.20000000000000001, 0, 0)
        self.lockStore()
        self.acceptOnce('returnStore', self.unlockStore)
        self.acceptOnce('nameChosen', self.handleCommitPurchasePart2)
 def changeAmmo(self, amt = 1):
     if amt == 0:
         return None
     
     keepChanging = True
     ammoSkillId = self.getAmmoSkillId()
     while keepChanging:
         ammoSkillId += amt
         if ammoSkillId > InventoryType.CannonGrappleHook:
             ammoSkillId = InventoryType.CannonRoundShot
         
         if ammoSkillId < InventoryType.begin_WeaponSkillCannon + 1:
             ammoSkillId = InventoryType.CannonGrappleHook
         
         inv = base.localAvatar.getInventory()
         if ammoSkillId > InventoryType.CannonBullet:
             keepChanging = False
         
         if inv and inv.getStackQuantity(ammoSkillId) >= 2:
             keepChanging = False
         
         if WeaponGlobals.isInfiniteAmmo(ammoSkillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), ammoSkillId):
             keepChanging = False
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(ammoSkillId):
                 keepChanging = True
             
         WeaponGlobals.canFreeUse(ammoSkillId)
     self.setAmmoSkillId(ammoSkillId)
     del ammoSkillId
     if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()):
         self.cgui.setAmmoLeft(-1, -1)
     elif inv:
         ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId())
         self.numShots = inv.getStackQuantity(ammoInvId)
         maxShots = inv.getStackLimit(ammoInvId)
         self.cgui.setAmmoLeft(self.numShots, maxShots)
     
     self.cgui.setAmmoId(self.getAmmoSkillId())
     self.updateCannonDressing()
     self.hideCannonDressing()
     self.setVolley(0)
Ejemplo n.º 33
0
 def updateProfile(self):
     imageName = self.ShipIconTable.get(self.purchaseInventory[0][0])
     myTexCard = self.card.find('**/' + imageName + '*')
     myTex = myTexCard.findAllTextures()[0]
     self.purchaseTitle['text'] = PLocalizer.InventoryTypeNames[
         self.purchaseInventory[0][0]]
     self.descText['text'] = (
         PLocalizer.ShipDescriptions[self.purchaseInventory[0][0]], )
     self.shipImage['image'] = myTex
     self.shipImage['image_scale'] = 0.25
     self.updateStats()
     self.shipStats.refreshBars(self.statData)
     self.updateBalance()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if self.purchaseInventory[0][
                 0] != ItemId.INTERCEPTOR_L1 and self.purchaseInventory[0][
                     0] != ItemId.MERCHANT_L1:
             self.lock.show()
         else:
             self.lock.hide()
    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
Ejemplo n.º 35
0
 def canLocalUseItem(self, itemTuple):
     canUse = 1
     reason = ItemConstants.REASON_NONE
     itemCat = itemTuple[0]
     itemId = itemTuple[1]
     rarity = ItemGlobals.getRarity(itemId)
     if rarity != ItemConstants.CRUDE and not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         canUse = 0
         reason = ItemConstants.REASON_VELVETROPE
         return (canUse, reason)
     elif itemCat == InventoryType.ItemTypeClothing:
         gender = localAvatar.style.getGender()
         if gender == 'm' and ItemGlobals.getMaleModelId(itemId) == -1:
             canUse = 0
             reason = ItemConstants.REASON_GENDER
             return (canUse, reason)
         elif gender == 'f' and ItemGlobals.getFemaleModelId(itemId) == -1:
             canUse = 0
             reason = ItemConstants.REASON_GENDER
             return (canUse, reason)
         
     elif itemCat in [
         InventoryType.ItemTypeWeapon,
         InventoryType.ItemTypeCharm]:
         inv = localAvatar.getInventory()
         if not inv:
             canUse = 0
             reason = ItemConstants.REASON_INVENTORY
             return (canUse, reason)
         
         reqs = localAvatar.getInventory().getItemRequirements(itemId)
         if reqs == None or filter(lambda x: reqs[x][1] == False, reqs):
             canUse = 0
             reason = ItemConstants.REASON_LEVEL
             return (canUse, reason)
         
     
     return (canUse, reason)
Ejemplo n.º 36
0
 def _QuestTitleList__makeButtons(self, guiParent, tree):
     i = 0
     for (node, indent) in self._QuestTitleList__graphWalker(tree):
         if not node.questId:
             continue
         
         if node.hideButton:
             continue
         
         isContainer = isinstance(node.questDNA, QuestLadderDNA.QuestContainerDNA)
         text = self._QuestTitleList__getText(indent, node.questId, isContainer)
         text_scale = PiratesGuiGlobals.TextScaleLarge
         frameSize = (0, 0.92000000000000004, 0, 0.042000000000000003)
         text_pos = (0.059999999999999998, 0.01)
         textFg = PiratesGuiGlobals.TextFG1
         if indent == 0:
             text_pos = (0.01, 0.01)
         
         button = DirectButton(parent = guiParent, relief = None, frameSize = frameSize, borderWidth = (0.0050000000000000001, 0.0050000000000000001), text = text, text_fg = textFg, text_scale = text_scale, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, text_pos = text_pos, command = self.select, extraArgs = [
             node.questId])
         questDNA = QuestDB.QuestDict.get(node.questId)
         if questDNA:
             if questDNA.getVelvetRoped():
                 if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                     subCard = loader.loadModel('models/gui/toplevel_gui')
                     appendMe = DirectFrame(parent = button, relief = None, pos = (self.width - 0.97999999999999998, 0, -0.029999999999999999), state = DGG.DISABLED, geom = subCard.find('**/pir_t_gui_gen_key_subscriber'), geom_scale = 0.10000000000000001, geom_pos = (0.059999999999999998, 0, 0.059999999999999998))
                     subCard.removeNode()
                 
             
         
         button.accept('press-wheel_up-%s' % button.guiId, self.mouseWheelUp)
         button.accept('press-wheel_down-%s' % button.guiId, self.mouseWheelDown)
         button.indent = indent
         button.questId = node.questId
         self.updateButton(button)
         self.buttons.append(button)
         i += 1
 def determineButtonState(self):
     self.guildName = None
     self.guildReal = None
     self.guildRank = None
     self.guildId = base.localAvatar.guildId
     if not self.setupFlag:
         self.setupButtons()
     
     if self.guildId:
         self.guildName = base.localAvatar.getGuildName()
         self.guildReal = self.guildName
         self.guildRank = base.localAvatar.getGuildRank()
         if self.guildName == '0' or self.guildName == '':
             self.guildName = PLocalizer.GuildDefaultName % self.guildId
         
         if hasattr(base, 'localAvatar'):
             inv = base.localAvatar.getInventory()
             if inv and not inv.getStackQuantity(InventoryType.NewGuild):
                 base.localAvatar.sendRequestContext(InventoryType.NewGuild)
             
         
     
     if self.nameLabel and self.guildName and self.guildName != PLocalizer.GuildNoGuild:
         if self.guildName != '0' or self.guildName != '':
             self.nameLabel.show()
             self.nameLabel['text'] = self.guildName
         elif self.nameLabel:
             self.nameLabel.hide()
         
     rank = base.localAvatar.getGuildRank()
     if rank == 1:
         ranktxt = PLocalizer.GuildRankMember
     elif rank == 2:
         ranktxt = PLocalizer.GuildRankSubLead
     elif rank == 3:
         ranktxt = PLocalizer.GuildRankLeader
     elif rank == 4:
         ranktxt = PLocalizer.GuildRankInviter
     else:
         ranktxt = None
     if self.rankLabel and rank and ranktxt:
         self.rankLabel['text'] = ranktxt
         self.rankLabel.show()
     elif self.rankLabel:
         ranktxt = PLocalizer.Loading
         self.rankLabel.hide()
     
     if self.memberButton:
         self.memberButton['state'] = DGG.DISABLED
     
     self.renameButton['state'] = DGG.DISABLED
     self.createButton['state'] = DGG.DISABLED
     self.leaveButton['state'] = DGG.DISABLED
     self.inviteButton['state'] = DGG.DISABLED
     self.redeemInvite['state'] = DGG.NORMAL
     self.codeInviteOptions['state'] = DGG.DISABLED
     if self.guildRank > 2:
         if (self.guildReal == '0' or self.guildReal == '') and not (self.recentlySentName):
             self.renameButton['state'] = DGG.NORMAL
             self.redeemInvite['state'] = DGG.DISABLED
         
     if self.guildRank > 1:
         self.inviteButton['state'] = DGG.NORMAL
         self.redeemInvite['state'] = DGG.DISABLED
         self.codeInviteOptions['state'] = DGG.NORMAL
     
     if self.guildRank > 0:
         self.leaveButton['state'] = DGG.NORMAL
         self.memberButton['state'] = DGG.NORMAL
         self.redeemInvite['state'] = DGG.DISABLED
     else:
         self.createButton['state'] = DGG.NORMAL
     if Freebooter.FreeGuildRestrict:
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if self.createButton:
                 self.createButton['state'] = DGG.DISABLED
             
             if self.renameButton:
                 self.renameButton['state'] = DGG.DISABLED
Ejemplo n.º 38
0
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     inv = localAvatar.getInventory()
     if not inv:
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
     border = self.SkillIcons.find('**/base')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x001slant\x001%s %s\x002' % (rarityText, subtypeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     subtHeight = 0.050000000000000003
     subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
     runningVertPosition -= subtHeight
     runningSize += subtHeight
     labels.append(subtitleLabel)
     itemType = ItemGlobals.getType(itemId)
     itemSubtype = ItemGlobals.getSubtype(itemId)
     model = ItemGlobals.getModel(itemId)
     if model:
         self.realItem = loader.loadModel('models/inventory/' + model)
         if self.realItem:
             posHpr = ItemGlobals.getModelPosHpr(model)
             if posHpr:
                 self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                 self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
             elif itemSubtype == ItemGlobals.RAM:
                 self.realItem.setPos(-1.5, 1.5, -0.59999999999999998)
                 self.realItem.setHpr(70, 160, -90)
             else:
                 self.realItem.setPos(0.0, 1.5, -0.059999999999999998)
                 self.realItem.setHpr(0, 90, 0)
             self.realItem.reparentTo(self.portraitSceneGraph)
         
     
     iHeight = 0.17999999999999999
     self.createBuffer()
     self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
     runningVertPosition -= iHeight
     runningSize += iHeight
     labels.append(self.itemCard)
     itemCost = int(ItemGlobals.getGoldCost(itemId))
     if self.cell and self.cell.container:
         itemCost = int(itemCost * self.cell.container.getItemPriceMult())
     
     goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(itemCost), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale))
     labels.append(goldLabel)
     specialAttack = ItemGlobals.getSpecialAttack(itemId)
     if specialAttack:
         attackIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(specialAttack))
         specialAttackNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.10000000000000001, geom = attackIcon, geom_scale = 0.10000000000000001, image_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), geom_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), text = PLocalizer.getInventoryTypeName(specialAttack), text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         specialAttackRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % ItemGlobals.getSpecialAttackRank(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         specialAttackType = WeaponGlobals.getSkillTrack(specialAttack)
         if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX:
             specialAttackTypeText = PLocalizer.BreakAttackSkill
         elif specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX:
             specialAttackTypeText = PLocalizer.DefenseSkill
         else:
             specialAttackTypeText = PLocalizer.WeaponSkill
         specialAttackTypeLabel = DirectLabel(parent = self, relief = None, text = specialAttackTypeText, text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - PiratesGuiGlobals.TextScaleLarge), text_pos = (0.0, -textScale))
         specialAttackInfo = PLocalizer.SkillDescriptions.get(specialAttack)
         specialAttackDescriptionText = specialAttackInfo[1]
         specialAttackDescriptionLabel = DirectLabel(parent = self, relief = None, text = specialAttackDescriptionText, text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() - 0.059999999999999998), text_pos = (0.0, -textScale))
         saHeight = specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() + specialAttackDescriptionLabel.getHeight() - 0.040000000000000001
         runningVertPosition -= saHeight
         runningSize += saHeight
         labels.append(specialAttackNameLabel)
         labels.append(specialAttackRankLabel)
         labels.append(specialAttackTypeLabel)
         labels.append(specialAttackDescriptionLabel)
     
     attributes = ItemGlobals.getAttributes(itemId)
     for i in range(0, len(attributes)):
         attributeIcon = self.SkillIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0]))
         if not attributeIcon:
             attributeIcon = self.BuffIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0]))
         
         attributeNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = attributeIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.getItemAttributeName(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         attributeRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % attributes[i][1], text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         if attributeNameLabel.getHeight() > 0.074999999999999997:
             attributeNameSpace = 0.080000000000000002
         else:
             attributeNameSpace = PiratesGuiGlobals.TextScaleLarge
         attributeDescriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemAttributeDescription(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - attributeNameSpace), text_pos = (0.0, -textScale))
         aHeight = attributeNameLabel.getHeight() + attributeDescriptionLabel.getHeight()
         runningVertPosition -= aHeight + splitHeight
         runningSize += aHeight + splitHeight
         labels.append(attributeNameLabel)
         labels.append(attributeRankLabel)
         labels.append(attributeDescriptionLabel)
     
     skillBoosts = ItemGlobals.getSkillBoosts(itemId)
     for i in range(0, len(skillBoosts)):
         boostIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(skillBoosts[i][0]))
         boostNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = boostIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.ItemBoost % PLocalizer.getInventoryTypeName(skillBoosts[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         boostRankLabel = DirectLabel(parent = self, relief = None, text = '+%s' % str(skillBoosts[i][1]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         bHeight = boostNameLabel.getHeight()
         runningVertPosition -= bHeight + splitHeight
         runningSize += bHeight + splitHeight
         labels.append(boostNameLabel)
         labels.append(boostRankLabel)
     
     description = PLocalizer.getItemFlavorText(itemId)
     if description != '':
         descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         dHeight = descriptionLabel.getHeight() + 0.02
         runningVertPosition -= dHeight
         runningSize += dHeight
         labels.append(descriptionLabel)
     
     weaponLevel = 0
     weaponRepId = WeaponGlobals.getRepId(itemId)
     weaponRep = inv.getReputation(weaponRepId)
     weaponReq = ItemGlobals.getWeaponRequirement(itemId)
     weaponText = None
     if weaponReq:
         weaponLevel = ReputationGlobals.getLevelFromTotalReputation(weaponRepId, weaponRep)[0]
         if weaponLevel < weaponReq:
             weaponColor = PiratesGuiGlobals.TextFG6
         else:
             weaponColor = (0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
         weaponText = PLocalizer.ItemLevelRequirement % (weaponReq, PLocalizer.getItemTypeName(itemType))
     else:
         trainingToken = EconomyGlobals.getItemTrainingReq(itemId)
         trainingAmt = inv.getItemQuantity(trainingToken)
         if trainingAmt == 0:
             weaponColor = PiratesGuiGlobals.TextFG6
             weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName(itemType)
         
     if weaponText:
         weaponReqLabel = DirectLabel(parent = self, relief = None, text = weaponText, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = weaponColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         wHeight = weaponReqLabel.getHeight()
         runningVertPosition -= wHeight
         runningSize += wHeight
         labels.append(weaponReqLabel)
     
     if not Freebooter.getPaidStatus(localAvatar.getDoId()):
         if rarity != ItemGlobals.CRUDE:
             unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
             uHeight = unlimitedLabel.getHeight()
             runningVertPosition -= uHeight
             runningSize += uHeight
             labels.append(unlimitedLabel)
         
     
     runningVertPosition -= 0.02
     runningSize += 0.02
     panels = self.helpFrame.attachNewNode('panels')
     topPanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/top_panel').copyTo(topPanel)
     topPanel.setScale(0.080000000000000002)
     topPanel.reparentTo(self.helpFrame)
     middlePanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/middle_panel').copyTo(middlePanel)
     middlePanel.setScale(0.080000000000000002)
     middlePanel.reparentTo(self.helpFrame)
     placement = 0
     i = 0
     heightMax = -0.080000000000000002
     currentHeight = runningVertPosition
     while currentHeight < heightMax:
         middlePanel = panels.attachNewNode('middlePanel%s' % 1)
         detailGui.find('**/middle_panel').copyTo(middlePanel)
         middlePanel.setScale(0.080000000000000002)
         middlePanel.reparentTo(self.helpFrame)
         if currentHeight + 0.20000000000000001 >= heightMax:
             difference = heightMax - currentHeight
             placement += (0.16800000000000001 / 0.20000000000000001) * difference
             currentHeight += difference
         else:
             placement += 0.16800000000000001
             currentHeight += 0.20000000000000001
         middlePanel.setZ(-placement)
         i += 1
     bottomPanel = panels.attachNewNode('bottomPanel')
     detailGui.find('**/bottom_panel').copyTo(bottomPanel)
     bottomPanel.setScale(0.080000000000000002)
     bottomPanel.setZ(-placement)
     bottomPanel.reparentTo(self.helpFrame)
     colorPanel = panels.attachNewNode('colorPanel')
     detailGui.find('**/color').copyTo(colorPanel)
     colorPanel.setScale(0.080000000000000002)
     colorPanel.setColor(titleColor)
     colorPanel.reparentTo(self.helpFrame)
     lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
     detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
     lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007)
     lineBreakTopPanel.setZ(0.0080000000000000002)
     lineBreakTopPanel.reparentTo(self.helpFrame)
     panels.flattenStrong()
     self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin)
     totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
     for label in labels:
         label.reparentTo(self.helpFrame)
     
     if basePosX > 0.0:
         newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
     else:
         newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
     if basePosZ > 0.0:
         newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
     else:
         newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
     if detailsPos:
         (newPosX, newPosZ) = detailsPos
     
     self.helpFrame.setPos(newPosX, 0, newPosZ)
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
     border = self.SkillIcons.find('**/base')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x01slant\x01%s %s\x02' % (rarityText, subtypeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     subtHeight = 0.050000000000000003
     subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
     runningVertPosition -= subtHeight
     runningSize += subtHeight
     labels.append(subtitleLabel)
     itemType = ItemGlobals.getType(itemId)
     itemSubtype = ItemGlobals.getSubtype(itemId)
     model = ItemGlobals.getModel(itemId)
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     if itemSubtype == ItemGlobals.POTION_BUFF:
         self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId)), pos = (0.0, 2.5, 0.0))
     elif model:
         self.realItem = loader.loadModel('models/inventory/' + model, okMissing = True)
         if not self.realItem:
             self.realItem = loader.loadModel('models/handheld/' + model)
         
         if self.realItem:
             posHpr = ItemGlobals.getModelPosHpr(model)
             if posHpr:
                 self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                 self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
             else:
                 self.realItem.setPos(0.0, 2.5, -0.40000000000000002)
                 self.realItem.setHpr(45, 0, 0)
             self.realItem.reparentTo(self.portraitSceneGraph)
         
     
     iHeight = 0.17999999999999999
     self.createBuffer()
     self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
     runningVertPosition -= iHeight
     runningSize += iHeight
     labels.append(self.itemCard)
     itemCost = int(ItemGlobals.getGoldCost(itemId))
     if self.cell and self.cell.container:
         itemCost = int(itemCost * self.cell.container.getItemPriceMult())
     
     goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(itemCost), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale))
     labels.append(goldLabel)
     if ItemGlobals.getSubtype(itemId) == 30:
         duration = PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId)))
         if duration >= 3600:
             duration = duration / 3600
             if duration == 1:
                 units = PLocalizer.Hour
             else:
                 units = PLocalizer.Hours
         elif duration >= 60:
             duration = duration / 60
             if duration == 1:
                 units = PLocalizer.Minute
             else:
                 units = PLocalizer.Minutes
         else:
             units = PLocalizer.Seconds
         potency = PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId)))
         data = {
             'pot': int(potency * 100),
             'dur': int(duration),
             'unit': units }
         description = PLocalizer.PotionDescs[ItemGlobals.getUseSkill(itemId)].safe_substitute(data)
     else:
         description = PLocalizer.getItemFlavorText(itemId)
     if description != '':
         descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
         dHeight = descriptionLabel.getHeight() + 0.02
         runningVertPosition -= dHeight
         runningSize += dHeight
         labels.append(descriptionLabel)
     
     if not Freebooter.getPaidStatus(localAvatar.getDoId()):
         if rarity != ItemGlobals.CRUDE:
             unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
             uHeight = unlimitedLabel.getHeight()
             runningVertPosition -= uHeight
             runningSize += uHeight
             labels.append(unlimitedLabel)
         
     
     runningVertPosition -= 0.02
     runningSize += 0.02
     useLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.RightClickPotion, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     uHeight = useLabel.getHeight()
     runningVertPosition -= uHeight
     runningSize += uHeight
     labels.append(useLabel)
     runningVertPosition -= 0.02
     runningSize += 0.02
     panels = self.helpFrame.attachNewNode('panels')
     topPanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/top_panel').copyTo(topPanel)
     topPanel.setScale(0.080000000000000002)
     topPanel.reparentTo(self.helpFrame)
     middlePanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/middle_panel').copyTo(middlePanel)
     middlePanel.setScale(0.080000000000000002)
     middlePanel.reparentTo(self.helpFrame)
     placement = 0
     i = 0
     heightMax = -0.080000000000000002
     currentHeight = runningVertPosition
     if detailsHeight:
         currentHeight = -detailsHeight
     
     while currentHeight < heightMax:
         middlePanel = panels.attachNewNode('middlePanel%s' % 1)
         detailGui.find('**/middle_panel').copyTo(middlePanel)
         middlePanel.setScale(0.080000000000000002)
         middlePanel.reparentTo(self.helpFrame)
         if currentHeight + 0.20000000000000001 >= heightMax:
             difference = heightMax - currentHeight
             placement += (0.16800000000000001 / 0.20000000000000001) * difference
             currentHeight += difference
         else:
             placement += 0.16800000000000001
             currentHeight += 0.20000000000000001
         middlePanel.setZ(-placement)
         i += 1
     bottomPanel = panels.attachNewNode('bottomPanel')
     detailGui.find('**/bottom_panel').copyTo(bottomPanel)
     bottomPanel.setScale(0.080000000000000002)
     bottomPanel.setZ(-placement)
     bottomPanel.reparentTo(self.helpFrame)
     colorPanel = panels.attachNewNode('colorPanel')
     detailGui.find('**/color').copyTo(colorPanel)
     colorPanel.setScale(0.080000000000000002)
     colorPanel.setColor(titleColor)
     colorPanel.reparentTo(self.helpFrame)
     lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
     detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
     lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007)
     lineBreakTopPanel.setZ(0.0080000000000000002)
     lineBreakTopPanel.reparentTo(self.helpFrame)
     panels.flattenStrong()
     self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin)
     totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
     for label in labels:
         label.reparentTo(self.helpFrame)
     
     if basePosX > 0.0:
         newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
     else:
         newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
     if basePosZ > 0.0:
         newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
     else:
         newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
     if detailsPos:
         (newPosX, newPosZ) = detailsPos
     
     self.helpFrame.setPos(newPosX, 0, newPosZ)
Ejemplo n.º 40
0
 def hasQuestOffers(self):
     AvailableQuests = []
     inventory = localAvatar.getInventory()
     prereqExcludes = base.config.GetString('exclude-prereq-quests', '')
     for (questId, questDNA) in QuestDB.QuestDict.items():
         if len(prereqExcludes):
             if questId in prereqExcludes:
                 continue
             
         
         prereqs = questDNA.getPrereqs()
         passed = True
         for prereq in prereqs:
             if not prereq.giverCanGive(self.getUniqueId()):
                 passed = False
                 break
             
             if not prereq.avIsReady(localAvatar):
                 passed = False
                 break
             
             if questDNA.minLevel > localAvatar.level:
                 passed = False
                 break
             
             if not base.cr.questDependency.checkDependency(questId, localAvatar.getQuestLadderHistory(), 1):
                 passed = False
                 break
             
             boolWeapLvlCheck = (questDNA.weapLvlType != None) & (questDNA.minWeapLevel > 0)
             if boolWeapLvlCheck & (questDNA.minWeapLevel > getLevelFromTotalReputation(questDNA.weapLvlType, inventory.getReputation(questDNA.weapLvlType))[0]):
                 passed = False
                 break
             
             if questDNA.getVelvetRoped() and not Freebooter.getPaidStatus(localAvatar.getDoId()):
                 passed = False
                 break
             
             if questDNA.getAcquireOnce():
                 history = localAvatar.getQuestLadderHistory()
                 questLadderId = base.cr.questDynMap.findQuestLadderInt(questId)
                 containsLadderId = history.count(questLadderId)
                 if containsLadderId:
                     passed = False
                     break
                 
             
             if questDNA.getHoliday() is not None:
                 holidayId = questDNA.getHoliday()
                 if base.cr.newsManager and not base.cr.newsManager.getHoliday(holidayId):
                     passed = False
                     break
                 
             not base.cr.newsManager.getHoliday(holidayId)
         
         if prereqs and passed:
             AvailableQuests.append(questDNA)
             continue
     
     if len(AvailableQuests):
         inventory = localAvatar.getInventory()
         if inventory:
             toRemove = []
             questList = inventory.getQuestList()
             for questDNA in AvailableQuests:
                 questId = questDNA.getQuestId()
                 found = False
                 for quest in questList:
                     if questId == quest.getQuestId() or localAvatar.questStatus.hasLadderQuestId(questId):
                         found = True
                         continue
                 
                 if found:
                     toRemove.append(questDNA)
                     continue
             
             for questDNA in toRemove:
                 AvailableQuests.remove(questDNA)
             
         
     
     for quest in localAvatar.getQuests():
         if quest and quest.getTimeLimit() and quest.canBeReturnedTo(self.getQuestGiverId()):
             return True
             continue
     
     return len(AvailableQuests) > 0
Ejemplo n.º 41
0
    def update(self, repId=None, fromUser=0):
        inv = localAvatar.getInventory()
        if not inv:
            self.notify.warning('SkillPage unable to find inventory')
            return
        if self.tabBar == None:
            return
        if self.demo:
            return
        if fromUser:
            self.lastUserSelectedTab = repId
        if repId == None:
            if localAvatar.getGameState() == 'Fishing':
                if self.lastUserSelectedTab:
                    repId = self.lastUserSelectedTab
                else:
                    repId = InventoryType.CannonRep
            elif localAvatar.cannon:
                repId = InventoryType.CannonRep
            elif localAvatar.gameFSM.state == 'ShipPilot':
                repId = InventoryType.SailingRep
            elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
                repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
            elif localAvatar.currentWeaponId and not localAvatar.isWeaponDrawn and self.lastUserSelectedTab:
                repId = self.lastUserSelectedTab
            else:
                repId = InventoryType.CannonRep
        self.setRep(repId)
        self.tabBar.selectTab(str(repId))
        self.repMeter.setCategory(repId)
        self.repMeter.update(inv.getReputation(repId))
        unSpentId = self.getUnspent()
        amt = inv.getStackQuantity(unSpentId)
        if unSpentId in self.localMods:
            amt = self.localMods[unSpentId]
        self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
        if amt > 0:
            self.unspent['text_fg'] = (0.8, 1, 0.8, 1)
        else:
            self.unspent['text_fg'] = (1, 1, 1, 1)
        comboSkills = RadialMenu.ComboSkills(repId, 1)
        totalComboSkills = RadialMenu.ComboSkills(repId, 0)
        activeSkills = RadialMenu.ActiveSkills(repId, 1)
        totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
        passiveSkills = RadialMenu.PassiveSkills(repId, 1)
        totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
        self.linkedSkillIds = {}
        linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
        if linkedSkills:
            for skillId in linkedSkills:
                realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
                self.linkedSkillIds[realSkillId] = skillId

        for excludedSkillId in self.EXCLUDED_SKILLS:
            for skillId in activeSkills:
                if excludedSkillId == skillId:
                    activeSkills.remove(skillId)
                    totalActiveSkills.remove(skillId)

        for spot in self.skillFrames.keys():
            if spot not in totalComboSkills:
                self.skillFrames[spot].hide()

        count = 0
        for skill in totalComboSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in comboSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 1.11
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        count = 0
        for skill in totalActiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            xMod, yMod = self.ringOffset(count)
            xMod *= 0.9
            yMod *= 0.9
            showIcon = skill in activeSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = xMod + 0.53
            y = yMod + 0.615
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            ammo = self.getAmmo(skill)
            if ammo != None and showIcon:
                self.skillFrames[skill].showQuantity = True
                self.skillFrames[skill].updateQuantity(ammo)
            count += 1

        count = 0
        for skill in totalPassiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in passiveSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 0.15
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        self.dataChanged = False
        return
Ejemplo n.º 42
0
 def addPoint(self, skillId):
     if skillId == InventoryType.SailPowerRecharge:
         return None
     
     inv = localAvatar.getInventory()
     frameSkillId = skillId
     skillId = WeaponGlobals.getLinkedSkillId(frameSkillId)
     if not skillId:
         skillId = frameSkillId
     
     if self.currentRep == InventoryType.CutlassRep and localAvatar.style.tutorial < PiratesGlobals.TUT_GOT_CUTLASS:
         if inv.getStackQuantity(InventoryType.CutlassSweep) < 2:
             if skillId != InventoryType.CutlassSweep:
                 return None
             
         elif skillId == InventoryType.CutlassSweep:
             messenger.send('skillImprovementAttempted')
         
     
     unSpentId = self.getUnspent()
     unSp = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         unSp = self.localMods[unSpentId]
     
     if unSp < 1:
         return None
     
     if inv.getStackLimit(skillId):
         curAmt = inv.getStackQuantity(skillId)
         if skillId in self.localMods:
             curAmt = self.localMods[skillId]
         
         if curAmt > 5:
             return None
         else:
             curAmt += 1
     else:
         return None
     self._SkillPage__handleFreeDialog()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if curAmt > Freebooter.FreeSkillCap:
             self.spentDialog = PDialog.PDialog(text = PLocalizer.FreebooterSkillMax, style = OTPDialog.CancelOnly, command = self._SkillPage__handleFreeDialog)
             return None
         
         playerExp = inv.getAccumulator(self.currentRep)
         (categoryLevel, extra) = ReputationGlobals.getLevelFromTotalReputation(self.currentRep, playerExp)
         alreadySpent = categoryLevel - 1 - unSp
         if alreadySpent > 5:
             self.spentDialog = PDialog.PDialog(text = PLocalizer.FreebooterSkillLock, style = OTPDialog.CancelOnly, command = self._SkillPage__handleFreeDialog)
             return None
         
     
     if not base.config.GetBool('want-combo-skips', 0):
         comboSkills = [
             InventoryType.CutlassSlash,
             InventoryType.CutlassCleave,
             InventoryType.CutlassFlourish,
             InventoryType.CutlassStab,
             InventoryType.DaggerSwipe,
             InventoryType.DaggerGouge,
             InventoryType.DaggerEviscerate]
         if skillId in comboSkills and inv.getStackQuantity(skillId - 1) <= 1:
             base.localAvatar.guiMgr.createWarning(PLocalizer.ComboOrderWarn, PiratesGuiGlobals.TextFG6)
             return None
         
     
     messenger.send('skillImprovementAttempted')
     localAvatar.spendSkillPoint(skillId)
     self.localMods[skillId] = curAmt
     self.localMods[unSpentId] = unSp - 1
     self.skillFrames[frameSkillId].skillRank = curAmt - 1
 def getCargoResults(self):
     (missionTime, shipDamage, skeletonKills, navyKills, creatureKills, seamonsterKills, pirateKills, townfolkKills, shipKills, repairCost, exp, gold, cargo, numCrew) = self.stats
     (pMissionTime, pShipDamage, pSkeletonKills, pNavyKills, pCreatureKills, pSeamonsterKills, pPirateKills, pTownfolkKills, pShipKills, pRepairCost, pExp, pGold, pCargo, pLootBoxes, dummyCrew) = self.playerStats
     inventory = base.localAvatar.getInventory()
     if inventory:
         currentGold = inventory.getGoldInPocket()
     
     avId = base.localAvatar.getDoId()
     cargoValue = EconomyGlobals.getCargoTotalValue(pCargo)
     totalGold = cargoValue + pGold
     bonusGold = 0
     if base.localAvatar.ship:
         if base.localAvatar.ship.getOwnerId() == avId and len(base.localAvatar.ship.getCrew()) > 1:
             bonusGold = int(totalGold * EconomyGlobals.CAPTAIN_LOOT_MULTIPLIER)
             totalGold += bonusGold
         
     
     if base.cr.newsManager:
         if base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAYPAID) or Freebooter.getPaidStatus(avId) or base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAY):
             totalGold *= 2
         
     netGold = totalGold - pRepairCost
     self.results = []
     self.results.append({
         'Type': 'Title',
         'Text': PLocalizer.CargoPlunder,
         'Value1': '' })
     if pGold:
         self.results.append({
             'Type': 'Entry',
             'Text': PLocalizer.GoldLooted,
             'Value1': pGold,
             'Value2': gold })
     
     if len(pCargo) == 0:
         self.results.append({
             'Type': 'Entry',
             'Text': PLocalizer.NoCargoLooted,
             'Value1': '',
             'UnwrapMode': 1 })
     else:
         for itemId in pCargo:
             self.results.append({
                 'Type': 'Cargo',
                 'Text': '',
                 'Value1': itemId,
                 'UnwrapMode': 1 })
         
     if bonusGold > 0:
         self.results.append({
             'Type': 'Space',
             'Text': '',
             'Value1': '',
             'UnwrapMode': 1 })
         self.results.append({
             'Type': 'Entry',
             'Text': PLocalizer.CaptainsBonus,
             'Value1': str(bonusGold) + ' ' + PLocalizer.MoneyName,
             'UnwrapMode': 1 })
     
     if base.cr.newsManager:
         if base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAYPAID) or Freebooter.getPaidStatus(avId) or base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAY):
             self.results.append({
                 'Type': 'Space',
                 'Text': '',
                 'Value1': '',
                 'UnwrapMode': 1 })
             self.results.append({
                 'Type': 'Entry',
                 'Text': PLocalizer.DoubleGoldBonus,
                 'Value1': str(totalGold / 2) + ' ' + PLocalizer.MoneyName,
                 'UnwrapMode': 1 })
         
     self.results.append({
         'Type': 'Space',
         'Text': '',
         'Value1': '',
         'UnwrapMode': 1 })
     self.results.append({
         'Type': 'Title',
         'Text': PLocalizer.PlunderShare,
         'Value1': str(netGold) + ' ' + PLocalizer.MoneyName,
         'UnwrapMode': 1 })
     return self.results
Ejemplo n.º 44
0
    def getCargoResults(self):
        missionTime, shipDamage, skeletonKills, navyKills, creatureKills, seamonsterKills, pirateKills, townfolkKills, shipKills, repairCost, exp, gold, cargo, numCrew = self.stats
        pMissionTime, pShipDamage, pSkeletonKills, pNavyKills, pCreatureKills, pSeamonsterKills, pPirateKills, pTownfolkKills, pShipKills, pRepairCost, pExp, pGold, pCargo, pLootBoxes, dummyCrew = self.playerStats
        inventory = base.localAvatar.getInventory()
        if inventory:
            currentGold = inventory.getGoldInPocket()
        avId = base.localAvatar.getDoId()
        cargoValue = EconomyGlobals.getCargoTotalValue(pCargo)
        totalGold = cargoValue + pGold
        bonusGold = 0
        if base.localAvatar.ship:
            if base.localAvatar.ship.getOwnerId() == avId:
                if len(base.localAvatar.ship.getCrew()) > 1:
                    bonusGold = int(totalGold *
                                    EconomyGlobals.CAPTAIN_LOOT_MULTIPLIER)
                    totalGold += bonusGold
            if base.cr.newsManager and (base.cr.newsManager.getHoliday(
                    HolidayGlobals.DOUBLEGOLDHOLIDAYPAID)
                                        and Freebooter.getPaidStatus(avId)
                                        or base.cr.newsManager.getHoliday(
                                            HolidayGlobals.DOUBLEGOLDHOLIDAY)):
                totalGold *= 2
            netGold = totalGold - pRepairCost
            self.results = []
            self.results.append({
                'Type': 'Title',
                'Text': PLocalizer.CargoPlunder,
                'Value1': ''
            })
            if pGold:
                self.results.append({
                    'Type': 'Entry',
                    'Text': PLocalizer.GoldLooted,
                    'Value1': pGold,
                    'Value2': gold
                })
            len(pCargo) == 0 and self.results.append({
                'Type': 'Entry',
                'Text': PLocalizer.NoCargoLooted,
                'Value1': '',
                'UnwrapMode': 1
            })
        else:
            cargoDict = {}
            for itemId in pCargo:
                cargoCount = cargoDict.get(itemId, None)
                if cargoCount == None:
                    cargoDict[itemId] = 0
                cargoDict[itemId] += 1

            for cargoKey in cargoDict:
                amount = cargoDict[cargoKey]
                self.results.append({
                    'Type': 'Cargo',
                    'Text': '',
                    'Value1': cargoKey,
                    'UnwrapMode': 1,
                    'Amount': amount
                })

            if bonusGold > 0:
                self.results.append({
                    'Type': 'Space',
                    'Text': '',
                    'Value1': '',
                    'UnwrapMode': 1
                })
                self.results.append({
                    'Type':
                    'Entry',
                    'Text':
                    PLocalizer.CaptainsBonus,
                    'Value1':
                    str(bonusGold) + ' ' + PLocalizer.MoneyName,
                    'UnwrapMode':
                    1
                })
        if base.cr.newsManager and (base.cr.newsManager.getHoliday(
                HolidayGlobals.DOUBLEGOLDHOLIDAYPAID)
                                    and Freebooter.getPaidStatus(avId)
                                    or base.cr.newsManager.getHoliday(
                                        HolidayGlobals.DOUBLEGOLDHOLIDAY)):
            self.results.append({
                'Type': 'Space',
                'Text': '',
                'Value1': '',
                'UnwrapMode': 1
            })
            self.results.append({
                'Type':
                'Entry',
                'Text':
                PLocalizer.DoubleGoldBonus,
                'Value1':
                str(totalGold / 2) + ' ' + PLocalizer.MoneyName,
                'UnwrapMode':
                1
            })
        self.results.append({
            'Type': 'Space',
            'Text': '',
            'Value1': '',
            'UnwrapMode': 1
        })
        self.results.append({
            'Type': 'Title',
            'Text': PLocalizer.PlunderShare,
            'Value1': str(netGold) + ' ' + PLocalizer.MoneyName,
            'UnwrapMode': 1
        })
        return self.results
def getAllSkills(repId, skilltrack, wantWeaponSkill = 0):
    inv = base.localAvatar.getInventory()
    if inv == None:
        print 'WARNING - getAllSkills came up with no inventory for ', repId
        return []
    
    minlvl = 2
    choices = []
    if repId == InventoryType.CutlassRep:
        skillId = InventoryType.begin_WeaponSkillCutlass
        while skillId < InventoryType.end_WeaponSkillCutlass:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.MeleeRep:
        skillId = InventoryType.begin_WeaponSkillMelee
        while skillId < InventoryType.end_WeaponSkillMelee:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.DaggerRep:
        skillId = InventoryType.begin_WeaponSkillDagger
        while skillId < InventoryType.end_WeaponSkillDagger:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.GrenadeRep:
        skillId = InventoryType.begin_WeaponSkillGrenade
        while skillId < InventoryType.end_WeaponSkillGrenade:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.DollRep:
        skillId = InventoryType.begin_WeaponSkillDoll
        while skillId < InventoryType.end_WeaponSkillDoll:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.WandRep:
        skillId = InventoryType.begin_WeaponSkillWand
        while skillId < InventoryType.end_WeaponSkillWand:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.KettleRep:
        skillId = InventoryType.begin_WeaponSkillKettle
        while skillId < InventoryType.end_WeaponSkillKettle:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.PistolRep:
        skillId = InventoryType.begin_WeaponSkillPistol
        while skillId < InventoryType.end_WeaponSkillPistol:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.CannonRep:
        wantWeaponSkill = 0
        skillId = InventoryType.begin_WeaponSkillCannon
        while skillId < InventoryType.end_WeaponSkillCannon:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.SailingRep:
        skillId = InventoryType.begin_SkillSailing
        while skillId < InventoryType.end_SkillSailing:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                shouldBeVisible = inv.getStackQuantity(skillId) >= minlvl
                skill = (skillId, shouldBeVisible, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.DefenseCannonRep:
        wantWeaponSkill = 0
        for skillId in PiratesGlobals.CANNON_DEFENSE_SKILLS:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                skill = (skillId, True, False)
                choices.append(skill)
            
            skillId += 1
        
    elif repId == InventoryType.FishingRep:
        wantWeaponSkill = 0
        skillId = InventoryType.begin_WeaponSkillFishingRod
        skilltrack = 1
        while skillId < InventoryType.end_WeaponSkillFishingRod:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    
    if wantWeaponSkill:
        weaponSkill = getWeaponSkill(repId)
        if weaponSkill:
            choices.append((weaponSkill, True, 0))
        
    
    return choices
    def hasQuestOffers(self):
        AvailableQuests = []
        inventory = localAvatar.getInventory()
        prereqExcludes = base.config.GetString('exclude-prereq-quests', '')
        for (questId, questDNA) in QuestDB.QuestDict.items():
            if len(prereqExcludes):
                if questId in prereqExcludes:
                    continue


            prereqs = questDNA.getPrereqs()
            passed = True
            for prereq in prereqs:
                if not prereq.giverCanGive(self.getUniqueId()):
                    passed = False
                    break

                if not prereq.avIsReady(localAvatar):
                    passed = False
                    break

                if questDNA.minLevel > localAvatar.level:
                    passed = False
                    break

                if not base.cr.questDependency.checkDependency(questId, localAvatar.getQuestLadderHistory(), 1):
                    passed = False
                    break

                boolWeapLvlCheck = (questDNA.weapLvlType != None) & (questDNA.minWeapLevel > 0)
                if boolWeapLvlCheck & (questDNA.minWeapLevel > getLevelFromTotalReputation(questDNA.weapLvlType, inventory.getReputation(questDNA.weapLvlType))[0]):
                    passed = False
                    break

                if questDNA.getVelvetRoped() and not Freebooter.getPaidStatus(localAvatar.getDoId()):
                    passed = False
                    break

                if questDNA.getAcquireOnce():
                    history = localAvatar.getQuestLadderHistory()
                    questLadderId = base.cr.questDynMap.findQuestLadderInt(questId)
                    containsLadderId = history.count(questLadderId)
                    if containsLadderId:
                        passed = False
                        break


                if questDNA.getHoliday() is not None:
                    holidayId = questDNA.getHoliday()
                    if base.cr.newsManager and not base.cr.newsManager.getHoliday(holidayId):
                        passed = False
                        break

                not base.cr.newsManager.getHoliday(holidayId)

            if prereqs and passed:
                AvailableQuests.append(questDNA)
                continue

        if len(AvailableQuests):
            inventory = localAvatar.getInventory()
            if inventory:
                toRemove = []
                questList = inventory.getQuestList()
                for questDNA in AvailableQuests:
                    questId = questDNA.getQuestId()
                    found = False
                    for quest in questList:
                        if questId == quest.getQuestId() or localAvatar.questStatus.hasLadderQuestId(questId):
                            found = True
                            continue

                    if found:
                        toRemove.append(questDNA)
                        continue

                for questDNA in toRemove:
                    AvailableQuests.remove(questDNA)



        for quest in localAvatar.getQuests():
            if quest and quest.getTimeLimit() and quest.canBeReturnedTo(self.getQuestGiverId()):
                return True
                continue

        return len(AvailableQuests) > 0
Ejemplo n.º 47
0
    def showLoot(self,
                 plunder=[],
                 gold=0,
                 collect=0,
                 card=0,
                 cloth=0,
                 color=0,
                 jewel=None,
                 tattoo=None,
                 weapon=None,
                 bounty=0):
        for loot in self.loot:
            loot.destroy()
            del loot

        self.loot = []
        gender = localAvatar.style.getGender()
        self.show()
        self.setAlphaScale(1.0)
        treasure = []
        for itemId in self.icons.iterkeys():
            count = 0
            for item in plunder:
                if item == itemId:
                    count += 1
                    continue

            if count > 0:
                treasure.append([itemId, count])
                continue

        plunder = treasure
        if gold:
            plunder.append([ItemId.GOLD, gold])
            LootPopupPanel.lootSfx.play()

        if bounty:
            plunder.append([ItemId.BOUNTY, bounty])
            LootPopupPanel.lootSfx.play()

        if collect:
            plunder.append([ItemId.COLLECT, collect])
            LootPopupPanel.lootSfx.play()

        if card:
            plunder.append([ItemId.CARD, card])
            LootPopupPanel.lootSfx.play()

        if cloth:
            plunder.append([ItemId.CLOTHING, (cloth, color)])
            LootPopupPanel.lootSfx.play()

        if jewel is not None:
            plunder.append([ItemId.QUEST_DROP_JEWEL, jewel])
            LootPopupPanel.lootSfx.play()

        if tattoo is not None:
            plunder.append([ItemId.QUEST_DROP_TATTOO, tattoo])
            LootPopupPanel.lootSfx.play()

        if weapon is not None:
            plunder.append([ItemId.QUEST_DROP_WEAPON, weapon])
            LootPopupPanel.lootSfx.play()

        for item in plunder:
            (itemType, quantity) = item
            if itemType == ItemId.COLLECT:
                itemId = quantity
                howRare = CollectionMap.Collection_Rarity.get(itemId, 0)
                rarityText = PLocalizer.CollectionRarities.get(howRare)
                value = CollectionValues.get(howRare, 0)
                itemName = PLocalizer.Collections[itemId]
                howManyDoIHave = localAvatar.getInventory().getStackQuantity(
                    itemId)
                howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1)
                if howManyDoIHave < howManyINeed:
                    textInfo = PLocalizer.CollectionPopupNewText % (
                        itemName, rarityText, value)
                else:
                    textInfo = PLocalizer.CollectionPopupDuplicateText % (
                        itemName, rarityText, value)
                pic_name = CollectionMap.Assets[itemId]
                lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name)
                iconScale = 0.34999999999999998
            elif itemType == ItemId.CLOTHING:
                (clothingId, colorId) = quantity
                if clothingId in ClothingGlobals.quest_items:
                    textInfo = PLocalizer.getItemName(clothingId)
                else:
                    textInfo = PLocalizer.TailorColorStrings.get(colorId)
                    textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName(
                        ItemGlobals.getType(clothingId))
                clothingType = ItemGlobals.getType(clothingId)
                iconScale = 0.13
                if clothingType == 0:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_hat')
                elif clothingType == 1:
                    lootIcon = loader.loadModel('models/gui/char_gui').find(
                        '**/chargui_cloth')
                    iconScale = 0.29999999999999999
                elif clothingType == 2:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_vest')
                elif clothingType == 3:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_coat')
                elif clothingType == 4:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_pants')
                elif clothingType == 5:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_belt')
                elif clothingType == 6:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_sock')
                else:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_booths')
            elif itemType == ItemId.CARD:
                textInfo = PLocalizer.InventoryTypeNames.get(quantity)
                pic_name = ''
                lootIcon = PlayingCardGlobals.getImage(
                    'standard', PlayingCardGlobals.getSuit(quantity),
                    PlayingCardGlobals.getRank(quantity))
                iconScale = 0.20000000000000001
            elif itemType == ItemId.GOLD:
                textInfo = PLocalizer.LootGold % str(quantity)
                potionPercent = PotionGlobals.getGoldBoostEffectPercent(
                    localAvatar)
                potionGold = 0
                textInfo = PLocalizer.LootGold % str(quantity)
                if base.cr.newsManager:
                    if base.cr.newsManager.getHoliday(
                            HolidayGlobals.DOUBLEGOLDHOLIDAYPAID
                    ) or Freebooter.getPaidStatus(base.localAvatar.getDoId(
                    )) or base.cr.newsManager.getHoliday(
                            HolidayGlobals.DOUBLEGOLDHOLIDAY):
                        textInfo = PLocalizer.LootGold % str(
                            quantity /
                            2) + '\n + ' + PLocalizer.LootGoldDouble % str(
                                quantity / 2)

                if potionGold > 0:
                    textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str(
                        potionGold)

                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.27000000000000002
            elif itemType == ItemId.BOUNTY:
                textInfo = PLocalizer.LootBounty % str(quantity)
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.27000000000000002
            elif itemType == ItemId.CARGO_CRATE:
                if quantity == 1:
                    textInfo = PLocalizer.CargoCrate % quantity
                else:
                    textInfo = PLocalizer.CargoCrateP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_CHEST:
                if quantity == 1:
                    textInfo = PLocalizer.CargoChest % quantity
                else:
                    textInfo = PLocalizer.CargoChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_SKCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.CargoSkChest % quantity
                else:
                    textInfo = PLocalizer.CargoSkChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_LOOTSAC:
                if quantity == 1:
                    textInfo = PLocalizer.LootSac % quantity
                else:
                    textInfo = PLocalizer.LootSacP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_LOOTCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootChest % quantity
                else:
                    textInfo = PLocalizer.LootChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_LOOTSKCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootSkChest % quantity
                else:
                    textInfo = PLocalizer.LootSkChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_SHIPUPGRADECHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootUpgradeChest % quantity
                else:
                    textInfo = PLocalizer.LootUpgradeChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_SHIPUPGRADESKCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootRareUpgradeChest % quantity
                else:
                    textInfo = PLocalizer.LootRareUpgradeChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.QUEST_DROP_JEWEL:
                textInfo = None
                type = None
                lootIcon = None
                iconScale = 1.0
                type = ItemGlobals.getType(quantity)
                textInfo = PLocalizer.getItemName(quantity)
                if type == ItemGlobals.BROW:
                    lootIcon = LootPopupPanel.JewelerIconsB.find(
                        '**/icon_shop_tailor_brow')
                    iconScale = (-0.14000000000000001, 0.14000000000000001,
                                 0.14000000000000001)
                elif type == ItemGlobals.EAR:
                    lootIcon = LootPopupPanel.JewelerIconsA.find(
                        '**/chargui_ears')
                    iconScale = (-0.34999999999999998, 0.34999999999999998,
                                 0.34999999999999998)
                elif type == ItemGlobals.NOSE:
                    lootIcon = LootPopupPanel.JewelerIconsA.find(
                        '**/chargui_nose')
                    iconScale = (0.34999999999999998, 0.34999999999999998,
                                 0.34999999999999998)
                elif type == ItemGlobals.MOUTH:
                    lootIcon = LootPopupPanel.JewelerIconsA.find(
                        '**/chargui_mouth')
                    iconScale = (0.32500000000000001, 0.32500000000000001,
                                 0.32500000000000001)
                elif type == ItemGlobals.HAND:
                    lootIcon = LootPopupPanel.JewelerIconsB.find(
                        '**/icon_shop_tailor_hand')
                    iconScale = (0.125, 0.125, 0.125)
                else:
                    lootIcon = None
            elif itemType == ItemId.QUEST_DROP_TATTOO:
                textInfo = None
                type = None
                lootIcon = None
                iconScale = 1.0
                type = ItemGlobals.getType(quantity)
                textInfo = PLocalizer.getItemName(quantity)
                if type == ItemGlobals.CHEST:
                    lootIcon = LootPopupPanel.TattooIcons.find(
                        '**/icon_shop_tailor_chest_male')
                    iconScale = 0.10000000000000001
                elif type == ItemGlobals.ARM:
                    lootIcon = LootPopupPanel.TattooIcons.find(
                        '**/icon_shop_tailor_arm')
                    iconScale = 0.10000000000000001
                elif type == ItemGlobals.FACE:
                    lootIcon = LootPopupPanel.TattooIcons.find(
                        '**/icon_shop_tailor_face_male')
                    iconScale = 0.10000000000000001
                else:
                    lootIcon = None
            elif itemType == ItemId.QUEST_DROP_WEAPON:
                weaponId = quantity
                iconScale = 0.10000000000000001
                textInfo = None
                lootIcon = None
                iconName = getItemIcons(weaponId)
                if iconName is not None:
                    lootIcon = LootPopupPanel.WeaponIcons.find('**/' +
                                                               iconName)
                    textInfo = PLocalizer.InventoryTypeNames.get(weaponId)

            entry = DirectFrame(parent=self,
                                relief=None,
                                geom=lootIcon,
                                geom_scale=iconScale,
                                text=textInfo,
                                text_scale=PiratesGuiGlobals.TextScaleSmall,
                                text_align=TextNode.ALeft,
                                text_fg=PiratesGuiGlobals.TextFG0,
                                text_pos=(0.070000000000000007, 0.01),
                                text_font=PiratesGlobals.getInterfaceFont())
            entry.setTransparency(1)
            self.loot.append(entry)

        self.repackPanels()
 def refresh(self):
     inv = localAvatar.getInventory()
     origRank = self.rank
     if inv:
         invType = TitleGlobals.getInventoryType(self.titleId)
         if self.titleId == TitleGlobals.ShipPVPTitle:
             self.expPoints = localAvatar.getInventory().getStackQuantity(InventoryType.PVPTotalInfamySea)
         elif self.titleId == TitleGlobals.LandPVPTitle:
             self.expPoints = localAvatar.getInventory().getStackQuantity(InventoryType.PVPTotalInfamyLand)
         elif invType:
             self.expPoints = inv.getStackQuantity(invType)
         else:
             self.expPoints = 0
             if self.titleId == TitleGlobals.FounderTitle and localAvatar.getFounder():
                 self.expPoints = 1
             
         self.rank = TitleGlobals.getRank(self.titleId, self.expPoints)
         self.maxRank = TitleGlobals.getMaxRank(self.titleId)
         self.expTarget = TitleGlobals.getBreakpoints(self.titleId)[min(self.rank + 1, self.maxRank)]
         self.expBase = TitleGlobals.getBreakpoints(self.titleId)[self.rank]
     
     if self.titleNameFrame:
         self.titleNameFrame['text'] = TitleGlobals.getTitleRankName(self.titleId, self.expPoints)
     
     if self.expMeter:
         value = 0
         if self.rank < self.maxRank and self.expTarget - self.expBase > 0:
             value = int((self.expPoints - self.expBase) * 100 / (self.expTarget - self.expBase))
         
         self.expMeter['value'] = value
     
     if self.expMeterText:
         if self.rank >= self.maxRank:
             self.expBase = 0
             self.expTarget = 0
         
         text = '0 / 0'
         if self.rank < self.maxRank and self.expTarget - self.expBase > 0:
             text = '%s / %s' % (self.expPoints - self.expBase, self.expTarget - self.expBase)
         
         self.expMeterText['text'] = text
     
     if self.iconFrame:
         icName = TitleGlobals.getIconName(self.titleId, self.rank)
         if icName:
             img = self.iconModel.find('**/' + icName)
         else:
             img = None
         self.iconFrame['image'] = img
         imgScale = TitleGlobals.getScale(self.titleId)
         self.iconFrame['image_scale'] = (0.065000000000000002 * imgScale, 1, 0.065000000000000002 * imgScale)
     
     titleOnOff = [
         PLocalizer.TitleOff,
         PLocalizer.TitleOn]
     if self.rank != origRank:
         if self.landActive:
             self.titlesPage.setLandActive(self.panelIndex, self.landActive)
         
         if self.seaActive:
             self.titlesPage.setSeaActive(self.panelIndex, self.seaActive)
         
     
     if self.rank == 0 or not Freebooter.getPaidStatus(localAvatar.doId):
         self.landButton.hide()
         self.seaButton.hide()
     else:
         self.landButton.show()
         self.seaButton.show()
    def refreshList(self, setKey=0):
        if setKey == 0 or setKey == None:
            return None

        if self.currentDisplay != 0:
            oldSize = CollectionMap.Collection_Set_Sizes.get(self.currentDisplay)
            for loopItr in range(oldSize):
                curNum = self.currentDisplay + loopItr + 1
                if curNum in self.setPics:
                    self.setPics[curNum].hide()

                self.setFrames[curNum].hide()

        self.currentDisplay = setKey
        self.setLabel["text"] = PLocalizer.Collections[setKey]
        inv = localAvatar.getInventory()
        if not inv:
            return None

        setCount = 0
        heightOffset = 0
        setSize = CollectionMap.Collection_Set_Sizes.get(setKey)
        gui = loader.loadModel("models/gui/toplevel_gui")
        for loopItr in range(setSize):
            setItem = setKey + 1 + loopItr
            rowSpot = loopItr % 4
            colSpot = loopItr / 4
            localHeight = PiratesGuiGlobals.InventoryPanelHeight - 0.20000000000000001
            howMany = inv.getStackQuantity(setItem)
            if setItem in CollectionMap.Collection_Set_Locked:
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    isLocked = True
                else:
                    isLocked = False
            else:
                isLocked = False
            if isLocked or howMany > 0:
                if setItem in self.setPics:
                    self.setPics[setItem].show()
                    self.setFrames[setItem].show()
                else:
                    frameImg = gui.find("**/treasure_w_b_slot_full")
                    self.setFrames[setItem] = DirectFrame(
                        parent=self,
                        relief=None,
                        image=frameImg,
                        image_scale=0.40000000000000002,
                        image_pos=(0, 0, 0),
                        pos=(
                            0.28000000000000003 + 0.17999999999999999 * rowSpot,
                            0,
                            localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                        ),
                    )
                    pic_name = CollectionMap.Assets[setItem]
                    if isLocked:
                        tex = gui.find("**/pir_t_gui_gen_key_subscriber")
                        use_scale = 0.25
                        self.setPics[setItem] = DirectButton(
                            parent=self,
                            relief=None,
                            image=tex,
                            image_scale=use_scale,
                            image_pos=(0, 0, 0),
                            pos=(
                                0.28000000000000003 + 0.17999999999999999 * rowSpot,
                                0,
                                localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                            ),
                            text=PLocalizer.Collections[setItem],
                            text_fg=PiratesGuiGlobals.TextFG2,
                            text_align=TextNode.ACenter,
                            text_wordwrap=6,
                            text_scale=0.025000000000000001,
                            text_pos=(0, -0.085000000000000006, 0),
                            command=base.localAvatar.guiMgr.showNonPayer,
                            extraArgs=["Restricted_Treasure_Selection", 7],
                        )
                    else:
                        tex = self.card.find("**/%s*" % pic_name)
                        use_scale = 0.39000000000000001
                        self.setPics[setItem] = DirectButton(
                            parent=self,
                            relief=None,
                            image=tex,
                            image_scale=use_scale,
                            image_pos=(0, 0, 0),
                            pos=(
                                0.28000000000000003 + 0.17999999999999999 * rowSpot,
                                0,
                                localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                            ),
                            command=self.clickedTreasure,
                            extraArgs=[setItem],
                            text=PLocalizer.Collections[setItem],
                            text_fg=PiratesGuiGlobals.TextFG2,
                            text_align=TextNode.ACenter,
                            text_wordwrap=6,
                            text_scale=0.025000000000000001,
                            text_pos=(0, -0.085000000000000006, 0),
                        )
                    self.setPics[setItem].setTransparency(1)
                if setItem in CollectionMap.Collection_Needed:
                    howManyINeed = CollectionMap.Collection_Needed[setItem]
                else:
                    howManyINeed = 1
                if setItem in CollectionMap.Collection_SingleNumeric:
                    if howMany > 0:
                        if howMany == 1:
                            weightTxt = "Lb"
                        else:
                            weightTxt = "Lbs"
                        if setItem in self.setHowMany:
                            self.setHowMany[setItem]["text"] = "%d %s" % (howMany, weightTxt)
                        else:
                            self.setHowMany[setItem] = DirectLabel(
                                parent=self.setPics[setItem],
                                relief=None,
                                text="%d %s" % (howMany, weightTxt),
                                text_align=TextNode.ARight,
                                text_scale=0.040000000000000001,
                                text_fg=PiratesGuiGlobals.TextFG2,
                                text_shadow=PiratesGuiGlobals.TextShadow,
                                textMayChange=1,
                                pos=(0.080000000000000002, 0, -0.050000000000000003),
                                text_font=PiratesGlobals.getInterfaceOutlineFont(),
                            )

                elif setItem in self.setHowMany:
                    if howManyINeed < 2:
                        self.setHowMany[setItem].hide()
                    else:
                        self.setHowMany[setItem]["text"] = "%d/%d" % (howMany, howManyINeed)
                        self.setHowMany[setItem].show()
                elif howMany > 1:
                    self.setHowMany[setItem] = DirectLabel(
                        parent=self.setPics[setItem],
                        relief=None,
                        text="%d/%d" % (howMany, howManyINeed),
                        text_align=TextNode.ARight,
                        text_scale=0.040000000000000001,
                        text_fg=PiratesGuiGlobals.TextFG2,
                        text_shadow=PiratesGuiGlobals.TextShadow,
                        textMayChange=1,
                        pos=(0.080000000000000002, 0, -0.050000000000000003),
                        text_font=PiratesGlobals.getInterfaceOutlineFont(),
                    )

                if isLocked:
                    if setItem in self.setHowMany:
                        self.setHowMany[setItem].hide()

            if setItem in self.setFrames:
                self.setFrames[setItem].show()
                continue
            frameImg = gui.find("**/treasure_w_b_slot_empty")
            self.setFrames[setItem] = DirectFrame(
                parent=self,
                relief=None,
                image=frameImg,
                image_scale=0.40000000000000002,
                image_pos=(0, 0, 0),
                pos=(
                    0.28000000000000003 + 0.17999999999999999 * rowSpot,
                    0,
                    localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                ),
            )

        gui.removeNode()
    def __init__(self, npc, shopId, **kw):
        optiondefs = (('relief', None, None), ('framSize', (0, self.width, 0, self.height), None), ('sortOrder', 20, None))
        self.defineoptions(kw, optiondefs)
        DirectFrame.__init__(self, None)
        self.initialiseoptions(BarberStoreGUI)
        self.pirate = None
        self.camIval = None
        self.buttons = []
        self.buttonIndex = 0
        self.itemAmount = 0
        self.currentPage = None
        self.confirmBox = None
        self.buttonsPerPage = 3
        self.displayRegionStates = { }
        self.numPages = 0
        gui = loader.loadModel('models/gui/toplevel_gui')
        self.CoinImage = gui.find('**/treasure_w_coin*')
        self.ParchmentIcon = gui.find('**/main_gui_quest_scroll')
        self.barberIconsA = loader.loadModel('models/gui/char_gui')
        self.barberIconsB = loader.loadModel('models/textureCards/shopIcons')
        self.ShirtIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
        self.LockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
        self.backTabParent = self.attachNewNode('backTabs', sort = 0)
        self.panel = GuiPanel.GuiPanel(None, self.width, self.height, parent = self, showClose = False)
        self.setPos(0.0, 0, -0.75)
        self.balance = 0
        self.npc = npc
        self.rootTitle = PLocalizer.ShopBarber
        self.paid = Freebooter.getPaidStatus(localAvatar.getDoId())
        self.shopId = shopId
        if localAvatar.gameFSM.camIval is not None:
            if localAvatar.gameFSM.camIval.isPlaying():
                localAvatar.gameFSM.camIval.finish()


        self.initialCamPos = camera.getPos()
        self.initialCamHpr = camera.getHpr()
        self.initialPirateH = 0
        self.cartWidth = self.columnWidth - 0.10000000000000001
        self.cartHeight = self.height - 0.25
        self.cartFrame = DirectFrame(parent = self.panel, relief = None, frameSize = (0, self.cartWidth, 0, self.cartHeight))
        self.cartFrame.setPos(self.columnWidth + 0.025000000000000001, 0, 0.080000000000000002)
        self.categoryText = [
            [
                PLocalizer.Hat,
                PLocalizer.Hats],
            [
                PLocalizer.Shirt,
                PLocalizer.Shirts],
            [
                PLocalizer.Vest,
                PLocalizer.Vests],
            [
                PLocalizer.Coat,
                PLocalizer.Coats],
            [
                PLocalizer.Pants,
                PLocalizer.Pants],
            [
                PLocalizer.Belt,
                PLocalizer.Belts],
            [
                None,
                None],
            [
                PLocalizer.Shoe,
                PLocalizer.Shoes]]
        self.frontTabParent = self.panel.attachNewNode('frontTab', sort = 2)
        self.myGoldTitle = DirectFrame(parent = self.cartFrame, relief = None, text = PLocalizer.YourMoney, text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, pos = (-0.375, 0, 0.17499999999999999))
        self.myGold = DirectFrame(parent = self.cartFrame, relief = None, text = str(localAvatar.getMoney()), text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, image = self.CoinImage, image_scale = 0.14999999999999999, image_pos = (0.029999999999999999, 0, 0.014999999999999999), pos = (-0.059999999999999998, 0, 0.17499999999999999))
        self.closeButton = DialogButton.DialogButton(command = self.closePanel, parent = self.cartFrame, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG2, text_pos = (0.02, -(PiratesGuiGlobals.TextScaleLarge) * 0.25), text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, buttonStyle = DialogButton.DialogButton.NO)
        self.closeButton.setPos(0, 0, 0.0050000000000000001)
        tGui = loader.loadModel('models/gui/triangle')
        triangle = (tGui.find('**/triangle'), tGui.find('**/triangle_down'), tGui.find('**/triangle_over'))
        self.nextPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = 0.065000000000000002, pos = (0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.nextPage)
        self.prevPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = -0.065000000000000002, pos = (-0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.previousPage)
        self.pageNumber = DirectFrame(parent = self.cartFrame, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.0, 0.0), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0.089999999999999997))
        self.titleLabel = DirectLabel(parent = self, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG1, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge * 1.3, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.62, 0.0, 1.3300000000000001))
        self.titleLabel.setBin('gui-fixed', 1)
        self.createPirate()
        charGui = loader.loadModel('models/gui/char_gui')
        self.rotateSlider = DirectSlider(parent = base.a2dBottomLeft, relief = None, command = self.rotatePirate, image = charGui.find('**/chargui_slider_small'), image_scale = (2.1499999999999999, 2.1499999999999999, 1.5), thumb_relief = None, thumb_image = (charGui.find('**/chargui_slider_node'), charGui.find('**/chargui_slider_node_down'), charGui.find('**/chargui_slider_node_over')), pos = (0.80000000000000004, 0.0, 0.089999999999999997), text_align = TextNode.ACenter, text_scale = (0.10000000000000001, 0.10000000000000001), text_pos = (0.0, 0.10000000000000001), text_fg = PiratesGuiGlobals.TextFG1, scale = 0.42999999999999999, text = PLocalizer.RotateSlider, value = 0.5, sortOrder = -1)
        self.rotateSlider['extraArgs'] = [
            self.rotateSlider]
        self.rotateSliderOrigin = 0.5
        self.accept('mouse1', self._startMouseReadTask)
        self.accept('mouse1-up', self._stopMouseReadTask)
        self.clothWindows = []
        self.clothRenders = []
        self.clothHumans = []
        self.clothCameraNPs = []
        self.clothCameras = []
        self.createDisplayRegions()
        self.alertDialog = None
        self.accept('aspectRatioChanged', self.aspectRatioChange)
        self.accept('NonPayerPanelShown', self.hideDisplayRegions)
        self.accept('NonPayerPanelHidden', self.showDisplayRegions)
        self.accept('MainMenuShown', self.hideDisplayRegions)
        self.accept('MainMenuHidden', self.showDisplayRegions)
        self.accept('GUIShown', self.showDisplayRegions)
        self.accept('GUIHidden', self.hideDisplayRegions)
        localAvatar.guiMgr.chatPanel.show()
        localAvatar.guiMgr.chatPanel.startFadeTextIval()
        self.model = loader.loadModel('models/gui/gui_shop_tailor')
        self.model.reparentTo(self.panel)
        self.model.setBin('gui-fixed', 0)
        self.model.setPos(0.625, 0.0, 1.05)
        self.model.setScale(0.33700000000000002, 0.0, 0.32700000000000001)
        localAvatar.guiMgr.hideTrackedQuestInfo()
        self.initTabs()
        self.updateBalance()
        self.focusCamera()
Ejemplo n.º 51
0
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     typeText = PLocalizer.getJewelryTypeName(ItemGlobals.getType(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x001slant\x001%s %s\x002' % (rarityText, typeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     subtHeight = 0.050000000000000003
     subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
     runningVertPosition -= subtHeight
     runningSize += subtHeight
     labels.append(subtitleLabel)
     gender = localAvatar.style.gender
     dna = HumanDNA.HumanDNA(gender)
     dna.copy(localAvatar.style)
     bodyShape = localAvatar.style.getBodyShape()
     bodyHeight = localAvatar.style.getBodyHeight()
     bodyOffset = 0.5
     browOffset = 0
     earOffset = 0
     noseOffset = 0
     mouthOffset = 0
     handOffset = 0
     if bodyShape == 0:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.75
             earOffset = 0.65000000000000002
             noseOffset = 0.69999999999999996
             mouthOffset = 0.75
             handOffset = 0.40000000000000002
         elif gender == 'f':
             browOffset = 0.55000000000000004
             earOffset = 0.55000000000000004
             noseOffset = 0.45000000000000001
             mouthOffset = 0.65000000000000002
             handOffset = 0.29999999999999999
         
     elif bodyShape == 1:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.20000000000000001
             earOffset = 0.20000000000000001
             noseOffset = 0.10000000000000001
             mouthOffset = 0.20000000000000001
             handOffset = 0.20000000000000001
         elif gender == 'f':
             browOffset = 0.5
             earOffset = 0.5
             noseOffset = 0.40000000000000002
             mouthOffset = 0.5
             handOffset = 0.20000000000000001
         
     elif bodyShape == 2:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = -0.10000000000000001
             earOffset = -0.10000000000000001
             noseOffset = -0.20000000000000001
             mouthOffset = -0.10000000000000001
             handOffset = -0.10000000000000001
         
     elif bodyShape == 3:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.20000000000000001
             earOffset = 0.20000000000000001
             noseOffset = 0.050000000000000003
             mouthOffset = 0.20000000000000001
             handOffset = 0.20000000000000001
         elif gender == 'f':
             browOffset = -0.40000000000000002
             earOffset = -0.40000000000000002
             noseOffset = -0.45000000000000001
             mouthOffset = -0.29999999999999999
             handOffset = -0.20000000000000001
         
     elif bodyShape == 4:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = -0.20000000000000001
             earOffset = -0.20000000000000001
             noseOffset = -0.29999999999999999
             mouthOffset = -0.14999999999999999
             handOffset = -0.050000000000000003
         elif gender == 'f':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = 0.0
             mouthOffset = 0.10000000000000001
             handOffset = 0.0
         
     elif bodyShape == 5:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = -0.050000000000000003
             earOffset = -0.10000000000000001
             noseOffset = -0.14999999999999999
             mouthOffset = -0.050000000000000003
             handOffset = -0.10000000000000001
         
     elif bodyShape == 6:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = 0.40000000000000002
             earOffset = 0.40000000000000002
             noseOffset = 0.25
             mouthOffset = 0.40000000000000002
             handOffset = 0.10000000000000001
         
     elif bodyShape == 7:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = 0.0
             earOffset = -0.050000000000000003
             noseOffset = -0.10000000000000001
             mouthOffset = 0.0
             handOffset = -0.050000000000000003
         
     elif bodyShape == 8:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = -0.10000000000000001
             earOffset = -0.10000000000000001
             noseOffset = -0.20000000000000001
             mouthOffset = -0.050000000000000003
             handOffset = -0.050000000000000003
         elif gender == 'f':
             browOffset = -0.14999999999999999
             earOffset = -0.14999999999999999
             noseOffset = -0.25
             mouthOffset = -0.14999999999999999
             handOffset = -0.10000000000000001
         
     elif bodyShape == 9:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = -0.20000000000000001
             earOffset = -0.20000000000000001
             noseOffset = -0.29999999999999999
             mouthOffset = -0.10000000000000001
             handOffset = -0.050000000000000003
         elif gender == 'f':
             browOffset = -0.34999999999999998
             earOffset = -0.34999999999999998
             noseOffset = -0.45000000000000001
             mouthOffset = -0.34999999999999998
             handOffset = -0.20000000000000001
         
     
     m = Mat4(Mat4.identMat())
     itemType = ItemGlobals.getType(itemId)
     if itemType == ItemGlobals.BROW:
         jewelType = JewelryGlobals.LBROW
     elif itemType == ItemGlobals.EAR:
         jewelType = JewelryGlobals.LEAR
     elif itemType == ItemGlobals.NOSE:
         jewelType = JewelryGlobals.NOSE
     elif itemType == ItemGlobals.MOUTH:
         jewelType = JewelryGlobals.MOUTH
     elif itemType == ItemGlobals.HAND:
         jewelType = JewelryGlobals.LHAND
     
     primaryColor = ItemGlobals.getPrimaryColor(itemId)
     secondaryColor = ItemGlobals.getSecondaryColor(itemId)
     if localAvatar.style.gender == 'm':
         maleModelId = ItemGlobals.getMaleModelId(itemId)
         if maleModelId:
             jewelId = maleModelId
             dna = HumanDNA.HumanDNA(localAvatar.style.gender)
             dna.copy(localAvatar.style)
             gender = 'm'
         else:
             jewelId = ItemGlobals.getFemaleModelId(itemId)
             dna = HumanDNA.HumanDNA('f')
             gender = 'f'
     else:
         femaleModelId = ItemGlobals.getFemaleModelId(itemId)
         if femaleModelId:
             jewelId = femaleModelId
             dna = HumanDNA.HumanDNA(localAvatar.style.gender)
             dna.copy(localAvatar.style)
             gender = 'f'
         else:
             jewelId = ItemGlobals.getMaleModelId(itemId)
             dna = HumanDNA.HumanDNA('m')
             gender = 'm'
     if jewelType == JewelryGlobals.LBROW:
         dna.setJewelryZone3(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.LEAR:
         dna.setJewelryZone1(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.NOSE:
         dna.setJewelryZone5(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.MOUTH:
         dna.setJewelryZone6(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.LHAND:
         dna.setJewelryZone7(jewelId, primaryColor, secondaryColor)
     
     dna.setClothesHat(0, 0)
     self.displayHuman.setDNAString(dna)
     self.displayHuman.generateHuman(gender, self.masterHuman)
     self.displayHuman.stopBlink()
     self.displayHuman.pose('idle', 1)
     lodNode = self.displayHuman.find('**/+LODNode').node()
     lodNode.forceSwitch(lodNode.getHighestSwitch())
     if jewelType == JewelryGlobals.LBROW:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('trs_right_eyebrow').getNetTransform(m)
         rightEyeHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetX = 0.40000000000000002
             offsetZ = -rightEyeHeight + browOffset - bodyHeight * 1.0
             offsetY = 0.25 + bodyOffset
         else:
             offsetX = 0.29999999999999999
             offsetZ = -rightEyeHeight * 0.98999999999999999 + browOffset - bodyHeight * 1.0
             offsetY = 0.14999999999999999 + bodyOffset
         offsetH = -240
     elif jewelType == JewelryGlobals.LEAR:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_trs_left_ear').getNetTransform(m)
         leftEarHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetZ = -leftEarHeight + earOffset - bodyHeight * 1.0
             offsetY = 0.40000000000000002 + bodyOffset
             offsetX = 0.14999999999999999
         else:
             offsetZ = -leftEarHeight * 0.98999999999999999 + earOffset - bodyHeight * 1.0
             offsetY = 0.29999999999999999 + bodyOffset
             offsetX = 0.040000000000000001
         offsetH = -250
     elif jewelType == JewelryGlobals.NOSE:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_trs_mid_nose_bot').getNetTransform(m)
         noseHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetZ = -noseHeight + 0.089999999999999997 + noseOffset - bodyHeight * 0.80000000000000004
             offsetY = 0.45000000000000001 + bodyOffset
         else:
             offsetZ = -noseHeight + 0.10000000000000001 + noseOffset - bodyHeight * 0.80000000000000004
             offsetY = 0.40000000000000002 + bodyOffset
         offsetX = 0.059999999999999998
         offsetH = 180
     elif jewelType == JewelryGlobals.MOUTH:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('trs_lips_top').getNetTransform(m)
         mouthHeight = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -mouthHeight + 0.02 + mouthOffset - bodyHeight * 1.1000000000000001
         offsetY = 0.59999999999999998 + bodyOffset
         offsetX = 0.080000000000000002
         offsetH = 180
     elif jewelType == JewelryGlobals.LHAND:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_left_index01').getNetTransform(m)
         leftIndexHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetZ = -leftIndexHeight + 0.050000000000000003 + handOffset - bodyHeight * 0.5
             offsetX = -0.69999999999999996
             offsetY = 1.25 + bodyOffset
         else:
             offsetZ = -leftIndexHeight + handOffset - bodyHeight * 0.5
             if bodyShape == 4:
                 offsetX = -1.0
                 offsetY = 1.75 + bodyOffset
             elif bodyShape == 3:
                 offsetX = -0.69999999999999996
                 offsetY = 1.25 + bodyOffset
             elif bodyShape == 1:
                 offsetX = -0.69999999999999996
                 offsetY = 1.25 + bodyOffset
             elif bodyShape == 0:
                 offsetX = -0.69999999999999996
                 offsetY = 1.25 + bodyOffset
             else:
                 offsetX = -0.80000000000000004
                 offsetY = 1.25 + bodyOffset
         offsetH = 160
     else:
         offsetZ = 0.0
         offsetY = 0.0
         offsetX = 0.0
         offsetH = 0
     self.displayHuman.setY(offsetY)
     self.displayHuman.setZ(offsetZ)
     self.displayHuman.setX(offsetX)
     self.displayHuman.setH(offsetH)
     self.displayHuman.reparentTo(self.portraitSceneGraph)
     iHeight = 0.17999999999999999
     self.createBuffer()
     self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
     runningVertPosition -= iHeight
     runningSize += iHeight
     labels.append(self.itemCard)
     itemCost = int(ItemGlobals.getGoldCost(itemId))
     if self.cell and self.cell.container:
         itemCost = int(itemCost * self.cell.container.getItemPriceMult())
     
     goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(itemCost), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale))
     labels.append(goldLabel)
     descriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemFlavorText(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_fg = PiratesGuiGlobals.TextFG0, text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     dHeight = descriptionLabel.getHeight() + 0.02
     runningVertPosition -= dHeight
     runningSize += dHeight
     labels.append(descriptionLabel)
     if not Freebooter.getPaidStatus(localAvatar.getDoId()):
         if rarity != ItemGlobals.CRUDE:
             unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
             uHeight = unlimitedLabel.getHeight()
             runningVertPosition -= uHeight
             runningSize += uHeight
             labels.append(unlimitedLabel)
         
     
     runningVertPosition -= 0.02
     runningSize += 0.02
     panels = self.helpFrame.attachNewNode('panels')
     topPanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/top_panel').copyTo(topPanel)
     topPanel.setScale(0.080000000000000002)
     topPanel.reparentTo(self.helpFrame)
     middlePanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/middle_panel').copyTo(middlePanel)
     middlePanel.setScale(0.080000000000000002)
     middlePanel.reparentTo(self.helpFrame)
     placement = 0
     i = 0
     heightMax = -0.080000000000000002
     currentHeight = runningVertPosition
     if detailsHeight:
         currentHeight = -detailsHeight
     
     while currentHeight < heightMax:
         middlePanel = panels.attachNewNode('middlePanel%s' % 1)
         detailGui.find('**/middle_panel').copyTo(middlePanel)
         middlePanel.setScale(0.080000000000000002)
         middlePanel.reparentTo(self.helpFrame)
         if currentHeight + 0.20000000000000001 >= heightMax:
             difference = heightMax - currentHeight
             placement += (0.16800000000000001 / 0.20000000000000001) * difference
             currentHeight += difference
         else:
             placement += 0.16800000000000001
             currentHeight += 0.20000000000000001
         middlePanel.setZ(-placement)
         i += 1
     bottomPanel = panels.attachNewNode('bottomPanel')
     detailGui.find('**/bottom_panel').copyTo(bottomPanel)
     bottomPanel.setScale(0.080000000000000002)
     bottomPanel.setZ(-placement)
     bottomPanel.reparentTo(self.helpFrame)
     colorPanel = self.helpFrame.attachNewNode('colorPanel')
     detailGui.find('**/color').copyTo(colorPanel)
     colorPanel.setScale(0.080000000000000002)
     colorPanel.setColor(titleColor)
     colorPanel.reparentTo(self.helpFrame)
     lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
     detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
     lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007)
     lineBreakTopPanel.setZ(0.0080000000000000002)
     lineBreakTopPanel.reparentTo(self.helpFrame)
     panels.flattenStrong()
     self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin)
     totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
     for label in labels:
         label.reparentTo(self.helpFrame)
     
     if basePosX > 0.0:
         newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
     else:
         newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
     if basePosZ > 0.0:
         newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
     else:
         newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
     if detailsPos:
         (newPosX, newPosZ) = detailsPos
     
     self.helpFrame.setPos(newPosX, 0, newPosZ)
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        halfWidth = 0.29999999999999999
        halfHeight = 0.20000000000000001
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ

        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.029999999999999999
        runningVertPosition = 0.29999999999999999
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        typeText = ClothingGlobals.getClothingTypeName(
            ItemGlobals.getType(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
        elif rarity == ItemGlobals.COMMON:
            titleColor = PiratesGuiGlobals.TextFG13
        elif rarity == ItemGlobals.RARE:
            titleColor = PiratesGuiGlobals.TextFG4
        elif rarity == ItemGlobals.FAMED:
            titleColor = PiratesGuiGlobals.TextFG5

        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.070000000000000007
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x001slant\x001%s %s\x002' %
                                    (rarityText, typeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.050000000000000003
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        clothingType = ItemGlobals.getType(itemId)
        if localAvatar.style.getGender() == 'm':
            maleModelId = ItemGlobals.getMaleModelId(itemId)
            if maleModelId != -1:
                modelId = maleModelId
                texId = ItemGlobals.getMaleTextureId(itemId)
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'm'
            else:
                modelId = ItemGlobals.getFemaleModelId(itemId)
                texId = ItemGlobals.getFemaleTextureId(itemId)
                dna = HumanDNA.HumanDNA('f')
                gender = 'f'
        else:
            femaleModelId = ItemGlobals.getFemaleModelId(itemId)
            if femaleModelId != -1:
                modelId = femaleModelId
                texId = ItemGlobals.getFemaleTextureId(itemId)
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'f'
            else:
                modelId = ItemGlobals.getMaleModelId(itemId)
                texId = ItemGlobals.getMaleTextureId(itemId)
                dna = HumanDNA.HumanDNA('m')
                gender = 'm'
        bodyShape = localAvatar.style.getBodyShape()
        bodyHeight = localAvatar.style.getBodyHeight()
        bodyOffset = 0.5
        headOffset = 0
        topOffset = 0
        pantOffset = 0
        beltOffset = 0
        shoeOffset = 0
        if bodyShape == 0:
            bodyOffset = 1
            headOffset = 0.69999999999999996
            topOffset = 0.69999999999999996
            pantOffset = 0.20000000000000001
            beltOffset = 0.5
        elif bodyShape == 1:
            bodyOffset = 0
            if gender == 'm':
                headOffset = -0.10000000000000001
                beltOffset = 0.10000000000000001
                shoeOffset = 0.10000000000000001
            elif gender == 'f':
                headOffset = 0.59999999999999998
                topOffset = 0.40000000000000002
                beltOffset = 0.40000000000000002
                shoeOffset = 0.10000000000000001

        elif bodyShape == 2:
            bodyOffset = 0.5
        elif bodyShape == 3:
            bodyOffset = 1
            if gender == 'm':
                topOffset = 0.10000000000000001
                beltOffset = 0.10000000000000001
            elif gender == 'f':
                headOffset = -0.40000000000000002
                topOffset = -0.10000000000000001
                beltOffset = -0.10000000000000001
                pantOffset = -0.10000000000000001

        elif bodyShape == 4:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = -0.20000000000000001
                topOffset = -0.29999999999999999
            elif gender == 'f':
                headOffset = 0.10000000000000001
                beltOffset = 0.10000000000000001

        elif bodyShape == 5:
            bodyOffset = 0.5
        elif bodyShape == 6:
            bodyOffset = 0.5
            if gender == 'f':
                headOffset = 0.40000000000000002
                topOffset = 0.40000000000000002
                beltOffset = 0.29999999999999999

        elif bodyShape == 7:
            bodyOffset = 0.5
        elif bodyShape == 8:
            bodyOffset = 0.5
            headOffset = -0.20000000000000001
            topOffset = -0.20000000000000001
        elif bodyShape == 9:
            bodyOffset = 0.5
            headOffset = -0.20000000000000001
            topOffset = -0.20000000000000001

        m = Mat4(Mat4.identMat())
        topColor = localAvatar.style.getClothesBotColor()
        botColor = localAvatar.style.getClothesTopColor()
        hatColor = localAvatar.style.getHatColor()
        (shirtIdx, shirtTex) = localAvatar.style.getClothesShirt()
        (hatIdx, hatTex) = localAvatar.style.getClothesHat()
        (coatIdx, coatTex) = localAvatar.style.getClothesCoat()
        (beltIdx, beltTex) = localAvatar.style.getClothesBelt()
        (shoeIdx, shoeTex) = localAvatar.style.getClothesShoe()
        (vestIdx, vestTex) = localAvatar.style.getClothesVest()
        (pantIdx, pantTex) = localAvatar.style.getClothesPant()
        dna.setClothesBotColor(topColor[0], topColor[1], topColor[2])
        dna.setClothesTopColor(botColor[0], botColor[1], botColor[2])
        dna.setHatColor(hatColor)
        dna.setClothesShirt(shirtIdx, shirtTex)
        dna.setClothesHat(hatIdx, hatTex)
        dna.setClothesBelt(beltIdx, beltTex)
        dna.setClothesPant(pantIdx, pantTex)
        dna.setClothesShoe(shoeIdx, shoeTex)
        if clothingType == ClothingGlobals.SHIRT:
            dna.setClothesVest(0)
            dna.setClothesCoat(0)
        elif clothingType == ClothingGlobals.VEST:
            dna.setClothesCoat(0)
        elif clothingType == ClothingGlobals.BELT:
            dna.setClothesCoat(0)
            dna.setClothesVest(0)
        else:
            dna.setClothesVest(vestIdx, vestTex)
            dna.setClothesCoat(coatIdx, coatTex)
        dna.setClothesByType(ClothingGlobals.CLOTHING_STRING[clothingType],
                             modelId, texId, self.itemTuple[3])
        self.displayHuman.setDNAString(dna)
        self.displayHuman.generateHuman(gender, self.masterHuman)
        self.displayHuman.stopBlink()
        self.displayHuman.pose('idle', 1)
        lodNode = self.displayHuman.find('**/+LODNode').node()
        lodNode.forceSwitch(lodNode.getHighestSwitch())
        if clothingType == ClothingGlobals.HAT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_head01').getNetTransform(m)
            headHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = (-headHeight -
                       0.40000000000000002) + headOffset - bodyHeight * 1.0
            offsetY = 2.0 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.SHIRT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine03').getNetTransform(m)
            spine3Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine3Height + topOffset - bodyHeight * 1.3999999999999999
            offsetY = 3.25 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.VEST:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine03').getNetTransform(m)
            spine3Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine3Height + topOffset - bodyHeight * 1.3999999999999999
            offsetY = 3.5 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.COAT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine02').getNetTransform(m)
            spine2Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine2Height + topOffset - bodyHeight * 1.3999999999999999
            offsetY = 4.5 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.PANT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_right_knee').getNetTransform(m)
            kneeHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -kneeHeight + pantOffset - 0.5 - bodyHeight * 0.29999999999999999
            offsetY = 4.5 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.BELT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_hips').getNetTransform(m)
            hipHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -hipHeight + beltOffset - bodyHeight * 0.5
            offsetY = 1.7 + bodyOffset
            offsetH = 180
        elif clothingType == ClothingGlobals.SHOE:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_right_ankle').getNetTransform(m)
            ankleHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -ankleHeight + shoeOffset - 0.14999999999999999 - bodyHeight * -0.10000000000000001
            offsetY = 3.25 + bodyOffset
            offsetH = 200
        else:
            offsetZ = 0
            offsetY = 0
            offsetH = 0
        offsetX = 0
        self.displayHuman.setY(offsetY)
        self.displayHuman.setZ(offsetZ)
        self.displayHuman.setX(offsetX)
        self.displayHuman.setH(offsetH)
        self.displayHuman.reparentTo(self.portraitSceneGraph)
        iHeight = 0.17999999999999999
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        if self.showResaleValue:
            value = int(
                ItemGlobals.getGoldCost(itemId) *
                ItemGlobals.GOLD_SALE_MULTIPLIER)
        else:
            value = ItemGlobals.getGoldCost(itemId)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell and self.cell.container:
            itemCost = int(itemCost * self.cell.container.getItemPriceMult())

        goldLabel = DirectLabel(
            parent=self,
            relief=None,
            image=coinImage,
            image_scale=0.12,
            image_pos=Vec3(0.025000000000000001, 0, -0.02),
            text=str(itemCost),
            text_scale=subtitleScale,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(halfWidth - 0.050000000000000003, 0.0,
                 runningVertPosition + 0.080000000000000002),
            text_pos=(0.0, -textScale))
        labels.append(goldLabel)
        descriptionLabel = DirectLabel(
            parent=self,
            relief=None,
            text=PLocalizer.getItemFlavorText(itemId),
            text_scale=textScale,
            text_wordwrap=halfWidth * 2.0 * (0.94999999999999996 / textScale),
            text_fg=PiratesGuiGlobals.TextFG0,
            text_align=TextNode.ALeft,
            pos=(-halfWidth + textScale * 0.5, 0.0, runningVertPosition),
            text_pos=(0.0, -textScale))
        dHeight = descriptionLabel.getHeight() + 0.02
        runningVertPosition -= dHeight
        runningSize += dHeight
        labels.append(descriptionLabel)
        if not Freebooter.getPaidStatus(localAvatar.getDoId()):
            if rarity != ItemGlobals.CRUDE:
                unlimitedLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.UnlimitedAccessRequirement,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                    text_fg=PiratesGuiGlobals.TextFG6,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_align=TextNode.ACenter,
                    pos=(0.0, 0.0, runningVertPosition),
                    text_pos=(0.0, -textScale))
                uHeight = unlimitedLabel.getHeight()
                runningVertPosition -= uHeight
                runningSize += uHeight
                labels.append(unlimitedLabel)

        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.080000000000000002)
        topPanel.reparentTo(self.helpFrame)
        middlePanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/middle_panel').copyTo(middlePanel)
        middlePanel.setScale(0.080000000000000002)
        middlePanel.reparentTo(self.helpFrame)
        placement = 0
        i = 0
        heightMax = -0.080000000000000002
        currentHeight = runningVertPosition
        if detailsHeight:
            currentHeight = -detailsHeight

        while currentHeight < heightMax:
            middlePanel = panels.attachNewNode('middlePanel%s' % 1)
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.080000000000000002)
            middlePanel.reparentTo(self.helpFrame)
            if currentHeight + 0.20000000000000001 >= heightMax:
                difference = heightMax - currentHeight
                placement += (0.16800000000000001 /
                              0.20000000000000001) * difference
                currentHeight += difference
            else:
                placement += 0.16800000000000001
                currentHeight += 0.20000000000000001
            middlePanel.setZ(-placement)
            i += 1
        bottomPanel = panels.attachNewNode('bottomPanel')
        detailGui.find('**/bottom_panel').copyTo(bottomPanel)
        bottomPanel.setScale(0.080000000000000002)
        bottomPanel.setZ(-placement)
        bottomPanel.reparentTo(self.helpFrame)
        colorPanel = self.helpFrame.attachNewNode('colorPanel')
        detailGui.find('**/color').copyTo(colorPanel)
        colorPanel.setScale(0.080000000000000002)
        colorPanel.setColor(titleColor)
        colorPanel.reparentTo(self.helpFrame)
        lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
        detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
        lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002,
                                   0.070000000000000007)
        lineBreakTopPanel.setZ(0.0080000000000000002)
        lineBreakTopPanel.reparentTo(self.helpFrame)
        panels.flattenStrong()
        self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                       -(runningSize + vMargin), vMargin)
        totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
        for label in labels:
            label.reparentTo(self.helpFrame)

        if basePosX > 0.0:
            newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
        else:
            newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            (newPosX, newPosZ) = detailsPos

        self.helpFrame.setPos(newPosX, 0, newPosZ)
Ejemplo n.º 53
0
 def update(self, repId = None, fromUser = 0):
     inv = localAvatar.getInventory()
     if not inv:
         self.notify.warning('SkillPage unable to find inventory')
         return None
     
     if self.tabBar == None:
         return None
     
     if self.demo:
         return None
     
     if fromUser:
         self.lastUserSelectedTab = repId
     
     if repId == None:
         if localAvatar.getGameState() == 'Fishing':
             if self.lastUserSelectedTab:
                 repId = self.lastUserSelectedTab
             else:
                 repId = InventoryType.CannonRep
         elif localAvatar.cannon:
             repId = InventoryType.CannonRep
         elif localAvatar.gameFSM.state == 'ShipPilot':
             repId = InventoryType.SailingRep
         elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
             repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
         elif localAvatar.currentWeaponId and not (localAvatar.isWeaponDrawn) and self.lastUserSelectedTab:
             repId = self.lastUserSelectedTab
         else:
             repId = InventoryType.CannonRep
     
     self.setRep(repId)
     self.tabBar.selectTab(str(repId))
     self.repMeter.setCategory(repId)
     self.repMeter.update(inv.getReputation(repId))
     unSpentId = self.getUnspent()
     amt = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         amt = self.localMods[unSpentId]
     
     self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
     if amt > 0:
         self.unspent['text_fg'] = (0.80000000000000004, 1, 0.80000000000000004, 1)
     else:
         self.unspent['text_fg'] = (1, 1, 1, 1)
     comboSkills = RadialMenu.ComboSkills(repId, 1)
     totalComboSkills = RadialMenu.ComboSkills(repId, 0)
     activeSkills = RadialMenu.ActiveSkills(repId, 1)
     totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
     passiveSkills = RadialMenu.PassiveSkills(repId, 1)
     totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
     self.linkedSkillIds = { }
     linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
     if linkedSkills:
         for skillId in linkedSkills:
             realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
             self.linkedSkillIds[realSkillId] = skillId
         
     
     for excludedSkillId in self.EXCLUDED_SKILLS:
         for skillId in activeSkills:
             if excludedSkillId == skillId:
                 activeSkills.remove(skillId)
                 totalActiveSkills.remove(skillId)
                 continue
         
     
     for spot in self.skillFrames.keys():
         if spot not in totalComboSkills:
             self.skillFrames[spot].hide()
             continue
     
     count = 0
     for skill in totalComboSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         if not skill in comboSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = 0.20000000000000001 + 0.17499999999999999 * count
         y = 1.1100000000000001
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         count += 1
     
     count = 0
     for skill in totalActiveSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         (xMod, yMod) = self.ringOffset(count)
         xMod *= 0.90000000000000002
         yMod *= 0.90000000000000002
         if not skill in activeSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = xMod + 0.53000000000000003
         y = yMod + 0.61499999999999999
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         ammo = self.getAmmo(skill)
         if ammo != None and showIcon:
             self.skillFrames[skill].showQuantity = True
             self.skillFrames[skill].updateQuantity(ammo)
         
         count += 1
     
     count = 0
     for skill in totalPassiveSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         if not skill in passiveSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = 0.20000000000000001 + 0.17499999999999999 * count
         y = 0.14999999999999999
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         count += 1
     
     self.dataChanged = False
Ejemplo n.º 54
0
 def __init__(self, npc, shopId, **kw):
     optiondefs = (('relief', None, None), ('framSize', (0, self.width, 0, self.height), None), ('sortOrder', 20, None))
     self.defineoptions(kw, optiondefs)
     DirectFrame.__init__(self, None, **None)
     self.initialiseoptions(BarberStoreGUI)
     self.pirate = None
     self.camIval = None
     self.buttons = []
     self.buttonIndex = 0
     self.itemAmount = 0
     self.currentPage = None
     self.confirmBox = None
     self.buttonsPerPage = 3
     self.displayRegionStates = { }
     self.numPages = 0
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.CoinImage = gui.find('**/treasure_w_coin*')
     self.ParchmentIcon = gui.find('**/main_gui_quest_scroll')
     self.barberIconsA = loader.loadModel('models/gui/char_gui')
     self.barberIconsB = loader.loadModel('models/textureCards/shopIcons')
     self.ShirtIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
     self.LockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
     self.backTabParent = self.attachNewNode('backTabs', sort = 0)
     self.panel = GuiPanel.GuiPanel(None, self.width, self.height, parent = self, showClose = False)
     self.setPos(0.0, 0, -0.75)
     self.balance = 0
     self.npc = npc
     self.rootTitle = PLocalizer.ShopBarber
     self.paid = Freebooter.getPaidStatus(localAvatar.getDoId())
     self.shopId = shopId
     if localAvatar.gameFSM.camIval is not None:
         if localAvatar.gameFSM.camIval.isPlaying():
             localAvatar.gameFSM.camIval.finish()
         
     
     self.initialCamPos = camera.getPos()
     self.initialCamHpr = camera.getHpr()
     self.initialPirateH = 0
     self.cartWidth = self.columnWidth - 0.10000000000000001
     self.cartHeight = self.height - 0.25
     self.cartFrame = DirectFrame(parent = self.panel, relief = None, frameSize = (0, self.cartWidth, 0, self.cartHeight))
     self.cartFrame.setPos(self.columnWidth + 0.025000000000000001, 0, 0.080000000000000002)
     self.categoryText = [
         [
             PLocalizer.Hat,
             PLocalizer.Hats],
         [
             PLocalizer.Shirt,
             PLocalizer.Shirts],
         [
             PLocalizer.Vest,
             PLocalizer.Vests],
         [
             PLocalizer.Coat,
             PLocalizer.Coats],
         [
             PLocalizer.Pants,
             PLocalizer.Pants],
         [
             PLocalizer.Belt,
             PLocalizer.Belts],
         [
             None,
             None],
         [
             PLocalizer.Shoe,
             PLocalizer.Shoes]]
     self.frontTabParent = self.panel.attachNewNode('frontTab', sort = 2)
     self.myGoldTitle = DirectFrame(parent = self.cartFrame, relief = None, text = PLocalizer.YourMoney, text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, pos = (-0.375, 0, 0.17499999999999999))
     self.myGold = DirectFrame(parent = self.cartFrame, relief = None, text = str(localAvatar.getMoney()), text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, image = self.CoinImage, image_scale = 0.14999999999999999, image_pos = (0.029999999999999999, 0, 0.014999999999999999), pos = (-0.059999999999999998, 0, 0.17499999999999999))
     self.closeButton = DialogButton.DialogButton(command = self.closePanel, parent = self.cartFrame, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG2, text_pos = (0.02, -(PiratesGuiGlobals.TextScaleLarge) * 0.25), text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, buttonStyle = DialogButton.DialogButton.NO)
     self.closeButton.setPos(0, 0, 0.0050000000000000001)
     tGui = loader.loadModel('models/gui/triangle')
     triangle = (tGui.find('**/triangle'), tGui.find('**/triangle_down'), tGui.find('**/triangle_over'))
     self.nextPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = 0.065000000000000002, pos = (0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.nextPage)
     self.prevPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = -0.065000000000000002, pos = (-0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.previousPage)
     self.pageNumber = DirectFrame(parent = self.cartFrame, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.0, 0.0), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0.089999999999999997))
     self.titleLabel = DirectLabel(parent = self, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG1, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge * 1.3, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.62, 0.0, 1.3300000000000001))
     self.titleLabel.setBin('gui-fixed', 1)
     self.createPirate()
     charGui = loader.loadModel('models/gui/char_gui')
     self.rotateSlider = DirectSlider(parent = base.a2dBottomLeft, relief = None, command = self.rotatePirate, image = charGui.find('**/chargui_slider_small'), image_scale = (2.1499999999999999, 2.1499999999999999, 1.5), thumb_relief = None, thumb_image = (charGui.find('**/chargui_slider_node'), charGui.find('**/chargui_slider_node_down'), charGui.find('**/chargui_slider_node_over')), pos = (0.80000000000000004, 0.0, 0.089999999999999997), text_align = TextNode.ACenter, text_scale = (0.10000000000000001, 0.10000000000000001), text_pos = (0.0, 0.10000000000000001), text_fg = PiratesGuiGlobals.TextFG1, scale = 0.42999999999999999, text = PLocalizer.RotateSlider, value = 0.5, sortOrder = -1)
     self.rotateSlider['extraArgs'] = [
         self.rotateSlider]
     self.rotateSliderOrigin = 0.5
     self.accept('mouse1', self._startMouseReadTask)
     self.accept('mouse1-up', self._stopMouseReadTask)
     self.clothWindows = []
     self.clothRenders = []
     self.clothHumans = []
     self.clothCameraNPs = []
     self.clothCameras = []
     self.createDisplayRegions()
     self.alertDialog = None
     self.accept('aspectRatioChanged', self.aspectRatioChange)
     self.accept('NonPayerPanelShown', self.hideDisplayRegions)
     self.accept('NonPayerPanelHidden', self.showDisplayRegions)
     self.accept('MainMenuShown', self.hideDisplayRegions)
     self.accept('MainMenuHidden', self.showDisplayRegions)
     self.accept('GUIShown', self.showDisplayRegions)
     self.accept('GUIHidden', self.hideDisplayRegions)
     localAvatar.guiMgr.chatPanel.show()
     localAvatar.guiMgr.chatPanel.startFadeTextIval()
     self.model = loader.loadModel('models/gui/gui_shop_tailor')
     self.model.reparentTo(self.panel)
     self.model.setBin('gui-fixed', 0)
     self.model.setPos(0.625, 0.0, 1.05)
     self.model.setScale(0.33700000000000002, 0.0, 0.32700000000000001)
     localAvatar.guiMgr.hideTrackedQuestInfo()
     self.initTabs()
     self.updateBalance()
     self.focusCamera()
 def showLoot(self, plunder = [], gold = 0, collect = 0, card = 0, cloth = 0, color = 0, jewel = None, tattoo = None, weapon = None, bounty = 0):
     for loot in self.loot:
         loot.destroy()
         del loot
     
     self.loot = []
     gender = localAvatar.style.getGender()
     self.show()
     self.setAlphaScale(1.0)
     treasure = []
     for itemId in self.icons.iterkeys():
         count = 0
         for item in plunder:
             if item == itemId:
                 count += 1
                 continue
         
         if count > 0:
             treasure.append([
                 itemId,
                 count])
             continue
     
     plunder = treasure
     if gold:
         plunder.append([
             ItemId.GOLD,
             gold])
         LootPopupPanel.lootSfx.play()
     
     if bounty:
         plunder.append([
             ItemId.BOUNTY,
             bounty])
         LootPopupPanel.lootSfx.play()
     
     if collect:
         plunder.append([
             ItemId.COLLECT,
             collect])
         LootPopupPanel.lootSfx.play()
     
     if card:
         plunder.append([
             ItemId.CARD,
             card])
         LootPopupPanel.lootSfx.play()
     
     if cloth:
         plunder.append([
             ItemId.CLOTHING,
             (cloth, color)])
         LootPopupPanel.lootSfx.play()
     
     if jewel is not None:
         plunder.append([
             ItemId.QUEST_DROP_JEWEL,
             jewel])
         LootPopupPanel.lootSfx.play()
     
     if tattoo is not None:
         plunder.append([
             ItemId.QUEST_DROP_TATTOO,
             tattoo])
         LootPopupPanel.lootSfx.play()
     
     if weapon is not None:
         plunder.append([
             ItemId.QUEST_DROP_WEAPON,
             weapon])
         LootPopupPanel.lootSfx.play()
     
     for item in plunder:
         (itemType, quantity) = item
         if itemType == ItemId.COLLECT:
             itemId = quantity
             howRare = CollectionMap.Collection_Rarity.get(itemId, 0)
             rarityText = PLocalizer.CollectionRarities.get(howRare)
             value = CollectionValues.get(howRare, 0)
             itemName = PLocalizer.Collections[itemId]
             howManyDoIHave = localAvatar.getInventory().getStackQuantity(itemId)
             howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1)
             if howManyDoIHave < howManyINeed:
                 textInfo = PLocalizer.CollectionPopupNewText % (itemName, rarityText, value)
             else:
                 textInfo = PLocalizer.CollectionPopupDuplicateText % (itemName, rarityText, value)
             pic_name = CollectionMap.Assets[itemId]
             lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name)
             iconScale = 0.34999999999999998
         elif itemType == ItemId.CLOTHING:
             (clothingId, colorId) = quantity
             if clothingId in ClothingGlobals.quest_items:
                 textInfo = PLocalizer.getItemName(clothingId)
             else:
                 textInfo = PLocalizer.TailorColorStrings.get(colorId)
                 textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName(ItemGlobals.getType(clothingId))
             clothingType = ItemGlobals.getType(clothingId)
             iconScale = 0.13
             if clothingType == 0:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_hat')
             elif clothingType == 1:
                 lootIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
                 iconScale = 0.29999999999999999
             elif clothingType == 2:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_vest')
             elif clothingType == 3:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_coat')
             elif clothingType == 4:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_pants')
             elif clothingType == 5:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_belt')
             elif clothingType == 6:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_sock')
             else:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_booths')
         elif itemType == ItemId.CARD:
             textInfo = PLocalizer.InventoryTypeNames.get(quantity)
             pic_name = ''
             lootIcon = PlayingCardGlobals.getImage('standard', PlayingCardGlobals.getSuit(quantity), PlayingCardGlobals.getRank(quantity))
             iconScale = 0.20000000000000001
         elif itemType == ItemId.GOLD:
             textInfo = PLocalizer.LootGold % str(quantity)
             potionPercent = PotionGlobals.getGoldBoostEffectPercent(localAvatar)
             potionGold = 0
             textInfo = PLocalizer.LootGold % str(quantity)
             if base.cr.newsManager:
                 if base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAYPAID) or Freebooter.getPaidStatus(base.localAvatar.getDoId()) or base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAY):
                     textInfo = PLocalizer.LootGold % str(quantity / 2) + '\n + ' + PLocalizer.LootGoldDouble % str(quantity / 2)
                 
             if potionGold > 0:
                 textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str(potionGold)
             
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.27000000000000002
         elif itemType == ItemId.BOUNTY:
             textInfo = PLocalizer.LootBounty % str(quantity)
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.27000000000000002
         elif itemType == ItemId.CARGO_CRATE:
             if quantity == 1:
                 textInfo = PLocalizer.CargoCrate % quantity
             else:
                 textInfo = PLocalizer.CargoCrateP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_CHEST:
             if quantity == 1:
                 textInfo = PLocalizer.CargoChest % quantity
             else:
                 textInfo = PLocalizer.CargoChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_SKCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.CargoSkChest % quantity
             else:
                 textInfo = PLocalizer.CargoSkChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTSAC:
             if quantity == 1:
                 textInfo = PLocalizer.LootSac % quantity
             else:
                 textInfo = PLocalizer.LootSacP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.LootChest % quantity
             else:
                 textInfo = PLocalizer.LootChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTSKCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.LootSkChest % quantity
             else:
                 textInfo = PLocalizer.LootSkChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.QUEST_DROP_JEWEL:
             textInfo = None
             type = None
             lootIcon = None
             iconScale = 1.0
             type = ItemGlobals.getType(quantity)
             textInfo = PLocalizer.getItemName(quantity)
             if type == ItemGlobals.BROW:
                 lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_brow')
                 iconScale = (-0.14000000000000001, 0.14000000000000001, 0.14000000000000001)
             elif type == ItemGlobals.EAR:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_ears')
                 iconScale = (-0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
             elif type == ItemGlobals.NOSE:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_nose')
                 iconScale = (0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
             elif type == ItemGlobals.MOUTH:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_mouth')
                 iconScale = (0.32500000000000001, 0.32500000000000001, 0.32500000000000001)
             elif type == ItemGlobals.LHAND:
                 lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_hand')
                 iconScale = (0.125, 0.125, 0.125)
             else:
                 lootIcon = None
         elif itemType == ItemId.QUEST_DROP_TATTOO:
             textInfo = None
             type = None
             lootIcon = None
             iconScale = 1.0
             type = ItemGlobals.getType(quantity)
             textInfo = PLocalizer.getItemName(quantity)
             if type == ItemGlobals.CHEST:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_chest_male')
                 iconScale = 0.10000000000000001
             elif type == ItemGlobals.ARM:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_arm')
                 iconScale = 0.10000000000000001
             elif type == ItemGlobals.FACE:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_face_male')
                 iconScale = 0.10000000000000001
             else:
                 lootIcon = None
         elif itemType == ItemId.QUEST_DROP_WEAPON:
             weaponId = quantity
             iconScale = 0.10000000000000001
             textInfo = None
             lootIcon = None
             iconName = getItemIcons(weaponId)
             if iconName is not None:
                 lootIcon = LootPopupPanel.WeaponIcons.find('**/' + iconName)
                 textInfo = PLocalizer.InventoryTypeNames.get(weaponId)
             
         
         entry = DirectFrame(parent = self, relief = None, geom = lootIcon, geom_scale = iconScale, text = textInfo, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG0, text_pos = (0.070000000000000007, 0.01), text_font = PiratesGlobals.getInterfaceFont())
         entry.setTransparency(1)
         self.loot.append(entry)
     
     self.repackPanels()
Ejemplo n.º 56
0
 def addPoint(self, skillId):
     if skillId == InventoryType.SailPowerRecharge:
         return
     inv = localAvatar.getInventory()
     frameSkillId = skillId
     skillId = WeaponGlobals.getLinkedSkillId(frameSkillId)
     if not skillId:
         skillId = frameSkillId
     if self.currentRep == InventoryType.CutlassRep and localAvatar.style.tutorial < PiratesGlobals.TUT_GOT_CUTLASS:
         if inv.getStackQuantity(InventoryType.CutlassSweep) < 2:
             if skillId != InventoryType.CutlassSweep:
                 return
         elif skillId == InventoryType.CutlassSweep:
             messenger.send('skillImprovementAttempted')
     unSpentId = self.getUnspent()
     unSp = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         unSp = self.localMods[unSpentId]
     if unSp < 1:
         return
     if inv.getStackLimit(skillId):
         curAmt = inv.getStackQuantity(skillId)
         if skillId in self.localMods:
             curAmt = self.localMods[skillId]
         if curAmt > 5:
             return
         else:
             curAmt += 1
     else:
         return
     self.__handleFreeDialog()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if curAmt > Freebooter.FreeSkillCap:
             self.spentDialog = PDialog.PDialog(
                 text=PLocalizer.FreebooterSkillMax,
                 style=OTPDialog.CancelOnly,
                 command=self.__handleFreeDialog)
             return
         playerExp = inv.getAccumulator(self.currentRep)
         categoryLevel, extra = ReputationGlobals.getLevelFromTotalReputation(
             self.currentRep, playerExp)
         alreadySpent = categoryLevel - 1 - unSp
         if alreadySpent > 5:
             self.spentDialog = PDialog.PDialog(
                 text=PLocalizer.FreebooterSkillLock,
                 style=OTPDialog.CancelOnly,
                 command=self.__handleFreeDialog)
             return
     if not base.config.GetBool('want-combo-skips', 0):
         comboSkills = [
             InventoryType.CutlassSlash, InventoryType.CutlassCleave,
             InventoryType.CutlassFlourish, InventoryType.CutlassStab,
             InventoryType.DaggerSwipe, InventoryType.DaggerGouge,
             InventoryType.DaggerEviscerate
         ]
         if skillId in comboSkills and inv.getStackQuantity(skillId -
                                                            1) <= 1:
             base.localAvatar.guiMgr.createWarning(
                 PLocalizer.ComboOrderWarn, PiratesGuiGlobals.TextFG6)
             return
     messenger.send('skillImprovementAttempted')
     localAvatar.spendSkillPoint(skillId)
     self.localMods[skillId] = curAmt
     self.localMods[unSpentId] = unSp - 1
     self.skillFrames[frameSkillId].skillRank = curAmt - 1
Ejemplo n.º 57
0
 def unlockAmmoFromAI(self, ammoSkillIds):
     for ammoSkillId in ammoSkillIds:
         if Freebooter.getPaidStatus(base.localAvatar.doId) or ammoSkillId <= CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
             self.buttons[ammoSkillId].unlock()
             continue
 def updateText(self):
     tText = PLocalizer.DisplayTitle
     if not Freebooter.getPaidStatus(localAvatar.doId):
         tText = PLocalizer.DisplayTitleFree
     
     self.displayTitleFrame['text'] = tText