diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-30 08:29:10 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-30 08:29:10 +0800 |
commit | 8c66da7267b5b91eb47b3321892a505e7824d5e6 (patch) | |
tree | 27fd486f52e7d5354f98808b6afeed192f57cb38 /mbbsd/chc.c | |
parent | 9d9efb47decf91be83230ff1f2318d6f2d981265 (diff) | |
download | pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.tar pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.tar.gz pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.tar.bz2 pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.tar.lz pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.tar.xz pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.tar.zst pttbbs-8c66da7267b5b91eb47b3321892a505e7824d5e6.zip |
* (pwch branch) change chess results to use pwcu API
git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.pwcu@4793 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/chc.c')
-rw-r--r-- | mbbsd/chc.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 2a52f43b..6d4a2f4e 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -658,15 +658,6 @@ chc_ischeck(board_t board, int turn) */ static void -chcusr_put(userec_t* userec, const ChessUser* user) -{ - userec->chc_win = user->win; - userec->chc_lose = user->lose; - userec->chc_tie = user->tie; - userec->chess_elo_rating = user->rating; -} - -static void chc_init_user(const userinfo_t *uinfo, ChessUser *user) { strlcpy(user->userid, uinfo->userid, sizeof(user->userid)); @@ -848,9 +839,7 @@ chc(int s, ChessGameMode mode) /* Assume that info->user1 is me. */ info->user1.lose++; count_chess_elo_rating(&info->user1, &info->user2, 0.0); - passwd_sync_query(usernum, cuser_ref); - chcusr_put(cuser_ref, &info->user1); - passwd_sync_update(usernum, cuser_ref); + pwcuChessResult(SIG_CHC, CHESS_RESULT_LOST); } if (mode == CHESS_MODE_WATCH) @@ -876,36 +865,38 @@ chc_gameend(ChessInfo* info, ChessGameResult result) /* NOTE, 若紅方斷線則無 log */ time_t t = time(NULL); char buf[100]; + uint16_t lose1 = user1->lose, lose2 = user2->lose; + if (lose1 > 0) lose1--; + if (lose2 > 0) lose2--; sprintf(buf, "%s %s(%d,W%d/D%d/L%d) %s %s(%d,W%d/D%d/L%d)\n", ctime(&t), user1->userid, user1->rating, user1->win, - user1->tie, user1->lose - 1, + user1->tie, lose1, (result == CHESS_RESULT_TIE ? "和" : result == CHESS_RESULT_WIN ? "勝" : "負"), user2->userid, user2->rating, user2->win, - user2->tie, user2->lose - 1); + user2->tie, lose2); buf[24] = ' '; // replace '\n' log_file(BBSHOME "/log/chc.log", LOG_CREAT, buf); } + // lost was already initialized + if (result != CHESS_RESULT_LOST) + pwcuChessResult(SIG_CHC, result); + user1->rating = user1->orig_rating; - user1->lose--; + + // TODO update and save the elo rating if (result == CHESS_RESULT_WIN) { count_chess_elo_rating(user1, user2, 1.0); - user1->win++; - currutmp->chc_win++; } else if (result == CHESS_RESULT_LOST) { count_chess_elo_rating(user1, user2, 0.0); - user1->lose++; - currutmp->chc_lose++; } else { count_chess_elo_rating(user1, user2, 0.5); - user1->tie++; - currutmp->chc_tie++; } currutmp->chess_elo_rating = user1->rating; - chcusr_put(cuser_ref, user1); - passwd_sync_update(usernum, cuser_ref); + pwcuSetChessEloRating(user1->rating); + } else if (info->mode == CHESS_MODE_REPLAY) { free(info->board); free(info->tag); |