[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot game/board.cpp game/board.h utils/game_io...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot game/board.cpp game/board.h utils/game_io... |
Date: |
Tue, 23 Jun 2009 13:21:20 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 09/06/23 13:21:20
Modified files:
game : board.cpp board.h
utils : game_io.cpp
Log message:
More uses of the display characters
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/board.cpp?cvsroot=eliot&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/eliot/game/board.h?cvsroot=eliot&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/game_io.cpp?cvsroot=eliot&r1=1.17&r2=1.18
Patches:
Index: game/board.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/board.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- game/board.cpp 23 Jun 2009 12:56:40 -0000 1.24
+++ game/board.cpp 23 Jun 2009 13:21:19 -0000 1.25
@@ -20,6 +20,7 @@
*****************************************************************************/
#include <wctype.h>
+#include <algorithm>
#include "dic.h"
@@ -112,23 +113,20 @@
}
-wchar_t Board::getChar(int iRow, int iCol) const
+const Tile& Board::getTile(int iRow, int iCol) const
{
- wchar_t letter = 0;
- Tile tile = getTile(iRow, iCol);
- if (!tile.isEmpty())
- {
- letter = tile.toChar();
- if (isJoker(iRow, iCol))
- letter = towlower(letter);
- }
- return letter;
+ return m_tilesRow[iRow][iCol];
}
-const Tile& Board::getTile(int iRow, int iCol) const
+wstring Board::getDisplayStr(int iRow, int iCol) const
{
- return m_tilesRow[iRow][iCol];
+ ASSERT(!isVacant(iRow, iCol),
+ "Trying to get the display string on an empty board square");
+ wstring str = getTile(iRow, iCol).getDisplayStr();
+ if (isJoker(iRow, iCol))
+ std::transform(str.begin(), str.end(), str.begin(), towlower);
+ return str;
}
Index: game/board.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/board.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- game/board.h 23 Jun 2009 12:56:40 -0000 1.19
+++ game/board.h 23 Jun 2009 13:21:19 -0000 1.20
@@ -52,17 +52,12 @@
public:
Board();
- /**
- * Return an upper case letter for normal tiles and a
- * lower case letter for jokers.
- * For an empty square, 0 is returned.
- */
- wchar_t getChar(int iRow, int iCol) const;
-
- const Tile& getTile(int iRow, int iCol) const;
bool isJoker(int iRow, int iCol) const;
bool isVacant(int iRow, int iCol) const;
+ const Tile& getTile(int iRow, int iCol) const;
+ wstring getDisplayStr(int iRow, int iCol) const;
+
void addRound(const Dictionary &iDic, const Round &iRound);
void removeRound(const Dictionary &iDic, const Round &iRound);
int checkRound(Round &iRound) const;
Index: utils/game_io.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/game_io.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- utils/game_io.cpp 23 Jun 2009 12:56:40 -0000 1.17
+++ utils/game_io.cpp 23 Jun 2009 13:21:20 -0000 1.18
@@ -50,11 +50,10 @@
out << " " << (char)(row - BOARD_MIN + 'A') << " ";
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
- wchar_t l = iGame.getBoard().getChar(row, col);
- if (l == 0)
+ if (iGame.getBoard().isVacant(row, col))
out << " -";
else
- out << padAndConvert(wstring(1, l), 3);
+ out << padAndConvert(iGame.getBoard().getDisplayStr(row, col),
3);
}
out << endl;
}
@@ -101,13 +100,14 @@
out << " " << (char)(row - BOARD_MIN + 'A') << " ";
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
- wchar_t l = iGame.getBoard().getChar(row, col);
- bool j = iGame.getBoard().isJoker(row, col);
-
- if (l == 0)
- out << " " << (j ? "." : "--");
+ if (iGame.getBoard().isVacant(row, col))
+ out << " --";
else
- out << " " << (j ? "." : " ") << convertToMb(l);
+ {
+ bool j = iGame.getBoard().isJoker(row, col);
+ out << (j ? " ." : " ")
+ << convertToMb(iGame.getBoard().getDisplayStr(row, col));
+ }
}
out << endl;
}
@@ -128,9 +128,8 @@
out << " " << (char)(row - BOARD_MIN + 'A') << " ";
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
- wchar_t l = iGame.getBoard().getChar(row, col);
- if (l != 0)
- out << padAndConvert(wstring(1, l), 3);
+ if (!iGame.getBoard().isVacant(row, col))
+ out << padAndConvert(iGame.getBoard().getDisplayStr(row, col),
3);
else
{
int wm = iGame.getBoard().GetWordMultiplier(row, col);
@@ -163,7 +162,6 @@
out << " " << (char)(row - BOARD_MIN + 'A') << " ";
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
- wchar_t l = iGame.getBoard().getChar(row, col);
int wm = iGame.getBoard().GetWordMultiplier(row, col);
int tm = iGame.getBoard().GetLetterMultiplier(row, col);
@@ -173,7 +171,10 @@
out << " " << ((tm == 3) ? '*' : '+');
else
out << " -";
- out << (l ? convertToMb(l) : "-");
+ if (iGame.getBoard().isVacant(row, col))
+ out << "-";
+ else
+ out << convertToMb(iGame.getBoard().getDisplayStr(row, col));
}
out << endl;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot game/board.cpp game/board.h utils/game_io...,
Olivier Teulière <=