delete pipe character

このコミットが含まれているのは:
ninya9k 2023-11-15 07:03:20 +00:00
コミット d7f2f88615
1個のファイルの変更9行の追加9行の削除

18
uttt.c
ファイルの表示

@ -255,12 +255,12 @@ void ut_cursdraw(const struct ut_state *state)
} }
void ut_sockdraw(const struct ut_state *state, int fd) void ut_sockdraw(const struct ut_state *state, int fd)
{ {
ut_dprintf(fd, "| Turn: %c Play board: %d\n", (int)state->player, state->playBoard); ut_dprintf(fd, "Turn: %c Play board: %d\n", (int)state->player, state->playBoard);
char dtiles[DTILES_Y][DTILES_X]; char dtiles[DTILES_Y][DTILES_X];
ut_drawTiles(ut_tmvch, dtiles, state, true); ut_drawTiles(ut_tmvch, dtiles, state, true);
for(int r = 0; r < DTILES_Y; r++) for(int r = 0; r < DTILES_Y; r++)
{ {
ut_dprintf(fd, "| %.*s\n", DTILES_X, dtiles[r]); ut_dprintf(fd, "%.*s\n", DTILES_X, dtiles[r]);
} }
} }
@ -514,15 +514,15 @@ int ut_network_game(struct ut_state *state, int sock, char player, bool readable
ut_show_boards(state); ut_show_boards(state);
ut_show(state, sock, true); ut_show(state, sock, true);
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 = getpos(state, &x, &y); bool ok = getpos(state, &x, &y);
if (!ok) {continue;} if (!ok) {continue;}
ut_dprintf(sock, "%d,%d\n", x, y); ut_dprintf(sock, "%d,%d\n", x, y);
} else { } else {
printf("Waiting for game partner ...\n"); printf("Waiting for game partner ...\n");
if (readable) { if (readable) {
ut_dprintf(sock, "|\n"); // aligns game board each turn // line feed aligns game board each turn
ut_dprintf(sock, "| Place token %c in position x,y: ", ut_turn(player)); ut_dprintf(sock, "\nPlace token %c in position x,y: ", ut_turn(player));
} }
int err = ut_sockgetpos(state, sock, &x, &y); int err = ut_sockgetpos(state, sock, &x, &y);
if (err == -1) { if (err == -1) {
@ -538,22 +538,22 @@ int ut_network_game(struct ut_state *state, int sock, char player, bool readable
} }
int err = ut_move(state, state, y, x); int err = ut_move(state, state, y, x);
if (err) {continue;} if (err) {continue;}
ut_dprintf(sock, "|\n"); ut_dprintf(sock, "\n");
char w = ut_winner((char *)state->boards, 0, 3); char w = ut_winner((char *)state->boards, 0, 3);
if(w) if(w)
{ {
if(w == ' ') if(w == ' ')
{ {
printf("\nDraw!\n"); printf("\nDraw!\n");
if (readable) {ut_dprintf(sock, "|\n|Draw!\n");} if (readable) {ut_dprintf(sock, "\nDraw!\n");}
close(sock); close(sock);
if (readable) {ut_dprintf(sock, "|\n|Draw!\n");} if (readable) {ut_dprintf(sock, "\nDraw!\n");}
close(sock); close(sock);
} }
else else
{ {
printf("\n%c wins!\n", (int)w); printf("\n%c wins!\n", (int)w);
if (readable) {ut_dprintf(sock, "|\n|%c wins!\n", (int)w);} if (readable) {ut_dprintf(sock, "\n%c wins!\n", (int)w);}
close(sock); close(sock);
} }
break; break;