-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_file.cpp
More file actions
44 lines (42 loc) · 971 Bytes
/
check_file.cpp
File metadata and controls
44 lines (42 loc) · 971 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
36
37
38
39
40
41
42
43
44
#pragma once
#include "table.hpp"
/**
* @brief pre-plays the moves from a file to see if the file has valid moves
*
* @param none
*
* @return true
* @return false
*/
bool Table::checkFile()
{
// Check if the file is empty
if (moves.size() == 0)
{
return false;
}
// simulating the game
coor c;
marker();
while (true)
{
if (!hasTileToFlip())
break;
c = fileMoves();
// if any illegal move is found, the file is not valid
if (!isLegal(c))
return false;
// legal tiles are flipped here
flipTiles(c);
// switching the side when a move is done
switchTurn();
// in case there is no legal move for the next user the side is switched
if (!hasTileToFlip())
{
switchTurn();
}
}
// reconstructing the board
constructor();
return true;
}