summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/bbs.c34
-rw-r--r--mbbsd/gamble.c11
-rw-r--r--mbbsd/stuff.c25
3 files changed, 63 insertions, 7 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index bc6f5c29..904d4638 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1,4 +1,4 @@
-/* $Id: bbs.c,v 1.56 2002/06/22 07:35:44 ptt Exp $ */
+/* $Id: bbs.c,v 1.57 2002/06/23 03:33:07 ptt Exp $ */
#include "bbs.h"
static void mail_by_link(char* owner, char* title, char* path) {
@@ -952,14 +952,32 @@ static int b_man() {
}
#ifndef NO_GAMBLE
+void stop_gamble()
+{
+ boardheader_t *bp = getbcache(currbid);
+ char fn_ticket[128], fn_ticket_end[128];
+ if(!bp->endgamble || bp->endgamble>now) return;
+
+ setbfile(fn_ticket, currboard, FN_TICKET);
+ setbfile(fn_ticket_end, currboard, FN_TICKET_END);
+
+ rename(fn_ticket, fn_ticket_end);
+ if(bp->endgamble)
+ {
+ bp->endgamble= 0;
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
+ }
+}
static int join_gamble(int ent, fileheader_t *fhdr, char *direct) {
if(!HAS_PERM(PERM_LOGINOK)) return DONOTHING;
+ stop_gamble();
ticket(currbid);
return FULLUPDATE;
}
static int hold_gamble(int ent, fileheader_t *fhdr, char *direct) {
char fn_ticket[128],fn_ticket_end[128],genbuf[128],
msg[256]="",yn[10]="";
+ boardheader_t *bp = getbcache(currbid);
int i;
FILE *fp=NULL;
@@ -973,6 +991,11 @@ static int hold_gamble(int ent, fileheader_t *fhdr, char *direct) {
"是否要 [停止下注]?(N/y):", yn, 3, LCECHO);
if(yn[0]!='y') return FULLUPDATE;
rename(fn_ticket, fn_ticket_end);
+ if(bp->endgamble)
+ {
+ bp->endgamble= 0;
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
+ }
return FULLUPDATE;
}
@@ -1012,7 +1035,12 @@ static int hold_gamble(int ent, fileheader_t *fhdr, char *direct) {
i=atoi(yn);
} while( i<10 || i>10000);
fprintf(fp,"%d\n",i);
- move(3,0);
+ if(getdata(3,0,"設定自動封盤時間?(Y/n)",yn,6,LCECHO) && yn[0]!='n')
+ {
+ bp->endgamble= gettime(4, now);
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
+ }
+ move(4,0);
sprintf(genbuf,"請到 %s 板 按'f'參與賭博!\n\n一張 %d Ptt幣, 這是%s的賭博\n",
currboard,
i, i<100 ? "小賭式" : i<500 ? "平民級":
@@ -1022,7 +1050,7 @@ static int hold_gamble(int ent, fileheader_t *fhdr, char *direct) {
for(i=0; i<8; i++)
{
sprintf(yn, " %d)",i+1);
- getdata(6+i, 0, yn, genbuf, 9, DOECHO);
+ getdata(7+i, 0, yn, genbuf, 9, DOECHO);
if(!genbuf[0] && i>1)
break;
fprintf(fp,"%s\n",genbuf);
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index 88e82b67..c692cd4f 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -1,4 +1,4 @@
-/* $Id: gamble.c,v 1.19 2002/06/23 02:05:46 ptt Exp $ */
+/* $Id: gamble.c,v 1.20 2002/06/23 03:33:07 ptt Exp $ */
#include "bbs.h"
#ifndef _BBS_UTIL_C_
@@ -76,13 +76,18 @@ static int show_ticket_data(char *direct, int *price, boardheader_t *bh) {
int i,count, total = 0, end=0,
ticket[MAX_ITEM] = {0, 0, 0, 0, 0, 0, 0, 0};
FILE *fp;
- char genbuf[256];
+ char genbuf[256], t[25];
clear();
if (bh)
{
sprintf(genbuf,"%s 賭盤", bh->brdname);
- showtitle(genbuf, BBSNAME);
+ if(bh->endgamble && now > bh->endgamble && now-bh->endgamble<1800)
+ {
+ sprintf(t,"封盤倒數 %d 秒");
+ showtitle(genbuf, t);
+ }
+ else showtitle(genbuf, BBSNAME);
}
else
showtitle("Ptt賭盤", BBSNAME);
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 2fa278e9..f11ff9d5 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -1,4 +1,4 @@
-/* $Id: stuff.c,v 1.3 2002/06/04 13:08:34 in2 Exp $ */
+/* $Id: stuff.c,v 1.4 2002/06/23 03:33:07 ptt Exp $ */
#include "bbs.h"
/* ----------------------------------------------------- */
@@ -268,6 +268,29 @@ int belong(char *filelist, char *key) {
return rc;
}
+time_t gettime(int line, time_t dt)
+{
+ char yn[7];
+ struct tm *ptime = localtime(&dt), endtime;
+
+ sprintf(yn, "%4d", ptime->tm_year+1900);
+ do{
+ getdata_buf(line, 0, "西元年:", yn, 5, LCECHO);
+ }while( (endtime.tm_year = atoi(yn)-1900)<0 || endtime.tm_year>200);
+ sprintf(yn, "%d", ptime->tm_mon+1);
+ do{
+ getdata_buf(line, 13, "月:", yn, 3, LCECHO);
+ }while((endtime.tm_mon = atoi(yn)-1)<0 || endtime.tm_mon>11);
+ sprintf(yn, "%d", ptime->tm_mday);
+ do{
+ getdata_buf(line, 22, "日:", yn, 3, LCECHO);
+ }while((endtime.tm_mday = atoi(yn))<1 || endtime.tm_mday>31);
+ sprintf(yn, "%d", ptime->tm_hour);
+ do{
+ getdata_buf(line, 22, "時(0-23):", yn, 3, LCECHO);
+ }while(( endtime.tm_hour = atoi(yn))<0 || endtime.tm_hour>23);
+ return mktime(&endtime);
+}
char *Cdate(time_t *clock) {
static char foo[32];
struct tm *mytm = localtime(clock);