eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] Changes to eliot/game/player.h [antoine-1]


From: eliot-dev
Subject: [Eliot-dev] Changes to eliot/game/player.h [antoine-1]
Date: Sun, 23 Oct 2005 13:16:34 -0400

Index: eliot/game/player.h
diff -u /dev/null eliot/game/player.h:1.7.2.1
--- /dev/null   Sun Oct 23 17:16:34 2005
+++ eliot/game/player.h Sun Oct 23 17:16:24 2005
@@ -0,0 +1,149 @@
+<<<<<<< player.h
+/* Copyright (C) 2004-2005 Eliot                                             */
+/* Authors: Olivier Teuliere  <address@hidden>                            */
+/*                                                                           */
+/* This file is part of Eliot.                                               */
+/*                                                                           */
+/* Eliot 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.                                       */
+/*                                                                           */
+/* Eliot 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: player.h,v 1.7.2.1 2005/10/23 17:16:24 afrab Exp $ */
+
+/**
+ *  \file   player.h
+ *  \brief  Eliot player class
+ *  \author Olivier Teuliere
+ *  \date   2005
+ */
+=======
+/*****************************************************************************
+ * Copyright (C) 2004-2005 Eliot
+ * Authors: Olivier Teuliere  <address@hidden>
+ *
+ * $Id: player.h,v 1.7.2.1 2005/10/23 17:16:24 afrab Exp $
+ *
+ * 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
+ *****************************************************************************/
+>>>>>>> 1.7
+
+#ifndef _PLAYER_H_
+#define _PLAYER_H_
+
+#include <vector>
+#include <string>
+
+#include "history.h"
+
+/**
+ * This class is the parent classes for all the players involved in a game.
+ * It defines the common methods to update the rack, score, etc...
+ *
+ * A player has its own rack and round history. 
+ */
+
+class Player
+{
+ private:
+    /// Player number
+    int m_num;
+
+    /// Score of the player
+    int m_score;
+
+    /// player's name
+    std::string m_name;
+
+    /// History of the player's game 
+    History m_history;
+
+ public:
+    /// Player constructor, defaults to player number 0
+    Player(int number = 0);
+
+    /// Player destructor
+    virtual ~Player();
+
+    // Pseudo RTTI
+    virtual bool isHuman() const = 0;
+
+    /// set player's number
+    void setNumber(int n) { m_num = n; }
+
+    /// get player's number
+    int getNumber() const { return m_num; }
+
+    /// Get the (possibly incomplete) rack of the player
+    const PlayedRack getCurrentRack() const;
+
+    /// Set the current player rack
+    void setCurrentRack(const PlayedRack &iPld);
+
+    /// Get the previous turn
+    const Turn getPreviousTurn() const;
+
+    /// Get the complete player history
+    const History& getHistory() const { return m_history; }
+
+    /// Update the player "history" with the given round and
+    /// a new rack is created with the remaining letters 
+    void playRound(int iTurn, const Round &iRound);
+
+    /// Remove last turn
+    void removeLastTurn();
+
+    /// Add points for the player, used only in FreeGames
+    /// do not use with endTurn as it would duplicate points
+    void addPoints(int s);
+
+    /// Get current points for the player
+    int  getPoints() const;
+
+    /// dump the player's state to a string
+    std::string toString();
+};
+
+
+/**
+ * Human player.
+ */
+class HumanPlayer: public Player
+{
+ public:
+    HumanPlayer() {}
+    virtual ~HumanPlayer() {}
+
+    // Pseudo RTTI
+    virtual bool isHuman() const { return true; }
+};
+
+#endif
+
+
+/// Local Variables:
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// End:
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]