예제 #1
0
 def cancelGetInventory(self, requestId):
     if requestId in self.myInventoryRequests:
         self.myInventoryRequests.remove(requestId)
         DistributedInventoryBase.cancelGetInventory(requestId)
         return True
     
     return False
예제 #2
0
 def disable(self):
     DistributedInteractive.disable(self)
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(localAvatar.getInventoryId())
         self.invReq = None
     
     self.removeChildren()
    def destroy(self):
        self.ignoreAll()
        taskMgr.remove('doThreatMessageQueue')
        if self.invReq:
            DistributedInventoryBase.cancelGetInventory(self.invReq)
            self.invReq = None

        if self.statusEffectsPanel:
            self.statusEffectsPanel.destroy()
            self.statusEffectsPanel = None

        if self.openPortLabel:
            self.openPortLabel.destroy()
            self.openPortLabel = None

        if self.anchorButton:
            self.anchorButton.destroy()
            self.anchorButton = None

        self.hpMeterDownIval.pause()
        self.hpMeterUpGreenIval.pause()
        self.hpMeterUpRedIval.pause()
        self.hpMeterUpYellowIval.pause()
        del self.hpMeterDownIval
        del self.hpMeterUpGreenIval
        del self.hpMeterUpRedIval
        del self.hpMeterUpYellowIval
        self.timer = None
        self.anchorButton = None
        GuiTray.GuiTray.destroy(self)
        self.destroyBoardingPermissionPanel()
    def enterFireCannon(self):
        localAvatar.guiMgr.combatTray.setLinkedCannon(self)
        self.enableCannonFireInput()
        base.localAvatar.guiMgr.setIgnoreEscapeHotKey(True)
        self.accept(InteractiveBase.END_INTERACT_EVENT, self.handleEndInteractKey)
        localAvatar.cameraFSM.request(self._cameraState, self.prop)
        self.setCannonGUI()
        taskMgr.add(self.updateReload, 'updateCannonReload')
        self.cgui.setAmmoId(self.getAmmoSkillId())
        
        def gotInventory(inv):
            if inv:
                ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId())
                maxShots = inv.getStackLimit(ammoInvId)
                self.numShots = inv.getStackQuantity(ammoInvId)
                if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()):
                    self.cgui.setAmmoLeft(-1, -1)
                else:
                    self.cgui.setAmmoLeft(self.numShots, maxShots)
                self.updateCannonItems()
                self.updateCannonDressing()
            

        if self._DistributedPCCannon__invRequest:
            DistributedInventoryBase.cancelGetInventory(self._DistributedPCCannon__invRequest)
        
        self._DistributedPCCannon__invRequest = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), gotInventory)
예제 #5
0
    def cancelGetInventory(self, requestId):
        if requestId in self.myInventoryRequests:
            self.myInventoryRequests.remove(requestId)
            DistributedInventoryBase.cancelGetInventory(requestId)
            return True

        return False
예제 #6
0
 def disable(self):
     DistributedInteractive.disable(self)
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(localAvatar.getInventoryId())
         self.invReq = None
     
     self.removeChildren()
