/*
  crossword -- a crossword game
  Copyright (C) 2000 Falk Hueffner

  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

  $Id: Rules.hh,v 1.6 2000/10/21 20:09:32 falk Exp $
*/

#ifndef RULES_HH
#define RULES_HH

#include <vector>
#include <string>

#include "Dir.hh"
#include "Pos.hh"
#include "Tile.hh"

using namespace std;

// To avoid unnecessary complication, all members are static.
class Rules {
public:
    static void readRules(istream& in);
    static void readLayout(istream& in);
    static unsigned int xsize() { return _xsize; }
    static unsigned int ysize() { return _ysize; }
    static unsigned int numFields() { return _numFields; }
    static unsigned int maxRackTiles() { return _maxRackTiles; }
    static unsigned int frequency(Tile t) { return frequencies[t]; }
    static unsigned int score(Tile t) { return scores[t]; }
    static unsigned int wordMultiplier(Pos p) { return wordMultipliers[p]; }
    static unsigned int letterMultiplier(Pos p) { return letterMultipliers[p]; }

    static Dir right() { return 1; }
    static Dir left() { return -1; }
    static Dir up() { return -xsize(); }
    static Dir down() { return xsize(); }

    static Pos startPos() { return _startPos; }
    static const unsigned int NUM_CHARS = 256; // FIXME

private:
    // read a line ignoring comments
    static bool getLine(istream& in, string& line);

    static int _xsize, _ysize, _numFields, _maxRackTiles;
    static Pos _startPos;

    static vector<unsigned int>	frequencies;
    static vector<unsigned int>	scores;
    static vector<unsigned int> letterMultipliers;
    static vector<unsigned int> wordMultipliers;
};

#endif

