Skip to content

Commit abeae11

Browse files
author
Thumperrr
committed
Added member Type to Piece.
(to be used later with graphics)
1 parent 5a4f655 commit abeae11

File tree

8 files changed

+23
-13
lines changed

8 files changed

+23
-13
lines changed

src/board/Bishop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace chesspp
44
{
55

66
Bishop::Bishop(const Position& bPos, Color c)
7-
:Piece(bPos, Position(80 * 3,0), c)
7+
:Piece(bPos, Position(80 * 3,0), c, Type::BISHOP)
88
{
99

1010
}

src/board/King.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace chesspp
44
{
55
King::King(const Position& bPos, Color c)
6-
:Piece(bPos, Position(80 * 5,0), c)
6+
:Piece(bPos, Position(80 * 5,0), c, Type::KING)
77
{
88

99
}

src/board/Knight.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace chesspp
44
{
55
Knight::Knight(const Position& bPos, Color c)
6-
:Piece(bPos, Position(80 * 2,0), c)
6+
:Piece(bPos, Position(80 * 2,0), c, Type::KNIGHT)
77
{
88

99
}

src/board/Pawn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace chesspp
44
{
55

66
Pawn::Pawn(const Position& bPos, Color c)
7-
:Piece(bPos, Position(0,0), c), firstMove(true)
7+
:Piece(bPos, Position(0,0), c, Type::PAWN), firstMove(true)
88
{
99

1010
}

src/board/Piece.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace chesspp
44
{
5-
Piece::Piece(const Position& bPos, const Position& tPos, Color c)
6-
:boardPos(bPos), color(c)
5+
Piece::Piece(const Position& bPos, const Position& tPos, Color c, Type t)
6+
:boardPos(bPos), color(c), type(t)
77
{
88
int tX = tPos.getX();
99
int tY = tPos.getY() + ( c == WHITE ? 0 : 80 );

src/board/Piece.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// textureX = givenValX
1010
// textureY = givenValY + ( this->color == WHITE ? 0 : 80 )
1111

12-
13-
1412
#include "board\logger.h"
1513

1614
// The contigousness of this container does not matter
@@ -23,13 +21,25 @@ namespace chesspp
2321
class Board;
2422
typedef std::vector<Position> posList;
2523

26-
enum Color {WHITE, BLACK};
24+
enum Color {
25+
WHITE = 0,
26+
BLACK
27+
};
28+
enum Type {
29+
PAWN = 0,
30+
ROOK,
31+
KNIGHT,
32+
BISHOP,
33+
QUEEN,
34+
KING
35+
};
2736

2837
class Piece
2938
{
3039
private:
31-
Position texturePos; // Where in the texture is this pieece? (hardcoded)
40+
Position texturePos; // Where in the texture is this piece? (hardcoded)
3241
const Color color; // What color is this piece (WHITE, BLACK)
42+
const Type type; // What type this piece is.
3343

3444
protected:
3545

@@ -38,7 +48,7 @@ namespace chesspp
3848

3949
public:
4050

41-
Piece(const Position& bPos, const Position& tPos, Color c);
51+
Piece(const Position& bPos, const Position& tPos, Color c, Type t);
4252

4353
// Standard Accesors
4454
const Position& getBoardPos(void) const;

src/board/Queen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace chesspp
44
{
55
Queen::Queen(const Position& bPos, Color c)
6-
:Piece(bPos, Position(80 * 4,0), c)
6+
:Piece(bPos, Position(80 * 4,0), c, Type::QUEEN)
77
{
88

99
}

src/board/Rook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace chesspp
44
{
55
Rook::Rook(const Position& bPos, Color c)
6-
:Piece(bPos, Position(80 * 1,0), c)
6+
:Piece(bPos, Position(80 * 1,0), c, Type::ROOK)
77
{
88

99
}

0 commit comments

Comments
 (0)