#!/bin/sh

ROLES="LDH"
role="LDH"

host="localhost"
port="6000"
team="OZ"
reconnect_number=""
goalie="false"

usage()
{
	(echo "Usage: $0 [options]"
	 echo "Possible options are:"
	 echo "      --help"
	 echo "  -h, --host HOST"
	 echo "  -p, --port PORT"
	 echo "  -t, --team-name TEAM"
	 echo "  -r, --reconnect NUMBER"
	 echo "  -g, --goalie"
	 echo "  -R, --role"
	 echo "  -a, --acceptable-roles") 1>&2
}

while [ $# -gt 0 ]
do
	case $1 in

	--help)
		usage
		exit 0
		;;

	-h|--host)
		host=$2
		shift 1
		;;

	-p|--port)
		port=$2
		shift 1
		;;

	-t|--team-name)
		team=$2
		shift 1
		;;

	-r|--reconnect)
		reconnect_number=$2
		shift 1
		;;

	-g|--goalie)
		goalie="true"
		;;

	-R|--role)
		role=$2
		shift 1
		;;

	-a|--acceptable-roles)
		echo $ROLES
		exit 0
		;;

	*)
		usage
		exit 1
		;;
	esac

	shift 1
done



if [ "${goalie}" = "true" ]; then
	goalie_option="--goalie"
else
	goalie_option=""
fi

if [ ! -z "${reconnect_number}" ]; then
	reconnect_option="--reconnect ${reconnect_number}"
fi

case $role in
	LDH)
		./Gemini -s ${host} -p ${port} -t ${team} 1>/dev/null 2>&1 &
		;;
	*)
		echo "Can't accept role: \"${role}\""
		exit 1
		;;
esac
