2021-12-06 23:44:23 +01:00
|
|
|
extends Node2D
|
2021-12-06 23:10:39 +01:00
|
|
|
|
|
|
|
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),
|
|
|
|
]
|
|
|
|
|
2021-12-06 23:44:23 +01:00
|
|
|
var card_order = []
|
2021-12-13 23:38:36 +01:00
|
|
|
var next_to_draw = 0
|
2021-12-06 23:44:23 +01:00
|
|
|
|
2021-12-06 23:10:39 +01:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready() -> void:
|
2021-12-06 23:44:23 +01:00
|
|
|
init_card_order()
|
2021-12-06 23:10:39 +01:00
|
|
|
for c in cards:
|
|
|
|
add_child(c)
|
2021-12-12 23:21:03 +01:00
|
|
|
c.hide()
|
|
|
|
|
2021-12-06 23:44:23 +01:00
|
|
|
|
|
|
|
var card: HanafudaCard = cards[0]
|
2021-12-12 23:21:03 +01:00
|
|
|
card.show()
|
|
|
|
card.reveal(false)
|
2021-12-06 23:44:23 +01:00
|
|
|
|
|
|
|
func init_card_order() -> void:
|
|
|
|
card_order.resize(cards.size())
|
|
|
|
for i in range(cards.size()):
|
|
|
|
card_order[i] = i
|
2021-12-12 23:21:03 +01:00
|
|
|
card_order.shuffle()
|
2021-12-13 23:38:36 +01:00
|
|
|
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]
|