Skip to content

ScriptingEngine

Divided by Zer0 edited this page Jan 3, 2021 · 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

costs_dry_run

var 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.

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

Stores the inputed integer from the ask_integer task

wait_for_tasks

var wait_for_tasks

These task will require input from the player, so the subsequent task execution needs to wait for their completion

This variable can be extended when this class is extended with new tasks

Method Descriptions

_init

func _init(card_owner: Card, scripts_queue: Array, check_costs: bool = false) -> void

Sets the owner of this Scripting Engine

run_next_script

func run_next_script(card_owner: Card, scripts_queue: Array, prev_subjects: Array) -> var

The main engine starts here. It receives array with all the scripts 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

Supports KEY_IS_COST.

Requires the following keys:

flip_card

func flip_card(script: ScriptTask) -> int

Task for flipping cards

Supports KEY_IS_COST.

Requires the following keys:

move_card_to_container

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:

move_card_to_board

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

mod_tokens

func mod_tokens(script: ScriptTask) -> int

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:

spawn_card

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:

Optionally uses the following keys:

shuffle_container

func shuffle_container(script: ScriptTask) -> void

Task from shuffling a CardContainer

Requires the following keys:

attach_to_card

func attach_to_card(script: ScriptTask) -> void

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

Requires the following keys:

host_card

func host_card(script: ScriptTask) -> void

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

Requires the following keys:

modify_properties

func modify_properties(script: ScriptTask) -> int

Task for modifying a card's properties

Requires the following keys:

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

Requires the following keys:

Optionally uses the following keys:

mod_counter

func mod_counter(script: ScriptTask) -> int

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

Task for executing scripts on subject cards

Requires the following keys:

Optionally uses the following keys:

Signals

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