From e2afd13123e9c6b2c3b161792c69e7590585b197 Mon Sep 17 00:00:00 2001 From: bru Date: Sun, 6 Feb 2022 17:59:37 -0300 Subject: Traducciones --- ajedrez.c | 82 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/ajedrez.c b/ajedrez.c index 3a7980c..283a478 100644 --- a/ajedrez.c +++ b/ajedrez.c @@ -1,21 +1,27 @@ // SAKKOM: sakk a konzolban király! online multiplayer // chess.com alternatíva, ami netcatet használ mint kliens // +// AJEDREZ: servidor de ajedrez multijugador en línea +// alternativo a chess.com con un cliente para netcat. +// Hispanizado para texto-plano.xyz +// // do what you want // boa #include -#include +#include // -lpthread #include #include #include #include #include #include -#include -#include #include #include +#ifdef BSD +#include +#include +#endif #define PRINT_ALL(f_, ...) \ do { \ @@ -43,13 +49,13 @@ char ascii_symbols[7] = {' ', 'P', 'R', 'N', 'B', 'Q', 'K'}; typedef enum result { r_no, r_win, r_stalemate } result; typedef enum piece_type { - p_no, - p_pawn, - p_rook, - p_knight, - p_bishop, - p_queen, - p_king + p_no, // vacío + p_pawn, // peón + p_rook, // torre + p_knight, // caballo + p_bishop, // alfil + p_queen, // reina + p_king // rey } piece_type; typedef struct pos { @@ -63,10 +69,10 @@ typedef struct piece { } piece; typedef struct move { - pos f; // from - pos t; // to - piece p; // piece moved - piece e; // enemy taken + pos f; // pos. origen + pos t; // pos. destino + piece p; // pieza movida + piece e; // enemigo tomado } move; typedef struct en_passant { @@ -130,9 +136,9 @@ void print_table() { } dprintf( w_fd, - "\n\n \e[43m\x1B[39m\033[1m WHITE \x1B[0m\n\n\x1B[0m"); + "\n\n \e[43m\x1B[39m\033[1m BLANCO \x1B[0m\n\n\x1B[0m"); } else { - dprintf(w_fd, "\n [ BLACK ]\n\n "); + dprintf(w_fd, "\n [ NEGRO ]\n\n "); for (int x = 0; x < 8; x++) { dprintf(w_fd, " %c ", 'A' + x); } @@ -151,12 +157,12 @@ void print_table() { for (int x = 0; x < 8; x++) { dprintf(w_fd, " %c ", 'A' + x); } - dprintf(w_fd, "\n\n [ WHITE ]\n\n"); + dprintf(w_fd, "\n\n [ BLANCO ]\n\n"); } if (modes[c_b] == mode_unicode) { dprintf(b_fd, - "\n \e[43m\x1B[39m\033[1m WHITE \x1B[0m\n\n "); + "\n \e[43m\x1B[39m\033[1m BLANCO \x1B[0m\n\n "); for (int x = 0; x < 8; x++) { dprintf(b_fd, " %c ", 'A' + 7 - x); } @@ -178,9 +184,9 @@ void print_table() { } dprintf( b_fd, - "\n\n \e[43m\x1B[30m\033[1m BLACK \x1B[0m\n\n\x1B[0m"); + "\n\n \e[43m\x1B[30m\033[1m NEGRO \x1B[0m\n\n\x1B[0m"); } else { - dprintf(b_fd, "\n [ WHITE ]\n\n "); + dprintf(b_fd, "\n [ BLANCO ]\n\n "); for (int x = 0; x < 8; x++) { dprintf(b_fd, " %c ", 'A' + 7 - x); } @@ -199,7 +205,7 @@ void print_table() { for (int x = 0; x < 8; x++) { dprintf(b_fd, " %c ", 'A' + 7 - x); } - dprintf(b_fd, "\n\n [ BLACK ]\n\n"); + dprintf(b_fd, "\n\n [ NEGRO ]\n\n"); } } @@ -334,9 +340,9 @@ void print_move(move m) { buf[n++] = '\n'; buf[n++] = '\0'; if (m.p.c == c_w) { - PRINT_ALL("%d. white: ", move_num); + PRINT_ALL("%d. blanco: ", move_num); } else { - PRINT_ALL("%d. black: ", move_num); + PRINT_ALL("%d. negro: ", move_num); move_num++; } PRINT_ALL(buf); @@ -475,7 +481,7 @@ void do_move(move m) { piece_type choose_type(int fd) { char cbuf[10] = {0}; while (true) { - dprintf(fd, "mit kérsz?\n"); + dprintf(fd, "¿qué hacer?\n"); dprintf(fd, "> "); read(fd, cbuf, 10); switch (cbuf[0]) { @@ -505,9 +511,9 @@ void *run_timer(void *vargp) { remaining_time[c_c]--; if (remaining_time[c_c] <= 0) { if (c_c == c_w) - PRINT_ALL("fehérnek lejárt az ideje, fekete nyert!\n"); + PRINT_ALL("blanco se ha quedado sin tiempo. ¡negro gana!\n"); else - PRINT_ALL("feketének lejárt az ideje, fehér nyert!\n"); + PRINT_ALL("negro se ha quedado sin tiempo. ¡blanco gana!\n"); raise(SIGTERM); } } @@ -517,7 +523,7 @@ void *run_timer(void *vargp) { } void play_game() { - PRINT_ALL("(a)scii vagy (u)nicode? [u] "); + PRINT_ALL("¿interfaz (a)scii o (u)nicode? [u] "); char input_str[50]; read(w_fd, input_str, 50); if (input_str[0] == 'a') @@ -540,18 +546,18 @@ void play_game() { for (;;) { is_printing = true; if (c_c == c_w) - dprintf(b_fd, "fehér gondolkodik...\n"); + dprintf(b_fd, "blanco está pensando...\n"); else - dprintf(w_fd, "fekete gondolkodik...\n"); + dprintf(w_fd, "negro está pensando...\n"); no_print: if (is_checkmate(c_c)) { if (c_c == c_w) - PRINT_ALL("\na fekete nyert!\n"); + PRINT_ALL("\n¡jaque mate! ¡negro gana!\n"); else - PRINT_ALL("\na fehér nyert!\n"); + PRINT_ALL("\n¡jaque mate! ¡blanco gana!\n"); break; } else if (is_stalemate(c_c)) { - PRINT_ALL("\ndöntetlen\n"); + PRINT_ALL("\n¡empate!\n"); break; } dprintf(*c_fd, "\n%02d:%02d > ", remaining_time[c_c] / 60, @@ -611,7 +617,7 @@ void play_game() { print_table(); print_move(m); } else { - dprintf(*c_fd, "hiba\n"); + dprintf(*c_fd, "error\n"); goto no_print; } @@ -685,7 +691,7 @@ int main() { listen(listen_fd, 5); listen(listen6_fd, 5); - printf("Listening on :%d\n", port); + printf("Escuchando en :%d\n", port); FD_ZERO(&afds); FD_SET(listen_fd, &afds); @@ -708,15 +714,15 @@ int main() { exit(EXIT_FAILURE); } - printf("New connection from %s:%d\n", inet_ntoa(client_addr.sin_addr), + printf("Nueva conexión desde %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port)); FD_SET(new_fd, &afds); if (w_fd == -1) { - dprintf(new_fd, "te vagy az fehérrel\n"); + dprintf(new_fd, "tú eres las blancas\n"); w_fd = new_fd; } else if (b_fd == -1) { - dprintf(new_fd, "te vagy a feketével\n"); - dprintf(w_fd, "belépett a fekete is, kezdhetjük!\n"); + dprintf(new_fd, "tú eres las negras\n"); + dprintf(w_fd, "ha entrado las negras, ¡comenzamos!\n"); b_fd = new_fd; if (fork() == 0) { play_game(); -- cgit v1.2.3