-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveRecorder.cpp
More file actions
78 lines (73 loc) · 2.49 KB
/
Copy pathMoveRecorder.cpp
File metadata and controls
78 lines (73 loc) · 2.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Created by squig on 29/3/22.
//
#include "MoveRecorder.h"
#include "Board.h"
#include <ctime>
#include <iostream>
#include <fstream>
#include <string>
MoveRecorder::MoveRecorder() = default;
void MoveRecorder::setMove(int input) {
this->move = input;
}
int MoveRecorder::getMove(){
return this->move;
};
void MoveRecorder::recordMove(int x, int y, int xa, int ya, Board moveBoard){
move++;
time_t current = time(nullptr);
std::string dateTime = ctime(¤t);
std::string piece;
std::ofstream fileHandle;
fileHandle.open("Chess.txt",std::ios_base::app);
fileHandle << "[" << move << "]" << "\n";
fileHandle << "(" << x << "," << y << ":" << xa << "," << ya << ")" <<"\n" << "<" << moveBoard.returnSquare(xa,ya) << ">" << "\n" ;
fileHandle << "*****" << "\n";
for(int e = 0; e < 8; e++){
for(int i = 0; i < 8; i++){
piece = moveBoard.returnSquare(e,i);
if(piece == "White Left Rook")
fileHandle << "wlR,";
if(piece == "White Left Knight")
fileHandle << "wlN,";
if(piece == "White Left Bishop")
fileHandle << "wlB,";
if(piece == "White Queen")
fileHandle << "wQ,";
if(piece == "White King")
fileHandle << "wK,";
if(piece == "White Right Bishop")
fileHandle << "wrB,";
if(piece == "White Right Knight")
fileHandle << "wrN,";
if(piece == "White Right Rook")
fileHandle << "wrR,";
if(piece == "White Pawn")
fileHandle << "wP,";
if(piece == "Black Left Rook")
fileHandle << "blR,";
if(piece == "Black Left Knight")
fileHandle << "blN,";
if(piece == "Black Left Bishop")
fileHandle << "blB,";
if(piece == "Black Queen")
fileHandle << "bQ,";
if(piece == "Black King")
fileHandle << "bK,";
if(piece == "Black Right Bishop")
fileHandle << "brB,";
if(piece == "Black Right Knight")
fileHandle << "brN,";
if(piece == "Black Right Rook")
fileHandle << "brR,";
if(piece == "Black Pawn")
fileHandle << "bP,";
if(piece == "Empty")
fileHandle << "X,";
}
fileHandle << "\n";
}
fileHandle << "+++++" << "\n";
fileHandle.close();
}