This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Items.py
129 lines (89 loc) · 2.8 KB
/
Items.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!usr/bin/python
# -*- coding: utf-8 -*-
class BaseItem:
"""
Represents basic inventory item class
"""
def __init__(self, name, cost, info):
self.name = name
self.cost = int(cost)
self.info = info
class Weapon(BaseItem):
"""
Represents weapon item class for inventory
"""
def __init__(self, name, dmg, cost, info):
"""
:param name: string - weapon name
:param dmg: int - weapon damage (will be added to owner's physical damage)
:param cost: int - weapon cost
"""
super().__init__(name, cost, info)
self.dmg = dmg
def __str__(self):
return '{} (+{})'.format(self.name, self.dmg)
class Armor(BaseItem):
"""
Represents armor item class for inventory
"""
def __init__(self, name, defence, cost, info):
super().__init__(name, cost, info)
self.defence = defence
def __str__(self):
return '{} (+{})'.format(self.name, self.defence)
class Usable(BaseItem):
"""
Represents usable item like potion, which applies some effect to user
"""
def __init__(self, name, cost, info, side):
super().__init__(name, cost, info)
self.side = side
def __str__(self):
return '{} ({} G)'.format(self.name, self.cost)
def apply_effect(self, target):
"""
apply item effect on it's target
:param target: player or enemy party member
"""
pass
def check_appliable(self, target):
pass
class ManaPotion(Usable):
def __init__(self):
super().__init__('Mana potion', 50, 'Restores 20 MP', 1)
def apply_effect(self, target):
target.restore_mana(20)
def check_appliable(self, target):
if target.KO is not True and target.MP < target.MAX_MP:
return True
else:
return False
class HealthPotion(Usable):
def __init__(self):
super().__init__('Health potion', 50, 'Restores 20 HP', 1)
def apply_effect(self, target):
target.heal(20)
def check_appliable(self, target):
if target.KO is not True and target.HP < target.MAX_HP:
return True
else:
return False
class PhoenixDown(Usable):
def __init__(self):
super().__init__('Phoenix Down', 300, 'Resurrects party member', 1)
def apply_effect(self, target):
target.resurrect()
def check_appliable(self, target):
if target.KO is True:
return True
else:
return False
class FireBlade(Weapon):
"""
Drops from fire elemental
"""
def __init__(self):
super().__init__('Fire blade', 10, 85, 'Blade made of elemental fire')
class StoneArmor(Armor):
def __init__(self):
super().__init__('Stone armor', 25, 100, 'Perfect stone armor')