-
-
Notifications
You must be signed in to change notification settings - Fork 101
CFUtils
Extends: Reference
Card Gaming Framework Utilities
This is a library of static functions.
func shuffle_array(array: Array) -> void
Randomize array through our own seed
func randi() -> int
Mapping randi function
func randf() -> float
Mapping randf function
func randi_range(from: int, to: int) -> int
Mapping randi_range function
func randf_range(from: float, to: float) -> float
Mapping randf_range function
func rand_bool() -> bool
Returns a random boolean
func compare_floats(a, b, epsilon = 0.001)
Compares two floats within a threshold value
func array_join(arr: Array, separator = "") -> String
Returns a string of all elements in the array, separared by the provided separator
func list_files_in_directory(path: String, prepend_needed: String = "", full_path: bool = false) -> Array
Returns a an array of all files in a specific directory. If a prepend_needed String is passed, only returns files which start with that string.
NOTE: This will not work for images when exported. use list_imported_in_directory() instead
func list_imported_in_directory(path: String) -> Array
Returns a an array of all images in a specific directory.
Due to the way Godot exports work, we cannot look for image Files. Instead we have to explicitly look for their .import filenames, and grab the filename from there.
func confirm(script: Dictionary, card_name: String, task_name: String, type: String = "task") -> var
Creates a ConfirmationDialog for the player to approve the Use of an optional script or task.
func sort_index_ascending(c1, c2) -> bool
Used with sort_custom to find the highest child index among multiple cards
func sort_card_containers(c1, c2) -> bool
Used with sort_custom to find the highest child index among multiple cards
func sort_by_card_field(c1, c2) -> bool
Used with sort_custom sort cards according to properties or tokens Expects a list of dictionaries. Each dictionary has two keys
- card: The card object
- value: The value being compared.
func sort_by_shift_priority(c1, c2) -> bool
Returns an array of CardContainers sorted reverse order of whichever has to be shifted first to resolve duplicate anchor placement
func sort_scriptables_by_name(c1, c2) -> bool
Sorts scriptable objects by their canonical names all noes in the list need to have a "canonical_name" property
func generate_random_seed() -> String
Generates a random 10-char string to serve as a seed for a game. This allows the seed to be viewed and shared for the same game to be replayed.
func compare_numbers(n1: int, n2: int, comparison_type: String) -> bool
Compares two numbers based on a comparison type The comparison type is one of the following
- "eq": Equal
- "ne": Not Equal
- "gt": Greater than
- "lt": Less than
- "le": Less than or Equal
- "ge": Geater than or equal
The perspective is always from the perspetive of n1 I.e. n1 = 1, n2 = 2 and comparison_type = "gt" is equal to: 1 > 2
func compare_strings(s1: String, s2: String, comparison_type: String) -> bool
Compares two strings based on a comparison type The comparison type is one of the following
- "eq": Equal
- "ne": Not Equal
func get_unique_values(property: String) -> Array
Calculates all unique values of one card property, among all card definitions
Returns an array with all the unique values
func convert_texture_to_image(texture, is_lossless = false) -> ImageTexture
Converts a resource path to a texture, or a StreamTexture object
(which you get with preload()
)
into an ImageTexture you can assign to a node's texture property.