Card
namespace Griff.Modules.Cards;
public sealed class Card : Component, IDrawable, IDrawEffect, INetSecret, IPlaytestReportA playing card, with no code: it draws itself as a card of its Color with its Title along the top, its Value in the corner, a picture (Image) and its rules Text, or as its back while it’s face down. Put cards inside a Deck to draw from, a Hand to hold them or a PlayZone on the table: each lays out the cards inside it, and a card that goes from one to another slides over. Its Kind is what a play zone checks before it takes it.
With a Sprite on it, the sprite is its face and the card only draws its back over it. Its back is the one of the deck it belongs to (its Home). Components on it that are an ICardPart hear when it’s drawn, played and discarded, and can say it can’t be played: that’s how card effects and costs hang off a card. With a TableValues its title, text, value, kind and color come from a row of a table (a deck made from a table gives each of its cards one). In a network game, a card in a face-down deck or in another side’s hidden hand isn’t sent to players who aren’t to see it.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”public Color Color { get; set; }The color of its face.
public int Cost { get; set; }Mana it costs to play, paid from the hand’s Mana (which refills as each of its team’s turns starts): a card that costs more than the hand has can’t be played. Shown in its top-right corner. 0 is free.
FaceUp
Section titled “FaceUp”public bool FaceUp { get; set; }True while its face shows. A deck turns the cards put in it face down (a face-up deck, such as a discard pile, face up), a hand face up and a play zone as its Face Up says. A hidden hand shows its faces only to its own side.
public string? Font { get; set; }The font of its writing (see Text’s Font). Empty uses the built-in one.
public string? Home { get; set; }The deck it belongs to, by name: its back is that deck’s, and the deck’s Restart gathers it back. Set by the game as it starts for the cards in each deck that have none.
public string? Image { get; set; }A picture drawn on its face, e.g. “Art/fireball.png”.
IsResting
Section titled “IsResting”public bool IsResting { get; }True once it has slid into its place in its deck, hand or play zone.
public string? Kind { get; set; }What kind of card it is, e.g. “Spell” or “Hearts”: a play zone’s Accepts names the kinds it takes.
OnTableFor
Section titled “OnTableFor”public float OnTableFor { get; set; }Seconds it has lain in its place on a play zone with a Discard After, which goes on to the zone’s discard pile once it’s that long: a spell, cast and gone. Set by the game, and saved with the scene so a rewind keeps it.
PlayedBy
Section titled “PlayedBy”public string? PlayedBy { get; set; }The hand it was last played from, by name: whose side it’s on while it’s on the table (its effects’ “you”, a creature’s side). Set by the game as it’s played.
public string? Price { get; set; }What else it costs to play, beside its mana: items, e.g. “2 Gold”, paid from the items of whoever plays it (an Inventory on the hand or the entity it’s inside, or its team’s: a strategy faction’s gold, coins a teammate picked up; see Items). A card whose price can’t be paid can’t be played. Empty costs nothing more.
ShownText
Section titled “ShownText”public string ShownText { get; }The rules text it shows: its Text, or with none, what its CardEffects do.
ShownTitle
Section titled “ShownTitle”public string ShownTitle { get; }The title it shows: Title, or its entity’s name.
public Vector2 Size { get; set; }How big it is, in world units: 1.6 by 2.24 has a playing card’s shape.
public string? Text { get; set; }What it does, written under its picture and wrapped to fit, e.g. “Deal 3 damage.”
TextColor
Section titled “TextColor”public Color TextColor { get; set; }The color of its writing.
public string? Title { get; set; }What it’s called, written along its top. Empty writes its entity’s name.
public int Value { get; set; }A number in its top-left corner: its rank, its strength, its points. 0 shows none. A card with no picture and no text shows it big in its middle too, like a playing card.
public CardZone? Zone { get; }The place it’s in (the deck, hand or play zone it’s inside), or null.
Methods
Section titled “Methods”public override bool Uses(string property)Events
Section titled “Events”Discarded
Section titled “Discarded”public event Action<Card, Deck>? DiscardedRaised as it’s put on a discard pile (or any deck), with the deck.
public event Action<Card, Hand>? DrawnRaised as it’s drawn into a hand, with the hand.
Played
Section titled “Played”public event Action<Card, PlayZone>? PlayedRaised as it’s played, with the play zone.