From 48049f58fca08253facdfa66371b48ea046abcc9 Mon Sep 17 00:00:00 2001 From: victor Date: Mon, 16 Apr 2007 02:59:01 +0000 Subject: horoscope flavor birthday card git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3503 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/admin.c | 13 ++++++++++--- mbbsd/calendar.c | 16 ++++++++++++++++ mbbsd/mbbsd.c | 4 +++- 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 766ecab0..161dd851 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -679,8 +679,8 @@ m_board(void) int x_file(void) { - int aborted; - char ans[4], *fpath; + int aborted, num; + char ans[4], *fpath, buf[256]; move(b_lines - 7, 0); /* Ptt */ @@ -786,7 +786,14 @@ x_file(void) fpath = "etc/Logout"; break; case 'k': - fpath = "etc/Welcome_birth"; + mouts(b_lines - 3, 0, "1.摩羯 2.水瓶 3.雙魚 4.白羊 5.金牛 6.雙子"); + mouts(b_lines - 2, 0, "7.巨蟹 8.獅子 9.處女 10.天秤 11.天蠍 12.射手"); + getdata(b_lines - 1, 0, "請選擇 [1-12]", ans, sizeof(ans), LCECHO); + num = atoi(ans); + if (num <= 0 || num > 12) + return FULLUPDATE; + snprintf(buf, sizeof(buf), "etc/Welcome_birth.%d\n", num); + fpath = buf; break; case 'l': fpath = "etc/feast"; diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index ba0fb45a..2f2e5af6 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -323,3 +323,19 @@ calendar(void) pressanykey(); return 0; } + +int getHoroscope(int m, int d) +{ + // 摩羯 水瓶 雙魚 白羊 金牛 雙子 巨蟹 獅子 處女 天秤 天蠍 射手 + const int firstday[12] = { + /* Dec. */ 22, /* Jan. */ 20, 19, 21, 20, 21, 21, 23, 23, 23, 23, 22 + }; + if (d >= firstday[m]) { + if (m == 12) + return 1; + else + return m - 1; + } + else + return m; +} diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index eadcc622..979d76dc 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1114,7 +1114,9 @@ user_login(void) /* show welcome_login */ if( (ifbirth = (ptime->tm_mday == cuser.day && ptime->tm_mon + 1 == cuser.month)) ){ - more("etc/Welcome_birth", NA); + char buf[PATHLEN]; + snprintf(buf, sizeof(buf), "etc/Welcome_birth.%d", getHoroscope(cuser.month, cuser.day)); + more(buf, NA); } else { #ifndef MULTI_WELCOME_LOGIN -- cgit v1.2.3