[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot game/board.cpp game/board.h qt/board_widg...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot game/board.cpp game/board.h qt/board_widg... |
Date: |
Tue, 23 Jun 2009 12:56:40 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 09/06/23 12:56:40
Modified files:
game : board.cpp board.h
qt : board_widget.cpp
utils : game_io.cpp
Log message:
Simplifications
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/board.cpp?cvsroot=eliot&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/eliot/game/board.h?cvsroot=eliot&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/board_widget.cpp?cvsroot=eliot&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/game_io.cpp?cvsroot=eliot&r1=1.16&r2=1.17
Patches:
Index: game/board.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/board.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- game/board.cpp 12 Mar 2009 18:56:25 -0000 1.23
+++ game/board.cpp 23 Jun 2009 12:56:40 -0000 1.24
@@ -94,7 +94,7 @@
m_crossCol(BOARD_REALDIM, Cross()),
m_pointRow(BOARD_REALDIM, -1),
m_pointCol(BOARD_REALDIM, -1),
- m_testsRow(BOARD_REALDIM, 0),
+ m_testsRow(BOARD_REALDIM, false),
m_isEmpty(true)
{
// No cross check allowed around the board
@@ -125,13 +125,6 @@
return letter;
}
-int Board::getCharAttr(int iRow, int iCol) const
-{
- int t = getTestChar(iRow, iCol);
- int j = isJoker(iRow, iCol);
- return (t << 1) | j;
-}
-
const Tile& Board::getTile(int iRow, int iCol) const
{
@@ -414,7 +407,7 @@
t = iRound.getTile(i);
m_tilesRow[row][col + i] = t;
m_jokerRow[row][col + i] = iRound.isJoker(i);
- m_testsRow[row][col + i] = 1;
+ m_testsRow[row][col + i] = true;
m_tilesCol[col + i][row] = t;
m_jokerCol[col + i][row] = iRound.isJoker(i);
@@ -430,7 +423,7 @@
t = iRound.getTile(i);
m_tilesRow[row + i][col] = t;
m_jokerRow[row + i][col] = iRound.isJoker(i);
- m_testsRow[row + i][col] = 1;
+ m_testsRow[row + i][col] = true;
m_tilesCol[col][row + i] = t;
m_jokerCol[col][row + i] = iRound.isJoker(i);
@@ -449,7 +442,7 @@
if (m_testsRow[row][col])
{
m_tilesRow[row][col] = Tile();
- m_testsRow[row][col] = 0;
+ m_testsRow[row][col] = false;
m_jokerRow[row][col] = false;
m_tilesCol[col][row] = Tile();
@@ -460,7 +453,7 @@
}
-char Board::getTestChar(int iRow, int iCol) const
+bool Board::isTestChar(int iRow, int iCol) const
{
return m_testsRow[iRow][iCol];
}
Index: game/board.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/board.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- game/board.h 17 Jan 2009 14:57:32 -0000 1.18
+++ game/board.h 23 Jun 2009 12:56:40 -0000 1.19
@@ -41,29 +41,23 @@
#define BOARD_REALDIM (BOARD_DIM + 2)
+/**
+ * Representation of the board.
+ *
+ * In all the methods, the given coordinates
+ * have to be BOARD_MIN <= int <= BOARD_MAX.
+ */
class Board
{
public:
Board();
- /*************************
- * Coordinates have to be BOARD_MIN <= int <= BOARD_MAX
- *
- * getChar returns an upper case letter for normal tiles and a
+ /**
+ * Return an upper case letter for normal tiles and a
* lower case letter for jokers.
- *
- * getCharAttr tells the attributes of the tile
- * 0 : normal played tile
- * 1 : joker tile
- * 2 : test tile for preview purpose
- * Attributes can be combined with the or (|) operator
- *************************/
-#define ATTR_NORMAL 0
-#define ATTR_JOKER 1
-#define ATTR_TEST 2
-
- wchar_t getChar (int iRow, int iCol) const;
- int getCharAttr(int iRow, int iCol) const;
+ * 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;
@@ -76,9 +70,9 @@
/**
*
*/
+ bool isTestChar(int iRow, int iCol) const;
void testRound(const Round &iRound);
void removeTestRound();
- char getTestChar(int iRow, int iCol) const;
/**
* board_search.c
@@ -117,7 +111,7 @@
Matrix<int> m_pointRow;
Matrix<int> m_pointCol;
- Matrix<char> m_testsRow;
+ Matrix<bool> m_testsRow;
/// Flag indicating if the board is empty or if it has letters
bool m_isEmpty;
Index: qt/board_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/board_widget.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- qt/board_widget.cpp 23 Jun 2009 12:41:54 -0000 1.14
+++ qt/board_widget.cpp 23 Jun 2009 12:56:40 -0000 1.15
@@ -119,7 +119,7 @@
// Set the brush color
if (m_game != NULL && !m_game->getBoard().getTile(row,
col).isEmpty())
{
- if (m_game->getBoard().getCharAttr(row, col) & ATTR_TEST)
+ if (m_game->getBoard().isTestChar(row, col))
painter.setBrush(PreviewColour);
else
painter.setBrush(TileColour);
@@ -142,7 +142,7 @@
wstring chr = m_game->getBoard().getTile(row,
col).getDisplayStr();
// Make the display char in upper case
std::transform(chr.begin(), chr.end(), chr.begin(), towupper);
- if (m_game->getBoard().getCharAttr(row, col) & ATTR_JOKER)
+ if (m_game->getBoard().isJoker(row, col))
painter.setPen(JokerColour);
painter.setFont(letterFont);
painter.drawText(xPos, yPos + 1, squareSize, squareSize,
@@ -150,8 +150,7 @@
painter.setPen(NormalColour);
// Draw the points of the tile
- if (showPoints &&
- !m_game->getBoard().getCharAttr(row, col) & ATTR_JOKER)
+ if (showPoints && !m_game->getBoard().isJoker(row, col))
{
painter.setFont(pointsFont);
painter.drawText(xPos + squareSize * (1 - pointsCoeff),
Index: utils/game_io.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/game_io.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- utils/game_io.cpp 23 Jun 2009 12:41:54 -0000 1.16
+++ utils/game_io.cpp 23 Jun 2009 12:56:40 -0000 1.17
@@ -102,7 +102,7 @@
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
wchar_t l = iGame.getBoard().getChar(row, col);
- bool j = (iGame.getBoard().getCharAttr(row, col) & ATTR_JOKER);
+ bool j = iGame.getBoard().isJoker(row, col);
if (l == 0)
out << " " << (j ? "." : "--");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot game/board.cpp game/board.h qt/board_widg...,
Olivier Teulière <=