Deck
namespace Griff.Modules.Cards;
public sealed class Deck : CardZone, IDrawable, IDrawEffect, IPlaytestReportA 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.
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.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”public string? Back { get; set; }The picture on the back of its cards. Empty draws a plain back of BackColor.
BackColor
Section titled “BackColor”public Color BackColor { get; set; }The color of its cards’ backs.
ClickToDraw
Section titled “ClickToDraw”public bool ClickToDraw { get; set; }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.
CountColumn
Section titled “CountColumn”public string? CountColumn { get; set; }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.
DrawSound
Section titled “DrawSound”public string? DrawSound { get; set; }A sound played as a card is drawn from it, e.g. “Sounds/draw.wav”.
EmptyMessage
Section titled “EmptyMessage”public string? EmptyMessage { get; set; }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.
FaceUp
Section titled “FaceUp”public bool FaceUp { get; set; }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.
Prefab
Section titled “Prefab”public string? Prefab { get; set; }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.
PrefabColumn
Section titled “PrefabColumn”public string? PrefabColumn { get; set; }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.
RefillFrom
Section titled “RefillFrom”public string? RefillFrom { get; set; }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.
ShuffleMessage
Section titled “ShuffleMessage”public string? ShuffleMessage { get; set; }A message sent as it’s shuffled, with this entity as its data.
ShuffleOnStart
Section titled “ShuffleOnStart”public bool ShuffleOnStart { get; set; }Shuffles it as the game starts.
ShuffleSound
Section titled “ShuffleSound”public string? ShuffleSound { get; set; }A sound played as it’s shuffled.
Shuffles
Section titled “Shuffles”public int Shuffles { get; set; }How many times it has been shuffled. Saved with the scene, so a rewind takes them back.
public Vector2 Size { get; set; }How big its pile is drawn: its cards’ size.
SlideTime
Section titled “SlideTime”public float SlideTime { get; set; }Seconds a card takes to slide onto it.
Spread
Section titled “Spread”public float Spread { get; set; }How far up each card of the pile sits from the one under it, so a thick deck looks thick.
Started
Section titled “Started”public bool Started { get; set; }Set by the game once it has made its cards and shuffled, so a rewind doesn’t do it again. Leave it be.
public string? Table { get; set; }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.
TakesDrops
Section titled “TakesDrops”public bool TakesDrops { get; set; }Cards can be dragged from a hand onto it, and land on top: a discard pile.
public Card? Top { get; }Its top card, or null if it’s empty.
Methods
Section titled “Methods”public void Draw(int count = 1)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.
Restart
Section titled “Restart”public void 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.
Shuffle
Section titled “Shuffle”public void Shuffle()Shuffles it at the start of the next frame.
public override bool Uses(string property)Events
Section titled “Events”Shuffled
Section titled “Shuffled”public event Action<Deck>? ShuffledRaised as it’s shuffled.