Return to repo list

tzed

Simple story-driven open world 2D CRPG.
Return to HMagellan.com

commit eae4a0e3713ae0508e05e1d4cdd5eef3766517d2
parent 619a32778d24e393b6e7e1e9c4810177d2c3dc8f
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue, 31 Aug 2021 01:06:17 -0500

npc skel work

Diffstat:
Msrc/entity.py | 34++++++++++++++++++++++++++++++++++
Msrc/game.py | 10+++++++---
2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/src/entity.py b/src/entity.py @@ -145,3 +145,37 @@ class PlayerEntity(DynamicEntity): # Parent intialization super().__init__(image, cellpos, tilepos, pixcolor) + +class NPCEntity(DynamicEntity): + """ + Class that represents the non-player character + in locations. + """ + + def __init__(self, image, cellpos, tilepos, pixcolor = None, npc_def = {}): + + # Parent intialization + super().__init__(image, cellpos, tilepos, pixcolor) + + # Definition vals + self.definition = npc_def + + def get_conversation_string(self, convo_option = None, flags = None): + """ + Return the conversation string associated + with this NPC, checking progress flags for + any modifications. + """ + # TODO: The way convo trees should work should be recursive. Each NPC flag + # could be associated with a unique string that could be keyed to a line + # in the npc_def's convos dict. This dict could have at least one key + # called 'default' and one or more others with a unique name, each being + # associated with a flag that is defined as part of the scenario. Each + # of these keys will have a 'default' key and associated convo string, + # along with one or more other keys ALSO associated with named flags. + # The convo tree should then be read recursively, and this would allow + # there to be a true heirarchy of conversations. + # NOTE: Maybe this is a bad/half-baked idea... Convo options should be taken + # into account... + pass + diff --git a/src/game.py b/src/game.py @@ -60,8 +60,11 @@ class Game(object): self.clock_element = None self.clock_element_pos = (0, 0) + # Progress values + self.prog_flags = { "npc" : {}, "quest" : {}, "other" : {} } + # Other values - self.active_story = "Tzed 1" # TMP! + self.active_scenario = "Tzed 1" # TMP! self.sheets = {} self.loaded_boards = {} self.current_board = None @@ -381,7 +384,8 @@ class Game(object): "board" : self.current_board.name, "cell" : self.player.cellpos, "tile" : self.player.tilepos, - "party" : self.party + "party" : self.party, + "flags" : self.prog_flags } with open(os.path.join(SAVE_PATH, savename + ".json")) as sj: json.dump(savestate) @@ -391,7 +395,7 @@ class Game(object): """ if os.path.exists(os.path.join(SAVE_PATH, savename + ".json")): with open(os.path.join(SAVE_PATH, savename + ".json")) as lj: saveraw = json.load(lj) - self.active_story = saveraw["story"] + self.active_scenario = saveraw["scenario"] self.player_name = saveraw["player"] self.party = saveraw["party"] self.switch_board(saveraw["board"], tuple(saveraw["cell"]))