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

#ifndef CARDWORDS_CARDDESCRIPTION_HH
#define CARDWORDS_CARDDESCRIPTION_HH

#include "cardwords_cardbase.hh"

class CardWords_CardDescription : public CardWords_CardBase {
public:
  // the test if this card is a wildcard:
  virtual
  bool
  is_wildcard(void) const;

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

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

  void set_points(int);

  void
  set_faceValue (CardWords_Char);

  CardWords_CardDescription &
  operator = (const CardWords_CardBase &);

  CardWords_CardDescription (const CardWords_CardBase &);
  CardWords_CardDescription (class istream &);
  CardWords_CardDescription (CardWords_Char face,
                             CardWords_Char means,
                             int score);
  CardWords_CardDescription ( char face,
                              char means,
                              int score);
  CardWords_CardDescription ( char faceAndMeans = ' ',
                              int score = 0);
  //       the default constructor creates a blanko

private:
  bool wildcard;
  CardWords_Char faceValue;
  int  points; // The score for this card.
};

class istream & operator >> (class istream &, CardWords_CardDescription &);

// the test if this card is a wildcard:
inline
bool
CardWords_CardDescription::is_wildcard(void) const
{
  return wildcard;
}

// Get the char that is written on this card:
inline
const CardWords_Char &
CardWords_CardDescription::get_faceValue(void) const
{
  return faceValue;
}

// Get the score for this card:
inline
int
CardWords_CardDescription::get_points(void) const
{
  return points;
}

inline  void
CardWords_CardDescription::set_points(int p)
{
  points = p;
}

inline
void
CardWords_CardDescription::set_faceValue (CardWords_Char c) {
  faceValue = c;
  wildcard = (c == CardWords_Char::blanko);
  set_meaning (c);
}

inline
CardWords_CardDescription &
CardWords_CardDescription::operator = (const CardWords_CardBase & other)
{
  faceValue = other.get_faceValue();
  wildcard = (faceValue == CardWords_Char::blanko);
  if (wildcard) {
    set_meaning(other.get_meaning());
  }
  else {
    set_meaning(faceValue);
  }

  set_points(other.get_points());

  return *this;
}

inline
CardWords_CardDescription::
CardWords_CardDescription (const CardWords_CardBase & other)
  : CardWords_CardBase (other.get_meaning())
{
  (*this) = other;
}

inline
CardWords_CardDescription::CardWords_CardDescription (CardWords_Char face,
                                                      CardWords_Char means,
                                                      int score)
  : CardWords_CardBase (means)
{
  points = score;
  faceValue = face;
  wildcard = (face == CardWords_Char::blanko);
}
inline 
CardWords_CardDescription::CardWords_CardDescription ( char face,
                                                       char means,
                                                       int score)
  : CardWords_CardBase (means)
{
  faceValue = face;
  wildcard = (faceValue == CardWords_Char::blanko);
  points = score;
}
inline
CardWords_CardDescription::
CardWords_CardDescription ( char faceAndMeans = ' ',
                            int score = 0)
  : CardWords_CardBase (faceAndMeans)
{
  faceValue = faceAndMeans;
  wildcard = (faceValue == CardWords_Char::blanko);
  points = score;
}
#endif
