# Reference patch — 01-power-up-squares

The answer key for how the reference absorbs this change, and the thing that makes `budget.json`
reproducible. **Never shipped to the candidate.**

1. **Overlay** `../contract-delta/SquareEffect.java` onto `contract/SquareEffect.java` and **add**
   `../contract-delta/PowerUp.java` to `contract/`. Contract files are given, so nothing here is
   charged.

2. **Add** `PowerUpRollsAgain.java` (in this directory) to `reference/src/`. New file, so
   `measureChange` charges nothing for it.

3. **Change one line** in `reference/src/Game.java`, in the middle convenience constructor:

   ```diff
   -        this(board, players, dice, new BoardGeometry(), new SixRollsAgain());
   +        this(board, players, dice, new BoardGeometry(), new PowerUpRollsAgain(board, new SixRollsAgain()));
   ```

   `SixRollsAgain` is wrapped, not edited or deleted. "A six rolls again" is still one small class
   that can still be read and tested on its own.

4. **Add two lines** of board data in `reference/src/BoardLayout.java`, inside `standard()`:

   ```diff
                    24, new Ladder(30),
   +                7, new PowerUp(),
   +                14, new PowerUp(),
                    17, new Snake(6),
   ```

   (`Map.of` takes at most ten pairs and this brings it to exactly ten. A board with more power-ups
   would want `Map.ofEntries`; that is a one-line change too and not worth pre-empting.)

5. **Add one line** to the exhaustive switch in `reference/src/BoardGeometry.java`:

   ```diff
                case Ladder ladder -> ladder.top();
   +            case PowerUp powerUp -> square;
   ```

6. **Add one line** to the exhaustive switch in `Demo`'s commentator, `reference/src/Demo.java`:

   ```diff
                case Plain plain -> "nothing happened at " + from;
   +            case PowerUp powerUp -> "on the power-up at " + from;
   ```

## What steps 5 and 6 are actually worth

They were **not found by a failing test**. They were two `javac` errors —
*"the switch expression does not cover all possible input values"* — with the file and line, before
a single test ran. That is the entire argument for `sealed` over an enum with a tag field or a
string discriminator: adding a variant is a compile error at every site that has to care, and the
compiler enumerates the sites for you.

The price is honest and visible here: **a sealed hierarchy cannot be extended by adding a file
alone.** Four of the six charged lines exist because of that choice. The trade the reference is
making, and the thing to defend in Phase 5, is that four named compile errors are cheaper than one
silent wrong answer in the middle of a game — and that the seams keep those four lines *tiny* and
in files that do one thing each, instead of scattering them through the turn loop.

## Measurement

`reference_diff = 6` (BoardGeometry +1, BoardLayout +2, Demo +1, Game +1/-1), so
`diff_budget = max(3, 6 + ceil(6/2)) = 9`.

The curveball suite is green after the patch: **6 tests, 6 passed.**

The base suite is **not** expected to stay green, and it does not: 13 of 16 pass. The three that
fail — *"a six lets the same player roll again"*, *"a roll that would pass the final square is
wasted"* and *"wins by landing exactly on the final square"* — are the ones whose scripted dice runs
a player over square 7 or the ladder to square 14, which are now power-ups and now grant an extra
roll. That is what the requirement means; the base suite asserts the old board.
