adds some documentation

This commit is contained in:
Nathan Singer 2025-04-24 18:43:26 -04:00
parent fe38fc49bf
commit b82f5e4c19

View File

@ -16,17 +16,24 @@ func _cache_error(err: String) -> String:
return "CACHE::ERROR::" + err + "\n"
func get_card_data_from_name(_name: String) -> Dictionary:
return _get_card_data_from_bulk("name", _name)
func _get_dict_from_file(filepath: String) -> Dictionary:
var file = FileAccess.open(filepath, FileAccess.READ)
var data = JSON.parse_string(file.get_as_text())
return data
## get_card_data_from_name
##
## _name: String [br]
## A wrapper for searching for a card by name. Use **get_card_data_from_id** where possible, as it avoids an expensive search for the new card, if the card has been cached already.
func get_card_data_from_name(_name: String) -> Dictionary:
return _get_card_data_from_bulk("name", _name)
## get_card_data_from_id
##
## id: String [br]
## This is the preferred wrapper to use when fetching card data, it checks the cache for preexisting data and uses that if it's available. Otherwise, it will search the bulk json for the data.
func get_card_data_from_id(id: String) -> Dictionary:
if FileAccess.file_exists("user://card_cache/" + id + "/card.json"):
return _get_dict_from_file("user://card_cache/" + id + "/card.json")