summaryrefslogtreecommitdiffstats
path: root/mbbsd/chess.c
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-09-03 23:40:34 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-09-03 23:40:34 +0800
commitcf12c67f29ef452feef6c9426671c108f0c717e8 (patch)
tree36882d0a58c6d14256c03b0326f12e40ebea1f5e /mbbsd/chess.c
parentd4da0ab5ad5337030f4d1923e6e6368fc571f70b (diff)
downloadpttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.tar
pttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.tar.gz
pttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.tar.bz2
pttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.tar.lz
pttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.tar.xz
pttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.tar.zst
pttbbs-cf12c67f29ef452feef6c9426671c108f0c717e8.zip
* 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
Diffstat (limited to 'mbbsd/chess.c')
-rw-r--r--mbbsd/chess.c23
1 files changed, 17 insertions, 6 deletions
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;