Skip to content

Commit

Permalink
The next enemy in an adventure now spawns after reading
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <oleherman93@gmail.com>
  • Loading branch information
olehermanse committed Jun 9, 2019
1 parent a1c0e62 commit 329f355
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 3 additions & 6 deletions mrpg/core/game.py
Expand Up @@ -99,7 +99,9 @@ def battle_menu_choice(self, choice):
self.progress()

def progress(self):
if self.adventure and not self.battle:
if not self.adventure and self.state == State.BATTLE:
self.set_state(State.GAME_MENU)
elif self.adventure and not self.battle:
self.progress_adventure()
elif self.battle.is_over():
self.end_battle()
Expand Down Expand Up @@ -129,11 +131,6 @@ def end_battle(self):
single_newline(out)
self.put_output(out)

if self.adventure:
self.progress()
else:
self.set_state(State.GAME_MENU)

def new_battle(self):
enemy = self.adventure.next_monster()
self.put_output("A wild {} appeared".format(enemy.name))
Expand Down
8 changes: 7 additions & 1 deletion mrpg/gui/controller.py
Expand Up @@ -53,7 +53,8 @@ def update_text(self):
if not self.gui.has_output():
self.gui.display.text = self.game.player.string_long()
elif state == State.BATTLE:
self.gui.display.text = self.game.battle.stats()
if self.game.battle:
self.gui.display.text = self.game.battle.stats()
else:
raise AssertionError

Expand All @@ -79,6 +80,11 @@ def progress_to_output(self):
output = self.resolve_to_output()
if output:
return output
if self.game.adventure and not self.game.battle:
self.game.progress()
output = self.resolve_to_output()
if output:
return output
return None

def update_choices(self):
Expand Down

0 comments on commit 329f355

Please sign in to comment.