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:
1 parent
21fb40c6f5
commit
820b378929
27 files changed
+530
-30
No files matched your search
@@ -163,3 +163,25 @@ test("test_08_stacked_you_moves_together", () => {
|
||||
expect(b.posOf(first)).toEqual([2, 2]);
|
||||
expect(b.posOf(second)).toEqual([2, 2]);
|
||||
});
|
||||
|
||||
test("test_08_stack_is_age_ordered", () => {
|
||||
const b = newBaba(emptyLevel(3, 3));
|
||||
write(b, [
|
||||
["BABA", 0, 0],
|
||||
["IS", 1, 0],
|
||||
["YOU", 2, 0],
|
||||
]);
|
||||
const baba = b.place("baba", 0, 2);
|
||||
b.place("rock", 1, 2);
|
||||
b.place("key", 1, 2);
|
||||
|
||||
expect(b.stackAt(1, 2)).toEqual(["rock", "key"]);
|
||||
|
||||
b.move("right");
|
||||
|
||||
expect(b.posOf(baba)).toEqual([1, 2]);
|
||||
expect(b.kindsAt(1, 2)).toEqual(["baba", "key", "rock"]);
|
||||
// Oldest first: Baba arrived last, but it was placed first.
|
||||
expect(b.stackAt(1, 2)).toEqual(["baba", "rock", "key"]);
|
||||
expect(b.stackAt(0, 2)).toEqual([]);
|
||||
});
|
||||
Reference in new issue
Block a user