Playtest
Playtest puts a deck on a virtual table so you can play it out by hand: draw, play cards, tap them, count damage, take turns. You can play solo or against a mirrored opponent that you also control. Nothing checks the rules of the game; you move the cards, and every move can be undone.
What the table looks like comes from a playtest rules script. It lists the piles (zones), where they sit, who can see them, what you can do to cards and piles, and which keys do it. Every launched game with a playtest table ships a default script, and you can fork it, change it and share your version.
This guide covers playing first, then writing and sharing rules. For the exact shape of everything a script can return, see the playtest rules script API.
Using Playtest
Where to find it
Look for the Playtest button (a game controller icon) on any deck:
- on a deck page and in the deck preview dialog,
- in the deck builder, next to the deck's other actions,
- in the action menu of your saved decks.
Playtest is also its own item in the side navigation, near the bottom, on every game that has playtest rules. Opening it from there starts with no deck picked.
Pick the rules and a deck
Setting up a game takes three steps, and you can go back and Change any of them before you start.
- Rules. When only one set of rules is switched on for the game, it is used without asking. With more than one, pick a set; tick Don't ask again to always use the last set you picked. You can switch rules on and off in Settings.
- Deck. The deck you launched Playtest from is already filled in. Otherwise pick one of Your saved decks (when signed in) or Paste a deck code (anyone can).
- Mode. Solo sets up only your side of the table. Versus adds a mirrored opponent board that you also control; there is no computer opponent. The opponent plays the same deck as yours unless you choose Use a different deck.
Press Start and the table deals itself: the rules' setup runs for each side (usually a shuffle and an opening hand).
Playing the table
The rules decide what each input does, but the inputs are always the same:
| Input | What it does |
|---|---|
| Click a card | Runs the card's click action if the rules give it one; otherwise selects it (click again to deselect). |
| Ctrl-click, Cmd-click or Shift-click a card | Adds the card to the selection, or takes it out. Actions on "the selection" then run on every selected card. |
| Double-click a card | Runs the card's double-click action, such as playing it or taking a prize. |
| Click a pile | Runs the pile's main action, such as drawing from the deck. |
| Right-click (or long-press) a card or pile | Opens a menu of every action that applies to it. A pile's menu also has View cards and Look at top cards. |
| View card in a card's menu | Shows everything stacked on the card, such as attached energy and tools and earlier evolutions. Pick any of them and Move them, as in View cards: a moved card takes its attachments along, a lone attachment comes off. |
| Drag a card onto a pile | Moves it there (a dragged card that is part of the selection moves the whole selection). Some rules run an action instead. |
| Drag a card onto another card | Runs the dragged card's drop action if it has one, such as attaching an energy or evolving a Pokémon. |
On a touch screen, tap a card to select it and tap it again to run its main action. In your hand, drag a card upward to pick it up; elsewhere, press and hold, then move. Release a held card without moving to open its menu instead.
Some actions create cards that weren't in your deck, such as copies, level-ups and tokens. Created cards carry a small badge. When an action can create more than one kind of card, a picker asks which.
The toolbar above the table has New game, Undo and Redo, an Actions menu (everything that applies to a side or the whole table, for both sides), the Turn button, a − and + for each tracker such as life or mana, the Action log and Keyboard shortcuts. In Versus it also has Reveal opponent hand, which shows the opponent's private cards to you, and Flip board, which swaps which side sits at the bottom.
Turn shows the current turn, starting at 1. When the rules name a turn action (usually New turn), clicking Turn runs it, exactly as picking it from the Actions menu does, and it undoes the same way; that action's shortcut (N in the default rules) does the same as the click. In Versus the sides take turns: each click starts the next turn for the other side, start-of-turn draw included, and the button names whose turn it is (Turn 3 · Opponent). Rules whose turn action advances the whole table at once, as Legends of Runeterra's does, count Rounds instead. Rules without a turn action show the count only.
In Versus the Actions menu lists your actions and the opponent's under separate headings (Game · You, Game · Opponent), and the opponent's shortcuts show with Alt.
View cards opens with Move to set to your hand, the usual place to take a card from a deck or discard pile.
A pile or a card that refuses a move (a full Bench, a card the zone doesn't accept) keeps the card where it was, and the log says so.
Acting for the opponent: hold Alt
In Versus, every input with Alt held acts on the opponent's side instead of yours. With Legends of Runeterra's default rules, D draws for you and Alt+D draws for the opponent, and Alt-clicking your deck draws for the opponent too. Actions on cards always act for the card's owner, so Alt matters for piles and for side-wide actions.
On a Mac, Alt is the Option key. Because Alt is reserved for this, no rules script can put Alt in a shortcut.
Undo, redo and rewind
Every change to the table can be undone, including a drag and drop and New game.
- Undo with
Mod+Z(Cmd+Z on a Mac, Ctrl+Z elsewhere) or the toolbar button. Redo withMod+Shift+ZorMod+Y. - One action is one undo step. A compound action such as New turn (untap everything, then draw) undoes as a whole.
- Doing something new clears the redo list, as in a text editor.
- Shuffles repeat exactly. The table's randomness comes from a seed saved with the game, so undoing a shuffle and redoing it gives the same order. To really re-roll, open Actions and pick New random seed.
- Rewind from the log. The Action log lists every action in order. Click an entry to Rewind to this point; the later actions stay in the redo list until you do something new.
Selecting cards, hovering and opening a viewer are not changes to the table, so they are never undone.
Keyboard shortcuts
Press ? at any time to see every shortcut the current rules define, grouped as the rules group them. When the rules describe an action, the description under its name says what it does and which card to select or point at.
- A shortcut for a card action runs on the selected cards, or on the card under the pointer when nothing is selected.
- A shortcut that attaches cards (an energy, a tool, an evolution) runs on the selected cards and attaches them to the card under the pointer, as long as that card is not selected itself. Right-clicking that card offers the same attach actions in its menu.
- A shortcut for a pile action runs on the pile under the pointer, or on the pile the action belongs to.
- A shortcut for a side or table action runs for you (hold Alt for the opponent).
Escapeclears the selection.
Shortcuts match the key you press, not the letter it types, so they work the same on every keyboard layout.
Your game is saved in this browser
The game in progress, including its undo history, is saved automatically in this browser as you play, so a reload doesn't lose it. It is not saved to your account: another browser or device starts fresh, and clearing the site's data deletes it.
The default rules
Each game's default rules are plain playtest scripts. Read their source to see a complete, real table, or fork one as the starting point for your own:
| Game | Rules | Source |
|---|---|---|
| Cyberpunk TCG | Standard | Read the script |
| Flesh and Blood | Standard | Read the script |
| Hearthstone | Standard | Read the script |
| Legends of Runeterra | Standard | Read the script |
| Magic: The Gathering | Standard | Read the script |
| Magic: The Gathering | Commander | Read the script |
| Palworld TCG | Standard game | Read the script |
| Pokémon TCG | Standard | Read the script |
| Riftbound | Standard | Read the script |
Writing playtest rules
A playtest rules script is a JavaScript function that runs once when a game starts. It returns plain data describing the table, and the table does the rest. It never runs again during the game, so it cannot react to clicks: instead it declares actions as lists of simple steps (move, draw, shuffle, tap, add a counter, ...) that the table runs for you.
Manage your rules
Playtest rules belong to one game. Manage them in Settings → Playtest rules on that game's site, for example Legends of Runeterra or Pokémon TCG. The list shows the game's system defaults and your own rules. From there you can:
- switch any set on or off; a switched-off set is hidden from the rules picker ("Hidden from the rules picker"),
- Try it to open Playtest with those rules and a sample deck,
- View code of a system default or a saved copy,
- Fork any set into a new, editable set of your own,
- Edit, Delete and share the sets you made (see Sharing).
System defaults are read-only. To change one, fork it.
Tutorial: a three-zone table
This tutorial builds a small table from scratch: a deck, a hand and a board. Then it adds actions and shortcuts.
1. Start a new set of rules
- Open Settings → Playtest rules and click New rules.
- Type
My first tablein Name. - Replace the Rules script with the script below.
The Validation panel beside the editor re-checks the script as you type, over a sample deck for the game. It lists any problem with its code (see Troubleshooting), or counts the zones, actions and shortcuts and lists every shortcut.
js
export default function playtest(deck) {
// One entry per copy: a 3-of appears three times.
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) {
cards.push(code);
}
});
return {
version: 1,
// Each side is 6 columns by 2 rows. Row 0 is nearest the middle.
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [],
setup: [],
initialZones: { deck: cards },
};
}What each part does:
deckis the deck being played:deck.mainmaps each card code to its number of copies. The script turns it into a list with one entry per copy.tableis the grid each side is drawn on. Row 0 borders the middle of the table, so the board sits nearest the opponent and the hand nearest you.zonesare the piles.owner: "side"gives each player their own copy.visibilitysays who sees card faces: nobody ("hidden"), only the owner ("private") or everyone ("public").layoutis how the cards are drawn: a"pile", a"fan", a"row", and more.initialZonessays where the cards start: the whole deck, face down, indeck.
Even with no actions, this table already works: drag cards between the three zones, and undo any move.
2. Add actions
An action is a named list of steps, plus what it runs on (target) and how you trigger it. Replace actions: [], in the script with:
js
actions: [
// Click the deck to draw a card.
{
id: "draw",
label: "Draw",
target: "zone",
zones: ["deck"],
triggers: ["click"],
steps: [{ kind: "draw", from: "deck", to: "hand" }],
},
// Double-click a card in hand to play it.
{
id: "play",
label: "Play",
target: "selection",
zones: ["hand"],
triggers: ["doubleClick"],
steps: [{ kind: "move", to: "board" }],
},
// Double-click a card on the board to tap or untap it.
{
id: "tap",
label: "Tap / untap",
target: "selection",
zones: ["board"],
triggers: ["doubleClick"],
steps: [{ kind: "rotate" }],
},
],target: "zone"withzones: ["deck"]makes Draw an action of the deck.triggers: ["click"]runs it when you click the deck.target: "selection"runs on every selected card, or on the card you double-clicked.zones: ["hand"]limits Play to cards in your hand.- A
rotatestep with nototurns each card between upright and tapped. - Every action also appears in the right-click menu of whatever it applies to. Add
menu: falseto leave one out.
3. Add shortcuts and a setup
Give each action a shortcut, add a Next turn action that untaps and draws, and a setup that shuffles and deals an opening hand. This is the finished script:
js
export default function playtest(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) {
cards.push(code);
}
});
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
primaryActionId: "draw",
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "draw",
label: "Draw",
target: "zone",
zones: ["deck"],
shortcut: "d",
steps: [{ kind: "draw", from: "deck", to: "hand" }],
},
{
id: "play",
label: "Play",
target: "selection",
zones: ["hand"],
triggers: ["doubleClick"],
shortcut: "p",
steps: [{ kind: "move", to: "board" }],
},
{
id: "tap",
label: "Tap / untap",
target: "selection",
zones: ["board"],
triggers: ["doubleClick"],
shortcut: "t",
steps: [{ kind: "rotate" }],
},
{
id: "nextTurn",
label: "Next turn",
target: "side",
shortcut: "n",
steps: [
{ kind: "readyAll", zones: ["board"] },
{ kind: "turn" },
{ kind: "draw", from: "deck", to: "hand" },
],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 5 },
],
initialZones: { deck: cards },
};
}What changed:
- Shortcuts. Press
Dto draw,Pto play the selected (or hovered) card,Tto tap it andNfor the next turn.Alt+Ddraws for the opponent in Versus, with no extra code. Letters are matched case-insensitively;shift+andmod+(Cmd on a Mac, Ctrl elsewhere) are allowed,alt+is not. The full grammar is in the shortcut reference. primaryActionId: "draw"makes a click on the deck run Draw, instead of thetriggers: ["click"]from step 2.- Next turn is a
sideaction: it runs for your side (or the opponent's with Alt), readies every card on the board, adds 1 to the turn counter and draws, all as one undo step. The toolbar's Turn button shows the turn counter; to make it run an action, name it inroundActionIdas in Next round for both sides. Add adescriptionto any action to explain it under its name in the shortcut sheet (?) and as its tooltip in menus. setupruns for each side when a game starts, after the cards are placed: shuffle the deck, then draw 5.
4. Save and try it
Click Save. My first table appears in your list, switched on. Click Try it to open Playtest with it and a sample deck, or start Playtest from any deck and pick My first table.
Tips for writing rules
- Build card tags from
cardsById. Steps and zones can't read card fields directly. Compute tags (such as"unit"or"energy") from each card's fields once, return them incardTags, and test them with{ kind: "tag", tag: "energy" }. See Card tags fromcardsById. - Relate cards with
associatedCards. Level-ups, tokens and cards that create other cards come from each card'sgame.associatedCardRefs. Return them inassociatedCardsand let acardparam pick one. See Level up via an associated card. - Guard every card.
cardsById[code]can be missing when the catalog doesn't know a card, so checkcard && card.gamebefore reading fields. - Keep ids short and stable. Zone, action, tracker and marker ids are how steps refer to each other; labels are only what the player reads.
- Let the table do the bookkeeping. A zone's
enterStatecan untap, turn face up or clear counters on every card that enters it, so each action doesn't have to.
Cookbook
Small, complete scripts, one per technique. Paste one into the editor to try it, or copy the parts you need. The default rules use all of them at full size.
Each script starts with the same small cardList helper, which lists one entry per copy in the deck.
A hidden prize grid
Six face-down Prizes nobody can see, set aside from the top of the deck at setup. Double-click a prize to take it, or press Shift+P for a random one.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck) {
return {
version: 1,
table: { columns: 4, rows: 2 },
zones: [
{
id: "prizes",
label: "Prizes",
owner: "side",
visibility: "hidden",
layout: "grid",
area: { row: 0, col: 0, rowSpan: 2 },
ordered: false,
defaultFaceDown: true,
showCount: true,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 3 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 1, colSpan: 3 },
ordered: true,
defaultFaceDown: false,
enterState: { faceDown: false },
},
],
trackers: [],
markers: [],
actions: [
{
id: "takePrize",
label: "Take this prize",
target: "card",
zones: ["prizes"],
triggers: ["doubleClick"],
steps: [{ kind: "move", to: "hand" }],
},
{
id: "takeRandomPrize",
label: "Take a random prize",
target: "side",
shortcut: "shift+p",
steps: [
{
kind: "move",
cards: { zone: "prizes", count: 1, pick: "random" },
to: "hand",
},
],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{
kind: "move",
cards: { zone: "deck", count: 6 },
to: "prizes",
faceDown: true,
},
],
initialZones: { deck: cardList(deck) },
};
}visibility: "hidden" hides the faces from both players, you included. pick: "random" uses the game's seeded randomness, so undo and redo take the same prize.
An attach-under energy drop
Drag an Energy card onto a Pokémon and it tucks underneath it, then moves with it from zone to zone. Or use the keyboard: select the Energy, hover the Pokémon and press Q. Detach on the Pokémon returns everything under it to your hand.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck, cardsById) {
const cardTags = {};
Object.keys(cardsById).forEach((code) => {
const card = cardsById[code];
const supertype = card && card.game ? card.game.supertype : "";
if (supertype === "Energy") {
cardTags[code] = ["energy"];
}
});
return {
version: 1,
table: { columns: 5, rows: 2 },
zones: [
{
id: "active",
label: "Active",
owner: "side",
visibility: "public",
layout: "slots",
area: { row: 0, col: 0, colSpan: 4 },
capacity: 4,
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 4 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "attach",
label: "Attach",
target: "selection",
when: { kind: "tag", tag: "energy" },
triggers: ["drop"],
shortcut: "q",
steps: [{ kind: "attach", mode: "under" }],
},
{
id: "detach",
label: "Detach",
target: "card",
zones: ["active"],
steps: [{ kind: "detach", to: "hand" }],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 7 },
],
initialZones: { deck: cardList(deck) },
cardTags: cardTags,
};
}triggers: ["drop"] runs the action when the selected cards are dropped onto a card, which becomes the host. shortcut: "q" runs it from the keyboard: the selected cards attach to the card under the pointer, which becomes the host the same way (with nothing hovered, the last selected card is the host). mode: "under" keeps the host as the visible card; mode: "over" puts the new card on top, like an evolution. when hides the action unless every target card (here, every dragged or selected card) is tagged energy; the host is never tested. Attached cards skip the host zone's accepts and capacity.
A compound "Next turn"
One key that untaps everything, advances the turn and draws, as a single undo step.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck) {
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
primaryActionId: "draw",
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "draw",
label: "Draw",
target: "zone",
zones: ["deck"],
steps: [{ kind: "draw", from: "deck", to: "hand" }],
},
{
id: "tap",
label: "Tap / untap",
target: "selection",
zones: ["board"],
triggers: ["doubleClick"],
shortcut: "t",
steps: [{ kind: "rotate" }],
},
{
id: "nextTurn",
label: "Next turn",
target: "side",
group: "Turn",
shortcut: "n",
steps: [
{ kind: "readyAll", zones: ["board"] },
{ kind: "turn" },
{ kind: "draw", from: "deck", to: "hand" },
{ kind: "log", message: "Untapped and drew for the turn." },
],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 7 },
],
initialZones: { deck: cardList(deck) },
};
}A side action runs for one side: yours, or the opponent's with Alt. readyAll turns every card in the listed zones upright; its optional skipFlag leaves cards with that flag tapped. group puts the action under a heading in menus and the shortcut sheet.
Draw N with the digit keys
Hover the deck and press 1 to 9 to draw that many cards. From the deck's menu, Draw N asks how many.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck) {
return {
version: 1,
table: { columns: 6, rows: 1 },
zones: [
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 0 },
ordered: true,
defaultFaceDown: true,
primaryActionId: "draw",
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 0, col: 1, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "draw",
label: "Draw",
target: "zone",
zones: ["deck"],
steps: [{ kind: "draw", from: "deck", to: "hand" }],
},
{
id: "drawN",
label: "Draw N",
target: "zone",
zones: ["deck"],
shortcut: "1-9",
params: [
{ id: "count", label: "Cards", kind: "number", min: 1, max: 60 },
],
steps: [
{ kind: "draw", from: "deck", to: "hand", count: { param: "count" } },
],
},
],
setup: [{ kind: "shuffle", zone: "deck" }],
initialZones: { deck: cardList(deck) },
};
}The shortcut "1-9" binds every digit and passes the digit you pressed as the action's first number param. { param: "count" } reads that value in a step. From a menu, an action with params always asks for them first; a click or shortcut asks only for params that have no default.
A shared zone
A single Stadium for the whole table, between the two halves. Either player can put a Stadium there, but it holds only one card.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck) {
return {
version: 1,
table: { columns: 5, rows: 2, sharedRows: 1 },
zones: [
{
id: "stadium",
label: "Stadium",
owner: "shared",
visibility: "public",
layout: "slots",
area: { row: 0, col: 2 },
capacity: 1,
ordered: false,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 4 },
ordered: true,
defaultFaceDown: true,
},
{
id: "discard",
label: "Discard",
owner: "side",
visibility: "public",
layout: "pile",
area: { row: 0, col: 3 },
ordered: true,
defaultFaceDown: false,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "playStadium",
label: "Play as Stadium",
target: "card",
zones: ["hand"],
shortcut: "g",
steps: [{ kind: "move", to: "stadium" }],
},
{
id: "discardStadium",
label: "Discard Stadium",
target: "card",
zones: ["stadium"],
steps: [{ kind: "move", to: "discard" }],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 7 },
],
initialZones: { deck: cardList(deck) },
};
}A shared zone's area is a cell of the strip between the halves, which has table.sharedRows rows and the same columns as each side. Card actions always run for the card's owner, so Discard Stadium sends the card to its owner's discard pile, whichever side it came from.
To place a shared zone inside your half instead, next to your own zones (such as a Stadium left of the Active Pokémon), add sharedPlacement: "playerGrid". Its area is then a cell of the side grid (table.columns by table.rows) and must not cover any side zone; the opponent's mirrored half leaves that cell empty. It is still one zone for the whole table, and either side can play into it. sharedPlacement is only allowed on shared zones and defaults to "strip".
Card tags from cardsById
Tag each card from its catalog fields, then let zones and actions test the tags. Here, from Legends of Runeterra's card types: only units may enter the board, and Cast only shows up on spells.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck, cardsById) {
const cardTags = {};
// Tag every card the table can show, the opponent's deck included.
Object.keys(cardsById).forEach((code) => {
const card = cardsById[code];
const type = card && card.game ? card.game.typeRef : undefined;
if (type === "Unit") {
cardTags[code] = ["unit"];
} else if (type === "Spell") {
cardTags[code] = ["spell"];
}
});
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 4 },
ordered: true,
defaultFaceDown: false,
accepts: { kind: "tag", tag: "unit" },
},
{
id: "graveyard",
label: "Graveyard",
owner: "side",
visibility: "public",
layout: "pile",
area: { row: 0, col: 4 },
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "cast",
label: "Cast",
target: "selection",
zones: ["hand"],
when: { kind: "tag", tag: "spell" },
shortcut: "c",
steps: [{ kind: "move", to: "graveyard" }],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 4 },
],
initialZones: { deck: cardList(deck) },
cardTags: cardTags,
};
}cardTags maps a card code to its tags. Tag every code in cardsById, not only the ones in deck: in Versus with a different opponent deck, cardsById covers both decks. A spell dragged onto the board is refused and stays in hand. The card fields differ per game; see the card data reference for Cyberpunk TCG, Flesh and Blood, Hearthstone, Legends of Runeterra, Palworld TCG, Pokémon TCG and Riftbound.
Next round for both sides
A table-wide Next round, run by the toolbar's Turn button (which reads Round for a game action), that advances the round once, then refills mana, clears "Stunned" and draws for every side in play. It shows the round action, trackers, tracker values, flags and the forEachSide block.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck) {
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
enterState: { resetFlags: true },
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [
{
id: "manaGems",
label: "Mana gems",
initial: 0,
min: 0,
max: 10,
owner: "side",
},
{ id: "mana", label: "Mana", initial: 0, min: 0, max: 10, owner: "side" },
],
markers: [],
flags: [{ id: "stunned", label: "Stunned" }],
actions: [
{
id: "stun",
label: "Stun",
target: "selection",
zones: ["board"],
shortcut: "s",
steps: [{ kind: "flag", flag: "stunned", mode: "toggle" }],
},
{
id: "nextRound",
label: "Next round",
target: "game",
shortcut: "n",
steps: [
{ kind: "turn" },
{
kind: "forEachSide",
steps: [
{ kind: "tracker", tracker: "manaGems", delta: 1 },
{
kind: "tracker",
tracker: "mana",
set: { tracker: "manaGems" },
},
{ kind: "clearFlag", flag: "stunned", zones: ["board"] },
{ kind: "draw", from: "deck", to: "hand" },
],
},
],
},
],
roundActionId: "nextRound",
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 4 },
],
initialZones: { deck: cardList(deck) },
};
}roundActionIdnames the action the toolbar's Turn button runs; it must be agameorsideaction. Agameaction, as here, counts rounds that advance the whole table at once, so the button reads Round. Asideaction counts turns: in Versus each click starts the next turn for the other side. Either way theturnstep advances the table's turn counter once, outside the block, so there is no separate round tracker.- A
gameaction runs once for the whole table. forEachSideruns its steps once per side in play (you first), each time as that side. Block steps can't be nested, andsetupcan't useforEachSidebecause it already runs once per side.{ tracker: "manaGems" }in a number field reads that tracker's current value when the step runs: here, mana refills to the number of gems.- Flags are on/off marks on cards, declared in
flagsso the table can label them.enterState: { resetFlags: true }clears them when a card enters the board.
Redraw until a condition holds
A Pokémon-style opening hand: draw 7, and while the hand has no Basic Pokémon, shuffle it back and draw 7 again.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck, cardsById) {
const cardTags = {};
Object.keys(cardsById).forEach((code) => {
const game = cardsById[code] && cardsById[code].game;
const supertype = game ? String(game.supertype).replace("é", "e") : "";
const subtypes = game && Array.isArray(game.subtypes) ? game.subtypes : [];
if (supertype === "Pokemon" && subtypes.indexOf("Basic") !== -1) {
cardTags[code] = ["basic"];
}
});
const hasBasic = {
kind: "zoneHas",
zone: "hand",
where: { kind: "tag", tag: "basic" },
};
const redraw = [
{ kind: "move", cards: { zone: "hand" }, to: "deck" },
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 7 },
];
return {
version: 1,
table: { columns: 6, rows: 1 },
zones: [
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 0 },
ordered: true,
defaultFaceDown: true,
enterState: { faceDown: true },
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 0, col: 1, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "mulligan",
label: "Mulligan",
target: "side",
shortcut: "shift+m",
steps: redraw.concat([
{
kind: "repeatUntil",
until: hasBasic,
steps: redraw,
maxIterations: 20,
},
]),
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 7 },
{
kind: "repeatUntil",
until: hasBasic,
steps: redraw,
maxIterations: 20,
},
],
initialZones: { deck: cardList(deck) },
cardTags: cardTags,
};
}repeatUntil checks until before each pass, so a hand that already has a Basic Pokémon is kept as it is. maxIterations caps the passes (at most 20), which stops a deck with no Basic Pokémon at all from looping forever. until can only test zones, with zoneHas (combined with all, any and not if needed), because there is no single card to test. Every pass is logged, and the whole redraw is still one undo step.
Create a copy
Put a copy of a card on the table that was never in the deck, as some cards do in Legends of Runeterra. It shows the create and remove steps.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck) {
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [],
actions: [
{
id: "copy",
label: "Create a copy",
target: "card",
zones: ["board"],
shortcut: "c",
steps: [{ kind: "create", card: "target" }],
},
{
id: "copyToHand",
label: "Create a copy in hand",
target: "card",
zones: ["board"],
steps: [{ kind: "create", card: "target", to: "hand" }],
},
{
id: "removeCopy",
label: "Remove from game",
target: "selection",
zones: ["board", "hand"],
// Only offered on created cards.
when: { kind: "created" },
steps: [{ kind: "remove" }],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 4 },
],
initialZones: { deck: cardList(deck) },
};
}card: "target"copies the card the action runs on. Withoutto, the copy goes into the target's own zone; withto, into that zone.countmakes several copies at once (at most 20).- The copy is a new card marked as created. It takes the destination's
defaultFaceDownandenterStatelike any card moving in, and a full zone refuses it (the log says so). removetakes created cards out of the game. Cards from the deck are never removed: the step skips them and says so in the log. Cards attached to a removed card stay in its zone.- The
createdpredicate is true only for created cards, sowhen: { kind: "created" }keeps Remove from game off deck cards. Atagcan't tell them apart: a copy has the same card code as its original. - Undo takes the copy away again, and redo brings it back with the same id.
Level up via an associated card
A champion levels up by turning into its level 2 card. Catalog cards list their related cards (level-ups, tokens, cards they create) in card.game.associatedCardRefs, and the table includes those cards in cardsById. Return them in associatedCards, and a card param picks one of them.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck, cardsById) {
const cardTags = {};
const associatedCards = {};
Object.keys(cardsById).forEach((code) => {
const card = cardsById[code];
const game = card && card.game ? card.game : {};
if (game.supertypeRef === "Champion") cardTags[code] = ["champion"];
if (Array.isArray(game.associatedCardRefs)) {
associatedCards[code] = game.associatedCardRefs;
}
});
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "board",
label: "Board",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 5 },
ordered: true,
defaultFaceDown: false,
},
{
id: "deck",
label: "Deck",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
},
],
trackers: [],
markers: [{ id: "damage", label: "Damage", step: 1 }],
actions: [
{
id: "levelUp",
label: "Level up",
target: "card",
zones: ["board"],
when: { kind: "tag", tag: "champion" },
shortcut: "l",
params: [
{
id: "into",
label: "Level up into",
kind: "card",
cardSource: {
kind: "associated",
where: { kind: "tag", tag: "champion" },
},
},
],
steps: [{ kind: "transform", card: { param: "into" } }],
},
],
setup: [
{ kind: "shuffle", zone: "deck" },
{ kind: "draw", from: "deck", to: "hand", count: 4 },
],
initialZones: { deck: cardList(deck) },
cardTags: cardTags,
associatedCards: associatedCards,
};
}- A
cardparam'scardSourcesays where its choices come from.kind: "associated"lists the target card'sassociatedCards;wherenarrows them by tag.wherecan only test tags (withall,anyandnot), because the choices are card codes, not cards on the table. - When exactly one card qualifies, Playtest picks it without asking. Here a level 1 champion's associated cards include the spell it creates, so
wherekeeps only the champion card. transformchanges the card's code in place. It stays where it is, with its damage, flags, rotation and attached cards, so levelling up keeps the board as it was.- A
cardparam can also feedcreate:{ kind: "create", card: { param: "into" }, to: "board" }puts a new copy of the picked card on the board.
Tokens that vanish off the battlefield
In Magic: The Gathering, a token that leaves the battlefield stops existing. Mark the zones it can't survive in with removesCreated: true, and the table takes created cards out of the game when they enter.
js
function cardList(deck) {
const cards = [];
Object.keys(deck.main).forEach((code) => {
for (let copy = 0; copy < deck.main[code]; copy += 1) cards.push(code);
});
return cards;
}
export default function playtest(deck, cardsById) {
const cardTags = {};
const associatedCards = {};
Object.keys(cardsById).forEach((code) => {
const card = cardsById[code];
const game = card && card.game ? card.game : {};
if (game.layout === "token") cardTags[code] = ["token"];
if (Array.isArray(game.associatedCardRefs)) {
associatedCards[code] = game.associatedCardRefs;
}
});
return {
version: 1,
table: { columns: 6, rows: 2 },
zones: [
{
id: "battlefield",
label: "Battlefield",
owner: "side",
visibility: "public",
layout: "row",
area: { row: 0, col: 0, colSpan: 4 },
ordered: true,
defaultFaceDown: false,
},
{
id: "graveyard",
label: "Graveyard",
owner: "side",
visibility: "public",
layout: "pile",
area: { row: 0, col: 4 },
ordered: true,
defaultFaceDown: false,
removesCreated: true,
},
{
id: "library",
label: "Library",
owner: "side",
visibility: "hidden",
layout: "pile",
area: { row: 0, col: 5 },
ordered: true,
defaultFaceDown: true,
removesCreated: true,
},
{
id: "hand",
label: "Hand",
owner: "side",
visibility: "private",
layout: "fan",
area: { row: 1, col: 0, colSpan: 6 },
ordered: true,
defaultFaceDown: false,
removesCreated: true,
},
],
trackers: [],
markers: [],
actions: [
{
id: "makeToken",
label: "Create a token",
target: "card",
zones: ["battlefield"],
shortcut: "k",
params: [
{
id: "token",
label: "Token",
kind: "card",
cardSource: {
kind: "associated",
where: { kind: "tag", tag: "token" },
},
},
],
steps: [
{ kind: "create", card: { param: "token" }, to: "battlefield" },
],
},
{
id: "destroy",
label: "Destroy",
target: "selection",
zones: ["battlefield"],
shortcut: "x",
steps: [{ kind: "move", to: "graveyard" }],
},
],
setup: [
{ kind: "shuffle", zone: "library" },
{ kind: "draw", from: "library", to: "hand", count: 7 },
],
initialZones: { library: cardList(deck) },
cardTags: cardTags,
associatedCards: associatedCards,
};
}removesCreatedapplies however a created card gets there: a step, a drag and drop, or a draw. Cards from the deck move in as usual.- A token attached to a deck card leaves with it too: destroying the host sends the host to the graveyard and takes the token out of the game.
- The table doesn't know which cards are tokens. The script decides, here from the catalog's
game.layout; the card data reference for your game lists its fields.
Sharing
Every set of rules you make is private until you share it.
- Make public (a button in Settings → Playtest rules, or the Make public box in the editor) lists the rules on the Playtest rules tab of your profile and lets anyone with the link open them. Make private takes them down again.
- Copy link (public rules only) copies the rules' page link,
/playtest-rules/<id>on the game's site. Links always show the latest saved version.
The rules' page shows their name, owner, version and last update, and Show source expands the full script. From there anyone can:
- Playtest with these rules, which opens Playtest with them already picked,
- Save to account (when signed in), which adds a Downloaded copy to their own Settings list. A saved copy stays on the version it was saved from and never changes by itself.
- Update, when the owner has saved a newer version since, to move their copy to the latest version. In Settings the copy shows Update available and has the same Update button.
A downloaded copy can be switched on and off, viewed, forked and removed, but not edited. Fork it to make changes, which creates a private set of your own.
Things to know:
- A fork always starts private, even when you fork public rules.
- Public means the code is public. Don't put anything in a comment or label you wouldn't want others to read.
Troubleshooting
The Validation panel in the editor, and Playtest itself when a game can't start, show each problem the table found with the rules. Every problem has a code, listed below with its fix. Most also name the place in the definition, such as actions[2].shortcut (the third action's shortcut). The same codes are in the issue code reference.
The script doesn't run
script_unsafe
"The rules script uses code that isn't allowed." Playtest rules run in the same locked-down sandbox as custom rulesets and calculators, and a safety check reads every script before it runs or saves. The usual suspects are var (use let or const), globals that aren't on the allowed list (such as fetch, window or eval), async / await, class, this and import. The full rules are on the script sandbox page.
script_error
"The rules script failed to run." The script threw an error, or it doesn't export a function. Check that it has export default function playtest(deck, cardsById, ctx) (or a top-level function playtest), and read the message for the error: Cannot read properties of undefined usually means a missing card. Guard with card && card.game before reading card fields.
script_timeout
"The rules script took too long to run." A script that runs longer than 5 seconds is stopped. That almost always means a loop that never ends, such as a while whose condition never turns false.
worker_failed
"The rules script could not be run." The background worker that runs scripts crashed or never started. This is not a problem with your script: reload the page.
The shape is wrong
invalid_shape
A field is missing, has the wrong type, or holds a value that isn't allowed, such as layout: "stack" or owner: "player". The message names the field. Compare it with the definition reference; every allowed string is listed under Enums. Remember that the script must return the definition, not just build it.
unsupported_version
The definition's version must be 1.
over_cap
Something is over its limit: too many zones or actions, too many steps in one action, a label that is too long, and so on. The message names the limit. Every limit is listed under Limits.
invalid_id
Ids must start with a letter and use only letters, digits, _, ., : and -, and can't be names like constructor or toString. The same goes for the keys of initialZones and cardTags.
duplicate_zone_id
Two zones have the same id. Every zone needs its own.
duplicate_action_id
Two actions have the same id. When you build actions in a loop, make the id include the loop value (for example "damage" + n).
duplicate_tracker_id
Two trackers have the same id.
duplicate_marker_id
Two markers have the same id.
duplicate_param_id
Two params of the same action have the same id.
duplicate_flag_id
Two flags have the same id.
Something refers to a thing that doesn't exist
unknown_zone
A step, predicate, action zones list or initialZones key names a zone that isn't in zones. Check the spelling: ids are case-sensitive.
unknown_action
A zone's primaryActionId or dropActionId, or the definition's roundActionId, names an action that isn't in actions.
invalid_round_action
"The Turn button action must act on a side or the whole game." roundActionId names a card, selection or zone action, which the toolbar's Turn button has nothing to run on. Point it at a side or game action, usually your New turn.
unknown_tracker
A tracker step, or a { tracker: "..." } value, names a tracker that isn't in trackers.
unknown_marker
A counter step or a counterAtLeast predicate names a marker that isn't in markers.
unknown_flag
A flag or clearFlag step, a readyAll skipFlag, or a flag predicate names a flag that isn't in flags. Declare every flag you use.
unknown_param
A { param: "..." } value names a param the action doesn't declare in its params. setup has no params, so it can't use { param } at all.
param_kind_mismatch
A { param } value is used where its param can't supply the right kind of value, such as a choice param of zone names used as a card count. Use a number param for numbers, and a card param (or a choice param of card codes) for the card of a create or transform step.
invalid_tracker_ref
A { tracker, side } value names a side that doesn't fit the tracker. A shared tracker (owner: "shared") takes no side or side: "shared"; a per-side tracker takes side: "self" or side: "other".
invalid_tracker_toggle
A tracker step with toggle: true needs a tracker that runs from 0 to 1: declare it with min: 0, max: 1.
Steps are combined in a way that can't work
nested_block_step
A forEachSide or repeatUntil step sits inside another one. Block steps hold one level of plain steps only; move the inner block out, or split the action.
for_each_side_in_setup
setup already runs once for each side, so it can't use forEachSide. List the steps directly.
condition_needs_zone_has
A repeatUntil condition tests a card (with tag, flag, faceDown and so on), but there is no card to test. Wrap the card test in a zoneHas predicate, as in Redraw until a condition holds.
The table layout doesn't fit
zone_outside_table
A zone's area reaches past the edge of its grid. Side zones, and shared zones with sharedPlacement: "playerGrid", must fit in table.columns by table.rows; other shared zones must fit in the shared strip (table.sharedRows rows). Remember that rows and columns start at 0, so the last column is columns - 1.
zone_overlap
Two zones in the same grid cover the same cell. Move one, or shrink its rowSpan / colSpan. A side zone and a shared strip zone never overlap, because they sit in different grids, but a "playerGrid" shared zone sits in the side grid and must fit around the side zones.
A card option or created card can't work
card_param_needs_source
"Card option needs a cardSource to pick cards from." A param with kind: "card" needs a cardSource, such as { kind: "associated" }, so the table knows which cards to offer. See Level up via an associated card.
card_source_needs_tag
A cardSource's where tests something other than tags, such as zone or faceDown. Its choices are card codes, not cards on the table, so it can only use tag (combined with all, any and not). Tag the cards from cardsById and filter on the tag.
create_needs_card_target
A create step has no to, or copies card: "target", but its action doesn't run on a card. Only card and selection actions have a target card to copy or to put the new card beside; setup and side, game and zone actions don't. Name a destination zone with to and a card code (or a { param }) with card.
A shortcut can't be used
invalid_shortcut
The shortcut doesn't follow the grammar [mod+][shift+]<key>. Write mod instead of ctrl or cmd, and use a key from the list of keys. A "1-9" shortcut also needs the action to have a number param to receive the digit.
shortcut_uses_alt
The shortcut uses Alt (or Option). Alt is reserved: the table adds an Alt version of every shortcut that acts for the opponent. Pick another key; you get the opponent version for free.
shortcut_reserved
The shortcut is one the table itself uses: Mod+Z (undo), Mod+Shift+Z and Mod+Y (redo), ? (the shortcut sheet) or Escape (clear the selection). Pick another key.
shortcut_conflict
Two actions that can apply to the same thing share a key. Two card actions (or two zone actions) may share a key only when their zones lists don't overlap, and every side and game action needs its own key. Change one of the keys, or narrow the actions' zones.