2019-05-06 12:51:41 +02:00
|
|
|
class Plant():
|
2019-05-07 15:37:27 +02:00
|
|
|
def _init_(self):
|
|
|
|
@property
|
|
|
|
def is_alive(self):
|
|
|
|
pass
|
2019-05-06 12:51:41 +02:00
|
|
|
|
2019-05-07 15:37:27 +02:00
|
|
|
@property
|
|
|
|
def ttl(self):
|
|
|
|
pass
|
2019-05-06 12:51:41 +02:00
|
|
|
|
2019-05-07 15:37:27 +02:00
|
|
|
@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
|
2019-05-06 12:51:41 +02:00
|
|
|
|
2019-06-03 13:37:21 +02:00
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
pass
|
|
|
|
|
2019-05-06 12:51:41 +02:00
|
|
|
def get_stats(self):
|
2019-05-31 15:01:29 +02:00
|
|
|
return {"ttl": self.ttl, "is_alive": self.is_alive, "hydration": self.hydration, "soil_level": self.soil_level,
|
2019-06-03 13:37:21 +02:00
|
|
|
"ready": self.ready, "name": self.name }
|
2019-05-06 12:51:41 +02:00
|
|
|
#np. touple'a z info czy żyje, ile ma wody i nawozu
|
2019-05-31 15:01:29 +02:00
|
|
|
|
2019-05-07 15:37:27 +02:00
|
|
|
|
|
|
|
def get_symbol(self):
|
|
|
|
if not self.is_alive:
|
|
|
|
return ('x', None)
|
2019-06-08 17:48:36 +02:00
|
|
|
if self.name == 1 and self.hydration > (500) and self.soil_level > (400):
|
|
|
|
# (self.max_soil_lvl / self.optimal_soil_ratio):
|
2019-05-07 15:37:27 +02:00
|
|
|
return ('p', "green") if (self.ttl > self.ready) \
|
|
|
|
else ('P', "green")
|
2019-06-08 17:48:36 +02:00
|
|
|
|
|
|
|
elif self.name == 0 and self.hydration > (600) and self.soil_level > (500):
|
|
|
|
return ('o', "green") if (self.ttl > self.ready) \
|
|
|
|
else ('O', "green")
|
2019-05-07 15:37:27 +02:00
|
|
|
else:
|
2019-06-08 17:48:36 +02:00
|
|
|
if self.name == 1:
|
|
|
|
return ('p', "yellow") if (self.ttl > self.ready) \
|
2019-05-07 15:37:27 +02:00
|
|
|
else ('P', "yellow")
|
2019-06-08 17:48:36 +02:00
|
|
|
else:
|
|
|
|
return ('o', "yellow") if (self.ttl > self.ready) \
|
|
|
|
else ('O', "yellow")
|
|
|
|
|
2019-05-07 15:37:27 +02:00
|
|
|
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:
|
2019-05-31 15:13:21 +02:00
|
|
|
self.is_alive = False
|
2019-06-08 17:48:36 +02:00
|
|
|
if n==0:
|
|
|
|
self.is_alive = False
|
2019-05-07 15:37:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
def increase_hydration(self, n):
|
|
|
|
self.hydration += n
|
|
|
|
if self.hydration > self.max_hydration_lvl:
|
|
|
|
self.is_alive = False
|
|
|
|
|
|
|
|
def decrase_hydration(self, n):
|
2019-06-08 17:48:36 +02:00
|
|
|
self.hydration -= (n * self.dehydration_ratio)
|
2019-05-07 15:37:27 +02:00
|
|
|
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):
|
2019-06-08 17:48:36 +02:00
|
|
|
self.soil_level -= (n * self.desoil_ratio)
|
2019-05-07 15:37:27 +02:00
|
|
|
if self.soil_level < 1:
|
|
|
|
self.is_alive = False
|
2019-06-08 17:48:36 +02:00
|
|
|
|
|
|
|
|