Card situations

So now, what situations are there?

(found in "CardSituation.java")
   CARD TAPPED KEY
   CARD UNTAPPED KEY
   CARD PLAYED KEY
   CARD CAN ATTACK KEY
   CARD DECLARED AS ATTACKER KEY
   CARD UNDO DECLARED AS ATTACKER KEY
   CARD ATTACKER DONE KEY
   CARD UNTAP ATTACKER KEY
   CARD UNDO DECLARED AS BLOCKER KEY
   CARD CAN BLOCK KEY
   CARD DECLARED AS BLCOKER KEY
   CARD CAN BLOCK ATTACKER KEY
   CARD ATTACKER ACCEPT BLOCKER KEY
   CARD ATTACKER ENTERS FIGHT KEY
   CARD BLOCKER ENTERS FIGHT KEY
   CARD FIRST DAMAGEIN FIGHT KEY
   CARD DAMAGEIN FIGHT KEY
   CARD DAMGE TAKEN KEY
   CARD CREATURE DEATH KEY
   CARD SURVIVED BATTLE WITH POWER KEY
   CARD PUT TO GRAVEYARD KEY
   CARD PUT TO GRAVEYARD FROM BATTLE KEY
   CARD INIT KEY
   CARD PHASE CHANGE KEY
   CARD OTHER PUT IN GAME KEY
   CARD APPLY EFFECT KEY
   CARD REMOVE EFFECT KEY
   CARD CAN BE PLAYED KEY
   CARD EXECUTE TRIGGER KEY
   CARD CAN RESSURECT KEY
   CARD BLOCK ACTIVATED KEY
   CARD ATTACKER NOT BLOCKED KEY
   CARD IS BLOCKED ACTIVATED KEY
   CARD ACCEPT DAMAGE KEY
   CARD ACCEPT SPELL ABILITY FOCUS KEY
   CARD CAN BE TAPPED KEY

I am sorry - but I have to go through them and at least give a comment to each of these.

   CARD TAPPED KEY
Called whenever that card is tapped by a player. (For lands a template is used, see Card Templates)
Example: "King's Assassin", ID 4227

The scripting should test, whether tapping "now" should be allowed, meaning e.g. the above mentioned card can only be tapped during Declare Attackers Phase - not in any other phase!

   CARD UNTAPPED KEY
This should in general not be used. Untapping a card like "King's Assassin" would be quite difficult, since the card that went to grave would have to be reinstalled etc. While that is possible, it is not worthwhile the effort - and a player should know what he does.

However untapping of lands (e.g.) is allowed as long as the mana is not used.

   CARD PLAYED KEY
This is the "main" situation key. This script is called once the mana for the card is payed and the card is actually played out (sorcery, instant, creature).

   CARD CAN ATTACK KEY
Is the card able to attack? For a example a "Defender" would return "no".
Immediate call!

   CARD DECLARED AS ATTACKER KEY
Called whenever a card is successfully declared as an attacker.
Example: "Alaborn Cavalier", ID 6506

   CARD UNDO DECLARED AS ATTACKER KEY
