From be770c6b5ef0951aeb1ba8b57cdd290c6d63d979 Mon Sep 17 00:00:00 2001 From: Nate Smith Date: Wed, 6 Dec 2023 21:36:15 -0800 Subject: [PATCH] fix scoping on death_check change --- botany.py | 2 +- plant.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/botany.py b/botany.py index ba18c89..8525f9e 100755 --- a/botany.py +++ b/botany.py @@ -318,7 +318,7 @@ if __name__ == '__main__': my_plant = Plant(my_data.savefile_path) my_data.data_write_json(my_plant) # my_plant is either a fresh plant or an existing plant at this point - my_plant.start_life() + my_plant.start_life(my_data) my_data.start_threads(my_plant) try: diff --git a/plant.py b/plant.py index 3422fc3..f68274b 100644 --- a/plant.py +++ b/plant.py @@ -323,13 +323,13 @@ class Plant: def unlock_new_creation(self): self.write_lock = False - def start_life(self): + def start_life(self, dm): # runs life on a thread - thread = threading.Thread(target=self.life, args=()) + thread = threading.Thread(target=self.life, args=(dm,)) thread.daemon = True thread.start() - def life(self): + def life(self, dm): # I've created life :) generation_bonus = round(0.2 * (self.generation - 1), 1) score_inc = 1 * (1 + generation_bonus) @@ -346,10 +346,10 @@ class Plant: # Do something pass if self.dead_check(): - self.save_plant(this_plant) - self.data_write_json(this_plant) - self.update_garden_db(this_plant) - self.harvest_plant(this_plant) + dm.save_plant(this_plant) + dm.data_write_json(this_plant) + dm.update_garden_db(this_plant) + dm.harvest_plant(this_plant) this_plant.unlock_new_creation() # TODO: event check time.sleep(2)