mobile-api: a move's id is its node id, kept across edits
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

New moves come at the end and a removed one stays unreachable, so the
cursor and the report's marks stay on their moves when the game changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-26 00:33:55 +03:00
parent 68a9a37757
commit d9f37f1283
3 changed files with 36 additions and 12 deletions

View file

@ -373,6 +373,12 @@ impl Game {
self.nodes.len()
}
/// Every node ever made, by id (detached ones too: an id never changes and is never
/// reused, so it can name a move across edits).
pub fn all_nodes(&self) -> impl Iterator<Item = NodeId> + '_ {
(0..self.nodes.len()).map(|i| NodeId(i as u32))
}
/// Ids of all attached nodes in depth-first PGN order (root first).
pub fn attached_nodes(&self) -> Vec<NodeId> {
let mut out = Vec::new();