Skip to content

CardEffect

What a card does, with no code: as it’s played (or drawn, discarded, or each turn while it’s on the table) it deals Damage, gives back Heal, has you Draw cards, has its target’s side Discard, gives you GainMana, raises a number (Buff) or does any action (Do), like a Trigger, so a card can drive another part of the game. It does it to its Target: the opponent, yourself, a card or unit the player chooses, or all of them. Give a card one for each thing it does; with no Text of its own, a card writes what its effects do on its face.

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 numbers can come from a table: a deck made from a table sets a column called Damage, Heal, Draw, Discard, Target or Cost on each card (dice in a column roll for each play), so cards from a table carry their effects and costs. A target’s life is its Health: a side’s hero (see Hand.Hero), any character with a Health, or a card on the table with one (a creature, which goes to the discard pile when it dies). The computer weighs effects to choose its plays (see Hand). Effects happen where the game is run, with the game’s random numbers, so a seeded game plays the same, and what they change is saved with the scene.

Requires: Card (the card it’s part of)

Works with: Health (what its damage and healing land on (a hero’s, or the card’s own)); TableValues (its numbers from a table’s columns)

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.

  • when: one of Played, Drawn, Discarded, EachTurn = “Played”. When it happens: as the card is played (the usual), drawn or discarded, or as each of its team’s turns starts while it’s on the table. (Field: one of its values.)
  • target: one of Opponent, Self, Chosen, AllFoes, AllFriends, Everyone = “Opponent”. Whom it’s done to: the CardTarget.Opponent’s hero, your own (CardTarget.Self), a card or unit the player picks as they play it (CardTarget.Chosen), or every foe, friend or both. (Field: one of its values.)
  • chooseFrom: text = null. The entities a chosen target may be, by name, separated by commas, or a place they’re inside, e.g. “Enemy Row”: only the cards on it can be chosen. Empty: any card on the table or character with a Health. (Only used when target is Chosen.) (Names entities: their names, separated by commas.) (Field: an entity’s name.)
  • damage: a number = 0. Hit points it takes from its target (its Health), each target once. (Field: a number.)
  • damageRoll: text = null. Dice rolled each time in place of Damage, e.g. “1d6+1”; empty deals Damage every time. (Dice: how many, “d”, their sides, then anything added or taken away, e.g. “2d6+3”, “d20”, “1d8+1d6-1” or a plain number; empty for none. The Inspector builds them and shows the lowest, highest and average roll.) (Field: its own editor: Dice.)
  • heal: a number = 0. Hit points it gives back to its target, never past its Max. (Field: a number.)
  • healRoll: text = null. Dice rolled each time in place of Heal, e.g. “2d4”. (Dice: how many, “d”, their sides, then anything added or taken away, e.g. “2d6+3”, “d20”, “1d8+1d6-1” or a plain number; empty for none. The Inspector builds them and shows the lowest, highest and average roll.) (Field: its own editor: Dice.)
  • draw: a whole number = 0. Cards the player who played it draws, one after another. (Field: a number.)
  • discard: a whole number = 0. Cards its target’s side discards from their hand, picked at random (the game’s random numbers). (Field: a number.)
  • gainMana: a whole number = 0. Mana the player who played it gains: a hand’s Mana, for more plays this turn. (Field: a number.)
  • buff: a number = 0. How much it adds to a number of its target’s (BuffStat), for good: +2 to a creature’s Value. Less than 0 weakens. (Field: a number.)
  • buffStat: text = “Value”. The number Buff raises: a property of its target’s components, e.g. “Value” (a card’s), “Armor” or “Health.Max” (one component’s). (Only used when buff is set.) (A number of its target’s components, by its property’s name (“Value”: any component’s) or a component’s and its property’s (“Health.Max”). The Inspector lists the numbers of the components in the scene on things with a Card or Health.) (Field: its own editor: Stat.)
  • do: text = null. An action it does too, as a Trigger does, e.g. “Open”, “Spawn” or “Damage”: on DoOn, or on its target without any. A card can drive anything in the scene this way: a door in the level, a spawner, a script’s action. (Names an action of the entities doOn names, or this entity without any: one component_describe lists under Actions, e.g. “Damage”, or “Health.Damage” for one component’s.) (Field: an action’s name.)
  • doOn: text = null. The entities to do it on, by name, separated by commas. Empty does it on its target. (Names entities: their names, separated by commas.) (Field: an entity’s name.)
  • with: text = null. What to do it with, for an action that takes a value: how much, a name, or true or false. Empty uses the action’s own default. (The value the action do names is done with, as the action takes it: a number (“2”), true or false, or a name (a flag for Set Flag, a scene for Load Scene). Empty uses the action’s own default. The Inspector gives a box, a tick or a list as the action wants.) (Field: its own editor: Action Value.)
  • sound: text = null. A sound played as it happens, e.g. “Sounds/zap.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • effect: text = null. A prefab spawned on each target as it happens, e.g. “Sparkle”. (Names a prefab.) (Field: a name.)

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

  • chooses: true or false. True if it takes a target the player chooses as the card is played.

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