\n"
,playernum,playernum,width,margin,margin,margin);
const char *player_color = "white";
const char *bgcolor = "#f0dab5";
const char *msg = MSG_U(I_WHITE,"WHITES");
if (playernum == 1){
player_color = "black";
msg = MSG_U(I_BLACK,"BLACKS");
}
lines += string_f("
\n",bgcolor);
lines += string_f("%s\n",player_color,msg);
lines += "
\n";
lines += string_f("
\n"
,playernum,gameid.ptr,width,height,color);
const char *namept = name.ptr;
if(strcmp(namept,CHESS_ROBOT)==0) namept = svg;
if (namept[0] == '\0') namept = " ";
lines += string_f("%s\n",namept);
lines += "
\n";
lines += "
\n";
}
void CHESS::show_marked_pieces (
VARVAL ¬ify_var,
const char *color)
{
for (auto &m:marked_pieces){
string id=string_f("cm%u,%u",m.line,m.col);
update_circle(notify_var,id,color,color);
}
}
string CHESS::format_fen()
{
string lines;
for (unsigned i=0; i<8; i++){
if (i > 0) lines += '/';
unsigned nbspaces=0;
for (auto c:grid[i]){
if (c == ' '){
nbspaces++;
}else{
if (nbspaces > 0){
lines += (char)('0'+nbspaces);
nbspaces=0;
}
lines += c;
}
}
if (nbspaces > 0) lines += (char)('0'+nbspaces);
}
// Who must play
lines += ' ';
lines += player1_playing ? 'w' : 'b';
lines += ' ';
// castling
size_t curlen = lines.size();
if (!player1.king_moved){
if (!player1.right_rook_moved) lines += 'K';
if (!player1.left_rook_moved) lines += 'Q';
}
if (!player2.king_moved){
if (!player2.right_rook_moved) lines += 'k';
if (!player2.left_rook_moved) lines += 'q';
}
if (lines.size()==curlen) lines += '-';
lines += ' ';
if (player1_playing){
if (player1.has_en_passant()){
lines += (char)('a'+player1.en_passant.col);
lines += (char)('8'-player1.en_passant.line);
}else{
lines += '-';
}
}else if (player2.has_en_passant()){
lines += (char)('a'+player2.en_passant.col);
lines += (char)('8'-player2.en_passant.line);
}else{
lines += '-';
}
lines += string_f(" 0 %zu",undos.size()/2);
return lines;
}
// If the next player is a robot, we send it some work
void CHESS::robot_request(vector