/[eliot]/eliot/game/player.h
ViewVC logotype

Diff of /eliot/game/player.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by ipkiss, Sun Oct 23 14:53:43 2005 UTC revision 1.7.2.1 by afrab, Sun Oct 23 17:16:24 2005 UTC
# Line 1  Line 1 
1    <<<<<<< player.h
2    /* Copyright (C) 2004-2005 Eliot                                             */
3    /* Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>                            */
4    /*                                                                           */
5    /* This file is part of Eliot.                                               */
6    /*                                                                           */
7    /* Eliot is free software; you can redistribute it and/or modify             */
8    /* it under the terms of the GNU General Public License as published by      */
9    /* the Free Software Foundation; either version 2 of the License, or         */
10    /* (at your option) any later version.                                       */
11    /*                                                                           */
12    /* Eliot is distributed in the hope that it will be useful,                  */
13    /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
14    /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
15    /* GNU General Public License for more details.                              */
16    /*                                                                           */
17    /* You should have received a copy of the GNU General Public License         */
18    /* along with this program; if not, write to the Free Software               */
19    /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
20    
21    /* $Id$ */
22    
23    /**
24     *  \file   player.h
25     *  \brief  Eliot player class
26     *  \author Olivier Teuliere
27     *  \date   2005
28     */
29    =======
30  /*****************************************************************************  /*****************************************************************************
31   * Copyright (C) 2004-2005 Eliot   * Copyright (C) 2004-2005 Eliot
32   * Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>   * Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>
# Line 18  Line 47 
47   * along with this program; if not, write to the Free Software   * along with this program; if not, write to the Free Software
48   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
49   *****************************************************************************/   *****************************************************************************/
50    >>>>>>> 1.7
51    
52  #ifndef _PLAYER_H_  #ifndef _PLAYER_H_
53  #define _PLAYER_H_  #define _PLAYER_H_
54    
55  #include <vector>  #include <vector>
56    #include <string>
57    
58  class Playedrack;  #include "history.h"
 class Round;  
 class Board;  
 typedef struct _Dictionary * Dictionary;  
   
59    
60  /**  /**
61   * This class is the parent classes for all the players involved in a game.   * This class is the parent classes for all the players involved in a game.
62   * It defines the common metohds to update the rack, score, etc...   * It defines the common methods to update the rack, score, etc...
63     *
64     * A player has its own rack and round history.
65   */   */
66    
67  class Player  class Player
68  {  {
69  public:   private:
70      Player();      /// Player number
71        int m_num;
72    
73        /// Score of the player
74        int m_score;
75    
76        /// player's name
77        std::string m_name;
78    
79        /// History of the player's game
80        History m_history;
81    
82     public:
83        /// Player constructor, defaults to player number 0
84        Player(int number = 0);
85    
86        /// Player destructor
87      virtual ~Player();      virtual ~Player();
88    
89      // Pseudo RTTI      // Pseudo RTTI
90      virtual bool isHuman() const = 0;      virtual bool isHuman() const = 0;
91    
92      /**************************      /// set player's number
93       * General getters      void setNumber(int n) { m_num = n; }
94       **************************/  
95      // Get the (possibly incomplete) rack of the player      /// get player's number
96      const PlayedRack & getCurrentRack() const;      int getNumber() const { return m_num; }
     // Get the previous rack  
     const PlayedRack & getLastRack() const;  
     // Get the previous round (corresponding to the previous rack...)  
     const Round & getLastRound() const;  
97    
98        /// Get the (possibly incomplete) rack of the player
99        const PlayedRack getCurrentRack() const;
100    
101        /// Set the current player rack
102      void setCurrentRack(const PlayedRack &iPld);      void setCurrentRack(const PlayedRack &iPld);
103    
104      /**************************      /// Get the previous turn
105       * Acessors for the score of the player      const Turn getPreviousTurn() const;
      **************************/  
     // Add (or remove, if iPoints is negative) points to the score  
     // of the player  
     void addPoints(int iPoints) { m_score += iPoints; }  
     int  getPoints() const      { return m_score; }  
   
     // Update the player "history", with the given round.  
     // A new rack is created with the remaining letters  
     void endTurn(const Round &iRound, int iTurn);  
106    
107  private:      /// Get the complete player history
108      // Score of the player      const History& getHistory() const { return m_history; }
     int m_score;  
109    
110      // History of the racks and rounds for the player      /// Update the player "history" with the given round and
111      vector<PlayedRack *> m_playedRacks;      /// a new rack is created with the remaining letters
112      vector<Round *> m_rounds;      void playRound(int iTurn, const Round &iRound);
113      vector<int> m_turns;  
114        /// Remove last turn
115        void removeLastTurn();
116    
117        /// Add points for the player, used only in FreeGames
118        /// do not use with endTurn as it would duplicate points
119        void addPoints(int s);
120    
121        /// Get current points for the player
122        int  getPoints() const;
123    
124        /// dump the player's state to a string
125        std::string toString();
126  };  };
127    
128    
# Line 83  private: Line 131  private:
131   */   */
132  class HumanPlayer: public Player  class HumanPlayer: public Player
133  {  {
134  public:   public:
135      HumanPlayer() {}      HumanPlayer() {}
136      virtual ~HumanPlayer() {}      virtual ~HumanPlayer() {}
137    
# Line 93  public: Line 141  public:
141    
142  #endif  #endif
143    
144    
145    /// Local Variables:
146    /// mode: hs-minor
147    /// c-basic-offset: 4
148    /// End:
149    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.7.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26