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
/
Spells.py
103 lines (74 loc) · 2.58 KB
/
Spells.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
#!usr/bin/python
# -*- coding: utf-8 -*-
from Enums import CharacterEnum as Character, SideEnum
class Spell:
"""
Represents spell, which can be applied to characters
"""
def __init__(self, name, cost, mp_cost, info, character, side):
"""
:param name: string - spell name
:param cost: int - cost in gold
:param mp_cost: int - mana cost
:param info: string - spell description
:param character: CharacterEnum - determines which character can learn this spell (if spell is player-used)
:param side: SideEnum - determines if spell is used on Player or NPC party
"""
self.name = name
self.cost = int(cost)
self.mp = int(mp_cost)
self.info = info
self.char = character
self.side = side
def apply(self, target):
"""
apply spell on it's target
:param target: player or enemy party member
"""
pass
def check_appliable(self, target):
"""
Check if spell can be applied to target
:param target:
:return:
"""
pass
def __str__(self):
return '{} ({} MP)'.format(self.name, self.mp)
class Heal(Spell):
def __init__(self):
super().__init__('Heal', 50, 5, 'Heal 5 MP', Character.Healer, SideEnum.Player)
def apply(self, target):
target.heal(5)
def check_appliable(self, target):
if target.KO is not True and target.HP < target.MAX_HP:
return True
else:
return False
class Fireball(Spell):
def __init__(self):
super().__init__('Fireball', 50, 10, 'Deal 15 points of damage', Character.Mage, SideEnum.NPC)
def apply(self, target):
target.apply_damage(15)
def check_appliable(self, target):
return True # Spell is always appliable to NPC,as they are removed on knock out
class Lightning(Spell):
def __init__(self):
super().__init__('Lightning', 100, 20, 'Deal 25 points of damage', Character.Mage, SideEnum.NPC)
def apply(self, target):
target.apply_damage(25)
def check_appliable(self, target):
return True # Spell is always appliable to NPC,as they are removed on knock out
class FireBreath(Spell):
"""
Fire elemental spell
"""
def __init__(self):
super().__init__('Fire breath', 0, 10, 'Deal 15 points of damage', 0, SideEnum.Player)
def apply(self, target):
target.apply_magic_damage(15)
def check_appliable(self, target):
if target.KO:
return False
else:
return True