untap/deck_input.gd
2025-04-24 13:20:57 -04:00

109 lines
2.4 KiB
GDScript

extends Node
var _caching = preload("res://caching.gd")
var _decklist
var cards = "1 All That Glitters\n1 Ancestral Mask\n1 Angelic Destiny\n1 Arcane Signet\n1 Archon of Sun's Grace\n1 Austere Command\n1 Banishing Light\n1 Bear Umbra\n1 Blossoming Sands\n1 Canopy Vista\n1 Celestial Mantle\n1 Collective Resistance\n1 Command Tower\n1 Danitha Capashen, Paragon\n1 Danitha, New Benalia's Light\n1 Darksteel Mutation
1 Daybreak Coronet
1 Destiny Spinner
1 Eidolon of Blossoms
1 Eidolon of Countless Battles
1 Ellivere of the Wild Court
1 Enchantress's Presence
1 Envoy of the Ancestors
1 Ethereal Armor
1 Fertile Ground
13 Forest
1 Frantic Strength
1 Generous Gift
1 Gilded Lotus
1 Glittering Frost
1 Grasp of Fate
1 Gylwain, Casting Director
1 Hall of Heliod's Generosity
1 Heliod's Pilgrim
1 Hidden Grotto
1 Horrid Vigor
1 Idyllic Tutor
1 Jukai Naturalist
1 Kenrith's Transformation
1 Kor Spiritdancer
1 Krosan Verge
1 Light-Paws, Emperor's Voice
1 Luminous Broodmoth
1 Mantle of the Ancients
1 Overgrowth
1 Overprotect
1 Pacifism
14 Plains
1 Rancor
1 Retether
1 Rogue's Passage
1 Sage's Reverie
1 Sanctum Weaver
1 Selesnya Guildgate
1 Setessan Champion
1 Shalai, Voice of Plenty
1 Snake Umbra
1 Sol Ring
1 Solemnity
1 Songbirds' Blessing
1 Starfield Mystic
1 Swords to Plowshares
1 Tanglespan Lookout
1 Timber Paladin
1 Timely Ward
1 Tithe Taker
1 Transcendent Envoy
1 Twinblade Blessing
1 Umbra Mystic
1 Unfinished Business
1 Utopia Sprawl
1 Wild Growth
1 Winds of Rath
1 Yenna, Redtooth Regent
1 Sythis, Harvest's Hand"
signal done_fetching
func _init() -> void:
_decklist = Dictionary()
func convert_mtgo_to_http(decklist: String) -> Dictionary:
var links = {}
var lines = decklist.split("\n")
for line in lines:
var words = line.split(" ", false, 1)
if words.size() != 2:
continue
words[1] = words[1].replace(" ", "+")
links["https://api.scryfall.com/cards/named?exact=" + words[1]] = words[0]
return links
func _do_decklist_grab(queries: Dictionary) -> void:
var cache = _caching.new()
add_child(cache)
print("test")
for query in queries:
print("Test2")
var id = await cache.custom_query_fetch(query)
if id == "NONE":
continue
_decklist[id] = queries[query]
print("test3")
done_fetching.emit()
_show_decklist()
func _show_decklist():
for card in _decklist:
print(card + " : " + _decklist[card])
func _ready() -> void:
var queries = convert_mtgo_to_http(cards)
_do_decklist_grab(queries)