added 4 methods to Statistics class
This commit is contained in:
parent
1c28b3a644
commit
ff29e52a8d
@ -1,6 +1,46 @@
|
||||
class Statistics:
|
||||
def __init__(self):
|
||||
self.hp
|
||||
self.hunger
|
||||
self.thirst
|
||||
self.stamina
|
||||
self.hp = 100
|
||||
self.hunger = 100
|
||||
self.thirst = 100
|
||||
self.stamina = 100
|
||||
|
||||
# methods that don't let the values pass below 0 and over 100 during change
|
||||
def set_hp(self, hp_diff):
|
||||
if 0 <= self.hp + hp_diff <= 100:
|
||||
self.hp = self.hp + hp_diff
|
||||
else:
|
||||
if self.hp + hp_diff <= 0:
|
||||
self.hp = 0
|
||||
else:
|
||||
self.hp = 100
|
||||
|
||||
def set_hunger(self, hunger_diff):
|
||||
if 0 <= self.hp + hunger_diff <= 100:
|
||||
self.hp = self.hp + hunger_diff
|
||||
else:
|
||||
if self.hp + hunger_diff <= 0:
|
||||
self.hp = 0
|
||||
else:
|
||||
self.hp = 100
|
||||
|
||||
def set_thirst(self, thirst_diff):
|
||||
if 0 <= self.hp + thirst_diff <= 100:
|
||||
self.hp = self.hp + thirst_diff
|
||||
else:
|
||||
if self.hp + thirst_diff <= 0:
|
||||
self.hp = 0
|
||||
else:
|
||||
self.hp = 100
|
||||
|
||||
def set_stamina(self, stamina_diff):
|
||||
if 0 <= self.hp + stamina_diff <= 100:
|
||||
self.hp = self.hp + stamina_diff
|
||||
else:
|
||||
if self.hp + stamina_diff <= 0:
|
||||
self.hp = 0
|
||||
else:
|
||||
self.hp = 100
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user