summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/chc.h4
-rw-r--r--mbbsd/chc.c128
2 files changed, 70 insertions, 62 deletions
diff --git a/include/chc.h b/include/chc.h
index d78cbe8a..7ae4257b 100644
--- a/include/chc.h
+++ b/include/chc.h
@@ -11,17 +11,19 @@
#define STEP_ROW 9
#define REAL_TIME_ROW1 10
#define REAL_TIME_ROW2 11
-#define WARN_ROW 13
+#define REAL_WARN_ROW 13
#define MYWIN_ROW 17
#define HISWIN_ROW 18
#define PHOTO_TURN_ROW 19
#define PHOTO_TIME_ROW1 20
#define PHOTO_TIME_ROW2 21
+#define PHOTO_WARN_ROW 22
/* virtual lines */
#define TURN_ROW 128
#define TIME_ROW 129
+#define WARN_ROW 130
#define CHC_VERSUS 1 /* 雙人 */
#define CHC_WATCH 2 /* 觀棋 */
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index 3cb44c12..20173251 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -265,6 +265,8 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li
chc_drawline(board, user1, user2,
chcd->photo ? PHOTO_TIME_ROW1 : REAL_TIME_ROW1);
line = chcd->photo ? PHOTO_TIME_ROW2 : REAL_TIME_ROW2;
+ } else if (line == WARN_ROW) {
+ line = chcd->photo ? PHOTO_WARN_ROW : REAL_WARN_ROW;
}
move(line, 0);
@@ -295,47 +297,27 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li
prints("%c%c", chess_brd[line - 3][i * 4 + 2],
chess_brd[line - 3][i * 4 + 3]);
}
+ } else if (line == 2 || line == 22) {
+ outs(" ");
+ if (line == 2)
+ for (i = 1; i <= 9; i++)
+ prints("%s ", num_str[0][i]);
+ else
+ for (i = 9; i >= 1; i--)
+ prints("%s ", num_str[1][i]);
+ }
- if (chcd->photo) {
+ if (chcd->photo) {
+ if (line >= 3 && line < 3 + PHOTO_LINE) {
outs(" ");
- if (line >= 3 && line < 3 + PHOTO_LINE)
- outs(chcd->photo + (line - 3) * PHOTO_COLUMN);
- else if (line == PHOTO_TURN_ROW)
- prints(" %s%s" ANSI_RESET,
- TURN_COLOR,
- chcd->my == chcd->turn ? "輪到你下棋了" : "等待對方下棋");
- else if (line == PHOTO_TIME_ROW1) {
- if (chcd->lefthand[0])
- prints(" 我方剩餘時間 %d:%02d / %2d 步",
- chcd->lefttime[0] / 60, chcd->lefttime[0] % 60,
- chcd->lefthand[0]);
- else
- prints(" 我方剩餘時間 %d:%02d",
- chcd->lefttime[0] / 60, chcd->lefttime[0] % 60);
- } else if (line == PHOTO_TIME_ROW2) {
- if (chcd->lefthand[1])
- prints(" 對方剩餘時間 %d:%02d / %2d 步",
- chcd->lefttime[1] / 60, chcd->lefttime[1] % 60,
- chcd->lefthand[1]);
- else
- prints(" 對方剩餘時間 %d:%02d",
- chcd->lefttime[1] / 60, chcd->lefttime[1] % 60);
- }
- } else {
- outs(" ");
- if (line >= 3 && line < 3 + (int)dim(hint_str)) {
- outs(hint_str[line - 3]);
- } else if (line == SIDE_ROW) {
- prints(ANSI_COLOR(1) "你是%s%s" ANSI_RESET,
- turn_color[chcd->my],
- turn_str[chcd->my]);
- } else if (line == REAL_TURN_ROW) {
+ outs(chcd->photo + (line - 3) * PHOTO_COLUMN);
+ } else if (line >= PHOTO_TURN_ROW && line <= PHOTO_WARN_ROW) {
+ outs(" ");
+ if (line == PHOTO_TURN_ROW)
prints("%s%s" ANSI_RESET,
TURN_COLOR,
chcd->my == chcd->turn ? "輪到你下棋了" : "等待對方下棋");
- } else if (line == STEP_ROW && !chcd->firststep) {
- showstep(board);
- } else if (line == REAL_TIME_ROW1) {
+ else if (line == PHOTO_TIME_ROW1) {
if (chcd->lefthand[0])
prints("我方剩餘時間 %d:%02d / %2d 步",
chcd->lefttime[0] / 60, chcd->lefttime[0] % 60,
@@ -343,7 +325,7 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li
else
prints("我方剩餘時間 %d:%02d",
chcd->lefttime[0] / 60, chcd->lefttime[0] % 60);
- } else if (line == REAL_TIME_ROW2) {
+ } else if (line == PHOTO_TIME_ROW2) {
if (chcd->lefthand[1])
prints("對方剩餘時間 %d:%02d / %2d 步",
chcd->lefttime[1] / 60, chcd->lefttime[1] % 60,
@@ -351,32 +333,56 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li
else
prints("對方剩餘時間 %d:%02d",
chcd->lefttime[1] / 60, chcd->lefttime[1] % 60);
- } else if (line == WARN_ROW) {
+ } else if (line == PHOTO_WARN_ROW)
outs(chcd->warnmsg);
- } else if (line == MYWIN_ROW) {
- prints(ANSI_COLOR(1;33) "%12.12s "
- ANSI_COLOR(1;31) "%2d" ANSI_COLOR(37) "勝 "
- ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "敗 "
- ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "和" ANSI_RESET,
- user1->userid,
- user1->win, user1->lose - 1, user1->tie);
- } else if (line == HISWIN_ROW) {
- prints(ANSI_COLOR(1;33) "%12.12s "
- ANSI_COLOR(1;31) "%2d" ANSI_COLOR(37) "勝 "
- ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "敗 "
- ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "和" ANSI_RESET,
- user2->userid,
- user2->win, user2->lose - 1, user2->tie);
- }
}
- } else if (line == 2 || line == 22) {
- outs(" ");
- if (line == 2)
- for (i = 1; i <= 9; i++)
- prints("%s ", num_str[0][i]);
- else
- for (i = 9; i >= 1; i--)
- prints("%s ", num_str[1][i]);
+ } else if (line >= 3 && line <= HISWIN_ROW) {
+ outs(" ");
+ if (line >= 3 && line < 3 + (int)dim(hint_str)) {
+ outs(hint_str[line - 3]);
+ } else if (line == SIDE_ROW) {
+ prints(ANSI_COLOR(1) "你是%s%s" ANSI_RESET,
+ turn_color[chcd->my],
+ turn_str[chcd->my]);
+ } else if (line == REAL_TURN_ROW) {
+ prints("%s%s" ANSI_RESET,
+ TURN_COLOR,
+ chcd->my == chcd->turn ? "輪到你下棋了" : "等待對方下棋");
+ } else if (line == STEP_ROW && !chcd->firststep) {
+ showstep(board);
+ } else if (line == REAL_TIME_ROW1) {
+ if (chcd->lefthand[0])
+ prints("我方剩餘時間 %d:%02d / %2d 步",
+ chcd->lefttime[0] / 60, chcd->lefttime[0] % 60,
+ chcd->lefthand[0]);
+ else
+ prints("我方剩餘時間 %d:%02d",
+ chcd->lefttime[0] / 60, chcd->lefttime[0] % 60);
+ } else if (line == REAL_TIME_ROW2) {
+ if (chcd->lefthand[1])
+ prints("對方剩餘時間 %d:%02d / %2d 步",
+ chcd->lefttime[1] / 60, chcd->lefttime[1] % 60,
+ chcd->lefthand[1]);
+ else
+ prints("對方剩餘時間 %d:%02d",
+ chcd->lefttime[1] / 60, chcd->lefttime[1] % 60);
+ } else if (line == REAL_WARN_ROW) {
+ outs(chcd->warnmsg);
+ } else if (line == MYWIN_ROW) {
+ prints(ANSI_COLOR(1;33) "%12.12s "
+ ANSI_COLOR(1;31) "%2d" ANSI_COLOR(37) "勝 "
+ ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "敗 "
+ ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "和" ANSI_RESET,
+ user1->userid,
+ user1->win, user1->lose - 1, user1->tie);
+ } else if (line == HISWIN_ROW) {
+ prints(ANSI_COLOR(1;33) "%12.12s "
+ ANSI_COLOR(1;31) "%2d" ANSI_COLOR(37) "勝 "
+ ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "敗 "
+ ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "和" ANSI_RESET,
+ user2->userid,
+ user2->win, user2->lose - 1, user2->tie);
+ }
}
}