Fix incorrect condition in "Chains of computations" example (#8109)

Fixes #8097

The refactored example in the "Chains of computations" section uses
an incorrect condition that changes the game logic from the original.

The original Effect-based code advances the round after 4 gold cards:
- Increments first (0→1, 1→2, 2→3, 3→4)
- Then checks `goldCardCount > 3` (true when count is 4)

The refactored code with `goldCardCount <= 3` allows 5 gold cards:
- Checks before incrementing
- Allows counts 0, 1, 2, 3 to increment (4 values)
- Advances on the 5th card (when count is 4)

This fix changes the condition to `goldCardCount < 3`:
- Allows counts 0, 1, 2 to increment (3 values)
- Advances on the 4th card (when count is 3)
- Matches the original behavior

Verified by tracing execution logic and building the docs site locally.

Co-authored-by: PaulyBearCoding <PaulyBearCoding@users.noreply.github.com>
This commit is contained in:
PaulyBearCoding
2025-11-05 18:25:46 -08:00
committed by GitHub
parent 6a708898a6
commit d271a7ac11

View File

@@ -437,7 +437,7 @@ function Game() {
// ✅ Calculate all the next state in the event handler
setCard(nextCard);
if (nextCard.gold) {
if (goldCardCount <= 3) {
if (goldCardCount < 3) {
setGoldCardCount(goldCardCount + 1);
} else {
setGoldCardCount(0);