-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems_v2.py
57 lines (49 loc) · 1.71 KB
/
items_v2.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
class ItemEnum:
KEY=0
BOSSKEY=1
RPOTION=2
BPOTION=3
YPOTION=4
PPOTION=5
def assort_item_name(idn):
return ["Key", "Boss Key", "Red Potion", "Blue Potion", "Yellow Potion", "Purple Potion"][idn]
class Item:
def __init__(self,idn):
self.battle_usable = idn in [2,3,4,5]
self.idn=idn
self.name=assort_item_name(self.idn)
self.actionmessage = ["\n","\n","\nHealth restored!","\nAttack damage increased by 2!","\nShielded!","\nMP restored!"][self.idn]
def action(self,plr):
if not self.battle_usable:
print("You can't use this item here.")
return False
if self.idn==ItemEnum.RPOTION:
plr.buffs.append(Effect(0,1))
if self.idn==ItemEnum.BPOTION:
plr.buffs.append(Effect(1,1))
if self.idn==ItemEnum.YPOTION:
plr.buffs.append(Effect(2,2))
if self.idn==ItemEnum.PPOTION:
plr.buffs.append(Effect(3,1))
return True
def draw(self):
return [" o¬¬ ","@=;;;","\033[91m ᵿ \033[0m","\033[96m ᵿ \033[0m","\033[93m ᵿ \033[0m","\033[38;5;129m ᵿ \033[0m"][self.idn]
def __str__(self):
return self.name
def __repr__(self):
return self.name
class Effect:
def __init__(self, idn, duration):
self.idn = idn
self.duration = duration
self.maxduration = duration
def inflict(self, plr):
if self.idn == 0:
plr.hp = plr.base.maxhp
elif self.idn == 1:
for attack in plr.base.attacks:
attack.damage += 2
elif self.idn == 2:
plr.shielded = True
elif self.idn == 3:
plr.mp = plr.base.maxmp