-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMove.cpp
More file actions
49 lines (36 loc) · 1.49 KB
/
Move.cpp
File metadata and controls
49 lines (36 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Move.h"
#include <bits/stdc++.h>
#include "Piece.h"
Move::Move(std::optional<std::string> _source,
std::optional<std::string> _destination,
std::optional<Piece> _replacement)
: source(_source), destination(_destination), replacement(_replacement) {}
std::optional<std::string> Move::getSource() { return source; }
std::optional<std::string> Move::getDestination() { return destination; }
std::optional<Piece> Move::getReplacement() { return replacement; }
bool Move::isNormal() {
return this->source.has_value() && this->destination.has_value() &&
!this->replacement.has_value();
}
bool Move::isPromotion() {
return this->source.has_value() && this->destination.has_value() &&
this->replacement.has_value();
}
bool Move::isDropIn() {
return !this->source.has_value() && this->destination.has_value() &&
this->replacement.has_value();
}
Move* Move::moveTo(std::optional<std::string> source,
std::optional<std::string> destination) {
return new Move(source, destination, {});
}
Move* Move::promote(std::optional<std::string> source,
std::optional<std::string> destination,
std::optional<Piece> replacement) {
return new Move(source, destination, replacement);
}
Move* Move::dropIn(std::optional<std::string> destination,
std::optional<Piece> replacement) {
return new Move({}, destination, replacement);
}
Move* Move::resign() { return new Move({}, {}, {}); }