예제 #7
0
    def destroy(self):
        self.ignoreAll()
        taskMgr.remove('doThreatMessageQueue')
        if self.invReq:
            DistributedInventoryBase.cancelGetInventory(self.invReq)
            self.invReq = None

        if self.statusEffectsPanel:
            self.statusEffectsPanel.destroy()
            self.statusEffectsPanel = None

        if self.openPortLabel:
            self.openPortLabel.destroy()
            self.openPortLabel = None

        if self.anchorButton:
            self.anchorButton.destroy()
            self.anchorButton = None

        self.hpMeterDownIval.pause()
        self.hpMeterUpGreenIval.pause()
        self.hpMeterUpRedIval.pause()
        self.hpMeterUpYellowIval.pause()
        del self.hpMeterDownIval
        del self.hpMeterUpGreenIval
        del self.hpMeterUpRedIval
        del self.hpMeterUpYellowIval
        self.timer = None
        self.anchorButton = None
        GuiTray.GuiTray.destroy(self)
        self.destroyBoardingPermissionPanel()
    def enterFireCannon(self):
        localAvatar.guiMgr.combatTray.setLinkedCannon(self)
        self.enableCannonFireInput()
        base.localAvatar.guiMgr.setIgnoreEscapeHotKey(True)
        self.accept(InteractiveBase.END_INTERACT_EVENT, self.handleEndInteractKey)
        localAvatar.cameraFSM.request(self._cameraState, self.prop)
        self.setCannonGUI()
        taskMgr.add(self.updateReload, 'updateCannonReload')
        self.cgui.setAmmoId(self.getAmmoSkillId())
        
        def gotInventory(inv):
            if inv:
                ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId())
                maxShots = inv.getStackLimit(ammoInvId)
                self.numShots = inv.getStackQuantity(ammoInvId)
                if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()):
                    self.cgui.setAmmoLeft(-1, -1)
                else:
                    self.cgui.setAmmoLeft(self.numShots, maxShots)
                self.updateCannonItems()
                self.updateCannonDressing()
            

        if self._DistributedPCCannon__invRequest:
            DistributedInventoryBase.cancelGetInventory(self._DistributedPCCannon__invRequest)
        
        self._DistributedPCCannon__invRequest = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), gotInventory)
예제 #9
0
 def disable(self):
     DistributedInteractive.disable(self)
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(
             localAvatar.getInventoryId())
         self.invReq = None
     self.get_children().detach()
     return
예제 #10
0
    def cancelAllInventoryRequests(self):
        canceled = False
        for currRequest in self.myInventoryRequests:
            DistributedInventoryBase.cancelGetInventory(currRequest)
            canceled = True

        self.myInventoryRequests = []
        return canceled
예제 #11
0
 def cancelAllInventoryRequests(self):
     canceled = False
     for currRequest in self.myInventoryRequests:
         DistributedInventoryBase.cancelGetInventory(currRequest)
         canceled = True
     
     self.myInventoryRequests = []
     return canceled
예제 #12
0
 def __init__(self, repository):
     DistributedInventoryBase.__init__(self, repository)
     self._locatableItems = InvItemList()
     self.tempAdds = []
     self.tempRems = []
     self.selfTestsTask = None
     self.selfTestTrades = []
     self.testPending = False
     self.areLocatablesReady = 0
 def __init__(self, repository):
     DistributedInventoryBase.__init__(self, repository)
     self._locatableItems = InvItemList()
     self.tempAdds = []
     self.tempRems = []
     self.selfTestsTask = None
     self.selfTestTrades = []
     self.testPending = False
     self.areLocatablesReady = 0
예제 #14
0
 def exitWaiting(self):
     DistributedInteractive.exitWaiting(self)
     if (self.newState != 'Use' and self).avGameState:
         if localAvatar.getGameState() == 'DinghyInteract':
             localAvatar.b_setGameState(self.avGameState)
             if self.avGameState in ['WaterRoam', 'BattleWaterRoam']:
                 localAvatar.motionFSM.setWaterState(True, True)
                 base.cr.interactionMgr.start()
         self.avGameState = None
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(localAvatar.getInventoryId())
         self.invReq = None
     return
    def startSellShip(self, storeType):
        self.pickShipGUI = ShipShoppingPanel(PLocalizer.SellShip, doneCallback = self.confirmSellShip, mode = 'sell')

        def inventoryHere(inv):
            self._DistributedShopKeeper__invRequest = None
            if inv:
                for shipId in inv.getShipDoIdList():
                    self.pickShipGUI.addOwnShip(shipId, self.confirmSellShip)

            else:
                self.finishShopping()

        if self._DistributedShopKeeper__invRequest:
            DistributedInventoryBase.cancelGetInventory(self._DistributedShopKeeper__invRequest)

        self._DistributedShopKeeper__invRequest = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), inventoryHere)
