feat: undo in Module 9 and stackAt from Module 8; Lesson 8 quote matches the reference

Baba.undo() restores the level before the last step or move (board snapshot:
objects in age order with ids, the id counter, and won; rules recompiled).
place clears the history. SpellGrid's undo throws/panics 'not supported'.
stackAt / stack_at lists a tile's kinds oldest first, on Baba and SpellGrid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-11-11 11:20:03 +01:00
1 parent 21fb40c6f5
commit 820b378929
27 files changed
+530 -30

No files matched your search

@@ -161,3 +161,22 @@ fn test_08_stacked_you_moves_together() {
assert_eq!(b.pos_of(first), Some((2, 2)));
assert_eq!(b.pos_of(second), Some((2, 2)));
}
#[test]
fn test_08_stack_is_age_ordered() {
let mut b = new_baba(empty_level(3, 3));
write(&mut b, &[("BABA", 0, 0), ("IS", 1, 0), ("YOU", 2, 0)]);
let baba = b.place("baba", 0, 2);
b.place("rock", 1, 2);
b.place("key", 1, 2);
assert_eq!(b.stack_at(1, 2), vec!["rock", "key"]);
b.move_dir(Dir::Right);
assert_eq!(b.pos_of(baba), Some((1, 2)));
assert_eq!(b.kinds_at(1, 2), vec!["baba", "key", "rock"]);
// Oldest first: Baba arrived last, but it was placed first.
assert_eq!(b.stack_at(1, 2), vec!["baba", "rock", "key"]);
assert_eq!(b.stack_at(0, 2), Vec::<String>::new());
}