From 3437b89ffc33f788b1e647502b54c90d91a46a93 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 27 Oct 2020 12:16:33 +0100 Subject: [PATCH] Levels specify which cards should be displayed --- levels/time-machine/branches | 1 + levels/time-machine/conflict | 1 + levels/time-machine/merge | 1 + levels/time-machine/pull-push | 1 + levels/time-machine/rebase | 1 + levels/time-machine/reorder | 1 + levels/time-machine/welcome | 1 + scenes/cardgame.gd | 13 ++++++++++++- scenes/cards.tscn | 1 + scenes/level.gd | 2 ++ scenes/main.gd | 2 +- 11 files changed, 23 insertions(+), 2 deletions(-) diff --git a/levels/time-machine/branches b/levels/time-machine/branches index 2933e2e..9d4ebc6 100644 --- a/levels/time-machine/branches +++ b/levels/time-machine/branches @@ -1,4 +1,5 @@ title = Parallelism +cards = checkout commit-auto reset-hard [description] diff --git a/levels/time-machine/conflict b/levels/time-machine/conflict index 276f33e..626d265 100644 --- a/levels/time-machine/conflict +++ b/levels/time-machine/conflict @@ -1,4 +1,5 @@ title = Contradictions +cards = checkout commit-auto reset-hard merge [description] diff --git a/levels/time-machine/merge b/levels/time-machine/merge index 778770a..6e2a6d8 100644 --- a/levels/time-machine/merge +++ b/levels/time-machine/merge @@ -1,4 +1,5 @@ title = Merging timelines +cards = checkout commit-auto reset-hard merge [description] diff --git a/levels/time-machine/pull-push b/levels/time-machine/pull-push index 6d1e599..de32a51 100644 --- a/levels/time-machine/pull-push +++ b/levels/time-machine/pull-push @@ -1,4 +1,5 @@ title = Helping each other +cards = checkout commit-auto reset-hard pull push [description] diff --git a/levels/time-machine/rebase b/levels/time-machine/rebase index c0cfb96..d37b290 100644 --- a/levels/time-machine/rebase +++ b/levels/time-machine/rebase @@ -1,4 +1,5 @@ title = Rebasing +cards = checkout commit-auto reset-hard rebase [description] diff --git a/levels/time-machine/reorder b/levels/time-machine/reorder index 980917f..1175df3 100644 --- a/levels/time-machine/reorder +++ b/levels/time-machine/reorder @@ -1,4 +1,5 @@ title = Reordering events +cards = checkout commit-auto reset-hard rebase-interactive cherry-pick [description] diff --git a/levels/time-machine/welcome b/levels/time-machine/welcome index 6359785..bb0f9a2 100644 --- a/levels/time-machine/welcome +++ b/levels/time-machine/welcome @@ -1,4 +1,5 @@ title = Welcome! +cards = checkout commit-auto reset-hard [description] diff --git a/scenes/cardgame.gd b/scenes/cardgame.gd index cdc5f51..1274205 100644 --- a/scenes/cardgame.gd +++ b/scenes/cardgame.gd @@ -5,7 +5,7 @@ var cards func _ready(): load_card_store() - redraw_all_cards() + #redraw_all_cards() arrange_cards() pass @@ -43,6 +43,15 @@ func draw_card(card): add_child(new_card) arrange_cards() +func draw(ids): + for card in get_tree().get_nodes_in_group("cards"): + card.queue_free() + + for id in ids: + draw_card(card_store[id]) + + arrange_cards() + func arrange_cards(): var t = Timer.new() t.wait_time = 0.05 @@ -80,6 +89,8 @@ func redraw_all_cards(): for card in card_store: draw_card(card_store[card]) + + arrange_cards() func add_card(command): draw_card({"command": command, "description": "", "arg_number": 0, "energy": 0}) diff --git a/scenes/cards.tscn b/scenes/cards.tscn index b471bf5..109d7c8 100644 --- a/scenes/cards.tscn +++ b/scenes/cards.tscn @@ -14,6 +14,7 @@ __meta__ = { } [node name="Button" type="Button" parent="."] +visible = false anchor_left = 1.0 anchor_right = 1.0 margin_left = -172.0 diff --git a/scenes/level.gd b/scenes/level.gd index 2db71ec..662b521 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -5,6 +5,7 @@ var slug var title var description var congrats +var cards var repos = {} # The path is an outer path. @@ -20,6 +21,7 @@ func load(path): title = config.get("title", slug) description = config.get("description", "(no description)") congrats = config.get("congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next Level'.") + cards = Array(config.get("cards", "checkout commit-auto merge rebase rebase-interactive reset-hard cherry-pick").split(" ")) var keys = config.keys() var repo_setups = [] diff --git a/scenes/main.gd b/scenes/main.gd index ec7df2b..0648250 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -63,6 +63,7 @@ func load_level(level_id): level_description.bbcode_text = level.description level_congrats.bbcode_text = level.congrats level_name.text = level.title + cards.draw(levels.chapters[current_chapter].levels[current_level].cards) for r in repositories_node.get_children(): r.queue_free() @@ -131,6 +132,5 @@ func update_repos(): if levels.chapters[current_chapter].levels[current_level].check_win(): show_win_status() - func toggle_cards(): cards.visible = not cards.visible