예제 #16
0
    def skipTutorial(self):
        def initDefQuest(inventory):
            self.pendingInitQuest = None
            if inventory:
                localAvatar.sendUpdate('giveDefaultQuest')
                localAvatar.b_setTutorial(PiratesGlobals.TUT_GOT_COMPASS)
                if base.launcher.getPhaseComplete(4):
                    self.leaveTutorial()
                else:
                    base.downloadWatcher.foreground()
                    self.acceptOnce('phaseComplete-4', self.leaveTutorial)
            return

        self.pendingInitQuest = DistributedInventoryBase.getInventory(
            localAvatar.getInventoryId(), initDefQuest)
        base.transitions.fadeOut(1.0)
        base.cr.loadingScreen.showHint(LocationIds.PORT_ROYAL_ISLAND)
        base.cr.loadingScreen.showTarget(LocationIds.PORT_ROYAL_ISLAND)
        base.cr.loadingScreen.show()
        localAvatar.guiMgr.ignoreAllKeys = False
        localAvatar.guiMgr.showTrays()
        localAvatar.show()
        if base.downloadWatcher and hasattr(base.downloadWatcher,
                                            'setStatusBarLocation'):
            base.downloadWatcher.setStatusBarLocation(2)
    def startSellShip(self, storeType):
        self.pickShipGUI = ShipShoppingPanel(PLocalizer.SellShip, doneCallback = self.confirmSellShip, mode = 'sell')
        
        def inventoryHere(inv):
            self._DistributedShopKeeper__invRequest = None
            if inv:
                for shipId in inv.getShipDoIdList():
                    self.pickShipGUI.addOwnShip(shipId, self.confirmSellShip)
                
            else:
                self.finishShopping()

        if self._DistributedShopKeeper__invRequest:
            DistributedInventoryBase.cancelGetInventory(self._DistributedShopKeeper__invRequest)
        
        self._DistributedShopKeeper__invRequest = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), inventoryHere)
예제 #18
0
        def gotGameInfo(info):
            requestId = DistributedInventoryBase.getLastInventoryRequestId()
            if requestId in self.myInventoryRequests:
                self.myInventoryRequests.remove(requestId)

            if callback:
                callback(info)
        def gotGameInfo(info):
            requestId = DistributedInventoryBase.getLastInventoryRequestId()
            if requestId in self.myInventoryRequests:
                self.myInventoryRequests.remove(requestId)

            if callback:
                callback(info)
예제 #20
0
 def exitWaiting(self):
     DistributedInteractive.exitWaiting(self)
     if self.newState != 'Use' and self.avGameState:
         if localAvatar.getGameState() == 'DinghyInteract':
             localAvatar.b_setGameState(self.avGameState)
             if self.avGameState in [
                 'WaterRoam',
                 'BattleWaterRoam']:
                 localAvatar.motionFSM.setWaterState(True, True)
                 base.cr.interactionMgr.start()
             
         
         self.avGameState = None
     
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(localAvatar.getInventoryId())
         self.invReq = None
예제 #21
0
    def finishShopping(self):
        if self.storePush and self.storeMenuGUI:
            if self.confirmDialog:
                self.confirmDialog.destroy()
                self.confirmDialog = None

            if self.interactGUI:
                self.interactGUI.hide()

            self.storeMenuGUI.show()
            self.storePush = False
            return None

        self.ignore('exitStore')
        self.ignore('makeSale')
        self.ignore('makeShipSale')
        self.ignore('purchaseAccessories')
        self.ignore('requestMusic')
        self.ignore('requestStowaway')
        messenger.send('stoppedShopping')
        self.ignore(
            InventoryGlobals.getCategoryChangeMsg(localAvatar.getInventoryId(),
                                                  InventoryType.ItemTypeMoney))
        if self._DistributedShopKeeper__invRequest:
            DistributedInventoryBase.cancelGetInventory(
                self._DistributedShopKeeper__invRequest)
            self._DistributedShopKeeper__invRequest = None

        if self.storeMenuGUI:
            self.storeMenuGUI.destroy()
            self.storeMenuGUI = None

        if self.pickShipGUI:
            self.pickShipGUI.destroy()
            self.pickShipGUI = None

        if self.confirmDialog:
            self.confirmDialog.destroy()
            self.confirmDialog = None

        self.setColorScale(1, 1, 1, 1)
        self.setTransparency(0)
        self.show()
        if self.fadeIval:
            self.fadeIval.pause()
            self.fadeIval = None
