作者s890510.bbs@bbs.cs.ntou.edu.tw (皮卡...累...) 看板: itoc
標題Re: 有人願意幫忙除錯一下嗎?
時間網際時空 (2008/02/07 Thu 21:17:58)
處裡好了~~
來貼個正確版吧~~
/include/global.h
+#ifdef HAVE_GAME
+#define FN_RUN_REDENVELOPE_LOG "run/redenvelope.log" /* jd.080205: 發紅包紀錄
*/
+#endif
在/so/新增redencelope.c
/*-------------------------------------------------------*/
/* redenvelope.c */
/*-------------------------------------------------------*/
/* target : 紅包系統 */
/* create : 08/02/05 */
/* update : / / */
/* author : s890510@bbs.cs.ntou.edu.tw */
/*-------------------------------------------------------*/
#include "bbs.h"
#ifdef HAVE_GAME
#define mouts(x,y,s) { move(x, y); outs(s); }
static void get_screen(int mode)
{
FILE *fp;
char *fpath, buf[ANSILINELEN];
vs_bar("領紅包");
if (mode == 0)
{
fpath = "etc/game/redenvelope.again";
move(1, 0);
}
else if (mode == 1)
{
fpath = "etc/game/redenvelope.get";
move(2, 0);
}
if (!(fp = fopen(fpath, "r")))
return;
while (fgets(buf, ANSILINELEN, fp))
outs(buf);
fclose(fp);
}
static int redenvelope()
{
char fpath[64],buf[80];
int fd,randum,rand_gold = 0;
while(1)
{
if (vans("準備好要領紅包了嗎(Y/N)?")!= 'y')
return 0;
usr_fpath(fpath, cuser.userid, "redenvelope");
if ((fd = open(fpath, O_RDONLY)) > 0)
{
vmsg("站長:領過了還想要領?門都沒有!");
return 0;
}
else
{
move(18,10);
prints("%s:嘿嘿~錢不太夠了,給點紅包錢吧~",cuser.userid);
move(19,10);
prints("站長:給你給你(隨便抓一些錢放進紅包),祝你新春愉快~");
randum = rand() % 2000000 + 1;
move(20,10);
if((randum % 9) == 0)
{
randum = (randum/100000)+1;
rand_gold = 1;
prints("系統:你獲得了%d金幣",randum);
cuser.gold += randum;
}
else
{
prints("系統:你獲得了%d銀幣",randum);
cuser.money += randum;
}
if(rand_gold == 1)
sprintf(buf, "%-13s領取了紅包 %d 金 (%s)\n", cuser.userid, randum, Now());
else
sprintf(buf, "%-13s領取了紅包 %d 銀 (%s)\n", cuser.userid, randum, Now());
f_cat(FN_RUN_REDENVELOPE_LOG, buf);
usr_fpath(fpath, cuser.userid, "redenvelope");
sprintf(buf, "已領取了紅包");
f_cat(fpath, buf);
}
}
}
int main_redenvelope()
{
get_screen(1);
redenvelope();
return 0;
}
#endif /* HAVE_GAME */
--
╭┼ Origin: 海大資工˙網際時空 bbs.cs.ntou.edu.tw
┼┘ Author: s890510 從 118-165-217-42.dynamic.hinet.net 發表