Make draw_card work with opponent's hand

This commit is contained in:
Hamcha 2019-05-28 00:56:20 +02:00
parent ef6aebf597
commit d249fa29bb
Signed by: hamcha
GPG key ID: A40413D21021EAEE

View file

@ -47,6 +47,9 @@ func _ready():
for i in range(0,6):
draw_card(0, "player1.deck")
for i in range(0,6):
draw_card(1, "player1.deck")
func _input(event: InputEvent):
# Camera zoom
if event.is_action("zoom_in"):
@ -190,7 +193,10 @@ func reparent(object: Node, from: Node, to: Node):
from.remove_child(object)
to.add_child(object)
object.set_owner(to)
if to == hand or from == hand:
reorder_hand(0)
if to == oppHand or from == oppHand:
reorder_hand(1)
func add_card(cardID: String, playerID: int, zone: String):
var card := CardTemplate.instance()
@ -227,7 +233,10 @@ func draw_card(playerID: int, from: String):
card.inZone = false
card.flipped = false
card.animation.queue("flip-back-fast")
reparent(card, zones[from], hand)
var target := hand
if playerID != 0:
target = oppHand
reparent(card, zones[from], target)
func check_hand_drop(card: Card):
# Re-order hand as soon as the animation is over