2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 #include <QStringList>
22 // TODO: make Board a component
25 * @brief A grid of pieces.
27 * The board class maintains a rectangular grid of Piece objects,
28 * providing methods to access, add, remove and find them.
30 class TAGUA_EXPORT Board
{
32 std::vector
<Piece
> m_data
;
35 * Create a new Board with the given size.
37 explicit Board(const Point
& size
);
40 * Create a Board copying a given one.
42 explicit Board(const Board
* other
);
45 * Compare two boards for equality.
47 bool equals(const Board
* other
) const;
55 * Retrieve a piece from the board.
56 * @param p Coordinates of the piece.
57 * @return The piece at that square, or an invalid piece, if the square is out of the board.
59 Piece
get(const Point
& p
) const;
62 * Add a piece to the board.
63 * @param p Coordinates of the piece.
64 * @param piece The piece to add.
65 * @note This function does nothing if @a p is out of the board.
67 void set(const Point
& p
, const Piece
& piece
);
70 * @return Whether @a p is a valid board square.
72 bool valid(const Point
& p
) const;
75 * @return Information on the path joining @a from and @a to.
77 PathInfo
path(const Point
& from
, const Point
& to
) const;
80 * Searches the board for a given piece.
81 * @return The first square where the piece is found, or an
82 * invalid point, if no such piece exists on the board.
84 Point
find(const Piece
& piece
) const;
87 * Coordinates displayed at the board border.
89 QStringList
borderCoords() const;
92 #endif // CORE__BOARD_H