예제 #22
0
    def postUpdate(self, cell):
        if (cell and cell).slotId:

            def invArrived(inventory):
                itemData = inventory.getLocatable(cell.slotId)
                if itemData:
                    cell.inventoryItem.amount = itemData.getCount()
                    cell.inventoryItem.updateAmountText()
                self.invReq = None
                return

            if self.invReq:
                DistributedInventoryBase.cancelGetInventory(self.invReq)
            self.invReq = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), invArrived)
            self.checkReqsForCell(cell)
        avInv = localAvatar.getInventory()
        if avInv and avInv.findAvailableLocation(InventoryType.ItemTypeConsumable) in [Locations.INVALID_LOCATION, Locations.NON_LOCATION]:
            localAvatar.sendRequestContext(InventoryType.InventoryFull)
    def finishShopping(self):
        if self.storePush and self.storeMenuGUI:
            if self.confirmDialog:
                self.confirmDialog.destroy()
                self.confirmDialog = None

            if self.interactGUI:
                self.interactGUI.hide()

            self.storeMenuGUI.show()
            self.storePush = False
            return None

        self.ignore('exitStore')
        self.ignore('makeSale')
        self.ignore('makeShipSale')
        self.ignore('purchaseAccessories')
        self.ignore('requestMusic')
        self.ignore('requestStowaway')
        messenger.send('stoppedShopping')
        self.ignore(InventoryGlobals.getCategoryChangeMsg(localAvatar.getInventoryId(), InventoryType.ItemTypeMoney))
        if self._DistributedShopKeeper__invRequest:
            DistributedInventoryBase.cancelGetInventory(self._DistributedShopKeeper__invRequest)
            self._DistributedShopKeeper__invRequest = None

        if self.storeMenuGUI:
            self.storeMenuGUI.destroy()
            self.storeMenuGUI = None

        if self.pickShipGUI:
            self.pickShipGUI.destroy()
            self.pickShipGUI = None

        if self.confirmDialog:
            self.confirmDialog.destroy()
            self.confirmDialog = None

        self.setColorScale(1, 1, 1, 1)
        self.setTransparency(0)
        self.show()
        if self.fadeIval:
            self.fadeIval.pause()
            self.fadeIval = None
예제 #24
0
    def leaveAction(self, action, allin_amount=0):
        self.deleteLeaveDialog()

        def showLeaveDialog(displayText=None):
            if not displayText:
                pass
            self.leaveDialog = PDialog.PDialog(
                text=PLocalizer.PokerLeaveConfirmMessage,
                style=OTPDialog.YesNo,
                giveMouse=False,
                command=self.leaveCallback)
            self.table.setDialogBin(self.leaveDialog)

        if self.table.gameVariation == PiratesGlobals.PARLORGAME_VARIATION_UNDEAD:

            def gotInventory(inventory):
                text = None

                try:
                    for currQuest in inventory.getQuestList():
                        for (currQuestTask, currQuestTaskState) in zip(
                                currQuest.getTasks(),
                                currQuest.getTaskStates()):
                            if isinstance(currQuestTask, SkeletonPokerTaskDNA):
                                if currQuestTaskState.isComplete():
                                    if currQuestTaskState.isComplete(
                                            bonus=True):
                                        lostProgress = 0
                                    else:
                                        lostProgress = currQuestTaskState.getBonusProgress(
                                        )
                                else:
                                    lostProgress = currQuestTaskState.getProgress(
                                    )
                                loseAmt = min(
                                    PiratesGlobals.PARLORGAME_UNDEAD_EXIT_LOSS,
                                    lostProgress)
                                if loseAmt > 0:
                                    text = PLocalizer.PokerUndeadLeaveConfirmMessage % str(
                                        loseAmt)
                                    raise NameError('doneSearch')

                            loseAmt > 0

                except NameError:
                    pass

                showLeaveDialog(text)

            invReq = DistributedInventoryBase.getInventory(
                localAvatar.inventoryId, gotInventory)
        else:
            showLeaveDialog()
