Variables

Since sometimes JPortal is alive - I cannot gurantee that the provided information is allways up to date. The class "CardShellEnvironment.java" allways holds all variables which are passed to card scripts. If in doubt - please check back in the source of that class.

In card scripts certain variables are allways accessable, these are defined in the class "CardShellEnvironment", at the moment of this writing the variables are: (not all of them are allways set, if not set they will have a value of "null", variables which are not available at all have a value of "void"!)

(Communication responses are set to null, if no communication occured yet!)

(regarding a past communication)
Boolean: maybeTaken
Boolean: cancled
Boolean: successfull
Boolean: selectYes
Boolean: selectNo

MatchPlayable player
MatchPlayable opponent
MatchPlayable targetPlayer

Card card (this card we are scripting for)
Card attacker
Card blocker
Card targetCard
Card sourceCard

Match match
CardShellEnvironment ev
TemporaryEffect effect
CardTrigger trigger
int amount
int type
String status
Communication c
String thisScript
(the script currently being excuted)

Logable D
Logable L

Globals

Sometimes you might have the need to remember your own data from one call to another.
For this you can use a "global" variable mechanism, remember to clean up! The globals are managed by match (internally represented as a HashMap). To access your very own variables, you need a key.
You might define your own keys, but to be absolutly certain to get your own data back, you should use a key provided by match.

String baseKey = match.getGlobalScriptBaseKey(thisScript, player, card);

This key is certain to be unique for this "instance" of script. Which means if the script must be called several times per "round" you can pass variable information by using this base key.
Example (Primeval Force):

Here the player is asked to destroy three forests. After each such communication the Primeval Force - CARD PLAYED-script is called again to monitor the progress:

...
    String baseKey = match.getGlobalScriptBaseKey(thisScript, player, card);
    int counter = match.getIntData(baseKey+"Counter");
    ...
    if (counter < 3)
    {
        match.askSelectFromOwnLand(player, card, ev);
        bRet=false;
        return;
    }
...

Since this data is kept till removed, be sure to remove the data when not needed any longer, I didn't implement a garbage collection!

Following methods exists:
    public int getIntData(String key)
    public int setIntData(String key, int value)
    public int removeIntData(String key)

    public int getBooleanData(String key)
    public int setBooleanData(String key, int value)
    public int removeBooleanData(String key)

    public int getObjectData(String key)
    public int setObjectData(String key, int value)
    public int removeObjectData(String key)