mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-22 20:32:38 +01:00
Stating to polish the time travel levels...
This commit is contained in:
parent
cb7742466b
commit
eb4f46e52f
12 changed files with 209 additions and 82 deletions
|
@ -1,51 +1,85 @@
|
||||||
title = Parallelism
|
title = Branching out
|
||||||
cards = checkout commit-auto reset-hard
|
cards = checkout commit-auto reset-hard merge
|
||||||
|
|
||||||
[description]
|
[description]
|
||||||
|
|
||||||
In this zoo, we found a some parallel timelines. What's going on here? The ends of the timelines have little tags attached.
|
You can use these little blue labels to give names to different timelines! This makes it easier to remember what happened where.
|
||||||
|
|
||||||
Especially the `bad_ending` one needs our attention! Can you travel to the `good_ending` timeline, and make a new commit where everyone involved is happy?
|
One of your colleagues messed up here - can you help reordering the branches correctly using the "reset" card?
|
||||||
|
|
||||||
[congrats]
|
When you do commits or merges while you're on a branch, the branch will grow with you. Try that while you eat that donut.
|
||||||
|
|
||||||
Whew, good job! This seems like a *much* better outcome.
|
Finally, merge all timelines together, in a way so that the "main" branch points to the result. That's base reality!
|
||||||
|
|
||||||
But our next mission is already waiting...
|
|
||||||
|
|
||||||
[setup]
|
[setup]
|
||||||
|
|
||||||
git checkout -b bad_ending
|
echo "A friendly old lady.
|
||||||
|
Sells delicious baguettes." > mary
|
||||||
|
|
||||||
mkdir cage
|
echo "A rebellious teenager.
|
||||||
mkdir toy_shop
|
Sells good coffee." > larry
|
||||||
echo "Looks very hungry." > cage/lion
|
|
||||||
|
echo "A snail. Literally a snail.
|
||||||
|
Sells donuts with an unspecified, slimy filling." > gary
|
||||||
|
|
||||||
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
|
You do not have coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
|
|
||||||
echo "A small child.
|
|
||||||
It really loves cats!
|
|
||||||
It's holding a lollipop." > child
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "The beginning"
|
git commit -m "The Beginning"
|
||||||
|
|
||||||
mv child cage
|
git checkout -b coffee
|
||||||
|
echo "You have a baguette.
|
||||||
|
|
||||||
|
You do not have coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
git add .
|
git add .
|
||||||
git commit -m "The child is curious"
|
git commit -m "You buy a baguette"
|
||||||
git branch good_ending
|
|
||||||
|
|
||||||
git rm cage/child
|
echo "You ate a baguette.
|
||||||
echo "Looks happy. :)" > cage/lion
|
|
||||||
|
You do not have coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Oh no"
|
git commit -m "You eat the baguette"
|
||||||
|
|
||||||
git checkout HEAD~2
|
git checkout -b baguette main
|
||||||
git checkout -b boring_ending
|
echo "You do not have a baguette.
|
||||||
mv child toy_shop
|
|
||||||
|
You have coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
git add .
|
git add .
|
||||||
git commit -m "The child is distracted"
|
git commit -m "You buy some coffee"
|
||||||
|
|
||||||
git checkout bad_ending
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
|
You drank coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
|
git add .
|
||||||
|
git commit -m "You drink the coffee"
|
||||||
|
|
||||||
|
git checkout -b donut main
|
||||||
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
|
You do not have coffee.
|
||||||
|
|
||||||
|
You have a donut." > you
|
||||||
|
git add .
|
||||||
|
git commit -m "You buy a donut"
|
||||||
|
|
||||||
|
git checkout --detach main
|
||||||
|
|
||||||
[win]
|
[win]
|
||||||
|
|
||||||
# Is the child still there, and do we have a commit that's not in bad_ending?
|
{ git show main:you | grep "You ate a baguette"; } && { git show main:you | grep "You drank coffee"; } && { git show main:you | grep "You ate a donut"; }
|
||||||
{ git ls-tree --name-only -r good_ending | grep child; } && { test "$(git log good_ending ^bad_ending --oneline | wc -l)" -gt 0; }
|
|
||||||
|
[congrats]
|
||||||
|
|
||||||
|
Nice! It's often convenient to stay on branches most of the time!
|
||||||
|
|
50
levels/time-machine/branching
Normal file
50
levels/time-machine/branching
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
title = Parallelism
|
||||||
|
cards = checkout commit-auto
|
||||||
|
|
||||||
|
[description]
|
||||||
|
|
||||||
|
Did you know that creating parallel timelines is perfectly legal and safe? It's true!
|
||||||
|
|
||||||
|
Can you find out when things went wrong in this zoo, and create commits that tell a better story?
|
||||||
|
|
||||||
|
[setup]
|
||||||
|
|
||||||
|
mkdir cage
|
||||||
|
echo "Looks very hungry." > cage/lion
|
||||||
|
|
||||||
|
echo "A small child.
|
||||||
|
It really loves cats!" > child
|
||||||
|
git add .
|
||||||
|
git commit -m "The beginning"
|
||||||
|
|
||||||
|
echo "It's holding a lollipop." >> child
|
||||||
|
git commit -am "The child buys something"
|
||||||
|
|
||||||
|
mv child cage
|
||||||
|
git add .
|
||||||
|
git commit -m "The child is curious"
|
||||||
|
|
||||||
|
git rm cage/child
|
||||||
|
echo "Looks happy. :)" > cage/lion
|
||||||
|
git add .
|
||||||
|
git commit -m "Oh no"
|
||||||
|
|
||||||
|
echo "It's sleeping." > cage/lion
|
||||||
|
git add .
|
||||||
|
git commit -m "Nap time!"
|
||||||
|
|
||||||
|
git checkout --detach
|
||||||
|
git branch -d main
|
||||||
|
|
||||||
|
[win]
|
||||||
|
|
||||||
|
# Is the child still there, and is the lion not hungry?
|
||||||
|
{ git ls-tree --name-only -r HEAD | grep child; } && { git show HEAD:cage/lion | grep -v "very hungry"; }
|
||||||
|
|
||||||
|
[congrats]
|
||||||
|
|
||||||
|
Whew, good job! This seems like a *much* better outcome.
|
||||||
|
|
||||||
|
Feel free to add more parallel timelines, or make them longer.
|
||||||
|
|
||||||
|
If you're ready, our next mission is already waiting...
|
|
@ -1,15 +1,13 @@
|
||||||
title = Welcome!
|
title = Moving through time
|
||||||
cards = checkout commit-auto reset-hard
|
cards = checkout commit-auto
|
||||||
|
|
||||||
[description]
|
[description]
|
||||||
|
|
||||||
Welcome, time agent! Good to see you - we could really use your help with fixing some temporal paradoxes!
|
The yellow boxes are frozen points in time, we call them "commits"! You can travel between them using the "checkout" card! (Try it!)
|
||||||
|
|
||||||
Each yellow box is a frozen point in time, we call them "commits"! You can travel to one by dragging the "checkout" card to it, and you can go back to the present by dragging it on the blue "main" tag! (Try it!)
|
The grey panel below shows your current environment - click on an object to inspect or modify it! You can also click on commits to look at their contents.
|
||||||
|
|
||||||
The grey panel shows your current environment - click on an object to inspect or modify it!
|
Can you find out what happened here? Then, come back to the latest commit, and fix the problem, using the "commit" card!
|
||||||
|
|
||||||
Can you find out what happened here? Then, come back to the present, fix the problem, and make a new commit, using the "commit" card!
|
|
||||||
|
|
||||||
[setup]
|
[setup]
|
||||||
|
|
||||||
|
@ -34,9 +32,12 @@ mv room2/little_sister room1
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Little sister walks back"
|
git commit -m "Little sister walks back"
|
||||||
|
|
||||||
|
git checkout --detach
|
||||||
|
git branch -d main
|
||||||
|
|
||||||
[win]
|
[win]
|
||||||
|
|
||||||
{ git show refs/heads/main:room2/piggy_bank | grep "10 coins"; } && { git show refs/heads/main:room1/little_sister | grep -v "10 coins"; }
|
{ git show HEAD:room2/piggy_bank | grep "10 coins"; } && { git show HEAD:room1/little_sister | grep -v "10 coins"; } && { git rev-parse HEAD^; }
|
||||||
|
|
||||||
[congrats]
|
[congrats]
|
||||||
|
|
|
@ -13,26 +13,26 @@ Again, let your finalized timeline be the "main" one.
|
||||||
|
|
||||||
[setup]
|
[setup]
|
||||||
|
|
||||||
echo "Just woke up. Is hungry." > tom
|
echo "Just woke up. Is hungry." > sam
|
||||||
git add .
|
git add .
|
||||||
git commit -m "The beginning"
|
git commit -m "The beginning"
|
||||||
|
|
||||||
git checkout -b pancakes
|
git checkout -b pancakes
|
||||||
echo "Had blueberry pancakes with maple syrup for breakfast." > tom
|
echo "Had blueberry pancakes with maple syrup for breakfast." > sam
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Pancakes!"
|
git commit -m "Pancakes!"
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
Is at work." >> tom
|
Is at work." >> sam
|
||||||
git commit -am "Go to work"
|
git commit -am "Go to work"
|
||||||
|
|
||||||
git checkout -b muesli main
|
git checkout -b muesli main
|
||||||
echo "Had muesli with oats and strawberries for breakfast." > tom
|
echo "Had muesli with oats and strawberries for breakfast." > sam
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Muesli!"
|
git commit -m "Muesli!"
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
Is at work." >> tom
|
Is at work." >> sam
|
||||||
git commit -am "Go to work"
|
git commit -am "Go to work"
|
||||||
|
|
||||||
git checkout main
|
git checkout main
|
||||||
|
|
22
levels/time-machine/init
Normal file
22
levels/time-machine/init
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
title = Welcome!
|
||||||
|
cards = init
|
||||||
|
|
||||||
|
[description]
|
||||||
|
|
||||||
|
Welcome, time agent! Good to see you - we could really use your help with fixing some temporal paradoxes!
|
||||||
|
|
||||||
|
Ready to initialize your time machine? Drag the `git init` card into the empty space!
|
||||||
|
|
||||||
|
[setup]
|
||||||
|
|
||||||
|
rm -rf .git
|
||||||
|
|
||||||
|
[win]
|
||||||
|
|
||||||
|
test -d .git
|
||||||
|
|
||||||
|
[congrats]
|
||||||
|
|
||||||
|
Wonderful! Now, let's make sure that your time machine works correctly...
|
||||||
|
|
||||||
|
Click on "Next level", as soon as you're ready!
|
|
@ -5,22 +5,20 @@ cards = checkout commit-auto reset-hard merge
|
||||||
|
|
||||||
Here's a trick so that you can sleep a bit longer: just do all your morning activities in parallel universes, and then at the end, merge them together!
|
Here's a trick so that you can sleep a bit longer: just do all your morning activities in parallel universes, and then at the end, merge them together!
|
||||||
|
|
||||||
Here, you see three parallel timelines - can you build a reality in the "main" timeline where you have a baguette, a coffee, *and* a donut?
|
Here, you see three parallel timelines - can you build a situation where you consumed a baguette, a coffee, *and* a donut?
|
||||||
|
|
||||||
The "merge" card will help you - try it!
|
The "merge" card will help you - try it!
|
||||||
|
|
||||||
[setup]
|
[setup]
|
||||||
|
|
||||||
mkdir bakery coffee_shop donut_shop
|
|
||||||
|
|
||||||
echo "A friendly old lady.
|
echo "A friendly old lady.
|
||||||
Sells delicious baguettes for 5 coins each." > bakery/mary
|
Sells delicious baguettes." > mary
|
||||||
|
|
||||||
echo "A rebellious teenager.
|
echo "A rebellious teenager.
|
||||||
Sells good coffee for 2 coins each." > coffee_shop/larry
|
Sells good coffee." > larry
|
||||||
|
|
||||||
echo "A snail. Literally a snail.
|
echo "A snail. Literally a snail.
|
||||||
Sells donuts with an unspecified, slimy filling - for 3 coins each." > donut_shop/gary
|
Sells donuts with an unspecified, slimy filling." > gary
|
||||||
|
|
||||||
echo "You do not have a baguette.
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
|
@ -31,50 +29,62 @@ You do not have a donut." > you
|
||||||
git add .
|
git add .
|
||||||
git commit -m "The Beginning"
|
git commit -m "The Beginning"
|
||||||
|
|
||||||
git checkout -b baguette
|
|
||||||
echo "You have a baguette.
|
echo "You have a baguette.
|
||||||
|
|
||||||
You do not have coffee.
|
You do not have coffee.
|
||||||
|
|
||||||
You do not have a donut." > you
|
You do not have a donut." > you
|
||||||
git mv you bakery
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "You get a baguette"
|
git commit -m "You buy a baguette"
|
||||||
git mv bakery/you .
|
|
||||||
git add .
|
|
||||||
git commit -m "You leave the bakery"
|
|
||||||
|
|
||||||
git checkout -b coffee main
|
echo "You ate a baguette.
|
||||||
|
|
||||||
|
You do not have coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
|
git add .
|
||||||
|
git commit -m "You eat the baguette"
|
||||||
|
|
||||||
|
git checkout HEAD~2
|
||||||
echo "You do not have a baguette.
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
You have coffee.
|
You have coffee.
|
||||||
|
|
||||||
You do not have a donut." > you
|
You do not have a donut." > you
|
||||||
git mv you coffee_shop
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "You get some coffee"
|
git commit -m "You buy some coffee"
|
||||||
git mv coffee_shop/you .
|
|
||||||
git add .
|
|
||||||
git commit -m "You leave the coffee_shop"
|
|
||||||
|
|
||||||
git checkout -b donut main
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
|
You drank coffee.
|
||||||
|
|
||||||
|
You do not have a donut." > you
|
||||||
|
git add .
|
||||||
|
git commit -m "You drink the coffee"
|
||||||
|
|
||||||
|
git checkout HEAD~2
|
||||||
echo "You do not have a baguette.
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
You do not have coffee.
|
You do not have coffee.
|
||||||
|
|
||||||
You have a donut." > you
|
You have a donut." > you
|
||||||
git mv you donut_shop
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "You get a donut"
|
git commit -m "You buy a donut"
|
||||||
git mv donut_shop/you .
|
|
||||||
git add .
|
|
||||||
git commit -m "You leave the donut shop"
|
|
||||||
|
|
||||||
git checkout main
|
echo "You do not have a baguette.
|
||||||
|
|
||||||
|
You do not have coffee.
|
||||||
|
|
||||||
|
You ate a donut." > you
|
||||||
|
git add .
|
||||||
|
git commit -m "You eat a donut"
|
||||||
|
|
||||||
|
git checkout HEAD~2
|
||||||
|
git branch -D main
|
||||||
|
|
||||||
[win]
|
[win]
|
||||||
|
|
||||||
{ git show main:you | grep "You have a baguette"; } && { git show main:you | grep "You have coffee"; } && { git show main:you | grep "You have a donut"; }
|
{ git show HEAD:you | grep "You ate a baguette"; } && { git show HEAD:you | grep "You drank coffee"; } && { git show HEAD:you | grep "You ate a donut"; }
|
||||||
|
|
||||||
[congrats]
|
[congrats]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
welcome
|
init
|
||||||
branches
|
checkout-commit
|
||||||
|
branching
|
||||||
merge
|
merge
|
||||||
|
branches
|
||||||
conflict
|
conflict
|
||||||
pull-push
|
pull-push
|
||||||
rebase
|
rebase
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"id": "init",
|
||||||
|
"command": "git init",
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Initialize the time machine!"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "checkout",
|
"id": "checkout",
|
||||||
"command": "git checkout",
|
"command": "git checkout",
|
||||||
"arg_number": 1,
|
"arg_number": 1,
|
||||||
"description": "Travel to a commit!"
|
"description": "Drag this card to a commit or to a branch to travel to it!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "commit-auto",
|
"id": "commit-auto",
|
||||||
"command": "git add .; git commit",
|
"command": "git add .; git commit",
|
||||||
"arg_number": 0,
|
"arg_number": 0,
|
||||||
"description": "Make a new commit!"
|
"description": "Make a new commit containing your current environment!\nDrag this card anywhere. You'll be asked to enter a short description of what you changed."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "merge",
|
"id": "merge",
|
||||||
|
@ -45,7 +51,7 @@
|
||||||
"id": "reset-hard",
|
"id": "reset-hard",
|
||||||
"command": "git reset --hard",
|
"command": "git reset --hard",
|
||||||
"arg_number": 1,
|
"arg_number": 1,
|
||||||
"description": "Reset current label to the specified commit."
|
"description": "Move the branch you're on to the specified commit."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "cherry-pick",
|
"id": "cherry-pick",
|
||||||
|
|
|
@ -114,11 +114,13 @@ func dropped_on(other):
|
||||||
|
|
||||||
func try_play(full_command):
|
func try_play(full_command):
|
||||||
if game.energy >= energy:
|
if game.energy >= energy:
|
||||||
|
var terminal = $"../../../..".terminal
|
||||||
|
terminal.send_command(full_command)
|
||||||
|
#yield(terminal, "command_done")
|
||||||
$PlaySound.play()
|
$PlaySound.play()
|
||||||
var particles = preload("res://scenes/card_particles.tscn").instance()
|
var particles = preload("res://scenes/card_particles.tscn").instance()
|
||||||
particles.position = position
|
particles.position = position
|
||||||
get_parent().add_child(particles)
|
get_parent().add_child(particles)
|
||||||
$"../../../..".terminal.send_command(full_command)
|
|
||||||
buuurn()
|
buuurn()
|
||||||
game.energy -= energy
|
game.energy -= energy
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -20,7 +20,7 @@ func load(path):
|
||||||
|
|
||||||
title = config.get("title", slug)
|
title = config.get("title", slug)
|
||||||
description = config.get("description", "(no description)")
|
description = config.get("description", "(no description)")
|
||||||
congrats = config.get("congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next Level'.")
|
congrats = config.get("congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next level'.")
|
||||||
cards = Array(config.get("cards", "checkout commit-auto merge rebase rebase-interactive reset-hard cherry-pick").split(" "))
|
cards = Array(config.get("cards", "checkout commit-auto merge rebase rebase-interactive reset-hard cherry-pick").split(" "))
|
||||||
|
|
||||||
var keys = config.keys()
|
var keys = config.keys()
|
||||||
|
@ -53,7 +53,7 @@ func load(path):
|
||||||
elif dir.file_exists(path+"/description"):
|
elif dir.file_exists(path+"/description"):
|
||||||
# This is an old-style level.
|
# This is an old-style level.
|
||||||
description = helpers.read_file(path+"/description", "(no description)")
|
description = helpers.read_file(path+"/description", "(no description)")
|
||||||
congrats = helpers.read_file(path+"/congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next Level'.")
|
congrats = helpers.read_file(path+"/congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next level'.")
|
||||||
|
|
||||||
var yours = LevelRepo.new()
|
var yours = LevelRepo.new()
|
||||||
yours.setup_commands = helpers.read_file(path+"/start", "")
|
yours.setup_commands = helpers.read_file(path+"/start", "")
|
||||||
|
|
|
@ -129,13 +129,13 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="NextLevelButton" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"]
|
[node name="NextLevelButton" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"]
|
||||||
margin_left = 406.0
|
margin_left = 406.0
|
||||||
margin_right = 516.0
|
margin_right = 511.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 35.0
|
||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
custom_styles/hover = SubResource( 1 )
|
custom_styles/hover = SubResource( 1 )
|
||||||
custom_styles/normal = ExtResource( 4 )
|
custom_styles/normal = ExtResource( 4 )
|
||||||
enabled_focus_mode = 0
|
enabled_focus_mode = 0
|
||||||
text = "Next Level"
|
text = "Next level"
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ margin_right = 633.0
|
||||||
margin_bottom = 782.0
|
margin_bottom = 782.0
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
size_flags_stretch_ratio = 0.75
|
size_flags_stretch_ratio = 0.75
|
||||||
title = "Working directory"
|
title = "Current environment"
|
||||||
|
|
||||||
[node name="Controls" type="HBoxContainer" parent="Rows"]
|
[node name="Controls" type="HBoxContainer" parent="Rows"]
|
||||||
margin_top = 790.0
|
margin_top = 790.0
|
||||||
|
|
|
@ -46,14 +46,14 @@ func apply_forces():
|
||||||
var offset = Vector2(-80, 0)
|
var offset = Vector2(-80, 0)
|
||||||
|
|
||||||
for c in children.keys():
|
for c in children.keys():
|
||||||
if type == "ref" or type == "head":
|
# if type == "ref" or type == "head":
|
||||||
offset = Vector2(0, 80)
|
# offset = Vector2(0, 80)
|
||||||
if repository.objects.has(c):
|
if repository.objects.has(c):
|
||||||
var other = repository.objects[c]
|
var other = repository.objects[c]
|
||||||
if other.visible:
|
if other.visible:
|
||||||
var d = other.position.distance_to(position+offset)
|
var d = other.position.distance_to(position+offset)
|
||||||
var dir = (other.position - (position+offset)).normalized()
|
var dir = (other.position - (position+offset)).normalized()
|
||||||
var f = (d*0.12)
|
var f = (d*0.06)
|
||||||
position += dir*f
|
position += dir*f
|
||||||
other.position -= dir*f
|
other.position -= dir*f
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue