-
-
Notifications
You must be signed in to change notification settings - Fork 100
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 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.
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 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
Stores the inputed integer from the ask_integer task
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
func _init(card_owner: Card, scripts_queue: Array, check_costs: bool = false) -> void
Sets the owner of this Scripting Engine
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.
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 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:
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:
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_SCENE_PATH: path to a [CardTemplate] .tscn file
- One of the following:
- Optionally uses the following keys:
- KEY_OBJECT_COUNT: int
func shuffle_container(script: ScriptTask) -> void
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) -> int
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) -> int
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) -> void
Task for executing scripts on subject cards
- Requires the following keys:
- Optionally uses the following keys:
- signal tasks_completed(): Emitted when all tasks have been run succesfully