tool class_name HanafudaCard extends Node2D const CardValue = preload("res://CardValue.gd") export var revealed: bool = true setget reveal export(Enums.Month) var month: int setget _set_card_month export(Enums.Type) var type: int setget _set_card_type onready var value = CardValue.new(Enums.Month.JANUARY, Enums.Type.LIGHT) onready var _is_ready := true # Called when the node enters the scene tree for the first time. func _ready() -> void: var texture_path := card_texture() $Frontside.texture = load(texture_path) reveal(revealed) func init_card(value_: CardValue) -> HanafudaCard: value = value_ return self func card_texture() -> String: var m := "" match value.month: Enums.Month.JANUARY: m = "January" Enums.Month.FEBRUARY: m = "February" Enums.Month.MARCH: m = "March" Enums.Month.APRIL: m = "April" Enums.Month.MAY: m = "May" Enums.Month.JUNE: m = "June" Enums.Month.JULY: m = "July" Enums.Month.AUGUST: m = "August" Enums.Month.SEPTEMBER: m = "September" Enums.Month.OCTOBER: m = "October" Enums.Month.NOVEMBER: m = "November" Enums.Month.DECEMBER: m = "December" var t := "" match value.type: Enums.Type.LIGHT: t = "Hikari" Enums.Type.ANIMAL: t = "Tane" Enums.Type.RIBBON: t = "Tanzaku" Enums.Type.SCRAP_1: t = "Kasu_1" Enums.Type.SCRAP_2: t = "Kasu_2" Enums.Type.SCRAP_3: t = "Kasu_3" var texture_path := "res://assets/png/Hanafuda_{month}_{type}.png".format({"month": m, "type": t}) return texture_path func reveal(new_reveal: bool) -> void: revealed = new_reveal if not _is_ready: yield(self, "ready") if revealed: $Frontside.show() $Backside.hide() else: $Frontside.hide() $Backside.show() func _set_card_month(new_month: int) -> void: value.month = new_month func _set_card_type(new_type: int) -> void: value.type = new_type