def __init__(self, marathon): """ Initialize the Marathon Screen """ PygameScreen.__init__(self) self.marathon = marathon self.backgroundImage = load_image(GetImagePath("Marathons/Kanto_Gym_Leaders.jpg")) self.congratsLabel = Label("Congratulations! You Won!") self.descriptionLabel = Label(marathon.description)
def __init__(self, marathon): """ Initialize the Marathon Screen """ PygameScreen.__init__(self) self.marathon = marathon self.backgroundImage = load_image( GetImagePath("Marathons/Kanto_Gym_Leaders.jpg")) self.congratsLabel = Label("Congratulations! You Won!") self.descriptionLabel = Label(marathon.description)
def __init__(self, entry, width, height): """ Initialize the widget """ MenuEntryWidget.__init__(self, entry, fontSize=28, width=width, height=height) self.entry = entry attack = self.entry.attack self.typeImage = TypeImage(attack.type) self.ppTextLabel = Label("PP", size=18) self.ppValuesLabel = Label("{0}/{1}".format(attack.currPowerPoints, attack.powerPoints), size=18)
def __init__(self, menu): """ """ PygameScreen.__init__(self) self.menu = menu self.commandLabels = [] self.keyLabels = [] for cmd in self.bindingsOrder: self.commandLabels.append( Label(self.menu.cmdStrings[cmd], bold=True)) self.keyLabels.append(Label(self.menu.keyBindings[cmd]))
def __init__(self, menu, currentPlayer): """ """ PygameScreen.__init__(self) self.currentPlayer = currentPlayer self.menu = menu self.logo = Logo() name = "None" if currentPlayer is not None: name = currentPlayer.fullname self.playerLabel = Label("{0}: {1}".format("Player", name), size=24, color=(0, 0, 0)) self.menuView = MainMenuWidget(menu)
class PokemonStatsView(MenuEntryWidget): """ View for a Pokemon's Stats in a Battle """ FONT_SIZE = 24 def __init__(self, width, height, pokemon=None, pokemonMenuEntry=None, showHP=True): """ Initialize the Pokemon Stats View """ if pokemon is not None: self.pokemon = pokemon pokemonMenuEntry = PokemonMenuEntry(self.pokemon, None) else: self.pokemon = pokemonMenuEntry.getPokemon() MenuEntryWidget.__init__(self, pokemonMenuEntry, width, height, fontSize=self.FONT_SIZE) self.showHP = showHP self.setLevelLabel() self.setHealthLabel() self.healthBarView = HealthBarView(self.pokemon, width, height*.1) def setLevelLabel(self): """ Set the Level Label """ self.levelLabel = Label("Lv. {0}".format(self.pokemon.getLevel()), size=self.FONT_SIZE) def setHealthLabel(self): """ Set the Health Label """ hpString = "{0}/{1}".format(self.pokemon.getCurrHP(), self.pokemon.getStat("HP")) self.healthLabel = Label(hpString, size=self.FONT_SIZE) def drawSurface(self): """ Draw the Pokemon Stats View """ pkmnSurface = self.mainLabel.draw() self.drawOnSurface(pkmnSurface, left=0, top=0) levelSurface = self.levelLabel.draw() self.drawOnSurface(levelSurface, right=1, top=0) healthBarSurface = self.healthBarView.draw() self.drawOnSurface(healthBarSurface, left=0, top=(pkmnSurface.get_height()+10.0)/self.height) if self.showHP: healthSurface = self.healthLabel.draw() self.drawOnSurface(healthSurface, right=1, top=(pkmnSurface.get_height()+healthBarSurface.get_height()+15.0)/self.height) def update(self): """ Update the Pokemon Stats View """ MenuEntryWidget.update(self) self.setLevelLabel() self.setHealthLabel()
class MenuEntryWidget(SizedWidget): """ Represents an entry in the menu """ def __init__(self, entry, width, height, fontSize=36): """ Sets the entry's text """ SizedWidget.__init__(self, width, height) self.mainLabel = Label(entry.getText(), size=fontSize) self.entry = entry def update(self): """ Update the Entry Widget """ self.mainLabel.setBold(self.entry.selected) self.mainLabel.setText(self.entry.getText()) def drawSurface(self): """ Draw the Widget """ self.drawOnSurface(self.mainLabel.draw(), centerx=.5, centery=.5)
class AttackMenuEntryWidget(MenuEntryWidget): """ Represents the widget for an Attack Menu Entry """ def __init__(self, entry, width, height): """ Initialize the widget """ MenuEntryWidget.__init__(self, entry, fontSize=28, width=width, height=height) self.entry = entry attack = self.entry.attack self.typeImage = TypeImage(attack.type) self.ppTextLabel = Label("PP", size=18) self.ppValuesLabel = Label("{0}/{1}".format(attack.currPowerPoints, attack.powerPoints), size=18) def drawSurface(self): """ Draw the Widget """ self.drawOnSurface(self.mainLabel.draw(), centerx=.5, centery=.3) self.drawOnSurface(self.typeImage.draw(), centerx=.3, centery=.65) self.drawOnSurface(self.ppTextLabel.draw(), left=.5, centery=.65) self.drawOnSurface(self.ppValuesLabel.draw(), right=.8, centery=.65)
class MarathonScreen(PygameScreen): """ Screen for a Pokemon Marathon """ def __init__(self, marathon): """ Initialize the Marathon Screen """ PygameScreen.__init__(self) self.marathon = marathon self.backgroundImage = load_image(GetImagePath("Marathons/Kanto_Gym_Leaders.jpg")) self.congratsLabel = Label("Congratulations! You Won!") self.descriptionLabel = Label(marathon.description) def drawSurface(self): """ Draw the screen """ self.drawOnSurface(self.backgroundImage, left=0, top=0) if self.marathon.beaten(): labelSurface = self.congratsLabel.draw() else: labelSurface = self.descriptionLabel.draw() self.drawOnSurface(labelSurface, left=.05, centery=.1) def update(self): """ Do Nothing """
class MarathonScreen(PygameScreen): """ Screen for a Pokemon Marathon """ def __init__(self, marathon): """ Initialize the Marathon Screen """ PygameScreen.__init__(self) self.marathon = marathon self.backgroundImage = load_image( GetImagePath("Marathons/Kanto_Gym_Leaders.jpg")) self.congratsLabel = Label("Congratulations! You Won!") self.descriptionLabel = Label(marathon.description) def drawSurface(self): """ Draw the screen """ self.drawOnSurface(self.backgroundImage, left=0, top=0) if self.marathon.beaten(): labelSurface = self.congratsLabel.draw() else: labelSurface = self.descriptionLabel.draw() self.drawOnSurface(labelSurface, left=.05, centery=.1) def update(self): """ Do Nothing """
class MainMenuScreen(PygameScreen): """ Represents the Main Menu screen """ def __init__(self, menu, currentPlayer): """ """ PygameScreen.__init__(self) self.currentPlayer = currentPlayer self.menu = menu self.logo = Logo() name = "None" if currentPlayer is not None: name = currentPlayer.fullname self.playerLabel = Label("{0}: {1}".format("Player", name), size=24, color=(0, 0, 0)) self.menuView = MainMenuWidget(menu) def drawSurface(self): """ Draws the screen to the provided window """ self.drawMap() self.drawOnSurface(self.playerLabel.draw(), right=1, top=0) self.drawLogo() self.drawMenu() def drawMap(self): """ Draws the map to the window """ mapSurface = map.draw() self.drawOnSurface(mapSurface, left=0, top=0) def drawLogo(self): """ Draws the Logo to the window """ logoSurface = self.logo.draw() self.drawOnSurface(logoSurface, centerx=.5, centery=.25) def drawMenu(self): """ Draws the Menu to the window """ menuSurface = self.menuView.draw() self.drawOnSurface(menuSurface, centerx=.5, centery=11.0/16)
class MainMenuScreen(PygameScreen): """ Represents the Main Menu screen """ def __init__(self, menu, currentPlayer): """ """ PygameScreen.__init__(self) self.currentPlayer = currentPlayer self.menu = menu self.logo = Logo() name = "None" if currentPlayer is not None: name = currentPlayer.fullname self.playerLabel = Label("{0}: {1}".format("Player", name), size=24, color=(0, 0, 0)) self.menuView = MainMenuWidget(menu) def drawSurface(self): """ Draws the screen to the provided window """ self.drawMap() self.drawOnSurface(self.playerLabel.draw(), right=1, top=0) self.drawLogo() self.drawMenu() def drawMap(self): """ Draws the map to the window """ mapSurface = map.draw() self.drawOnSurface(mapSurface, left=0, top=0) def drawLogo(self): """ Draws the Logo to the window """ logoSurface = self.logo.draw() self.drawOnSurface(logoSurface, centerx=.5, centery=.25) def drawMenu(self): """ Draws the Menu to the window """ menuSurface = self.menuView.draw() self.drawOnSurface(menuSurface, centerx=.5, centery=11.0 / 16)
def setHealthLabel(self): """ Set the Health Label """ hpString = "{0}/{1}".format(self.pokemon.getCurrHP(), self.pokemon.getStat("HP")) self.healthLabel = Label(hpString, size=self.FONT_SIZE)
class PokemonStatsView(MenuEntryWidget): """ View for a Pokemon's Stats in a Battle """ FONT_SIZE = 24 def __init__(self, width, height, pokemon=None, pokemonMenuEntry=None, showHP=True): """ Initialize the Pokemon Stats View """ if pokemon is not None: self.pokemon = pokemon pokemonMenuEntry = PokemonMenuEntry(self.pokemon, None) else: self.pokemon = pokemonMenuEntry.getPokemon() MenuEntryWidget.__init__(self, pokemonMenuEntry, width, height, fontSize=self.FONT_SIZE) self.showHP = showHP self.setLevelLabel() self.setHealthLabel() self.healthBarView = HealthBarView(self.pokemon, width, height * .1) def setLevelLabel(self): """ Set the Level Label """ self.levelLabel = Label("Lv. {0}".format(self.pokemon.getLevel()), size=self.FONT_SIZE) def setHealthLabel(self): """ Set the Health Label """ hpString = "{0}/{1}".format(self.pokemon.getCurrHP(), self.pokemon.getStat("HP")) self.healthLabel = Label(hpString, size=self.FONT_SIZE) def drawSurface(self): """ Draw the Pokemon Stats View """ pkmnSurface = self.mainLabel.draw() self.drawOnSurface(pkmnSurface, left=0, top=0) levelSurface = self.levelLabel.draw() self.drawOnSurface(levelSurface, right=1, top=0) healthBarSurface = self.healthBarView.draw() self.drawOnSurface(healthBarSurface, left=0, top=(pkmnSurface.get_height() + 10.0) / self.height) if self.showHP: healthSurface = self.healthLabel.draw() self.drawOnSurface(healthSurface, right=1, top=(pkmnSurface.get_height() + healthBarSurface.get_height() + 15.0) / self.height) def update(self): """ Update the Pokemon Stats View """ MenuEntryWidget.update(self) self.setLevelLabel() self.setHealthLabel()
def setLevelLabel(self): """ Set the Level Label """ self.levelLabel = Label("Lv. {0}".format(self.pokemon.getLevel()), size=self.FONT_SIZE)
def __init__(self, entry, width, height, fontSize=36): """ Sets the entry's text """ SizedWidget.__init__(self, width, height) self.mainLabel = Label(entry.getText(), size=fontSize) self.entry = entry