mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
adding actions
This commit is contained in:
parent
d8d48c245e
commit
275ffc5ec4
3 changed files with 29 additions and 2 deletions
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -61,6 +65,15 @@ func load(path):
|
|||
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)
|
||||
# print("Commands: " + repos[repo].win_conditions[desc])
|
||||
|
@ -106,8 +119,10 @@ func check_win():
|
|||
var win_states = {}
|
||||
for r in repos:
|
||||
var repo = repos[r]
|
||||
if repo.win_conditions.size() > 0:
|
||||
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:
|
||||
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"
|
||||
|
|
|
@ -4,4 +4,5 @@ class_name LevelRepo
|
|||
var slug
|
||||
var path
|
||||
var setup_commands = ""
|
||||
var action_commands = ""
|
||||
var win_conditions = {}
|
||||
|
|
Loading…
Reference in a new issue