/* This file is part of cardwords
   (c) 1998 1999 Tobias Peters
   
   This program 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.

   This program 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 this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_move.hh

/*
  A move consists of 
  - a TableLocation where it is going to
  - a direction, horizontal or vertikal
  - a CardSelection that specifies which Cards in which order go
  . in the free Places

  A  move consists only of the cards that actually get moved.

  So if [A 1] is already on the table at (7,7), and we want to lay
  'gap' horizontally from (6,7) to (8,7), the move would look like
  (7,7)_2[G 2][P 4]
  L___J|L_________J
  . |  |  +-Selection
  . |  +----Direction
  . +-------TableLocation

*/
#ifndef CARDWORDS_MOVE_HH
#define CARDWORDS_MOVE_HH

#include "cardwords_cardselection.hh"
#include "cardwords_cardtablelocation.hh"
#include "cardwords_direction.hh"

class CardWords_Move : public CardWords_CardSelection {
public:
  CardWords_CardTableLocation location;
  CardWords_Direction     direction;

  CardWords_Move():direction(horizontal){}

  CardWords_Move & operator = (const CardWords_CardDescription & desc)
    { *(CardWords_CardSelection *)this = desc; return *this; }

  CardWords_Move & operator = (const CardWords_CardSelection & sel)
    { *(CardWords_CardSelection *)this = sel; return *this; }

  CardWords_Move & operator = (const CardWords_Move & other)
    {
      *(CardWords_CardSelection *)this =
        *(const CardWords_CardSelection *) (&other);
      location = other.location; direction = other.direction;return *this;
    }

  CardWords_Move(const CardWords_CardSelection & sel)
    : CardWords_CardSelection(sel),direction(horizontal){}
};

inline
ostream & operator << (ostream & ostream, const CardWords_Move & move)
{
  return ostream << move.location << ' '
                 << move.direction << ' '
                 << *(CardWords_CardSelection *) (& move);
}
inline
istream & operator >> (istream & istream, CardWords_Move & move)
{
  return istream >> move.location
                 >> move.direction
                 >> *(CardWords_CardSelection *) (& move);
}
#endif
