diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-27 01:26:28 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-27 01:26:28 +0800 |
commit | b27ece46a69aa7d5b9a759a2164609dab689f258 (patch) | |
tree | ad7387b6b59ecfc3215deec393d1c932db8d09af /common/bbs | |
parent | 1ac9e4897fdf8839328d9c47d1d2f0cc27b02f1d (diff) | |
download | pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.gz pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.bz2 pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.lz pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.xz pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.zst pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.zip |
(internal) refine directory layout: libbbs/libbbsutil -> common/bbs,sys.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4027 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'common/bbs')
-rw-r--r-- | common/bbs/Makefile | 24 | ||||
-rw-r--r-- | common/bbs/log.c | 0 | ||||
-rw-r--r-- | common/bbs/money.c | 36 | ||||
-rw-r--r-- | common/bbs/string.c | 1 |
4 files changed, 61 insertions, 0 deletions
diff --git a/common/bbs/Makefile b/common/bbs/Makefile new file mode 100644 index 00000000..6ed3e554 --- /dev/null +++ b/common/bbs/Makefile @@ -0,0 +1,24 @@ + +SRCROOT= ../.. +.include "$(SRCROOT)/pttbbs.mk" + +CFLAGS+= -I$(SRCROOT)/include + +OBJS= log.o string.o money.o +TARGET= libcmbbs.a + + +.SUFFIXES: .c .o +.c.o: + $(CCACHE) $(DIETCC) $(CC) $(CFLAGS) -c $*.c + +all: $(TARGET) + +install: + +$(TARGET): $(OBJS) + $(AR) cru $@ $(OBJS) + ranlib $@ + +clean: + rm -f $(OBJS) $(TARGET) diff --git a/common/bbs/log.c b/common/bbs/log.c new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/common/bbs/log.c diff --git a/common/bbs/money.c b/common/bbs/money.c new file mode 100644 index 00000000..f2c7b9b3 --- /dev/null +++ b/common/bbs/money.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include "cmbbs.h" + +/* 計算贈與稅 */ +int +give_tax(int money) +{ + int i, tax = 0; + int tax_bound[] = {1000000, 100000, 10000, 1000, 0}; + double tax_rate[] = {0.4, 0.3, 0.2, 0.1, 0.08}; + for (i = 0; i <= 4; i++) + if (money > tax_bound[i]) { + tax += (money - tax_bound[i]) * tax_rate[i]; + money -= (money - tax_bound[i]); + } + return (tax <= 0) ? 1 : tax; +} + +const char* +money_level(int money) +{ + int i = 0; + + static const char *money_msg[] = + { + "債台高築", "赤貧", "清寒", "普通", "小康", + "小富", "中富", "大富翁", "富可敵國", "比爾蓋\天", NULL + }; + while (money_msg[i] && money > 10) + i++, money /= 10; + + if(!money_msg[i]) + i--; + return money_msg[i]; +} + diff --git a/common/bbs/string.c b/common/bbs/string.c new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/common/bbs/string.c @@ -0,0 +1 @@ + |