diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-03-12 19:25:53 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-03-12 19:25:53 +0800 |
commit | b729272d521985d2656660d2f83a3a29c8f6ec8f (patch) | |
tree | e3e9d4dd1ddf67e5499cab0479d52af52c721264 /mbbsd | |
parent | 097b557f8d8698c6992a4fdb510f76fd07229b64 (diff) | |
download | pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.tar pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.tar.gz pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.tar.bz2 pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.tar.lz pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.tar.xz pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.tar.zst pttbbs-b729272d521985d2656660d2f83a3a29c8f6ec8f.zip |
GO scoring and displaying on userlist.
!!!NOTE: shared memory changed!!!
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3276 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/cache.c | 6 | ||||
-rw-r--r-- | mbbsd/go.c | 36 | ||||
-rw-r--r-- | mbbsd/talk.c | 16 | ||||
-rw-r--r-- | mbbsd/user.c | 8 | ||||
-rw-r--r-- | mbbsd/var.c | 1 |
5 files changed, 48 insertions, 19 deletions
diff --git a/mbbsd/cache.c b/mbbsd/cache.c index a3bace26..8063d80c 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -319,7 +319,7 @@ search_ulist_pid(int pid) register userinfo_t *u; if (end == -1) return NULL; - ulist = SHM->sorted[SHM->currsorted][7]; + ulist = SHM->sorted[SHM->currsorted][8]; for (i = ((start + end) / 2);; i = (start + end) / 2) { u = &SHM->uinfo[ulist[i]]; j = pid - u->pid; @@ -347,7 +347,7 @@ search_ulistn(int uid, int unum) register userinfo_t *u; if (end == -1) return NULL; - ulist = SHM->sorted[SHM->currsorted][6]; + ulist = SHM->sorted[SHM->currsorted][7]; for (i = ((start + end) / 2);; i = (start + end) / 2) { u = &SHM->uinfo[ulist[i]]; j = uid - u->uid; @@ -410,7 +410,7 @@ count_logins(int uid, int show) userinfo_t *u; if (end == -1) return 0; - ulist = SHM->sorted[SHM->currsorted][6]; + ulist = SHM->sorted[SHM->currsorted][7]; for (i = ((start + end) / 2);; i = (start + end) / 2) { u = &SHM->uinfo[ulist[i]]; j = uid - u->uid; @@ -451,18 +451,18 @@ static void go_init_user(const userinfo_t* uinfo, ChessUser* user) { strlcpy(user->userid, uinfo->userid, sizeof(user->userid)); - user->win = 0; - user->lose = 0; - user->tie = 0; + user->win = uinfo->go_win; + user->lose = uinfo->go_lose; + user->tie = uinfo->go_tie; } static void go_init_user_userec(const userec_t* urec, ChessUser* user) { strlcpy(user->userid, urec->userid, sizeof(user->userid)); - user->win = 0; - user->lose = 0; - user->tie = 0; + user->win = urec->go_win; + user->lose = urec->go_lose; + user->tie = urec->go_tie; } static void @@ -793,8 +793,28 @@ go_post_game(ChessInfo* info) static void go_gameend(ChessInfo* info, ChessGameResult result) { - /* TODO: implement */ - if (info->mode == CHESS_MODE_REPLAY) { + if (info->mode == CHESS_MODE_VERSUS) { + ChessUser* const user1 = &info->user1; + /* ChessUser* const user2 = &info->user2; */ + + user1->lose--; + if (result == CHESS_RESULT_WIN) { + user1->win++; + currutmp->go_win++; + } else if (result == CHESS_RESULT_LOST) { + user1->lose++; + currutmp->go_lose++; + } else { + user1->tie++; + currutmp->go_tie++; + } + + cuser.go_win = user1->win; + cuser.go_lose = user1->lose; + cuser.go_tie = user1->tie; + + passwd_update(usernum, &cuser); + } else if (info->mode == CHESS_MODE_REPLAY) { free(info->board); free(info->tag); } diff --git a/mbbsd/talk.c b/mbbsd/talk.c index f53476b3..f5e0f9ad 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -13,7 +13,7 @@ static char * const withme_str[] = { "談天", "下五子棋", "鬥寵物", "下象棋", "下暗棋", "下圍棋", NULL }; -#define MAX_SHOW_MODE 5 +#define MAX_SHOW_MODE 6 #define M_INT 15 /* monitor mode update interval */ #define P_INT 20 /* interval to check for page req. in * talk/chat */ @@ -31,7 +31,7 @@ typedef struct pickup_t { /* 記錄 friend 的 user number */ // -#define PICKUP_WAYS 7 +#define PICKUP_WAYS 8 static char * const fcolor[11] = { "", ANSI_COLOR(36), ANSI_COLOR(32), ANSI_COLOR(1;32), @@ -1842,6 +1842,12 @@ descript(int show_mode, const userinfo_t * uentp, int diff) "%4d %s", uentp->chess_elo_rating, (uentp->withme&WITHME_CHESS)?"找我下棋":(uentp->withme&WITHME_NOCHESS)?"別找我":""); return description; + case 5: + snprintf(description, sizeof(description), + "%4d/%4d/%2d %c", uentp->go_win, + uentp->go_lose, uentp->go_tie, + (uentp->withme&WITHME_GO)?'o':(uentp->withme&WITHME_NOGO)?'x':' '); + return description; default: syslog(LOG_WARNING, "damn!!! what's wrong?? show_mode = %d", show_mode); @@ -2069,10 +2075,10 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, int show_pid, int myfriend, int friendme, int bfriend, int badfriend) { char *msg_pickup_way[PICKUP_WAYS] = { - "嗨! 朋友", "網友代號", "網友動態", "發呆時間", "來自何方", " 五子棋 ", " 象棋 " + "嗨! 朋友", "網友代號", "網友動態", "發呆時間", "來自何方", " 五子棋 ", " 象棋 ", " 圍棋 ", }; char *MODE_STRING[MAX_SHOW_MODE] = { - "故鄉", "好友描述", "五子棋戰績", "象棋戰績", "象棋等級分", + "故鄉", "好友描述", "五子棋戰績", "象棋戰績", "象棋等級分", "圍棋戰績", }; char pagerchar[5] = "* -Wf"; @@ -2656,6 +2662,8 @@ userlist(void) user_query_mode = 1; else if (show_mode == 3 || show_mode == 4) user_query_mode = 2; + else if (show_mode == 5) + user_query_mode = 3; else user_query_mode = 0; #endif /* defined(CHESSCOUNTRY) */ diff --git a/mbbsd/user.c b/mbbsd/user.c index 0cc785b9..fa4de3c1 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -6,12 +6,12 @@ static char * const sex[8] = { }; #ifdef CHESSCOUNTRY -static const char * const chess_photo_name[2] = { - "photo_fivechess", "photo_cchess" +static const char * const chess_photo_name[3] = { + "photo_fivechess", "photo_cchess", "photo_go", }; -static const char * const chess_type[2] = { - "五子棋", "象棋" +static const char * const chess_type[3] = { + "五子棋", "象棋", "圍棋", }; #endif diff --git a/mbbsd/var.c b/mbbsd/var.c index e44abd9d..3dc46b82 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -398,6 +398,7 @@ int user_query_mode; * user_query_mode = 0 simple data * = 1 gomoku chess country data * = 2 chc chess country data + * = 3 go chess country data */ #endif /* defined(CHESSCOUNTRY) */ |