-
-
Notifications
You must be signed in to change notification settings - Fork 106
Counters
Extends: Control
This class contains the methods needed to manipulate counters in a game
It is meant to be extended and attached to a customized scene.
In the extended script, the various values should be filled during the _ready() method
var counters: Dictionary
Hold the actual values of the various counters requested
var needed_counters: Dictionary
Hold the actual values of the various counters requested Holds the label nodes which display the counter values to the user Each entry in this dictionary will specify one counter to be added The key will be the name of the node holding the counter The value is a dictionary where each key is a label node path relative to the counter_scene and each value, is the text value for the label
var temp_count_modifiers: Dictionary
Hold the actual values of the various counters requested Holds the label nodes which display the counter values to the user Each entry in this dictionary will specify one counter to be added The key will be the name of the node holding the counter The value is a dictionary where each key is a label node path relative to the counter_scene and each value, is the text value for the label This hold modifiers to counters that will be only active temporarily.
Typically only used during an [execute_scripts()](ScriptingEngine#execute_scripts] task.
Each key is a ScriptingEngine reference, and each value is a dictionary With the following keys:
- requesting_card: The card object which has requested this temp modifier
- modifer: A dictionary with all the modifications requested by this card Each key is a counter name, and value is the temp modifier requested for this counter
This allows multiple modifiers may be active at the same time, even from nested tasks on the same card during an execute_scripts task.
export var counter_scene = "[Object:null]"
Holds the counter scene which has been created by the developer
var counters_container: Container
This variable should hold the path to the Control container Which will hold the counter objects.
It should be set in the _ready() function of the script which extends this class
var value_node: String
This variable should hold the path to the Control container Which will hold the counter objects.
It should be set in the _ready() function of the script which extends this class This variable should hold which needed_counters dictionary key is the path to the label which holds the values for the counter
It should be set in the _ready() function of the script which extends this class
func spawn_needed_counters() -> Array
This function should be called by the _ready() function of the script which extends thic class, after it has set all the necessary variables.
It creates and initiates all the necessary counters required by this game.
func mod_counter(counter_name: String, value: int, set_to_mod: bool = false, check: bool = false, requesting_object = null, tags: Array = "Manual") -> int
Modifies the value of a counter. The counter has to have been specified
in the needed_counters
- Returns CFConst.ReturnCode.CHANGED if a modification happened
- Returns CFConst.ReturnCode.OK if the modification requested is already the case
- Returns CFConst.ReturnCode.FAILED if for any reason the modification cannot happen
If check is true, no changes will be made, but will return the appropriate return code, according to what would have happened
If set_to_mod is true, then the counter will be set to exactly the value requested. otherwise the value will be modified from the current value
func get_counter(counter_name: String, requesting_object = null) -> int
Returns the value of the specified counter. Takes into account temp_count_modifiers and alterants
func get_counter_and_alterants(counter_name: String, requesting_object = null) -> var
Discovers the modified value of the specified counter based on temp_count_modifiers and alterants.
Returns a dictionary with the following keys:
- count: The final value of this counter after all modifications
- alteration: The full dictionary returned by CFScriptUtils.get_altered_value() but including details about
- temp_modifiers: A custom dictionary, following the format of the alteration dictionary, but holding modifications done by temp_count_modifiers temp_count_modifiers
- signal counter_modified(card, trigger, details):