use std::collections::HashMap;
use std::fmt::Display;
use serde::{Deserialize, Serialize};
use crate::allyset::AllySet;
use crate::decision::DecisionPath;
pub type OutcomeMap = HashMap<Outcome, DecisionPathMetadata>;
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Outcome {
pub survivors: AllySet,
pub loyal: AllySet,
pub rescued_crew: bool,
}
impl Display for Outcome {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
writeln!(f, "Survivors: {}", self.survivors)?;
write!(f, "Loyal: ")?;
if self.loyal.len() == self.survivors.len() {
writeln!(f, "all survivors")?;
} else {
writeln!(f, "{}", self.loyal)?;
}
let past_tense_verb = if self.rescued_crew {
"rescued"
} else {
"abandoned"
};
writeln!(f, "The crew was {past_tense_verb}.")
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct DecisionPathMetadata {
pub count: usize,
pub example: DecisionPath,
}