Move init action manager function to the top

This commit is contained in:
Marek Wolan
2023-08-29 14:33:28 +01:00
parent f0b82cbdfb
commit 40d3e04e64
6 changed files with 79 additions and 79 deletions

View File

@@ -17,6 +17,18 @@ class Network(SimComponent):
"""Initialise the network."""
super().__init__(**kwargs)
def _init_action_manager(self) -> ActionManager:
am = super()._init_action_manager()
am.add_action(
"node",
Action(
func=lambda request, context: self.nodes[request.pop(0)].apply_action(request, context),
validator=AllowAllValidator(),
),
)
return am
def describe_state(self) -> Dict:
"""
Produce a dictionary describing the current state of this object.
@@ -35,18 +47,6 @@ class Network(SimComponent):
)
return state
def _init_action_manager(self) -> ActionManager:
am = super()._init_action_manager()
am.add_action(
"node",
Action(
func=lambda request, context: self.nodes[request.pop(0)].apply_action(request, context),
validator=AllowAllValidator(),
),
)
return am
def add_node(self, node: Node) -> None:
"""
Add an existing node to the network.