from Plant import Plant class Cucumber(Plant): def __init__(self): self.__is_alive = True self.__ttl = 40 self.__hydration = 40 self.__soil_level = 40 self.__dehydration_ratio = 0.8 self.__desoil_ratio = 0.7 self.__max_soil_lvl = 40 self.__max_hydration_lvl = 40 self.__ready = 11 def get_symbol(self): if not self.__is_alive: return ('x', None) elif self.__hydration > (self.__max_hydration_lvl / 2) \ and self.__soil_level > (self.__max_soil_lvl / 2): return ('o', "green") if (self.__ttl > self.__ready) \ else ('O', "green") else: return ('o', "yellow") if (self.__ttl > self.__ready) \ else ('O', "yellow") def tick(self, n): self.decrease_ttl(n) self.decrase_hydration(n) self.decrease_soillevel(n) def decrease_ttl(self, n): self.__ttl -= n if self.__ttl == 0: self.__is_life == False def increase_hydration(self, n): self.__hydration += n if self.__hydration > 40: self.__is_life = False def decrase_hydration(self, n): self.__hydration -= n * self.__dehydration_ratio if self.__hydration < 1: self.__is_life = False def increase_soillevel(self, n): self.__soil_level += n if self.__soil_level > 40: self.__is_life = False def decrease_soillevel(self, n): self.__soil_level -= n * self.__desoil_ratio if self.__soil_level < 1: self.__is_life = False