mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Debug PGN parsing
This commit is contained in:
parent
5691b7b30f
commit
04fe528060
2 changed files with 22 additions and 8 deletions
|
@ -60,9 +60,9 @@ MainWindow::MainWindow()
|
||||||
NewGame(std::shared_ptr<Game>(new Game()));
|
NewGame(std::shared_ptr<Game>(new Game()));
|
||||||
|
|
||||||
// Temporary TO REMOVE JUST FOR TESTS:
|
// Temporary TO REMOVE JUST FOR TESTS:
|
||||||
/*BaseTab *bt = new BaseTab((wxFrame *)notebook, "/home/loic/pgn/Milov.pgn");
|
//BaseTab *bt = new BaseTab((wxFrame *)notebook, "/home/loic/jean.pgn");
|
||||||
this->AddPage(bt,bt);
|
//this->AddPage(bt,bt);
|
||||||
|
/*
|
||||||
bt = new BaseTab((wxFrame *)notebook, "/home/loic/pgn/Milov.pgn");
|
bt = new BaseTab((wxFrame *)notebook, "/home/loic/pgn/Milov.pgn");
|
||||||
this->AddPage(bt,bt);*/
|
this->AddPage(bt,bt);*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,23 @@ std::shared_ptr<Game> PGNGameBase::GetCurrentGame() {
|
||||||
if (pgn->HasTag("FEN")) {
|
if (pgn->HasTag("FEN")) {
|
||||||
fen = pgn->GetTagValue("FEN");
|
fen = pgn->GetTagValue("FEN");
|
||||||
}
|
}
|
||||||
HalfMove *m = new HalfMove(pgnp_moves);
|
|
||||||
m->SetFen(fen);
|
// Init game object
|
||||||
Game *g = new Game(m, fen);
|
Game *g;
|
||||||
|
if(pgnp_moves->count == -1){ // Check if PGN contains at least a move
|
||||||
|
g=new Game(fen);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HalfMove *m = new HalfMove(pgnp_moves);
|
||||||
|
m->SetFen(fen);
|
||||||
|
g=new Game(m, fen);
|
||||||
|
}
|
||||||
|
// Setup game object
|
||||||
for (std::string &s : pgn->GetTagList()) {
|
for (std::string &s : pgn->GetTagList()) {
|
||||||
g->SetTag(s, pgn->GetTagValue(s));
|
g->SetTag(s, pgn->GetTagValue(s));
|
||||||
}
|
}
|
||||||
g->SetResult(pgn->GetResult());
|
g->SetResult(pgn->GetResult());
|
||||||
|
// Finish
|
||||||
return (std::shared_ptr<Game>(g));
|
return (std::shared_ptr<Game>(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +154,13 @@ std::string PGNGameBase::GetPGN(std::shared_ptr<Game> g) {
|
||||||
for (auto const &element : g->ListTags()) {
|
for (auto const &element : g->ListTags()) {
|
||||||
pgn += '[' + element + " \"" + g->GetTag(element) + "\"]\n";
|
pgn += '[' + element + " \"" + g->GetTag(element) + "\"]\n";
|
||||||
}
|
}
|
||||||
pgn += GetMovesPGN(m,m->IsABlackMove());
|
|
||||||
|
|
||||||
pgn += " " + g->GetResult();
|
if(m !=NULL){
|
||||||
|
pgn += GetMovesPGN(m,m->IsABlackMove());
|
||||||
|
pgn += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
pgn += g->GetResult();
|
||||||
return (pgn);
|
return (pgn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue