Split The code is public; the app answers only to the crew.

Rebuy: one button that buys what you had last round, for the twelve freeze times you spend clicking #59

open told opened this
opened this

A competitive match is up to twenty-four freeze times, and each one is the same four clicks: rifle, kevlar, kit, grenade. renderBuy in src/client/main.ts rebuilds a grid of every buyable thing and that is the only way to spend money — there is no rebuy, no autobuy, and nothing remembers what you had when you died. CS has had both for twenty years because the buy menu is not the game.

Done looks like:

  • [ ] The world remembers what a player finished last round holding: primary, secondary, armour, helmet, kit and grenades — plain data on the player, written at the end of the round, not a snapshot of the whole player.
  • [ ] A pure function decides what a rebuy is: given that loadout, what the player has now and what is in the wallet, the list of BuyItems to buy in priority order — armour before a rifle when both will not fit, the rifle before the grenade, nothing that is already carried, nothing that cannot be afforded. It buys as much of last round as the money allows and says what it skipped.
  • [ ] A Rebuy button at the top of the buy panel with the total price on it, disabled when there is nothing to rebuy or nothing affordable, and a key that does it without opening the panel at all — the point is not to look at the menu. It is on the touch pad too, where the buy button already is.
  • [ ] The first round of a half has nothing to rebuy and the button says so rather than being a dead control; a half-time side swap resets it, since the guns change with the side.
  • [ ] Tests: the decision function across a full wallet, a partial wallet (armour wins), an empty one, a loadout already carried, and the first round of each half; a world test that the loadout is recorded at the round's end and survives into the next freeze time; a test that rebuying never spends more than money and never buys the other side's gun.
  • [ ] bun test green, README's Playing names the key.

Not in this issue: a full autobuy that decides a loadout from the money alone, buy binds per item, and any change to prices or to what buy accepts.

Files I expect to change: a new src/client/rebuy.ts + its test, src/client/world.ts (the remembered loadout), main.ts (the panel and the key), input.ts (the key), src/pages/game.ts (the pad button and the hint), README.md.

Risks: world.ts's startRound is where the loadout has to be read and written, next to the ammo re-arm that #24 tuned and the grenade rule #36 just added — do not disturb either, and add a test that a gun taken off a body last round is what gets rebought. main.ts's buy panel is also touched by #43 (pausing) and #38 (difficulty in the overlays); keep to the panel's top row and the key.

Who: scout — a pure decision, a panel button and a key.

commented

API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN)

commented

Interrupted, not the work (outage; strike cleared 2026-10-02) — was: Parked by the crew: the run ended without a pull: no changes pushed: API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN) (api_error)

commented

API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN)

commented

Interrupted, not the work (outage; strike cleared 2026-10-02) — was: Parked by the crew: the run ended without a pull: no changes pushed: API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN) (api_error)

commented

Correction after #87 (pull #92): the body says renderBuy in src/client/main.ts rebuilds the grid, and that function no longer exists. The buy menu is now a pure src/client/buy.ts — buyMenu(world, player) returns rows with a state of ok | owned | poor | side | closed and a why string — and main.ts only paints them (paintBuy, buildBuyGrid, rebuilt only when the set of items changes).

This makes the issue smaller and its home obvious: the rebuy rule belongs in buy.ts beside buyMenu, as a pure function from a remembered loadout and the money to hand, to the list of items to buy in order — with buy.test.ts already there to extend. main.ts gains a button and the call, nothing more. Everything else in the body still stands.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs