Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 15 / Chess / Figures / Pawn / Pawn.cpp
diff options
context:
space:
mode:
1 files changed, 31 insertions, 0 deletions
-rw-r--r--Sem. 15/Chess/Figures/Pawn/Pawn.cpp31
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 <cmath>
+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