-
-
Notifications
You must be signed in to change notification settings - Fork 102
ScriptingEngine
Extends: Reference
This class contains all the functionality required to perform full rules enforcement on any card.
The automation is based on ScriptTasks. Each such "task" performs a very specific manipulation of the board state, based on using existing functions in the object manipulated. Therefore each task function effectively provides a text-based API.
This class is loaded by each card invidually during execution.
var run_type: int
var can_all_costs_be_paid: bool
This is set to true whenever we're doing a cost dry-run and any task marked "is_cost" will not be able to manipulate the game state as required, either because the board is already at the requested state, or because something prevents it.
var all_tasks_completed: bool
This is set to true whenever we're doing a cost dry-run
and any task marked "is_cost" will not be able to manipulate the
game state as required, either because the board is already at the
requested state, or because something prevents it.
This is checked by the yield in Card execute_scripts()
to know when the cost dry-run has completed, so that it can
check the state of can_all_costs_be_paid
.
var stored_integer: int
This is set to true whenever we're doing a cost dry-run
and any task marked "is_cost" will not be able to manipulate the
game state as required, either because the board is already at the
requested state, or because something prevents it.
This is checked by the yield in Card execute_scripts()
to know when the cost dry-run has completed, so that it can
check the state of can_all_costs_be_paid
.
Stores the inputed integer from the ask_integer task
var scripts_queue: Array
This is set to true whenever we're doing a cost dry-run
and any task marked "is_cost" will not be able to manipulate the
game state as required, either because the board is already at the
requested state, or because something prevents it.
This is checked by the yield in Card execute_scripts()
to know when the cost dry-run has completed, so that it can
check the state of can_all_costs_be_paid
.
Stores the inputed integer from the ask_integer task
func _init(state_scripts: Array, owner, trigger_object: Node, trigger_details: Dictionary) -> void
Simply initiates the run_next_script() loop
func costs_dry_run() -> bool
This flag will be true if we're attempting to find if the card has costs that need to be paid, before the effects take place.
func execute(_run_type) -> var
The main engine starts here. It receives array with all the tasks to execute, then turns each array element into a ScriptTask object and send it to the appropriate tasks.
func rotate_card(script: ScriptTask) -> int
Task for rotating cards
- Supports KEY_IS_COST.
- Requires the following keys:
func flip_card(script: ScriptTask) -> int
Task for flipping cards
- Supports KEY_IS_COST.
- Requires the following keys:
func view_card(script: ScriptTask) -> int
Task for viewing face-down cards
- Requires the following keys:
func move_card_to_container(script: ScriptTask) -> var
Task for moving card to a CardContainer
- Supports KEY_IS_COST.
- Requires the following keys:
- Optionally uses the following keys:
func move_card_to_board(script: ScriptTask) -> var
Task for playing a card to the board directly.
- Supports KEY_IS_COST.
- Requires the following keys
- KEY_SUBJECT
- One of the following:
- Optionally uses the following keys:
func mod_tokens(script: ScriptTask) -> var
Task from modifying tokens on a card
- Supports KEY_IS_COST.
- Can be affected by Alterants.
- Requires the following keys:
- Optionally uses the following keys:
func spawn_card(script: ScriptTask) -> var
Task from creating a new card instance on the board
- Can be affected by Alterants
- Requires the following keys:
- KEY_CARD_NAME: name of the Card as per card definitions
- One of the following:
- Optionally uses the following keys:
func spawn_card_to_container(script: ScriptTask) -> var
Task from creating a new card instance in a CardContainer
- Can be affected by Alterants
- Requires the following keys:
- One of the following:
- KEY_CARD_NAME: name of the Card as per card definitions
-
KEY_CARD_FILTERS: A dictionary to pass to CardFilter to filter possible cards from the card pool
if KEY_CARD_FILTERS is specified then the following key has to also be specified:
- if KEY_SELECTION_CHOICES_AMOUNT: How to select cards based on the specified filters
- KEY_DEST_CONTAINER: The container in which to place the created card
- One of the following:
- Optionally uses the following keys:
func shuffle_container(script: ScriptTask) -> var
Task from shuffling a CardContainer
- Requires the following keys:
func attach_to_card(script: ScriptTask) -> void
Task from making the owner card an attachment to the subject card.
- Requires the following keys:
func host_card(script: ScriptTask) -> void
Task from making the subject card an attachment to the owner card.
- Requires the following keys:
func modify_properties(script: ScriptTask) -> var
Task for modifying a card's properties
- Requires the following keys:
func ask_integer(script: ScriptTask) -> var
Requests the player input an integer, then stores it in a script-global variable to be used by any subsequent task
- Requires the following keys:
func add_grid(script: ScriptTask) -> var
Adds a specified BoardPlacementGrid scene to the board at the specified position
- Requires the following keys:
- KEY_SCENE_PATH: path to BoardPlacementGrid .tscn file
- One of the following:
- Optionally uses the following keys:
func mod_counter(script: ScriptTask) -> var
Task for modifying a a counter. If this task is specified, the variable counters has to be set inside the board script
- Supports KEY_IS_COST.
- Can be affected by Alterants
- Requires the following keys:
- Optionally uses the following keys:
func execute_scripts(script: ScriptTask) -> var
Task for executing scripts on subject cards.
- Supports KEY_IS_COST. If it is set, the cost check will fail, if any of the target card's cost checks also fail.
- Requires the following keys:
- Optionally uses the following keys:
func nested_script(script: ScriptTask) -> var
Task for executing nested tasks This task will execute internal non-cost cripts accordin to its own nested cost instructions. Therefore if you set this task as a cost, it will modify the board, even if other costs of this script could not be paid. You can use SP.KEY_ABORT_ON_COST_FAILURE to control this behaviour better
func null_script(script: ScriptTask) -> int
Does nothing. Useful for selecting subjects to pass to further filters etc. warning-ignore:unused_argument
- signal tasks_completed(): Emitted when all tasks have been run succesfully