Merge remote-tracking branch 'refs/remotes/origin/cleaner' into cleaner
このコミットが含まれているのは:
コミット
6314045855
33
uttt.c
33
uttt.c
|
@ -41,6 +41,12 @@ const char arg_local[] = "--local";
|
|||
const char arg_host[] = "--host";
|
||||
const char arg_join[] = "--join";
|
||||
|
||||
const char PLAY_BOARDS[][14] = {
|
||||
"top left", "top middle", "top right",
|
||||
"middle left", "middle", "middle right",
|
||||
"bottom left", "bottom middle", "bottom right",
|
||||
"all boards",
|
||||
};
|
||||
|
||||
char ut_turn(char player)
|
||||
{
|
||||
|
@ -265,22 +271,22 @@ 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
|
||||
ut_dprintf(fd, "%sTurn: %c\n%sPlay board: %d\n", as_comment ? "| " : "", (int)state->player, as_comment ? "| " : "", state->playBoard);
|
||||
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, "%s 012 345 678\n", as_comment ? "| " : "");
|
||||
ut_dprintf(fd, " 012 345 678\n");
|
||||
for(int y = 0; y < 9; y++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
if (x == 3 || x == 6) {
|
||||
|
@ -294,9 +300,9 @@ void ut_sockdraw(const struct ut_state *state, int fd)
|
|||
ut_writefill(fd, "\n", 1);
|
||||
}
|
||||
if (play_board_col == -1) {
|
||||
ut_dprintf(fd, "%s ^^^ ^^^ ^^^", as_comment ? "| " : "");
|
||||
ut_dprintf(fd, " ^^^ ^^^ ^^^");
|
||||
} else {
|
||||
ut_dprintf(fd, "%s ", as_comment ? "| " : "");
|
||||
ut_dprintf(fd, " ");
|
||||
for (int i = 0; i < play_board_col; i++) {
|
||||
ut_dprintf(fd, " ");
|
||||
}
|
||||
|
@ -304,7 +310,7 @@ void ut_sockdraw(const struct ut_state *state, int fd)
|
|||
}
|
||||
ut_writefill(fd, "\n", 1);
|
||||
#undef tiles
|
||||
}*/
|
||||
}
|
||||
|
||||
/*void ut_show_boards(const struct ut_state *state) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
@ -535,7 +541,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, true);
|
||||
ut_show(state, sock);
|
||||
if (state->player == player) {
|
||||
if (readable) {ut_dprintf(sock, "Waiting for game partner ...\n");}
|
||||
bool ok = ut_cursgetpos(state, &x, &y);
|
||||
|
@ -617,9 +623,6 @@ int ut_host_game(struct ut_state *state) {
|
|||
char player;
|
||||
if ((player = ut_random_player()) < 0) {return 1;}
|
||||
|
||||
// tell partner X or O
|
||||
ut_dprintf(conn, "%c\n", ut_turn(player));
|
||||
|
||||
// check to determine readable
|
||||
char byte;
|
||||
ut_dprintf(conn, "| Press enter to start: ");
|
||||
|
@ -639,6 +642,12 @@ int ut_host_game(struct ut_state *state) {
|
|||
}
|
||||
}
|
||||
|
||||
// tell partner X or O
|
||||
ut_dprintf(conn, "%c\n", ut_turn(player));
|
||||
if (readable) {
|
||||
ut_dprintf(conn, "You play as: %c\n\n", ut_turn(player));
|
||||
}
|
||||
|
||||
return ut_network_game(state, conn, player, readable);
|
||||
}
|
||||
|
||||
|
|
読み込み中…
新しいイシューから参照