use ut_sockdraw
このコミットが含まれているのは:
コミット
01f4e1e021
46
uttt.c
46
uttt.c
|
@ -262,7 +262,7 @@ void ut_cursdraw(const struct ut_state *state)
|
|||
}
|
||||
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\nPlay board: %s\n", (int)state->player, PLAY_BOARDS[(state->playBoard + 10) % 10]);
|
||||
char dtiles[DTILES_Y][DTILES_X];
|
||||
ut_drawTiles(ut_tmvch, dtiles, state, true);
|
||||
for(int r = 0; r < DTILES_Y; r++)
|
||||
|
@ -271,47 +271,6 @@ void ut_sockdraw(const struct ut_state *state, int fd)
|
|||
}
|
||||
}
|
||||
|
||||
void ut_show(const struct ut_state *state, int fd) {
|
||||
#define tiles state->tiles
|
||||
ut_dprintf(fd, "Turn: %c\nPlay board: %s\n", (int)state->player, PLAY_BOARDS[(state->playBoard + 10) % 10]);
|
||||
int play_board_row = -1;
|
||||
int play_board_col = -1;
|
||||
if (state->playBoard != -1) {
|
||||
play_board_row = state->playBoard / 3;
|
||||
play_board_col = state->playBoard % 3;
|
||||
}
|
||||
ut_dprintf(fd, " 012 345 678\n");
|
||||
for(int y = 0; y < 9; y++)
|
||||
{
|
||||
if (y == 3 || y == 6) {
|
||||
ut_dprintf(fd, " ---+---+---\n");
|
||||
}
|
||||
ut_dprintf(fd, "%d ", y);
|
||||
for(int x = 0; x < 9; x++)
|
||||
{
|
||||
if (x == 3 || x == 6) {
|
||||
ut_writefill(fd, "|", 1);
|
||||
}
|
||||
ut_writefill(fd, tiles[y][x] ? &tiles[y][x] : " ", 1);
|
||||
}
|
||||
if (y / 3 == play_board_row || play_board_row == -1) {
|
||||
ut_writefill(fd, "<", 1);
|
||||
}
|
||||
ut_writefill(fd, "\n", 1);
|
||||
}
|
||||
if (play_board_col == -1) {
|
||||
ut_dprintf(fd, " ^^^ ^^^ ^^^");
|
||||
} else {
|
||||
ut_dprintf(fd, " ");
|
||||
for (int i = 0; i < play_board_col; i++) {
|
||||
ut_dprintf(fd, " ");
|
||||
}
|
||||
ut_dprintf(fd, "^^^");
|
||||
}
|
||||
ut_writefill(fd, "\n", 1);
|
||||
#undef tiles
|
||||
}
|
||||
|
||||
/*void ut_show_boards(const struct ut_state *state) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -321,7 +280,6 @@ void ut_show(const struct ut_state *state, int fd) {
|
|||
}
|
||||
}*/
|
||||
|
||||
|
||||
int ut_readfill(int fd, char *x, size_t l)
|
||||
{
|
||||
while(l > 0)
|
||||
|
@ -541,7 +499,7 @@ int ut_network_game(struct ut_state *state, int sock, char player, bool readable
|
|||
while (true) {
|
||||
//ut_show(state, 1, false);
|
||||
//ut_show_boards(state);
|
||||
ut_show(state, sock);
|
||||
ut_sockdraw(state, sock);
|
||||
if (state->player == player) {
|
||||
if (readable) {ut_dprintf(sock, "Waiting for game partner ...\n");}
|
||||
bool ok = ut_cursgetpos(state, &x, &y);
|
||||
|
|
読み込み中…
新しいイシューから参照