Skip to content

Armory variety: withhold two random offers each wave#2

Open
lfscheidegger wants to merge 1 commit into
andrewmunn:mainfrom
lfscheidegger:shop-offer-variety
Open

Armory variety: withhold two random offers each wave#2
lfscheidegger wants to merge 1 commit into
andrewmunn:mainfrom
lfscheidegger:shop-offer-variety

Conversation

@lfscheidegger

Copy link
Copy Markdown

What

The between-wave armory always offered the same five upgrade lines (interceptor, shield, laser, fire rate, twin barrels), so every run shopped the same way. This rolls two of the five slots to withhold each wave, leaving three on the counter — so build order and run feel vary playthrough to playthrough, without changing the underlying economy.

How

  • getShopItems() now tags each offer with a stable key and filters out the wave's withheld set.
  • The set is rolled once per wave clear in endWave() — deliberately not inside getShopItems(), which rebuilds every render frame and would make the shop flicker.
  • The roll is serialized into the checkpoint and restored on continueGame(), so reopening the armory after a reload shows the same stock rather than letting you re-roll by refreshing. Older saves without the field just roll fresh.
  • Count is configurable via config.shop.dropPerWave (default 2); it's clamped to always leave at least one purchasable offer.
  • Added a small non-mutating shuffle() to utils.js.

Tests

  • New coverage for the drop count, the keep-at-least-one clamp, the per-wave reroll, and reload stability.
  • The existing shop/touch/save tests assume a full counter, so the test preload (setup.js) defaults dropPerWave to 0; the new tests opt back in explicitly. Full suite passes (205).

Try it

Clear a wave to reach the armory — you'll see three offers instead of five; clear another and a different pair is withheld. Refresh mid-armory and hit Continue: the same three persist.

The between-wave armory always listed the same five upgrade lines, so
every run shopped identically. Now each wave clear rolls two of the five
slots to withhold, leaving three on the counter — build order varies run
to run without touching the underlying economy.

The roll happens once on wave clear (not in getShopItems, which rebuilds
every frame and would flicker) and rides along in the checkpoint, so
revisiting the armory after a reload shows the same stock instead of
re-rolling into a fresh one. The count lives in config.shop.dropPerWave.

Tests cover the drop count, the keep-at-least-one clamp, the per-wave
reroll, and reload stability; the existing shop tests opt out of the drop
(setup.js) so they stay deterministic.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant