-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.py
executable file
·46 lines (37 loc) · 1.38 KB
/
player.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
import random
from entity import Entity
from room import Room
class Player(Entity) :
num_enemy_types = 1;
def __init__(self, name):
Entity.__init__(self)
self.name = name
self.init_stats()
def get_player_name(self) :
return self.name
def set_player_name(self, name):
self.name = name
def get_name(self) :
toReturn = ""
for adj in self.get_adjectives() :
toReturn = toReturn + adj + " "
return toReturn + self.get_player_name()
def reset_all_stats() : #Reset all stats and health
self.curr_stats = self.base_stats
def partial_reset_stats(self) :
for i in range(0, len(self.curr_stats)) :
if(self.curr_stats[i] > self.base_stats[i] + 1) :
delta = self.curr_stats[i] - self.base_stats[i]
self.curr_stats[i] -= (delta / 2)
elif(self.curr_stats[i] < self.base_stats[i] - 1) :
delta = self.base_stats[i] - self.curr_stats[i]
self.curr_stats += (delta / 2)
else :
self.curr_stats[i] = self.base_stats[i]
def init_stats(self) :
health = 100
attack = random.randint(10,20)
defense = random.randint(5,10)
evasion = random.randint(0,20)
self.base_stats = [health, attack, defense, evasion]
self.curr_stats = self.base_stats