hanafuda/Deck.gd

87 lines
3.1 KiB
GDScript3
Raw Normal View History

2021-12-06 23:44:23 +01:00
extends Node2D
2021-12-06 23:10:39 +01:00
2021-12-14 21:53:45 +01:00
const CardValue = preload("res://CardValue.gd")
2021-12-06 23:10:39 +01:00
2024-09-02 13:26:07 +02:00
@onready var cards = [
2021-12-14 21:53:45 +01:00
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),
2021-12-06 23:10:39 +01:00
]
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
func _ready() -> void:
2021-12-06 23:44:23 +01:00
init_card_order()
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
2021-12-14 21:53:45 +01:00
func draw_card() -> CardValue:
2021-12-13 23:38:36 +01:00
if next_to_draw >= card_order.size():
2021-12-14 21:53:45 +01:00
return null
2021-12-13 23:38:36 +01:00
var card_id = card_order[next_to_draw]
next_to_draw += 1
var card = cards[card_id]
return card