diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-31 19:53:17 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-31 19:53:17 +0800 |
commit | 6f896bea66286ad637861ccae7126fda98c0c4ff (patch) | |
tree | 2c76bdbb8e1d1a049e7d09c0764ea7d99afe2ddf | |
parent | 4b5bac6a3c1bd493bb89e6973a0849977e6bbf11 (diff) | |
download | pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.tar pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.tar.gz pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.tar.bz2 pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.tar.lz pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.tar.xz pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.tar.zst pttbbs-6f896bea66286ad637861ccae7126fda98c0c4ff.zip |
treat lose and decrease chess rating if disconnected
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2301 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/chc.h | 1 | ||||
-rw-r--r-- | mbbsd/chc.c | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/include/chc.h b/include/chc.h index 052565cf..e3b16d38 100644 --- a/include/chc.h +++ b/include/chc.h @@ -38,6 +38,7 @@ typedef struct chcusr_t{ int lose; int tie; unsigned short rating; + unsigned short orig_rating; // 原始 rating, 因為遊戲開始先算輸一場, rating 值就跑掉了 } chcusr_t; #define CHC_ACT_BOARD 0x1 /* set if transfered board to this sock */ diff --git a/mbbsd/chc.c b/mbbsd/chc.c index f2c22fbd..c4f20dff 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -620,6 +620,7 @@ chcusr_get(userec_t *userec, chcusr_t *user) user->rating = userec->chess_elo_rating; if(user->rating == 0) user->rating = 1500; /* ELO initial value */ + user->orig_rating = user->rating; } static int @@ -813,6 +814,7 @@ count_chess_elo_rating(chcusr_t *user1, chcusr_t *user2, double myres) { double k; double exp_res; + if(user1->rating < 1800) k = 30; else if(user1->rating < 2000) @@ -850,7 +852,8 @@ mainloop(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t pla } if (chc_mode & CHC_VERSUS) { - /* XXX 不正常斷線目前不會更改 ELO rating */ + user1->rating = user1->orig_rating; + user1->lose--; if (endgame == 1) { strlcpy(chc_warnmsg, "對方認輸了!", sizeof(chc_warnmsg)); count_chess_elo_rating(user1, user2, 1.0); @@ -868,7 +871,6 @@ mainloop(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t pla currutmp->chc_tie++; } currutmp->chess_elo_rating = user1->rating; - user1->lose--; chcusr_put(&cuser, user1); passwd_update(usernum, &cuser); } @@ -1017,6 +1019,7 @@ chc_init(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t pla // chc_broadcast_recv(act_list, board); user1->lose++; + count_chess_elo_rating(user1, user2, 0.0); if (chc_mode & CHC_VERSUS) { passwd_query(usernum, &xuser); |