├── Enter ├── corridor │ ├── .first_chamber │ │ ├── .2nd_chamber │ │ │ ├── .garden_of_mitra │ │ │ │ ├── .PS1 │ │ │ │ │ └── parchment │ │ │ │ ├── .room1 │ │ │ │ │ ├── .room2 │ │ │ │ │ │ ├── .chamber_of_loss │ │ │ │ │ │ │ ├── BEHOLD_THE_DANGER_OF_RM │ │ │ │ │ │ │ ├── lever │ │ │ │ │ │ │ └── word_of_power │ │ │ │ │ │ ├── TIP │ │ │ │ │ │ ├── parchment │ │ │ │ │ │ └── vault │ │ │ │ │ ├── .shop │ │ │ │ │ │ ├── parchment │ │ │ │ │ │ ├── scroll_of_knowledge │ │ │ │ │ │ └── shopkeeper │ │ │ │ │ ├── LoremIpsum │ │ │ │ │ ├── chest │ │ │ │ │ ├── parchement │ │ │ │ │ └── word_of_power │ │ │ │ ├── long_sword │ │ │ │ ├── parchment │ │ │ │ ├── scroll_of_knowledge │ │ │ │ ├── thorns │ │ │ │ └── word_of_power │ │ │ ├── HINT │ │ │ ├── chest │ │ │ ├── parchment │ │ │ └── poem │ │ ├── parchment │ │ ├── rat │ │ └── short_sword │ ├── chest │ ├── parchment │ ├── parchment_2 │ └── spell └── parchment ├── LICENSE └── README.md /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.PS1/parchment: -------------------------------------------------------------------------------- 1 | _________________________________________________________________________________ 2 | /\ \ 3 | \_| | 4 | | By now, your prompt must be extremely long and annoying to work with. | 5 | | | 6 | | The prompt is the text to left of where your cursor is in your terminal. | 7 | | | 8 | | The prompt is set from the PS1 variable. | 9 | | | 10 | | We can change it and customize it to our hearts content. | 11 | | | 12 | | For now, lets make the current prompt tell the cursor to jump down a line | 13 | | | 14 | | so that you can type easier. | 15 | | | 16 | | Enter this spell: | 17 | | « export PS1=$PS1'\n' » | 18 | | | 19 | | Now you can type below your prompt | 20 | | | 21 | | We didn't want to change your current prompt info, so we just added a '\n' to | 22 | | | 23 | | the end of it. | 24 | | | 25 | | You can make this change permenant in the '~/.bashrc' | 26 | | ____________________________________________________________________________|_ 27 | \_/______________________________________________________________________________/ 28 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.room2/.chamber_of_loss/BEHOLD_THE_DANGER_OF_RM: -------------------------------------------------------------------------------- 1 | 'rm' is the command we use to delete things in the shell. 2 | 3 | 'rm' is a very powerful command that can remove files and directories 4 | 5 | Completely from your filesystem. 6 | 7 | Meaning that they wont end up in a trash can! They will be gone! 8 | 9 | FOREVER AND EVER! 10 | 11 | To delete a directory with all of its contents, we can use: 12 | 13 | « rm -rf dir » 14 | 15 | The -f flag means that it will force remove everything and the -r 16 | 17 | stands for recursively removing everything. 18 | 19 | We can make this dangerous command slightly safer by doing: 20 | 21 | « rm -ri dir » 22 | 23 | The -i flag makes the 'rm' command interactive. 24 | 25 | It will ask you every time if it should remove something. 26 | 27 | There is yet a safer way to remove things that allows us to 28 | 29 | restore them if we make a mistake. 30 | 31 | Install the following package from your distro's package manager. 32 | 33 | 'trash-cli' 34 | 35 | Next time you want to delete something, use: 36 | 37 | « trash-put file or dir » 38 | 39 | And if you want to restore it later, use: 40 | 41 | « trash-restore » 42 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.room2/.chamber_of_loss/lever: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir ../../../cellar 2>/dev/null 4 | 5 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.room2/.chamber_of_loss/word_of_power: -------------------------------------------------------------------------------- 1 | ------------------------------------------- 2 | -- word of power is 'alias' -- 3 | -- -- 4 | -- Use it to make nicknames for commands -- 5 | -- -- 6 | -- Example: -- 7 | -- -- 8 | -- alias rm='trash-put' -- 9 | ------------------------------------------- 10 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.room2/TIP: -------------------------------------------------------------------------------- 1 | 2 | The first commandline argument is $1, the second $2 and so on ... 3 | 4 | Example: 5 | script.sh arg1 arg2 arg3 ... 6 | 7 | Now you know what to do when a script asks for a $1 ;) 8 | 9 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.room2/parchment: -------------------------------------------------------------------------------- 1 | ________________________________________________________________________ 2 | /\ \ 3 | \_| Bash can perform integer arithmetics very well. | 4 | | | 5 | | But when it comes to floating point arithmetics, it's a bit lacking. | 6 | | | 7 | | There are however, workarounds. | 8 | | | 9 | | The most common one is to 'echo' the operation into « bc -l » | 10 | | | 11 | | Try this now: | 12 | | | 13 | | « echo 12 / 2.2 | bc -l » | 14 | | | 15 | | Use this knowledge to open the vault and progress. | 16 | | ___________________________________________________________________|_ 17 | \_/_____________________________________________________________________/ 18 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.room2/vault: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | key="76.45161290322580645161" 4 | : 237 / 3.1 5 | 6 | if [[ $1 != $key ]]; then 7 | echo -e "You must enter the correct floating point key value\n" 8 | echo -e "Enter the result of 237 / 3.1 as \$1\n" 9 | else 10 | echo -e "Well done! Collect your loot!\n" 11 | fi 12 | 13 | 14 | mv .chamber_of_loss chamber_of_loss 2>/dev/null 15 | 16 | cat <<'EOF' > functions 17 | A shell function, stores a 18 | 19 | series of commands for later execution. 20 | 21 | When the name of a shell function is 22 | 23 | used as a simple command name, 24 | 25 | the list of commands associated with that 26 | 27 | function name is executed. 28 | 29 | As an example, we can create a function that lists 30 | 31 | the directory contents right after we 'cd' into it. 32 | 33 | ``` 34 | cs () 35 | { 36 | cd $* && ls 37 | } 38 | ``` 39 | to type that in a single line: 40 | 41 | « cs() { cd $* && ls; } » 42 | 43 | type the above line into your terminal and use the 'cs' 44 | 45 | command to 'cd' into the chamber_of_loss directory 46 | EOF 47 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.shop/parchment: -------------------------------------------------------------------------------- 1 | ______________________________________________________________________ 2 | /\ \ 3 | \_| | 4 | | Sourcing, in bash, is the act of making functions and variables | 5 | | | 6 | | that live inside a script, available at your current bash session. | 7 | | | 8 | | Meaning that the variables and functions that are written inside a | 9 | | | 10 | | shell script, can also be accessed from your normal terminal. | 11 | | | 12 | | Sourcing a bash script in essence, changes the shell behavior. | 13 | | | 14 | | The syntax of sourcing is as follows: | 15 | | | 16 | | « source script.sh » | 17 | | or | 18 | | « . script.sh » | 19 | | | 20 | | Now proceed with executing the shopkeeper while sourcing it. | 21 | | | 22 | | The script will be able to export the proper Gold balance once | 23 | | | 24 | | it is sourced. | 25 | | | 26 | | Otherwise, no matter how much Gold you spend, the output of | 27 | | | 28 | | « echo $gold » | 29 | | | 30 | | will remain 10 | 31 | | | 32 | | _________________________________________________________________|_ 33 | \_/___________________________________________________________________/ 34 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.shop/scroll_of_knowledge: -------------------------------------------------------------------------------- 1 | /"\/\_..------------------------------------------------------------------._/\/"\ 2 | ( _|| ||_ ) 3 | \_/\/ || Scripts in bash, run inside their own sub-shells and are not || \/\_/ 4 | || || 5 | || able to change the current shell's parameters or behavior. || 6 | || || 7 | || This is something you need to know early on, as it can become || 8 | || || 9 | || annoying in the future when you start writing your own scripts. || 10 | || || 11 | /"\/\_|-------------------------------------------------------------------|_/\/"\ 12 | ( _| |_ ) 13 | \_/\/ `-------------------------------------------------------------------' \/\_/ 14 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/.shop/shopkeeper: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mv ../.room2 ../room2 2>/dev/null 4 | (return 0 2>/dev/null) && sourced=1 || sourced=0 5 | if [[ $sourced == 0 ]]; then 6 | echo "YOU MUST SOURCE THIS SCRIPT" 7 | exit 1 8 | fi 9 | 10 | if [[ -z $gold ]]; then 11 | echo "YOU HAVE NOT SET YOUR GOLD VARIABLE!" 12 | fi 13 | 14 | write_dart() { 15 | cat <<'EOF' >dart 16 | Darts allow you to attack enemies from 17 | 18 | A distance without risking your HP. 19 | 20 | Add this item to your inventory, 21 | 22 | By now you should know how. 23 | 24 | EOF 25 | } 26 | 27 | write_portal() { 28 | cat <<'EOF' >portal 29 | We can create symlinks (symbolic links) in linux. 30 | 31 | symlinks are shortcuts to files, binaries or directories. 32 | 33 | Lets create a symlink from the poem you found a few dungeons back 34 | 35 | to the current directory. 36 | 37 | The spell for a symlink is: 38 | 39 | « ln -s original_path destination_path » 40 | 41 | Remember that « .. » means behind and « . » means here. 42 | 43 | Make a symlink with: 44 | 45 | « ln -s ../../../poem . » 46 | 47 | Then you can use 'cat' to read the poem right here, 48 | 49 | eventhough its three directories behind. 50 | EOF 51 | } 52 | 53 | write_poh() { 54 | cat <<'EOF' >potion_of_health 55 | Add this point, you should have two PoHs. 56 | 57 | You might want to create a dedicated variable 58 | 59 | to hold the value of how many PoHs you have. 60 | 61 | The game will check for $PoH from now on. 62 | 63 | By now, you should know how to do that. 64 | 65 | You can check how many PoHs you have with: 66 | 67 | « echo $PoH » 68 | EOF 69 | } 70 | 71 | write_pom() { 72 | cat <<'EOF' >potion_of_magic 73 | The PoM comes in handy in a future room. 74 | 75 | You might want to create a dedicated variable 76 | 77 | to hold the value of how many PoMs you have. 78 | 79 | The game will check for $PoM from now on. 80 | 81 | By now, you should know how to do that. 82 | 83 | You can check how many PoMs you have with: 84 | 85 | « echo $PoM » 86 | EOF 87 | } 88 | 89 | write_trick() { 90 | cat <<'EOF' >trick 91 | The shell uses emacs bindings by default. 92 | 93 | Emacs is the GNU editor and its a rather complicated one. 94 | 95 | We are only concered with a handful of emacs key bindings. 96 | 97 | Ctrl+l => Clear the screen 98 | Ctrl+u => Clear the entire line 99 | 100 | Ctrl+a => Jump to the start of line 101 | Ctrl+e => Jump to the end of line 102 | 103 | Alt+b => Jump back by a word 104 | Alt+f => Jump forward by a word 105 | 106 | These should be enough to get you started. 107 | EOF 108 | } 109 | 110 | echo -e "Welcome to the Bash Shop!\n" 111 | echo -e "Enter the number of the item\n" 112 | echo -e "Ctrl+C to exit\n" 113 | echo -e "What do you wish to buy?\n" 114 | select item in Dart Portal PoH PoM Trick; do 115 | case $item in 116 | Dart) 117 | price=2 118 | if [[ gold -ge 2 ]]; then write_dart; fi 119 | ;; 120 | Portal) 121 | price=4 122 | if [[ gold -ge 4 ]]; then write_portal; fi 123 | ;; 124 | PoH) 125 | price=9 126 | if [[ gold -ge 9 ]]; then write_poh; fi 127 | ;; 128 | PoM) 129 | price=10 130 | if [[ gold -ge 10 ]]; then write_pom; fi 131 | ;; 132 | Trick) 133 | price=3 134 | if [[ gold -ge 3 ]]; then write_trick; fi 135 | write_trick 136 | ;; 137 | *) 138 | echo "Invalid option. Please select a valid number." 139 | continue 140 | ;; 141 | esac 142 | 143 | echo "You selected $item." 144 | echo "Price: $price Gold" 145 | echo "Do you wish to purchase $item y/n?" 146 | read -r ans 147 | if [[ $ans == y ]] && [[ $gold -ge $price ]]; then 148 | ((gold -= price)) 149 | echo "You have $gold remaining Gold" 150 | else 151 | echo "You don't have enough Gold" 152 | echo "Be gone, peasant!" 153 | fi 154 | done 155 | 156 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/LoremIpsum: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at massa et 2 | est vulputate sollicitudin vitae at libero. Pellentesque iaculis neque diam, 3 | vulputate tempor est ullamcorper quis. Lorem ipsum dolor sit amet, consectetur 4 | adipiscing elit. Vivamus sed purus risus. Nunc vitae augue sit amet magna 5 | semper efficitur quis at erat. Suspendisse commodo sem at neque feugiat auctor. 6 | Praesent pretium tellus odio. Integer a facilisis nibh. Duis hendrerit nibh 7 | quis turpis vulputate aliquam id quis nibh. Suspendisse ut quam quis arcu 8 | sodales luctus. Ut id sagittis ex. Praesent facilisis velit blandit dictum 9 | luctus. Cras in erat malesuada nisi dignissim tempus. Ut in placerat tortor. 10 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at massa et 11 | est vulputate sollicitudin vitae at libero. Pellentesque iaculis neque diam, 12 | vulputate tempor est ullamcorper quis. Lorem ipsum dolor sit amet, consectetur 13 | adipiscing elit. Vivamus sed purus risus. Nunc vitae augue sit amet magna 14 | semper efficitur quis at erat. Suspendisse commodo sem at neque feugiat auctor. 15 | Praesent pretium tellus odio. Integer a facilisis nibh. Duis hendrerit nibh 16 | quis turpis vulputate aliquam id quis nibh. Suspendisse ut quam quis arcu 17 | sodales luctus. Ut id sagittis ex. Praesent facilisis velit blandit dictum 18 | luctus. Cras in erat malesuada nisi dignissim tempus. Ut in placerat tortor. 19 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at massa et 20 | est vulputate sollicitudin vitae at libero. Pellentesque iaculis neque diam, 21 | vulputate tempor est ullamcorper quis. Lorem ipsum dolor sit amet, consectetur 22 | adipiscing elit. Vivamus sed purus risus. Nunc vitae augue sit amet magna 23 | semper efficitur quis at erat. Suspendisse commodo sem at neque feugiat auctor. 24 | Praesent pretium tellus odio. Integer a facilisis nibh. Duis hendrerit nibh 25 | quis turpis vulputate aliquam id quis nibh. Suspendisse ut quam quis arcu 26 | sodales luctus. Ut id sagittis ex. Praesent facilisis velit blandit dictum 27 | luctus. Cras in erat malesuada nisi dignissim tempus. Ut in placerat tortor. 28 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at massa et 29 | est vulputate sollicitudin vitae at libero. Pellentesque iaculis neque diam, 30 | vulputate tempor est ullamcorper quis. Lorem ipsum dolor sit amet, consectetur 31 | adipiscing elit. Vivamus sed purus risus. Nunc vitae augue sit amet magna 32 | semper efficitur quis at erat. Suspendisse commodo sem at neque feugiat auctor. 33 | Praesent pretium tellus odio. Integer a facilisis nibh. Duis hendrerit nibh 34 | quis turpis vulputate aliquam id quis nibh. Suspendisse ut quam quis arcu 35 | sodales luctus. Ut id sagittis ex. Praesent facilisis velit blandit dictum 36 | luctus. Cras in erat malesuada nisi dignissim tempus. Ut in placerat tortor. 37 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at massa et 38 | est vulputate sollicitudin vitae at libero. Pellentesque iaculis neque diam, 39 | vulputate tempor est ullamcorper quis. Lorem ipsum dolor sit amet, consectetur 40 | adipiscing elit. Vivamus sed purus risus. Nunc vitae augue sit amet magna 41 | semper efficitur quis at erat. Suspendisse commodo sem at neque feugiat auctor. 42 | Praesent pretium tellus odio. Integer a facilisis nibh. Duis hendrerit nibh 43 | quis turpis vulputate Pass is: 256 aliquam id quis nibh. Suspendisse ut quam quis arcu 44 | sodales luctus. Ut id sagittis ex. Praesent facilisis velit blandit dictum 45 | luctus. Cras in erat malesuada nisi dignissim tempus. Ut in placerat tortor. 46 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at massa et 47 | est vulputate sollicitudin vitae at libero. Pellentesque iaculis neque diam, 48 | vulputate tempor est ullamcorper quis. Lorem ipsum dolor sit amet, consectetur 49 | adipiscing elit. Vivamus sed purus risus. Nunc vitae augue sit amet magna 50 | semper efficitur quis at erat. Suspendisse commodo sem at neque feugiat auctor. 51 | Praesent pretium tellus odio. Integer a facilisis nibh. Duis hendrerit nibh 52 | quis turpis vulputate aliquam id quis nibh. Suspendisse ut quam quis arcu 53 | sodales luctus. Ut id sagittis ex. Praesent facilisis velit blandit dictum 54 | luctus. Cras in erat malesuada nisi dignissim tempus. Ut in placerat tortor. 55 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/chest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo -e "This chest is locked!\nYou need the proper key to enter!" 4 | 5 | echo "Enter Key value: " 6 | read -r val 7 | 8 | unlock(){ 9 | lock_val=256 10 | if [[ $val != "$lock_val" ]]; then 11 | echo "Wrong!" 12 | exit 0 13 | else 14 | echo "Correct! You found a scroll of knowledge!" 15 | cat <<'EOF' >scroll_of_knowledge 16 | /"\/\_..-------------------------------------------------------------------------------._/\/"\ 17 | ( _|| ||_ ) 18 | \_/\/ || Piping is the act of sewing commands together to change their output. || \/\_/ 19 | || || 20 | || You have already used piping when you used: || 21 | || || 22 | || « cat poem | wc -l » || 23 | || || 24 | || In that spell, you piped the output of 'cat' to the input of 'wc -l' || 25 | || || 26 | || and you saw that instead of getting the entire poem in your terminal || 27 | || || 28 | || you got a line count. || 29 | || || 30 | || Almost everything in the shell is pipe-able. || 31 | || || 32 | || Now try to find out how you can make 'grep' case insensitive by || 33 | || || 34 | || piping « grep --help » to another instance of 'grep' that looks for the word || 35 | || || 36 | || 'case' || 37 | || || 38 | || « grep --help | grep 'case' » || 39 | || || 40 | || Then use that flag to look for the word 'pass' in the LoremIpsum file. || 41 | || || 42 | || Hint: || 43 | || « grep -i etc ... » || 44 | || || 45 | /"\/\_|--------------------------------------------------------------------------------|_/\/"\ 46 | ( _| |_ ) 47 | \_/\/ `--------------------------------------------------------------------------------' \/\_/ 48 | EOF 49 | 50 | fi 51 | mv .shop shop 2>/dev/null 52 | } 53 | unlock 54 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/parchement: -------------------------------------------------------------------------------- 1 | ____________________________________________________ 2 | /\ \ 3 | \_| In this tiny dim room, you find a word of power! | 4 | | | 5 | | Use it to unlock the chest and move forward! | 6 | | _______________________________________________|_ 7 | \_/_________________________________________________/ 8 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/.room1/word_of_power: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------- 2 | -- -- 3 | -- word of power is 'grep' -- 4 | -- -- 5 | -- 'grep' has so many qualities and functionalities. -- 6 | -- -- 7 | -- Think of it as 'grab' since we will use it to grab -- 8 | -- -- 9 | -- bits of information from files that are important to us. -- 10 | -- -- 11 | -- To make 'grep' more visually apealing, enter the following spell: -- 12 | -- -- 13 | -- « alias grep='grep --color=always' » -- 14 | -- -- 15 | -- There is a Pass key hidden inside the mess of giberish that is the LoremIpsum file. -- 16 | -- -- 17 | -- Use grep to find the line that contains that word. -- 18 | -- -- 19 | -- « grep 'word' filename » -- 20 | -- -- 21 | ----------------------------------------------------------------------------------------- 22 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/long_sword: -------------------------------------------------------------------------------- 1 | 2 | You found a long sword! 3 | 4 | Add it to your inventory. 5 | 6 | « export I=long_sword » 7 | 8 | You can view your inventory with: 9 | 10 | « echo $I » 11 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/parchment: -------------------------------------------------------------------------------- 1 | __________________________________________________________ 2 | /\ \ 3 | \_| | 4 | | This is the Garden of Mitra | 5 | | | 6 | | Here you will find many items of interest. | 7 | | | 8 | | We are now past the tutorial phase. | 9 | | | 10 | | set your HP variable to 100 and proceed with the game. | 11 | | | 12 | | « export HP=100 » | 13 | | | 14 | | | 15 | | _____________________________________________________|_ 16 | \_/_______________________________________________________/ 17 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/scroll_of_knowledge: -------------------------------------------------------------------------------- 1 | /"\/\_..--------------------------------------------------------------._/\/"\ 2 | ( _|| ||_ ) 3 | \_/\/ || So far you have learned to assign values to variables || \/\_/ 4 | || || 5 | || and print them with echo. || 6 | || || 7 | || You have probably also realized that assigning a new || 8 | || || 9 | || value to a variable overrides the previous value, || 10 | || || 11 | || which is the point of a variable. || 12 | || || 13 | || But what if you want to add a value to the already existing || 14 | || || 15 | || value in the variable? || 16 | || || 17 | || For example, you might want to keep the short sword and add || 18 | || || 19 | || the long sword to your inventory as well. || 20 | || || 21 | || In that case, use the following syntax: || 22 | || || 23 | || « export I=long_sword,$I » || 24 | || || 25 | || With that, the long_sword is added to your inventory and || 26 | || || 27 | || if you echo $I, you will see that both items are in there. || 28 | || || 29 | /"\/\_|---------------------------------------------------------------|_/\/"\ 30 | ( _| |_ ) 31 | \_/\/ `---------------------------------------------------------------' \/\_/ 32 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/thorns: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat < potioneer 25 | #!/usr/bin/env bash 26 | 27 | if [[ \$1 == poem ]]; then 28 | echo -e "Excellent!\n Here, Have a potion of health\n You should add it to your inventory\n" 29 | mv .PS1 PS1 2>/dev/null 30 | mv .room1 room1 2>/dev/null 31 | cat <<'INNER_EOF' > potion_of_health 32 | Potion of Health 33 | 34 | Add it to your inventory with: 35 | 36 | « export I=PoH,\$I » 37 | 38 | We will use 'PoH' since its shorter 39 | INNER_EOF 40 | exit 0 41 | fi 42 | 43 | echo -e "well hello there traveller!\n " 44 | echo -e "I am the potioneer\n" 45 | echo -e "Anything you desire\n" 46 | echo -e "I can brew\n" 47 | echo -e "But not for free of course\n" 48 | echo -e "and not for everyone!\n" 49 | echo -e "To you I shall sell a potion of health\n" 50 | echo -e "for I see that you are bleeding\n" 51 | echo -e "The price of which is cheap\n" 52 | echo -e "\tDo you wanna know? y/n \n" 53 | read -r ans 54 | 55 | if [[ \$ans == y ]]; then 56 | echo -e "Long ago on my way here, I read a poem, which I have forgotton\n" 57 | echo -e "If you bring it to me, I'll trade you for a potion\n" 58 | echo -e "Simply run me and append the poem to the command\n" 59 | echo -e "./potioneer poem\n" 60 | fi 61 | EOF 62 | 63 | chmod +x potioneer 64 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/.garden_of_mitra/word_of_power: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- -- 3 | -- « cp » is the word of power -- 4 | -- -- 5 | -- use it to copy files around your filesystem -- 6 | -- -- 7 | -- remember that « .. » means one directory back and « . » means here. -- 8 | -- -- 9 | -- So you can copy something you've left behind into this directory like: -- 10 | -- -- 11 | -- « cp ../name_of_file . » -- 12 | -- -- 13 | ---------------------------------------------------------------------------- 14 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/HINT: -------------------------------------------------------------------------------- 1 | This chest is locked! 2 | 3 | The key to the chest, is the line count of the poem. 4 | 5 | You need a spell for that! 6 | 7 | Look behind by using the « ls .. » spell 8 | 9 | Have you missed something? 10 | 11 | « .. » always means one directory behind. 12 | 13 | Can you figure out how to use cat with « .. » 14 | 15 | to read the spell you left behind? 16 | 17 | 18 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/chest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | lock_val=$(cat poem | wc -l) 4 | 5 | cat <../spell 6 | ############################################### 7 | # « cat filename | wc -l » # 8 | # # 9 | # There are many ways to count words or lines # 10 | # # 11 | # in the shell. This is one of them. # 12 | # # 13 | ############################################### 14 | EOF 15 | 16 | echo -e "This chest is locked!\nYou need the proper key to enter!" 17 | 18 | echo "Enter Key value: " 19 | read -r val 20 | 21 | 22 | if [[ $val != "$lock_val" ]]; then 23 | echo "Wrong!" 24 | exit 0 25 | else 26 | echo "Correct! You found 10 gold coins!" 27 | fi 28 | 29 | cat <gold 30 | 31 | Here are 10 gold coins. 32 | 33 | Create a « gold » variable and asign the value of 10 to it. 34 | 35 | « export gold=10 » 36 | 37 | You can always check your gold with: 38 | 39 | echo \$gold 40 | 41 | EOF 42 | 43 | mv .garden_of_mitra garden_of_mitra 2>/dev/null 44 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/parchment: -------------------------------------------------------------------------------- 1 | _________________________________________________________________________ 2 | /\ \ 3 | \_| You may have already realized that you can use « cat » to see inside | 4 | | | 5 | | the scripts as well. While this is a good method for quickly checking | 6 | | | 7 | | a short script or file, it will be annoying for longer files. | 8 | | | 9 | | In this chamber, there is a poetry book. Try the cat command on it | 10 | | | 11 | | but add this to the end of your spell « | less » | 12 | | | 13 | | You will be able to scroll up and down with arrow keys or the vi | 14 | | | 15 | | keys: j for down and k for up | 16 | | | 17 | | Press q to quit less | 18 | | ____________________________________________________________________|_ 19 | \_/______________________________________________________________________/ 20 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/.2nd_chamber/poem: -------------------------------------------------------------------------------- 1 | Beloved reached desired glow 2 | 3 | And so we say, may it be so 4 | All doubts towards faith did grow 5 | And so we say, may it be so 6 | 7 | The devil’s plot caused perturbation 8 | And the nation faced agitation; 9 | Once again was Solomon’s nation 10 | And so we say, may it be so 11 | 12 | Beloved who put my heart in pain 13 | Closed doors on my face once again 14 | Friends would console and entertain 15 | And so we say, may it be so 16 | 17 | You drank wine on your own 18 | Lusted after all, alone 19 | Now lead the drunk upon a throne 20 | And so we say, may it be so 21 | 22 | From your majestic bright face 23 | The flame lighting my place 24 | Each corner, a well-lit space 25 | And so we say, may it be so 26 | 27 | From your fake anger and rage 28 | And the sweet turning of the page 29 | The world is a sugary stage 30 | And so we say, may it be so 31 | 32 | Night replaced by the morrow 33 | Joy has conquered every sorrow 34 | Sun light, pervasive and thorough 35 | And so we say, may it be so 36 | 37 | From mendicant generosity 38 | And lovers’ pertinacity 39 | Revival and vivacity 40 | And so we say, may it be so 41 | 42 | Celebrate this festivity 43 | Restored to compatibility 44 | Festivals abound in our city 45 | And so we say, may it be so 46 | 47 | O masterful wise minstrel 48 | In the underworld do not dwell 49 | Finally Venus in Libra fell 50 | And so we say, may it be so 51 | 52 | The mendicant reached kingly might 53 | In wealth attained unimagined height 54 | Partaking of courtly delight 55 | And so we say, may it be so 56 | 57 | Consider the wind in the air 58 | Sweet lips’ bewitching flair 59 | Wailing windpipe will not spare 60 | And so we say, may it be so 61 | 62 | The Pharaoh with much hardship 63 | Misfortunes his life grip 64 | Of suffering, Moses strip 65 | And so we say, may it be so 66 | 67 | Evil looking and ugly wolf 68 | Drowned in ignorance’s deep gulf 69 | By Joseph’s goodness now dwarf 70 | And so we say, may it be so 71 | 72 | O Shams-e Tabrizi, you 73 | Compassionately blend and renew 74 | East and west through and through 75 | And so we say, may it be so 76 | 77 | From submission to Satan’s will 78 | Your prophetic soul emerged through this mill 79 | Satan himself, God’s will fulfill 80 | And so we say, may it be so 81 | 82 | When the moon was shining its light 83 | Both worlds were garden of delight 84 | All souls for home then took flight 85 | And so we say, may it be so 86 | 87 | The ignorant and the blind 88 | With insight are now wise and kind 89 | Surpass Jesus, put him behind 90 | And so we say, may it be so 91 | 92 | It was all for souls to grow 93 | May it always have been so 94 | Thy splendor brightly aglow 95 | And so we say, may it be so 96 | 97 | All thy wrath was thy mercy 98 | Thy poison, sweet clemency 99 | Like dark clouds’ sweet potency 100 | And so we say, may it be so 101 | 102 | In his temple, colors remain 103 | Pulling by the horns will not disdain 104 | When this bull’s blood floors stain 105 | And so we say, may it be so 106 | 107 | Silence! I am drunk, you know 108 | My hands are tied in this earthly show 109 | My disheveled mind moves to and fro 110 | And so we say, may it be so 111 | 112 | CREDIT: 113 | Translated By: 114 | Shahriar Shahriari 1998, Vancouver Canada, 1999 - 2005, Los Angeles, CA 115 | https://www.rumionfire.com/shams/rumi021.htm 116 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/parchment: -------------------------------------------------------------------------------- 1 | __________________________________________________________ 2 | /\ \ 3 | \_| Variables are words in which we store data. | 4 | | | 5 | | It is called a variable because what gets stored in it | 6 | | | 7 | | can change. | 8 | | | 9 | | You can always use « $ » before a variable name to | 10 | | print | 11 | | it's contents to your STDOUT. | 12 | | | 13 | | STDOUT is just a fancy name for your terminal. ;) | 14 | | _____________________________________________________|_ 15 | \_/_______________________________________________________/ 16 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/rat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rat_HP=7 4 | sword_damage=5 5 | long_sword_damage=10 6 | 7 | has_sword(){ 8 | if [[ $I == "short_sword" ]]; then 9 | declare -g sword_type="short" 10 | declare -g damage=$sword_damage 11 | elif [[ $I == long_sword ]]; then 12 | declare -g sword_type="long" 13 | declare -g damage=$long_sword_damage 14 | else 15 | echo "Invalid sword type" 16 | exit 1 17 | fi 18 | } 19 | 20 | remains(){ 21 | cat < rat_remains 22 | 23 | Smelly stinking rat meat! 24 | 25 | Nothing worthy here! 26 | 27 | EOF 28 | mv .2nd_chamber 2nd_chamber 2>/dev/null 29 | } 30 | 31 | is_dead(){ 32 | if (( rat_HP <= 0 )); then 33 | declare -g rat_is_dead="dead" 34 | fi 35 | } 36 | 37 | echo -e "The rat has $rat_HP HP\n" 38 | echo -e "The rat bites!\n" 39 | echo -e "attack rat? y/n \n" 40 | read -r ans 41 | 42 | has_sword 43 | if [[ $ans == 'y' ]]; then 44 | echo -e "You attack the rat with your $sword_type sword!\n" 45 | (( rat_HP -= damage )) 46 | is_dead 47 | echo -e "The rat takes $damage damage from your $sword_type sword!\n" 48 | if [[ $rat_is_dead == "dead" ]]; then 49 | echo "You killed the rat!" 50 | remains 51 | exit 0 52 | fi 53 | echo -e "The rat has $rat_HP HP\n" 54 | echo -e "Attack again? y/n \n" 55 | read -r ans2 56 | if [[ $ans2 == 'y' ]]; then 57 | echo -e "You attack the rat with your $sword_type sword!\n" 58 | (( rat_HP -= damage )) 59 | is_dead 60 | if [[ $rat_is_dead == "dead" ]]; then 61 | echo "You killed the rat!" 62 | remains 63 | exit 0 64 | fi 65 | fi 66 | fi 67 | 68 | -------------------------------------------------------------------------------- /Enter/corridor/.first_chamber/short_sword: -------------------------------------------------------------------------------- 1 | 2 | You found a short sword! 3 | 4 | Create a variable to add it to your inventory. 5 | 6 | « export I=short_sword » 7 | 8 | You can view your inventory with: 9 | 10 | « echo $I » 11 | 12 | Now that you have a sword, try to kill the rat! 13 | 14 | -------------------------------------------------------------------------------- /Enter/corridor/chest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat </dev/null 24 | -------------------------------------------------------------------------------- /Enter/corridor/parchment: -------------------------------------------------------------------------------- 1 | _______________________________________________________________ 2 | /\ \ 3 | \_| When looking around, you might wonder what everything is. | 4 | | | 5 | | In that case, use the 'file' spell and point to the name of | 6 | | | 7 | | that, which you want to identify. | 8 | | __________________________________________________________|_ 9 | \_/____________________________________________________________/ 10 | -------------------------------------------------------------------------------- /Enter/corridor/parchment_2: -------------------------------------------------------------------------------- 1 | _______________________________________________________________ 2 | /\ \ 3 | \_| In this room, there is a chest. You must identify it before | 4 | | | 5 | | trying to open it! | 6 | | | 7 | | Look around, there might be a spell! | 8 | | __________________________________________________________|_ 9 | \_/____________________________________________________________/ 10 | -------------------------------------------------------------------------------- /Enter/corridor/spell: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # # 3 | # You can use the « head -n 1 » spell to take a peek at what a file # 4 | # holds. # 5 | # Use this power to identify what the chest is! # 6 | # # 7 | # If you see a '#!', it means that its a script, which you can run # 8 | # by preceeding it's name with './' # 9 | # Like « ./chest » # 10 | # # 11 | # BEHOLD! # 12 | # While all the scripts in this game are safe, # 13 | # IT'S NOT ALWAYS SAFE TO RUN SCRIPTS WITHOUT KNOWING WHAT THEY'LL DO! # 14 | # # 15 | # You will learn how to examine the scripts in a little bit # 16 | # # 17 | ########################################################################## 18 | -------------------------------------------------------------------------------- /Enter/parchment: -------------------------------------------------------------------------------- 1 | ___________________________________________________________________ 2 | /\ \ 3 | \_| Welcome To The Bash Dungeon! | 4 | | | 5 | | In this game you will crawl a series of dungeons(directories) | 6 | | and learn about your shell by using pure bash spells(commands). | 7 | | | 8 | | The dungeon rooms are directories, you use 'cd' to enter them. | 9 | | To look around, you use your torch with the 'ls' spell. | 10 | | To read the parchments you find, use the 'cat' spell. | 11 | | | 12 | | ALWAYS READ THE PARCHMENTS FIRST, THEY CONTAIN IMPORTANT INFO! | 13 | | Good Luck! | 14 | | | 15 | | TIP: | 16 | | To make your life easier, alias « ls » to « ls -F » right now. | 17 | | « alias ls='ls -F' » | 18 | | ______________________________________________________________|_ 19 | \_/________________________________________________________________/ 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2024, wolandark 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bash Dungeon 2 |
3 | 4 |
5 | 6 | A dungeon crawler game in bash where the dungeons are directories.
Inspired by [Dungeons And Directories](https://github.com/wheybags/DungeonsAndDirectories) and [Bash Crawl](https://gitlab.com/slackermedia/bashcrawl). (WIP)
7 | 8 | _This game is intended to teach new users how to use their shell in a fun and interactive way.
_ 9 | 10 | **Right now its a work in progress ...** 11 | 12 | # Play in GitPod 13 | Sign up for a free gitpod account and click the link below
14 | [Bash Dungeon GitPod](https://wolandark-bashdungeon-wr1fmhxhnti.ws-us108.gitpod.io/) 15 | 16 | # Play in docker 17 | You must have docker installed.
18 | Then: 19 | ``` 20 | docker pull wolandark/bash-dungeon 21 | docker run -it wolandark/bash-dungeon 22 | ``` 23 | 24 | # Play Locally 25 | clone the repository and cd into it
26 | `cd Enter` the dungeon
27 | `cat` your first parchment and follow the instructions.
28 | 29 | # Instructions 30 | `cd`, `ls` and `cat` are all you need to know to start playing. 31 | 32 | ## Your very first moves 33 | `cd bash-dungeon`
34 | `ls`
35 | `cd Enter`
36 | `ls`
37 | `cat parchment`
38 | 39 | # Contribution 40 | If you have any ideas, please open a new discussion.
41 | If you find any bugs or issues, please submit an issue.
42 | When submitting PRs, please follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) . 43 | --------------------------------------------------------------------------------