summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-23 22:19:42 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-23 22:19:42 +0800
commit3a0e713966abc5096a05d4294cc71a15bd71233c (patch)
tree4eca932f10d74f61fc3a44090fdbc069ef8c21b3
parent253ffe32777fe96cf317ad3c9c94b0accd78e72f (diff)
downloadpttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.tar
pttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.tar.gz
pttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.tar.bz2
pttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.tar.lz
pttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.tar.xz
pttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.tar.zst
pttbbs-3a0e713966abc5096a05d4294cc71a15bd71233c.zip
Fix gomoku passing states.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2423 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/gomo.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index c36a6b0e..e73c6ad6 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -299,7 +299,7 @@ gomoku(int fd)
{
Horder_t mv;
int me, he, ch;
- int hewantpass, iwantpass;
+ char hewantpass, iwantpass, passrejected;
userinfo_t *my = currutmp;
Horder_t pool[BRDSIZ*BRDSIZ];
int scr_need_redraw;
@@ -452,7 +452,7 @@ gomoku(int fd)
add_io(fd, 0);
- hewantpass = iwantpass = 0;
+ hewantpass = iwantpass = passrejected = 0;
mv.x = mv.y = 7;
scr_need_redraw = 1;
for (;;) {
@@ -491,21 +491,32 @@ gomoku(int fd)
}
}
move(draw_photo ? 20 : 14, 40);
+ clrtoeol();
if (hewantpass) {
outs("\033[1;32m和棋要求!\033[m");
bell();
- } else
- clrtoeol();
+ } else if (iwantpass)
+ outs("\033[1;32m提出和棋要求!\033[m");
+ else if (passrejected) {
+ outs("\033[1;32m要求被拒!\033[m");
+ passrejected = 0;
+ }
BGOTOCUR(mv.x, mv.y);
ch = igetch();
- if (ch != I_OTHERDATA)
+ if ((iwantpass || hewantpass) && ch != 'p' && ch != I_OTHERDATA) {
+ mv.x = mv.y = -3;
+ send(fd , &mv, sizeof(Horder_t), 0);
+ mv = *(v - 1);
iwantpass = 0;
+ hewantpass = 0;
+ continue;
+ }
if (ch == 'q') {
if (countgomo(pool) < 10) {
cuser.five_lose--;
passwd_update(usernum, &cuser);
}
- send(fd, '\0', 1, 0);
+ send(fd, "", 1, 0);
break;
} else if (ch == 'u' && !my->turn && v > pool) {
mv.x = mv.y = -1;
@@ -569,6 +580,13 @@ gomoku(int fd)
mv = *(v - 1);
continue;
}
+ } else if (mv.x == -3 && mv.y == -3) {
+ if (iwantpass)
+ passrejected = 1;
+ iwantpass = 0;
+ hewantpass = 0;
+ mv = *(v - 1);
+ continue;
}
if (my->turn && mv.x == -1 && mv.y == -1) {
outmsg("對方悔棋");