Commit d44d308f authored by Loic Guegan's avatar Loic Guegan
Browse files

Debug

parent 7bf1d43f
Pipeline #219826845 passed with stage
in 9 minutes and 38 seconds
icons/screenshot.jpg

102 KB | W: | H:

icons/screenshot.jpg

92.5 KB | W: | H:

icons/screenshot.jpg
icons/screenshot.jpg
icons/screenshot.jpg
icons/screenshot.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -92,28 +92,28 @@ void Editor::Draw(Shape shape) {
DC->DrawCircle(shape.x, shape.y, shape.radius);
break;
case Shape::TEXT:
//if (shape.mouseHover)
//DC->SetTextForeground(*wxRED);
// if(shape.target==Shape::MOVE){
// ochess::model::Move *m=(ochess::model::Move *)shape.move->data;
// if(!m->isLongCastle && !m->isShortCastle){
// char p='p';
// if(!m->isPawn){
// shape.text.erase(0,1);
// p=std::tolower(m->piece);
// }
// if(m->isWhite)
// p=std::toupper(p);
// DC->DrawBitmap(*skin.Get(p),wxPoint(shape.x,shape.y));
// DC->DrawText(shape.text, shape.x+16, shape.y);
// }
// else
// DC->DrawText(shape.text, shape.x, shape.y);
//
// }
// else {
if (shape.mouseHover)
DC->SetTextForeground(*wxRED);
if(shape.target==Shape::MOVE){
ochess::model::Move *m=(ochess::model::Move *)shape.move->data;
if(!m->isLongCastle && !m->isShortCastle){
char p='p';
if(!m->isPawn){
shape.text.erase(0,1);
p=std::tolower(m->piece);
}
if(m->isWhite)
p=std::toupper(p);
DC->DrawBitmap(*skin.Get(p),wxPoint(shape.x,shape.y));
DC->DrawText(shape.text, shape.x+16, shape.y);
}
else
DC->DrawText(shape.text, shape.x, shape.y);
}
else {
DC->DrawText(shape.text, shape.x, shape.y);
//}
}
DC->SetTextForeground(*wxBLACK);
break;
}
......
#include "../model/Move.hpp"
namespace ochess
{
namespace model
{
namespace ochess {
namespace model {
void Move::freeMove(Move *m)
{
if (m->main == nullptr && m->variations.size() == 0)
delete (m);
if (m->main != nullptr)
freeMove(m->main);
for (auto v : m->variations)
freeMove(v);
}
Move::Move() : parent(nullptr), main(nullptr), isCheck(false), isPromotion(false),
isCheckMate(false), isPawn(false),
isCapture(false), isLongCastle(false), isShortCastle(false), promoteTo('?'), col('?'),
clk{0}, egt{0}, emt{0}, mct{0},piece('?'),moveId(1),isWhite(true) {
editorMove.move=&SANMove;
editorMove.data=this;
FEN=FEN_INITIAL;
}
void Move::Dump()
{
LOG(info) << "isCheck:" << isCheck << " isPromotion:" << isPromotion << " isCheckMate:" << isCheckMate << " isPawn:" << isPawn << " isCapture:" << isCapture << " isLongCastle:" << isLongCastle << " isShortCastle:" << isShortCastle << " dst:" << dst << " promoteTo:" << promoteTo << " col:" << col << " clk:" << clk[0] << ":" << clk[1] << ":" << clk[2];
}
Move::Move() :
parent(nullptr), main(nullptr), isCheck(false), isPromotion(false), isCheckMate(
false), isPawn(false), isCapture(false), isLongCastle(false), isShortCastle(
false), promoteTo('?'), col('?'), clk { 0 }, egt { 0 }, emt { 0 }, mct {
0 }, piece('?'), moveId(1), isWhite(true) {
editorMove.move = &SANMove;
editorMove.data = this;
FEN = FEN_INITIAL;
}
void Move::Dump() {
LOG(info)
<< "isCheck:" << isCheck << " isPromotion:" << isPromotion
<< " isCheckMate:" << isCheckMate << " isPawn:" << isPawn
<< " isCapture:" << isCapture << " isLongCastle:" << isLongCastle
<< " isShortCastle:" << isShortCastle << " dst:" << dst
<< " promoteTo:" << promoteTo << " col:" << col << " clk:"
<< clk[0] << ":" << clk[1] << ":" << clk[2];
}
Move::~Move()
{
if(this->parent !=nullptr){
this->parent->main=nullptr;
this->parent->editorMove.next=nullptr;
}
if (this->main != nullptr)
delete this->main;
for (auto v : this->variations)
delete v;
Move::~Move() {
if (this->parent != nullptr) {
if (this->parent->main == this) {
this->parent->main = nullptr;
this->parent->editorMove.next = nullptr;
}
}
if (this->main != nullptr)
delete this->main;
for (auto v : this->variations)
delete v;
}
Move Move::FromLA(string move)
{
Move m;
m.Src = move.substr(0, 2);
m.Dst = move.substr(2, 2);
m.promoteTo = ' ';
if (move.size() == 5)
{
m.isPromotion = true;
m.promoteTo = move[4];
}
return (m);
}
bool Move::IsLeaf()
{
return (this->main == nullptr && this->variations.size() == 0);
}
void Move::expand(Move *m)
{
if(this->main==nullptr){
this->main=m;
this->editorMove.next=&(m->editorMove);
}
else{
this->variations.push_back(m);
this->editorMove.variations.push_back(&m->editorMove);
}
m->parent=this;
m->isWhite=!(this->isWhite);
}
void Move::AddVariation(Move *m){
this->variations.push_back(m);
this->editorMove.variations.push_back(&m->editorMove);
}
bool Move::operator==(const Move &m){
return(
this->Src==m.Src &&
this->Dst==m.Dst &&
this->FEN==m.FEN
);
}
Move Move::FromLA(string move) {
Move m;
m.Src = move.substr(0, 2);
m.Dst = move.substr(2, 2);
m.promoteTo = ' ';
if (move.size() == 5) {
m.isPromotion = true;
m.promoteTo = move[4];
}
return (m);
}
bool Move::IsLeaf() {
return (this->main == nullptr && this->variations.size() == 0);
}
void Move::expand(Move *m) {
if (this->main == nullptr) {
this->main = m;
this->editorMove.next = &(m->editorMove);
} else {
this->variations.push_back(m);
this->editorMove.variations.push_back(&m->editorMove);
}
m->parent = this;
m->isWhite = !(this->isWhite);
}
void Move::AddVariation(Move *m) {
this->variations.push_back(m);
this->editorMove.variations.push_back(&m->editorMove);
}
bool Move::operator==(const Move &m) {
return (this->Src == m.Src && this->Dst == m.Dst && this->FEN == m.FEN);
}
} // namespace model
} // namespace model
} // namespace ochess
......@@ -8,72 +8,67 @@
#include "model/Fen.hpp"
using namespace std;
namespace ochess
{
namespace model
{
namespace ochess {
namespace model {
/**
* @brief Node of a game Abstract Syntax Tree (AST)
*/
class Move
{
public:
/// @brief Piece source.
Coord Src;
/// @brief Piece destination.
Coord Dst;
Move *parent;
Move *main;
pgneditor::Move editorMove;
vector<Move *> variations;
string SANMove;
string dst;
string comment;
string FEN;
char piece;
bool isCheck;
bool isPromotion;
bool isCheckMate;
bool isPawn;
bool isCapture;
bool isLongCastle;
bool isShortCastle;
bool isWhite;
char promoteTo;
char col;
short clk[3];
short egt[3];
short emt[3];
short mct[3];
short moveId;
/**
* @brief Node of a game Abstract Syntax Tree (AST)
*/
class Move {
public:
/// @brief Piece source.
Coord Src;
/// @brief Piece destination.
Coord Dst;
Move *parent;
Move *main;
pgneditor::Move editorMove;
vector<Move*> variations;
string SANMove;
string dst;
string comment;
string FEN;
char piece;
bool isCheck;
bool isPromotion;
bool isCheckMate;
bool isPawn;
bool isCapture;
bool isLongCastle;
bool isShortCastle;
bool isWhite;
char promoteTo;
char col;
short clk[3];
short egt[3];
short emt[3];
short mct[3];
short moveId;
/**
* @brief Initialize a MoveNode (set pointers values etc.)
*/
Move();
~Move();
void Dump();
/**
* @brief Initialize a MoveNode (set pointers values etc.)
*/
Move();
~Move();
void Dump();
/// @brief Free a game AST
static void freeMove(Move *m);
/**
* Parse a long algebraic notation move
* @param move in the long algebraic notation format
* @return A struct containing the actual move.
*/
static Move FromLA(string move);
/**
* Parse a long algebraic notation move
* @param move in the long algebraic notation format
* @return A struct containing the actual move.
*/
static Move FromLA(string move);
bool IsLeaf();
void expand(Move*m);
bool operator== (const Move &m);
void AddVariation(Move *m);
bool IsLeaf();
void expand(Move *m);
bool operator==(const Move &m);
void AddVariation(Move *m);
};
};
// ---------- Utility functions ----------
// ---------- Utility functions ----------
} // namespace model
}// namespace model
} // namespace ochess
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment