diff --git a/levels/01-blob/win b/levels/01-blob/win index 0815775..337555a 100644 --- a/levels/01-blob/win +++ b/levels/01-blob/win @@ -1,7 +1,7 @@ BLOB_COUNT=$(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep blob | wc -l) if [ "$BLOB_COUNT" -gt 2 ]; then - echo yes + exit 0 else - echo no + exit 1 fi diff --git a/main.gd b/main.gd index 679395c..6a39fb3 100644 --- a/main.gd +++ b/main.gd @@ -4,6 +4,7 @@ var dragged = null var server var client_connection +var current_level = 0 onready var input = $Terminal/Control/Input onready var output = $Terminal/Control/Output @@ -43,6 +44,8 @@ func list_levels(): return levels func load_level(id): + current_level = id + var levels = list_levels() var level = levels[id] @@ -80,6 +83,10 @@ func load_level(id): var win_script_target = game.tmp_prefix+"/win" var dir = Directory.new() dir.copy(win_script, win_script_target) + +func load_next_level(): + current_level += 1 + load_level(current_level) func construct_repo(script, path): # Becase in an exported game, all assets are in a .pck file, we need to put diff --git a/terminal.gd b/terminal.gd index 55d3dc9..cbfc4bb 100644 --- a/terminal.gd +++ b/terminal.gd @@ -8,6 +8,7 @@ var history_position = 0 onready var input = $Control/Input onready var output = $Control/Output onready var repo = $"../Repositories/ActiveRepository" +onready var main = get_parent() func _ready(): repo.shell.connect("output", self, "receive_output") @@ -51,4 +52,6 @@ func receive_output(text): output.text += text func check_win_condition(): - print( repo.shell.run("bash /tmp/win") ) + if repo.shell.run("bash /tmp/win && echo yes || echo no") == "yes\n": + main.load_next_level() + print("you win!") diff --git a/terminal.tscn b/terminal.tscn index 8802e12..e24ea09 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -36,7 +36,7 @@ __meta__ = { [node name="Output" type="RichTextLabel" parent="Control"] margin_right = 1920.0 -margin_bottom = 1019.0 +margin_bottom = 999.0 size_flags_vertical = 3 custom_styles/normal = SubResource( 1 ) custom_fonts/normal_font = ExtResource( 1 ) @@ -44,26 +44,35 @@ scroll_following = true [node name="Button" parent="Control" instance=ExtResource( 4 )] margin_left = 0.0 +margin_top = 999.0 +margin_right = 1920.0 +margin_bottom = 1019.0 +text = "git commit --allow-empty" +align = 0 + +[node name="Button5" parent="Control" instance=ExtResource( 4 )] +margin_left = 0.0 margin_top = 1019.0 margin_right = 1920.0 margin_bottom = 1039.0 -text = "git commit --allow-empty" +text = "echo $RANDOM | git hash-object -w --stdin" align = 0 [node name="Button2" parent="Control" instance=ExtResource( 4 )] visible = false margin_left = 0.0 -margin_top = 1019.0 +margin_top = 979.0 margin_right = 1920.0 -margin_bottom = 1039.0 +margin_bottom = 999.0 text = "git switch -c $RANDOM" align = 0 [node name="Button3" parent="Control" instance=ExtResource( 4 )] visible = false -margin_top = 958.0 -margin_right = 700.0 -margin_bottom = 1011.0 +margin_left = 0.0 +margin_top = 999.0 +margin_right = 1920.0 +margin_bottom = 1019.0 text = "git checkout HEAD^" align = 0 @@ -75,7 +84,6 @@ margin_right = 1920.0 margin_bottom = 1039.0 text = "sleep 1;echo hey" align = 0 -async = true [node name="Input" type="LineEdit" parent="Control"] margin_top = 1039.0