-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
35 lines (31 loc) · 1012 Bytes
/
Copy pathGame.cpp
File metadata and controls
35 lines (31 loc) · 1012 Bytes
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
//
// Created by Max Mitchell on 12/10/2023.
//
#include "Game.h"
Game::Game(const Game &other)
: gameState{other.gameState}
, enPassantTargetSquare{other.enPassantTargetSquare}
, whiteCastlingAvailability{other.whiteCastlingAvailability}
, blackCastlingAvailability{other.blackCastlingAvailability}
, activePlayer{other.activePlayer}
{
for (const auto& pair : other.board) {
board[pair.first] = pair.second->clone();
}
}
Game &Game::operator=(const Game &other) {
if (this != &other) {
Game temp(other);
std::swap(*this, temp);
}
return *this;
}
std::string Game::gameStateAsString(Game::GameState gs) noexcept {
switch (gs) {
case GameState::WHITE_WIN: return "White Wins";
case GameState::BLACK_WIN: return "Black Wins";
case GameState::DRAW: return "Draw";
case GameState::STALEMATE: return "Draw by Stalemate";
case GameState::IN_PROGRESS: return "Game In Progress";
}
}