- commit
- dabf07be33ea276c7d0210ed94181386ea01b3ec
- parent
- eb161f4649904aaa3204eaa555743213db95560b
- author
- dami <gazey55@gmail.com>
| M | site/ | 28 | ++++++++++++++++++++-------- |
@@ -174,6 +174,7 @@ type Frame = {
174174 tileHue: Int16Array; // per tile: agent hue or -1175175 agentName: Map<string, string>;176176 reached: Uint8Array; // per tile: 1 if some territory has reached it177+ final: boolean; // the last revision of a finished game: never-reached tiles are shown177178 };178179 179180 /** `State.reached` once the fold provides it; every tile reached before. */@@ -183,7 +184,7 @@ function reachedOf(s: State): Uint8Array {
183184 return new Uint8Array(s.tiles.length).fill(1);184185 }185186 186-function frameOf(s: State, hues: Map<string, number>): Frame {187+function frameOf(s: State, hues: Map<string, number>, final = false): Frame {187188 const n = s.tiles.length;188189 const tileHue = new Int16Array(n).fill(-1);189190 // a solved tile is its solver's; a revealed one is its revealer's while@@ -203,7 +204,7 @@ function frameOf(s: State, hues: Map<string, number>): Frame {
203204 }204205 const agentName = new Map<string, string>();205206 for (const a of s.agents) agentName.set(a.id, a.name || a.id);206- return { s, tileHue, agentName, reached: reachedOf(s) };207+ return { s, tileHue, agentName, reached: reachedOf(s), final };207208 }208209 209210 // ---------------------------------------------------------------- raster@@ -253,7 +254,7 @@ function renderMapTile(
253254 }254255 return true;255256 };256- const fog = level <= 1 ? fogFill(theme) : null;257+ const fog = level <= 1 && f.final ? fogFill(theme) : null;257258 const hues: number[] = [];258259 const fillOf = (id: number): string | null => {259260 const st = statusOfCell(id);@@ -262,7 +263,7 @@ function renderMapTile(
262263 if (!c) return null; // a hole263264 return scene.fill([], "solved", true, 0); // ownerless known cell (v2 filler)264265 }265- if (st === "hidden" && !c && unreachedCell(id)) return fog; // the fog: void at L2+266+ if (st === "hidden" && !c && unreachedCell(id)) return fog; // fog: void, unless final266267 const age = c ? s.revision - c.rev : RECENCY_REVS;267268 const recency = c && age < RECENCY_REVS ? 1 - age / RECENCY_REVS : 0;268269 huesOfCell(id, hues);@@ -317,9 +318,9 @@ function renderMapTile(
317318 for (const id of tiles) {318319 const st = s.tiles[id];319320 if (st === "hidden") {320- // at L2+ an unreached tile is only its outline, faint: the shape321- // of what is there to explore, nothing more322- if (level >= 2 && f.reached[id] === 0) {321+ // an unreached tile is void; at the end of a finished game its322+ // outline shows faintly, as what was never explored323+ if (level >= 2 && f.reached[id] === 0 && f.final) {323324 const t = s.manifest!.tiles[id];324325 ctx.strokeStyle = theme.muted;325326 ctx.globalAlpha = 0.14;@@ -836,7 +837,18 @@ export default function Viewer(
836837 huesRef.current = h;837838 return h;838839 }, [final.agents, final.geo]);839- const frame = useMemo(() => frameOf(state, hues), [state, hues]);840+ // fog is fog while a game runs or is scrubbed; only the last revision841+ // of a finished game shows what was never explored842+ const frame = useMemo(843+ () =>844+ frameOf(845+ state,846+ hues,847+ state.revision === events.length - 1 &&848+ events[events.length - 1]?.kind === "end",849+ ),850+ [state, hues, events],851+ );840852 841853 // change log: which map tiles each event touched (fed once per event)842854 const fed = useRef(0);