Return to repo list

heart-of-gold

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

commit 4b225ef023480504ae18a712b5221cc68ca3216c
parent 2320892d389a6149cd98fa30c472bd2bd4e65982
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon, 28 Dec 2020 13:48:57 -0600

progress toward dialog functionality

Diffstat:
Adata/json/scenes/testdia.json | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/bus.py | 2++
Msrc/constants.py | 2+-
Msrc/game.py | 2++
Msrc/interface.py | 7+++++++
Msrc/manager.py | 2++
Msrc/turn.py | 7+++++++
7 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/data/json/scenes/testdia.json b/data/json/scenes/testdia.json @@ -0,0 +1,49 @@ +{ + "name" : "TestDialog", + "fonts" : { + "A" : ["ArchivoNarrow-Regular.otf", 28] + }, + "bg_sheet" : null, + "bg_sprite" : null, + "script" : [ + { + "speaker" : "Jisella", + "name_font" : "A", + "name_pos" : [20, 480], + "line_font" : "A", + "voice" : null, + "portrait" : "jisella_actor_portrait", + "line" : "Hello there. How are you doing today? I'm fine, thanks for asking.", + "characters" : [ + { + "name" : "jisella", + "flipped" : true, + "pos" : [70, 118], + "actor" : [ + { "sheet" : "base", "sprite" : [0, 0] }, + { "sheet" : "eyes", "sprite" : [1, 2] }, + { "sheet" : "mouth", "sprite" : [1, 0] }, + { "sheet" : "brows", "sprite" : [0, 0] } + ] + } + ], + "effects" : [ ] + }, + { + "speaker" : "", + "name_font" : "A", + "name_pos" : [20, 480], + "line_font" : "A", + "voice" : null, + "portrait" : null, + "line" : "", + "characters" : [ ], + "effects" : [ + { + "call" : "ef_game_switch_control", + "data" : "Turn_Normal" + } + ] + } + ] +} 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_scene_manager_load_scene_from_file(self, scenefile): + self.game.scene_manager.load_still_scene_from_file(scenefile) def perform_continue_current_scene_script(self): self.game.scene_manager.current_scene.continue_script() def perform_display_move_range_of_piece(self, piece): diff --git a/src/constants.py b/src/constants.py @@ -91,7 +91,7 @@ OTHER_STATS = ["HP", "EXP", "LVL", "RNK"] STATE_MODES = enum.Enum('STATE_MODES', 'Main_Menu_Mode Battle_Mode Still_Scene_Mode') CTRL_MODES = enum.Enum('CTRL_MODES', 'No_Control Main_Menu_Normal Turn_Normal Turn_Select_Move Turn_Select_Attack Turn_Watch_Move Turn_Watch_Attack Turn_Display_Stats Turn_Watch_Guard Battle_Dialog Still_Scene_Normal') FACE_DIR = enum.Enum('FACE_DIR', 'U D L R') -GAME_EFFECTS = enum.Enum('GAME_EFFECTS', 'ef_game_quit ef_game_switch_mode') +GAME_EFFECTS = enum.Enum('GAME_EFFECTS', 'ef_game_quit ef_game_switch_mode ef_game_switch_control') ATTACK_NOTATIONS = enum.Enum('ATTACK_NOTATIONS', 'backattack critical counter opposite weakness resist riposte ignoredef parry block sweep miss onetwo stun') # Error types diff --git a/src/game.py b/src/game.py @@ -146,6 +146,8 @@ class Game(object): # moving entity caused by the drawing order. if self.control_mode == CTRL_MODES.Turn_Watch_Move: self.camera.snap_to_position(self.turn_manager.current_active_piece.rect.center) + elif self.control_mode == CTRL_MODES.Battle_Dialog: + self.scene_manager.update(self.camera.camera_surface) self.camera.update_camera(self.screen) self.turn_manager.update(self.screen) # Draw to the screen since it manages UI elements elif self.state_mode == STATE_MODES.Still_Scene_Mode: diff --git a/src/interface.py b/src/interface.py @@ -147,6 +147,13 @@ class GameInterface(subsystem.GameSubsystem): self.game.control_mode = CTRL_MODES.Turn_Watch_Attack self.bus.perform_load_board_overlay() + # StillScene in-battle dialog options + elif self.game.control_mode == CTRL_MODES.Battle_Dialog: + + # Normal still-scene control + if self.game.control_mode == CTRL_MODES.Still_Scene_Normal: + self.bus.perform_continue_current_scene_script() + # Still-scene mode behavior elif self.game.state_mode == STATE_MODES.Still_Scene_Mode: diff --git a/src/manager.py b/src/manager.py @@ -101,6 +101,8 @@ class Manager(subsystem.GameSubsystem): # be whatever game needs for that particular mode (even compound data types such as list/dict) elif ef["call"] == GAME_EFFECTS.ef_game_switch_mode.name: self.game.switch_mode(STATE_MODES[ef["data"][0]], ef["data"][1]) + elif ef["call"] == GAME_EFFECTS.ef_game_switch_control: + self.game.control_mode = CTRL_MODES[ef["data"]] def update(self, surface): """ diff --git a/src/turn.py b/src/turn.py @@ -232,6 +232,13 @@ class TurnManager(manager.Manager): self.in_play_pieces.pop(self.in_play_pieces.index(piece)) self.project_turn_order() + def play_battle_dialog(self, scenefile): + """ + Play a dialog scene in mid-battle. + """ + self.game.control_mode = CTRL_MODES.Battle_Dialog + self.bus.perform_scene_manager_load_scene_from_file(scenefile) + def refresh_turn_state(self): """ Refresh the entire state of the turn