Skip to content
Divided by Zer0 edited this page Dec 27, 2020 · 63 revisions

SP

Extends: Reference

Description

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

Constants Descriptions

FILTER_DEGREES

const FILTER_DEGREES: String = "filter_degrees"

Value Type: int.

Filter used in for checking against TRIGGER_DEGREES

FILTER_DESTINATION

const FILTER_DESTINATION: String = "filter_destination"

Value Type: Dynamic.

Filter for checking against TRIGGER_DESTINATION

FILTER_FACEUP

const FILTER_FACEUP: String = "filter_faceup"

Value Type: bool.

Filter for checking against TRIGGER_FACEUP

FILTER_MODIFIED_PROPERTIES

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"

FILTER_MODIFIED_PROPERTY_NEW_VALUE

const FILTER_MODIFIED_PROPERTY_NEW_VALUE: String = "new_value"

Value Type: String.

Filter used for checking against TRIGGER_NEW_PROPERTY_VALUE

FILTER_MODIFIED_PROPERTY_PREV_VALUE

const FILTER_MODIFIED_PROPERTY_PREV_VALUE: String = "previous_value"

Value Type: String.

Filter used for checking against TRIGGER_PREV_PROPERTY_VALUE

FILTER_PROPERTIES

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.

FILTER_SOURCE

const FILTER_SOURCE: String = "filter_source"

Value Type: Dynamic.

Filter for checking against TRIGGER_SOURCE

FILTER_STATE

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.
  • "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."

FILTER_TOKENS

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}
	]
}

FILTER_TOKEN_COUNT

const FILTER_TOKEN_COUNT: String = "filter_token_count"

Value Type: int.

Filter used for checking against TRIGGER_NEW_TOKEN_VALUE and in check_state

FILTER_TOKEN_DIFFERENCE

const FILTER_TOKEN_DIFFERENCE: String = "filter_token_difference"

Value Type: String

FILTER_TOKEN_NAME

const FILTER_TOKEN_NAME: String = "filter_token_name"

Value Type: String.

Filter used for checking against TRIGGER_TOKEN_NAME and in check_state

KEY_ASK_INTEGER_MAX

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

KEY_ASK_INTEGER_MIN

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

KEY_BOARD_POSITION

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.

KEY_COMPARISON

const KEY_COMPARISON: String = "comparison"

Value Type: String

  • "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"

KEY_DEGREES

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.

KEY_DEST_CONTAINER

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

KEY_DEST_INDEX

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

KEY_GRID_NAME

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.

KEY_IS_COST

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:

KEY_IS_OPTIONAL

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.

KEY_MODIFICATION

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

KEY_MODIFY_PROPERTIES

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

KEY_OBJECT_COUNT

const KEY_OBJECT_COUNT: String = "object_count"

Value Type: Dynamic (Default = 1).

Used in conjunction with the following tasks

specified how many of the "thing" done by the task, to perform.

KEY_PER

const KEY_PER: String = "per"

KEY_SCENE_PATH

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.

KEY_SET_FACEUP

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.

KEY_SET_TO_MOD

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

KEY_SRC_CONTAINER

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

KEY_SUBJECT

const KEY_SUBJECT: String = "subject"

Value Type: String

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.

KEY_SUBJECT_COUNT

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:

KEY_SUBJECT_COUNT_V_ALL

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:

KEY_SUBJECT_INDEX

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

KEY_SUBJECT_INDEX_V_BOTTOM

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

KEY_SUBJECT_INDEX_V_TOP

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

KEY_SUBJECT_V_BOARDSEEK

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")

KEY_SUBJECT_V_INDEX

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.

KEY_SUBJECT_V_PREVIOUS

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

KEY_SUBJECT_V_SELF

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.

KEY_SUBJECT_V_TARGET

const KEY_SUBJECT_V_TARGET: String = "target"
  • If this is the value of the KEY_SUBJECT key, we initiate targetting from the owner card

KEY_SUBJECT_V_TUTOR

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

KEY_TOKEN_NAME

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

KEY_TRIGGER

const KEY_TRIGGER: String = "trigger"

TRIGGER_DEGREES

const TRIGGER_DEGREES: String = "degrees"

Value Type: int.

Filter value sent by the trigger Card card_rotated signal.

These are the degress in multiples of 90, that the subjects was rotated.

TRIGGER_DESTINATION

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

TRIGGER_FACEUP

const TRIGGER_FACEUP: String = "is_faceup"

Value Type: bool.

Filter value sent by the trigger Card card_flipped signal.

This is the facing of trigger.

  • true: Trigger turned face-up
  • false: Trigger turned face-down

TRIGGER_HOST

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

TRIGGER_MODIFIED_PROPERTY_NAME

const TRIGGER_MODIFIED_PROPERTY_NAME: String = "property_name"

Value Type: String.

Filter value sent by the trigger card_properties_modified signal.

This is the property name

TRIGGER_NEW_PROPERTY_VALUE

const TRIGGER_NEW_PROPERTY_VALUE: String = "new_property_value"

Value Type: String.

Filter value sent by the trigger card_properties_modified signal.

This is the current value of the property.

TRIGGER_NEW_TOKEN_VALUE

const TRIGGER_NEW_TOKEN_VALUE: String = "new_token_value"

Value Type: int.

Filter value sent by the trigger Card card_token_modified signal.

This is the current value of the token. If token was removed value will be 0

TRIGGER_PREV_PROPERTY_VALUE

const TRIGGER_PREV_PROPERTY_VALUE: String = "previous_property_value"

Value Type: String.

Filter value sent by the trigger card_properties_modified signal.

This is the value the property had before it was modified

TRIGGER_PREV_TOKEN_VALUE

const TRIGGER_PREV_TOKEN_VALUE: String = "previous_token_value"

Value Type: int.

Filter value sent by the trigger Card card_token_modified signal.

This is the value the token had before it was modified If token was removed value will be 0

TRIGGER_SOURCE

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

TRIGGER_TOKEN_NAME

const TRIGGER_TOKEN_NAME: String = "token_name"

Value Type: String.

Filter value sent by the trigger Card card_token_modified signal.

This is the value of the token name modified

TRIGGER_V_TOKENS_DECREASED

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

TRIGGER_V_TOKENS_INCREASED

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

VALUE_RETRIEVE_INTEGER

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

Method Descriptions

get_default (static)

func get_default(property: String)

Returns the default value any script definition key should have

filter_trigger (static)

func filter_trigger(card_scripts, trigger_card, owner_card, signal_details) -> bool

check_properties (static)

func check_properties(card, property_filters) -> 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.

check_token_filter (static)

func check_token_filter(card, token_states) -> 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.

check_rotation_filter (static)

func check_rotation_filter(card, rotation_state) -> bool

Returns true if the rotation of the card matches the specified filter or the filter key was not defined. Otherwise returns false.

check_faceup_filter (static)

func check_faceup_filter(card, flip_state) -> bool

Returns true if the faceup state of the card matches the specified filter or the filter key was not defined. Otherwise returns false.

check_validity (static)

func check_validity(card, card_scripts, type: String = "trigger") -> bool

Check if the card is a valid subject or trigger, according to its state.

Clone this wiki locally