From f1c53390c4817e5f9552588f298808764ef1bc65 Mon Sep 17 00:00:00 2001 From: scw Date: Sat, 10 Sep 2005 17:30:22 +0000 Subject: GO convertion to chess framework * versus, personal and watching all work chess.c framework update * "pass" and "tie request" are distinguished * chess-specific key binding * post-game processing !!!NOTE!!! Chess protocals are NOT backward compatible RESTART WHOLE system to ensure correctness git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3153 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/chess.h | 18 ++++++++++++++---- include/gomo.h | 3 --- include/proto.h | 7 +++++-- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/chess.h b/include/chess.h index 8384e225..f51dfa5b 100644 --- a/include/chess.h +++ b/include/chess.h @@ -97,7 +97,7 @@ typedef struct ChessInfo { const char myturn; /* 我方顏色 */ char turn; - char ipass, hepass; + char pass[2]; char warnmsg[64]; char last_movestr[36]; char *photo; @@ -128,11 +128,13 @@ typedef struct ChessActions { void (*drawline) (const ChessInfo* info, int line); void (*movecur) (int r, int c); void (*prepare_play)(ChessInfo* info); + int (*process_key) (ChessInfo* info, int key, ChessGameResult* result); int (*select) (ChessInfo* info, rc_t location, ChessGameResult* result); void (*prepare_step)(ChessInfo* info, const void* step); - ChessGameResult (*apply_step) (void* board, const void* step); + ChessGameResult (*apply_step)(void* board, const void* step); void (*drawstep) (ChessInfo* info, const void* step); + ChessGameResult (*post_game)(ChessInfo* info); /* ending */ void (*gameend) (ChessInfo* info, ChessGameResult result); @@ -144,6 +146,7 @@ typedef struct ChessConstants { int traditional_timeout; int board_height; int board_width; + int pass_is_step; const char *chess_name; const char *photo_file_name; const char *log_board; @@ -154,7 +157,13 @@ typedef struct ChessConstants { typedef enum { CHESS_STEP_NORMAL, CHESS_STEP_PASS, CHESS_STEP_DROP, CHESS_STEP_FAILURE, - CHESS_STEP_NOP, /* for wake up */ + CHESS_STEP_SPECIAL, /* chesses' special steps */ + CHESS_STEP_NOP, /* for wake up */ + + CHESS_STEP_TIE, /* tie request */ + CHESS_STEP_TIE_ACC, /* accept */ + CHESS_STEP_TIE_REJ, /* reject */ + CHESS_STEP_UNDO, /* undo request */ CHESS_STEP_UNDO_ACC, /* accept */ CHESS_STEP_UNDO_REJ, /* reject */ @@ -185,7 +194,8 @@ void ChessEstablishRequest(int sock); void ChessAcceptingRequest(int sock); void ChessShowRequest(void); +void ChessRedraw(const ChessInfo* info); void ChessDrawLine(const ChessInfo* info, int line); -void ChessDrawExtraInfo(const ChessInfo* info, int line); +void ChessDrawExtraInfo(const ChessInfo* info, int line, int space); #endif /* INCLUDE_CHESS_H */ diff --git a/include/gomo.h b/include/gomo.h index b5e8d014..85b9d276 100644 --- a/include/gomo.h +++ b/include/gomo.h @@ -11,9 +11,6 @@ #define BRDSIZ (15) /* 棋盤單邊大小 */ #endif -#define BGOTO(x, y) move( 16 - (y) , (x) * 2 + 3) -#define BGOTOCUR(x, y) move(16 - (y), (x) * 2 + 4 - 8) - /* 0 0 0 = #@# : len= 3 : NO 00 NO 1 1 0 = #_@# : len= 4 : NO 00 NO diff --git a/include/proto.h b/include/proto.h index 38bd407c..b34cfab1 100644 --- a/include/proto.h +++ b/include/proto.h @@ -290,8 +290,11 @@ int openticket(int bid); int ticket(int bid); /* go */ -int gochess(int fd); -int GoBot(void); +void gochess(int s, ChessGameMode mode); +int gochess_main(void); +int gochess_personal(void); +int gochess_watch(void); +ChessInfo* gochess_replay(FILE* fp); /* gomo */ void gomoku(int s, ChessGameMode mode); -- cgit v1.2.3