A Magic: The Gathering tabletop where one host owns the board state and each player plays from their own device. In-person games, Godot host + clients, by hand only for V1.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
muse-lantern 19eef0c766 Wire desktop 2.5D table into the client (web/solo)
Web/desktop loads the slanted 3D table scene (DesktopTable) driven by live
SoloNet state: hand row, zones 1-8, life/turn HUD, mana panel, hover-peek,
click-pinned inspect, double-click main action. Mobile keeps the portrait
GameScreen. Card images from Scryfall with user:// cache and bundled
mockup_assets for the default deck. No drag placement yet (later step).
2026-12-04 05:45:18 +00:00
docs Offline (solo) mode: play your own board with no host, no network 2026-12-02 23:03:32 +00:00
mockup_assets Wire desktop 2.5D table into the client (web/solo) 2026-12-04 05:45:18 +00:00
scenes Wire desktop 2.5D table into the client (web/solo) 2026-12-04 05:45:18 +00:00
screenshots Manual-mode mana payment on cast; stack removed from manual mode 2026-12-03 01:03:24 +00:00
scripts Wire desktop 2.5D table into the client (web/solo) 2026-12-04 05:45:18 +00:00
tests Wire desktop 2.5D table into the client (web/solo) 2026-12-04 05:45:18 +00:00
.gitignore V1 prototype: Godot host + client, by-hand-only MTG tabletop 2026-12-02 18:18:46 +00:00
export_presets.cfg Add Web export preset (no threads) 2026-12-02 22:31:04 +00:00
project.godot Portrait mobile client UI: Card scene template + mockup layout 2026-12-02 19:40:48 +00:00
README.md Offline (solo) mode: play your own board with no host, no network 2026-12-02 23:03:32 +00:00

MTG Tabletop

A Magic: The Gathering tabletop where one host owns the board state and each player plays from their own device. In-person games: the host runs on a tablet on the table or a computer driving a projector; clients are phones, tablets, or laptops showing the player's hand. Cockatrice-style manual play.

V1 is by-hand-only. Data transport, presentation, and data tracking (deck, field, graveyard, exile, command zone, life, counters, mana). No card scripts, no automation, no rules enforcement yet. See docs/DESIGN.md for the full design and docs/PROTOCOL.md for the wire protocol.

Built with Godot 4.7.2 (host + client). Non-standard clients (PSP, DSi) can be written in any language as long as they speak the protocol.

Quick start

Requirements: Godot 4.7.2 (standard editor, no .NET needed).

# Import once (headless is fine)
Godot_v4.7.2-stable_linux.x86_64 --headless --import --path .

# Run the host (default port 7777, join code K7QM)
Godot_v4.7.2-stable_linux.x86_64 --headless --path . scenes/host_main.tscn -- --port=7777 --join-code=K7QM

# Run a client (GUI)
Godot_v4.7.2-stable_linux.x86_64 --path . scenes/client_main.tscn

In the client, enter the host address, port, join code, and your name, paste a plain-text deck list, and hit Load Deck && Enter Game.

Deck lists

Plain text, one card per line, exactly what Moxfield / Archidekt / TappedOut / Arena / MTGO export:

4 Lightning Bolt
4 Grizzly Bears
20 Mountain

Sideboard:
2 Smash to Smithereens

The host resolves names against its card data and reports anything it could not find, plus which cards are verified vs unverified (homebrew).

Offline deck loading

The client can load a deck without being connected to a host: paste the deck list and hit Load Deck (Offline). It resolves what it can from the cards it has seen and lists the rest as unresolved (kept in the decklist — they may resolve when connected). The deck stays loaded, so when you join a game it is sent as-is.

Offline (solo) mode

No host, no network: after Load Deck (Offline) verifies a deck, Load Deck && Enter Game becomes enabled and starts a solo game — you are both client and host, playing your own board alone (draw, play, tap, move zones, set life, mana pool, all locally). This is what makes the web build playable: browsers cannot open raw TCP sockets at all, so the web client can only play solo. Hosted play is unchanged — Connect with a host address, port, and join code as before.

The client only ever stores card data for cards it has seen — its own deck cards plus cards encountered in games — in user://seen_cards.json, keyed by content hash. It never downloads the whole card database. The host, by contrast, holds the whole database for validation.

Card identity: two hashes

  • name_hash — SHA-256 of the card name. Cosmetic, display only. The host never validates it.
  • content_hash — SHA-256 of the card body (cost, type line, rules text, power/toughness). The mechanical identity. A reskin (same body, different name) shares the content hash and is mechanically the same card. A card whose text changes (errata) has a different content hash.

If the host doesn't recognise a content hash, it asks the client for the card and stores it flagged unverified — this is the homebrew path.

Client UI (portrait mobile)

