-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction_handler.py
32 lines (28 loc) · 1.48 KB
/
action_handler.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
from action_handlers.end_turn_action_handler import EndTurnActionHandler
from actions.end_turn_action import EndTurnAction
from actions.move_action import MoveAction
from actions.attack_action import AttackAction
from actions.drop_action import DropAction
from actions.equip_action import EquipAction
from actions.pickup_action import PickupAction
from actions.unequip_action import UnequipAction
from action_handlers.move_action_handler import MoveActionHandler
from action_handlers.attack_action_handler import AttackActionHandler
from action_handlers.drop_action_handler import DropActionHandler
from action_handlers.equip_action_handler import EquipActionHandler
from action_handlers.pickup_action_handler import PickupActionHandler
from action_handlers.unequip_action_handler import UnequipActionHandler
class ActionHandler:
def __init__(self, dungeon):
self.__dungeon = dungeon
self.__actionHandlers = {
AttackAction.__name__: AttackActionHandler(dungeon),
MoveAction.__name__: MoveActionHandler(dungeon),
DropAction.__name__: DropActionHandler(dungeon),
EquipAction.__name__: EquipActionHandler(dungeon),
PickupAction.__name__: PickupActionHandler(dungeon),
UnequipAction.__name__: UnequipActionHandler(dungeon),
EndTurnAction.__name__: EndTurnActionHandler(dungeon)
}
def handle_action(self, action):
return self.__actionHandlers[action.__class__.__name__].perform_action(action)