From 715542867ba891acf8c1fd6234f5d6ea2fc285f6 Mon Sep 17 00:00:00 2001 From: scw Date: Wed, 30 May 2007 15:42:18 +0000 Subject: Reversi (multiplayer othello) added git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3523 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/chess.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'mbbsd/chess.c') diff --git a/mbbsd/chess.c b/mbbsd/chess.c index 9df4f5bc..ca99bfaf 100644 --- a/mbbsd/chess.c +++ b/mbbsd/chess.c @@ -56,6 +56,7 @@ static const struct { { "gomoku", 6, &gomoku_replay }, { "chc", 3, &chc_replay }, { "go", 2, &gochess_replay }, + { "reversi",7, &reversi_replay }, { NULL } }; @@ -386,9 +387,9 @@ ChessReplayUntil(ChessInfo* info, int n) /* spcial for last one to maintian information correct */ step = ChessHistoryRetrieve(info, info->current_step); + info->turn = info->current_step++ & 1; info->actions->prepare_step(info, step); info->actions->apply_step(info->board, step); - info->current_step++; } static int @@ -778,6 +779,7 @@ ChessPlayFuncWatch(ChessInfo* info) /* at head but redo-ed */ info->actions->init_board(info->board); info->current_step = 0; + info->turn = 1; ChessReplayUntil(info, info->history.used - 1); ChessRedraw(info); } @@ -786,10 +788,10 @@ ChessPlayFuncWatch(ChessInfo* info) result == CHESS_STEP_SPECIAL) { if (info->current_step == info->history.used - 1) { /* was watching up-to-date board */ + info->turn = info->current_step++ & 1; info->actions->prepare_step(info, &info->step_tmp); info->actions->apply_step(info->board, &info->step_tmp); info->actions->drawstep(info, &info->step_tmp); - info->current_step++; } } else if (result == CHESS_STEP_PASS) strcpy(info->last_movestr, "µê¤â"); @@ -817,10 +819,10 @@ ChessPlayFuncWatch(ChessInfo* info) else { const void* step = ChessHistoryRetrieve(info, info->current_step); + info->turn = info->current_step++ & 1; info->actions->prepare_step(info, step); info->actions->apply_step(info->board, step); info->actions->drawstep(info, step); - info->current_step++; } break; @@ -1070,13 +1072,15 @@ ChessPlay(ChessInfo* info) for (game_result = CHESS_RESULT_CONTINUE; game_result == CHESS_RESULT_CONTINUE; info->turn ^= 1) { - info->actions->prepare_play(info); - ChessDrawLine(info, CHESS_DRAWING_TURN_ROW); - ChessDrawLine(info, CHESS_DRAWING_WARN_ROW); - game_result = info->play_func[(int) info->turn](info); + if (info->actions->prepare_play(info)) + info->pass[(int) info->turn] = 1; + else { + ChessDrawLine(info, CHESS_DRAWING_TURN_ROW); + ChessDrawLine(info, CHESS_DRAWING_WARN_ROW); + game_result = info->play_func[(int) info->turn](info); + } - if (info->constants->pass_is_step && - info->pass[0] && info->pass[1]) + if (info->pass[0] && info->pass[1]) game_result = CHESS_RESULT_END; } -- cgit v1.2.3