[M3] 俄羅斯方塊(單雙版) talk.c 之修改...
為配合雙人對戰,伀五子棋做法,在兩人聊天時用功能鍵調用。
並且讓用戶在網友列錶裏可以查詢用戶的戰績,加上功能鍵 'G'.
::: src/maple/talk.c :::
1) 在
... ...
's', ulist_init, /* refresh status Thor: 應user要求 */
之後增加以下幾行
#ifdef HAVE_TETRIS /* hightman.030101: 戰績查詢 */
'G', ulist_query2,
#endif
2) 修改 do_query() 函數
+ if (paling >= 0) {
+ /* hightman.010719: 為負數時不顯示名片,不必vmsg(NULL)... */
showplans(userid);
vmsg(NULL);
move(b_lines, 0);
clrtoeol();
+ }
3) 在 函數 static int ulist_query(xo) 之前增加以下部分
如果您站上沒有五子棋,象棋功能可去掉相關部分。或在
將 #define HAVE_CHESS 改為 #undef
/* hightman.030101: 查詢戰績 */
#ifdef HAVE_TETRIS
#define HAVE_CHESS // 若沒有五子棋,象棋,請在此 undef
static void show_game_rec(userid)
char *userid;
{
int win, total, prop, key_win, key_total, i;
TetrisRecord tr;
#ifdef HAVE_CHESS
static char *bw[] = { "黑白棋", "五子棋", "圍棋" };
static char *ch[] = { "象棋", "暗棋" };
#endif
#define BOUNDLINE " +-----------------------------------------+\n"
outs("\n | | 對弈次數 | 戰勝次數 | 勝率 |\n");
#ifdef HAVE_CHESS
for (i = 0; i < 3; i++)
{
key_win = ATTR_OTHELLO_WIN + (i << 8);
key_total = ATTR_OTHELLO_TOTAL + (i << 8);
if (attr_get(userid, key_win, &win) < 0)
win = 0;
if (attr_get(userid, key_total, &total) < 0)
total = 0;
prop = (total ? 100 * win / total : 0);
outs(BOUNDLINE);
prints(" | %-10s | %-8d | %-8d | %3d%% |\n", bw[i], total, win, prop);
}
for (i = 0; i < 2; i++)
{
key_win = ATTR_GCHESS_WIN + (i << 8);
key_total = ATTR_GCHESS_LOSE + (i << 8);
if (attr_get(userid, key_win, &win) < 0)
win = 0;
if (attr_get(userid, key_total, &total) < 0)
total = 0;
total += win;
prop = (total ? 100 * win / total : 0);
outs(BOUNDLINE);
prints(" | %-10s | %-8d | %-8d | %3d%% |\n", ch[i], total, win, prop);
}
#endif
if (attr_get(userid, ATTR_TETRIS_REC, &tr) < 0)
{
tr.exp = 1000;
tr.total = tr.win = tr.maxscore = tr.maxlines = 0;
}
prop = (tr.total ? 100 * tr.win / tr.total : 0);
outs(BOUNDLINE);
prints(" | 俄羅斯方塊 | %-8d | %-8d | %3d%% |\n", tr.total, tr.win, prop);
outs(BOUNDLINE);
outs(" | | 最高得分 | 最多條數 | |\n");
//outs(BOUNDLINE);
prints(" | | %-8d | % -8d | |\n", tr.maxscore, tr.maxlines);
//outs(BOUNDLINE);
prints(" | | 積分: %-8d 點 (第%2d級) |\n", tr.exp, (tr.exp / 100));
outs(BOUNDLINE);
#undef BOUNDLINE
vmsg(NULL);
}
static int ulist_query2(xo)
XO *xo;
{
move(1, 0);
clrtobot();
my_query(ulist_pool[xo->pos]->userid, -1);
show_game_rec(ulist_pool[xo->pos]->userid);
ulist_neck(xo);
return XO_FOOT;
}
#endif
4) 修改 talk_speak() 函數
在 ... ...
if (ch == I_OTHERDATA) {
ch = recv(fd, data, 80, 0);
if (ch <= 0)
break;
之後加上
#ifdef HAVE_TETRIS
if (data[0] == Ctrl('T')) { /* Hightman.021229: 俄羅斯方塊對戰 */
if (DL_func("bin/tetris2.so:vaTetris", fd, 1) == -2)
break;
utmp_mode(M_TALK);
continue;
}
#endif
.............
在 ... ...
else if (isprint2(ch) || ch == '\n' || ch == Ctrl('H')
|| ch == Ctrl('G')) {
.......
之前(註意是之前)加上
#ifdef HAVE_TETRIS
else if (ch == Ctrl('T')) { /* Hightman.021229: 俄羅斯方塊對戰 */
data[0] = ch;
if (send(fd, data, 1, 0) != 1)
break;
if (DL_func("bin/tetris2.so:vaTetris", fd, 0) == -2)
break;
utmp_mode(M_TALK);
}
#endif
--
※ 來源:.溫馨小屋 bbs.feeling.smth.org.[FROM: lib.zju.edu.cn]
Maple 近期熱門文章
PTT數位生活區 即時熱門文章