예제 #25
0
    def getInventory(self, inventoryId, callback, timeout=30):

        def gotInventory(inventory):
            requestId = DistributedInventoryBase.getLastInventoryRequestId()
            if requestId in self.myInventoryRequests:
                self.myInventoryRequests.remove(requestId)
            if callback:
                callback(inventory)

        requestId = DistributedInventoryBase.getInventory(inventoryId, gotInventory, timeout)
        if requestId:
            self.myInventoryRequests.append(requestId)
        return requestId
    def postUpdate(self, cell):
        if cell and cell.slotId:
            
            def invArrived(inventory):
                itemData = inventory.getLocatable(cell.slotId)
                if itemData:
                    cell.inventoryItem.amount = itemData.getCount()
                    cell.inventoryItem.updateAmountText()
                
                self.invReq = None

            if self.invReq:
                DistributedInventoryBase.cancelGetInventory(self.invReq)
            
            self.invReq = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), invArrived)
            self.checkReqsForCell(cell)
        
        avInv = localAvatar.getInventory()
        if avInv and avInv.findAvailableLocation(InventoryType.ItemTypeConsumable) in [
            Locations.INVALID_LOCATION,
            Locations.NON_LOCATION]:
            localAvatar.sendRequestContext(InventoryType.InventoryFull)
 def getItemQuantity(self, itemCat, itemId=None):
     if isLocatable(itemCat):
         findFields = [(self.ITEM_CAT_IDX, itemCat)]
         if itemId:
             findFields.append((self.ITEM_ID_IDX, itemId))
         itemCounts = self._findLocatablesWithValues(findFields,
                                                     countsOnly=True)
         if itemId:
             return itemCounts.get(itemId, 0)
         else:
             return sum(itemCounts.values())
     else:
         return DistributedInventoryBase.getStackQuantity(self, itemCat)
    def getItemQuantity(self, itemCat, itemId = None):
        if isLocatable(itemCat):
            findFields = [
                (self.ITEM_CAT_IDX, itemCat)]
            if itemId:
                findFields.append((self.ITEM_ID_IDX, itemId))

            itemCounts = self._findLocatablesWithValues(findFields, countsOnly = True)
            if itemId:
                return itemCounts.get(itemId, 0)
            else:
                return sum(itemCounts.values())
        else:
            return DistributedInventoryBase.getStackQuantity(self, itemCat)
