diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-05-30 23:42:18 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-05-30 23:42:18 +0800 |
commit | 715542867ba891acf8c1fd6234f5d6ea2fc285f6 (patch) | |
tree | 35727b8664dce3eb0f7421dd0cbb28c6636c672b /mbbsd/chess.c | |
parent | 05df0b0f9445089d03f7a2933875b9c7266eb96e (diff) | |
download | pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.tar pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.tar.gz pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.tar.bz2 pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.tar.lz pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.tar.xz pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.tar.zst pttbbs-715542867ba891acf8c1fd6234f5d6ea2fc285f6.zip |
Reversi (multiplayer othello) added
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3523 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/chess.c')
-rw-r--r-- | mbbsd/chess.c | 22 |
1 files changed, 13 insertions, 9 deletions
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; } |