diff options
fixes
2 files changed, 0 insertions, 109 deletions
| -rw-r--r-- | Sem. 15/Chess/ChessBoard/ChessBoard.cpp | 66 | ||||
| -rw-r--r-- | Sem. 15/Chess/ChessBoard/ChessBoard.h | 43 |
diff --git a/Sem. 15/Chess/ChessBoard/ChessBoard.cpp b/Sem. 15/Chess/ChessBoard/ChessBoard.cpp deleted file mode 100644 index 2c618bd..0000000 --- a/Sem. 15/Chess/ChessBoard/ChessBoard.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "ChessBoard.h" -#include "../FigureFactory/FigureFactory.h" - -ChessBoard::ChessBoard() -{ - - for (int i = 0; i < BOARD_SIZE; i++) - { - board[1][i].f = FigureFactory::createFigure(false, PawnFigure); - board[6][i].f = FigureFactory::createFigure(true, PawnFigure); - } - - board[0][0].f = FigureFactory::createFigure(false, RookFigure); - board[0][7].f = FigureFactory::createFigure(false, RookFigure); - - board[7][0].f = FigureFactory::createFigure(true, RookFigure); - board[7][7].f = FigureFactory::createFigure(true, RookFigure); - - - board[0][1].f = FigureFactory::createFigure(false, KnightFigure); - board[0][6].f = FigureFactory::createFigure(false, KnightFigure); - board[7][1].f = FigureFactory::createFigure(true, KnightFigure);; - board[7][6].f = FigureFactory::createFigure(true, KnightFigure); - - board[0][2].f = FigureFactory::createFigure(false, BishopFigure); - board[0][5].f = FigureFactory::createFigure(false, BishopFigure);; - board[7][2].f = FigureFactory::createFigure(true, BishopFigure); - board[7][5].f = FigureFactory::createFigure(true, BishopFigure); - - board[0][3].f = FigureFactory::createFigure(false, KingFigure); - board[0][4].f = FigureFactory::createFigure(false, QueenFigure); - board[7][4].f = FigureFactory::createFigure(true, QueenFigure); - board[7][3].f = FigureFactory::createFigure(true, KingFigure); -} - -void ChessBoard::print() const -{ - for (int i = 0; i < BOARD_SIZE; i++) - { - for (int j = 0; j < BOARD_SIZE; j++) - { - board[i][j].print(); - } - std::cout << std::endl; - } -} - -void ChessBoard::move(size_t x, size_t y, size_t destX, size_t destY) -{ - - Figure* current = board[x][y].f; - - if (current->getType() == PawnFigure) - { - //Some logic..... - } - else - { - if (board[x][y].f && board[x][y].f->canBeMoved(x, y, destX, destY)) - { - board[destX][destY].f = board[x][y].f; - board[x][y].f = nullptr; - } - } - -}
\ No newline at end of file diff --git a/Sem. 15/Chess/ChessBoard/ChessBoard.h b/Sem. 15/Chess/ChessBoard/ChessBoard.h deleted file mode 100644 index e38acd5..0000000 --- a/Sem. 15/Chess/ChessBoard/ChessBoard.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "../Figures/FigureBase/Figure.h" - -const size_t BOARD_SIZE = 8; -class ChessBoard -{ - struct Cell - { - Figure* f = nullptr; - Cell() = default; - - Cell(const Cell& other) = delete; - Cell& operator=(const Cell& other) = delete; - bool isEmpty() - { - return f == nullptr; - } - - void print() const - { - if (f != nullptr) - f->print(); - else - std::cout << ' '; - } - - ~Cell() - { - delete f; - } - }; - Cell board[BOARD_SIZE][BOARD_SIZE]; - -public: - ChessBoard(); - ChessBoard(const ChessBoard& other) = delete; - ChessBoard& operator=(const ChessBoard&) = delete; - - void print() const; - - void move(size_t x, size_t y, size_t destX, size_t destY); - -}; |
