-
Notifications
You must be signed in to change notification settings - Fork 4
/
manager.py
103 lines (80 loc) · 2.44 KB
/
manager.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
"""Base class for Managers.
"""
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, Any, Dict
from sc2.units import Units
if TYPE_CHECKING:
from ares import AresBot
from ares.consts import ManagerName, ManagerRequestType
from ares.managers.manager_mediator import ManagerMediator
class Manager(metaclass=ABCMeta):
"""Base class for Managers.
Attributes
----------
ai :
Bot object that will be running the game
config :
Dictionary with the data from the configuration file
manager_mediator :
ManagerMediator used for getting information from other managers.
empty_units :
Empty Units object that's often useful to have around.
"""
def __init__(self, ai: "AresBot", config: Dict, mediator: ManagerMediator) -> None:
"""Set up the manager.
Parameters
----------
ai :
Bot object that will be running the game
config :
Dictionary with the data from the configuration file
mediator :
ManagerMediator used for getting information from other managers.
Returns
-------
"""
super().__init__()
self.ai: AresBot = ai
self.config: Dict = config
self.manager_mediator: ManagerMediator = mediator
self.empty_units: Units = Units([], self.ai)
def initialise(self) -> None:
"""Supply the manager with information that requires the game to have launched.
Returns
-------
"""
pass
def manager_request(
self,
receiver: ManagerName,
request: ManagerRequestType,
reason: str = None,
**kwargs
) -> Any:
"""To be implemented by managers that inherit from IManagerMediator interface.
Parameters
----------
receiver :
The Manager the request is being sent to.
request :
The Manager that made the request
reason :
Why the Manager has made the request
kwargs :
If the ManagerRequest is calling a function, that function's keyword
arguments go here.
Returns
-------
"""
pass
@abstractmethod
async def update(self, iteration: int) -> None:
"""Update the Manager.
Parameters
----------
iteration :
The game iteration.
Returns
-------
"""
pass