54 lines
1.6 KiB
GDScript
54 lines
1.6 KiB
GDScript
extends Node
|
|
|
|
onready var HanafudaCard = preload("res://HanafudaCard.tscn")
|
|
|
|
onready var deck = $Deck
|
|
onready var tween = $Tween
|
|
|
|
func _ready():
|
|
var dealer = oya()
|
|
|
|
func oya():
|
|
tween.start()
|
|
var deck_position = Vector2(10, 10)
|
|
var card_reveal_duration = 0.5
|
|
var card_dim = 150
|
|
|
|
var card_1 = HanafudaCard.instance().init_card($Deck.draw_card())
|
|
card_1.set_min_dimension(card_dim)
|
|
add_child(card_1)
|
|
|
|
var card_size = card_1.get_size()
|
|
var padding = 20
|
|
var delta_x = (card_size.x + padding) / 2
|
|
|
|
tween.interpolate_property(card_1, "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)
|
|
|
|
var card_2 = HanafudaCard.instance().init_card($Deck.draw_card())
|
|
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)
|
|
|
|
yield(tween, "tween_all_completed")
|
|
|
|
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")
|
|
|
|
print("update oya")
|