From 0556b3f75a7f64e354e469f6d307a5168ad92ae0 Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 3 Oct 2020 09:44:06 +0200 Subject: [PATCH 1/3] protect plants against old timestamps --- botany.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/botany.py b/botany.py index 6d199c8..cbc881e 100755 --- a/botany.py +++ b/botany.py @@ -237,7 +237,7 @@ class Plant(object): if element['user'] not in visitors_this_check: visitors_this_check.append(element['user']) # prevent users from manually setting watered_time in the future - if element['timestamp'] <= int(time.time()): + if element['timestamp'] <= int(time.time() and element['timestamp'] >= self.watered_timestamp): guest_timestamps.append(element['timestamp']) try: self.update_visitor_db(visitors_this_check) From 729e5268e4e1e3f9abf46fa36aab865c283c6d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaume=20Delcl=C3=B2s=20Coll?= Date: Sun, 25 Oct 2020 02:08:42 +0200 Subject: [PATCH 2/3] don't use "is" to compare string literals --- menu_screen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu_screen.py b/menu_screen.py index 116d504..441593b 100644 --- a/menu_screen.py +++ b/menu_screen.py @@ -89,7 +89,7 @@ class CursedMenu(object): def set_options(self, options): # Validates that the last option is "exit" - if options[-1] is not 'exit': + if options[-1] != 'exit': options.append('exit') self.options = options @@ -114,7 +114,7 @@ class CursedMenu(object): # Actually draws the menu and handles branching request = "" try: - while request is not "exit": + while request != "exit": self.draw() request = self.get_user_input() self.handle_request(request) From 85d51f40f591aff4ee6800491d1d1c8347d315ac Mon Sep 17 00:00:00 2001 From: "J.M. de Jong" Date: Sat, 23 Jan 2021 14:30:31 +0100 Subject: [PATCH 3/3] Stop making all plants godly python2 division of integers always results in an integer, so `(2/3)` would result in `0`. This caused all plants to get "godly" as rarity. This change makes sure a float division is being used --- botany.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/botany.py b/botany.py index 6d199c8..63f7046 100755 --- a/botany.py +++ b/botany.py @@ -174,10 +174,10 @@ class Plant(object): # Generate plant rarity CONST_RARITY_MAX = 256.0 rare_seed = random.randint(1,CONST_RARITY_MAX) - common_range = round((2/3)*CONST_RARITY_MAX) - uncommon_range = round((2/3)*(CONST_RARITY_MAX-common_range)) - rare_range = round((2/3)*(CONST_RARITY_MAX-common_range-uncommon_range)) - legendary_range = round((2/3)*(CONST_RARITY_MAX-common_range-uncommon_range-rare_range)) + common_range = round((2.0/3)*CONST_RARITY_MAX) + uncommon_range = round((2.0/3)*(CONST_RARITY_MAX-common_range)) + rare_range = round((2.0/3)*(CONST_RARITY_MAX-common_range-uncommon_range)) + legendary_range = round((2.0/3)*(CONST_RARITY_MAX-common_range-uncommon_range-rare_range)) common_max = common_range uncommon_max = common_max + uncommon_range