def __init__(self, dungeon, victory, **kwargs): super().__init__(**kwargs) self.victory = victory self.dungeon = dungeon self.width = self.REL_WIDTH * constants.MENU_SCALE self.height = self.REL_HEIGHT * constants.MENU_SCALE self.x = (self.game.width - self.width) / 2 self.y = (self.game.height - self.height) / 2 text_x = self.x + 5 * constants.MENU_SCALE text_y = self.y + 5 * constants.MENU_SCALE if victory: top_text = self._get_win_text() else: top_text = self._get_lose_text() self.text = wgt.TextLines( renderer=self.game.renderer, color=constants.WHITE, size=5 * constants.MENU_SCALE, offset=(text_x, text_y), text=(*top_text, "Time: " + time_to_str(dungeon.game_time), "You killed " + pluralise(dungeon.kills, "creature") + ".", " ", "Space to continue playing" if self.victory else "Space to play again", "Escape to finish run" if self.victory else "Space to return to the Main Menu"))
def _get_lose_text(self): """Return a string of what to display if the player loses.""" return ( "You lose!", "You completed " + pluralise(self._get_completed_levels(), "level") + ".", "You were killed by :PLACEHOLDER:." # Will implement this, probably by adding an AttackedBy component. )
def _get_win_text(self): """Return a string of what to display if the player wins.""" return ("You win!", "You completed " + pluralise(self._get_completed_levels(), "level") + ".")