Script not supported any longer (meaning it is never ever called, since "un attacking" was removed some time ago. Was used to ask whether un-attacking is possible.
Immediate call

   CARD ATTACKER DONE KEY
Not implemented, not used.

   CARD UNTAP ATTACKER KEY
Not implemented, not used.

   CARD UNDO DECLARED AS BLOCKER KEY
Called after a card was successfully un-declared as blocker. (implemented, but no card uses this as yet)

   CARD CAN BLOCK KEY
Called to ask whether a card can block at all.
Example: "Craven Knight", ID 4213 (see also template "NoBlock")
Immediate call

   CARD DECLARED AS BLCOKER KEY
Called when a card was successfully appointed as a blocker. (implemented, but no card uses this as yet)

   CARD CAN BLOCK ATTACKER KEY
Called to ask whether a blocker can actually block an attacker.
Example: "Cloud Dragon", ID 4252
Immediate call

   CARD ATTACKER ACCEPT BLOCKER KEY
Called to ask whether an attacker accepts a blocker.
Example: "Prowling Nightstalker", ID 6556
Immediate call

   CARD ATTACKER ENTERS FIGHT KEY
Called when an attacker successfully enters a fight. Meaning when the fighting starts.
Example: "Shrieking Specter", ID 20363

   CARD BLOCKER ENTERS FIGHT KEY
Not implemented, not used.

   CARD FIRST DAMAGEIN FIGHT KEY
Not implemented, not used.

   CARD DAMAGEIN FIGHT KEY
Not implemented, not used.

   CARD DAMGE TAKEN KEY
Not implemented, not used.

   CARD CREATURE DEATH KEY
Implemented, but no card uses this as yet, you should not use this one, there are other keys to use! (Graveyard)

   CARD SURVIVED BATTLE WITH POWER KEY
Implemented, but no card uses this as yet (trample?)

   CARD PUT TO GRAVEYARD KEY
Implemented, but no card uses this as yet. This is called allways a card is moved to the graveyard, if it is put to grave from hand or from library. It is called BEFOR "CARD PUT TO GRAVEYARD FROM BATTLE KEY". But no card I encountered as of now has a speciality when moving to grave from NON battlefield.

   CARD PUT TO GRAVEYARD FROM BATTLE KEY
Called when a creature is moved from the battlefield to the graveyard. Called after the above: "CARD PUT TO GRAVEYARD KEY"
Example: "Alabaster Dragon", ID 4369

   CARD INIT KEY
Called befor the actual game starts. Each card may have access to match befor start. As of yet not yet used. But might be interesting for cards that may want to install a trigger upon some obscure things.

When a match starts, for each card this script will be executed (if it exists). With it the card can and should set what things it might be interested in. This is done by turning a boolean flag to true about the corresponding event. At the moment only support for "enter phase" events is provided. To tell the card it is interested to be called (with a coresponding script) at the beginning of each untap phase, do something like:
card.setBoolData(Match.PHASE STRINGS[Match.PHASE BEGINNING UNTAP], true);
If the card is in the game - it will be called by a the general script key:    CARD PHASE CHANGE KEY
   OTHER PUT IN GAME

There the card should again check whether its really the phase it is interested in this keeps the number of scripts a little bit more in check (the check is only needed if the card is interested in more than one phase change).

There is no TEMPLATE for this script, and if there is it will be ignored!

(No card uses this as yet)

   CARD PHASE CHANGE KEY
Call will occur on cards that are interested in phase change events (see: CARD INIT KEY). The card will be called on each phase it is interested in. If it is interested in more than one phase, the script must check which phase it got called for.

The script is ONLY called during phase changes of the cards owner!

(the blocking phase the script might be called for is also the phase, when the cards owner is the one initiating the attack)

On Combat damage phase it is called BEFOR damage is dealt.

(No card uses this as yet)

   CARD OTHER PUT IN GAME KEY
Called whenever a card is put into the game. This is also a call a card can register to - and there again is no template!

(No card uses this as yet)

   CARD APPLY EFFECT KEY
Each card that changes any "value" of another card has an effect on that card. To be able to use an effect a card has to call:

match.setEffect(...)

Within that code the card will be called with the above situation key.

Usually an effect has some sort of "lifetime". e.g.: Add +1/+1 till the end of the turn

After the "lifetime" of such an effect has run out (match handles that) the next situation key "CARD REMOVE EFFECT KEY" is called.

The script is called with an effect class. Within that class (in good old C-slang struct) all fields are defined that are needed for an effect to take place. (Java class: "TemporaryEffect.java" for more in depth knowledge about effects see: Effects)

Effects in JPortal are at the moment twofold:

  1. an effect on a single card

  2. an effect on a "bunch" of cards

Effects on a single card

These effects are more or less straight forward. Withing the effect scripting the change is made - and within the removeing script the changes are taken back. A simple example may be:
Example: "Monstrous Growth", ID 4305

Effects on a multiple targets

These effects are applied using multiple calls to the effect script.

Usually your first (targetCard=null) call to the script sets the effect to its right values. If these values suggests subsequent calling (of a cardList), match will call the script again (and again...) for each target card and expects the script to apply the effect to the target cards. (Removing the effect vice/versa)

Match also has the responsibility to call the apply effect script if the corresponding list changes (new creatures were played/ creature moved to graveyard etc...)

Example: "Meng Huo, Barbarian King", ID 10732

   CARD REMOVE EFFECT KEY
See apply effects.

   CARD CAN BE PLAYED KEY
A key I sometimes forget. There are other ways to implement "not being able to play a card". Nonetheless - this script is called to evaluate whether a card can be played at a given time. Example: "Assassin's Blade", ID 4208
Immediate call

   CARD EXECUTE TRIGGER KEY
You can add triggers to cards. When the match detects a situation you defined a trigger for, than this script is actived.

Java class: "CardTrigger.java" for more in depth knowledge abouut effects see: Triggers
Example: "Temporal Manipulation", ID 4208

   CARD CAN RESSURECT KEY
Called to ask whether a card can be ressurected. No single card uses this as of now. "Wrath" uses this feature to give each living creature a temporal buff "NoRival" and than destroys the creatures. The template for "NoRivival" returns "false" so no ressuction can be done after playing wrath.
Immediate call

   CARD BLOCK ACTIVATED KEY
Called when a card is blocking an attacker.
Script is from the card, that DOES the blocking!
Example: "Alaborn Zealot", ID 6492

   CARD ATTACKER NOT BLOCKED KEY
Called when an attacker was not blocked.
Example: "Abyssal Nightstalker", ID 6567

   CARD IS BLOCKED ACTIVATED KEY
Script is from the card, that is being blocked!
Example: "Lone Wolf", ID 6614

   CARD ACCEPT DAMAGE KEY
Script is called when creature receives damage of any kind, whether the damage is accepted!
Example: "Champion Lancer", ID 20184
Immediate call

   CARD ACCEPT SPELL ABILITY FOCUS KEY
Whenever that card tries to be focused by another, whether the focus is accepted!
Example: "Zuo Ci, the Mocking Sage", ID 10610
Immediate call

   CARD CAN BE TAPPED KEY
Not implemented, not used.