From 275ffc5ec42973681473d3486fea145793736e90 Mon Sep 17 00:00:00 2001 From: bleeptrack Date: Tue, 22 Dec 2020 17:04:01 +0100 Subject: [PATCH] adding actions --- levels/time-machine/branches | 13 ++++++++++++- scenes/level.gd | 17 ++++++++++++++++- scenes/level_repo.gd | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/levels/time-machine/branches b/levels/time-machine/branches index facfcaa..65796c6 100644 --- a/levels/time-machine/branches +++ b/levels/time-machine/branches @@ -78,7 +78,18 @@ git checkout --detach main [win] -{ git show main:you | grep "You ate.*baguette"; } && { git show main:you | grep "You drank.*coffee"; } && { git show main:you | grep "You ate.*donut"; } +# Did you eat a baguette on the main branch? +git show main:you | grep "You ate.*baguette" + +# Did you drink a coffee on the main branch? +git show main:you | grep "You drank.*coffee" + +# Did you eat a donut on the main branch? +git show main:you | grep "You ate.*donut" + +[actions] + +test "$(git rev-parse HEAD^)" = "$(git rev-parse donut)" && hint "Ooops, your branch ref is still on the old commit." [congrats] diff --git a/scenes/level.gd b/scenes/level.gd index 1604fce..8f08827 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -34,6 +34,10 @@ func load(path): for k in keys: if k.begins_with("win"): repo_wins.push_back(k) + var repo_actions = [] + for k in keys: + if k.begins_with("actions"): + repo_actions.push_back(k) for k in repo_setups: var repo @@ -60,6 +64,15 @@ func load(path): if not repos[repo].win_conditions.has(description): repos[repo].win_conditions[description] = "" repos[repo].win_conditions[description] += line+"\n" + + for k in repo_actions: + var repo + if " " in k: + repo = Array(k.split(" "))[1] + else: + repo = "yours" + + repos[repo].action_commands = config[k] # for desc in repos[repo].win_conditions: # print("Desc: " + desc) @@ -106,8 +119,10 @@ func check_win(): var win_states = {} for r in repos: var repo = repos[r] + game.global_shell.cd(repo.path) + if repo.action_commands.length() > 0: + game.global_shell.run("function actions { %s\n}; actions 2>/dev/null >/dev/null || true" % repo.action_commands) if repo.win_conditions.size() > 0: - game.global_shell.cd(repo.path) for description in repo.win_conditions: var commands = repo.win_conditions[description] var won = game.global_shell.run("function win { %s\n}; win 2>/dev/null >/dev/null && echo yes || echo no" % commands) == "yes\n" diff --git a/scenes/level_repo.gd b/scenes/level_repo.gd index 407e5f4..afe692f 100644 --- a/scenes/level_repo.gd +++ b/scenes/level_repo.gd @@ -4,4 +4,5 @@ class_name LevelRepo var slug var path var setup_commands = "" +var action_commands = "" var win_conditions = {}