Get in the mix.
The viewer is part of this repo: plain TypeScript and one HTML page in viewer/src/, bundled by esbuild. This challenge adds a creep counter to the top bar. This is a good way to use your llm to explore the viewer’s code and learn how it works.
- Open
viewer/src/index.htmland find the#topbarline. Add a span for the count. - Open
viewer/src/main.tsand find theonChannelhandler — the block that runs once per tick when a room frame arrives. Look at how it already updates#gametime. - Look at
viewer/src/state.tsto see howRoomStateholds the room’s objects, and count the ones whosetypeis"creep". - Set your span’s text from that count in the tick block.
- Run
nix build .#checks.x86_64-linux.viewer-typecheck --no-link 2>&1 - Run
nix run .#client, reload the page - In the console type
Object.keys(Game.creeps)to get the harvester id - In the console type
Game.creeps['<harvester-id'].suicide()and observe the counter increment.
Stretch Goal
Add the spawn’s energy next to the count, updated the same way. The spawn is in the room’s objects with type "spawn"; its energy is in its store. Watching it drain by 300 when a creep is built tells you where the body budget went.
Try the viewer stretch goal.