pub struct Occultation {
region: Area, // automatically affect pieces here
occulter: PieceId, // kept in synch with PieceOccult::active
+ pieces: BTreeSet<PieceId>, // kept in synch with PieceOccult::passive
+ #[serde(flatten)] views: OccultationViews,
+}
+
+#[derive(Clone,Debug,Serialize,Deserialize)]
+pub struct OccultationViews {
views: Vec<OccultView>,
#[serde(default)] defview: OccultationKind,
- pieces: BTreeSet<PieceId>, // kept in synch with PieceOccult::passive
}
#[derive(Clone,Debug,Serialize,Deserialize)]
pub struct OccultView {
- players: Vec<PlayerId>,
#[serde(default)] occult: OccultationKind,
+ players: Vec<PlayerId>,
}
#[derive(Clone,Copy,Debug,Serialize,Deserialize)]
}
}
-impl Occultation {
+impl OccultationViews {
pub fn get_kind(&self, player: PlayerId) -> &OccultationKind {
let kind = self.views.iter().find_map(|view| {
if view.players.contains(&player) { return Some(&view.occult); }
);
kind
}
+}
+
+impl Occultation {
+ pub fn get_kind(&self, player: PlayerId) -> &OccultationKind {
+ self.views.get_kind(player)
+ }
pub fn in_region(&self, pos: Pos) -> bool {
self.region.contains(pos)