-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.py
42 lines (32 loc) · 1.26 KB
/
action.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
import player, world
class Action():
def __init__(self, method, name, hotkey, **kwargs):
self.method = method
self.hotkey = hotkey
self.name = name
self.kwargs = kwargs
def __str__(self):
return "{}: {}".format(self.hotkey, self.name)
class MoveNorth(Action):
def __init__(self):
super().__init__(method=player.move_north, name='Move north', hotkey='n')
class MoveSouth(Action):
def __init__(self):
super().__init__(method=player.move_south, name='Move south', hotkey='s')
class MoveEast(Action):
def __init__(self):
super().__init__(method=player.move_east, name='Move east', hotkey='e')
class MoveWest(Action):
def __init__(self):
super().__init__(method=player.move_west, name='Move west', hotkey='w')
class ViewInventory(Action):
"""Prints the player's inventory"""
def __init__(self):
super().__init__(method=player.print_inventory, name='View inventory', hotkey='i')
class Attack(Action):
def __init__(self, enemy):
super().__init__(method=player.attack, name="Attack", hotkey='a', enemy=enemy)
# Save
class SaveAndExit(Action):
def __init__(self):
super().__init__(method=player.save_and_exit, name="Save and Exit", hotkey='x')