Skip to content

ScriptingEngine

Divided by Zer0 edited this page Feb 6, 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

Method Descriptions

_init

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

Simply initiates the run_next_script() loop

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

shuffle_container

func shuffle_container(script: ScriptTask) -> void

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

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.

Signals

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