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 startHoliday(self, holidayId, configId=0, time=0, manual=False): if self.isHolidayActive(holidayId) or not self.wantHolidays: return if not holidayId in HolidayGlobals.getAllHolidayIds( ) and configId == 0: self.notify.warning( "Failed to start holiday. %s is an invalid holiday Id" % holidayId) return if configId != 0: holidayId = HolidayGlobals.getHolidayId(holidayId, configId) canStart = True if self.isInvasionHoliday(holidayId): canStart = self.startInvasionHoliday(holidayId) if self.isFleetHoliday(holidayId): canStart = self.startFleetHoliday(holidayId) if holidayId == HolidayGlobals.QUEENANNES: canStart = self.startQueenAnne() if canStart: self.activeHolidays[holidayId] = (time, manual) self.air.newsManager.addHoliday(holidayId, time) self.notify.info('Starting holiday %s (%d)' % ((HolidayGlobals.getHolidayName(holidayId) or holidayId), holidayId)) messenger.send('holidayActivated', [holidayId]) messenger.send('holidayListChanged')
def startHoliday(self, holidayId, configId=0, time=0, manual=False, channel=None): if not channel: if self.isHolidayActive(holidayId): return self.activeHolidays[holidayId] = (time, manual) self.notify.info('Starting Holiday %s (%d)' % ((HolidayGlobals.getHolidayName(holidayId) or holidayId), holidayId)) self.sendUpdate('startHoliday', [holidayId, configId, time, manual]) else: if self.isHolidayActive(holidayId, channel): return self.districts[channel]['localHolidays'][holidayId] = (time, manual) self.notify.info('Starting Holiday %s (%d) on %s' % ((HolidayGlobals.getHolidayName(holidayId) or holidayId), holidayId, channel)) self.sendUpdateToChannel(channel, 'startHoliday', [holidayId, configId, time, manual])
def getCatalogItemsForHoliday(holidayId): holidayClass = HolidayGlobals.getHolidayClass(holidayId) if holidayClass != HolidayGlobals.CATALOGHOLIDAY: return [] holidayConfig = HolidayGlobals.getHolidayConfig(holidayId) if holidayConfig not in CatalogHolidayGlobals.CatalogHolidayConfigs: return [] return CatalogHolidayGlobals.CatalogHolidayConfigs[holidayConfig].get( 'items', [])
def getCatalogItemsForHoliday(holidayId): holidayClass = HolidayGlobals.getHolidayClass(holidayId) if holidayClass != HolidayGlobals.CATALOGHOLIDAY: return [] holidayConfig = HolidayGlobals.getHolidayConfig(holidayId) if holidayConfig not in CatalogHolidayGlobals.CatalogHolidayConfigs: return [] return CatalogHolidayGlobals.CatalogHolidayConfigs[holidayConfig].get('items', [])
def getCatalogTabNameForHoliday(holidayId): holidayClass = HolidayGlobals.getHolidayClass(holidayId) if holidayId in HolidayGlobals.HOLIDAYS_WITH_CATALOGS: holidayName = PLocalizer.HOLIDAYIDS_TO_NAMES.get(holidayClass, 'error') return holidayName if holidayClass != HolidayGlobals.CATALOGHOLIDAY: return 'not-catalog-holiday' holidayConfig = HolidayGlobals.getHolidayConfig(holidayId) if holidayConfig not in CatalogHolidayGlobals.CatalogHolidayConfigs: return 'not-catalog-config' return PLocalizer.CatalogHolidayNames.get(holidayConfig, {}).get('tabName', 'no-tab-name')
def getCatalogTabNameForHoliday(holidayId): holidayClass = HolidayGlobals.getHolidayClass(holidayId) if holidayId in HolidayGlobals.HOLIDAYS_WITH_CATALOGS: holidayName = PLocalizer.HOLIDAYIDS_TO_NAMES.get(holidayClass, 'error') return holidayName if holidayClass != HolidayGlobals.CATALOGHOLIDAY: return 'not-catalog-holiday' holidayConfig = HolidayGlobals.getHolidayConfig(holidayId) if holidayConfig not in CatalogHolidayGlobals.CatalogHolidayConfigs: return 'not-catalog-config' return PLocalizer.CatalogHolidayNames.get(holidayConfig, { }).get('tabName', 'no-tab-name')
def __init__(self, area): Map.__init__(self, 'map-' + area.getName()) self.capturePoints = {} mapNode = area.getMapNode() if mapNode and not mapNode.isEmpty(): geom = mapNode.getChild(0) geom.setScale(mapNode.getScale()) geom.flattenStrong() mapNode.setScale(1) self.worldNode = mapNode self.map = self.worldNode.copyTo(NodePath()) (a, b) = self.map.getTightBounds() diff = b - a h = diff[1] w = diff[0] else: self.worldNode = area self.map = NodePath('no map found') (a, b) = self.worldNode.geom.getTightBounds() diff = b - a h = diff[1] w = diff[0] ratio = h / w if ratio < 0.98999999999999999: normalScale = 2 / w screenScale = 1 else: normalScale = 2 / h screenScale = 0.75 self.map.clearTransform() self.map.show() self.screenNode = NodePath('Minimap-screenNode') self.screenNode.setP(90) self.screenNode.setScale(screenScale * normalScale) self.screenNode.hide() self.map.reparentTo(self.screenNode) self.mapOverlay = self.map.attachNewNode('mapOverlay') self.mapOverlay.wrtReparentTo(self.screenNode) self.radarTransformNode = NodePath('radarTransform') self.radarTransformNode.setScale(self.worldNode.getScale()[0]) self.map.instanceTo(self.radarTransformNode) localAvatar.guiMgr.addMinimap(self) if self.allowOnScreen(): self.addObject(MinimapFootprint(area)) if self.allowOnScreen(): if area.getUniqueId() not in [LocationIds.RAVENS_COVE_ISLAND]: for shop in area.getShopNodes(): uid = shop.getTag('Uid') shopType = shop.getTag('ShopType') self.addObject(MinimapShop(uid, shop, shopType)) self.map.findAllMatches('**/=Holiday').stash() if base.cr.newsManager: for holiday in base.cr.newsManager.getHolidayList(): self.handleHolidayStarted( area, HolidayGlobals.getHolidayName(holiday)) self.zoomLevels = area.getZoomLevels() self.accept('landMapRadarAxisChanged', self.setRadarAxis)
def setHolidayId(self, holidayId): self.holidayId = holidayId self.name = PLocalizer.CapturePointNames[HolidayGlobals.getHolidayName(self.holidayId)][self.zone] if self.hpMeter: self.hpMeter.categoryLabel['text'] = self.name self.createCollisions()
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 setNextPhase(self, phase, message): self.currentPhase = phase self.notify.debug('setting next phase of invasion to %s' % self.currentPhase) text = PLocalizer.InvasionJollyRogerNextBrigade % ( self.currentPhase, self.totalPhases - self.currentPhase) base.localAvatar.guiMgr.messageStack.addModalTextMessage( text, seconds=10, priority=0, color=PiratesGuiGlobals.TextFG14, icon=(HolidayGlobals.getHolidayIcon(self.holidayId), ''), modelName='general_frame_f') if self.brigadeText: self.brigadeText[ 'text'] = PLocalizer.InvasionJollyRogerBrigadeUpdate % ( self.currentPhase, self.totalPhases - self.currentPhase) if self.canPlaySfx: if self.currentPhase == 1: sfx = self.startMessages[message] else: if self.currentPhase == 2: sfx = self.secondWaveMessages[message] else: if self.currentPhase == 7: sfx = self.lastWaveMessages[message] else: sfx = self.waveMessages[message] base.playSfx(sfx)
def setHolidayId(self, holidayId): self.holidayId = holidayId self.name = PLocalizer.CapturePointNames[HolidayGlobals.getHolidayName( self.holidayId)][self.zone] if self.hpMeter: self.hpMeter.categoryLabel['text'] = self.name self.createCollisions()
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 destroy(self): if self.onIsland and localAvatar.getParentObj( ) and localAvatar.getParentObj().getUniqueId( ) == InvasionGlobals.getIslandId( self.holidayId) and localAvatar.getParentObj().minimap: localAvatar.getParentObj().minimap.handleHolidayEnded( localAvatar.getParentObj(), HolidayGlobals.getHolidayName(self.holidayId), True) if self.screenNode: self.screenNode.reparentTo(localAvatar.guiMgr.minimapRoot) self.screenNode.setPos(0, 0, 0) self.screenNode.setScale(self.screenNodeScale) self.screenNode.hide() if self.panel: self.panel.destroy() self.panel = None for firePath in self.firePaths: firePath.removeNode() del firePath self.firePaths = [] DirectFrame.destroy(self)
def __init__(self, area): Map.__init__(self, "map-" + area.getName()) self.capturePoints = {} mapNode = area.getMapNode() if mapNode and not mapNode.isEmpty(): geom = mapNode.getChild(0) geom.setScale(mapNode.getScale()) geom.flattenStrong() mapNode.setScale(1) self.worldNode = mapNode self.map = self.worldNode.copyTo(NodePath()) (a, b) = self.map.getTightBounds() diff = b - a h = diff[1] w = diff[0] else: self.worldNode = area self.map = NodePath("no map found") (a, b) = self.worldNode.geom.getTightBounds() diff = b - a h = diff[1] w = diff[0] ratio = h / w if ratio < 0.98999999999999999: normalScale = 2 / w screenScale = 1 else: normalScale = 2 / h screenScale = 0.75 self.map.clearTransform() self.map.show() self.screenNode = NodePath("Minimap-screenNode") self.screenNode.setP(90) self.screenNode.setScale(screenScale * normalScale) self.screenNode.hide() self.map.reparentTo(self.screenNode) self.mapOverlay = self.map.attachNewNode("mapOverlay") self.mapOverlay.wrtReparentTo(self.screenNode) self.radarTransformNode = NodePath("radarTransform") self.radarTransformNode.setScale(self.worldNode.getScale()[0]) self.map.instanceTo(self.radarTransformNode) localAvatar.guiMgr.addMinimap(self) if self.allowOnScreen(): self.addObject(MinimapFootprint(area)) if self.allowOnScreen(): if area.getUniqueId() not in [LocationIds.RAVENS_COVE_ISLAND]: for shop in area.getShopNodes(): uid = shop.getTag("Uid") shopType = shop.getTag("ShopType") self.addObject(MinimapShop(uid, shop, shopType)) self.map.findAllMatches("**/=Holiday").stash() if base.cr.newsManager: for holiday in base.cr.newsManager.getHolidayList(): self.handleHolidayStarted(area, HolidayGlobals.getHolidayName(holiday)) self.zoomLevels = area.getZoomLevels() self.accept("landMapRadarAxisChanged", self.setRadarAxis)
def __init__(self, air, holidayId): FSM.__init__(self, '%s-FSM' % self.__class__.__name__) self.air = air self.holidayId = holidayId self.configId = HolidayGlobals.getHolidayConfig(holidayId) self.configData = FleetHolidayGlobals.FleetHolidayConfigs[self.configId] self.devTimer = config.GetBool('want-fleet-dev-timer', False) self.timerSeconds = 10 if self.devTimer else 60
def delete(self): for holidayId in HolidayGlobals.getAllHolidayIds(): taskMgr.remove('showHolidayMessage-holidayId:' + str(holidayId)) if localAvatar and localAvatar.guiMgr and localAvatar.guiMgr.mapPage: for waypointId in self.noteablePathList: localAvatar.guiMgr.mapPage.removePath(waypointId) self.cr.newsManager = None DistributedObject.DistributedObject.delete(self)
def loadEffects(self): self.editorMode = hasattr(base, 'pe') if not self.parent: return None effectSetting = None if not self.editorMode: effectSetting = base.options.getSpecialEffectsSetting() else: effectSetting = 2 for effectEntry in self.effectDict: locators = self.parent.findAllMatches('**/' + effectEntry + '*;+s') for locator in locators: if not locator.isEmpty() and locator.getNetTag('Holiday') != '': if not self.holidayLocators.has_key(effectEntry): self.holidayLocators[effectEntry] = [ locator] else: list = self.holidayLocators.get(effectEntry) list.append(locator) self.holidayLocators[effectEntry] = list self.holidayLocators.has_key(effectEntry) if not locator.isEmpty(): effectParent = locator locatorPos = locator.getPos() locatorHpr = locator.getHpr() locatorScale = locator.getScale() effects = self.effectDict.get(effectEntry) for (effectName, effectLevel) in effects: if effectLevel <= effectSetting: if isinstance(effectName, PooledEffect): effect = effectName.getEffect() effect.reparentTo(effectParent) else: effect = effectName(effectParent) if hasattr(effect, 'setEffectScale'): effect.setEffectScale(locatorScale[0]) if not effect.getNetTag('visZone'): effect.startLoop(effectSetting) self.effects.append(effect) if not self.editorMode: self.parent.builder.registerEffect(effect) if self.editorMode: return None if base.cr.newsManager: for holidayId in base.cr.newsManager.getHolidayList().iterkeys(): self.loadHolidayEffects(HolidayGlobals.getHolidayName(holidayId))
def __checkHolidays(self, task=None): holidays = HolidayGlobals.getAllHolidayIds() for holidayId in holidays: date = HolidayGlobals.getHolidayDates(holidayId) currentTime = time.time() if date is None: continue if isinstance(date, dict): continue for index in range(len(date.startDates)): start = date.getStartTime(index) end = date.getEndTime(index) if currentTime >= start and currentTime <= end: remaining = end - currentTime self.startHoliday(holidayId, time=remaining) return Task.again
def endHoliday(self, holidayId, channel=None): if not channel: if not self.isHolidayActive(holidayId): return self.activeHolidays.pop(holidayId) self.notify.info('Ending Holiday %s (%d)' % ((HolidayGlobals.getHolidayName(holidayId) or holidayId), holidayId)) self.sendUpdate('endHoliday', [holidayId]) else: if not self.isHolidayActive(holidayId, channel): return districtData = self.districts[channel] if districtData['scheduledRunning'] == holidayId: districtData['scheduledRunning'] = None self.districts[channel]['localHolidays'].pop(holidayId) self.notify.info('Ending Holiday %s (%d) on %s' % ((HolidayGlobals.getHolidayName(holidayId) or holidayId), holidayId, channel)) self.sendUpdateToChannel(channel, 'endHoliday', [holidayId])
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
def endHoliday(self, holidayId): if not self.isHolidayActive(holidayId): return self.notify.info('Ending holiday %s (%d)' % ((HolidayGlobals.getHolidayName(holidayId) or holidayId), holidayId)) self.activeHolidays.pop(holidayId) self.air.newsManager.removeHoliday(holidayId) if self.isInvasionHoliday(holidayId): self.endInvasionHoliday(holidayId) if self.isFleetHoliday(holidayId): self.endFleetHoliday(holidayId) if holidayId == HolidayGlobals.QUEENANNES: self.endQueenAnne() messenger.send('holidayDeactivated', [holidayId]) messenger.send('holidayListChanged')
def setHolidayId(self, holidayId): self.holidayId = HolidayGlobals.getHolidayClass(holidayId) self.holidayName = HolidayGlobals.getHolidayName(self.holidayId) self.totalPhases = InvasionGlobals.getTotalPhases(self.holidayId) self.mainZone = InvasionGlobals.getTotalCapturePoints(self.holidayId)
from pirates.quest.QuestConstants import NPCIds from pirates.ai import HolidayGlobals from pirates.world.LocationConstants import LocationIds from pirates.uberdog.UberDogGlobals import InventoryType JOLLY_ROGER_INVASION_SHIP = ShipGlobals.JOLLY_ROGER JOLLY_UNIQUE_ID = "1248740229.97robrusso" JOLLY_DISENGAGE_LIMIT = 1 JOLLY_DISENGAGE_TIME = 5.0 JOLLY_ATTACK_TIME = 2.0 BOSS_WAIT_TIME = 120 INVASION_PORT_ROYAL = HolidayGlobals.INVASIONPORTROYAL INVASION_TORTUGA = HolidayGlobals.INVASIONTORTUGA INVASION_DEL_FUEGO = HolidayGlobals.INVASIONDELFUEGO INVASION_IDS = [ HolidayGlobals.getHolidayName(INVASION_PORT_ROYAL), HolidayGlobals.getHolidayName(INVASION_TORTUGA), HolidayGlobals.getHolidayName(INVASION_DEL_FUEGO), ] INVASION_NUMBERS = [INVASION_PORT_ROYAL, INVASION_TORTUGA, INVASION_DEL_FUEGO] ISLAND_IDS = { INVASION_PORT_ROYAL: LocationIds.PORT_ROYAL_ISLAND, INVASION_TORTUGA: LocationIds.TORTUGA_ISLAND, INVASION_DEL_FUEGO: LocationIds.DEL_FUEGO_ISLAND, HolidayGlobals.WRECKEDGOVERNORSMANSION: LocationIds.PORT_ROYAL_ISLAND, HolidayGlobals.WRECKEDFAITHFULBRIDE: LocationIds.TORTUGA_ISLAND, HolidayGlobals.WRECKEDDELFUEGOTOWN: LocationIds.DEL_FUEGO_ISLAND, } def getIslandId(holiday):
def setNextPhase(self, phase, message): self.currentPhase = phase self.notify.debug('setting next phase of invasion to %s' % self.currentPhase) text = PLocalizer.InvasionJollyRogerNextBrigade % (self.currentPhase, self.totalPhases - self.currentPhase) base.localAvatar.guiMgr.messageStack.addModalTextMessage(text, seconds = 10, priority = 0, color = PiratesGuiGlobals.TextFG14, icon = (HolidayGlobals.getHolidayIcon(self.holidayId), ''), modelName = 'general_frame_f') if self.brigadeText: self.brigadeText['text'] = PLocalizer.InvasionJollyRogerBrigadeUpdate % (self.currentPhase, self.totalPhases - self.currentPhase) if self.canPlaySfx: if self.currentPhase == 1: sfx = self.startMessages[message] elif self.currentPhase == 2: sfx = self.secondWaveMessages[message] elif self.currentPhase == 7: sfx = self.lastWaveMessages[message] else: sfx = self.waveMessages[message] base.playSfx(sfx)
def destroy(self): if self.onIsland and localAvatar.getParentObj() and localAvatar.getParentObj().getUniqueId() == InvasionGlobals.getIslandId(self.holidayId) and localAvatar.getParentObj().minimap: localAvatar.getParentObj().minimap.handleHolidayEnded(localAvatar.getParentObj(), HolidayGlobals.getHolidayName(self.holidayId), True) if self.screenNode: self.screenNode.reparentTo(localAvatar.guiMgr.minimapRoot) self.screenNode.setPos(0, 0, 0) self.screenNode.setScale(self.screenNodeScale) self.screenNode.hide() if self.panel: self.panel.destroy() self.panel = None for firePath in self.firePaths: firePath.removeNode() del firePath self.firePaths = [] DirectFrame.destroy(self)
def getInvasionResults(self): self.results = [] mainZoneBonus = int(self.reputationEarned * InvasionGlobals.MAIN_ZONE_BONUS) enemyBonus = int(self.reputationEarned * InvasionGlobals.ENEMY_BONUS) waveBonus = self.wavesCleared * InvasionGlobals.WAVE_BONUS barricadeBonus = int(self.reputationEarned * self.barricadesSaved * InvasionGlobals.BARRICADE_BONUS) if self.wonInvasion: totalBonus = int((mainZoneBonus + enemyBonus + barricadeBonus) * (waveBonus + 1.0)) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionMainZoneSaved % PLocalizer.getInvasionMainZoneName(HolidayGlobals.getHolidayName(self.holidayId)), 'Value1': PLocalizer.InvasionNotoriety % mainZoneBonus }) else: totalBonus = int((enemyBonus + barricadeBonus) * (waveBonus + 1.0)) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionBarricadesSaved % self.barricadesSaved, 'Value1': PLocalizer.InvasionNotoriety % barricadeBonus }) if self.enemiesKilled == 1: self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionEnemyKilled, 'Value1': PLocalizer.InvasionNotoriety % enemyBonus }) else: self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionEnemiesKilled % self.enemiesKilled, 'Value1': PLocalizer.InvasionNotoriety % enemyBonus }) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionWavesCleared % self.wavesCleared, 'Value1': PLocalizer.InvasionNotorietyBonus % int(waveBonus * 100) }) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionTotalBonus, 'Value1': PLocalizer.InvasionNotoriety % totalBonus }) return self.results
def getInvasionResults(self): self.results = [] mainZoneBonus = int(self.reputationEarned * InvasionGlobals.MAIN_ZONE_BONUS) enemyBonus = int(self.reputationEarned * InvasionGlobals.ENEMY_BONUS) waveBonus = self.wavesCleared * InvasionGlobals.WAVE_BONUS barricadeBonus = int(self.reputationEarned * self.barricadesSaved * InvasionGlobals.BARRICADE_BONUS) if self.wonInvasion: totalBonus = int((mainZoneBonus + enemyBonus + barricadeBonus) * (waveBonus + 1.0)) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionMainZoneSaved % PLocalizer.getInvasionMainZoneName( HolidayGlobals.getHolidayName(self.holidayId)), 'Value1': PLocalizer.InvasionNotoriety % mainZoneBonus }) else: totalBonus = int((enemyBonus + barricadeBonus) * (waveBonus + 1.0)) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionBarricadesSaved % self.barricadesSaved, 'Value1': PLocalizer.InvasionNotoriety % barricadeBonus }) if self.enemiesKilled == 1: self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionEnemyKilled, 'Value1': PLocalizer.InvasionNotoriety % enemyBonus }) else: self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionEnemiesKilled % self.enemiesKilled, 'Value1': PLocalizer.InvasionNotoriety % enemyBonus }) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionWavesCleared % self.wavesCleared, 'Value1': PLocalizer.InvasionNotorietyBonus % int(waveBonus * 100) }) self.results.append({ 'Type': 'Entry', 'Text': PLocalizer.InvasionTotalBonus, 'Value1': PLocalizer.InvasionNotoriety % totalBonus }) return self.results
def __init__(self, holidayId, wonInvasion, reputationEarned, enemiesKilled, barricadesSaved, wavesCleared): DirectFrame.__init__(self, relief=None, parent=base.aspect2d, image=None, pos=(0.0, 0.0, 0.5)) self.holidayId = holidayId self.wonInvasion = wonInvasion self.reputationEarned = reputationEarned self.enemiesKilled = enemiesKilled self.barricadesSaved = barricadesSaved self.wavesCleared = wavesCleared self.panel = None self.onIsland = False if localAvatar.getParentObj(): if localAvatar.getParentObj().getUniqueId( ) == InvasionGlobals.getIslandId(self.holidayId): if localAvatar.getParentObj().minimap: self.onIsland = True self.firePaths = [] top_gui = loader.loadModel('models/gui/toplevel_gui') general_frame_gui = loader.loadModel( 'models/gui/general_frame') main_gui = loader.loadModel('models/gui/gui_main') background = general_frame_gui.find('**/middle') side_bar = main_gui.find('**/boarder_side') top_left = general_frame_gui.find('**/topLeft') top_right = general_frame_gui.find('**/topRight') bottom_left = general_frame_gui.find('**/bottomLeft') bottom_right = general_frame_gui.find('**/bottomRight') generic_x = main_gui.find('**/x2') generic_box = main_gui.find('**/exit_button') generic_box_over = main_gui.find('**/exit_button_over') parchment = top_gui.find('**/pir_t_gui_gen_parchment') wax_seal = top_gui.find('**/pir_t_gui_gen_waxSeal') fires = [ top_gui.find('**/pir_t_gui_gen_fire0'), top_gui.find('**/pir_t_gui_gen_fire1'), top_gui.find('**/pir_t_gui_gen_fire2') ] top_gui.removeNode() general_frame_gui.removeNode() main_gui.removeNode() if self.onIsland: topLeftBackground = OnscreenImage(parent=self, image=background, scale=0.75, pos=(0.75, 0.0, 0.0), color=(0.3, 0.3, 0.3, 1.0)) topRightBackground = OnscreenImage(parent=self, image=background, scale=0.75, pos=(1.5, 0.0, 0.0), color=(0.3, 0.3, 0.3, 1.0)) bottomLeftBackground = OnscreenImage(parent=self, image=background, scale=0.75, pos=(0.75, 0.0, -0.75), color=(0.3, 0.3, 0.3, 1.0)) bottomRightBackground = OnscreenImage(parent=self, image=background, scale=0.75, pos=(1.5, 0.0, -0.75), color=(0.3, 0.3, 0.3, 1.0)) leftBorder1 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(-0.26, 0.0, -0.53)) leftBorder2 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(-0.26, 0.0, -1.15)) rightBorder1 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.235, 0.0, -0.53)) rightBorder2 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.235, 0.0, -1.15)) topBorder1 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(0.53, 0.0, -0.26), hpr=(0, 0, -90)) topBorder2 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.15, 0.0, -0.26), hpr=(0, 0, -90)) bottomBorder1 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(0.53, 0.0, -1.765), hpr=(0, 0, -90)) bottomBorder2 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.15, 0.0, -1.765), hpr=(0, 0, -90)) topLeftCorner = OnscreenImage(parent=self, image=top_left, scale=1.0, pos=(0.12, 0.0, -0.11)) topRightCorner = OnscreenImage(parent=self, image=top_right, scale=1.0, pos=(1.38, 0.0, -0.11)) bottomLeftCorner = OnscreenImage(parent=self, image=bottom_left, scale=1.0, pos=(0.12, 0.0, -1.39)) bottomRightCorner = OnscreenImage(parent=self, image=bottom_right, scale=1.0, pos=(1.38, 0.0, -1.39)) titlePos = (0.75, 0, -0.08) resultPos = (0.75, 0, -0.17) scoreboardPos = (0.2, 0, -1.35) closePos = (1.81, 0, -1.21) else: leftBackground = OnscreenImage(parent=self, image=background, scale=0.75, pos=(0.75, 0.0, -0.375), color=(0.3, 0.3, 0.3, 1.0)) rightBackground = OnscreenImage(parent=self, image=background, scale=0.75, pos=(1.5, 0.0, -0.375), color=(0.3, 0.3, 0.3, 1.0)) leftBorder = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(-0.26, 0.0, -0.84)) rightBorder = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.235, 0.0, -0.84)) topBorder1 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(0.53, 0.0, -0.635), hpr=(0, 0, -90)) topBorder2 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.15, 0.0, -0.635), hpr=(0, 0, -90)) bottomBorder1 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(0.53, 0.0, -1.39), hpr=(0, 0, -90)) bottomBorder2 = OnscreenImage(parent=self, image=side_bar, scale=0.25, pos=(1.15, 0.0, -1.39), hpr=(0, 0, -90)) topLeftCorner = OnscreenImage(parent=self, image=top_left, scale=1.0, pos=(0.12, 0.0, -0.485)) topRightCorner = OnscreenImage(parent=self, image=top_right, scale=1.0, pos=(1.38, 0.0, -0.485)) bottomLeftCorner = OnscreenImage(parent=self, image=bottom_left, scale=1.0, pos=(0.12, 0.0, -1.015)) bottomRightCorner = OnscreenImage(parent=self, image=bottom_right, scale=1.0, pos=(1.38, 0.0, -1.015)) titlePos = (0.75, 0, -0.5) resultPos = (0.75, 0, -0.59) scoreboardPos = (0.2, 0, -0.9) closePos = (1.81, 0, -1.585) titleTxt = PLocalizer.InvasionScoreboardTitle % PLocalizer.LocationNames[ InvasionGlobals.getIslandId(self.holidayId)] title = DirectLabel( parent=self, relief=None, text=titleTxt, text_align=TextNode.ACenter, text_scale=0.07, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, pos=titlePos, text_font=PiratesGlobals.getPirateOutlineFont()) if self.wonInvasion: resultText = PLocalizer.InvasionWon else: resultText = PLocalizer.InvasionLost % PLocalizer.getInvasionMainZoneName( HolidayGlobals.getHolidayName(self.holidayId)) result = DirectLabel( parent=self, relief=None, text=resultText, text_align=TextNode.ACenter, text_scale=PiratesGuiGlobals.TextScaleTitleMed, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, pos=resultPos, text_font=PiratesGlobals.getPirateOutlineFont()) self.screenNode = None self.screenNodeScale = None if self.onIsland: parchmentImage = OnscreenImage(parent=self, image=parchment, scale=(0.8, 0, 0.95), pos=(0.75, 0, -0.7)) self.screenNode = localAvatar.getParentObj( ).minimap.getScreenNode() if self.screenNode: self.screenNode.reparentTo(self) screenInfo = InvasionGlobals.getScreenInfo(self.holidayId) self.screenNode.setPos(screenInfo[0]) self.screenNodeScale = self.screenNode.getScale() self.screenNode.setScale(screenInfo[1]) self.screenNode.show() waxSealImage = self.onIsland and self.wonInvasion and OnscreenImage( parent=self, image=wax_seal, pos=(1.27, 0, -0.95), scale=1.0) self.fireSeq = None else: for fireInfo in InvasionGlobals.getLossFires(self.holidayId): firePath = NodePath(SequenceNode('SeqNode')) firePath.setPos firePath.setScale for fireCard in fires: firePath.node().addChild(fireCard.node()) firePath.node().setFrameRate(10) firePath.node().loop(False) firePath.reparentTo(self) firePath.setPos(fireInfo[0]) firePath.setScale(fireInfo[1]) self.firePaths.append(firePath) closeButton = GuiButton.GuiButton( parent=self, relief=None, pos=closePos, image=(generic_box, generic_box, generic_box_over, generic_box), image_scale=0.6, command=localAvatar.guiMgr.removeInvasionScoreboard) xButton = OnscreenImage(parent=closeButton, image=generic_x, scale=0.3, pos=(-0.382, 0, 1.15)) self.createScoreboard(scoreboardPos) return
def __init__(self, holidayId, wonInvasion, reputationEarned, enemiesKilled, barricadesSaved, wavesCleared): DirectFrame.__init__(self, relief = None, parent = base.aspect2d, image = None, pos = (0.0, 0.0, 0.5)) self.holidayId = holidayId self.wonInvasion = wonInvasion self.reputationEarned = reputationEarned self.enemiesKilled = enemiesKilled self.barricadesSaved = barricadesSaved self.wavesCleared = wavesCleared self.panel = None self.onIsland = False if localAvatar.getParentObj() and localAvatar.getParentObj().getUniqueId() == InvasionGlobals.getIslandId(self.holidayId) and localAvatar.getParentObj().minimap: self.onIsland = True self.firePaths = [] top_gui = loader.loadModel('models/gui/toplevel_gui') general_frame_gui = loader.loadModel('models/gui/general_frame') main_gui = loader.loadModel('models/gui/gui_main') background = general_frame_gui.find('**/middle') side_bar = main_gui.find('**/boarder_side') top_left = general_frame_gui.find('**/topLeft') top_right = general_frame_gui.find('**/topRight') bottom_left = general_frame_gui.find('**/bottomLeft') bottom_right = general_frame_gui.find('**/bottomRight') generic_x = main_gui.find('**/x2') generic_box = main_gui.find('**/exit_button') generic_box_over = main_gui.find('**/exit_button_over') parchment = top_gui.find('**/pir_t_gui_gen_parchment') wax_seal = top_gui.find('**/pir_t_gui_gen_waxSeal') fires = [ top_gui.find('**/pir_t_gui_gen_fire0'), top_gui.find('**/pir_t_gui_gen_fire1'), top_gui.find('**/pir_t_gui_gen_fire2')] top_gui.removeNode() general_frame_gui.removeNode() main_gui.removeNode() if self.onIsland: topLeftBackground = OnscreenImage(parent = self, image = background, scale = 0.75, pos = (0.75, 0.0, 0.0), color = (0.29999999999999999, 0.29999999999999999, 0.29999999999999999, 1.0)) topRightBackground = OnscreenImage(parent = self, image = background, scale = 0.75, pos = (1.5, 0.0, 0.0), color = (0.29999999999999999, 0.29999999999999999, 0.29999999999999999, 1.0)) bottomLeftBackground = OnscreenImage(parent = self, image = background, scale = 0.75, pos = (0.75, 0.0, -0.75), color = (0.29999999999999999, 0.29999999999999999, 0.29999999999999999, 1.0)) bottomRightBackground = OnscreenImage(parent = self, image = background, scale = 0.75, pos = (1.5, 0.0, -0.75), color = (0.29999999999999999, 0.29999999999999999, 0.29999999999999999, 1.0)) leftBorder1 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (-0.26000000000000001, 0.0, -0.53000000000000003)) leftBorder2 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (-0.26000000000000001, 0.0, -1.1499999999999999)) rightBorder1 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.2350000000000001, 0.0, -0.53000000000000003)) rightBorder2 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.2350000000000001, 0.0, -1.1499999999999999)) topBorder1 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (0.53000000000000003, 0.0, -0.26000000000000001), hpr = (0, 0, -90)) topBorder2 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.1499999999999999, 0.0, -0.26000000000000001), hpr = (0, 0, -90)) bottomBorder1 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (0.53000000000000003, 0.0, -1.7649999999999999), hpr = (0, 0, -90)) bottomBorder2 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.1499999999999999, 0.0, -1.7649999999999999), hpr = (0, 0, -90)) topLeftCorner = OnscreenImage(parent = self, image = top_left, scale = 1.0, pos = (0.12, 0.0, -0.11)) topRightCorner = OnscreenImage(parent = self, image = top_right, scale = 1.0, pos = (1.3799999999999999, 0.0, -0.11)) bottomLeftCorner = OnscreenImage(parent = self, image = bottom_left, scale = 1.0, pos = (0.12, 0.0, -1.3899999999999999)) bottomRightCorner = OnscreenImage(parent = self, image = bottom_right, scale = 1.0, pos = (1.3799999999999999, 0.0, -1.3899999999999999)) titlePos = (0.75, 0, -0.080000000000000002) resultPos = (0.75, 0, -0.17000000000000001) scoreboardPos = (0.20000000000000001, 0, -1.3500000000000001) closePos = (1.8100000000000001, 0, -1.21) else: leftBackground = OnscreenImage(parent = self, image = background, scale = 0.75, pos = (0.75, 0.0, -0.375), color = (0.29999999999999999, 0.29999999999999999, 0.29999999999999999, 1.0)) rightBackground = OnscreenImage(parent = self, image = background, scale = 0.75, pos = (1.5, 0.0, -0.375), color = (0.29999999999999999, 0.29999999999999999, 0.29999999999999999, 1.0)) leftBorder = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (-0.26000000000000001, 0.0, -0.83999999999999997)) rightBorder = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.2350000000000001, 0.0, -0.83999999999999997)) topBorder1 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (0.53000000000000003, 0.0, -0.63500000000000001), hpr = (0, 0, -90)) topBorder2 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.1499999999999999, 0.0, -0.63500000000000001), hpr = (0, 0, -90)) bottomBorder1 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (0.53000000000000003, 0.0, -1.3899999999999999), hpr = (0, 0, -90)) bottomBorder2 = OnscreenImage(parent = self, image = side_bar, scale = 0.25, pos = (1.1499999999999999, 0.0, -1.3899999999999999), hpr = (0, 0, -90)) topLeftCorner = OnscreenImage(parent = self, image = top_left, scale = 1.0, pos = (0.12, 0.0, -0.48499999999999999)) topRightCorner = OnscreenImage(parent = self, image = top_right, scale = 1.0, pos = (1.3799999999999999, 0.0, -0.48499999999999999)) bottomLeftCorner = OnscreenImage(parent = self, image = bottom_left, scale = 1.0, pos = (0.12, 0.0, -1.0149999999999999)) bottomRightCorner = OnscreenImage(parent = self, image = bottom_right, scale = 1.0, pos = (1.3799999999999999, 0.0, -1.0149999999999999)) titlePos = (0.75, 0, -0.5) resultPos = (0.75, 0, -0.58999999999999997) scoreboardPos = (0.20000000000000001, 0, -0.90000000000000002) closePos = (1.8100000000000001, 0, -1.585) titleTxt = PLocalizer.InvasionScoreboardTitle % PLocalizer.LocationNames[InvasionGlobals.getIslandId(self.holidayId)] title = DirectLabel(parent = self, relief = None, text = titleTxt, text_align = TextNode.ACenter, text_scale = 0.070000000000000007, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = titlePos, text_font = PiratesGlobals.getPirateOutlineFont()) if self.wonInvasion: resultText = PLocalizer.InvasionWon else: resultText = PLocalizer.InvasionLost % PLocalizer.getInvasionMainZoneName(HolidayGlobals.getHolidayName(self.holidayId)) result = DirectLabel(parent = self, relief = None, text = resultText, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleTitleMed, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, pos = resultPos, text_font = PiratesGlobals.getPirateOutlineFont()) self.screenNode = None self.screenNodeScale = None if self.onIsland: parchmentImage = OnscreenImage(parent = self, image = parchment, scale = (0.80000000000000004, 0, 0.94999999999999996), pos = (0.75, 0, -0.69999999999999996)) self.screenNode = localAvatar.getParentObj().minimap.getScreenNode() if self.screenNode: self.screenNode.reparentTo(self) screenInfo = InvasionGlobals.getScreenInfo(self.holidayId) self.screenNode.setPos(screenInfo[0]) self.screenNodeScale = self.screenNode.getScale() self.screenNode.setScale(screenInfo[1]) self.screenNode.show() if self.onIsland: if self.wonInvasion: waxSealImage = OnscreenImage(parent = self, image = wax_seal, pos = (1.27, 0, -0.94999999999999996), scale = 1.0) self.fireSeq = None else: for fireInfo in InvasionGlobals.getLossFires(self.holidayId): firePath = NodePath(SequenceNode('SeqNode')) for fireCard in fires: firePath.node().addChild(fireCard.node()) firePath.node().setFrameRate(10) firePath.node().loop(False) firePath.reparentTo(self) firePath.setPos(fireInfo[0]) firePath.setScale(fireInfo[1]) self.firePaths.append(firePath) closeButton = GuiButton.GuiButton(parent = self, relief = None, pos = closePos, image = (generic_box, generic_box, generic_box_over, generic_box), image_scale = 0.59999999999999998, command = localAvatar.guiMgr.removeInvasionScoreboard) xButton = OnscreenImage(parent = closeButton, image = generic_x, scale = 0.29999999999999999, pos = (-0.38200000000000001, 0, 1.1499999999999999)) self.createScoreboard(scoreboardPos)
from pandac.PandaModules import Point3, Vec4 from pirates.quest.QuestConstants import NPCIds from pirates.ai import HolidayGlobals from pirates.world.LocationConstants import LocationIds from pirates.uberdog.UberDogGlobals import InventoryType JOLLY_ROGER_INVASION_SHIP = ShipGlobals.JOLLY_ROGER JOLLY_UNIQUE_ID = '1248740229.97robrusso' JOLLY_DISENGAGE_LIMIT = 1 JOLLY_DISENGAGE_TIME = 5.0 JOLLY_ATTACK_TIME = 2.0 BOSS_WAIT_TIME = 120 INVASION_PORT_ROYAL = HolidayGlobals.INVASIONPORTROYAL INVASION_TORTUGA = HolidayGlobals.INVASIONTORTUGA INVASION_DEL_FUEGO = HolidayGlobals.INVASIONDELFUEGO INVASION_IDS = [ HolidayGlobals.getHolidayName(INVASION_PORT_ROYAL), HolidayGlobals.getHolidayName(INVASION_TORTUGA), HolidayGlobals.getHolidayName(INVASION_DEL_FUEGO) ] INVASION_NUMBERS = [INVASION_PORT_ROYAL, INVASION_TORTUGA, INVASION_DEL_FUEGO] ISLAND_IDS = { INVASION_PORT_ROYAL: LocationIds.PORT_ROYAL_ISLAND, INVASION_TORTUGA: LocationIds.TORTUGA_ISLAND, INVASION_DEL_FUEGO: LocationIds.DEL_FUEGO_ISLAND, HolidayGlobals.WRECKEDGOVERNORSMANSION: LocationIds.PORT_ROYAL_ISLAND, HolidayGlobals.WRECKEDFAITHFULBRIDE: LocationIds.TORTUGA_ISLAND, HolidayGlobals.WRECKEDDELFUEGOTOWN: LocationIds.DEL_FUEGO_ISLAND } def getIslandId(holiday):