Co-op matches of editor campaigns

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-05 17:39:38 +01:00
1 parent 0966e3318f
commit abe01ff23e
13 files changed
+394 -44

No files matched your search

+3
View File
@@ -116,6 +116,9 @@ Ctrl+Z/Y undo/redo, Ctrl+C/V copy/paste the selected block, Delete removes it, C
- **Online** (server with the savegame service): own campaigns per user, overwrite on the next
save; *Published* adds the campaign to the list every logged-in player sees and can open (as a
copy) and play. Server API: `/api/campaigns`, `/api/public/campaigns` (see `server/src/main.rs`).
- **Co-op**: the campaign last opened in the editor can be played in a co-op match (Multiplayer,
*Editor campaign*), one mission per match; missions need a map of at least 72x72 and a goal besides
rival masters. See `docs/MULTIPLAYER.md`.
## File format (`src/campaign_doc.rs`)
+11
View File
@@ -69,6 +69,17 @@ per turn. Fog of war, particles and the camera are local and not part of the sha
by the simplified rival AI on every client, so they stay deterministic.
- **Co-op** (`Game::coop`): the master sides are allies against the heroes; allied creatures never target each
other, allied ground does not block claims. Co-op campaign matches use `campaign::start_coop_mission`.
- **Editor campaigns in co-op**: on the Match page the host can switch from the built-in campaign to the
campaign last opened in the editor (`Menu::campaign_doc`) and pick one of its missions that fits co-op
(`campaign::is_editor_coop_mission`: map at least 72x72, a goal besides rival masters). The create message
carries the whole campaign (`"doc"`, the `CampaignDoc` JSON, up to `MAX_WS_MESSAGE` = 40 MB per WebSocket
message); the relay keeps it in the room and adds it to the `start` message (room updates only show
`"editor": true`). Every client builds the mission with `campaign::start_editor_coop_mission(doc, i, seed)` from
the room's shared seed (rival masters of the map and the Rivals goal are left out, like in built-in co-op),
then the usual co-op setup. Block scripts run from side 0 in the fixed step. When the mission ends, the match
ends and the players go back to the lobby; there is no branching to a next mission and no progress is stored.
- **Shared simulation side**: the shared part of a step (waves, units, towers, rivals, dwarves) runs with the
first master switched in on every client; only the end check and the fog use the local master.
## Steps