From cf12c67f29ef452feef6c9426671c108f0c717e8 Mon Sep 17 00:00:00 2001 From: scw Date: Sat, 3 Sep 2005 15:40:34 +0000 Subject: * help message update: 'p' means "tie request" as well as pass * opposite alive check at begin * time limit calculating way changed (Chinese chess rule) git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3126 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/chess.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'mbbsd/chess.c') diff --git a/mbbsd/chess.c b/mbbsd/chess.c index 72632357..c44b669f 100644 --- a/mbbsd/chess.c +++ b/mbbsd/chess.c @@ -120,7 +120,7 @@ ChessDrawHelpLine(const ChessInfo* info) ANSI_COLOR(;31;47) " (←↑↓→)" ANSI_COLOR(30) " 移動 " ANSI_COLOR(31) "(空白鍵/ENTER)" ANSI_COLOR(30) " 下子 " ANSI_COLOR(31) "(q)" ANSI_COLOR(30) " 認輸 " - ANSI_COLOR(31) "(p)" ANSI_COLOR(30) " 虛手 " + ANSI_COLOR(31) "(p)" ANSI_COLOR(30) " 虛手/和棋 " ANSI_COLOR(31) "(u)" ANSI_COLOR(30) " 悔棋 " ANSI_RESET, @@ -223,11 +223,9 @@ ChessStepMade(ChessInfo* info, int who) { if (!info->timelimit) info->lefttime[who] = info->constants->traditional_timeout; - else if ( - (info->lefthand[who] && (--(info->lefthand[who]) == 0)) - || - (info->lefthand[who] == 0 && info->lefttime[who] <= 0) - ) { + else if (info->lefthand[who]) + info->lefthand[who]--; + else if (info->lefthand[who] == 0 && info->lefttime[who] <= 0) { info->lefthand[who] = info->timelimit->limit_hand; info->lefttime[who] = info->timelimit->limit_time; } @@ -314,6 +312,13 @@ ChessMessageSend(ChessInfo* info, ChessStepType type) return ChessStepSend(info, &type); } +static inline int +ChessCheckAlive(ChessInfo* info) +{ + ChessStepType type = CHESS_STEP_NOP; + return ChessStepSendOpposite(info, &type); +} + ChessStepType ChessStepReceive(ChessInfo* info, void* step) { @@ -912,6 +917,12 @@ ChessPlay(ChessInfo* info) if (info == NULL) return; + if (!ChessCheckAlive(info)) { + if (info->sock) + close(info->sock); + return; + } + /* XXX */ if (!info->timelimit) { info->timelimit = _current_time_limit; -- cgit v1.2.3