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 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)
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)
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 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 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)
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)
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 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 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 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 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 offerOptions(self): self.invReq = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), self.invArrived, 10)
def offerOptions(self): self.invReq = DistributedInventoryBase.getInventory(localAvatar.getInventoryId(), self.invArrived, 10)