15 KiB
App Plan: Play Files TCG Against the Bot
Prepared 2026-09-30 against rules v0.9 and the simulator in sim/.
Status, 2026-09-30: built. Levels 1 and 2 are in
app/; see app/README.md. The open decisions in section 7 were given defaults for now: the app runs locally (the build is a static site, so it can be hosted later), undo is on only in playtest mode, and the odds preview is on, with a setting to turn it off.
This plan covers a browser app where one person plays a full game of Files TCG against the simulator's greedy bot. It comes in two levels:
- Level 1, the playtest prototype. Every rule and card works, and the screen is plain. It replaces paper playtests.
- Level 2, properly playable. You act by clicking the board and your cards, which look like the printed cards. Combat is easy to read, and games can be saved, undone and replayed. Someone who has read QUICKSTART.md can play without help.
Online play between two people, sound, mobile layouts and a tutorial are out of scope. Those are level 3.
1. What the Simulator Already Provides
The engine in sim/src/engine.ts is already built the way a game app needs:
| Function | What the app uses it for |
|---|---|
createGame({ pool, decks, seed, rules }) |
Starts a game. The same seed always gives the same game. |
decider(s) |
Whose decision it is: the human or the bot. |
legalActions(s) |
Every legal move right now. The UI only ever picks from this list. |
applyAction(s, a) |
Makes the move, then runs the game until the next decision. |
viewFor(s, p) |
Player p's view: the opponent's hand, deck, Server pile and face-down Anomalies are hidden. |
actionCost(s, a) |
The Gb cost to show on a move. |
greedyBot(DEFAULT_GREEDY) |
The opponent. It already only sees its own viewFor, so it can't cheat. |
winChance(atk, def) in odds.ts |
The odds of winning one combat roll, for the attack preview. |
checkInvariants(s) |
Catches engine bugs during play. |
Response windows only stop for a player who actually has an Execution or Ability they could use. The engine already passes automatically for everyone else.
Measured numbers. These come from 50 greedy-vs-greedy games, counting South as the human:
| Measure | Value |
|---|---|
| Decisions per game for one player | 367, about 10 per command |
| Decisions where the only options are End, Pass or Salvage | 55 |
| Legal moves per decision | 23 on average, 112 at most |
| Response windows reaching you in the bot's command | 43 per game |
| Combat windows (before and after the roll) | 28 when you attack, 26 when the bot attacks |
| Card prompts ("pick one") | 16 per game |
| Bot's slowest move | 1.3 ms |
What this means for the design:
- Speed is not a concern. The bot can run in the browser, and no server is needed.
- Click count is the main design problem. The large number of decisions is why both levels include step skipping. Level 2 adds settings for when the game stops to let you respond.
2. Architecture
files-tcg/
sim/ engine, card scripts, bots (unchanged, apart from section 3)
app/
index.html
src/
main.tsx start screen and page shell
match.ts game controller: real state, bot loop, undo stack
describe.ts re-export of sim/src/describe.ts
ui/ board, hand, panels, prompts
vite.config.ts
package.json
- Stack: Vite, TypeScript and Preact. Preact is the only runtime dependency. It's a small React
equivalent, and it's worth having because level 2 has a lot of selection and highlighting state.
Vite serves the sim's
.tsimports as they are. - The app imports the engine from
../sim/src, and nothing is copied. Rule changes you test in the sim appear in the app automatically. The app only breaks if theActionorGameStateshapes change. - Card data is imported live. The app loads
cards.csvwith Vite's?rawimport, so card edits appear on reload. - The controller in
match.tsholds the real state. Components only receiveviewFor(s, human), so the UI can't show the bot's hand by mistake. - Every move is one of the actions from
legalActions. The UI filters and labels that list and never builds anActionitself. Illegal moves are therefore impossible, and the rules stay in one place.
3. Sim Changes Needed First
These are small, and each keeps npm test passing.
- Browser-safe card loading.
loadCardsreads the file withnode:fs. Split it intoparseCards(csvText, sets)incards.ts, and move the file-reading wrapper into a Node-only module used by the CLI and tests. describeAction(s, a)in a newsim/src/describe.ts. It gives a readable label for every action type, for examplePlay Execute: Force Reboot on D2 (5 Gb)orPlace Firewall Lv 2 on B1–C2 (4 Gb). Execution and Ability arguments (target Anomaly, cards, mode) need labels too.describeArgsincards/hardware.tsis a starting point and can be generalized. Add a test: across fuzz games, every legal action gets a label, and no two actions in the same decision share one.- Private log lines.
say()writes a single public log, and some lines name hidden cards. For example, "North chooses: Bottom Undefined Behavior and draw again" names a card in North's hand. Givesayan optional audience and a public version of the message. Then audit the 92saycalls.
4. Level 1: Playtest Prototype
Goal: a full game against the bot in a browser, on the classic board. Every card works, and the look is plain.
+--------------------------------------------------------------------------+
| NORTH (bot) 12 Gb 6 cards 4/10 locations Anomalies [1][2][■][■] |
+-----------------------------------------------+--------------------------+
| | Log |
| board (SVG) | - Round 4, command 13 - |
| locations, Servers, Anomalies, gateways | South captures B2 with |
| | Server Farm: +8 Gb |
| hover a location for details | North places a Firewall |
| | ... |
+-----------------------------------------------+--------------------------+
| SOUTH (you) 16 Gb 5/10 locations Anomalies [1][2][3][■] |
| Hand: [Overclocked CPU 6][Execute: Packet Flood 5][Resource Leech 5] ... |
| Step: Deploy > Play > Attack > Play again [End step] |
| Moves: Place > | Advance > | Play > | Install > | Firewall > | Salvage > |
+--------------------------------------------------------------------------+
Features
- Start screen. Pick your side (South, North or random) and a seed, which is random by default.
Both decks are random legal decks from
randomDeck. - Board. An SVG of the 13 locations and 2 starts, with fixed coordinates for the classic board.
- Each location shows its owner color, level, Server name and Program count.
- Anomalies appear as tokens showing slot, Cores and damage/Health.
- Gateways show their Firewall level.
- Hovering a location shows a details panel: Server text, Programs, and the Anomalies there with their Hardware.
- Player panels for both sides:
- Gb, cards in hand, deck, discard and Server pile.
- Locations held out of 10.
- The four Anomaly slots: face down or up, in the slot or on a location, damage, Hardware.
- The bot's hand shows only as a count. Its discard pile can be opened.
- Hand. Text cards showing name, kind, type, Gb and text.
- Moves panel. The legal actions are grouped by kind and then by card, and labelled with
describeActionand their cost. Clicking one plays it.- A step bar shows Deploy, Play, Attack, Play again, with an End step button.
- An End command button repeats End step. It stops early if a prompt or response window comes up for you.
- Prompts.
- A card prompt (
s.choicefor you) opens a dialog with the prompt and its options. - A response window shows a banner such as "North attacks D1 — respond?". It lists your possible responses and a Pass button.
- A card prompt (
- Bot turns. The bot's moves play one at a time with an adjustable delay from 0 to 1 s, and the log scrolls with them.
- Auto-skip. Steps where you can only end or salvage are ended for you. This is a setting and on by default. It saves about 55 clicks a game.
- Combat readout. While a combat is live, it shows attacker and defenders, each side's Cores, the dice once rolled, the totals and the damage.
- Game over. Shows the winner, the reason and the game stats from
stats.ts, with New game and Rematch (same seed) buttons. - Dev tools.
- Show the seed.
- Copy the log.
- A toggle that runs
checkInvariantsafter every move and shows any errors.
Tests
- A headless test drives
match.tswith a random "human" for a few hundred games. It checks that no game gets stuck and the loop always hands control back. - The
describeActionlabel test from section 3.
Done when
You can play a full game on the classic board, start to finish, without opening the browser console, and both tests pass.
Not in level 1
Art and card templates, acting by clicking the board, animations, undo, save, other boards, rule variants and deck choice.
Effort
| Work | Days |
|---|---|
| Sim changes (section 3) | 0.5–1 |
| App scaffold, controller, bot loop | 0.5 |
| Board, panels, hand | 1 |
| Moves panel, prompts, windows, combat readout, game over | 0.5–1 |
| Controller test and fixes from the first playtests | 0.5 |
| Total | 3–4 |
5. Level 2: Properly Playable
Goal: it feels like a digital card game. Each workstream below can ship on its own, in the order listed.
A. Click to act (2–3 days)
- Select, then target. Select a source: a card in hand, an Anomaly, a gateway or an Anomaly
Ability. Its legal targets then light up on the board, and clicking a target plays the move.
- This works by filtering
legalActionsby source, then by target. - When several moves share a source and target, a small popover picks between them. Examples are Firewall levels, Sabotage's destroy or disable, and Bit Flip's number.
- This works by filtering
- Keep the full move list. The level 1 moves panel becomes an "All moves" drawer, so anything the click UI misses is still reachable.
- Keyboard:
Key Action Space End step, or Pass Enter End command Z Undo Esc Cancel the selection
B. Real cards (2 days)
- Render cards in the browser from the Cider templates in
decks/files-deck-1.- Use Handlebars with each template's CSS, scoped per template.
- Include the art from the Image column.
- Provide the helpers the templates use (
lowercase,eq,index).indexmust return a SafeString.
- Templates are 750×1050, so show them scaled down, with a hover zoom and right-click to pin.
- On the board, Servers, Programs and Anomalies use compact tokens, and the full card appears on hover.
- Cards without art show a placeholder in the art window.
C. Combat and dice (1–2 days)
- A combat panel breaks down each Anomaly's Cores by source: Anomaly, Hardware, Programs, Server and
temporary modifiers. This needs a breakdown version of
anomalyCores. - Before you attack, it shows your chance to win the roll from
winChanceand the expected damage. - After the roll, it shows the dice, totals, damage and any Anomaly destroyed.
- A short dice animation, which can be turned off.
D. Stops and pacing (1 day)
-
Stops setting. This decides when the game waits for your response:
Setting Behavior In combat only The default. The bot's Executions and Ability uses outside combat pass automatically, which skips about 43 windows a game. Every opponent move Stops for every response window. Never Passes every response automatically. A held key overrides the setting for one window.
-
Bot speed slider, pause, and step-one-move.
-
A status banner shows whose command it is, the step, and any Executions waiting to resolve.
E. Information (2 days)
- Structured events. Add events next to the text log, such as capture, damage, card played and
Firewall placed. They drive animations and a filterable log (Combat, Captures, Cards).
- The hooks already fired through
emit()are a starting point.
- The hooks already fired through
- Status icons on Anomalies and cards, with tooltips:
- Infection and Bug counters
- disabled, rooted, copies, temporary Core modifiers
- Viewable discard piles and Server pile counts for both sides.
F. Setup, saving and replays (2–3 days)
- Decks.
- Choose a random deck, a preset from
app/decks/*.json, or paste a list. - Every list is checked with
validateDeckand errors are shown.
- Choose a random deck, a preset from
- Rule variants. An advanced panel takes the same
K=Voverrides as the CLI's--rule, for playtesting variants in the app. - Save and resume.
- The game saves to local storage after every move and resumes on reload.
- The state is plain data, apart from the card definitions, which are rebuilt from the CSV.
- Undo.
- The app snapshots the state with
structuredClonebefore each of your moves. Undo goes back to your previous decision. - The dice RNG is part of the snapshot, so undoing and trying again doesn't reroll the dice.
- A playtest mode turns undo on. It's off for a normal game.
- The app snapshots the state with
- Replays.
- A game record is the seed, both decks, the rules and the list of
actionKeys. - The engine is deterministic, so a record replays exactly. You can export and import records.
- Attach a record to any bug report, so the bug can be reproduced.
- A game record is the seed, both decks, the rules and the list of
G. Layout and finish (2 days)
- Targets 1280×720 and up, not phones.
- Owner colors that stay distinct for color-blind players, with a pattern as a second cue.
- Fixes from playtests.
Effort
| Workstream | Days |
|---|---|
| A. Click to act | 2–3 |
| B. Real cards | 2 |
| C. Combat and dice | 1–2 |
| D. Stops and pacing | 1 |
| E. Information | 2 |
| F. Setup, saving and replays | 2–3 |
| G. Layout and finish | 2 |
| Total | 12–15, about 3 weeks |
6. Risks
- Human play reaches paths the bots never take. The invariant toggle and replay records turn these into bugs that can be reproduced. Expect the first playtests to find a few engine bugs.
- The greedy bot is tuned for balance testing, not for fun. Players may spot patterns it falls
for. Changing
GreedyParamscould give difficulty levels without writing a new bot. - The 4×4 boards need their own coordinates. The app starts with the classic board only.
- Set 2 cards have no scripts yet. The app loads set 1 only, as the CLI does by default.
- Hidden information. The log audit in section 3 is the main risk. The engine's view and the bot's view are already correct.
7. Open Decisions for the Owner
- Local or public. Is the app local-only for now, or should the level 2 build go on a static host such as itch.io or GitHub Pages for outside playtesters?
- Undo in normal games. Is undo allowed outside playtest mode?
- Odds preview. Should the win odds for a roll show before attacking? It helps playtesting, but takes some tension out of the choice.