Skip to content

Lesson 08 — Commit a claim and rebuild ​

Where this lesson fits: lesson 07 produces a proposed result. This lesson follows the transaction that turns it into the new playable world.

Time: 2–3 hours

Prerequisites and outcomes ​

Complete lesson 07 and the wall-path lesson. By the end, you can trace the no-result recovery and successful commit paths without mixing their effects.

Prepare and run ​

  1. Reuse the tutorial chapter 06 project prepared in lesson 07; do not copy it again.
  2. In its staged Source\Game\LastPerimeterApp.cs, search for ProcessCompletedTrail and ApplyClaimResult. Follow tutorial chapter 06 steps 3–6. The staged app performs the handoff inline; the final app uses CompleteTrailClaim.
  3. From your learner project's solution folder, run dotnet test --filter "FullyQualifiedName~AreaClaimingSystemTests|FullyQualifiedName~LearningPlan3CaptureTests|FullyQualifiedName~WallSystemV2Tests". At least those three classes must be discovered.
  4. Run dotnet run --project Platforms\DesktopVK and perform the corner-cut and hairpin in the tutorial's checkpoint.
  5. Stage note: score, capture audio, and enemy removal are taught later. Compare the full operation sequence with last-perimeter\Source\Game\LastPerimeterApp.cs in the course repository without copying it into your staged project.

Code anchors ​

  • LastPerimeterApp.CompleteTrailClaim in last-perimeter/Source/Game/LastPerimeterApp.cs
  • ArenaSystem.ApplyClaimResult
  • WallSystemV2.RebuildPlayablePath
  • ClaimedAreaRenderer.MarkDirty
  • last-perimeter/Tests/Systems/PlayableWallPathTraversalTests.cs

Guided operations ​

  1. In the staged app follow the completed trail into ProcessCompletedTrail; in the final app find CompleteTrailClaim and compare the equivalent handoff.
  2. In the staged app, inspect the claimResult is null recovery for a loop endpoint. Verify that it returns the player to the anchor without committing an arena claim or new path. The final app also displays "NO CAPTURE"; score is added later.
  3. In the final app, follow this order: apply to arena; recompute percentage and score; append capture history; rebuild the playable path; invalidate claimed-area rendering; snap the player onto the rebuilt path; issue feedback; remove eliminated enemies; check the level target.
  4. Compare the order with the runtime diagram in the plan overview. Explain why the new path cannot be built from old grid state.
  5. Run the tests in step 3 above, then play through a claim and inspect visual fill and wall traversal. Check score in lesson 10.

Checkpoint ​

At chapter 06, arena ownership, displayed fill, and movement path agree; score is added later. The lesson 07 tests show a null result does not partially apply.

Common mistakes ​

  • Applying the result twice, which double-counts territory or score.
  • Rebuilding the path before applying the claim to the authoritative arena.
  • Forgetting to invalidate the cached claimed-area texture.

Questions and extension ​

Which side effects belong to a transaction's commit stage? Suggest a regression test that would catch a partial update if scoring were moved before validation.