Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit 24347008c0578acab957980cbba01ddc0dbab155
parent 45978f1f80e8ebabb4395393914f9120fce0a697
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon,  1 Feb 2021 18:10:11 -0600

basic gameplay loop now going!

Diffstat:
Mdata/board/testbase1/testbase1.json | 2+-
Msrc/base.py | 10+++++-----
Msrc/bus.py | 2++
Msrc/game.py | 4+++-
Msrc/interface.py | 7++++++-
Msrc/piece.py | 9+++++++++
Msrc/turn.py | 1+
7 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/data/board/testbase1/testbase1.json b/data/board/testbase1/testbase1.json @@ -2,7 +2,7 @@ "gatekeeperent" : { "name" : "Bidru", "type" : "Normal", - "sheet" : "Jisella_1", + "sheet" : "jisella_1", "sprite" : [0, 0], "visible" : true, "animation" : "stand_L", diff --git a/src/base.py b/src/base.py @@ -39,7 +39,7 @@ class BaseManager(manager.Manager): """ Load the base from a given definition JSON. """ - with open(os.path.join("data", "board", basename, basename + ".json")) as f: definiton = json.load(f) + with open(os.path.join("data", "board", basename, basename + ".json")) as f: definition = json.load(f) for e in definition: work = copy.deepcopy(definition[e]) if work["type"] == "Normal": @@ -50,7 +50,7 @@ class BaseManager(manager.Manager): n_occ = work["occupied"] n_spec = {} for k in work["spec"]: - n_spec[int(k)] = work["spec"][l] + n_spec[int(k)] = work["spec"][k] n_react = work["ereact"] ne = BaseEntity(self, n_react, n_spec, n_occ, n_sheet, n_sprite, n_anim, n_animated) ne.assign_tile(tuple(work["tile"]), self.bus.fetch("board_manager", "board_tile_layer")[tuple(work["tile"])]) @@ -104,11 +104,11 @@ class BaseManager(manager.Manager): if ent != None and ent.event_react: for e in ent.event_spec: if e == self.current_event_stage: - self.game.control_mode = CTRL_MODE.Base_Dialog + self.game.control_mode = CTRL_MODES.Base_Dialog self.bus.perform_scene_manager_load_scene_from_file(ent.event_spec[e]) return - if -1 in self.event_spec.keys(): - self.game.control_mode = CTRL_MODE.Base_Dialog + if -1 in ent.event_spec.keys(): + self.game.control_mode = CTRL_MODES.Base_Dialog self.bus.perform_scene_manager_load_scene_from_file(ent.event_spec[-1]) def update_managed(self, surface = None): diff --git a/src/bus.py b/src/bus.py @@ -119,6 +119,8 @@ class ManagerBus(subsystem.GameSubsystem): self.game.piece_manager.execute_guard(piece) def perform_piece_manager_kill_piece(self, piece): self.game.piece_manager.kill_piece(piece) + def perform_piece_manager_reset_state(self): + self.game.piece_manager.reset_state() def perform_base_manager_position_tile_cursor(self, tile_pos): self.game.base_manager.position_tile_cursor(tile_pos) def perform_click_base_entity_at_pos(self, pos): diff --git a/src/game.py b/src/game.py @@ -88,7 +88,7 @@ class Game(object): elif new_mode == STATE_MODES.Base_Mode: self.control_mode = CTRL_MODES.Base_Normal self.board_manager.load_board(data) - self.base_manager.load_base_from_file(data) + self.base_manager.load_base(data) self.base_manager.load_ui_elements() self.camera.load_camera_surface(self.board_manager.current_board.pixel_dimensions) elif new_mode == STATE_MODES.Battle_Mode: @@ -150,6 +150,8 @@ class Game(object): self.board_manager.update(self.camera.camera_surface) self.base_manager.update(self.camera.camera_surface) self.camera.update_camera(self.screen) + if self.control_mode == CTRL_MODES.Base_Dialog: + self.scene_manager.update(self.screen) elif self.state_mode == STATE_MODES.Battle_Mode: self.board_manager.update(self.camera.camera_surface) self.piece_manager.update(self.camera.camera_surface) diff --git a/src/interface.py b/src/interface.py @@ -109,7 +109,12 @@ class GameInterface(subsystem.GameSubsystem): if self.game.state_mode == STATE_MODES.Base_Mode: # Check for clicking on base entities - self.bus.perform_click_base_entity_at_pos(mouseraw) + if self.game.control_mode == CTRL_MODES.Base_Normal: + self.bus.perform_click_base_entity_at_pos(mousepos) + + # Handle cycling script segments during scenes in base mode + elif self.game.control_mode == CTRL_MODES.Base_Dialog: + self.bus.perform_continue_current_scene_script() # Battle mode behavior elif self.game.state_mode == STATE_MODES.Battle_Mode: diff --git a/src/piece.py b/src/piece.py @@ -44,6 +44,15 @@ class PieceManager(manager.Manager): """ self.pieces.add(piece) + def reset_state(self): + """ + Reset the piece manager to a just-loaded + state. + """ + self.pieces = pygame.sprite.LayeredDirty() + self.selected_piece = None + self.load_ui_elements() + def load_pieces_from_def(self, definition): """ Loaded one or more pieces from a definition diff --git a/src/turn.py b/src/turn.py @@ -373,6 +373,7 @@ class TurnManager(manager.Manager): elif self.game.control_mode == CTRL_MODES.Battle_Resolve: # TODO: Should be a delay and animation, plus displaying post battle info like loot self.game.switch_mode(STATE_MODES.Base_Mode, "testbase1") + self.bus.perform_piece_manager_reset_state() ############################# # Section 2 - Turn Entities #