-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhuman.cc
More file actions
43 lines (38 loc) · 1.06 KB
/
human.cc
File metadata and controls
43 lines (38 loc) · 1.06 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
//
// human.cpp
// PawnPusher9000
//
// Created by Lavi on 2015-11-22.
// Copyright © 2015 Lavi. All rights reserved.
//
#include "human.h"
#include <iostream>
#include <string>
using namespace std;
Human::Human(ChessGame & g) : Player(g){
isHuman = true;
}
void Human::makeMove(){
ChessPosition & board= game.getCurrentPosition();
string begPos, endPos;
if (cin >> begPos >> endPos){
bool promotionNeeded=false;
if (board.colourToMove()==0){
if (board.getSquare(begPos)=='P' && endPos[1]=='8') promotionNeeded=true;
}
else {
if (board.getSquare(endPos)=='p' && endPos[1]=='1') promotionNeeded=true;
}
if (promotionNeeded){
char prom;
cin >> prom;
if (prom == 'Q' || prom == 'R' || prom == 'B' || prom=='N'){
if (board.colourToMove()==BLACK){
prom+='a'-'A';
}
game.makeMove(begPos, endPos, prom);
}
}
else game.makeMove(begPos, endPos);
}
}