diff --git a/card.gd b/card.gd new file mode 100644 index 0000000..817f9fd --- /dev/null +++ b/card.gd @@ -0,0 +1,47 @@ +extends Node + +# 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 cached = false + +var card_id = "placedholder_id" +var card_name = "placeholder_name" +var card_type = "placeholder_card_type" +var oracle_text = "placeholder_oracle_text" + +func _check_cache() -> bool: + ## want to check the cache before we make any scryfall calls + return false + +func _do_scryfall_get(id) -> void: + # TODO: fetch the card here... + + var fetched = false + + if !fetched: + print("Failed to fetch card data from scryfall") + + var card_content = "fetched_card_json" #TODO + var card_cache = FileAccess.open("user://card_cache/" + id + ".json", FileAccess.WRITE) + card_cache.store_string(card_content) + card_cache = null # closes the file + + +func load_card(id) -> void: + if !(_check_cache()): + _do_scryfall_get(id) + + var ondisk_card = FileAccess.open("user://card_cache/" + id + ".json", FileAccess.READ) + # parse json here to get card content + card_id = id + card_name = "loaded_cardname" + card_type = "loaded_type" + oracle_text = "loaded_oracletext" + + ondisk_card = null + pass + +## these variables above will be used for the helper boxes we draw +## on hover, to make cards easier to read diff --git a/card.gd.uid b/card.gd.uid new file mode 100644 index 0000000..458b657 --- /dev/null +++ b/card.gd.uid @@ -0,0 +1 @@ +uid://b3yqd1qu7dyq diff --git a/data/mana.gd b/data/mana.gd new file mode 100644 index 0000000..5f3ed67 --- /dev/null +++ b/data/mana.gd @@ -0,0 +1,10 @@ +enum ManaCosts { + WHITE, + BLUE, + BLACK, + RED, + GREEN, + COLOURLESS, + GENERIC, + LIFE +} diff --git a/data/mana.gd.uid b/data/mana.gd.uid new file mode 100644 index 0000000..14e0f51 --- /dev/null +++ b/data/mana.gd.uid @@ -0,0 +1 @@ +uid://brn2sbfea8fyf diff --git a/project.godot b/project.godot index c42aec0..753f1cc 100644 --- a/project.godot +++ b/project.godot @@ -14,3 +14,7 @@ config/name="mtg-tabletop" run/main_scene="uid://b4ldtb3gw0jlu" config/features=PackedStringArray("4.4", "Forward Plus") config/icon="res://icon.svg" + +[editor_plugins] + +enabled=PackedStringArray("res://addons/godot_vim/plugin.cfg")