2011-08-27 19:21:26 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Eliot
|
|
|
|
* Copyright (C) 2011 Olivier Teulière
|
|
|
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef GAME_PARAMS_H_
|
|
|
|
#define GAME_PARAMS_H_
|
|
|
|
|
2011-08-28 17:29:39 +02:00
|
|
|
#include "game_exception.h"
|
|
|
|
|
2011-08-28 18:44:34 +02:00
|
|
|
class Dictionary;
|
|
|
|
|
2011-08-27 19:21:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GameParams groups various game characteristics.
|
|
|
|
* These attributes are defined when the game is created,
|
|
|
|
* and cannot change during the game.
|
|
|
|
*/
|
|
|
|
class GameParams
|
|
|
|
{
|
|
|
|
public:
|
2011-08-28 18:20:00 +02:00
|
|
|
|
|
|
|
/// Game mode
|
|
|
|
enum GameMode
|
|
|
|
{
|
|
|
|
kTRAINING,
|
|
|
|
kFREEGAME,
|
|
|
|
kDUPLICATE
|
|
|
|
};
|
|
|
|
|
2011-08-28 17:29:39 +02:00
|
|
|
/**
|
|
|
|
* Game variants: they slightly modifies the rules of the game.
|
|
|
|
* Note that the Joker and Explosive variants are incompatible.
|
|
|
|
*/
|
|
|
|
static const unsigned int kNO_VARIANT = 0; // Normal game rules
|
|
|
|
static const unsigned int kJOKER_VARIANT = 1; // Joker game
|
|
|
|
static const unsigned int kEXPLOSIVE_VARIANT = 2; // "Explosive" game
|
|
|
|
static const unsigned int k7AMONG8_VARIANT = 4; // Play up to 7 letters from a rack containing 8
|
2011-08-27 19:21:26 +02:00
|
|
|
|
2011-08-28 18:44:34 +02:00
|
|
|
/**
|
|
|
|
* The dictionary does not belong to this class
|
|
|
|
* (it won't be destroyed by ~GameParams())
|
|
|
|
*/
|
|
|
|
GameParams(const Dictionary &iDic,
|
|
|
|
GameMode iMode, unsigned int iVariants = 0)
|
|
|
|
: m_dic(iDic), m_mode(iMode), m_variants(iVariants)
|
2011-08-27 19:21:26 +02:00
|
|
|
{
|
|
|
|
// Set default values
|
2011-08-28 17:29:39 +02:00
|
|
|
m_rackSize = hasVariant(k7AMONG8_VARIANT) ? 8 : 7;
|
2011-08-27 19:21:26 +02:00
|
|
|
m_lettersToPlay = 7;
|
|
|
|
m_bonusPoints = 50;
|
2011-08-28 17:29:39 +02:00
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
if (hasVariant(kJOKER_VARIANT) && hasVariant(kEXPLOSIVE_VARIANT))
|
|
|
|
throw GameException("Incompatible variants: Joker and Explosive");
|
2011-08-27 19:21:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Getters
|
2011-08-28 18:44:34 +02:00
|
|
|
const Dictionary & getDic() const { return m_dic; }
|
2011-08-28 18:20:00 +02:00
|
|
|
GameMode getMode() const { return m_mode; }
|
2011-08-28 17:29:39 +02:00
|
|
|
bool hasVariant(unsigned int iVariant) const { return m_variants & iVariant; }
|
2011-08-27 19:21:26 +02:00
|
|
|
int getRackSize() const { return m_rackSize; }
|
|
|
|
int getLettersToPlay() const { return m_lettersToPlay; }
|
|
|
|
int getBonusPoints() const { return m_bonusPoints; }
|
|
|
|
|
|
|
|
private:
|
2011-08-28 18:44:34 +02:00
|
|
|
const Dictionary &m_dic;
|
2011-08-28 18:20:00 +02:00
|
|
|
GameMode m_mode;
|
2011-08-28 17:29:39 +02:00
|
|
|
unsigned int m_variants;
|
2011-08-27 19:21:26 +02:00
|
|
|
int m_rackSize;
|
|
|
|
int m_lettersToPlay;
|
|
|
|
int m_bonusPoints;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|