From 50444e86ea5048e05b8eb74055e0f7c4d2c5d7b7 Mon Sep 17 00:00:00 2001 From: angeld55 Date: Thu, 10 Jun 2021 18:54:25 +0300 Subject: sem 15 --- Sem. 15/Chess/Figures/Pawn/Pawn.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Sem. 15/Chess/Figures/Pawn/Pawn.cpp (limited to 'Sem. 15/Chess/Figures/Pawn/Pawn.cpp') diff --git a/Sem. 15/Chess/Figures/Pawn/Pawn.cpp b/Sem. 15/Chess/Figures/Pawn/Pawn.cpp new file mode 100644 index 0000000..fd04dad --- /dev/null +++ b/Sem. 15/Chess/Figures/Pawn/Pawn.cpp @@ -0,0 +1,31 @@ +#include "Pawn.h" +#include +Pawn::Pawn(bool isWhite) : Figure(isWhite), isFirstMove(true) +{} +bool Pawn::canBeMoved(size_t currentX, size_t currentY, size_t destX, size_t destY) const +{ + /*if (currentX != destX) + return false; + + int diff = destY - currentY; + + if (abs(diff) > 2) + return false; + + if (diff < 0 && getIsWhite() || diff > 0 && !getIsWhite()) + return false; + + if (!abs(diff) == 2 || isFirstMove) + { + return true; + } + return false;*/ + return false; +} +void Pawn::print() const +{ + if (getIsWhite()) + std::cout << 'P'; + else + std::cout << 'p'; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d