chiark / gitweb /
hidden recompute: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 2 Mar 2021 22:48:23 +0000 (22:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 2 Mar 2021 23:08:47 +0000 (23:08 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hidden.rs

index 313cd180a7de6363a09f36c9a0673c6f0a0d0d01..55ca8fd6d34266f78da1e5413658e7596d82ac58 100644 (file)
@@ -714,40 +714,39 @@ mod recompute {
       r
     }
     pub fn mark_dirty(&mut self, occid: OccId) { self.outdated.insert(occid); }
-    pub fn implement(self,
-                     _gplayers: &GPlayers,
-                     _gpieces: &mut GPieces,
-                     _goccults: &mut GameOccults,
-                     _ipieces: &IPieces) -> Implemented {
-      dbg!(&self.outdated); // xxx
-
-      // for each occultation
-
-      // check to see if we have any views that are scrambled or
-      // displaced or invisible (we must do invisible too, so that
-      // when they reappear the ids have been permuted)
-      //
-      // err won't we always?
-      //
-      // choose a single permutation of the pieces in
-      // the Occultation::pieces map, and put the corresponding
-      // numbers in there
-      //
-      // somehow make the per player id maps permute the same way
-      //   so we have all the pieces and their current visible piece ids
-      //   get all the visible piece ids, sort them, then permute them
-      //   then assign them like that
-      //
-      // when we are done, displaced sees
-      //   but how do we send an update?
-      //   when one is taken out of the hand, leaves a gap?
-      //   does another one come in ?
-      // xxx
-
+    pub fn implement(mut self,
+                     gplayers: &GPlayers,
+                     gpieces: &mut GPieces,
+                     goccults: &mut GameOccults,
+                     ipieces: &IPieces) -> Implemented {
+      for occid in self.outdated.drain() {
+        if let Some(occ) = goccults.occults.get_mut(occid) {
+          permute(occid, occ, gplayers, gpieces, ipieces);
+        }
+      }
 
       Implemented { }
     }
   }
+
+  #[allow(unused_variables)]
+  fn permute(occid: OccId,
+             occ: &mut Occultation,
+             gplayers: &GPlayers,
+             gpieces: &mut GPieces,
+             ipieces: &IPieces) {
+    // We must permute for if we have any views that are scrambled
+    // or displaced obviously.  For invisible too, so that when they
+    // reappear the ids have been permuted.  And that's all the
+    // non-Visible views which an occultation ought to have at least
+    // one of...
+    //
+    // We choose a single permutation of the pieces in the
+    // Occultation::notches.
+
+      
+
+  }
 }
 use recompute::*;