Skip to content

Commit

Permalink
Quest starts here...
Browse files Browse the repository at this point in the history
  • Loading branch information
sibgit committed Oct 18, 2024
1 parent 73c1291 commit 52af758
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
36 changes: 36 additions & 0 deletions open_chest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
source .script/quest_functions.sh

# Test if all keys are present.
pirate_say "Let's see if we can open this treasure chest!\n"
sleep 1
key_nb=0
for key in $KEY_1 $KEY_2 $KEY_3; do
key_nb=$(( key_nb + 1 ))
if [[ ! -f "$key" ]]; then
echo -e "$(random_exclamation) We're missing the key in lock $key_nb ! Let's go look for it, sail ho!\n"
exit 1
fi
if ! $(is_valid_key "$key"); then
echo -e "$(random_exclamation) That key in lock $key_nb isn't working! Let's find the correct one, sail ho!\n"
exit 1
fi
done

# Verify the keys are the correct.
echo -e "Fine job gals and lads! It looks like all keys are present.\n"
echo "Let's try to open that chest..."
for key_nb in $(seq 1 3); do
echo -n "trying key $key_nb (drumrolls!)"
sleep 1
for x in $(seq 1 3); do echo -n "."; sleep 1; done
echo " success! Sail Ho!"
sleep 1
done
sleep 1

# Reveal treasure.
cat .script/treasure.ascii
echo "Hooray, you made it - Longsilver's treasure is finally yours! Great success :-)"
echo -e "If you are doing this exercise for the exam, here's the code: $(get_key_code 1)$(get_key_code 2)$(get_key_code 3))\n"
exit 0
Empty file added supplies/.supplies
Empty file.
31 changes: 31 additions & 0 deletions verify_contract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
source .script/quest_functions.sh

# Quest starts here...
pirate_say "Welcome to this quest Pirates!"
sleep 1
echo -e "To start, each team member should read the pirate's code and sign it.\n"
sleep 2

# Crew member onboarding
echo "Let's see if this was done properly..."
sleep 1
if [[ ! -f "$CREW" ]]; then
echo "$(random_exclamation) We're missing the pirate code!"
echo -e "Did you delete the '$CREW' file by mistake? Please restore it.\n"
exit 1
fi

for member in "${PIRATES[@]}"; do
if [[ ! $( grep "^${member}" $CREW ) ]] || [[ $( grep "^$member\ *:\ *NAME" $CREW ) ]]; then
echo -e "$(random_exclamation) We're missing the ${member}'s signature on the pirate's code!\n"
exit 1
fi
done

echo -e "The following pirates have signed the code:\n"
grep "^Captain\|^Quartermaster\|^First mate" $CREW
sleep 2

echo -e "\nCongrats for the paperwork - let's get on that ship and sail!\n"
exit 0
36 changes: 36 additions & 0 deletions verify_supplies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
source .script/quest_functions.sh

# Quest starts here...
pirate_say "Let's see if we have all we need for this quest...\n"
sleep 1

# Check the ship:
if [[ ! -f "$SHIP" ]]; then
echo -e "$(random_exclamation) We're missing a ship! Talk about a bad start.\n"
exit 1
fi
echo -e "\nThat's a good ship we have there!"
cat $SHIP
sleep 2

# Check rhum supplies:
if [[ ! -f "$RHUM" ]]; then
echo -e "$(random_exclamation) There's no rhum on that ship! Let's get back to work, we'll never make it without rhum!\n"
exit 1
fi
echo -e "\nRhum supplies are loaded, now we're taking!"
cat $RHUM
sleep 2

# Fly the flag:
if [[ ! -f "$FLAG" ]]; then
echo -e "$(random_exclamation) This ship has no flag! What's a pirate ship without a flag. Hurry and get one!\n"
exit 1
fi
echo -e "\nRaise the flag and let the treasure hunt begin! Sail Ho!"
cat $FLAG
sleep 1

echo -e "\nWell done! Let's go find this treasure...\n"
exit 0

0 comments on commit 52af758

Please sign in to comment.