forked from alexfrostdesu/RoyalBattleofRogalique
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.py
170 lines (145 loc) · 5.53 KB
/
item.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import random
class Item:
_character = False
def __init__(self, bonus_attack=0, bonus_hp=0, bonus_mp=0, bonus_defence=0):
self._name = self.get_type()
self._full_name = self.get_full_name()
self._bonus_attack = bonus_attack
self._bonus_hp = bonus_hp
self._bonus_mp = bonus_mp
self._bonus_defence = bonus_defence
def get_name(self):
"""
Returns item's name
"""
return self._name
def get_full_name(self):
"""
Returns item's name
"""
return f"{self.get_rarity()} {self.get_name()} {self.get_affix()}"
def set_name(self, name):
"""
Takes new value for item's name and sets it
"""
self._name = name
def get_type(self):
"""
Returns item's type
"""
return self._type
def get_character(self):
"""
Check if it is a character
"""
return self._character
def get_rarity(self):
"""
Returns item's type
"""
return self._rarity
def get_affix(self):
"""
Returns item's affix
"""
return self._item_affix
def set_type(self, new_type):
"""
Takes new value for item's type and sets it
"""
self._name = new_type
def get_bonus_attack(self):
"""
Returns item's bonus attack
"""
return self._bonus_attack
def set_bonus_attack(self, bonus_attack):
"""
Takes new value for item's bonus attack and sets it
"""
self._bonus_attack = bonus_attack
def get_bonus_hp(self):
"""
Returns item's bonus HP
"""
return self._bonus_hp
def set_bonus_hp(self, bonus_hp):
"""
Takes new value for item's bonus HP and sets it
"""
self._bonus_hp = bonus_hp
def get_bonus_mp(self):
"""
Returns item's bonus MP
"""
return self._bonus_mp
def set_bonus_mp(self, bonus_mp):
"""
Takes new value for item's bonus MP and sets it
"""
self._bonus_mp = bonus_mp
def get_bonus_defence(self):
"""
Returns item's bonus defence
"""
return self._bonus_defence
def set_bonus_defence(self, bonus_defence):
"""
Takes new value for item's bonus defence and sets it
"""
self._bonus_defence = bonus_defence
def print_stats(self):
print(self.get_full_name())
print(f"Bonus Damage: {self._bonus_attack}")
print(f"Bonus HP: {self._bonus_hp}")
print(f"Bonus MP: {self._bonus_mp}")
print(f"Bonus Defence: {self._bonus_defence}")
def get_stats(self):
stats = f"*{self.get_full_name()}*\n" + \
f"```\nBonus Damage: ".ljust(15) + f"| {self._bonus_attack}" + \
f"\nBonus HP:".ljust(15) + f"| {self._bonus_hp}" + \
f"\nBonus MP:".ljust(15) + f"| {self._bonus_mp}" + \
f"\nBonus Defence:".ljust(15) + f"| {self._bonus_defence}```"
return stats
def get_compare_stats(self, other_item):
stats = f"{self.get_full_name()}\n" + \
f"```\nBonus Damage: ".ljust(15) + f"| {self._bonus_attack}".ljust(5) + f"({self._bonus_attack - other_item.get_bonus_attack()})" + \
f"\nBonus HP:".ljust(15) + f"| {self._bonus_hp}".ljust(5) + f"({self._bonus_hp - other_item.get_bonus_hp()})" + \
f"\nBonus MP:".ljust(15) + f"| {self._bonus_mp}".ljust(5) + f"({self._bonus_mp - other_item.get_bonus_mp()})" + \
f"\nBonus Defence:".ljust(15) + f"| {self._bonus_defence}".ljust(5) + f"({self._bonus_defence - other_item.get_bonus_defence()})```"
return stats
class CommonItem(Item):
def __init__(self, lvl):
player_lvl_bonus = random.randint(1, lvl)
# ATTACK || HP || MP || DEFENSE
self._item_dict = {'Armour': (0, 10, 2, 5 + player_lvl_bonus),
'Weapon': (5 + player_lvl_bonus, 0, 2, 0),
'Helm': (0, 5, 2, 5),
'Boots': (0, 10, 2, 2),
'Ring': (5, 20, 5, 0)
}
self._type = random.choice(list(self._item_dict))
item_stats = list([random.randint(0, i) for i in self._item_dict[self._type]])
self._item_affix = ''
self._rarity = 'Common'
super().__init__(*item_stats)
class RareItem(Item):
def __init__(self, lvl):
player_lvl_bonus = random.randint(0, lvl+5)
# ATTACK || HP || MP || DEFENSE
self._item_dict = {'Armour': (0, 40, 10, 15 + player_lvl_bonus),
'Weapon': (15 + player_lvl_bonus, 0, 10, 0),
'Helm': (0, 10, 10, 5),
'Boots': (0, 20, 4, 4),
'Ring': (10, 20, 20, 0)
}
self._affixlist = ['of Damage', 'of Vitality', 'of Magic', 'of Defence', 'of Random']
self._type = random.choice(list(self._item_dict))
self._item_affix = random.choice(self._affixlist)
self._rarity = 'Rare'
item_stats = list([random.randint(0, i) for i in self._item_dict[self._type]])
if self._item_affix != 'of Random':
item_stats[self._affixlist.index(self._item_affix)] += random.randint(0, lvl+5)
else:
item_stats = (random.randint(0, lvl+5), random.randint(0, lvl+5), random.randint(0, lvl+5), random.randint(0, lvl+5))
super().__init__(*item_stats)