-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmonster_base.py
129 lines (105 loc) · 3.71 KB
/
monster_base.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
from __future__ import annotations
import abc
from stats import Stats
class MonsterBase(abc.ABC):
def __init__(self, simple_mode=True, level:int=1) -> None:
"""
Initialise an instance of a monster.
:simple_mode: Whether to use the simple or complex stats of this monster
:level: The starting level of this monster. Defaults to 1.
"""
raise NotImplementedError
def get_level(self):
"""The current level of this monster instance"""
raise NotImplementedError
def level_up(self):
"""Increase the level of this monster instance by 1"""
raise NotImplementedError
def get_hp(self):
"""Get the current HP of this monster instance"""
raise NotImplementedError
def set_hp(self, val):
"""Set the current HP of this monster instance"""
raise NotImplementedError
def get_attack(self):
"""Get the attack of this monster instance"""
raise NotImplementedError
def get_defense(self):
"""Get the defense of this monster instance"""
raise NotImplementedError
def get_speed(self):
"""Get the speed of this monster instance"""
raise NotImplementedError
def get_max_hp(self):
"""Get the maximum HP of this monster instance"""
raise NotImplementedError
def alive(self) -> bool:
"""Whether the current monster instance is alive (HP > 0 )"""
raise NotImplementedError
def attack(self, other: MonsterBase):
"""Attack another monster instance"""
# Step 1: Compute attack stat vs. defense stat
# Step 2: Apply type effectiveness
# Step 3: Ceil to int
# Step 4: Lose HP
raise NotImplementedError
def ready_to_evolve(self) -> bool:
"""Whether this monster is ready to evolve. See assignment spec for specific logic."""
raise NotImplementedError
def evolve(self) -> MonsterBase:
"""Evolve this monster instance by returning a new instance of a monster class."""
raise NotImplementedError
### NOTE
# Below is provided by the factory - classmethods
# You do not need to implement them
# And you can assume they have implementations in the above methods.
@classmethod
@abc.abstractmethod
def get_name(cls) -> str:
"""Returns the name of the Monster - Same for all monsters of the same type."""
pass
@classmethod
@abc.abstractmethod
def get_description(cls) -> str:
"""Returns the description of the Monster - Same for all monsters of the same type."""
pass
@classmethod
@abc.abstractmethod
def get_evolution(cls) -> type[MonsterBase]:
"""
Returns the class of the evolution of the Monster, if it exists.
Same for all monsters of the same type.
"""
pass
@classmethod
@abc.abstractmethod
def get_element(cls) -> str:
"""
Returns the element of the Monster.
Same for all monsters of the same type.
"""
pass
@classmethod
@abc.abstractmethod
def can_be_spawned(cls) -> bool:
"""
Returns whether this monster type can be spawned on a team.
Same for all monsters of the same type.
"""
pass
@classmethod
@abc.abstractmethod
def get_simple_stats(cls) -> Stats:
"""
Returns the simple stats class for this monster, if it exists.
Same for all monsters of the same type.
"""
pass
@classmethod
@abc.abstractmethod
def get_complex_stats(cls) -> Stats:
"""
Returns the complex stats class for this monster, if it exists.
Same for all monsters of the same type.
"""
pass