ref: 7c8bed102376b1150c2eef93111d61db99ff6aea
parent: 380bb05adb556fa822526e18ea03748fde5b8da9
author: zamfofex <zamfofex@twdb.moe>
date: Thu Dec 12 12:39:25 EST 2024
change piece set and board style for IRC integration
--- a/tools/chat.c
+++ b/tools/chat.c
@@ -146,6 +146,28 @@
}
}
+static void moonfish_write_fen(struct tls *tls, struct moonfish_chess *chess, struct moonfish_move *move, char *channel)
+{+ char fen[128];
+ char name[6];
+ int i;
+
+ moonfish_to_fen(&move->chess, fen);
+ moonfish_to_uci(chess, move, name);
+
+ for (i = 0 ; fen[i] != 0 ; i++) {+ if (fen[i] == ' ') fen[i] = '_';
+ }
+
+ moonfish_write_text(tls, "PRIVMSG ");
+ moonfish_write_text(tls, channel);
+ moonfish_write_text(tls, " :https://lichess.org/export/fen.gif?theme=blue&piece=caliente&lastMove=");
+ moonfish_write_text(tls, name);
+ moonfish_write_text(tls, "&fen=");
+ moonfish_write_text(tls, fen);
+ moonfish_write_text(tls, "\r\n");
+}
+
static void moonfish_chat(char **command, char **options, char *host, char *port, char *username, char *channels)
{struct tls *tls;
@@ -157,9 +179,7 @@
FILE *in, *out;
char *value;
char *names, *name0;
- char fen[128];
char *password;
- int i;
moonfish_chess(&chess);
@@ -231,31 +251,22 @@
if (moonfish_from_san(&chess, &move, message)) continue;
- moonfish_to_uci(&chess, &move, name);
- chess = move.chess;
-
- if (moonfish_finished(&chess)) {+ if (moonfish_finished(&move.chess)) {- moonfish_to_fen(&chess, fen);
+ moonfish_write_fen(tls, &chess, &move, channel);
moonfish_chess(&chess);
fprintf(in, "ucinewgame\n");
- for (i = 0 ; fen[i] != 0 ; i++) {- if (fen[i] == ' ') fen[i] = '_';
- }
moonfish_write_text(tls, "PRIVMSG ");
moonfish_write_text(tls, channel);
- moonfish_write_text(tls, " :https://lichess.org/export/fen.gif?fen=");
- moonfish_write_text(tls, fen);
- moonfish_write_text(tls, "\r\n");
-
- moonfish_write_text(tls, "PRIVMSG ");
- moonfish_write_text(tls, channel);
moonfish_write_text(tls, " :Game over!\r\n");
continue;
}
+ moonfish_to_uci(&chess, &move, name);
+ chess = move.chess;
+
names = realloc(names, strlen(names) + strlen(name) + 2);
if (names == NULL) { perror("realloc");@@ -289,13 +300,7 @@
}
moonfish_to_san(&chess, &move, name, 0);
- chess = move.chess;
- moonfish_to_fen(&chess, fen);
- for (i = 0 ; fen[i] != 0 ; i++) {- if (fen[i] == ' ') fen[i] = '_';
- }
-
moonfish_write_text(tls, "PRIVMSG ");
moonfish_write_text(tls, channel);
moonfish_write_text(tls, " :");
@@ -302,11 +307,8 @@
moonfish_write_text(tls, name);
moonfish_write_text(tls, "\r\n");
- moonfish_write_text(tls, "PRIVMSG ");
- moonfish_write_text(tls, channel);
- moonfish_write_text(tls, " :https://lichess.org/export/fen.gif?fen=");
- moonfish_write_text(tls, fen);
- moonfish_write_text(tls, "\r\n");
+ moonfish_write_fen(tls, &chess, &move, channel);
+ chess = move.chess;
if (moonfish_finished(&chess)) {--
⑨