Load next level when win condition is fulfilled

This commit is contained in:
Sebastian Morr 2020-09-10 12:47:18 +02:00
parent 39d952528f
commit 41260bc93c
4 changed files with 29 additions and 11 deletions

View file

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

View file

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

View file

@ -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!")

View file

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