mobile-api: a move's id is its node id, kept across edits
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:
parent
68a9a37757
commit
d9f37f1283
3 changed files with 36 additions and 12 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue