-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpersonagem.py
64 lines (53 loc) · 1.73 KB
/
personagem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from tabulate import tabulate
class Personagem:
def __init__(self, nome='Thiago'):
self.__nome = nome
self.__saude = 100
self.__relacionamento = 100
self.__dinheiro = 150
self.__estresse = 0
self.__xp = 0
@property
def nome(self):
return self.__nome
@property
def saude(self):
return self.__saude
@property
def relacionamento(self):
return self.__relacionamento
@property
def dinheiro(self):
return self.__dinheiro
@property
def estresse(self):
return self.__estresse
@property
def xp(self):
return self.__xp
def __str__(self):
tabelaStatusHora = [
['Saúde:', self.__saude],
['Relacionamento:', self.__relacionamento],
['Dinheiro:', f'R$ {self.__dinheiro:.2f}'],
['Estresse', self.__estresse],
['Experiência', self.__xp]]
return tabulate(tabelaStatusHora, tablefmt='plain')
def _avaliar(self, valor):
if valor > 100:
return 100
elif valor < 0:
return 0
else:
return valor
def atribuirValores(self, saude = 0, relacionamento = 0, dinheiro = 0, estresse = 0, xp = 0):
self.__saude += saude
self.__relacionamento += relacionamento
self.__dinheiro += dinheiro
self.__estresse += estresse
self.__xp += xp
self.__saude = self._avaliar(self.__saude)
self.__relacionamento = self._avaliar(self.__relacionamento)
self.__dinheiro = self._avaliar(self.__dinheiro)
self.__estresse = self._avaliar(self.__estresse)
self.__xp = self._avaliar(self.__xp)