summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-23 20:48:19 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-23 20:48:19 +0800
commit76e1eaf7912082c13829bab92b0a4974c2c824cf (patch)
tree021b6ba6820af464595b547c2f0bcd1604d4d16a
parentd1d03b072337c249adfaeb5ff936fa2d9065b9c7 (diff)
downloadpttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.tar
pttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.tar.gz
pttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.tar.bz2
pttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.tar.lz
pttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.tar.xz
pttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.tar.zst
pttbbs-76e1eaf7912082c13829bab92b0a4974c2c824cf.zip
Showing picture on five chess match. (only when both sides participated
chess country and have photos) git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2421 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/gomo.c142
1 files changed, 118 insertions, 24 deletions
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index b1bef205..9980d9fc 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -8,6 +8,7 @@ static int tick, lastcount, mylasttick, hislasttick;
//static char ku[BRDSIZ][BRDSIZ];
static Horder_t *v;
+static int draw_photo;
#define move(y,x) move(y, (x) + ((y) < 2 || (y) > 16 ? 0 : \
(x) > 35 ? 11 : 8))
@@ -237,7 +238,7 @@ chkmv(char ku[][BRDSIZ], Horder_t * mv, int color, int limit)
"\033[1;31m�s��\033[m"};
int rule = getstyle(ku, mv->x, mv->y, color, limit);
if (rule > 1 && rule < 13) {
- move(15, 40);
+ move(draw_photo ? 19 : 15, 40);
outs(xtype[rule - 2]);
bell();
}
@@ -301,8 +302,9 @@ gomoku(int fd)
int hewantpass, iwantpass;
userinfo_t *my = currutmp;
Horder_t pool[BRDSIZ*BRDSIZ];
- int scr_need_redraw = 1;
+ int scr_need_redraw;
char ku[BRDSIZ][BRDSIZ];
+ char genbuf[200];
HO_init(ku, pool);
me = !(my->turn) + 1;
@@ -319,13 +321,13 @@ gomoku(int fd)
outs(
" A B C D E F G H I J K L M N\n"
" 15\033[30;43m�z�s�s�s�s�s�s�s�s�s�s�s�s�s�{\033[m\n"
- " 14\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m [q] �{�����}\n"
- " 13\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m [u] ���� \n"
- " 12\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m [p] �n�D�M��\n"
+ " 14\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
+ " 13\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
+ " 12\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 11\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 10\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 9\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
- " 8\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m [�w���five_chess�Q�פ��l�ѳ�]\n"
+ " 8\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 7\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 6\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 5\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
@@ -334,21 +336,112 @@ gomoku(int fd)
" 2\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n"
" 1\033[30;43m�|�r�r�r�r�r�r�r�r�r�r�r�r�r�}\033[m\n"
);
- move(11, 40);
- prints("�ڬO %s", me == BBLACK ? "���� ��, ���T��" : "��� ��");
- move(16, 40);
- prints("\033[1;33m%s", cuser.userid);
- move(17, 40);
- prints("\033[1;33m%s", my->mateid);
- move(16, 60);
- prints("\033[1;31m%d\033[37m�� \033[34m%d\033[37m�� \033[36m%d\033[37m�M"
- "\033[m", cuser.five_win, cuser.five_lose, cuser.five_tie);
+ draw_photo = 0;
+ setuserfile(genbuf, "photo_fivechess");
+ if (dashf(genbuf)) {
+ sethomefile(genbuf, my->mateid, "photo_fivechess");
+ if (dashf(genbuf))
+ draw_photo = 1;
+ }
getuser(my->mateid);
- move(17, 60);
- prints("\033[1;31m%d\033[37m�� \033[34m%d\033[37m�� \033[36m%d\033[37m"
- "�M\033[m", xuser.five_win, xuser.five_lose, xuser.five_tie);
+ if (draw_photo) { // XXX
+ int line;
+ FILE* fp;
+
+ setuserfile(genbuf, "photo_fivechess");
+ fp = fopen(genbuf, "r");
+ if (fp == NULL)
+ goto drawing_reference;
+ for (line = 2; line < 8; ++line) {
+ move(line, 37);
+ if (fgets(genbuf, 200, fp)) {
+ genbuf[strlen(genbuf) - 1] = 0;
+ prints("%s ", genbuf);
+ } else
+ outs(" ");
+
+ switch (line - 2) {
+ case 0: prints("<�N��> %s", cuser.userid); break;
+ case 1: prints("<�ʺ�> %.16s", cuser.username); break;
+ case 2: prints("<�W��> %d", cuser.numlogins); break;
+ case 3: prints("<�峹> %d", cuser.numposts); break;
+ case 4: prints("<�]��> %d", cuser.money); break;
+ case 5: prints("<�ӷ�> %.16s", cuser.lasthost); break;
+ }
+ }
+ fclose(fp);
+
+ move(8, 43);
+ prints("\033[7m%s\033[m", me == BBLACK ? "�´�" : "�մ�");
+ move(9, 43);
+ outs(" ��.�� ");
+ move(10, 68);
+ prints("\033[7m%s\033[m", me == BBLACK ? "�մ�" : "�´�");
+
+ sethomefile(genbuf, my->mateid, "photo_fivechess");
+ fp = fopen(genbuf, "r");
+ if (fp == NULL)
+ goto drawing_reference;
+ for (line = 11; line < 17; ++line) {
+ move(line, 37);
+ switch (line - 11) {
+ case 0: prints("<�N��> %-16.16s ", xuser.userid); break;
+ case 1: prints("<�ʺ�> %-16.16s ", xuser.username); break;
+ case 2: prints("<�W��> %-16d ", xuser.numlogins); break;
+ case 3: prints("<�峹> %-16d ", xuser.numposts); break;
+ case 4: prints("<�]��> %-16d ", xuser.money); break;
+ case 5: prints("<�ӷ�> %-16.16s ", xuser.lasthost); break;
+ }
+
+ if (fgets(genbuf, 200, fp)) {
+ genbuf[strlen(genbuf) - 1] = 0;
+ outs(genbuf);
+ } else
+ outs(" ");
+ }
+ fclose(fp);
+
+ move(18, 4);
+ prints("�ڬO %s", me == BBLACK ? "���� ���A���T��" : "��� ��");
+ } else {
+drawing_reference:
+
+ if (draw_photo) { // jump from `if' block
+ int i;
+ for (i = 2; i < 11; ++i) {
+ move(i, 37);
+ clrtoeol();
+ }
+ draw_photo = 0;
+ }
+
+ move(3, 40); outs("[q] �{�����}");
+ move(4, 40); outs("[u] ����");
+ move(5, 40); outs("[p] �n�D�M��");
+ move(9, 39); outs("[�w���five_chess�Q�פ��l�ѳ�]");
+
+ move(11, 40);
+ prints("�ڬO %s", me == BBLACK ? "���� ��, ���T��" : "��� ��");
+ move(16, 40);
+ prints("\033[1;33m%s", cuser.userid);
+ move(17, 40);
+ prints("\033[1;33m%s", my->mateid);
+
+ move(16, 60);
+ prints("\033[1;31m%d\033[37m�� \033[34m%d\033[37m�� \033[36m%d\033[37m�M"
+ "\033[m", cuser.five_win, cuser.five_lose, cuser.five_tie);
+
+ move(17, 60);
+ prints("\033[1;31m%d\033[37m�� \033[34m%d\033[37m�� \033[36m%d\033[37m"
+ "�M\033[m", xuser.five_win, xuser.five_lose, xuser.five_tie);
+
+ move(18, 40);
+ prints("%s�ɶ��ٳ�%d:%02d\n", my->turn ? "�A��" : "���",
+ MAX_TIME / 60, MAX_TIME % 60);
+ }
+ outmsg("\033[1;33;42m �U���l�� \033[;31;47m (��������)\033[30m���� \033[31m(�ť���/ENTER)\033[30m�U�l \033[31m(q)\033[30m�뭰 \033[31m(p)\033[30m�M�� \033[31m(u)\033[30m���� \033[m");
cuser.five_lose++;
/* �@�i�ӥ��[�@���ѳ�, Ĺ�F��A���^�h, �קK�ֿ�F�c�N�_�u */
@@ -358,12 +451,13 @@ gomoku(int fd)
hewantpass = iwantpass = 0;
mv.x = mv.y = 7;
- move(18, 40);
- prints("%s�ɶ��ٳ�%d:%02d\n", my->turn ? "�A��" : "���",
- MAX_TIME / 60, MAX_TIME % 60);
+ scr_need_redraw = 1;
for (;;) {
if (scr_need_redraw){
- move(13, 40);
+ if (draw_photo)
+ move(19, 4);
+ else
+ move(13, 40);
outs(my->turn ? "����ۤv�U�F!" : "���ݹ��U�l..");
redoln();
scr_need_redraw = 0;
@@ -393,7 +487,7 @@ gomoku(int fd)
break;
}
}
- move(14, 40);
+ move(draw_photo ? 20 : 14, 40);
if (hewantpass) {
outs("\033[1;32m�M�ѭn�D!\033[m");
bell();
@@ -539,7 +633,7 @@ gomoku(int fd)
my->five_lose++;
break;
}
- move(15, 40);
+ move(draw_photo ? 19 : 15, 40);
clrtoeol();
}
scr_need_redraw = 1;