Levels specify which cards should be displayed

This commit is contained in:
Sebastian Morr 2020-10-27 12:16:33 +01:00
parent f19d2bee8a
commit 3437b89ffc
11 changed files with 23 additions and 2 deletions

View file

@ -1,4 +1,5 @@
title = Parallelism
cards = checkout commit-auto reset-hard
[description]

View file

@ -1,4 +1,5 @@
title = Contradictions
cards = checkout commit-auto reset-hard merge
[description]

View file

@ -1,4 +1,5 @@
title = Merging timelines
cards = checkout commit-auto reset-hard merge
[description]

View file

@ -1,4 +1,5 @@
title = Helping each other
cards = checkout commit-auto reset-hard pull push
[description]

View file

@ -1,4 +1,5 @@
title = Rebasing
cards = checkout commit-auto reset-hard rebase
[description]

View file

@ -1,4 +1,5 @@
title = Reordering events
cards = checkout commit-auto reset-hard rebase-interactive cherry-pick
[description]

View file

@ -1,4 +1,5 @@
title = Welcome!
cards = checkout commit-auto reset-hard
[description]

View file

@ -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})

View file

@ -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

View file

@ -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 = []

View file

@ -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