adds some baseline code for loading cards
This commit is contained in:
parent
c990b68e07
commit
a67f2e1096
47
card.gd
Normal file
47
card.gd
Normal file
@ -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
|
1
card.gd.uid
Normal file
1
card.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://b3yqd1qu7dyq
|
10
data/mana.gd
Normal file
10
data/mana.gd
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
enum ManaCosts {
|
||||||
|
WHITE,
|
||||||
|
BLUE,
|
||||||
|
BLACK,
|
||||||
|
RED,
|
||||||
|
GREEN,
|
||||||
|
COLOURLESS,
|
||||||
|
GENERIC,
|
||||||
|
LIFE
|
||||||
|
}
|
1
data/mana.gd.uid
Normal file
1
data/mana.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://brn2sbfea8fyf
|
@ -14,3 +14,7 @@ config/name="mtg-tabletop"
|
|||||||
run/main_scene="uid://b4ldtb3gw0jlu"
|
run/main_scene="uid://b4ldtb3gw0jlu"
|
||||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[editor_plugins]
|
||||||
|
|
||||||
|
enabled=PackedStringArray("res://addons/godot_vim/plugin.cfg")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user