Skip to content

Deck

A pile of cards to draw from, with no code: its cards are the entities inside it with a Card (the last one is the top), or made from a Table, one for each row, as the game starts. It’s shuffled as the game starts (shuffles use the game’s random numbers, so a seeded game deals the same), and a Hand draws its top card. Face down it shows only its back; face up (FaceUp) it’s a discard pile showing its top card. Click it to draw a card into your hand. Run out, it shuffles its RefillFrom pile back in.

Part of the Cards module: Card games: cards (Card) drawn from decks (Deck) into hands (Hand) and played by dragging them onto play zones (PlayZone), shuffled, discarded and sliding between them; the Cards template, a duel against the computer made from a table of cards; and Create Deck, Create Play Zone and Create Card in the Entity menu.

Its Draw, Shuffle and Restart actions are there for a Trigger, a wire or a script, and its Count output for a Counter or a Text. The order of its cards is saved with the scene, so a rewind goes back to it. In a network game the host shuffles and deals, and the cards in a face-down deck aren’t sent to anyone’s machine: only how many there are.

Works with: Card (its cards, inside it); Hand (draws from it); TableValues

Draws itself (its entity draws at Order 0 unless it has a Sprite, whose order counts).

Changes how its entity is drawn (a tint, a shake or drawing it on top).

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • faceUp: true or false = false. Shows its top card face up: a discard pile. Face down (as it is by default) shows only its back, and nobody can tell the order of its cards: in a network game they aren’t even sent to players’ machines. (Field: on or off.)
  • shuffleOnStart: true or false = true. Shuffles it as the game starts. (Field: on or off.)
  • clickToDraw: true or false = true. Clicking it draws its top card into the clicking player’s hand (one that draws from it), as does a hand’s Draw Action on the keys or a gamepad. (Field: on or off.)
  • takesDrops: true or false = false. Cards can be dragged from a hand onto it, and land on top: a discard pile. (Field: on or off.)
  • refillFrom: text = null. Another deck (a discard pile) whose cards are shuffled back into this one when a card is drawn from it once it has run out. Empty: it stays empty. (Names an entity.) (Field: an entity’s name.)
  • table: text = null. A table to make its cards from as the game starts, e.g. “Cards”: a card for each row (more with CountColumn), named like the row, with a Table Values setting it from the row, so a column called Title, Text, Value, Kind, Color or Image sets the card’s, and any other column a property of the same name on the Prefab’s components. (Names a table.) (Field: a name.)
  • prefab: text = null. The prefab each card made from the table is a copy of, e.g. “Card”: its look and parts. Empty makes plain cards. A row can name its own in the PrefabColumn. (Names a prefab.) (Field: a name.)
  • prefabColumn: text = “Prefab”. A column of the table naming the prefab each row’s cards are a copy of, e.g. “Creature” for a card with a Health and “Spell” for one without, so one table holds cards of several makes. A row with it empty (or a table without it) uses Prefab. (Names a column of a table.) (Field: a name.)
  • countColumn: text = “Count”. A whole-number column of the table saying how many copies of each row’s card go in it. A row without one gets one. (Names a column of a table.) (Field: a name.)
  • size: [x, y] = [1.6,2.24]. How big its pile is drawn: its cards’ size. (Field: a vector.)
  • back: text = null. The picture on the back of its cards. Empty draws a plain back of BackColor. (A picture in Assets, e.g. “Sprites/back.png”.) (Field: an image.)
  • backColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#2D4F8AFF”. The color of its cards’ backs. (Field: a color.)
  • spread: a number = 0.012. How far up each card of the pile sits from the one under it, so a thick deck looks thick. (Field: a number.)
  • slideTime: a number = 0.3. Seconds a card takes to slide onto it. (Field: a number.)
  • drawSound: text = null. A sound played as a card is drawn from it, e.g. “Sounds/draw.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • shuffleSound: text = null. A sound played as it’s shuffled. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • shuffleMessage: text = null. A message sent as it’s shuffled, with this entity as its data. (Names a message.) (Field: a name.)
  • emptyMessage: text = null. A message sent when a card is to be drawn from it while it’s empty and nothing refills it, with this entity as its data: the end of the game in some card games. (Names a message.) (Field: a name.)
  • started: true or false = false. Set by the game once it has made its cards and shuffled, so a rewind doesn’t do it again. Leave it be. (Field: on or off.)
  • shuffles: a whole number = 0. How many times it has been shuffled. Saved with the scene, so a rewind takes them back. (Field: a number.)

What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).

  • Draw (done with a whole number, its count: a trigger’s with, 1 without one). Draws count cards from it at the start of the next frame, into the hand that draws from it (the one whose team’s turn it is, if several do), a tenth of a second apart.
  • Shuffle. Shuffles it at the start of the next frame.
  • Restart. Gathers every card that belongs to it (see Card.Home) back in at the start of the next frame, face down, shuffles it, and has the hands that draw from it deal their Start With afresh: a new game.

What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.

  • Count (a whole number). How many cards are in it. Kept up to date by the game; in a network game, players’ machines are sent it.
  • Shuffles (a whole number). How many times it has been shuffled. Saved with the scene, so a rewind takes them back.

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • top: an entity with a Card: its name, id or path. Its top card, or null if it’s empty.
  • count: a whole number. How many cards are in it. Kept up to date by the game; in a network game, players’ machines are sent it. (Sent in a network game.)

Scripts use it as Deck: its methods, events and values that aren’t saved with the scene.