Source: ksirk/player.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          player.h  -  description
                             -------------------
    begin                : Wed Jul 18 2001
    copyright            : (C) 2001 by Gaël de Chalendar
    email                : Gael.de.Chalendar@libertysurf.fr
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
#define KDE_NO_COMPAT

#ifndef  PLAYER_H
#define PLAYER_H

#include "global.h"
#include "nationality.h"

#include 
#include 
#include 
#include 

class Nationality;

/**
  * The class Player represents a player and its associated data
  */
class Player : public QObject
{
	Q_OBJECT
public:

	/**
	  * Constructor with simple initializations
	  */
	Player(QString &nomPlayer, int nbArmies, Nationality* myNation) :
		name(nomPlayer), nbCountries(0), nbAvailArmies(nbArmies), nbAttack(0), 
		nbDefense(0), nation(myNation) {}

	/**
	  * bit to bit comparison
	  */
	virtual int operator ==(Player Arg1) const;

	/**
	  * Accessors to the variables
	  */
	void setNbAvailArmies(int nb);
	int getNbAvailArmies(void);
	void setNbAttack(int nb);
	int getNbAttack(void);
	void setNbDefense(int nb);
	int getNbDefense(void);
	void setNbCountries(int nb);
	int getNbCountries(void);
	void setName(QString &nomPlayer);
	const QString &getName(void) const;
//	void setNum(int nb);
//	int getNum(void);

	/**
	  * Add/Remove nb armies to the number of available armies (defaults to 1)
	  */
	void incrNbAvailArmies(int nb=1);
	void decrNbAvailArmies(int nb=1);

	/**
	  * Add/Remove nb countries to the player (defaults to 1)
	  */
	void incrNbCountries(int nb=1);
	void decrNbCountries(int nb=1);

	/** This function returns the flag associated to the nationality of the player */
	const AnimSprite* getFlag(void) const;
	const QString& getFlagFileName(void) const;

	/**
	  * This function is called whenever the player should choose an action
	  * (attack, defence, etc.). If the player is human, this method do nothing
	  * and so is empty. Its inherited version, in AIPlayer will have an activity
	  */
	virtual void actionChoice(GameState state) {}

	/**
	  * Returns false (a Player is not an AI)
	  */
	virtual bool isAI(void) const;

	/**
	  * Read property of QPtrQueue clickedPoints.
	  */
	virtual QPtrQueue* getClickedPoints() {return 0;}

	/**
	  * Read property of QPtrQueue actionsQueue.
	  */
	virtual QPtrQueue* getActionsQueue() {return 0;}

private:

	/**
	  * The player's name
	  */
	QString name;

	/**
	  * Number of countries owned by the player
	  */
	int nbCountries;

	/**
	  * Number of armies the player can distribute
	  */
	int nbAvailArmies;

	/**
	  * Number of armies used for an attack
	  * (  0 <> 3, < nbArmies of the country )
	  */
	int nbAttack;

	/**
	  * Number of armies used for defense
	  * (  0 <> 2, <= nbArmies used for the attack, < nbArmies of the country )
	  */
	int nbDefense;

	/**
	  * Numerical id of the player
	  */
//	int num;

	/**
	  * The nation choosen by the player
	  */
	Nationality *nation;
};

typedef QPtrList PlayersArray;
#endif // PLAYER_H

Generated by: gael on noirdes.limsi.u-psud.fr on Fri Jan 3 17:03:38 2003, using kdoc 2.0a53.