pub struct TroopManager { /* private fields */ }Expand description
Manages all active troops in the system.
Implementations§
Source§impl TroopManager
impl TroopManager
Sourcepub fn with_router(router: Arc<MessageRouter>) -> Self
pub fn with_router(router: Arc<MessageRouter>) -> Self
Create a new troop manager with a shared message router.
Sourcepub fn router(&self) -> &Arc<MessageRouter>
pub fn router(&self) -> &Arc<MessageRouter>
Get a reference to the underlying message router.
Sourcepub fn register_capabilities(
&self,
fighter_id: FighterId,
capabilities: Vec<String>,
)
pub fn register_capabilities( &self, fighter_id: FighterId, capabilities: Vec<String>, )
Register capabilities for a fighter (used by Specialist strategy).
Sourcepub fn form_troop(
&self,
name: String,
leader: FighterId,
members: Vec<FighterId>,
strategy: CoordinationStrategy,
) -> TroopId
pub fn form_troop( &self, name: String, leader: FighterId, members: Vec<FighterId>, strategy: CoordinationStrategy, ) -> TroopId
Form a new troop with a leader and initial members.
The leader is automatically included in the members list.
Sourcepub fn recruit(
&self,
troop_id: &TroopId,
fighter_id: FighterId,
) -> PunchResult<()>
pub fn recruit( &self, troop_id: &TroopId, fighter_id: FighterId, ) -> PunchResult<()>
Add a fighter to an existing troop.
Sourcepub fn dismiss(
&self,
troop_id: &TroopId,
fighter_id: &FighterId,
) -> PunchResult<()>
pub fn dismiss( &self, troop_id: &TroopId, fighter_id: &FighterId, ) -> PunchResult<()>
Remove a fighter from a troop.
If the dismissed fighter is the leader, the first remaining member becomes the new leader. Returns an error if this would leave the troop empty.
Sourcepub fn disband_troop(&self, troop_id: &TroopId) -> PunchResult<String>
pub fn disband_troop(&self, troop_id: &TroopId) -> PunchResult<String>
Dissolve a troop entirely.
Sourcepub fn list_troops(&self) -> Vec<Troop>
pub fn list_troops(&self) -> Vec<Troop>
List all troops.
Sourcepub fn assign_task(
&self,
troop_id: &TroopId,
task_description: &str,
) -> PunchResult<Vec<FighterId>>
pub fn assign_task( &self, troop_id: &TroopId, task_description: &str, ) -> PunchResult<Vec<FighterId>>
Assign a task to a troop, returning the fighter(s) that should handle it based on the troop’s coordination strategy.
This method uses the MessageRouter to actually dispatch tasks to fighters and collects results according to the strategy.
Sourcepub async fn assign_task_async(
&self,
troop_id: &TroopId,
task_description: &str,
) -> PunchResult<TaskAssignmentResult>
pub async fn assign_task_async( &self, troop_id: &TroopId, task_description: &str, ) -> PunchResult<TaskAssignmentResult>
Assign a task using the full async strategy dispatch, returning a
TaskAssignmentResult with routing details and collected results.
Sourcepub async fn execute_pipeline(
&self,
troop: &Troop,
initial_input: &str,
) -> PunchResult<TaskAssignmentResult>
pub async fn execute_pipeline( &self, troop: &Troop, initial_input: &str, ) -> PunchResult<TaskAssignmentResult>
Pipeline: Execute the full pipeline, passing each stage’s output to the next.
Sourcepub fn tally_votes(&self, votes: &[(FighterId, String)]) -> Option<String>
pub fn tally_votes(&self, votes: &[(FighterId, String)]) -> Option<String>
Tally votes and determine the majority result.
Sourcepub fn is_in_troop(&self, fighter_id: &FighterId) -> bool
pub fn is_in_troop(&self, fighter_id: &FighterId) -> bool
Check if a fighter is a member of any troop.
Sourcepub fn get_fighter_troops(&self, fighter_id: &FighterId) -> Vec<TroopId>
pub fn get_fighter_troops(&self, fighter_id: &FighterId) -> Vec<TroopId>
Get all troops a fighter belongs to.
Sourcepub fn pause_troop(&self, troop_id: &TroopId) -> PunchResult<()>
pub fn pause_troop(&self, troop_id: &TroopId) -> PunchResult<()>
Pause a troop.
Sourcepub fn resume_troop(&self, troop_id: &TroopId) -> PunchResult<()>
pub fn resume_troop(&self, troop_id: &TroopId) -> PunchResult<()>
Resume a paused troop.