From c99a35d54f7778c17328ea63d5f5299e7e3465f6 Mon Sep 17 00:00:00 2001 From: blinry Date: Thu, 7 Jan 2021 12:57:31 +0100 Subject: [PATCH] Reorder levels and chapters into a better sequence --- README.md | 3 +- levels/{time-machine => bisect}/bisect | 0 .../{time-machine => branches}/branch-create | 0 .../{time-machine => branches}/branch-remove | 0 levels/{time-machine => branches}/branches | 0 levels/{time-machine => branches}/branching | 0 .../rebase | 0 .../reorder | 0 .../{time-machine => changing-the-past}/split | 0 .../{time-machine => changing-the-past}/steps | 0 levels/contrib/template | 33 -------------- levels/experiments/bad-layout | 32 -------------- levels/experiments/commit | 26 ----------- levels/experiments/conflict | 43 ------------------- levels/experiments/pull-merge-push | 29 ------------- levels/experiments/rebase | 20 --------- levels/experiments/sandbox | 8 ---- levels/experiments/sequence | 1 - levels/{time-machine => files}/files-add | 0 levels/{time-machine => files}/files-delete | 0 levels/{time-machine => files}/files-move | 0 levels/high-level/first-remote | 33 -------------- levels/{high-level/restore => intro/checkout} | 18 +++----- .../{time-machine => intro}/checkout-commit | 0 levels/intro/first-remote | 39 +++++++++++++++++ levels/{time-machine => intro}/init | 0 levels/{high-level => intro}/motivation | 19 ++++---- levels/intro/restore | 28 ++++++++++++ levels/{high-level => intro}/sequence | 2 + levels/{high-level => intro}/setup | 23 +++++----- levels/{time-machine => merge}/conflict | 0 levels/{time-machine => merge}/merge | 0 levels/{time-machine => remotes}/friend | 0 levels/{time-machine => remotes}/pull-push | 0 levels/sandbox/empty | 3 ++ .../sandbox => sandbox/three-commits} | 8 +--- levels/sequence | 9 +++- levels/time-machine/sequence | 13 ------ resources/cards.json | 18 ++++++-- scenes/main.gd | 8 ++-- 40 files changed, 128 insertions(+), 288 deletions(-) rename levels/{time-machine => bisect}/bisect (100%) rename levels/{time-machine => branches}/branch-create (100%) rename levels/{time-machine => branches}/branch-remove (100%) rename levels/{time-machine => branches}/branches (100%) rename levels/{time-machine => branches}/branching (100%) rename levels/{time-machine => changing-the-past}/rebase (100%) rename levels/{time-machine => changing-the-past}/reorder (100%) rename levels/{time-machine => changing-the-past}/split (100%) rename levels/{time-machine => changing-the-past}/steps (100%) delete mode 100644 levels/contrib/template delete mode 100644 levels/experiments/bad-layout delete mode 100644 levels/experiments/commit delete mode 100644 levels/experiments/conflict delete mode 100644 levels/experiments/pull-merge-push delete mode 100644 levels/experiments/rebase delete mode 100644 levels/experiments/sandbox delete mode 100644 levels/experiments/sequence rename levels/{time-machine => files}/files-add (100%) rename levels/{time-machine => files}/files-delete (100%) rename levels/{time-machine => files}/files-move (100%) delete mode 100644 levels/high-level/first-remote rename levels/{high-level/restore => intro/checkout} (56%) rename levels/{time-machine => intro}/checkout-commit (100%) create mode 100644 levels/intro/first-remote rename levels/{time-machine => intro}/init (100%) rename levels/{high-level => intro}/motivation (70%) create mode 100644 levels/intro/restore rename levels/{high-level => intro}/sequence (53%) rename levels/{high-level => intro}/setup (54%) rename levels/{time-machine => merge}/conflict (100%) rename levels/{time-machine => merge}/merge (100%) rename levels/{time-machine => remotes}/friend (100%) rename levels/{time-machine => remotes}/pull-push (100%) create mode 100644 levels/sandbox/empty rename levels/{time-machine/sandbox => sandbox/three-commits} (93%) delete mode 100644 levels/time-machine/sequence diff --git a/README.md b/README.md index c0897cc..7e4aa73 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,7 @@ Wanna build your own level? Great! Here's how to do it: 1. Run the game – the easiest way to do so is to run `godot scenes/main.tscn` from the project directory. 1. Get a bit familiar with the levels which are currently there. 1. Take a look into the `levels` directory. It's split into chapters, and each level is a file. -1. Make a copy of an existing level or start writing your own. See the documention of the format below. Put your level in the `contrib` chapter. -1. The dropdowns in the game will automatically refresh to contain your level, you don't need to restart the game. +1. Make a copy of an existing level or start writing your own. See the documention of the format below. 1. Write and test your level. If you're happy with it, feel free to send it to us in a pull request! <3 ### Level format diff --git a/levels/time-machine/bisect b/levels/bisect/bisect similarity index 100% rename from levels/time-machine/bisect rename to levels/bisect/bisect diff --git a/levels/time-machine/branch-create b/levels/branches/branch-create similarity index 100% rename from levels/time-machine/branch-create rename to levels/branches/branch-create diff --git a/levels/time-machine/branch-remove b/levels/branches/branch-remove similarity index 100% rename from levels/time-machine/branch-remove rename to levels/branches/branch-remove diff --git a/levels/time-machine/branches b/levels/branches/branches similarity index 100% rename from levels/time-machine/branches rename to levels/branches/branches diff --git a/levels/time-machine/branching b/levels/branches/branching similarity index 100% rename from levels/time-machine/branching rename to levels/branches/branching diff --git a/levels/time-machine/rebase b/levels/changing-the-past/rebase similarity index 100% rename from levels/time-machine/rebase rename to levels/changing-the-past/rebase diff --git a/levels/time-machine/reorder b/levels/changing-the-past/reorder similarity index 100% rename from levels/time-machine/reorder rename to levels/changing-the-past/reorder diff --git a/levels/time-machine/split b/levels/changing-the-past/split similarity index 100% rename from levels/time-machine/split rename to levels/changing-the-past/split diff --git a/levels/time-machine/steps b/levels/changing-the-past/steps similarity index 100% rename from levels/time-machine/steps rename to levels/changing-the-past/steps diff --git a/levels/contrib/template b/levels/contrib/template deleted file mode 100644 index 90d5e4f..0000000 --- a/levels/contrib/template +++ /dev/null @@ -1,33 +0,0 @@ -title = This is the level's title - -[description] - -This text will be shown when the level starts. - -It describes the task or puzzle the player can solve. - -[congrats] - -This text will be shown after the player has solved the level. - -Can contain additional information, or bonus exercises. - -[setup] - -# Bash commands that set up the initial state of the level. An initial -# `git init` is always done automatically. The default branch is called `main`. - -echo You > people_who_are_awesome -git add . -git commit -m "Initial commit" - -[win] - -# Bash commands that check whether the level is solved. Write these as if you're -# writing the body of a Bash function. Make the function return 0 if it's -# solved, and a non-zero value otherwise. You can use `return`, and also, Bash -# functions return the exit code of the last statement, which sometimes allows -# very succinct checks. - -# Check whether the file has at least two lines in the latest commit: -test "$(git show HEAD:people_who_are_awesome | wc -l)" -ge 2 diff --git a/levels/experiments/bad-layout b/levels/experiments/bad-layout deleted file mode 100644 index fbe91f9..0000000 --- a/levels/experiments/bad-layout +++ /dev/null @@ -1,32 +0,0 @@ -[setup] - -git commit --allow-empty -m "fu" -git commit --allow-empty -m "fu" -git commit --allow-empty -m "fu" -git commit --allow-empty -m "fu" -git commit --allow-empty -m "fu" -git commit --allow-empty -m "fu" - -git branch branch1 -git checkout HEAD~4 - -git commit --allow-empty -m "fa" -git commit --allow-empty -m "fa" - -git branch branch2 -git checkout HEAD~2 - -git commit --allow-empty -m "fi" -git commit --allow-empty -m "fi" -git commit --allow-empty -m "fi" -git commit --allow-empty -m "fi" -git commit --allow-empty -m "fi" -git commit --allow-empty -m "fi" -git commit --allow-empty -m "fi" - -git branch branch3 - -git checkout main -git merge branch1 -git merge branch2 -git merge branch3 diff --git a/levels/experiments/commit b/levels/experiments/commit deleted file mode 100644 index f25ed1c..0000000 --- a/levels/experiments/commit +++ /dev/null @@ -1,26 +0,0 @@ -[description] - -So you've been working on a project for a while, and decide you want to put it in a Git repository. - -Here's how to do it! First, you initialize a new Git repository in your current directory: - - git init - -Then say that you want to record the current state of all files: - - git add . - -And then you make a commit, which gives the current state a description, a date, and your name: - - git commit - -[setup] - -mkdir recipes -echo -e "blueberries\nflour" > recipes/blueberry_cake.txt -echo -e "water\ncarrots" > recipes/carrot soup.txt -echo "Very good recipes!" > README.md - -[win] - -test "$(git rev-parse HEAD^{tree})" = 1e02e3151284d0e22cd9b07ca5c5dbae2f3cb521 diff --git a/levels/experiments/conflict b/levels/experiments/conflict deleted file mode 100644 index cffe295..0000000 --- a/levels/experiments/conflict +++ /dev/null @@ -1,43 +0,0 @@ -[description] - -(This is not a real puzzle yet.) - -Try merging the two branches together! - - git merge - -[setup] - -echo ? > bikeshed_color -git add . -git commit -m "Initial commit" - -echo green > bikeshed_color -git commit -a -m "My suggestion" - -git switch -c alternative HEAD^ -echo blue > bikeshed_color -git commit -a -m "This is way better" - -git switch main - -[setup goal] - -echo ? > bikeshed_color -git add . -git commit -m "Initial commit" - -echo green > bikeshed_color -git commit -a -m "My suggestion" - -git switch -c alternative HEAD^ -echo blue > bikeshed_color -git commit -a -m "This is way better" - -git switch main - -git merge alternative -echo blue-green > bikeshed_color -git add . -git commit -m "Merge" -git prune diff --git a/levels/experiments/pull-merge-push b/levels/experiments/pull-merge-push deleted file mode 100644 index 16585e7..0000000 --- a/levels/experiments/pull-merge-push +++ /dev/null @@ -1,29 +0,0 @@ -[description] - -You want to push your new commits to the server, but someone has already pushed their own changes. - -In this situation, you need to pull first! Try that here - you'll have to resolve a merge conflict. Push your changes afterwards. - -[congrats] - -Good job! Here's some additional info: banana! - -[setup yours] - -echo fu > file -git add . -git commit -m "Initial commit" -git push -u origin main - -echo fi > file -git commit -a -m "Fi is good" - -[setup origin] - -echo fa > file -git add . -git commit -a -m "Fa is good" - -[win origin] - -test "$(git rev-parse HEAD^1^)" = "$(git rev-parse HEAD^2^)" diff --git a/levels/experiments/rebase b/levels/experiments/rebase deleted file mode 100644 index 9a46e7f..0000000 --- a/levels/experiments/rebase +++ /dev/null @@ -1,20 +0,0 @@ -description = Rebase all branches on top of the main branch, so that the commits are in alphabetical order, and then point the main branch to the top commit. - -[setup] - -git commit --allow-empty -m A -git commit --allow-empty -m B -git commit --allow-empty -m C - -git switch -c side1 main~1 -git commit --allow-empty -m D -git commit --allow-empty -m E - -git switch -c side2 main~2 -git commit --allow-empty -m F - -git checkout main - -[win] - -diff <(git log --pretty=%s main) <(echo -e "F\nE\nD\nC\nB\nA") diff --git a/levels/experiments/sandbox b/levels/experiments/sandbox deleted file mode 100644 index 68052c8..0000000 --- a/levels/experiments/sandbox +++ /dev/null @@ -1,8 +0,0 @@ -[setup local] - -git commit --allow-empty -m "1" -git commit --allow-empty -m "2" -git commit --allow-empty -m "3" -git push -u origin main - -[setup origin] diff --git a/levels/experiments/sequence b/levels/experiments/sequence deleted file mode 100644 index b04600a..0000000 --- a/levels/experiments/sequence +++ /dev/null @@ -1 +0,0 @@ -sandbox diff --git a/levels/time-machine/files-add b/levels/files/files-add similarity index 100% rename from levels/time-machine/files-add rename to levels/files/files-add diff --git a/levels/time-machine/files-delete b/levels/files/files-delete similarity index 100% rename from levels/time-machine/files-delete rename to levels/files/files-delete diff --git a/levels/time-machine/files-move b/levels/files/files-move similarity index 100% rename from levels/time-machine/files-move rename to levels/files/files-move diff --git a/levels/high-level/first-remote b/levels/high-level/first-remote deleted file mode 100644 index 7ebb065..0000000 --- a/levels/high-level/first-remote +++ /dev/null @@ -1,33 +0,0 @@ -title = Your first remote - -[description] - -A friend has asked you to help with an essay about hobbies! She has already started to write a list, started tracking it in a Git repository. You can get a copy by typing - - git pull friend main - -Help her by adding at least two more items to the list! When you're done, commit your result and use - - git push friend main - -to send it to her copy of the repository! - -[congrats] - -"Thanks, these are some really nice hobbies! Hope we can do that together soon!" - -[setup] - -[setup friend] - -echo "~ Best hobbies ~ - -- Collecting stamps -- Looking at clouds" >> hobbies.txt - -git add . -git commit -m "Initial list (I definitely need more)" - -[win friend] - -test "$(git show HEAD:hobbies.txt |wc -l)" -ge 6 diff --git a/levels/high-level/restore b/levels/intro/checkout similarity index 56% rename from levels/high-level/restore rename to levels/intro/checkout index 6bb93f7..9d9c957 100644 --- a/levels/high-level/restore +++ b/levels/intro/checkout @@ -1,18 +1,11 @@ -title = Looking into the past +title = Getting the last version +cards = checkout-file [description] -You've been working on your essay for a while. But - ughh! Now your cat walks over your keyboard and "helps you", so now it's all messed up again! :/ +You've been working on your essay for a while. But - ughh! Now your cat walks over your keyboard and "helps you", so now it's all messed up! :/ -To restore your essay from the last backup, type: - - git checkout essay.txt - -To restore an older version, for example, from two backups before the latest one, type: - - git checkout HEAD~2 essay.txt - -For nostalgic reasons, restore the very first backup you made! +But Git is here to help! To discard all changes your cat made, and go back to the version in the last commit, use `checkout`! [setup] @@ -34,4 +27,5 @@ blaaaargh" > essay.txt [win] -diff essay.txt <(echo "A") +# Restore the version from the last commit. +cat essay.txt | grep D diff --git a/levels/time-machine/checkout-commit b/levels/intro/checkout-commit similarity index 100% rename from levels/time-machine/checkout-commit rename to levels/intro/checkout-commit diff --git a/levels/intro/first-remote b/levels/intro/first-remote new file mode 100644 index 0000000..b8c91bc --- /dev/null +++ b/levels/intro/first-remote @@ -0,0 +1,39 @@ +title = Working together +cards = pull commit-auto push + +[description] + +A friend has asked you to help with an essay about hobbies! She has already started to write a list, started tracking it in a Git repository. You can get a copy by using `git pull`! + + +[congrats] + +"Thanks, these are some really nice hobbies! Hope we can do that together soon!" + +[setup] + +echo "~ Best hobbies ~" > hobbies.txt +git add . +git commit -m "Initial version" + +git push -u friend main + +[setup friend] + +git checkout main +echo " +- Collecting stamps +- Looking at clouds" >> hobbies.txt + +git add . +git commit -m "Added two hobbies" + +[win] + +# Help her by adding at least two more items to the list! +test "$(cat hobbies.txt |wc -l)" -ge 6 + +[win friend] + +# When you're done, commit your result and use `git push` to send it to her copy of the repository! +test "$(git show main:hobbies.txt |wc -l)" -ge 6 diff --git a/levels/time-machine/init b/levels/intro/init similarity index 100% rename from levels/time-machine/init rename to levels/intro/init diff --git a/levels/high-level/motivation b/levels/intro/motivation similarity index 70% rename from levels/high-level/motivation rename to levels/intro/motivation index 690fcfe..a4817b6 100644 --- a/levels/high-level/motivation +++ b/levels/intro/motivation @@ -1,15 +1,12 @@ title = Why Git? +cards = file-copy [description] -(This chapter is not a complete introduction to Git yet, but it will explain some of the basic concepts to you.) - So you've been working on an essay about goldfish. You can look at the backup copies you made by clicking on them! But look - something went wrong in the latest version of the file! Maybe it has been infected with a vowel-eating virus? -Make a new version (with the number 5) from the last version that's still okay, and add at least two more lines to it! - [congrats] Good that you had that backup, huh? @@ -26,27 +23,31 @@ rm -rf .git echo "~ Why goldfish are the best pets ~ -(I still need to write this.)" >> essay_1.txt +(I still need to write this.)" >> essay1.txt echo "~ Why goldfish are the best pets ~ - They don't make any noise. -- They are pretty. (I should probably put this higher in the list?)" >> essay_2.txt +- They are pretty. (I should probably put this higher in the list?)" >> essay2.txt echo "~ Why goldfish are the best pets ~ - They are pretty. - They don't pee on the carpet. -- They don't make any noise." >> essay_3.txt +- They don't make any noise." >> essay3.txt echo "~ Why gldfsh r th bst pts ~ - Thy r prtty. - Thy dn't p n th crpt. -- Thy dn't mk ny ns." >> essay_4.txt +- Thy dn't mk ny ns." >> essay4.txt [win] -test "$(cat *5.txt | wc -l )" -ge 7 && grep carpet *5.txt +# Make a new version (with the number 5) from the last version that's still okay +cat essay5.txt | grep carpet + +# And add at least two more lines to it! +test "$(cat essay5.txt | wc -l )" -ge 7 diff --git a/levels/intro/restore b/levels/intro/restore new file mode 100644 index 0000000..1f9961e --- /dev/null +++ b/levels/intro/restore @@ -0,0 +1,28 @@ +title = Looking into the past +cards = checkout-from + +[description] + +You've been working on your essay for a while. But you're not happy with the changes you've made recently. You want to go back to the version called "Best version"! + +No problem, you can use the `checkout` card to restore your essay from an older commit! + +[setup] + +echo "Initial version" > essay.txt +git add . +git commit -m "Initial commit" + +echo "Improved version" > essay.txt +git commit -a -m "Improved version" + +echo "Best version" > essay.txt +git commit -a -m "Best version" + +echo "Less-good version" > essay.txt +git commit -a -m "Less-good version" + +[win] + +# For nostalgic reasons, restore the very first backup you made! +diff essay.txt <(echo "Best version") diff --git a/levels/high-level/sequence b/levels/intro/sequence similarity index 53% rename from levels/high-level/sequence rename to levels/intro/sequence index 6c6c634..7cfdc9f 100644 --- a/levels/high-level/sequence +++ b/levels/intro/sequence @@ -1,3 +1,5 @@ motivation setup +checkout restore +first-remote diff --git a/levels/high-level/setup b/levels/intro/setup similarity index 54% rename from levels/high-level/setup rename to levels/intro/setup index e6678bc..cc9126b 100644 --- a/levels/high-level/setup +++ b/levels/intro/setup @@ -1,4 +1,5 @@ title = A better way +cards = init commit-auto [description] @@ -6,18 +7,11 @@ One month later, you're woking on an essay about tardigrades! This time, a friend has recommended that you use the version control system Git to keep backups of your file. -Currently, your directory only contains your essay. To initialize a Git repository in your directory, type: +Currently, your directory only contains your essay. To initialize a Git repository in your directory, use the `init` card! - git init +Then, each time you want to make a backup, use the `commit` card! -Then, each time you want to make a backup, type: - - git add essay.txt - git commit - -Enter a description of what you changed in the editor that opens and click save. - -That way, you've made a backup of the current version of the file. Then add at least two more lines, and make another backup by repeating the add and the commit commands. +That way, you've made a backup of the current version of the file. [setup] @@ -30,4 +24,11 @@ echo "~ Why tardigrades are cool ~ [win] -test -d .git && git rev-parse HEAD^ && test "$(git show HEAD:essay.txt | wc -l)" -ge 6 +# Initialize a Git repository +test -d .git + +# And make another commit +test -d .git && git rev-parse HEAD^ + +# Add at least two more lines. +test "$(git show HEAD:essay.txt | wc -l)" -ge 6 diff --git a/levels/time-machine/conflict b/levels/merge/conflict similarity index 100% rename from levels/time-machine/conflict rename to levels/merge/conflict diff --git a/levels/time-machine/merge b/levels/merge/merge similarity index 100% rename from levels/time-machine/merge rename to levels/merge/merge diff --git a/levels/time-machine/friend b/levels/remotes/friend similarity index 100% rename from levels/time-machine/friend rename to levels/remotes/friend diff --git a/levels/time-machine/pull-push b/levels/remotes/pull-push similarity index 100% rename from levels/time-machine/pull-push rename to levels/remotes/pull-push diff --git a/levels/sandbox/empty b/levels/sandbox/empty new file mode 100644 index 0000000..ab578f3 --- /dev/null +++ b/levels/sandbox/empty @@ -0,0 +1,3 @@ +title = Empty sandbox + +[setup] diff --git a/levels/time-machine/sandbox b/levels/sandbox/three-commits similarity index 93% rename from levels/time-machine/sandbox rename to levels/sandbox/three-commits index 36e04c2..7d8d22a 100644 --- a/levels/time-machine/sandbox +++ b/levels/sandbox/three-commits @@ -1,4 +1,4 @@ -title = Sandbox +title = Three commits [setup] @@ -14,11 +14,7 @@ git commit -am "Who's there?" git branch not_main -[win] - -test true - -[congrats] +[description] That's all for now! Here's a sandbox you can play around in. diff --git a/levels/sequence b/levels/sequence index df36100..c569414 100644 --- a/levels/sequence +++ b/levels/sequence @@ -1,6 +1,11 @@ -stash +intro +files index +branches +merge +tags remotes +changing-the-past shit-happens -time-machine +stash low-level diff --git a/levels/time-machine/sequence b/levels/time-machine/sequence deleted file mode 100644 index 4e85a99..0000000 --- a/levels/time-machine/sequence +++ /dev/null @@ -1,13 +0,0 @@ -init -checkout-commit -branching -merge -branches -conflict -pull-push -rebase -reorder -bisect -steps -split -sandbox diff --git a/resources/cards.json b/resources/cards.json index 4dfea4b..d6e38a8 100644 --- a/resources/cards.json +++ b/resources/cards.json @@ -6,8 +6,13 @@ }, { "id": "checkout", - "command": "git checkout [commit, ref, file]", - "description": "Drag this card to a commit or to a branch to travel to it!\n\nAlternatively, reset changes in a local file." + "command": "git checkout [commit, ref]", + "description": "Drag this card to a commit or to a branch to travel to it!" + }, + { + "id": "checkout-file", + "command": "git checkout [file]", + "description": "Reset changes in a local file." }, { "id": "checkout-from", @@ -21,8 +26,8 @@ }, { "id": "commit-auto", - "command": "git add .; git commit", - "description": "Make a new commit containing your current environment!\nYou'll be asked to enter a short description of what you changed." + "command": "git add .; git commit -m \"New commit\"", + "description": "Make a new commit containing your current environment!" }, { "id": "merge", @@ -143,5 +148,10 @@ "id": "file-rename", "command": "mv [file] [string]", "description": "Rename a new file." + }, + { + "id": "file-copy", + "command": "cp [file] [string]", + "description": "Make a copy of a file." } ] diff --git a/scenes/main.gd b/scenes/main.gd index 3fa3a30..36109a2 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -72,10 +72,10 @@ func load_level(level_id): level_description.bbcode_text = level.description[0] level_congrats.bbcode_text = level.congrats level_name.text = level.title - if levels.chapters[game.current_chapter].levels[game.current_level].cards.size() == 0: - cards.redraw_all_cards() - else: - cards.draw(levels.chapters[game.current_chapter].levels[game.current_level].cards) + #if levels.chapters[game.current_chapter].levels[game.current_level].cards.size() == 0: + # cards.redraw_all_cards() + #else: + cards.draw(levels.chapters[game.current_chapter].levels[game.current_level].cards) for r in repositories_node.get_children(): r.queue_free()