# How to make an online monster collector with turn-based battles

> Start the MOSSBOUND monster collector with one command: up to eight players walk a shared marsh, meet wild creatures in tall grass, battle them turn by turn with a team of three, catch the ones worth keeping and wear down one shared boss. Add creatures, moves and grass zones in src/game.ts.

Net Forge, the open-source multiplayer browser game engine built for AI coding agents, is published on npm under `@netforge` with source at https://github.com/netnetdev/net-forge.

Source: https://forge.netnet.capital/docs/guides/monster-collector-game  
Last updated: 2026-10-23. Checked against @netforge/engine 0.2.0.

Run `npm create netforge@latest my-collector -- --template collector --yes` and you have an online monster collector: pick a starter at camp, walk the grass, battle wild creatures turn by turn with a team of three, catch them, and join everyone in the marsh to bring down the warden before dusk. Creatures, moves, elements and the map are declarations in `src/game.ts`.

```sh
npm create netforge@latest my-collector -- --template collector --yes
cd my-collector
npm run play
```

`--template monsters` is accepted as the same template.

## What you get

| Part | Where | Notes |
|---|---|---|
| Creatures | `creature({...})` | 1 to 24, with element, hp, attack, defence, speed, 1 to 4 moves and a catch rate. Stats grow 12% a level. |
| Moves | `move({...})` | Up to 48, with power, accuracy and effects `drain`, `heal` and `guard`. |
| Elements | engine | `root`, `tide`, `spark`, `stone` in a cycle; strong hits deal 1.5x, weak ones 0.67x. |
| The map | `marsh({...})` | Size, camp, water, blocked rects and grass zones with encounter rates and pools. |
| Shared boss | `marsh({ warden })` | One health pool for the whole marsh; everyone who hurt it shares the win. |
| Private battles | room server | Your team, your foe and the battle log reach only you. |
| Playtest | `npm test` | Four keepers playing four minutes take 349 ms; the warden-falls test plays a whole run in 1.2 s (Apple M2 Pro, Node 22). |

## 1. Start it

```sh
npm create netforge@latest my-collector -- --template collector --yes
cd my-collector
npm run play -- --players 2
```

Walk with WASD, the arrows or the left thumb on touch.

## 2. Add a creature and its moves

```ts title=src/game.ts
import { creature, move } from "@netforge/engine";

move("leaf_lash", { element: "root", power: 40 });
move("thorn_curl", { element: "root", power: 0, effect: "guard" });
move("tide_crash", { element: "tide", power: 70, accuracy: 0.8 });
creature("thistlehog", {
  model: "style.lowpoly.fox",
  element: "root",
  hp: 50,
  atk: 52,
  def: 48,
  spd: 46,
  moves: ["leaf_lash", "thorn_curl"],
  catchRate: 0.7,
});
```

Then put it in a grass zone's `pool` in `marsh({...})` and add its label to `src/names.json` under `weapons`. A power of 40 is a plain hit.

## 3. Shape the marsh

Grass zones decide what you meet and how often. Put weak creatures near camp and stronger ones toward the warden:

```ts title=src/game.ts check=skip
marsh({
  size: [30, 20],
  camp: [2, 10],
  grass: [{ at: [4, 2, 6, 5], rate: 0.22, pool: [{ creature: "thistlehog", weight: 3, level: [2, 3] }] }],
  // ...the template's water, blocked tiles, warden and dusk stay as they are
});
```

Rects are `[x, y, width, height]` in tiles of 2 m. Leave a walkable way from camp to every grass zone and to the warden; the build checks it.

## 4. Test it

```sh
npm test
```

Four playtest keepers must win battles, catch creatures and fire an earn rule within four minutes, without losing their whole team more than twice each.

## How it works

The collector is a rules genre: the room runs it at 30 Hz with integer state and a seeded generator. Every roll (encounters, accuracy, damage spread, snares and the foe's move) is the room's, so a run replays exactly from its inputs. Your keeper is predicted with the same tile collision the room runs, so walking never waits. A battle is private: the room sends your team, your foe and the log only to you, and others see the creature beside you. See [Make a turn-based multiplayer game](https://forge.netnet.capital/docs/guides/turn-based-browser-game.md) and the [monster collector template page](https://forge.netnet.capital/docs/templates/monster-collector.md).

## Alternatives

- **[Godot](https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_web.html)** has a scene editor and tile tools suited to hand-built RPG maps, and exports to the web as WebAssembly with WebGL 2. Pick it for a single-player creature RPG with a long story.
- **[Phaser](https://docs.phaser.io/)** is a free, open-source 2D framework with WebGL and Canvas rendering. Pick it for a 2D top-down collector in sprite art.
- **[Colyseus](https://docs.colyseus.io/)** is an authoritative room server with state sync, for writing the battle rules as server code against your own client.

Pick Net Forge when you want the shared-world, turn-based collector already online, with private battles and a playtest.

## FAQ

### Are battles turn-based or real-time?

Turn-based. Each turn you pick a move, a swap, a snare or flee; the faster creature acts first and the foe answers with its best move.

### Can players see each other's battles?

They see the creature beside you, not the battle. Your team, your foe and the log are sent only to you.

### How does catching work?

A snare's chance is the creature's catch rate times (0.25 plus 0.75 times the foe's missing health), so weakened creatures are easier to catch. A team holds three; more go into the lantern.

### How many players share the world?

Up to eight per marsh, all wearing down the same warden.

### Can I add more element types?

The four elements and their cycle are fixed by the genre. Variety comes from creatures, moves and effects.
