Piece position at the Board.
More...
#include <board.hpp>
Piece position at the Board.
◆ Mode
◆ Position() [1/5]
tt::Position::Position |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Create Position object with coordinates x
y
- Parameters
-
x | x coordinate |
y | y coordinate |
◆ Position() [2/5]
tt::Position::Position |
( |
char |
l, |
|
|
int |
d |
|
) |
| |
Create Position object with coordinates ld
(eq. b3
)
- Parameters
-
l | letter x coordinate |
d | digit y coordinate |
◆ Position() [3/5]
Creates Position object at str
position.
The str
arguments has the form of
int x() const
x coordinate
Definition board.hpp:123
int y() const
y coordinate
Definition board.hpp:128
where the <x>
is the lowercase letter in range a-h inclusive, <y>
is a number from range [1;8].
Table for <x>
letter-to-digit mapping
Letter | Digit |
a | 1 |
b | 2 |
c | 3 |
d | 4 |
e | 5 |
f | 6 |
g | 7 |
h | 8 |
Example arguments:
Argument | x() | y() |
"d4" | 4 | 4 |
"e7" | 5 | 7 |
"h3" | 8 | 3 |
- Parameters
-
str | 2-character letter-digit string representation of position |
◆ Position() [4/5]
tt::Piece::Position::Position |
( |
const char * |
str | ) |
|
|
inline |
Creates Position object at str
position.
The str
arguments has the form of
where the <x>
is the lowercase letter in range a-h inclusive, <y>
is a number from range [1;8].
Table for <x>
letter-to-digit mapping
Letter | Digit |
a | 1 |
b | 2 |
c | 3 |
d | 4 |
e | 5 |
f | 6 |
g | 7 |
h | 8 |
Example arguments:
Argument | x() | y() |
"d4" | 4 | 4 |
"e7" | 5 | 7 |
"h3" | 8 | 3 |
- Parameters
-
str | 2-character letter-digit string representation of position |
◆ Position() [5/5]
tt::Position::Position |
( |
const Position & |
other | ) |
|
Copy constructor.
- Note
- Copying does not copy the current Position::mode.
◆ atBottom()
bool tt::Position::atBottom |
( |
| ) |
const |
Check if the position are at bottom border.
- Note
- This function behaivor is influenced by current mode() value.
- Returns
true
if position is at left border false
otherwise
- See also
- setMode().
- Returns
true
if position is at bottom border, false
otherwise
- See also
- mode().
◆ atLeft()
bool tt::Position::atLeft |
( |
| ) |
const |
Check if the position are at left border.
- Note
- This function behaivor is influenced by current mode() value.
- Returns
true
if position is at left border false
otherwise
- See also
- setMode().
◆ atRight()
bool tt::Position::atRight |
( |
| ) |
const |
Check if the position are at right border.
- Note
- This function behaivor is influenced by current mode() value.
- Returns
true
if position is at left border false
otherwise
- See also
- setMode().
- Returns
true
if position is at right border false
otherwise
- See also
- mode().
◆ atTop()
bool tt::Position::atTop |
( |
| ) |
const |
Check if the position are at top border.
- Note
- This function behaivor is influenced by current mode() value.
- Returns
true
if position is at left border false
otherwise
- See also
- setMode().
- Returns
true
if position is at top border false
otherwise
- See also
- mode().
◆ digit()
int tt::Piece::Position::digit |
( |
| ) |
const |
|
inline |
Digit representation of y coordinate.
- Returns
- y coordinate in digit representation
- See also
- y()
◆ letter()
char tt::Piece::Position::letter |
( |
| ) |
const |
|
inline |
Letter representation of x coordinate.
- Returns
- x coordinate in letter representation
- See also
- x()
◆ mode()
Mode tt::Piece::Position::mode |
( |
| ) |
const |
|
inline |
◆ offset() [1/2]
Position tt::Position::offset |
( |
char |
dc, |
|
|
int |
dd |
|
) |
| const |
Offset current position.
Works as offset(int dx, int dy) but with character-digit representation
- Parameters
-
dc | x coordinate incrementation represented as string |
dd | y coordinate incrementation |
- Returns
- new Position object at (x±dx, y±dy).
- Exceptions
-
- See also
- offsetMode().
◆ offset() [2/2]
Position tt::Position::offset |
( |
int |
dx, |
|
|
int |
dy |
|
) |
| const |
Offset current position.
Returns new position at (x±dx, y±dy). Operation sign depends on current mode().
- Parameters
-
dx | x coordinate incrementation |
dy | y coordinate incrementation |
- Returns
- new Position object at (x±dx, y±dy).
- Exceptions
-
- See also
- mode().
◆ operator()() [1/2]
Position tt::Position::operator() |
( |
char |
dc, |
|
|
int |
dd |
|
) |
| const |
Offset current position.
Works as offset(int dx, int dy) but with character-digit representation
- Parameters
-
dc | x coordinate incrementation represented as string |
dd | y coordinate incrementation |
- Returns
- new Position object at (x±dx, y±dy).
- Exceptions
-
- See also
- offsetMode().
◆ operator()() [2/2]
Position tt::Position::operator() |
( |
int |
dx, |
|
|
int |
dy |
|
) |
| const |
Offset current position.
Returns new position at (x±dx, y±dy). Operation sign depends on current mode().
- Parameters
-
dx | x coordinate incrementation |
dy | y coordinate incrementation |
- Returns
- new Position object at (x±dx, y±dy).
- Exceptions
-
- See also
- mode().
◆ operator+()
Addition operator.
- Returns
- new object with sum of corresponding coordinates of argument objects
◆ operator+=()
◆ operator-()
Substraction operator.
- Returns
- new object with difference of corresponding coordinates of argument objects
◆ operator-=()
◆ operator=()
Copy assignment operator.
- Note
- Copying does not copy the current Position::mode.
- Returns
- a new object with same coordinates.
◆ setDigit()
int tt::Piece::Position::setDigit |
( |
short |
y | ) |
|
|
inline |
Set y coordinate.
- Parameters
-
- Returns
- old value
- Exceptions
-
- See also
- setY(int)
◆ setLetter()
char tt::Piece::Position::setLetter |
( |
char |
x | ) |
|
|
inline |
Set x coordinate with string representation.
- Parameters
-
x | x coordinate represented as string |
- Returns
- old value
◆ setMode()
Set offset mode.
- Note
- Depending on the mode() value, functions from Position manipulation group behave differently.
- Parameters
-
- Returns
- old offset mode value
◆ setX()
int tt::Position::setX |
( |
int |
x | ) |
|
Set x coordinate.
- Parameters
-
- Returns
- old value
- Exceptions
-
◆ setY()
int tt::Position::setY |
( |
int |
y | ) |
|
Set y coordinate.
- Parameters
-
- Returns
- old value
- Exceptions
-
◆ str()
String position representation.
- Returns
- string representation of current position
◆ x()
int tt::Piece::Position::x |
( |
| ) |
const |
|
inline |
x coordinate
- Returns
- x coordinate
◆ y()
int tt::Piece::Position::y |
( |
| ) |
const |
|
inline |
y coordinate
- Returns
- y coordinate
◆ operator<<
◆ operator==
Comparison operator.
- Returns
true
if corresponding coordinates of both objects are equal
The documentation for this class was generated from the following files:
- board/include/tartan/board/board.hpp
- board/position.cpp