Skip to content

Commit

Permalink
Fix some flag setting bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoes01 committed Apr 21, 2019
1 parent 2a82ca9 commit ef57040
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
28 changes: 20 additions & 8 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@
class GameWorld(world.CustomWorld):
def __init__(self):
super().__init__()
' Flags. '
self.create_dijkstra_map = False
self.debug_mode = False
self.events = []
self.generate_map = False
self.pop_state = False
self.reset_game = False
self.victory = False
self.view_log = False

' Data. '
self.debug_mode = False # This one is a toggle
self.events = []
self.key = None
self.messages = []
self.messages_offset = 0
self.mouse_pos = None
self.pop_state = False
self.popup_menus = []
self.redraw = False
self.reset_game = False
self.redraw = False # This information needs to communicate cross-tick
self.state_stack = ['Exit', 'MainMenu']
self.ticker = 0
self.victory = False
self.view_log = False


' Objects. '
self.cursor = Cursor()
self.map = Map()

Expand All @@ -32,6 +36,14 @@ def state(self):
@property
def turn(self):
return self.ticker // 10

def reset_flags(self):
self.create_dijkstra_map = False
self.generate_map = False
self.pop_state = False
self.reset_game = False
self.victory = False
self.view_log = False

class Cursor():
def __init__(self):
Expand Down
5 changes: 3 additions & 2 deletions processors/final.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ def __init__(self):

def process(self):
if self.world._entities and self.world.reset_game:
self.world.reset_game = False
self.world.clear_database()
self.world.clear_database()

self.world.reset_flags()
15 changes: 3 additions & 12 deletions processors/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ def process(self):
if self.world.state == 'Game':
if self.world.pop_state:
self.world.state_stack.pop()
self.world.pop_state = False
self.world.reset_game = True
if self.world.component_for_entity(1, PlayerComponent).killed:
self.world.remove_component(1, PlayerComponent)
self.world.state_stack.append('GameOver')
if self.world.popup_menus:
self.world.state_stack.append('PopupMenu')
if self.world.generate_map:
self.world.generate_map = False
if self.world.victory:
self.world.victory = False
self.world.state_stack.append('VictoryScreen')
if self.world.view_log:
self.world.view_log = False
self.world.state_stack.append('ViewLog')
if self.world.cursor.active:
self.world.state_stack.append('Look')
Expand All @@ -36,35 +31,31 @@ def process(self):
if self.world.pop_state:
self.world.state_stack.pop() # Pop to Game
self.world.state_stack.pop() # Pop to MainMenu
self.world.pop_state = False
self.world.reset_game = True

elif self.world.state == 'Look':
if self.world.pop_state:
self.world.state_stack.pop()
self.world.pop_state = False
self.world.cursor.active = False

elif self.world.state == 'MainMenu':
if self.world.generate_map:
self.world.generate_map = False
self.world.state_stack.append('Game')
if self.world.pop_state:
self.world.state_stack.pop()
self.world.pop_state = False

elif self.world.state == 'PopupMenu':
if not self.world.popup_menus:
self.world.state_stack.pop()
if self.world.pop_state:
self.world.state_stack.pop()

elif self.world.state == 'VictoryScreen':
if self.world.pop_state:
self.world.state_stack.pop() # Pop to Game
self.world.state_stack.pop() # Pop to MainMenu
self.world.pop_state = False
self.world.reset_game = True

elif self.world.state == 'ViewLog':
if self.world.pop_state:
self.world.state_stack.pop()
self.world.pop_state = False
self.world.state_stack.pop()

0 comments on commit ef57040

Please sign in to comment.