hanafuda/Main.gd

54 lines
1.6 KiB
GDScript3
Raw Permalink Normal View History

2021-12-06 23:10:39 +01:00
extends Node
2024-09-02 13:26:07 +02:00
@onready var HanafudaCard = preload("res://HanafudaCard.tscn")
2021-12-14 21:53:45 +01:00
2024-09-02 13:26:07 +02:00
@onready var deck = $Deck
@onready var tween = $Tween
2021-12-13 23:38:36 +01:00
2021-12-06 23:10:39 +01:00
func _ready():
2021-12-14 13:22:44 +01:00
var dealer = oya()
2021-12-12 23:21:03 +01:00
2021-12-14 13:22:44 +01:00
func oya():
tween.start()
2022-01-23 23:56:54 +01:00
var deck_position = Vector2(10, 10)
var card_reveal_duration = 0.5
var card_dim = 150
2024-09-02 13:26:07 +02:00
var card_1 = HanafudaCard.instantiate().init_card($Deck.draw_card())
2022-01-23 23:56:54 +01:00
card_1.set_min_dimension(card_dim)
2021-12-14 21:53:45 +01:00
add_child(card_1)
2022-01-23 23:56:54 +01:00
var card_size = card_1.get_size()
var padding = 20
var delta_x = (card_size.x + padding) / 2
2021-12-13 23:38:36 +01:00
tween.interpolate_property(card_1, "position",
2022-01-23 23:56:54 +01:00
deck_position, Vector2(get_viewport().size.x / 2 - delta_x, get_viewport().size.y / 2),
card_reveal_duration,
2021-12-13 23:38:36 +01:00
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
2024-09-02 13:26:07 +02:00
var card_2 = HanafudaCard.instantiate().init_card($Deck.draw_card())
2022-01-23 23:56:54 +01:00
card_2.set_min_dimension(card_dim)
add_child(card_2)
tween.interpolate_property(card_2, "position",
deck_position, Vector2(get_viewport().size.x / 2 + delta_x, get_viewport().size.y / 2),
card_reveal_duration,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
2021-12-13 23:38:36 +01:00
2024-09-02 13:26:07 +02:00
await tween.tween_all_completed
2021-12-13 23:38:36 +01:00
2022-01-25 00:13:13 +01:00
print("Player 1: {c}".format({"c": card_1.value.desc()}))
print("Player 2: {c}".format({"c": card_2.value.desc()}))
if card_1.value.month < card_2.value.month:
print("Player 1 is the oya")
elif card_1.value.month > card_2.value.month:
print("Player 2 is the oya")
elif card_1.value.type >= Enums.Type.SCRAP_1 and card_2.value.tyoe >= Enums.Type.SCRAP_1:
print("Cards have the same value, redraw")
elif card_1.value.type < card_2.value.type:
print("Player 1 is the oya")
else:
print("Player 2 is the oya")
2021-12-12 23:21:03 +01:00
print("update oya")