#!/bin/bash

# BAGSGame.bsh
#
# Copyright 2005 M. Aaron Wadley
#
# This file is part of BAGS (Beany Adventure Game System).
# BAGS (Beany Adventure Game System) is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# BAGS (Beany Adventure Game System) is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BAGS (Beany Adventure Game System); if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

# Change this to match your environment
bagshome="$HOME/src/BAGS_src_0.1/"

declare -a parms

# Set up classpath
export BAGS_HOME="$bagshome"
export BAGS_GAMES="$bagshome/games/"

cp=".:$BAGS_HOME"

# Shift the arguments to eliminate the script name
for (( i=0; i<$#+1; i++ )) ; do
	arg=$i
	if [ $arg -gt 0 ] ; then
		index=$((i-1))
		parms[$index]=${!arg}
	fi
done

cd $BAGS_HOME

if [ "${parms[0]}" == "-c" ] ; then
	java -cp $cp bsh.Console  
else 
	# Call the BeanShell interpreter with the bsh script and arguments
	java -jar bags.jar ${parms[@]} 
fi

exit
