Block user from visiting self, fix guest watering bug

pull/8/head
Jake Funke 2018-03-12 14:35:42 -07:00
parent e6e8778dfb
commit b9ef7c31bb
2 changed files with 10 additions and 2 deletions

View File

@ -248,9 +248,12 @@ class Plant(object):
def water_check(self): def water_check(self):
latest_visitor_timestamp = self.guest_check() latest_visitor_timestamp = self.guest_check()
if latest_visitor_timestamp > self.watered_timestamp: if latest_visitor_timestamp > self.watered_timestamp:
visitor_delta_watered = latest_visitor_timestamp - self.watered_timestamp
if visitor_delta_watered <= (5 * (24 * 3600)):
self.watered_timestamp = latest_visitor_timestamp self.watered_timestamp = latest_visitor_timestamp
self.time_delta_watered = int(time.time()) - self.watered_timestamp self.time_delta_watered = int(time.time()) - self.watered_timestamp
if self.time_delta_watered <= (24 * 3600): if self.time_delta_watered <= (24 * 3600):
if not self.watered_24h:
self.watered_24h = True self.watered_24h = True
return True return True
else: else:

View File

@ -600,6 +600,11 @@ class CursedMenu(object):
if not guest_garden: if not guest_garden:
self.clear_info_pane() self.clear_info_pane()
return None return None
if guest_garden.lower() == getpass.getuser().lower():
self.screen.addstr(16, 2, "you're already here!")
self.screen.getch()
self.clear_info_pane()
return None
home_folder = os.path.dirname(os.path.expanduser("~")) home_folder = os.path.dirname(os.path.expanduser("~"))
guest_json = home_folder + "/{}/.botany/{}_plant_data.json".format(guest_garden, guest_garden) guest_json = home_folder + "/{}/.botany/{}_plant_data.json".format(guest_garden, guest_garden)
guest_plant_description = "" guest_plant_description = ""