Cleanup and revisions
parent
2644370a40
commit
eed6e61199
|
@ -124,7 +124,7 @@ class Plant(object):
|
||||||
# Constructor
|
# Constructor
|
||||||
self.plant_id = str(uuid.uuid4())
|
self.plant_id = str(uuid.uuid4())
|
||||||
self.life_stages = (3600*24, (3600*24)*3, (3600*24)*10, (3600*24)*20, (3600*24)*30)
|
self.life_stages = (3600*24, (3600*24)*3, (3600*24)*10, (3600*24)*20, (3600*24)*30)
|
||||||
# self.life_stages = (2, 4, 6, 8, 10)
|
# self.life_stages = (2, 4, 6, 8, 10) # debug mode
|
||||||
self.stage = 0
|
self.stage = 0
|
||||||
self.mutation = 0
|
self.mutation = 0
|
||||||
self.species = random.randint(0,len(self.species_list)-1)
|
self.species = random.randint(0,len(self.species_list)-1)
|
||||||
|
@ -142,7 +142,6 @@ class Plant(object):
|
||||||
# must water plant first day
|
# must water plant first day
|
||||||
self.watered_timestamp = int(time.time())-(24*3600)-1
|
self.watered_timestamp = int(time.time())-(24*3600)-1
|
||||||
self.watered_24h = False
|
self.watered_24h = False
|
||||||
# visitors are coming
|
|
||||||
self.visitors = []
|
self.visitors = []
|
||||||
|
|
||||||
def migrate_properties(self):
|
def migrate_properties(self):
|
||||||
|
@ -290,7 +289,6 @@ class Plant(object):
|
||||||
# Should this reset to 1? Seems unfair.. for now generations will
|
# Should this reset to 1? Seems unfair.. for now generations will
|
||||||
# persist through death.
|
# persist through death.
|
||||||
next_generation = self.generation
|
next_generation = self.generation
|
||||||
|
|
||||||
self.write_lock = True
|
self.write_lock = True
|
||||||
self.kill_plant()
|
self.kill_plant()
|
||||||
while self.write_lock:
|
while self.write_lock:
|
||||||
|
@ -347,7 +345,6 @@ class DataManager(object):
|
||||||
savefile_path = os.path.join(botany_dir, savefile_name)
|
savefile_path = os.path.join(botany_dir, savefile_name)
|
||||||
#set this.savefile_path to guest_garden path
|
#set this.savefile_path to guest_garden path
|
||||||
|
|
||||||
|
|
||||||
garden_db_path = os.path.join(game_dir, 'sqlite/garden_db.sqlite')
|
garden_db_path = os.path.join(game_dir, 'sqlite/garden_db.sqlite')
|
||||||
garden_json_path = os.path.join(game_dir, 'garden_file.json')
|
garden_json_path = os.path.join(game_dir, 'garden_file.json')
|
||||||
harvest_file_path = os.path.join(botany_dir, 'harvest_file.dat')
|
harvest_file_path = os.path.join(botany_dir, 'harvest_file.dat')
|
||||||
|
@ -376,7 +373,6 @@ class DataManager(object):
|
||||||
death_check_thread = threading.Thread(target=self.death_check_update, args=(this_plant,))
|
death_check_thread = threading.Thread(target=self.death_check_update, args=(this_plant,))
|
||||||
death_check_thread.daemon = True
|
death_check_thread.daemon = True
|
||||||
death_check_thread.start()
|
death_check_thread.start()
|
||||||
|
|
||||||
autosave_thread = threading.Thread(target=self.autosave, args=(this_plant,))
|
autosave_thread = threading.Thread(target=self.autosave, args=(this_plant,))
|
||||||
autosave_thread.daemon = True
|
autosave_thread.daemon = True
|
||||||
autosave_thread.start()
|
autosave_thread.start()
|
||||||
|
@ -566,8 +562,7 @@ class DataManager(object):
|
||||||
json.dump(plant_info, outfile)
|
json.dump(plant_info, outfile)
|
||||||
|
|
||||||
def harvest_plant(self, this_plant):
|
def harvest_plant(self, this_plant):
|
||||||
# TODO: could just use a sqlite query to retrieve all of user's dead
|
# TODO: plant history feature - could just use a sqlite query to retrieve all of user's dead plants
|
||||||
# plants
|
|
||||||
|
|
||||||
# harvest is a dict of dicts
|
# harvest is a dict of dicts
|
||||||
# harvest contains one entry for each plant id
|
# harvest contains one entry for each plant id
|
||||||
|
|
|
@ -525,7 +525,6 @@ class CursedMenu(object):
|
||||||
conn = sqlite3.connect(garden_db_path)
|
conn = sqlite3.connect(garden_db_path)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute("SELECT * FROM visitors WHERE garden_name = '{}' ORDER BY weekly_visits".format(self.plant.owner))
|
c.execute("SELECT * FROM visitors WHERE garden_name = '{}' ORDER BY weekly_visits".format(self.plant.owner))
|
||||||
# if c.rowcount:
|
|
||||||
visitor_data = c.fetchall()
|
visitor_data = c.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
visitor_block = ""
|
visitor_block = ""
|
||||||
|
@ -545,6 +544,7 @@ class CursedMenu(object):
|
||||||
return visitor_block
|
return visitor_block
|
||||||
|
|
||||||
def get_user_string(self, xpos=3, ypos=15):
|
def get_user_string(self, xpos=3, ypos=15):
|
||||||
|
# doesn't allow non-alphanumeric text
|
||||||
user_string = ""
|
user_string = ""
|
||||||
user_input = 0
|
user_input = 0
|
||||||
while user_input != 10:
|
while user_input != 10:
|
||||||
|
@ -572,7 +572,6 @@ class CursedMenu(object):
|
||||||
weekly_visitor_text = self.get_weekly_visitors()
|
weekly_visitor_text = self.get_weekly_visitors()
|
||||||
self.draw_info_text("this week you've been visited by: ", 6)
|
self.draw_info_text("this week you've been visited by: ", 6)
|
||||||
self.draw_info_text(weekly_visitor_text, 7)
|
self.draw_info_text(weekly_visitor_text, 7)
|
||||||
# user input section (can't get getstr to work)
|
|
||||||
guest_garden = self.get_user_string()
|
guest_garden = self.get_user_string()
|
||||||
if not guest_garden:
|
if not guest_garden:
|
||||||
self.clear_info_pane()
|
self.clear_info_pane()
|
||||||
|
@ -626,11 +625,8 @@ class CursedMenu(object):
|
||||||
try:
|
try:
|
||||||
self.visit_handler()
|
self.visit_handler()
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
print exception;
|
self.screen.refresh()
|
||||||
traceback.print_exc()
|
# traceback.print_exc()
|
||||||
|
|
||||||
# self.screen.refresh()
|
|
||||||
|
|
||||||
if request == "garden":
|
if request == "garden":
|
||||||
try:
|
try:
|
||||||
self.draw_garden()
|
self.draw_garden()
|
||||||
|
|
Loading…
Reference in New Issue