Return to repo list

tzed

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

commit 7fd2cbbd3505ec839b2cc8d428273c506ff2c0c9
parent 5ed26a68fb81feb7fe33ad9881a11ef67d43c316
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sat,  2 Oct 2021 23:23:00 -0500

save and battle work

Diffstat:
Msrc/dungeon.py | 8++++----
Msrc/game.py | 13++++++++++++-
2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/dungeon.py b/src/dungeon.py @@ -123,10 +123,10 @@ class Dungeon(object): Check to see if an random enemy encounter should happen. """ - if not self.safe and self.floor_factor_counters[self.current_floor] < self.floor_encounters[self.current_floor]["factor"]: - randchance = random.randint(1, 20) - if randchance >= self.floor_encounters[self.current_floor]["rate"]: - print("trigger encounter") + workenc = self.floor_encounters[self.current_floor] + if not self.safe and self.floor_factor_counters[self.current_floor] < workenc["factor"]: + if random.randint(1, 20) >= workenc["rate"]: + self.game.trigger_battle(workenc[tuple(workenc.keys())[random.randint(0, len(workenc["parties"]))]]) def take_dungeon_turn(self): """ diff --git a/src/game.py b/src/game.py @@ -337,6 +337,9 @@ class Game(object): """ self.message_board.post(text, self.gamedata) + def trigger_battle(self, partydef): + pass + def update_dynamic_ui(self, surface = None): """ Update the dynamic portions of the UI. @@ -449,6 +452,11 @@ class Game(object): } } + # Next, get progress for various loaded objects + dungeons = {} + for d in self.loaded_dungeons: + self.dungeons[d] = { "floor_factors" : self.loaded_dungeons[d].floor_factor_counters, "dungeon_flags" : self.loaded_dungeons[d].dungeon_flags } + # Then, construct the savestate and write it to a json savestate = { "story" : self.active_story, @@ -456,7 +464,10 @@ class Game(object): "gametime" : self.gametime, "at" : at, "party" : self.party, - "flags" : self.prog_flags + "flags" : self.prog_flags, + "dungeons" : dungeons, + "newgame" : False + } with open(os.path.join(SAVE_PATH, savename + ".json")) as sj: json.dump(savestate)