Skip to content

Lesson 15 — Separate level, run, and profile progression ​

Where this lesson fits: screen flow and profile persistence exist. Now connect level completion to a deterministic choice whose effects last for the run, not forever.

Time: 2–3 hours

Prerequisites and outcomes ​

Complete lessons 12 and 14. By the end, you can trace an upgrade offer, selection, run-state update, and application at the next level boundary.

Prepare and run ​

  1. From your learner project's solution folder, follow tutorial chapter 13 steps 1–6.
  2. Open Source\Data\RunModifiers.cs, GameSession.cs, and the app's UpdateLevelComplete, UpdateUpgradeSelect, and SetupLevel. Run the focused command below.
  3. Run dotnet run --project Platforms\DesktopVK and follow the tutorial's checkpoint to clear a level, select an upgrade, and start a fresh run.

Code anchors ​

  • last-perimeter/Source/Data/RunModifiers.cs
  • last-perimeter/Source/Data/RunUpgradeChoice.cs
  • last-perimeter/Source/Data/GameSession.cs (ApplyUpgrade)
  • last-perimeter/Source/Systems/PowerupSystem.cs (CreateUpgradeChoices)
  • last-perimeter/Tests/Systems/RunModifiersTests.cs

Guided operations ​

  1. Trace level completion into draft generation. Record the seed inputs and confirm identical inputs produce the same offers.
  2. Trace a menu selection into GameSession.ApplyUpgrade. Separate a modifier from an immediate resource such as an extra life.
  3. Follow the modifier to its actual use: setup configuration, movement speed, fuse timing, respawn grace, or claim scoring.
  4. Compare the lifetimes: level state is rebuilt by SetupLevel; run state survives level changes; profile state survives runs.
  5. Start a fresh run and check that modifiers do not leak. Run the focused tests.
powershell
dotnet test --filter FullyQualifiedName~RunModifiersTests

Checkpoint ​

An upgrade is recorded once, affects only the intended run, and reaches live gameplay at a named point rather than by mutating multiple systems ad hoc.

Common mistakes ​

  • Storing run modifiers in the persistent profile.
  • Applying a modifier to a live system and then applying it again during level setup.
  • Using an unseeded shuffle when repeatable offers are part of the design.

Questions and extension ​

What caps or trade-offs would keep repeated additive upgrades from breaking movement or balance? Propose a test for a cap before changing the implementation.