-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop_item.py
80 lines (68 loc) · 2.02 KB
/
shop_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
from abc import ABC, abstractmethod, abstractproperty
import time
class ShopItem(ABC):
@abstractproperty
def effect(self):
pass
@abstractproperty
def price(self):
pass
@abstractproperty
def name(self):
pass
@abstractmethod
def change(self, hero):
pass
def __str__(self):
return f"{self.name} ({self.price} gold)"
class BigHealingPotion(ShopItem):
effect = '+50 HP'
name = "big healing potion"
price = 3
def change(self, hero):
""" Gives hero 50 health points """
hero.health = hero.health + 50
hero.health = 100 if hero.health > 100 else hero.health
class SmallHealingPotion(ShopItem):
effect = '+10 HP'
name = "small healing potion"
price = 1
def change(self, hero):
""" Gives hero 10 health points """
hero.health = hero.health + 10
class SuperHealingPotion(ShopItem):
effect = '+75 HP'
name = "super healing potion"
price = 5
def change(self, hero):
""" Gives hero 75 health points """
hero.health = hero.health + 75
hero.health = 100 if hero.health > 100 else hero.health
class WeaponUpgrade(ShopItem):
effect = '+5% AP'
name = "weapon upgrade"
price = 1
def change(self, hero):
""" Increases hero power by 5% """
hero.power = round(hero.power * 1.05, 2)
class SuperWeaponUpgrade(ShopItem):
effect = '+15% AP'
name = "super weapon upgrade"
price = 3
def change(self, hero):
""" Increases hero power by 15% """
hero.power = round(hero.power * 1.15, 2)
class CriticalDagger(ShopItem):
effect = '+5% crt'
name = "critical dagger"
price = 2
def change(self, hero):
""" Increses Hero's critical strike chance by 5% """
hero.critical_chance += 0.05
class CurvedBlade(ShopItem):
effect = '+10% crt'
name = "curved blade"
price = 4
def change(self, hero):
""" Increses Hero's critical strike chance by 10% """
hero.critical_chance += 0.10