extends TextureRect ## The card class [br][br] ## ## ## Contains helper text for the text, the cards ID, and the image path. ## The goal of this class is to make card management easier. # we want to use this to convert the mana cost into text # in the helper text box, but thats for the future const ManaCosts = preload("res://data/mana.gd") var card_id = "placedholder_id" var card_name = "placeholder_name" var card_type = "placeholder_card_type" var oracle_text = "placeholder_oracle_text" func _card_error(error_type: String) -> String: return "CARD::" + card_id + "::" + error_type + "\n" func _init(id) -> void: card_id = id func load_card() -> bool: var ondisk_card = FileAccess.open( "user://card_cache/" + card_id + "/card.json", FileAccess.READ ) if ondisk_card == null: push_error("ERROR::CRITICAL::CACHE\nCard being accessed wasn't cached, yell at the coders plz") var card_json = JSON.parse_string(ondisk_card.get_as_text()) card_name = card_json["name"] card_type = card_json["type_line"] oracle_text = card_json["oracle_text"] var img = Image.new() img.load("user://card_cache/" + card_id + "/card.jpg") texture = ImageTexture.create_from_image(img) ondisk_card = null return true