Skip to content

CFUtils

Divided by Zer0 edited this page Mar 9, 2022 · 12 revisions

CFUtils

Extends: Reference

Description

Card Gaming Framework Utilities

This is a library of static functions.

Method Descriptions

shuffle_array (static)

func shuffle_array(array: Array) -> void

Randomize array through our own seed

randi (static)

func randi() -> int

Mapping randi function

randf (static)

func randf() -> float

Mapping randf function

randi_range (static)

func randi_range(from: int, to: int) -> int

Mapping randi_range function

randf_range (static)

func randf_range(from: float, to: float) -> float

Mapping randf_range function

rand_bool (static)

func rand_bool() -> bool

Returns a random boolean

compare_floats (static)

func compare_floats(a, b, epsilon = 0.001)

Compares two floats within a threshold value

array_join (static)

func array_join(arr: Array, separator = "") -> String

Returns a string of all elements in the array, separared by the provided separator

list_files_in_directory (static)

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

list_imported_in_directory (static)

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.

confirm (static)

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.

sort_index_ascending (static)

func sort_index_ascending(c1, c2) -> bool

Used with sort_custom to find the highest child index among multiple cards

sort_card_containers (static)

func sort_card_containers(c1, c2) -> bool

Used with sort_custom to find the highest child index among multiple cards

sort_by_card_field (static)

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.

sort_by_shift_priority (static)

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

sort_scriptables_by_name (static)

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

generate_random_seed (static)

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.

compare_numbers (static)

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

compare_strings (static)

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

get_unique_values (static)

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

convert_texture_to_image (static)

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.

Clone this wiki locally