summaryrefslogtreecommitdiffstats
path: root/mbbsd/cal.c
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-12 12:19:57 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-12 12:19:57 +0800
commit2ec4b4b319a3403bfb9c38998ff1111b42f716f0 (patch)
tree6bf076c034d69e549f92a164732de59f1e46d8e2 /mbbsd/cal.c
parentc78306e4c3f9d42acd182362bbbb5e13a06b840b (diff)
downloadpttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.tar
pttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.tar.gz
pttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.tar.bz2
pttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.tar.lz
pttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.tar.xz
pttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.tar.zst
pttbbs-2ec4b4b319a3403bfb9c38998ff1111b42f716f0.zip
integrate two giving-money code
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3028 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/cal.c')
-rw-r--r--mbbsd/cal.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index 0c5c61ca..9ce5de3f 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -395,27 +395,19 @@ give_tax(int money)
return (tax <= 0) ? 1 : tax;
}
-int
-p_give(void)
+int do_give_money(char *id, int uid, int money)
{
- int money, tax;
- char id[IDLEN + 1], money_buf[20];
+ int tax;
#ifdef PLAY_ANGEL
userec_t xuser;
#endif
- move(1, 0);
- usercomplete("這位幸運兒的id:", id);
- if (!id[0] || !strcmp(cuser.userid, id) ||
- !getdata(2, 0, "要給多少錢:", money_buf, 7, LCECHO))
- return 0;
- money = atoi(money_buf);
reload_money();
if (money > 0 && cuser.money >= money) {
tax = give_tax(money);
if (money - tax <= 0)
- return 0; /* 繳完稅就沒錢給了 */
- deumoney(searchuser(id, id), money - tax); // TODO if searchuser(id) return 0
+ return -1; /* 繳完稅就沒錢給了 */
+ deumoney(uid, money - tax);
demoney(-money);
log_file(FN_MONEY, LOG_CREAT | LOG_VF, "%-12s 給 %-12s %d\t(稅後 %d)\t%s",
cuser.userid, id, money, money - tax, ctime4(&now));
@@ -430,8 +422,29 @@ p_give(void)
#endif
mail_redenvelop(cuser.userid, id, money - tax,
getans("要自行書寫紅包袋嗎?[y/N]"));
+ return 0;
}
- return 0;
+ return -1;
+}
+
+int
+p_give(void)
+{
+ int uid;
+ char id[IDLEN + 1], money_buf[20];
+
+ move(1, 0);
+ usercomplete("這位幸運兒的id:", id);
+ if (!id[0] || !strcmp(cuser.userid, id) ||
+ !getdata(2, 0, "要給多少錢:", money_buf, 7, LCECHO)) {
+ vmsg("交易取消!");
+ return -1;
+ }
+ if ((uid = searchuser(id, id)) == 0) {
+ vmsg("查無此人!");
+ return -1;
+ }
+ return do_give_money(id, uid, atoi(money_buf));
}
int