converts card info to a dict
This commit is contained in:
parent
999c7989f3
commit
32bf3be0cd
@ -5,10 +5,7 @@ extends Node2D
|
|||||||
## Contains helper text for the text, the cards ID, and the image path.
|
## Contains helper text for the text, the cards ID, and the image path.
|
||||||
|
|
||||||
# Card information.
|
# Card information.
|
||||||
var card_id: String
|
var card_info: Dictionary
|
||||||
var card_name: String
|
|
||||||
var card_type: String
|
|
||||||
var oracle_text: String
|
|
||||||
|
|
||||||
# Card properties.
|
# Card properties.
|
||||||
var tapped: bool
|
var tapped: bool
|
||||||
@ -22,7 +19,7 @@ var mouse_offset: Vector2
|
|||||||
|
|
||||||
|
|
||||||
func init(id: String) -> void:
|
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
|
# 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:
|
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:
|
func colission_size() -> Vector2:
|
||||||
|
@ -25,7 +25,7 @@ func _load_card() -> Error:
|
|||||||
|
|
||||||
func _load_data() -> Error:
|
func _load_data() -> Error:
|
||||||
var cached_json = FileAccess.get_file_as_string(
|
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():
|
if cached_json.is_empty():
|
||||||
@ -37,17 +37,17 @@ func _load_data() -> Error:
|
|||||||
if card_json == null:
|
if card_json == null:
|
||||||
push_error("%s\nCard json data is could not be parsed as valid json" % card.error("DATA"))
|
push_error("%s\nCard json data is could not be parsed as valid json" % card.error("DATA"))
|
||||||
return FAILED
|
return FAILED
|
||||||
|
|
||||||
card.card_name = card_json["name"]
|
card.card_info["name"] = card_json["name"]
|
||||||
card.card_type = card_json["type_line"]
|
card.card_info["type"] = card_json["type_line"]
|
||||||
card.oracle_text = card_json["oracle_text"]
|
card.card_info["desc"] = card_json["oracle_text"]
|
||||||
|
|
||||||
return OK
|
return OK
|
||||||
|
|
||||||
|
|
||||||
func _load_image() -> Error:
|
func _load_image() -> Error:
|
||||||
# NOTE: Assuming we're going with using the .png cards on board.
|
# 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():
|
if cached_img.is_empty():
|
||||||
push_error("%sCard on-board image was not found in cache" % card.error("CACHE"))
|
push_error("%sCard on-board image was not found in cache" % card.error("CACHE"))
|
||||||
|
@ -113,6 +113,11 @@ func _ready() -> void:
|
|||||||
var deck = deck_input.new()
|
var deck = deck_input.new()
|
||||||
add_child(deck)
|
add_child(deck)
|
||||||
deck.add_new_deck(cards, "Blood rites")
|
deck.add_new_deck(cards, "Blood rites")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://b4ldtb3gw0jlu"]
|
[gd_scene load_steps=6 format=3 uid="uid://b4ldtb3gw0jlu"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cfkew150yl1y3" path="res://tabletop.gd" id="1_3we3x"]
|
[ext_resource type="Script" uid="uid://cfkew150yl1y3" path="res://tabletop.gd" id="1_3we3x"]
|
||||||
|
[ext_resource type="Script" uid="uid://brto6yniu3yx1" path="res://tooltip.gd" id="2_d43bn"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3we3x"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3we3x"]
|
||||||
bg_color = Color(0, 0, 0, 1)
|
bg_color = Color(0, 0, 0, 1)
|
||||||
@ -34,6 +35,7 @@ theme_override_constants/separation = 0
|
|||||||
[node name="MenuArea" type="PanelContainer" parent="UI/BigBar/Items"]
|
[node name="MenuArea" type="PanelContainer" parent="UI/BigBar/Items"]
|
||||||
custom_minimum_size = Vector2(0, 540)
|
custom_minimum_size = Vector2(0, 540)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
script = ExtResource("2_d43bn")
|
||||||
|
|
||||||
[node name="ChatArea" type="PanelContainer" parent="UI/BigBar/Items"]
|
[node name="ChatArea" type="PanelContainer" parent="UI/BigBar/Items"]
|
||||||
custom_minimum_size = Vector2(0, 270)
|
custom_minimum_size = Vector2(0, 270)
|
||||||
|
4
tooltip.gd
Normal file
4
tooltip.gd
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
extends PanelContainer
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass
|
1
tooltip.gd.uid
Normal file
1
tooltip.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://brto6yniu3yx1
|
Loading…
x
Reference in New Issue
Block a user