#!/bin/ksh
#  kornball.ksh - simulates Magic 8 Ball fortune toy
#

header() {
 clear
 echo
 echo ' The Magic Korn Ball is listening.. '
 echo
}

footer() {
 echo
 echo "               ,-.    "
 echo "              ((8))   "
 echo "               \`-'    "
 echo
}

fortunes() {
case "$1" in
  1) echo "          It is certain       "  ;;
  2) echo "        It is decidedly so    "  ;;
  3) echo "         Without a doubt      "  ;;
  4) echo "         Yes, definitely      "  ;;
  5) echo "        You may rely on it    "  ;;
  6) echo "         As I see it, yes     "  ;;
  7) echo "           Most likely        "  ;;
  8) echo "           Outlook good       "  ;;
  9) echo "               Yes            "  ;;
 10) echo "        Signs point to yes    "  ;;
 11) echo "       Reply hazy try again   "  ;;
 12) echo "         Ask again later      "  ;;
 13) echo "     Better not tell you now  "  ;;
 14) echo "       Cannot predict now     "  ;;
 15) echo "    Concentrate and ask again "  ;;
 16) echo "        Don't count on it     "  ;;
 17) echo "         My reply is no       "  ;;
 18) echo "        My sources say no     "  ;;
 19) echo "       Outlook not so good    "  ;;
 20) echo "          Very doubtful       "  ;;
esac
}

fortune() {
 printf '  Ask your Yes/No/Maybe question: \n\n  => '
 read -r
 echo
 echo '               -:- '
 echo
 fortunes $((1 + RANDOM % 20))
}

# main
main() {
 header
 fortune
 footer
}

main