/* This file is part of cardwords
   (c) 1998 1999 2000 Tobias Peters
   see file COPYING for the copyright terms.
   
   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_cardbase.hh

/* The format used for input and output of the classes
   CardWords_Card and CardWords_CardDescription:

   [x #]

   [ and ] are literal brackets
   x       is a Machine_Char that can be converted to a CardWords_Char
   .       This is the face value of the card. For wildcards, this
   .       must be something will be converted to the same as
   .       CardWords_Char::blanko.
   Space   is either a literal space or a Machine_Char that can be
   .       converted to a CardWords_Char. Use Space for non-wildcards
   .       (though the same as x is also possible) and a desired
   .       meaning for wildcards.
   #       an int in decimal, the points of that card.
*/

#ifndef CARDWORDS_CARDBASE_HH
#define CARDWORDS_CARDBASE_HH

#include "cardwords_char.hh"
namespace CardWords {

class CardBase {
public:

  // the test if this card is a wildcard:
  virtual
  bool
  is_wildcard(void) const = 0;

  // Get the char that is written on this card:
  virtual 
  const Char &
  get_faceValue(void) const = 0;

  // Get the char that is represented by this card;
  // can be different from the above for wildcards (and only for them):
  const Char &
  get_meaning(void) const;

  // Get the score for this card:
  virtual
  int
  get_points(void) const = 0;

  // Change the meaning of this card. Only allowed for wildcards:
  void
  set_meaning (Char);

  CardBase( Char means);

  CardBase( char means);
  
  // read the card definition from a stream:
  CardBase( istream & );

  bool
  operator == (const CardBase &) const;

  // for sorting:
  bool
  operator < (const CardBase & other) const;
  bool
  operator > (const CardBase & other) const;

private:
  // bool wildcard and Char faceValue are only defined in the
  // derived classes, because they will be (assignable in
  // CardDescription) and (a constant in Card).
  Char meaning; // The char that is represented by this card;
  // can be different from the faceValue for wildcards (and only for them).
};
}
class ostream &
operator << (class ostream &, const CardWords::CardBase &);
#endif

