fix coalition assigning

This commit is contained in:
132nd-Professor
2022-08-12 17:47:48 +02:00
parent c1ef22f3a3
commit cda33692cf
4 changed files with 25 additions and 6 deletions
+14 -1
View File
@@ -38,7 +38,8 @@ impl Display for Coalition {
Self::Blue => "blue".to_string(),
Self::Red => "red".to_string(),
Self::Purple => "purple".to_string(),
_ => unreachable!("We never need these variants"),
Self::All => "all".to_string(),
Self::Unknown => "unknown".to_string(),
}
)
}
@@ -64,4 +65,16 @@ impl<'a> CoalitionIDs<'a> {
Coalition::All | Coalition::Unknown => false,
};
}
pub fn get(&self, id: &'a str) -> Option<Coalition> {
if self.blue.contains(id) {
Some(Coalition::Blue)
} else if self.red.contains(id) {
Some(Coalition::Red)
} else if self.purple.contains(id) {
Some(Coalition::Purple)
} else {
None
}
}
}