The client defaults to portrait and follows the phone's orientation (it can rotate to landscape). Layout, top to bottom: turn strip, then a top row with life -/+ and the opponents strip shrunk to fit on the left and Deck (top) with Graveyard | Exile (below) stacked at top-right; the board's three zones — Board (all non-land permanents, mini cards), Lands (non-basic lands, collapses to its header when empty), Basic Lands (the per-color mana pool) — drag a zone's header by its grip to rearrange them; the Commander spot at bottom-left (hidden when the command zone is empty); and a fanned hand across the bottom. There is no stack strip in V1 by-hand-only play, no sort control, and no selected-card line — the focused card's name is on the Card Actions button at the base of the hand. Log, token creation, and opponent battlefields live in overlays so the main screen stays hand-first.

The hand is a fan-carousel: cards are fanned like a real hand, and swiping/tapping cycles them — the focused center card comes to the front, enlarged, so its text is readable. The focused card IS the selected card. There is no hand-size cap — just the count.

All cards on screen are instances of one reusable scene:

  • Scene: scenes/card.tscn (scripts/client/card.gd, class_name Card)
  • Use it: var c := preload("res://scenes/card.tscn").instantiate() as Card, then c.set_card(card_dict) with a host view dictionary (name, cost, type, text, power/toughness, verified, tapped, counters, damage, obj) and add_child(c). Tapping a card emits clicked(card); get_obj_id() and get_card_data() return what it represents. set_tapped() dims the card and shows a TAPPED badge; set_selected() draws the selection border.
  • The same scene is editable in the Godot editor: duplicate it and set the @export vars (name, cost, type line, rules text, P/T, tapped, verified, face-down) in the inspector to preview a card without running the game.

What works in V1

  • Host starts headless, accepts up to 4 clients, assigns seats (p1–p4), seat tokens, reconnect-by-token.
  • Two (or more) clients load plain-text decks, draw, play lands, tap/untap, add/spend mana, cast to the stack, set life/counters, move cards between zones, attack/block, pass/hold, advance steps, concede.
  • Every zone change gives the object a new opaque ID. The host never sends a hidden card's identity to another seat — hand contents are count-only for others, and the game log redacts hidden-zone card names for other seats (the raw events are filtered the same way).
  • A 15-card built-in test set (5 basic lands + 10 simple cards). Full Scryfall import is not in scope for the prototype.

Tests

# Host unit/integration suite (headless)
Godot_v4.7.2-stable_linux.x86_64 --headless --path . --script tests/test_host.gd
# => 86 passed, 0 failed

# Two-client end-to-end (drives the real host over raw TCP; see /tmp/e2e_test.py)
# Start the host on a port, then run the driver:
Godot_v4.7.2-stable_linux.x86_64 --headless --path . scenes/host_main.tscn -- --port=17803
python3 /tmp/e2e_test.py 17803
# => 25 checks, 0 failures

Project layout

project.godot            Godot 4.7.2 project (GL Compatibility)
docs/
  DESIGN.md              Full design document (adapted Dec 2, 2026)
  PROTOCOL.md            V1 wire protocol (authoritative contract)
scripts/
  core/
    protocol.gd          JSON message helpers + SHA-256 hashes
    card_data.gd         15-card built-in test set + homebrew registry
    deck.gd              Plain-text decklist parser
    game_state.gd        Deterministic core: state, zones, identity, events
  host/
    host_server.gd       TCP server, sessions, single-writer queue, filtering
    host_main.gd         Host entry point (headless)
  client/
    client_net.gd        TCP client, reconnect-by-token
    client_main.gd       Connect screen + offline deck load
    game_screen.gd       Game screen (hand, battlefield, zones, log)
    card_table.gd        Client copy of the 15-card test set
    card_cache.gd        Seen-cards-only cache (user://seen_cards.json)
scenes/
  host_main.tscn         Host scene
  client_main.tscn       Client scene
tests/
  test_host.gd           Headless host test suite

Known gaps (V1)

  • No UI for attach, commander_damage, request_undo/vote_undo, or activate with costs/sacrifices (the protocol supports them; the buttons aren't wired).
  • look/search/reveal are manual actions; the host records them and the players handle the reveal by hand — no temporary-visibility UI.
  • move to "library" doesn't distinguish top/bottom.
  • The 1280×720 client layout has not had a visual eyeball pass on a real display yet (headless-tested only).
  • Godot's TCPServer doesn't set SO_REUSEADDR: restarting a host on the same port immediately can fail with "Already in use" — wait ~60s or use another port. Godot also ignores SIGTERM; stop a headless host with SIGKILL.

Later milestones

M2 stack/response windows, M3 triggers + JSON scripts, M4 assistance (needs, prompts, hints), M5 PSP client, M6 Lua sandbox / multitap / VR. See docs/DESIGN.md section 10.