adding actions

This commit is contained in:
bleeptrack 2020-12-22 17:04:01 +01:00
parent d8d48c245e
commit 275ffc5ec4
3 changed files with 29 additions and 2 deletions

View file

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

View file

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

View file

@ -4,4 +4,5 @@ class_name LevelRepo
var slug
var path
var setup_commands = ""
var action_commands = ""
var win_conditions = {}