A · Building a Game — Overview

The game we'll build

GridBeasts is a territory game: mint creature cards, place them on one shared 8×6 map, and displace weaker enemies. Every rule below maps to a few lines of code you'll paste in Section C.

▼ details below

Cards

Meet the creatures

All art is generated — the same function that runs in game.html drew these. token id hash → species; more hash bits → the individual. No image files exist anywhere in the project.

Placing & battles

DEF fire 9 ATK water 4 ally of ATK fire 2 attacker: water 4 attacks fire 9 water beats fire → 4 × 1.5 = 6 + adjacent ally (fire 2) = 8 defender: 9, no allies = 9 9 ≥ 8 → defender holds (ties favor the defender) this exact battle happened in our test run — see Step 4
a worked battle: multiplier + adjacency support

The battle formula

Total
Attackerpower (+2 if in season) × element multiplier + Σ powers of your cards orthogonally adjacent to the target cell
Defenderpower (+2 if in season) + Σ powers of their adjacent cards

Seasons — the multi-chain twist

A counter contract on Midnight selects the season: counter mod 3 → fire / water / grass. The in-season element gets +2 power in every battle, on both sides. Advancing the season is a real Midnight transaction — a private ZK chain shifting the balance of power on an EVM-driven map. That's the bonus step.

Winning

The leaderboard ranks players by cells controlled. In the live session, most cells when the instructor calls time wins.

Which file implements which rule

RuleFileStep
card stats + namespackages/node/game.tsgenerateCardStats()2
battle formulapackages/node/game.tsresolveBattle()2
move validationpackages/node/state-machine.ts"place"4
battle fatigue (−1 power per battle)state-machine.tsdecrementCardPower after each battle4
seasonsstate-machine.ts"midnightContractState"6
grid size, multipliers, buffsconstants at the top of game.ts — tune freely2
← How Effectstream thinksInstall (pre-work) →