use crate::{PerPlayer, Playable, Player, Strategy};
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct Matchup<G: Playable<P>, const P: usize> {
players: PerPlayer<Arc<Player<G, P>>, P>,
}
impl<G: Playable<P>, const P: usize> Matchup<G, P> {
pub fn new(players: PerPlayer<Arc<Player<G, P>>, P>) -> Self {
Matchup { players }
}
pub fn from_players(players: [Player<G, P>; P]) -> Self {
Matchup::new(PerPlayer::new(players.map(Arc::new)))
}
pub fn players(&self) -> &PerPlayer<Arc<Player<G, P>>, P> {
&self.players
}
pub fn names(&self) -> PerPlayer<String, P> {
self.players.map(|player| player.name().to_owned())
}
pub fn strategies(&self) -> PerPlayer<Strategy<G, P>, P> {
self.players.map(|player| player.new_strategy())
}
}