예제 #29
0
    def getInventory(self, inventoryId, callback, timeout = 30):
        
        def gotInventory(inventory):
            requestId = DistributedInventoryBase.getLastInventoryRequestId()
            if requestId in self.myInventoryRequests:
                self.myInventoryRequests.remove(requestId)
            
            if callback:
                callback(inventory)
            

        requestId = DistributedInventoryBase.getInventory(inventoryId, gotInventory, timeout)
        if requestId:
            self.myInventoryRequests.append(requestId)
        
        return requestId
    def leaveAction(self, action, allin_amount = 0):
        self.deleteLeaveDialog()
        
        def showLeaveDialog(displayText = None):
            if not displayText:
                pass
            self.leaveDialog = PDialog.PDialog(text = PLocalizer.PokerLeaveConfirmMessage, style = OTPDialog.YesNo, giveMouse = False, command = self.leaveCallback)
            self.table.setDialogBin(self.leaveDialog)

        if self.table.gameVariation == PiratesGlobals.PARLORGAME_VARIATION_UNDEAD:
            
            def gotInventory(inventory):
                text = None
                
                try:
                    for currQuest in inventory.getQuestList():
                        for (currQuestTask, currQuestTaskState) in zip(currQuest.getTasks(), currQuest.getTaskStates()):
                            if isinstance(currQuestTask, SkeletonPokerTaskDNA):
                                if currQuestTaskState.isComplete():
                                    if currQuestTaskState.isComplete(bonus = True):
                                        lostProgress = 0
                                    else:
                                        lostProgress = currQuestTaskState.getBonusProgress()
                                else:
                                    lostProgress = currQuestTaskState.getProgress()
                                loseAmt = min(PiratesGlobals.PARLORGAME_UNDEAD_EXIT_LOSS, lostProgress)
                                if loseAmt > 0:
                                    text = PLocalizer.PokerUndeadLeaveConfirmMessage % str(loseAmt)
                                    raise NameError('doneSearch')
                                
                            loseAmt > 0
                        
                except NameError:
                    pass

                showLeaveDialog(text)

            invReq = DistributedInventoryBase.getInventory(localAvatar.inventoryId, gotInventory)
        else:
            showLeaveDialog()
    def skipTutorial(self):
        
        def initDefQuest(inventory):
            self.pendingInitQuest = None
            if inventory:
                localAvatar.sendUpdate('giveDefaultQuest')
                localAvatar.b_setTutorial(PiratesGlobals.TUT_GOT_COMPASS)
                if base.launcher.getPhaseComplete(4):
                    self.leaveTutorial()
                else:
                    base.downloadWatcher.foreground()
                    self.acceptOnce('phaseComplete-4', self.leaveTutorial)
            

        self.pendingInitQuest = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), initDefQuest)
        base.transitions.fadeOut(1.0)
        base.cr.loadingScreen.showHint(LocationIds.PORT_ROYAL_ISLAND)
        base.cr.loadingScreen.showTarget(LocationIds.PORT_ROYAL_ISLAND)
        base.cr.loadingScreen.show()
        localAvatar.guiMgr.ignoreAllKeys = False
        localAvatar.guiMgr.showTrays()
        localAvatar.show()
        if base.downloadWatcher and hasattr(base.downloadWatcher, 'setStatusBarLocation'):
            base.downloadWatcher.setStatusBarLocation(2)
 def destroy(self):
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(self.invReq)
         self.invReq = None
     
     InventoryUISlotContainer.InventoryUISlotContainer.destroy(self)
예제 #33
0
 def offerOptions(self):
     self.invReq = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), self.invArrived, 10)
 def getItemsInCategory(self, category):
     if isLocatable(category):
         return self._findLocatablesWithValues([
             (self.ITEM_CAT_IDX, category)])
     else:
         return DistributedInventoryBase.getStacksInCategory(self, category)
    def getItemLimit(self, category, type = None):
        limit = getItemLimit(category, type)
        if limit == None:
            limit = DistributedInventoryBase.getStackLimit(self, category)

        return limit
예제 #36
0
 def destroy(self):
     if self.invReq:
         DistributedInventoryBase.cancelGetInventory(self.invReq)
         self.invReq = None
     InventoryUISlotContainer.InventoryUISlotContainer.destroy(self)
     return
 def getItemLimit(self, category, type=None):
     limit = getItemLimit(category, type)
     if limit == None:
         limit = DistributedInventoryBase.getStackLimit(self, category)
     return limit
 def getItemsInCategory(self, category):
     if isLocatable(category):
         return self._findLocatablesWithValues([(self.ITEM_CAT_IDX,
                                                 category)])
     else:
         return DistributedInventoryBase.getStacksInCategory(self, category)
예제 #39
0
 def offerOptions(self):
     self.invReq = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), self.invArrived, 10)