hanafuda/Deck.gd
2024-09-02 13:26:07 +02:00

87 lines
3.1 KiB
GDScript

extends Node2D
const CardValue = preload("res://CardValue.gd")
@onready var cards = [
CardValue.new(Enums.Month.JANUARY, Enums.Type.LIGHT),
CardValue.new(Enums.Month.JANUARY, Enums.Type.RIBBON),
CardValue.new(Enums.Month.JANUARY, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.JANUARY, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.FEBRUARY, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.FEBRUARY, Enums.Type.RIBBON),
CardValue.new(Enums.Month.FEBRUARY, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.FEBRUARY, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.MARCH, Enums.Type.LIGHT),
CardValue.new(Enums.Month.MARCH, Enums.Type.RIBBON),
CardValue.new(Enums.Month.MARCH, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.MARCH, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.APRIL, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.APRIL, Enums.Type.RIBBON),
CardValue.new(Enums.Month.APRIL, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.APRIL, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.MAY, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.MAY, Enums.Type.RIBBON),
CardValue.new(Enums.Month.MAY, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.MAY, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.JUNE, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.JUNE, Enums.Type.RIBBON),
CardValue.new(Enums.Month.JUNE, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.JUNE, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.JULY, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.JULY, Enums.Type.RIBBON),
CardValue.new(Enums.Month.JULY, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.JULY, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.AUGUST, Enums.Type.LIGHT),
CardValue.new(Enums.Month.AUGUST, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.AUGUST, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.AUGUST, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.SEPTEMBER, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.SEPTEMBER, Enums.Type.RIBBON),
CardValue.new(Enums.Month.SEPTEMBER, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.SEPTEMBER, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.OCTOBER, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.OCTOBER, Enums.Type.RIBBON),
CardValue.new(Enums.Month.OCTOBER, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.OCTOBER, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.NOVEMBER, Enums.Type.LIGHT),
CardValue.new(Enums.Month.NOVEMBER, Enums.Type.ANIMAL),
CardValue.new(Enums.Month.NOVEMBER, Enums.Type.RIBBON),
CardValue.new(Enums.Month.NOVEMBER, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.DECEMBER, Enums.Type.LIGHT),
CardValue.new(Enums.Month.DECEMBER, Enums.Type.SCRAP_1),
CardValue.new(Enums.Month.DECEMBER, Enums.Type.SCRAP_2),
CardValue.new(Enums.Month.DECEMBER, Enums.Type.SCRAP_3),
]
var card_order = []
var next_to_draw = 0
func _ready() -> void:
init_card_order()
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() -> CardValue:
if next_to_draw >= card_order.size():
return null
var card_id = card_order[next_to_draw]
next_to_draw += 1
var card = cards[card_id]
return card