converts card info to a dict
This commit is contained in:
@ -5,10 +5,7 @@ extends Node2D
|
||||
## Contains helper text for the text, the cards ID, and the image path.
|
||||
|
||||
# Card information.
|
||||
var card_id: String
|
||||
var card_name: String
|
||||
var card_type: String
|
||||
var oracle_text: String
|
||||
var card_info: Dictionary
|
||||
|
||||
# Card properties.
|
||||
var tapped: bool
|
||||
@ -22,7 +19,7 @@ var mouse_offset: Vector2
|
||||
|
||||
|
||||
func init(id: String) -> void:
|
||||
card_id = id
|
||||
card_info["id"] = id
|
||||
|
||||
|
||||
# This is called when we want to apply the behaviour of the mouse being
|
||||
@ -35,7 +32,7 @@ func check_hover() -> void:
|
||||
|
||||
|
||||
func error(error_type: String) -> String:
|
||||
return "ERROR::CARD::%s::%s::%s::\n" % [card_id, card_name, error_type]
|
||||
return "ERROR::CARD::%s::%s::%s::\n" % [card_info["id"], card_info["name"], error_type]
|
||||
|
||||
|
||||
func colission_size() -> Vector2:
|
||||
|
@ -25,7 +25,7 @@ func _load_card() -> Error:
|
||||
|
||||
func _load_data() -> Error:
|
||||
var cached_json = FileAccess.get_file_as_string(
|
||||
"user://card_cache/" + card.card_id + "/card.json"
|
||||
"user://card_cache/" + card.card_info["id"] + "/card.json"
|
||||
)
|
||||
|
||||
if cached_json.is_empty():
|
||||
@ -37,17 +37,17 @@ func _load_data() -> Error:
|
||||
if card_json == null:
|
||||
push_error("%s\nCard json data is could not be parsed as valid json" % card.error("DATA"))
|
||||
return FAILED
|
||||
|
||||
card.card_name = card_json["name"]
|
||||
card.card_type = card_json["type_line"]
|
||||
card.oracle_text = card_json["oracle_text"]
|
||||
|
||||
card.card_info["name"] = card_json["name"]
|
||||
card.card_info["type"] = card_json["type_line"]
|
||||
card.card_info["desc"] = card_json["oracle_text"]
|
||||
|
||||
return OK
|
||||
|
||||
|
||||
func _load_image() -> Error:
|
||||
# NOTE: Assuming we're going with using the .png cards on board.
|
||||
var cached_img = FileAccess.get_file_as_bytes("user://card_cache/" + card.card_id + "/card.png")
|
||||
var cached_img = FileAccess.get_file_as_bytes("user://card_cache/" + card.card_info["id"] + "/card.png")
|
||||
|
||||
if cached_img.is_empty():
|
||||
push_error("%sCard on-board image was not found in cache" % card.error("CACHE"))
|
||||
|
Reference in New Issue
Block a user