commit 59f9ee1172e4954d6e12fee3415d3ad729ce713d
parent ff1497f79f3a7b59d1b5549cf11117c51795201c
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Sat, 24 Oct 2020 17:01:42 -0500
Enumify game effects
Diffstat:
4 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/data/json/menus/mainmenu.json b/data/json/menus/mainmenu.json
@@ -10,7 +10,7 @@
"intlayer" : 0,
"effects" : [
{
- "call" : "ef_switch_mode",
+ "call" : "ef_game_switch_mode",
"data" : "Battle_Mode"
}
]
@@ -22,7 +22,7 @@
"intlayer" : 0,
"effects" : [
{
- "call" : "ef_switch_mode",
+ "call" : "ef_game_switch_mode",
"data" : "Still_Scene_Mode"
}
]
@@ -34,7 +34,7 @@
"intlayer" : 0,
"effects" : [
{
- "call" : "ef_quit",
+ "call" : "ef_game_quit",
"data" : null
}
]
diff --git a/data/json/scenes/testscene.json b/data/json/scenes/testscene.json
@@ -41,7 +41,7 @@
],
"effects" : [
{
- "call" : "ef_switch_mode",
+ "call" : "ef_game_switch_mode",
"data" : "Battle_Mode"
}
]
diff --git a/src/constants.py b/src/constants.py
@@ -39,3 +39,4 @@ SCENE_JSON_PATH = os.path.join(JSON_PATH, "scenes")
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 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')
diff --git a/src/manager.py b/src/manager.py
@@ -6,18 +6,11 @@ from .constants import *
# manager.py #
##############
-# TODO:
-# 1. A "ManagerBus()" object should be defined in this file.
-# 2. Possibly rename "Manager" to "Subsystem"? idk, maybe a bad idea...
-# 3. As opposed to 2, it is possible that Subsystem should be reimplemented, and that Manager should source from it. GameInterface and ManagerBus
-# are both sufficiently different from what the abstract concept of a Manager is that they should probably be something else entirely. A generic
-# Subsystem object would be the simplest possible Game-component object, and would likely simply have a reference to its game and nothing else.
# Possible extensions:
# 1. An "update_managed(self, surface = None)" method prototype to be overridden in child objects. This method would handle all logic that involves
# updating the objects that a manager manages, and thus would have to be tailored to the specific manager. Implementation advantage would be that
# managers could be called together as a group to update in game, and could possibly be stored in a dict rather than have individual attributes
# they are associated with (would be very useful if implementing the ManagerBus() object).
-# 2. An "activated" bool value and associated setgets that would be used to determine whether or not a manager should update during an update pass.
# 3. Support for a ManagerBus() object (details pending, refer to main.py)
# 4. A generic "trigger_effects(self, effect_list)" method. This would implement a regularized form of the methods already present in SceneManager
# and MenuManager. It would rely on a regular style of effect-encoding in JSONs, but that already exists in the codebase and so far seems general
@@ -83,9 +76,9 @@ class Manager(subsystem.GameSubsystem):
# effect_list is ALWAYS a LIST of DICTS
if self.activated and self.effectual:
for ef in effect_list:
- if ef["call"] == "ef_quit":
+ if ef["call"] == GAME_EFFECTS.ef_game_quit.name:
self.game.quit_game()
- elif ef["call"] == "ef_switch_mode":
+ elif ef["call"] == GAME_EFFECTS.ef_game_switch_mode.name:
self.game.switch_mode(STATE_MODES[ef["data"]])
def update_managed(self, surface):