[Move] Fix streaming with promotion

This commit is contained in:
2022-12-21 21:05:05 +01:00
parent 16c7fe2a34
commit 11c84472d4
3 changed files with 30 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
#include "Move.hpp"
#include <ostream>
#include <iostream>
Move::Move(const Square &from, const Square &to, const std::optional<PieceType> &promotion)
: mFrom(from), mTo(to), mPromotion(promotion) {
@@ -41,7 +42,7 @@ std::optional<PieceType> Move::promotion() const {
std::ostream &operator<<(std::ostream &os, const Move &move) {
os << move.from() << move.to();
if (move.promotion().has_value()) {
os << static_cast<char>(move.promotion().value());
os << move.promotion().value();
}
return os;
}