-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
66 lines (46 loc) · 1.15 KB
/
player.py
File metadata and controls
66 lines (46 loc) · 1.15 KB
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
65
66
from random import randint
class Player:
def __init__(self, name, weapon):
self.name = name
self.MHP = 150
self.HP = self.MHP
self.weapon = weapon
self.inventory = [self.weapon]
self.x = 0
def __str__(self):
return f"Name: {self.name}\nHP: {self.MHP}\nAttack Power: {self.AP}\nWeapon: {self.weapon}\nInventory: {self.inventory}"
def AP():
num = randint(0, 5)
if num == 0:
AP = 1
return AP
elif num == 1:
AP = 1.1
return AP
elif num == 2:
AP = 1.2
return AP
elif num == 3:
AP = 1.3
return AP
elif num == 4:
AP = 1.4
return AP
elif num == 5:
AP = 1.5
return AP
def heal(self, num):
if self.HP + num <= self.MHP:
self.HP = self.HP + num
elif self.HP + num >= self.MHP:
self.HP = self.MHP
def take_damage(self, num):
if self.HP - num > 0:
self.HP = self.HP - num
elif self.HP - num <= 0:
self.HP = 0
def remove_item(self, item):
if item in self.inventory:
self.inventory.remove(self.inventory.index(item))
else:
print("\nInvalid Item")