100 lines
4.3 KiB
GDScript
100 lines
4.3 KiB
GDScript
extends Node2D
|
|
|
|
var HanafudaCard = preload("res://HanafudaCard.tscn")
|
|
|
|
onready var cards = [
|
|
HanafudaCard.instance().init_card(Enums.Month.JANUARY, Enums.Type.LIGHT),
|
|
HanafudaCard.instance().init_card(Enums.Month.JANUARY, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.JANUARY, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.JANUARY, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.FEBRUARY, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.FEBRUARY, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.FEBRUARY, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.FEBRUARY, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.MARCH, Enums.Type.LIGHT),
|
|
HanafudaCard.instance().init_card(Enums.Month.MARCH, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.MARCH, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.MARCH, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.APRIL, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.APRIL, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.APRIL, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.APRIL, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.MAY, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.MAY, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.MAY, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.MAY, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.JUNE, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.JUNE, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.JUNE, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.JUNE, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.JULY, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.JULY, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.JULY, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.JULY, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.AUGUST, Enums.Type.LIGHT),
|
|
HanafudaCard.instance().init_card(Enums.Month.AUGUST, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.AUGUST, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.AUGUST, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.SEPTEMBER, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.SEPTEMBER, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.SEPTEMBER, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.SEPTEMBER, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.OCTOBER, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.OCTOBER, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.OCTOBER, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.OCTOBER, Enums.Type.SCRAP_2),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.NOVEMBER, Enums.Type.LIGHT),
|
|
HanafudaCard.instance().init_card(Enums.Month.NOVEMBER, Enums.Type.ANIMAL),
|
|
HanafudaCard.instance().init_card(Enums.Month.NOVEMBER, Enums.Type.RIBBON),
|
|
HanafudaCard.instance().init_card(Enums.Month.NOVEMBER, Enums.Type.SCRAP_1),
|
|
|
|
HanafudaCard.instance().init_card(Enums.Month.DECEMBER, Enums.Type.LIGHT),
|
|
HanafudaCard.instance().init_card(Enums.Month.DECEMBER, Enums.Type.SCRAP_1),
|
|
HanafudaCard.instance().init_card(Enums.Month.DECEMBER, Enums.Type.SCRAP_2),
|
|
HanafudaCard.instance().init_card(Enums.Month.DECEMBER, Enums.Type.SCRAP_3),
|
|
]
|
|
|
|
var card_order = []
|
|
var next_to_draw = 0
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
init_card_order()
|
|
for c in cards:
|
|
add_child(c)
|
|
c.hide()
|
|
|
|
|
|
var card: HanafudaCard = cards[0]
|
|
card.show()
|
|
card.reveal(false)
|
|
|
|
func init_card_order() -> void:
|
|
card_order.resize(cards.size())
|
|
for i in range(cards.size()):
|
|
card_order[i] = i
|
|
card_order.shuffle()
|
|
next_to_draw = 0
|
|
|
|
func draw_card() -> int:
|
|
if next_to_draw >= card_order.size():
|
|
return -1
|
|
var card_id = card_order[next_to_draw]
|
|
next_to_draw += 1
|
|
return card_id
|
|
|
|
func card(index: int) -> HanafudaCard:
|
|
if index == -1:
|
|
printerr("Invalid card index")
|
|
return cards[index]
|