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

#ifndef CARDWORDS_CARDTABLE_HH
#define CARDWORDS_CARDTABLE_HH

#include "cardwords_cardcontainer2dim.hh"
class istream;
class ostream;
namespace CardWords {
class Move;

class CardTable : public CardContainer2Dim {
private:
  CardTableLocation starting_pos;
  Matrix<int>  letter_factors;
  Matrix<int>  word_factors;
  Matrix<int>  cell_points;
  Matrix<bool> cell_blocked;
  
public:
  // These functions are here for counting the cards on the card-table:
  // remove a special card from the container:
  virtual
  void
  remove_card (Card *);
    
  // add a card to the container:
  virtual
  void
  add_card (Card*, CardTableLocation);

  const CardTableLocation &
  get_starting_pos (void) const;

  int
  get_word_factor (CardTableLocation loc) const;

  int
  get_word_factor (size_t x, size_t y) const;

  int
  get_letter_factor (CardTableLocation loc) const;

  int
  get_letter_factor (size_t x, size_t y) const;

  int
  get_cell_points (CardTableLocation loc) const;

  int
  get_cell_points (size_t x, size_t y) const;

  bool
  is_cell_blocked (CardTableLocation loc) const;

  bool
  is_cell_blocked (size_t x, size_t y) const;

  friend
  CardTable *
  read_card_table (istream &);

  CardTable (size_t columns,
                       size_t rows,
                       CardTableLocation start);

  // Add the move, get the cards from this container:
  void
  add_move(const Move &, CardContainer1Dim *);

  // Check if such a move would fit on the card-table.
  // Moves creating 1-letters-words are marked as not-fitting.
  bool
  check_move_fits(const Move &) const;

  size_t
  get_number_of_cards(void) const;

  bool 
  has_cell_neighbour_card(CardTableLocation) const;
  
private:
  size_t number_of_cards;
};
}
ostream & operator << (ostream &, const CardWords::CardTable &);

#endif

