Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Market Barrow rules: a tested `market-barrow/barrow.js` that buys and sells a barrow of goods across village stalls over ten days, from plain data #168

shipped production is serving it opened this has it
opened this

A new Strategy game for the catalogue: push a barrow between four village stalls for ten days, buying where a good is cheap and selling where it is dear, and end with more coins than you started. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] market-barrow/barrow.js holds the rules as plain data in, plain data out, with no DOM. start(seed) sets stated starting coins, a barrow of stated capacity, four stalls and at least three goods, and seeded prices for each good at each stall that change each day; the same seed always gives the same prices.
  • [ ] buy(state, good, n) and sell(state, good, n) trade at the current stall and refuse spending more than you have, carrying more than the barrow holds, or selling what you do not carry. travel(state, stall) moves to another stall and costs one day; travelling to the stall you are at is refused.
  • [ ] After the tenth day the game ends and reports the coins and the best, with a win line at or above a stated target and a loss line below it; goods still in the barrow count for nothing.
  • [ ] market-barrow/barrow.test.mjs asserts each rule above: the same seed giving the same prices, each refused trade, a refused travel, the day count, a hand-played profit, the end after day ten, and the win and loss lines.
  • [ ] bun test passes for the new file.

Files: market-barrow/barrow.js, market-barrow/barrow.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html, town.js or rounds.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs