-
-
Notifications
You must be signed in to change notification settings - Fork 109
Extends: Reference
SP stands for "ScriptProperties".
This class provides a library for constants which are used a key values in the Card Script Definition
It also provides a few static functions for comparing filters
const FILTER_COUNTER_NAME: String = "filter_counter_name"
Value Type: String.
Filter used for checking against TRIGGER_COUNTER_NAME
const FILTER_DEGREES: String = "filter_degrees"
Value Type: int.
Filter used in for checking against TRIGGER_DEGREES
const FILTER_DESTINATION: String = "filter_destination"
Value Type: Dynamic.
Filter for checking against TRIGGER_DESTINATION
const FILTER_FACEUP: String = "filter_faceup"
Value Type: bool.
Filter for checking against TRIGGER_FACEUP
const FILTER_MODIFIED_PROPERTIES: String = "filter_modified_properties"
Value Type: Dictionary.
Filter key used for checking against card_properties_modified details.
Checking for modified properties is a bit trickier than other filters A signal emited from modified properties, will include as values the property name changed, and its new and old values.
The filter specified in the card script definition, will have as the requested property filter, a dictionary inside the card_scripts with the key FILTER_MODIFIED_PROPERTIES.
Inside that dictionary will be another dictionary with one key per property. That key inside will (optionally) have yet another dictionary within, with specific values to filter. A sample filter script for triggering only if a specific property was modified would look like this:
{"card_properties_modified": {
"hand": [{
"name": "flip_card",
"subject": "self",
"set_faceup": false
}],
"filter_modified_properties":
{
"Type": {}
},
"trigger": "another"}
}
The above example will trigger only if the "Type" property of another card is modified. But it does not care to what value the Type property changed.
A more advanced trigger might look like this:
{"card_properties_modified": {
"hand": [{
"name": "flip_card",
"subject": "self",
"set_faceup": false
}],
"filter_modified_properties": {
"Type": {
"new_value": "Orange",
"previous_value": "Green"
}
},
"trigger": "another"}
}
The above example will only trigger on the "Type" property changing on another card, and only if it changed from "Green" to "Orange"
const FILTER_MODIFIED_PROPERTY_NEW_VALUE: String = "new_value"
Value Type: String.
Filter used for checking against TRIGGER_NEW_PROPERTY_VALUE
const FILTER_MODIFIED_PROPERTY_PREV_VALUE: String = "previous_value"
Value Type: String.
Filter used for checking against TRIGGER_PREV_PROPERTY_VALUE
const FILTER_PROPERTIES: String = "filter_properties"
Value Type: Dictionary
Filter used for checking against the Card properties
Each value is a dictionary where the key is a card property, and the value is the desired property value to match on the filtered card.
const FILTER_SCENE_PATH: String = "filter_scene_path"
Value Type: String
Filter used for checking against KEY_SCENE_PATH
const FILTER_SOURCE: String = "filter_source"
Value Type: Dynamic.
Filter for checking against TRIGGER_SOURCE
const FILTER_STATE: String = "filter_state_"
Value Type: Array
Filter used for checking against the Card state
This is open ended to be appended, as the check can be run either against the trigger card, or the subjects card.
One of the following strings HAS to be appended at the end:
- "trigger": Will only filter cards triggering this effect via signals or cards triggering an alterant effect.
- "subject": Will only filter cards that are looked up as targets for the effect.
- "seek": Will only filter cards that are automatically sought on the board.
- "tutor": Will only filter cards that are automaticaly sought in a pile.
see check_validity()
The content of this value has to be an array of dictionaries The different elements in the array act as an "OR" check. If any of the dictionary filters matches, then the card will be considered a valid target.
Each filter dictionary has to contain at least one of the various FILTER_ Keys All the FILTER_ keys act as an "AND" check. The Dictionary filter will only match, if all the filters requested match the card's state.
This allows a very high level of flexibility in filtering exactly the cards required.
Here's a particularly complex script example that can be achieved:
"manual": {
"hand": [
{"name": "rotate_card",
"subject": "boardseek",
"subject_count": "all",
"filter_state_seek": [
{"filter_tokens": [
{"filter_token_name": "void",
"filter_token_count": 1,
"comparison": "gt"},
{"filter_token_name": "blood"}
],
"filter_properties": {"Type": "Barbarian"}},
{"filter_properties": {"Type": "Soldier"}}
],
"degrees": 90}
]
}
This example would roughly translate to the following ability: "Rotate to 90 degrees all barbarians with more than 1 void tokens and at least 1 blood token, as well as all soldiers."
const FILTER_TAGS: String = "filter_tags"
Value Type: String or Array of Strings
A number of keywords to try and match against KEY_TAGS passed by the script definition.
const FILTER_TASK: String = "filter_task"
Value Type: String
Filter used for checking against TRIGGER_TASK_NAME
const FILTER_TOKENS: String = "filter_tokens"
Value Type: Dictionary
Filter used for checking in check_state It contains a list of dictionaries, each detailing a token state that is wished on this subject. If any of them fails to match, then the whole filter fails to match.
This allows us to check for multiple tokens at once. For example: "If target has a blood and a void token..."
The below sample script, will rotate all cards which have any number of void tokens and exactly 1 bio token, 90 degrees
"manual": {
"hand": [
{"name": "rotate_card",
"subject": "boardseek",
"subject_count": "all",
"filter_state_seek": {
"filter_tokens": [
{"filter_token_name": "void"},
{"filter_token_name": "bio",
"filter_token_count": 1},
]
},
"degrees": 90}
]
}
const FILTER_TOKEN_COUNT: String = "filter_token_count"
Value Type: int.
Filter used for checking against TRIGGER_NEW_TOKEN_VALUE and in check_state
const FILTER_TOKEN_DIFFERENCE: String = "filter_token_difference"
Value Type: String
const FILTER_TOKEN_NAME: String = "filter_token_name"
Value Type: String.
Filter used for checking against TRIGGER_TOKEN_NAME and in check_state
const KEY_ALTERANTS: String = "alterants"
Value Type: Dictionary
Used in place of a trigger name (e.g. 'manual'). This key allows the card to be marked as an alterant. I.e. a card which will modify the values of other scripts or effects.
For example cards which reduce or increase costs, or cards which intensify the effect of other cards would be alterants.
The dictionary inside follows a similar format to the normal script, with the position of the card being the next key, specifying when the alterant is active, and inside that, an array of mulitple alterants to check against.
A sample alterant definition might look like this
{"alterants": {
"board": [
{"filter_task": "mod_counter",
"trigger": "another",
"filter_tags": ["PlayCost"],
"filter_counter_name": "research",
"filter_state_trigger": [{
"filter_properties": {"Type": "Science"}
}],
"alteration": -1}
]
}}
The above would roughly translate to "Whenever you are playing a Science card reduce it's research cost by 1"
The main Difference being that triggers are checked inside each individual alterant task, rather than on the whole script. This allows the same card to modify different sort of cards and triggers, in different ways.
Currently the following tasks support being altered during runtime via alterants
const KEY_ALTERATION: String = "alteration"
Value Type: int
Used by the AlterantEngine to determine by how much it should modify the currently performed task.
It can accept a VALUE_PER value which allows one to script an effect like "Increase the cost by the number of Soldiers on the table"
const KEY_ASK_INTEGER_MAX: String = "ask_int_max"
Value Type: int
Used by the ask_integer task. Specifies the maximum value the number needs to have
const KEY_ASK_INTEGER_MIN: String = "ask_int_min"
Value Type: int
Used by the ask_integer task. Specifies the minimum value the number needs to have
const KEY_BOARD_POSITION: String = "board_position"
Value Type: Vector2.
Used in the following tasks
It specfies the position of the board to place the subject or object of the task. If used in combination with KEY_SUBJECT_COUNT the task will attempt to place all subjects/objects in a way that they do not overlap.
const KEY_COMPARISON: String = "comparison"
Value Type: String. One of the below:
- "eq" (Defaut): Equal
- "ne": Not equal (This can be used to againsr strings as well)
- "gt": Greater than
- "lt": Less than
- "le": Less than or Equal
- "ge": Geater than or equal
Key is used typically to do numerical comparisons during filters involving numerical numbers.
I.e. it allows to write the script for something like: "Destroy all Monsters with cost equal or higher than 3"
const KEY_COUNTER_NAME: String = "counter_name"
Value Type: String.
Used with the mod_counter task to specify Which counter to modify with this task
const KEY_DEGREES: String = "degrees"
Value Type: int.
Used when a script is using the rotate_card task.
These are the degress in multiples of 90, that the subjects will be rotated.
const KEY_DEST_CONTAINER: String = "dest_container"
Value Type: Pile.
Used when a script is using one of the following tasks
Specifies the destination container to manipulate
const KEY_DEST_INDEX: String = "dest_index"
Value Type: Dynamic (Default = KEY_SUBJECT_INDEX_V_TOP)
Used when placing a card inside a CardContainer using the move_card_to_container task to specify which index inside the CardContainer to place the card
const KEY_EXEC_TEMP_MOD_COUNTERS: String = "exec_temp_mod_counters"
Value Type: Dictionary
This key is used in execute_scripts to temporary alter the value of a counter by a specified amount.
The value has to be a Dictionary where each key is an counter's name and the value is the modification to use on that counter.
const KEY_EXEC_TEMP_MOD_PROPERTIES: String = "exec_temp_mod_properties"
Value Type: Dictionary
This key is used in execute_scripts to temporary alter the numerical properties the target card think is has, by a specified amount.
The value has to be a Dictionary where each key is an number property's name As defined in PROPERTIES_NUMBERS and the value is the modification to use on that number
const KEY_EXEC_TRIGGER: String = "exec_trigger"
Value Type: String (Default = "manual").
This is used with the execute_scripts task to determine which execution trigger to run.
const KEY_GRID_NAME: String = "grid_name"
Value Type: String.
Used in the following tasks
For move_card_to_board
and spawn_card
, if specified,
it will take priority over KEY_BOARD_POSITION
The card will be placed to the specified grid on the board
For add_grid
, if not specified, the grid will be keep the names
defined in the scene. If specified, the node name and label
will use the provided value
This task will not check that the grid exists or that the card's mandatory grid name matches the grid name. The game has to be developed to not cause this situation.
const KEY_IS_COST: String = "is_cost"
Value Type: bool.
This key is used to mark a task as being a cost requirement before the rest of the defined tasks can execute.
If any tasks marked as costs will not be able to fulfil, then the whole script is not executed.
Currently the following tasks support being set as costs:
const KEY_IS_OPTIONAL: String = "is_optional_"
Value Type: bool (Default = false)
Specifies whether this script or task can be skipped by the owner.
This value needs to be prepended and placed depending on what it is making optional
If it is making a sigle task optional, you need to add "task" at the end and place it inside a task definition Example:
"manual": {
"board": [
{"name": "rotate_card",
"is_optional_task": true,
"subject": "self",
"degrees": 90},
]}
If you want to make a whole script optional, then you need to place it on the same level as the state and append the state name Example:
"card_flipped": {
"is_optional_board": true,
"board": [
{"name": "rotate_card",
"is_cost": true,
"subject": "self",
"degrees": 90}
]}
When set to true, a confirmation window will appear to the player when this script/task is about to execute.
At the task level, it will ask the player before activating that task only If that task is a cost, it will also prevent subsequent tasks from firing
At the script level, the whole script if cancelled.
const KEY_MODIFICATION: String = "modification"
Value Type: Dynamic
Used when a script is using one of the following tasks:
It specifies the amount we're setting/modifying or setting it to the exact one
const KEY_MODIFY_PROPERTIES: String = "set_properties"
Value Type: bool.
Used when a script is using the modify_properties task.
The value is supposed to be a dictionary of "property name": value
entries
const KEY_OBJECT_COUNT: String = "object_count"
Used in conjunction with the following tasks
specified how many of the "thing" done by the task, to perform.
const KEY_PER_BOARDSEEK: String = "per_boardseek"
Value Type: Dictionary
A VALUE_PER key for perfoming an effect equal the number of cards on the board matching a filter.
Typically the KEY_SUBJECT_COUNT inside this dictionary would be set to KEY_SUBJECT_COUNT_V_ALL, but a FILTER_STATE should also be typically specified
const KEY_PER_COUNTER: String = "per_counter"
Value Type: Dictionary
A VALUE_PER key for perfoming an effect equal to the value of a counter.
const KEY_PER_PROPERTY: String = "per_property"
Value Type: Dictionary
A VALUE_PER key for perfoming an effect equal to a accumulated property on the subject(s)
Other than the subject defintions the KEY_PROPERTY_NAME has to also be provided. Obviously, the property specified has to be a number.
const KEY_PER_TOKEN: String = "per_token"
Value Type: Dictionary
A VALUE_PER key for perfoming an effect equal to a number of tokens on the subject(s)
Other than the subject defintions the KEY_TOKEN_NAME has to also be provided
const KEY_PER_TUTOR: String = "per_tutor"
Value Type: Dictionary
A VALUE_PER key for perfoming an effect equal to a number of cards in pile matching a filter.
Typically the KEY_SUBJECT_COUNT inside this dictionary would be set to KEY_SUBJECT_COUNT_V_ALL, but a FILTER_STATE should also be typically specified
const KEY_PROPERTY_NAME: String = "property_name"
Value Type: String
This key is typically needed in combination with KEY_PER_PROPERTY to specify which property to base the per upon. The property has to be a number.
const KEY_REQUIRE_EXEC_STATE: String = "require_exec_state"
Value Type: String
This is used with the execute_scripts task to limit execution, only to cards in the right state ("board","hand" or "pile)
If this is not defined, it will execute the specified exec_trigger of the state the card is currently in, if any exists for it.
const KEY_SCENE_PATH: String = "scene_path"
Value Type: String
Used in conjunction with the following tasks
This is the path to the scene we will add to the game.
const KEY_SET_FACEUP: String = "set_faceup"
Value Type: bool.
- true: The card will be set face-up
- false: The card will be set face-down
Used when a script is using the flip_card task.
const KEY_SET_TO_MOD: String = "set_to_mod"
Value Type: bool (Default = false).
Used when a script is using one of the following tasks:
It specifies if we're modifying the existing amount or setting it to the exact one
const KEY_SRC_CONTAINER: String = "src_container"
Value Type: Pile.
Used when a script is using one of the following tasks
When the following KEY_SUBJECT values are also used:
Specifies the source container to pick the card from
const KEY_SUBJECT: String = "subject"
Value Type: String
- KEY_SUBJECT_V_TARGET
- KEY_SUBJECT_V_SELF
- KEY_SUBJECT_V_BOARDSEEK
- KEY_SUBJECT_V_TUTOR
- KEY_SUBJECT_V_PREVIOUS
Determines which card, if any, this script will try to affect.
If key does not exist, we set value to [], assuming there's no subjects in the task.
const KEY_SUBJECT_COUNT: String = "subject_count"
Value Type: Dynamic (Default = 1)
Used when we're seeking a card to limit the amount to retrieve to this amount Works with the following tasks and KEY_SUBJECT values:
const KEY_SUBJECT_COUNT_V_ALL: String = "all"
When specified as the value of KEY_SUBJECT_COUNT, will retrieve as many cards as match the criteria.
Useful with the following VALUES:
const KEY_SUBJECT_INDEX: String = "subject_index"
Value Options (Default = 0):
Used when we're seeking a card inside a CardContainer in one of the following tasks
Default is to seek card at index 0
const KEY_SUBJECT_INDEX_V_BOTTOM: String = "bottom"
Special entry to be used with KEY_SUBJECT_INDEX instead of an integer.
If specified, explicitly looks for the "bottom" card of a pile
const KEY_SUBJECT_INDEX_V_RANDOM: String = "random"
Special entry to be used with KEY_SUBJECT_INDEX instead of an integer.
If specified, picks a random index in the container
const KEY_SUBJECT_INDEX_V_TOP: String = "top"
Special entry to be used with KEY_SUBJECT_INDEX instead of an integer.
If specified, explicitly looks for the top "card" of a pile
const KEY_SUBJECT_V_BOARDSEEK: String = "boardseek"
If this is the value of the KEY_SUBJECT key, then we search all cards on the table by node order, and return candidates equal to KEY_SUBJECT_COUNT that match the filters.
This allows us to make tasks which will affect more than 1 card at the same time (e.g. "All Soldiers")
const KEY_SUBJECT_V_INDEX: String = "index"
If this is the value of the KEY_SUBJECT key, then we pick the card on the specified source pile by its index among other cards.
const KEY_SUBJECT_V_PREVIOUS: String = "previous"
If this is the value of the KEY_SUBJECT key, then we use the subject specified in the previous task
const KEY_SUBJECT_V_SELF: String = "self"
If this is the value of the KEY_SUBJECT key, then the task affects the owner card only.
const KEY_SUBJECT_V_TARGET: String = "target"
If this is the value of the KEY_SUBJECT key, we initiate targetting from the owner card
const KEY_SUBJECT_V_TRIGGER: String = "trigger"
This is only used during alterant scripts using the KEY_PER
If this is the value of the KEY_SUBJECT key, Then the script will count the properties of the trigger card only.
const KEY_SUBJECT_V_TUTOR: String = "tutor"
If this is the value of the KEY_SUBJECT key, then we search all cards on the specified pile by node order, and pick the first candidate that matches the filter
const KEY_TAGS: String = "tags"
Value Type: Array of Strings
A number of keywords you can assign to your script, which details what function it is serving. These can be hooked one by the AlterantEngine to figure out if this script effects should be altered.
A script has to have all the tags an alterant is looking for before it will be considered to be altered.
const KEY_TOKEN_NAME: String = "token_name"
Value Type: String (Default = 1).
Used when a script is using the mod_tokens task.
It specifies the name of the token we're modifying
const KEY_TRIGGER: String = "trigger"
const TRIGGER_COUNTER_NAME: String = "counter_name"
Value Type: String.
Filter value sent by the Counters trigger counter_modified
signal.
as well as via the mod_counters alterant script
This is the value of the token name modified
const TRIGGER_DEGREES: String = "degrees"
Value Type: int.
Filter value sent by the Card trigger card_rotated
signal.
These are the degress in multiples of 90, that the subjects was rotated.
const TRIGGER_DESTINATION: String = "destination"
Value Type: Dynamic.
Filter value sent by one of the trigger Card's following signals:
- card_moved_to_board
- card_moved_to_pile
- card_moved_to_hand The value will be the node name the Card moved to
const TRIGGER_FACEUP: String = "is_faceup"
Value Type: bool.
Filter value sent by the Card trigger card_flipped
signal.
This is the facing of trigger.
- true: Trigger turned face-up
- false: Trigger turned face-down
const TRIGGER_HOST: String = "host"
Value Type: Card.
Filter value sent by the following signals.
- card_attached
- card_unattached It contains the host object onto which this card attached or from which it unattached
const TRIGGER_MODIFIED_PROPERTY_NAME: String = "property_name"
Value Type: String.
Filter value sent by the Card trigger card_properties_modified
signal.
This is the property name
const TRIGGER_NEW_PROPERTY_VALUE: String = "new_property_value"
Value Type: String.
Filter value sent by the Card trigger card_properties_modified
signal.
This is the current value of the property.
const TRIGGER_NEW_TOKEN_VALUE: String = "new_token_value"
Value Type: int.
Filter value sent by the Card trigger card_token_modified
signal.
This is the current value of the token. If token was removed value will be 0
const TRIGGER_PREV_PROPERTY_VALUE: String = "previous_property_value"
Value Type: String.
Filter value sent by the Card trigger card_properties_modified
signal.
This is the value the property had before it was modified
const TRIGGER_PREV_TOKEN_VALUE: String = "previous_token_value"
Value Type: int.
Filter value sent by the Card trigger card_token_modified
signal.
This is the value the token had before it was modified If token was removed value will be 0
const TRIGGER_SOURCE: String = "source"
Value Type: Dynamic.
Filter value sent by one of the trigger Card's following signals:
- card_moved_to_board
- card_moved_to_pile
- card_moved_to_hand The value will be the node name the Card left
const TRIGGER_TASK_NAME: String = "task_name"
Sent to the AlterantEngine by a task which allows alterations, which allows a alterant cards to filter on whether to modify this value. See FILTER_TASK.
const TRIGGER_TOKEN_NAME: String = "token_name"
Value Type: String.
Filter value sent by the Card trigger card_token_modified
signal.
as well as via the mod_tokens alterant script
This is the value of the token name modified
const TRIGGER_V_TOKENS_DECREASED: String = "decreased"
Value is sent by trigger when new token count is lower than old token count. Compared against FILTER_TOKEN_DIFFERENCE
const TRIGGER_V_TOKENS_INCREASED: String = "increased"
Value is sent by trigger when new token count is higher than old token count. Compared against FILTER_TOKEN_DIFFERENCE
const VALUE_PER: String = "per_"
This is a versatile value that can be inserted into any various keys when a task needs to calculate the amount of subjects to look for or the number of things to do, based on the state of the board at that point in time. The value has to be appended with the type of seek to do to determine the amount. The full value has to match one of the following keys:
When this value is set, the relevant key must also exist in the Script definition. They key shall contain a dictionary which will Specify the subjects as well as the things to count.
Inside the per_ key, you again have to specify KEY_SUBJECT lookup which is relevant for the per search.
This allows us to calculate the effects of card scripts during runtime. For a complex example:
{"manual":
{"hand": [
{"name": "move_card_to_container",
"subject": "index",
"subject_count": "per_boardseek",
"src_container": deck,
"dest_container": hand,
"subject_index": "top",
"per_boardseek": {
"subject": "boardseek",
"subject_count": "all",
"filter_state_seek": [
{"filter_properties": {
"Power": 0}
}
]
}}
]}
}
The above example can be tranlated to: "Draw 1 card for each card with 0 power on the board"
const VALUE_RETRIEVE_INTEGER: String = "retrieve_integer"
This is a versatile value that can be inserted into any various keys when a task needs to use a previously inputed integer provided with a ask_integer task. When detected ,the task will retrieve the stored number and use it as specified
The following keys support this value
- KEY_MODIFICATION
- KEY_SUBJECT_COUNT (only for specific tasks, see documentation)
- KEY_OBJECT_COUNT (only for specific tasks, see documentation)
func get_default(property: String)
Returns the default value any script definition key should have
func filter_trigger(card_scripts, trigger_card, owner_card, trigger_details) -> bool
func check_properties(card, property_filters: Dictionary) -> bool
Returns true if the card properties match against filters specified in the provided card_scripts or if no card property filters were defined. Otherwise returns false.
func check_token_filter(card, token_states: Array) -> bool
Returns true if the card tokens match against filters specified in the provided card_scripts, of if no token filters were requested. Otherwise returns false.
func check_rotation_filter(card, rotation_state: int) -> bool
Returns true if the rotation of the card matches the specified filter or the filter key was not defined. Otherwise returns false.
func check_faceup_filter(card, flip_state: bool) -> bool
Returns true if the faceup state of the card matches the specified filter or the filter key was not defined. Otherwise returns false.
func check_validity(card, card_scripts, type: String = "trigger") -> bool
Check if the card is a valid subject or trigger, according to its state.