all repos — groupgardenbot @ 5373f6d93a1a98f5afc16a69dc4ff1a25cee5885

An extension of the game "botany", originally designed for unix-based systems, to the Telegram Bot API.

minor cleanup and corrections
Marco Andronaco andronacomarco@gmail.com
Sun, 25 Sep 2022 16:58:37 +0200
commit

5373f6d93a1a98f5afc16a69dc4ff1a25cee5885

parent

38ccab8a1e43e4e9d71412d52089648c2b8eee5e

2 files changed, 7 insertions(+), 15 deletions(-)

jump to
M Gardening.pyGardening.py

@@ -1,7 +1,7 @@

import random, os, time, datetime from Constants import * -water_duration = 3_600 * 24 +water_duration = 3_600 * 24 # 86_400s (24h) death_duration = 5 * water_duration stage_factors = (1, 3, 10, 20, 30) indicator_squares = 10

@@ -124,12 +124,6 @@ def get_water(self):

water_delta = int(time.time()) - self.last_water water_left_pct = max(0, 1 - (water_delta/water_duration)) water_left = int(round(water_left_pct * indicator_squares)) - return f"{water_left * '🟦'}{'⬛' * (indicator_squares - water_left)} {str(round(water_left_pct * 100))}%" - - def get_water_ascii(self): - water_delta = int(time.time()) - self.last_water - water_left_pct = max(0, 1 - (water_delta/water_duration)) - water_left = int(round(water_left_pct * indicator_squares)) return f"|{water_left * '█'}{' ' * (indicator_squares - water_left)}| {str(round(water_left_pct * 100))}%" def get_filename(self):

@@ -144,7 +138,7 @@ return "template.txt"

def get_art(self): filename = self.get_filename() - # Prints ASCII art from file at given coordinates + # Prints ASCII art from file this_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "art") this_filename = os.path.join(this_dir, filename) this_file = open(this_filename,"r")

@@ -159,7 +153,7 @@ this_color = color_list[self.color]

this_stage = self.stage if self.dead: - this_stage = 99 + this_stage = 99 try: description_num = random.randint(0,len(stage_descriptions[this_stage]) - 1) except KeyError as e:

@@ -176,7 +170,7 @@ ticks_since_last = self.points - last_growth_at

ticks_between_stage = self.life_stages[this_stage] - last_growth_at if ticks_since_last >= ticks_between_stage * 0.8: output_text += "You notice your plant looks different.\n" - + output_text += get_stage_description(this_stage, description_num, this_species, this_color) + "\n" # if seedling

@@ -190,7 +184,6 @@ # if young plant

if this_stage == 2: if self.rarity >= 2: output_text += "You feel like your plant is special.\n" - # if mature plant if this_stage == 3: color_options = [color_list[self.color],
M main.pymain.py

@@ -21,10 +21,9 @@ stage : {plant.parse_plant()}

age : {plant.age_days} days score : {plant.points} bonus : x{plant.generation_bonus - 1} -water : {plant.get_water_ascii()}``` +water : {plant.get_water()}``` {plant.get_description()} - {f'Last watered by {plant.last_water_name}.' if plant.last_water_user != plant.owner else ""} '''

@@ -61,7 +60,7 @@ new = True

if new: show_handler(update, context) - return reply(update, context, "Hai piantato un nuovo seme! Adesso usa /water per innaffiarlo.") + return reply(update, context, "Hai piantato un nuovo seme! Adesso usa /water o un tasto sopra per innaffiarlo.") return reply(update, context, "La tua pianta non è ancora pronta per andarsene!")

@@ -97,7 +96,7 @@ new_name = " ".join(context.args).strip()

if new_name == "": raise IndexError except IndexError: - return "Utilizzo: /rename <nuovo nome>" + return "Utilizzo: /rename nuovo nome" plant.name = new_name return f"Fatto! Adesso la tua pianta si chiama {new_name}!"