-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGiph.cpp
More file actions
35 lines (29 loc) · 903 Bytes
/
Giph.cpp
File metadata and controls
35 lines (29 loc) · 903 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
#include "Giph.h"
Giph::Giph() : board({}), parser(new Parser(&board)), validator(new Validator(&board)) {};
Giph::~Giph() {
delete parser;
delete validator;
}
void Giph::Start() {
while (parser->ParseCommand())
CommandManager(parser->command);
CommandManager(parser->command);
}
void Giph::CommandManager(const std::string& command) {
if (command.compare("LOAD_GAME_BOARD") == 0) {
parser->ParseGame();
validator->ValidateBoard();
}
else if (command.find("DO_MOVE") != std::string::npos) {
board.SetMove(command.substr(8, 2), command.substr(11, 2));
if (command.length() > 13) {
board.SetPawnCollectInfo(command[14], command.substr(17, 2), command.substr(20, 2));
validator->ValidateMove(true);
}
else validator->ValidateMove();
}
else if (command.compare("PRINT_GAME_BOARD") == 0) {
if (board.isValid) board.PrintGameState();
else Logger::Log(EMPTY_BOARD);
}
}