[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot game/duplicate.cpp game/duplicate.h game/...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot game/duplicate.cpp game/duplicate.h game/... |
Date: |
Sun, 30 Nov 2008 20:51:42 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 08/11/30 20:51:42
Modified files:
game : duplicate.cpp duplicate.h game.cpp training.h
utils : ncurses.cpp
Log message:
Get rid of Duplicate::prevHumanPlayer() and
Duplicate::nextHumanPlayer() + cosmetics
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/duplicate.cpp?cvsroot=eliot&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/eliot/game/duplicate.h?cvsroot=eliot&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.cpp?cvsroot=eliot&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.h?cvsroot=eliot&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/ncurses.cpp?cvsroot=eliot&r1=1.28&r2=1.29
Patches:
Index: game/duplicate.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/duplicate.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- game/duplicate.cpp 23 Nov 2008 17:06:44 -0000 1.27
+++ game/duplicate.cpp 30 Nov 2008 20:51:42 -0000 1.28
@@ -284,32 +284,6 @@
}
-void Duplicate::prevHumanPlayer()
-{
- if (getNHumanPlayers() == 0)
- return;
- // FIXME: possible infinite loop...
- do
- {
- prevPlayer();
- } while (!m_players[m_currPlayer]->isHuman() ||
- m_hasPlayed[m_currPlayer]);
-}
-
-
-void Duplicate::nextHumanPlayer()
-{
- if (getNHumanPlayers() == 0)
- return;
- // FIXME: possible infinite loop...
- do
- {
- nextPlayer();
- } while (!m_players[m_currPlayer]->isHuman() ||
- m_hasPlayed[m_currPlayer]);
-}
-
-
bool Duplicate::hasPlayed(unsigned int p) const
{
ASSERT(p < getNPlayers(), "Wrong player number");
Index: game/duplicate.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/duplicate.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- game/duplicate.h 23 Nov 2008 17:06:44 -0000 1.18
+++ game/duplicate.h 30 Nov 2008 20:51:42 -0000 1.19
@@ -87,12 +87,6 @@
*/
int setPlayer(unsigned int p);
- /// Switch to the previous human player who has not played yet
- void prevHumanPlayer();
-
- /// Switch to the next human player who has not played yet
- void nextHumanPlayer();
-
/// Return true if the player has played for the current turn
virtual bool hasPlayed(unsigned int iPlayerId) const;
Index: game/game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- game/game.cpp 23 Nov 2008 18:18:02 -0000 1.48
+++ game/game.cpp 30 Nov 2008 20:51:42 -0000 1.49
@@ -38,7 +38,6 @@
#include "results.h"
#include "player.h"
#include "game.h"
-#include "game_factory.h"
#include "turn.h"
#include "encoding.h"
#include "game_exception.h"
Index: game/training.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- game/training.h 23 Nov 2008 17:04:40 -0000 1.20
+++ game/training.h 30 Nov 2008 20:51:42 -0000 1.21
@@ -58,15 +58,15 @@
virtual int play(const wstring &iCoord, const wstring &iWord);
void search();
- const Results& getResults() const { return m_results; };
- int playResult(unsigned int);
+ const Results& getResults() const { return m_results; }
+ int playResult(unsigned int iResultIndex);
/**
* Complete (or reset) the rack randomly.
* @exception EndGameException if it is impossible to complete the rack
* for some reason...
*/
- void setRackRandom(bool, set_rack_mode);
+ void setRackRandom(bool iCheck, set_rack_mode iRackMode);
int setRackManual(bool iCheck, const wstring &iLetters);
@@ -87,7 +87,7 @@
*************************/
/// Place a temporary word on the board for preview purposes
- void testPlay(unsigned int);
+ void testPlay(unsigned int iResultIndex);
/// Remove the temporary word
void removeTestPlay();
/// Get the temporary word
Index: utils/ncurses.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/ncurses.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- utils/ncurses.cpp 7 Sep 2008 13:17:42 -0000 1.28
+++ utils/ncurses.cpp 30 Nov 2008 20:51:42 -0000 1.29
@@ -879,8 +879,23 @@
{
case 'n':
case 'N':
- iGame.nextHumanPlayer();
+ {
+ // Get the human players who have not played yet
+ set<unsigned int> humans;
+ for (unsigned int id = 0; id < iGame.getNPlayers(); ++id)
+ {
+ if (iGame.getPlayer(id).isHuman() && !iGame.hasPlayed(id))
+ humans.insert(id);
+ }
+ unsigned int currId = iGame.getCurrentPlayer().getId();
+ // Try to find a player with a bigger ID
+ set<unsigned int>::const_iterator it = humans.upper_bound(currId);
+ if (it != humans.end())
+ iGame.setPlayer(*it);
+ else
+ iGame.setPlayer(*humans.begin());
return 1;
+ }
default:
return 2;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot game/duplicate.cpp game/duplicate.h game/...,
Olivier Teulière <=