#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2017 Christopher Bratusek		#
#							#
#########################################################

# by AMOR

case ${1} in

	--help | -h)
		bashstyle-help -a "AMOR" -e "" -h "http://www.commandlinefu.com/"\
				-l "Public Domain" -n "hilow" -s "simple number guessing game" \
				-v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
				-o "none:|--"
	;;

	*)
		biggest=1000                            # maximum number possible
		guess=0                                 # guessed by player
		guesses=0                               # number of guesses made
		number=$(($$% biggest))                 # random number, 1 .. $biggest
			while [ $guess -ne $number ] ; do
				echo -n "Guess? " ; read -r guess
				if [ "$guess" -lt $number ] ; then
					echo "... bigger!"
				elif [ "$guess" -gt $number ] ; then
					echo "... smaller!"
				fi
				guesses=$((guesses+1))
			done
		echo "Right!! Guessed $number in $guesses guesses."
	;;

esac
