Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rpearce
Last active December 9, 2022 06:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpearce/008cb2af586d6c8a2dc2422454eb501c to your computer and use it in GitHub Desktop.
Save rpearce/008cb2af586d6c8a2dc2422454eb501c to your computer and use it in GitHub Desktop.
bday text game gift for my sister
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -eou pipefail
function clearscreen {
printf '\033c'
}
function welcome {
cat <<EOF
---------------------------
| |
| Welcome to |
| |
| Kathryn's |
| |
| Birthday Challenge! |
| |
---------------------------
EOF
}
function overview {
cat <<EOF
-----------------------------
| |
| You will be given |
| |
| THREE |
| |
| questions about |
| |
| HTML |
| |
| that you must answer |
| |
| to unlock... |
| |
-----------------------------
EOF
}
function gift_preview {
echo " ___ ___ ___ ___ ";
echo " ___ /__/\ / /\ / /\ ___ / /\ ___ ";
echo " / /\ \ \:\ / /:/_ / /:/_ / /\ / /:/_ / /\ ";
echo " / /:/ \__\:\ / /:/ /\ / /:/ /\ / /:/ / /:/ /\ / /:/ ";
echo " / /:/ ___ / /::\ / /:/ /:/_ / /:/_/::\ /__/::\ / /:/ /:/ / /:/ ";
echo " / /::\ /__/\ /:/\:\ /__/:/ /:/ /\ /__/:/__\/\:\ \__\/\:\__ /__/:/ /:/ / /::\ ";
echo " /__/:/\:\ \ \:\/:/__\/ \ \:\/:/ /:/ \ \:\ /~~/:/ \ \:\/\ \ \:\/:/ /__/:/\:\ ";
echo " \__\/ \:\ \ \::/ \ \::/ /:/ \ \:\ /:/ \__\::/ \ \::/ \__\/ \:\ ";
echo " \ \:\ \ \:\ \ \:\/:/ \ \:\/:/ /__/:/ \ \:\ \ \:\\";
echo " \__\/ \ \:\ \ \::/ \ \::/ \__\/ \ \:\ \__\/";
echo " \__\/ \__\/ \__\/ \__\/ ";
}
function run_q1 {
local msg="${1-}"
clearscreen
echo "$(q1)"
if [ -n "$msg" ]; then
echo "$msg"
fi
read -p "> " answer
if [ "$answer" = "Hypertext Markup Language" ] || [ "$answer" = "hypertext markup language" ]; then
echo ""
q1_success
else
run_q1 "(Please try again)"
fi
}
function q1 {
cat <<EOF
-----------------------------------------
| |
| Q1: What is HTML an acronym for? |
| |
| (hint: google "mdn HTML") |
| |
-----------------------------------------
EOF
}
function q1_success {
cat <<EOF
------------------
| |
| Great Job! |
| |
------------------
EOF
read -p "(Press return to continue)" _
}
function run_q2 {
local msg="${1-}"
clearscreen
echo "$(q2)"
if [ -n "$msg" ]; then
echo "$msg"
fi
read -p "> " answer
if [ "$answer" = "<p>Hello, World!</p>" ]; then
echo ""
q2_success
else
run_q2 "(Please try again)"
fi
}
function q2 {
cat <<EOF
----------------------------------------------
| |
| Q2: How do you write an HTML paragraph |
| with the content, "Hello, World!" |
| |
| (hint: google "mdn paragraph tag") |
| |
----------------------------------------------
EOF
}
function q2_success {
cat <<EOF
----------------------
| |
| Wow! You rock! |
| |
----------------------
EOF
read -p "(Press return to continue)" _
}
function run_q3 {
local msg="${1-}"
clearscreen
echo "$(q3)"
if [ -n "$msg" ]; then
echo "$msg"
fi
read -p "> " answer
if [ "$answer" = "CSS" ] || [ "$answer" = "css" ]; then
echo ""
q3_success
else
run_q3 "(Please try again)"
fi
}
function q3 {
cat <<EOF
-------------------------------------------
| |
| Q3: What is the acronym for what |
| gives websites styles? (color, |
| position, etc.) |
| |
| (hint: google "mdn cascading style") |
| |
-------------------------------------------
EOF
}
function q3_success {
cat <<EOF
------------------------
| |
| Amazing! I'm so |
| |
| proud of you! |
| |
------------------------
EOF
read -p "(Press return to continue)" _
}
function gift {
cat <<EOF
----------------------------------------------------
| |
| You have earned a subscription to egghead.io |
| |
| (when you are ready), or you can take half |
| |
| its value in cash right now. |
| |
| |
| |
| The choice is yours. |
| |
| |
| |
| Love, |
| |
| Robert & Emily |
| |
----------------------------------------------------
EOF
}
function start {
clearscreen
echo "$(welcome)"
read -p "(Press return to continue)" _
clearscreen
echo "$(overview)"
read -p "(Press return to continue)" _
echo "$(gift_preview)"
read -p "(Press return to be tested)" _
run_q1
run_q2
run_q3
clearscreen
echo "$(gift)"
read -p "(Press return to open egghead.io)" _
open https://egghead.io
}
start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment