Return to repo list

tzed

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

commit 7770e4334ce69b2e1f24ecc58fc8e2467cb62ca0
parent 1eb1909b1220757a4093be1c639876e3a3b6255c
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Thu, 26 Aug 2021 17:22:13 -0500

added basic world time

Diffstat:
Msrc/game.py | 18++++++++++++++++++
Msrc/interface.py | 1+
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/game.py b/src/game.py @@ -53,6 +53,7 @@ class Game(object): self.loaded_boards = {} self.current_board = None self.gamedata = {} + self.gametime = 0 # Loading self.load_sheets("sheets.json") @@ -174,6 +175,7 @@ class Game(object): if np[1] >= 0 and np[1] < len(self.current_board.current_cell) and np[0] >= 0 and np[0] < len(self.current_board.current_cell[np[1]]): if self.current_board.cellmap[self.player.cellpos][np[1]][np[0]][1]: self.player.tilepos = np + self.pass_time() canmove = True # Otherwise, in case we are trying to move out of the current cell, calculate the relative offset of the new cellpos @@ -191,6 +193,7 @@ class Game(object): self.player.cellpos = ncc self.player.tilepos = ntp self.current_board.change_cell(self.player.cellpos) + self.pass_time() canmove = True # Finally, post the message, reposition, and check events @@ -198,6 +201,21 @@ class Game(object): self.current_board.position_to_tile(self.player.tilepos) self.current_board.check_events_at_tilepos(self.player.tilepos) + def pass_time(self, time_mod = 1, take_turn = True): + """ + Passes time by 'time_mod', usually 1. If 'take_turn' + is true, the other entities on the current board + will move as well. + """ + + # First, add time and calculate into date string. + # TODO: Add date string and its display + self.gametime += time_mod + + # Then, if take_turn is true, take a turn for the other entities. + if take_turn: + pass + def post_message(self, text): """ This method is used by external objects to diff --git a/src/interface.py b/src/interface.py @@ -100,6 +100,7 @@ class Interface(object): return elif k in CONTROLS["wait"]: self.game.post_message("$PLAYERNAME waits.") + self.game.pass_time() for j in CONTROLS["wait"]: self.key_bools[j] = False return