SZI_PROJEKT_GR1_TRAKTOR/Plant.py
marcinljablonski 6cfeedcd7e refactored
2019-05-07 15:37:27 +02:00

88 lines
2.1 KiB
Python

class Plant():
def _init_(self):
@property
def is_alive(self):
pass
@property
def ttl(self):
pass
@property
def hydration(self):
pass
@property
def soil_level(self):
pass
@property
def dehydration_ratio(self):
pass
@property
def max_soil_lvl(self):
pass
@property
def optimal_soil_ratio(self):
pass
@property
def max_hydration_lvl(self):
pass
@property
def optimal_hydration_ratio(self):
pass
@property
def ready(self):
pass
def get_stats(self):
#np. touple'a z info czy żyje, ile ma wody i nawozu
raise NotImplementedError("Please Implement this method")
def get_symbol(self):
if not self.is_alive:
return ('x', None)
elif self.hydration > (self.max_hydration_lvl / self.optimal_hydration_ratio) \
and self.soil_level > (self.max_soil_lvl / self.optimal_soil_ratio):
return ('p', "green") if (self.ttl > self.ready) \
else ('P', "green")
else:
return ('p', "yellow") if (self.ttl > self.ready) \
else ('P', "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_alive == False
def increase_hydration(self, n):
self.hydration += n
if self.hydration > self.max_hydration_lvl:
self.is_alive = False
def decrase_hydration(self, n):
self.hydration -= n * self.dehydration_ratio
if self.hydration < 1:
self.is_alive = False
def increase_soillevel(self, n):
self.soil_level += n
if self.soil_level > self.max_soil_lvl:
self.is_alive = False
def decrease_soillevel(self, n):
self.soil_level -= n * self.desoil_ratio
if self.soil_level < 1:
self.is_alive = False