Settlers of EMF
Add a noddy game over screen that triggers when you end your turn with 10 points or more. Menu object was enhanced to allow multi- line questions to accomodate this.master
parent
82c0cb378c
commit
a6747e79f2
|
@ -91,6 +91,10 @@ class Menu(State):
|
||||||
self.choices = choices
|
self.choices = choices
|
||||||
self.clear_title = clear_title
|
self.clear_title = clear_title
|
||||||
if self.question:
|
if self.question:
|
||||||
|
if isinstance(self.question, list):
|
||||||
|
self.menu_offset = 100 + (20 * len(self.question))
|
||||||
|
else:
|
||||||
|
self.question = [question]
|
||||||
self.menu_offset = 120
|
self.menu_offset = 120
|
||||||
else:
|
else:
|
||||||
self.menu_offset = 100
|
self.menu_offset = 100
|
||||||
|
@ -111,7 +115,8 @@ class Menu(State):
|
||||||
else:
|
else:
|
||||||
ugfx.area(0, 95, 240, 225, ugfx.BLACK)
|
ugfx.area(0, 95, 240, 225, ugfx.BLACK)
|
||||||
if self.question:
|
if self.question:
|
||||||
ugfx.text(5, 95, self.question, ugfx.WHITE)
|
for i in range(len(self.question)):
|
||||||
|
ugfx.text(2, 95 + (i * 20), self.question[i], ugfx.WHITE)
|
||||||
offset = 0
|
offset = 0
|
||||||
for i in range(len(self.choices)):
|
for i in range(len(self.choices)):
|
||||||
self._draw_choice(i, offset)
|
self._draw_choice(i, offset)
|
||||||
|
@ -383,6 +388,12 @@ class NextPlayer(Menu):
|
||||||
super().__init__('Pass the badge to next team:', [team], False)
|
super().__init__('Pass the badge to next team:', [team], False)
|
||||||
|
|
||||||
|
|
||||||
|
class GameOver(Menu):
|
||||||
|
|
||||||
|
def __init__(self, team):
|
||||||
|
super().__init__(['Game over!', 'Congrats to the winning team:'], [team], False)
|
||||||
|
|
||||||
|
|
||||||
class Hex:
|
class Hex:
|
||||||
"""Hexes are the games tiles. They have a resource kind, correspond to the value
|
"""Hexes are the games tiles. They have a resource kind, correspond to the value
|
||||||
of a roll of two D6 and may or may not contain the robber."""
|
of a roll of two D6 and may or may not contain the robber."""
|
||||||
|
@ -1219,7 +1230,7 @@ class Settlers:
|
||||||
while self.state != Settlers.EXIT:
|
while self.state != Settlers.EXIT:
|
||||||
|
|
||||||
if self.state == Settlers.MAIN_MENU:
|
if self.state == Settlers.MAIN_MENU:
|
||||||
menu = MainMenu(self.game is None, self.old_state != Settlers.TEAM_MENU)
|
menu = MainMenu(self.game is None, self.old_state != Settlers.TEAM_MENU and self.old_state != Settlers.ACTION_END_TURN)
|
||||||
x = menu.run()
|
x = menu.run()
|
||||||
if x == MainMenu.NEW_GAME:
|
if x == MainMenu.NEW_GAME:
|
||||||
self.teams = []
|
self.teams = []
|
||||||
|
@ -1291,13 +1302,17 @@ class Settlers:
|
||||||
self.enter_state(Settlers.GAME)
|
self.enter_state(Settlers.GAME)
|
||||||
|
|
||||||
elif self.state == Settlers.ACTION_END_TURN:
|
elif self.state == Settlers.ACTION_END_TURN:
|
||||||
|
if self.game.player.score() >= 10:
|
||||||
|
menu = GameOver(self.game.player.team)
|
||||||
|
menu.run()
|
||||||
|
self.game = None
|
||||||
|
self.enter_state(Settlers.MAIN_MENU)
|
||||||
|
else:
|
||||||
self.game.next_player()
|
self.game.next_player()
|
||||||
menu = NextPlayer(self.game.player.team)
|
menu = NextPlayer(self.game.player.team)
|
||||||
menu.run()
|
menu.run()
|
||||||
self.enter_state(Settlers.GAME)
|
self.enter_state(Settlers.GAME)
|
||||||
|
|
||||||
# TODO: Game over!
|
|
||||||
|
|
||||||
# User chose exit, a machine reset is the easiest way :-)
|
# User chose exit, a machine reset is the easiest way :-)
|
||||||
restart_to_default()
|
restart_to_default()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue