#!/bin/sh

# $Header: $

usage ()
{
  echo "Usage: `basename $0`: game turn"
  exit 1
}

Append ()
{
  cat $1 >> /tmp/$game-orders
  echo "#end" >> /tmp/$game-orders # Just in case
}

if [ x$1 = x -o x$2 = x ] ; then
  usage
fi

touch /tmp/$game-orders

game=$1
turn=$2

cd $HOME/Mail/$game-Turns
for i in ? ?? ??? ; do
  echo $i | egrep '#|,' > /dev/null || Append $i
done

cd $HOME/$game
GAMENAME=$game
TURN=$turn
export GAMENAME TURN

./Order < /tmp/$game-orders

