diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-07-06 01:10:28 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-07-06 01:10:28 +0800 |
commit | 1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch) | |
tree | e6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/chc_draw.c | |
parent | 10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff) | |
download | pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2 pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip |
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/chc_draw.c')
-rw-r--r-- | mbbsd/chc_draw.c | 119 |
1 files changed, 64 insertions, 55 deletions
diff --git a/mbbsd/chc_draw.c b/mbbsd/chc_draw.c index bb9a15a9..9f4091b1 100644 --- a/mbbsd/chc_draw.c +++ b/mbbsd/chc_draw.c @@ -1,4 +1,4 @@ -/* $Id: chc_draw.c,v 1.2 2002/06/04 13:08:33 in2 Exp $ */ +/* $Id: chc_draw.c,v 1.3 2002/07/05 17:10:27 in2 Exp $ */ #include "bbs.h" #define SIDE_ROW 10 @@ -9,49 +9,51 @@ #define MYWIN_ROW 17 #define HISWIN_ROW 18 -static char *turn_str[2] = {"黑的", "紅的"}; +static char *turn_str[2] = {"黑的", "紅的"}; -static char *num_str[10] = { +static char *num_str[10] = { "", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; -static char *chess_str[2][8] = { +static char *chess_str[2][8] = { /* 0 1 2 3 4 5 6 7 */ {" ", "將", "士", "象", "車", "馬", "包", "卒"}, {" ", "帥", "仕", "相", "車", "傌", "炮", "兵"} }; -static char *chess_brd[BRD_ROW * 2 - 1] = { - /*0 1 2 3 4 5 6 7 8*/ - "┌─┬─┬─┬─┬─┬─┬─┬─┐", /* 0 */ +static char *chess_brd[BRD_ROW * 2 - 1] = { + /* 0 1 2 3 4 5 6 7 8 */ + "┌─┬─┬─┬─┬─┬─┬─┬─┐", /* 0 */ "│ │ │ │\│/│ │ │ │", - "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 1 */ + "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 1 */ "│ │ │ │/│\│ │ │ │", - "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 2 */ + "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 2 */ "│ │ │ │ │ │ │ │ │", - "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 3 */ + "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 3 */ "│ │ │ │ │ │ │ │ │", - "├─┴─┴─┴─┴─┴─┴─┴─┤", /* 4 */ + "├─┴─┴─┴─┴─┴─┴─┴─┤", /* 4 */ "│ 楚 河 漢 界 │", - "├─┬─┬─┬─┬─┬─┬─┬─┤", /* 5 */ + "├─┬─┬─┬─┬─┬─┬─┬─┤", /* 5 */ "│ │ │ │ │ │ │ │ │", - "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 6 */ + "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 6 */ "│ │ │ │ │ │ │ │ │", - "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 7 */ + "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 7 */ "│ │ │ │\│/│ │ │ │", - "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 8 */ + "├─┼─┼─┼─┼─┼─┼─┼─┤", /* 8 */ "│ │ │ │/│\│ │ │ │", - "└─┴─┴─┴─┴─┴─┴─┴─┘" /* 9 */ + "└─┴─┴─┴─┴─┴─┴─┴─┘" /* 9 */ }; -static char *hint_str[] = { +static char *hint_str[] = { " q 認輸離開", " p 要求和棋", "方向鍵 移動遊標", "Enter 選擇/移動" }; -void chc_movecur(int r, int c) { +void +chc_movecur(int r, int c) +{ move(r * 2 + 3, c * 4 + 4); } @@ -61,22 +63,25 @@ void chc_movecur(int r, int c) { #define RED_REVERSE "\033[1;37;41m" #define TURN_COLOR "\033[1;33m" -static void showstep(board_t board) { - int turn, fc, tc, eatten; - char *dir; - +static void +showstep(board_t board) +{ + int turn, fc, tc, eatten; + char *dir; + turn = CHE_O(board[chc_from.r][chc_from.c]); fc = (turn == (chc_my ^ 1) ? chc_from.c + 1 : 9 - chc_from.c); tc = (turn == (chc_my ^ 1) ? chc_to.c + 1 : 9 - chc_to.c); - if(chc_from.r == chc_to.r) + if (chc_from.r == chc_to.r) dir = "平"; else { - if(chc_from.c == chc_to.c) + if (chc_from.c == chc_to.c) tc = chc_from.r - chc_to.r; - if(tc < 0) tc = -tc; - - if((turn == (chc_my ^ 1) && chc_to.r > chc_from.r) || - (turn == chc_my && chc_to.r < chc_from.r)) + if (tc < 0) + tc = -tc; + + if ((turn == (chc_my ^ 1) && chc_to.r > chc_from.r) || + (turn == chc_my && chc_to.r < chc_from.r)) dir = "進"; else dir = "退"; @@ -86,28 +91,30 @@ static void showstep(board_t board) { chess_str[turn][CHE_P(board[chc_from.r][chc_from.c])], num_str[fc], dir, num_str[tc]); eatten = board[chc_to.r][chc_to.c]; - if(eatten) + if (eatten) prints(": %s%s", CHE_O(eatten) == 0 ? BLACK_COLOR : RED_COLOR, chess_str[CHE_O(eatten)][CHE_P(eatten)]); prints("\033[m"); } -void chc_drawline(board_t board, int line) { - int i, j; - +void +chc_drawline(board_t board, int line) +{ + int i, j; + move(line, 0); clrtoeol(); - if(line == 0) { + if (line == 0) { prints("\033[1;46m 象棋對戰 \033[45m%30s VS %-30s\033[m", cuser.userid, chc_mateid); - } else if(line >= 3 && line <= 21) { + } else if (line >= 3 && line <= 21) { outs(" "); - for(i = 0; i < 9; i++) { + for (i = 0; i < 9; i++) { j = board[RTL(line)][i]; - if((line & 1) == 1 && j) { - if(chc_selected && - chc_select.r == RTL(line) && chc_select.c == i) + if ((line & 1) == 1 && j) { + if (chc_selected && + chc_select.r == RTL(line) && chc_select.c == i) prints("%s%s\033[m", CHE_O(j) == 0 ? BLACK_REVERSE : RED_REVERSE, chess_str[CHE_O(j)][CHE_P(j)]); @@ -118,36 +125,36 @@ void chc_drawline(board_t board, int line) { } else prints("%c%c", chess_brd[line - 3][i * 4], chess_brd[line - 3][i * 4 + 1]); - if(i != 8) + if (i != 8) prints("%c%c", chess_brd[line - 3][i * 4 + 2], chess_brd[line - 3][i * 4 + 3]); } outs(" "); - if(line >= 3 && line < 3 + dim(hint_str)) { + if (line >= 3 && line < 3 + dim(hint_str)) { outs(hint_str[line - 3]); - } else if(line == SIDE_ROW) { + } else if (line == SIDE_ROW) { prints("\033[1m你是%s%s\033[m", chc_my == 0 ? BLACK_COLOR : RED_COLOR, turn_str[chc_my]); - } else if(line == TURN_ROW) { + } else if (line == TURN_ROW) { prints("%s%s\033[m", TURN_COLOR, chc_my == chc_turn ? "輪到你下棋了" : "等待對方下棋"); - } else if(line == STEP_ROW && !chc_firststep) { + } else if (line == STEP_ROW && !chc_firststep) { showstep(board); - } else if(line == TIME_ROW) { + } else if (line == TIME_ROW) { prints("剩餘時間 %d:%02d", chc_lefttime / 60, chc_lefttime % 60); - } else if(line == WARN_ROW) { + } else if (line == WARN_ROW) { outs(chc_warnmsg); - } else if(line == MYWIN_ROW) { + } else if (line == MYWIN_ROW) { prints("\033[1;33m%12.12s " "\033[1;31m%2d\033[37m勝 " "\033[34m%2d\033[37m敗 " "\033[36m%2d\033[37m和\033[m", cuser.userid, cuser.chc_win, cuser.chc_lose - 1, cuser.chc_tie); - } else if(line == HISWIN_ROW) { + } else if (line == HISWIN_ROW) { prints("\033[1;33m%12.12s " "\033[1;31m%2d\033[37m勝 " "\033[34m%2d\033[37m敗 " @@ -155,20 +162,22 @@ void chc_drawline(board_t board, int line) { chc_mateid, chc_hiswin, chc_hislose - 1, chc_histie); } - } else if(line == 2 || line == 22) { + } else if (line == 2 || line == 22) { outs(" "); - if(line == 2) - for(i = 1; i <= 9; i++) + if (line == 2) + for (i = 1; i <= 9; i++) prints("%s ", num_str[i]); else - for(i = 9; i >= 1; i--) + for (i = 9; i >= 1; i--) prints("%s ", num_str[i]); } } -void chc_redraw(board_t board) { - int i; - - for(i = 0; i <= 22; i++) +void +chc_redraw(board_t board) +{ + int i; + + for (i = 0; i <= 22; i++) chc_drawline(board, i); } |