-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiece.cpp
More file actions
88 lines (80 loc) · 1.92 KB
/
piece.cpp
File metadata and controls
88 lines (80 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***********************************************************************
* Source File:
* PIECE : Keep track of each piece on the board
* Author:
* Emilio Ordonez
* Summary:
* All the pieces on the board.
************************************************************************/
#include "piece.h"
/**************************************
* PIECE : ASSIGN POS
***************************************/
void Piece::assignPos(Position pos)
{
if (pos.getRow() > 7 || pos.getRow() < 0)
{
return;
}
else if (pos.getCol() > 7 || pos.getCol() < 0)
{
return;
}
position = pos;
nMoves++;
}
/**************************************
* PIECE : CONSTRUCTOR
***************************************/
Piece::Piece(Position p, bool color, PieceType pt)
{
position = p;
fWhite = color;
type = pt;
canSlide = false;
}
/*************************************************
* HAS MOVED() : DETERMINE IF THE PIECE HAS MOVED
***************************************************/
bool Piece::hasMoved()
{
if (nMoves > 0)
{
return true;
}
return false;
}
/******************************************************
* IS VALID() : DETERMINE IF THE PIECE IS NOT A SPACE
*******************************************************/
bool Piece::isValid()
{
if (type == SPACE)
{
return false;
}
return true;
}
/******************************************************
* GET DIRECTIONS() : DETERMINE THE DIRECTIONS EACH PIECE
* CAN GO
*******************************************************/
RC* Piece::getDirections()
{
RC* moves = new RC[4]{
{0, 1},
{-1, 0},
{1, 0},
{0, -1}
};
return moves;
}
//const Piece& Piece::operator= (const Piece& rhs)
//{
// Position position = rhs.position;
// bool fWhite = rhs.fWhite;
// int nMoves = rhs.nMoves;
// PieceType type = rhs.type;
// bool canSlide = rhs.canSlide;
// int possibleDirections = rhs.possibleDirections;
//}