From f0383eb3932b82d471483b0ecfa89e8f2b5b6300 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Thu, 15 Oct 2020 16:11:02 +0200 Subject: [PATCH] Show all cards, unlimited energy --- card.gd | 5 +++-- card.tscn | 1 + cardgame.gd | 41 ++++++++++++++++++++++++----------------- cards.tscn | 1 + 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/card.gd b/card.gd index fa1e4fc..51d4c8f 100644 --- a/card.gd +++ b/card.gd @@ -96,9 +96,10 @@ func move_back(): rotation_degrees = _home_rotation func buuurn(): - queue_free() + move_back() + #queue_free() #$"..".draw_rand_card() - $"..".arrange_cards() + #$"..".arrange_cards() func dropped_on(other): var full_command = "" diff --git a/card.tscn b/card.tscn index 2636092..916ac4d 100644 --- a/card.tscn +++ b/card.tscn @@ -99,6 +99,7 @@ __meta__ = { } [node name="Sprite" type="Sprite" parent="."] +visible = false position = Vector2( -103.288, -287.778 ) scale = Vector2( 0.542341, 0.542341 ) texture = ExtResource( 3 ) diff --git a/cardgame.gd b/cardgame.gd index 8aaef4e..48f6105 100644 --- a/cardgame.gd +++ b/cardgame.gd @@ -1,18 +1,6 @@ extends Control var cards = [ - { - "command": 'git commit --allow-empty -m "$RANDOM"', - "arg_number": 0, - "description": "Add a new commit under HEAD.", - "energy": 1 - }, - { - "command": 'git checkout', - "arg_number": 1, - "description": "Point HEAD to a branch or commit, and update the index and the working directory.", - "energy": 1 - }, { "command": 'git add .', "arg_number": 0, @@ -38,6 +26,18 @@ var cards = [ "description": "Merge specified commit into HEAD.", "energy": 1 }, + { + "command": 'git commit --allow-empty -m "$RANDOM"', + "arg_number": 0, + "description": "Add a new commit under HEAD.", + "energy": 1 + }, + { + "command": 'git checkout', + "arg_number": 1, + "description": "Point HEAD to a branch or commit, and update the index and the working directory.", + "energy": 1 + }, { "command": 'git update-ref -d', "arg_number": 1, @@ -112,12 +112,16 @@ func draw_rand_card(): deck.push_back(cards[0]) deck.push_back(cards[1]) - var new_card = preload("res://card.tscn").instance() var card = deck[randi() % deck.size()] + draw_card(card) + +func draw_card(card): + var new_card = preload("res://card.tscn").instance() + new_card.command = card.command new_card.arg_number = card.arg_number new_card.description = card.description - new_card.energy = card.energy + new_card.energy = 0 #card.energy new_card.position = Vector2(rect_size.x, rect_size.y*2) add_child(new_card) arrange_cards() @@ -153,8 +157,11 @@ func arrange_cards(): func redraw_all_cards(): game.energy = 5 + for card in get_tree().get_nodes_in_group("cards"): card.queue_free() - for i in range(7): - draw_rand_card() - + +# for i in range(7): +# draw_rand_card() + for card in cards: + draw_card(card) diff --git a/cards.tscn b/cards.tscn index 42abfcf..08b3248 100644 --- a/cards.tscn +++ b/cards.tscn @@ -27,6 +27,7 @@ __meta__ = { } [node name="Energy" type="Label" parent="."] +visible = false modulate = Color( 0.431373, 0.792157, 0.423529, 1 ) margin_left = 28.2219 margin_top = 16.6766