Skip to content

ScriptingEngine

Divided by Zer0 edited this page Mar 9, 2022 · 52 revisions

ScriptingEngine

Extends: Reference

Description

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.

Property Descriptions

run_type

var run_type: int

can_all_costs_be_paid

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.

all_tasks_completed

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.

stored_integer

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

scripts_queue

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

Method Descriptions

_init

func _init(state_scripts: Array, owner, trigger_object: Node, trigger_details: Dictionary) -> void

Simply initiates the run_next_script() loop

costs_dry_run

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.

execute

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.

rotate_card

func rotate_card(script: ScriptTask) -> int

Task for rotating cards

flip_card

func flip_card(script: ScriptTask) -> int

Task for flipping cards

view_card

func view_card(script: ScriptTask) -> int

Task for viewing face-down cards

move_card_to_container

func move_card_to_container(script: ScriptTask) -> var

Task for moving card to a CardContainer

move_card_to_board

func move_card_to_board(script: ScriptTask) -> var

Task for playing a card to the board directly.

mod_tokens

func mod_tokens(script: ScriptTask) -> var

Task from modifying tokens on a card

spawn_card

func spawn_card(script: ScriptTask) -> var

Task from creating a new card instance on the board

spawn_card_to_container

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:
    • KEY_DEST_CONTAINER: The container in which to place the created card
  • Optionally uses the following keys:

shuffle_container

func shuffle_container(script: ScriptTask) -> var

Task from shuffling a CardContainer

attach_to_card

func attach_to_card(script: ScriptTask) -> void

Task from making the owner card an attachment to the subject card.

host_card

func host_card(script: ScriptTask) -> void

Task from making the subject card an attachment to the owner card.

modify_properties

func modify_properties(script: ScriptTask) -> var

Task for modifying a card's properties

ask_integer

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

add_grid

func add_grid(script: ScriptTask) -> var

Adds a specified BoardPlacementGrid scene to the board at the specified position

mod_counter

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

execute_scripts

func execute_scripts(script: ScriptTask) -> var

Task for executing scripts on subject cards.

nested_script

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

null_script

func null_script(script: ScriptTask) -> int

Does nothing. Useful for selecting subjects to pass to further filters etc. warning-ignore:unused_argument

Signals

  • signal tasks_completed(): Emitted when all tasks have been run succesfully
Clone this wiki locally