summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-05-30 23:49:21 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-05-30 23:49:21 +0800
commit869d9c65fb1d6d14c30b8ffccc7006281be60188 (patch)
treeec9f714339d418e4991dcb8a4ae5fd58135be035
parent175c824f5c45e15ca8c9b8e277ff01ec721610d3 (diff)
downloadpttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.tar
pttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.tar.gz
pttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.tar.bz2
pttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.tar.lz
pttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.tar.xz
pttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.tar.zst
pttbbs-869d9c65fb1d6d14c30b8ffccc7006281be60188.zip
- prevent sharing buy_ticket for chicken and gamble
- prompt user gamble type choice git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4330 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/chicken.c6
-rw-r--r--pttbbs/mbbsd/gamble.c34
2 files changed, 36 insertions, 4 deletions
diff --git a/pttbbs/mbbsd/chicken.c b/pttbbs/mbbsd/chicken.c
index 7feb83f3..bacddcf9 100644
--- a/pttbbs/mbbsd/chicken.c
+++ b/pttbbs/mbbsd/chicken.c
@@ -453,14 +453,14 @@ ch_hit(chicken_t *mychicken)
pressanykey();
}
-void
+static void
ch_buyitem(int money, const char *picture, int *item, int haveticket)
{
int num = 0;
char buf[5];
getdata_str(b_lines - 1, 0, "要買多少份呢:",
- buf, sizeof(buf), DOECHO, "1");
+ buf, sizeof(buf), NUMECHO, "1");
num = atoi(buf);
if (num < 1)
return;
@@ -468,7 +468,7 @@ ch_buyitem(int money, const char *picture, int *item, int haveticket)
if (cuser.money/money >= num) {
*item += num;
if( haveticket )
- vice(money * num, "購買寵物,賭盤項目");
+ vice(money * num, "購買寵物");
else
demoney(-money * num);
show_chicken_picture(picture);
diff --git a/pttbbs/mbbsd/gamble.c b/pttbbs/mbbsd/gamble.c
index 4738b005..81310988 100644
--- a/pttbbs/mbbsd/gamble.c
+++ b/pttbbs/mbbsd/gamble.c
@@ -137,6 +137,36 @@ append_ticket_record(const char *direct, int ch, int n, int count)
return 0;
}
+void
+buy_ticket_ui(int money, const char *picture, int *item, int haveticket)
+{
+ int num = 0;
+ char buf[5];
+
+ // XXX defaults to 1?
+ getdata_str(b_lines - 1, 0, "要買多少份呢:",
+ buf, sizeof(buf), NUMECHO, "1");
+ num = atoi(buf);
+ if (num < 1)
+ return;
+
+ reload_money();
+ if (cuser.money/money <= num) {
+ vmsg("現金不夠 !!!");
+ return;
+ }
+
+ *item += num;
+ if( haveticket )
+ vice(money * num, "賭盤項目");
+ else
+ demoney(-money * num);
+ // XXX magic numbers 5, 14...
+ show_file(picture, 5, 14, SHOWFILE_ALLOW_ALL);
+ pressanykey();
+ usleep(100000); // sleep 0.1s
+}
+
#define lockreturn0(unmode, state) if(lockutmpmode(unmode, state)) return 0
int
ticket(int bid)
@@ -177,11 +207,13 @@ ticket(int bid)
--*/
if (ch == 'q' || ch == 'Q')
break;
+ outc(ch);
ch -= '1';
if (end || ch >= count || ch < 0)
continue;
n = 0;
- ch_buyitem(price, "etc/buyticket", &n, 0);
+
+ buy_ticket_ui(price, "etc/buyticket", &n, 0);
if (bid && !dashf(fn_ticket))
goto doesnt_catch_up;