コミットを比較

..

共通のコミットはありません。 "194825db5a6aa7b65eeb93fab30a76c72355eec3" と "8c83ddcba4dfae0d6475cefe3ff9ae806d6c7856" の履歴はすべて異なっています。

1個のファイルの変更11行の追加20行の削除

31
uttt.c
ファイルの表示

@ -41,12 +41,6 @@ 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)
{
@ -271,22 +265,22 @@ void ut_sockdraw(const struct ut_state *state, int fd)
}
}
void ut_show(const struct ut_state *state, int fd) {
/*void ut_show(const struct ut_state *state, int fd, bool as_comment) {
#define tiles state->tiles
ut_dprintf(fd, "Turn: %c\nPlay board: %s\n", (int)state->player, PLAY_BOARDS[(state->playBoard + 10) % 10]);
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_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");
ut_dprintf(fd, "%s 012 345 678\n", as_comment ? "| " : "");
for(int y = 0; y < 9; y++)
{
if (y == 3 || y == 6) {
ut_dprintf(fd, " ---+---+---\n");
ut_dprintf(fd, "%s ---+---+---\n", as_comment ? "| " : "");
}
ut_dprintf(fd, "%d ", y);
ut_dprintf(fd, "%s%d ", as_comment ? "| " : "", y);
for(int x = 0; x < 9; x++)
{
if (x == 3 || x == 6) {
@ -300,9 +294,9 @@ void ut_show(const struct ut_state *state, int fd) {
ut_writefill(fd, "\n", 1);
}
if (play_board_col == -1) {
ut_dprintf(fd, " ^^^ ^^^ ^^^");
ut_dprintf(fd, "%s ^^^ ^^^ ^^^", as_comment ? "| " : "");
} else {
ut_dprintf(fd, " ");
ut_dprintf(fd, "%s ", as_comment ? "| " : "");
for (int i = 0; i < play_board_col; i++) {
ut_dprintf(fd, " ");
}
@ -539,7 +533,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_show(state, sock, true);
if (state->player == player) {
if (readable) {ut_dprintf(sock, "Waiting for game partner ...\n");}
bool ok = ut_cursgetpos(state, &x, &y);
@ -621,6 +615,9 @@ 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: ");
@ -640,12 +637,6 @@ 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);
}