send board over socket

このコミットが含まれているのは:
ninya9k 2023-11-15 08:04:45 +00:00
コミット 573ae23c48
1個のファイルの変更7行の追加7行の削除

14
uttt.c
ファイルの表示

@ -264,7 +264,7 @@ void ut_sockdraw(const struct ut_state *state, int fd)
} }
} }
/*void ut_show(const struct ut_state *state, int fd, bool as_comment) { void ut_show(const struct ut_state *state, int fd) {
#define tiles state->tiles #define tiles state->tiles
ut_dprintf(fd, "%sTurn: %c\n%sPlay board: %d\n", as_comment ? "| " : "", (int)state->player, as_comment ? "| " : "", state->playBoard); ut_dprintf(fd, "%sTurn: %c\n%sPlay board: %d\n", as_comment ? "| " : "", (int)state->player, as_comment ? "| " : "", state->playBoard);
int play_board_row = -1; int play_board_row = -1;
@ -273,13 +273,13 @@ void ut_sockdraw(const struct ut_state *state, int fd)
play_board_row = state->playBoard / 3; play_board_row = state->playBoard / 3;
play_board_col = state->playBoard % 3; play_board_col = state->playBoard % 3;
} }
ut_dprintf(fd, "%s 012 345 678\n", as_comment ? "| " : ""); ut_dprintf(fd, " 012 345 678\n");
for(int y = 0; y < 9; y++) for(int y = 0; y < 9; y++)
{ {
if (y == 3 || y == 6) { if (y == 3 || y == 6) {
ut_dprintf(fd, "%s ---+---+---\n", as_comment ? "| " : ""); ut_dprintf(fd, " ---+---+---\n");
} }
ut_dprintf(fd, "%s%d ", as_comment ? "| " : "", y); ut_dprintf(fd, "%d ", y);
for(int x = 0; x < 9; x++) for(int x = 0; x < 9; x++)
{ {
if (x == 3 || x == 6) { if (x == 3 || x == 6) {
@ -293,9 +293,9 @@ void ut_sockdraw(const struct ut_state *state, int fd)
ut_writefill(fd, "\n", 1); ut_writefill(fd, "\n", 1);
} }
if (play_board_col == -1) { if (play_board_col == -1) {
ut_dprintf(fd, "%s ^^^ ^^^ ^^^", as_comment ? "| " : ""); ut_dprintf(fd, " ^^^ ^^^ ^^^");
} else { } else {
ut_dprintf(fd, "%s ", as_comment ? "| " : ""); ut_dprintf(fd, " ");
for (int i = 0; i < play_board_col; i++) { for (int i = 0; i < play_board_col; i++) {
ut_dprintf(fd, " "); ut_dprintf(fd, " ");
} }
@ -531,7 +531,7 @@ int ut_network_game(struct ut_state *state, int sock, char player, bool readable
while (true) { while (true) {
//ut_show(state, 1, false); //ut_show(state, 1, false);
//ut_show_boards(state); //ut_show_boards(state);
//ut_show(state, sock, true); ut_show(state, sock);
if (state->player == player) { if (state->player == player) {
if (readable) {ut_dprintf(sock, "Waiting for game partner ...\n");} if (readable) {ut_dprintf(sock, "Waiting for game partner ...\n");}
bool ok = ut_cursgetpos(state, &x, &y); bool ok = ut_cursgetpos(state, &x, &y);