summaryrefslogtreecommitdiffstats
path: root/mbbsd/card.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
commit1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch)
treee6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/card.c
parent10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff)
downloadpttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/card.c')
-rw-r--r--mbbsd/card.c964
1 files changed, 505 insertions, 459 deletions
diff --git a/mbbsd/card.c b/mbbsd/card.c
index e5ac18e7..2b09d9c2 100644
--- a/mbbsd/card.c
+++ b/mbbsd/card.c
@@ -1,255 +1,281 @@
-/* $Id: card.c,v 1.3 2002/06/04 13:08:33 in2 Exp $ */
+/* $Id: card.c,v 1.4 2002/07/05 17:10:27 in2 Exp $ */
#include "bbs.h"
-static int card_remain(int cards[]) {
- int i, temp = 0;
-
- for(i = 0; i < 52; i++)
- temp += cards[i];
- if(temp == 52)
- return 1;
+static int
+card_remain(int cards[])
+{
+ int i, temp = 0;
+
+ for (i = 0; i < 52; i++)
+ temp += cards[i];
+ if (temp == 52)
+ return 1;
return 0;
}
/* 0 Spare , 1 heart , ...3 dimon */
-static int card_flower(int card) {
+static int
+card_flower(int card)
+{
return (card / 13);
}
/* 1...13 */
-static int card_number(int card) {
+static int
+card_number(int card)
+{
return (card % 13 + 1);
}
-static int card_select(int *now) {
- char *cc[2] = {"\033[44m \033[m",
- "\033[1;33;41m ¡µ \033[m"};
-
- while(1) {
- move(20, 0);
- clrtoeol();
- prints("%s%s%s%s%s", (*now == 0) ? cc[1] : cc[0],
- (*now == 1) ? cc[1] : cc[0],
- (*now == 2) ? cc[1] : cc[0],
- (*now == 3) ? cc[1] : cc[0],
- (*now == 4) ? cc[1] : cc[0]);
- switch(egetch()) {
- case 'Q':
- case 'q':
- return 0;
- case '+':
- case ',':
- return 1;
- case '\r':
- return -1;
- case KEY_LEFT:
- *now = (*now + 4) % 5;
- break;
- case KEY_RIGHT:
- *now = (*now + 1) % 5;
- break;
- case '1':
- *now = 0;
- break;
- case '2':
- *now = 1;
- break;
- case '3':
- *now = 2;
- break;
- case '4':
- *now = 3;
- break;
- case '5':
- *now = 4;
- break;
- }
+static int
+card_select(int *now)
+{
+ char *cc[2] = {"\033[44m \033[m",
+ "\033[1;33;41m ¡µ \033[m"};
+
+ while (1) {
+ move(20, 0);
+ clrtoeol();
+ prints("%s%s%s%s%s", (*now == 0) ? cc[1] : cc[0],
+ (*now == 1) ? cc[1] : cc[0],
+ (*now == 2) ? cc[1] : cc[0],
+ (*now == 3) ? cc[1] : cc[0],
+ (*now == 4) ? cc[1] : cc[0]);
+ switch (egetch()) {
+ case 'Q':
+ case 'q':
+ return 0;
+ case '+':
+ case ',':
+ return 1;
+ case '\r':
+ return -1;
+ case KEY_LEFT:
+ *now = (*now + 4) % 5;
+ break;
+ case KEY_RIGHT:
+ *now = (*now + 1) % 5;
+ break;
+ case '1':
+ *now = 0;
+ break;
+ case '2':
+ *now = 1;
+ break;
+ case '3':
+ *now = 2;
+ break;
+ case '4':
+ *now = 3;
+ break;
+ case '5':
+ *now = 4;
+ break;
+ }
}
}
-static void card_display(int cline, int number, int flower, int show) {
- int color = 31;
- char *cn[13] = {"¢Ï", "¢±", "¢²", "¢³", "¢´", "¢µ",
- "¢¶", "¢·", "¢¸", "10", "¢Ø", "¢ß", "¢Ù"};
- if(flower == 0 || flower == 3)
- color = 36;
- if((show < 0) && (cline > 1 && cline < 8))
- prints("¢x\033[1;33;42m¡°¡°¡°¡°\033[m¢x");
+static void
+card_display(int cline, int number, int flower, int show)
+{
+ int color = 31;
+ char *cn[13] = {"¢Ï", "¢±", "¢²", "¢³", "¢´", "¢µ",
+ "¢¶", "¢·", "¢¸", "10", "¢Ø", "¢ß", "¢Ù"};
+ if (flower == 0 || flower == 3)
+ color = 36;
+ if ((show < 0) && (cline > 1 && cline < 8))
+ prints("¢x\033[1;33;42m¡°¡°¡°¡°\033[m¢x");
else
- switch(cline) {
- case 1:
- prints("¢~¢w¢w¢w¢w¢¡");
- break;
- case 2:
- prints("¢x\033[1;%dm%s\033[m ¢x", color, cn[number - 1]);
- break;
- case 3:
- if(flower == 1)
- prints("¢x\033[1;%dm¢¨¢©¢¨¢©\033[m¢x", color);
- else
- prints("¢x\033[1;%dm ¢¨¢© \033[m¢x", color);
- break;
- case 4:
- if(flower == 1)
- prints("¢x\033[1;%dm¢i¢i¢i¢i\033[m¢x", color);
- else if (flower == 3)
- prints("¢x\033[1;%dm¢©¢i¢i¢¨\033[m¢x", color);
- else
- prints("¢x\033[1;%dm¢¨¢i¢i¢©\033[m¢x", color);
- break;
- case 5:
- if(flower == 0)
- prints("¢x\033[1;%dm¢i¢i¢i¢i\033[m¢x", color);
- else if (flower == 3)
- prints("¢x\033[1;%dm¢i¢ª¢«¢i\033[m¢x", color);
- else
- prints("¢x\033[1;%dm¢ª¢i¢i¢«\033[m¢x", color);
- break;
- case 6:
- if(flower == 0)
- prints("¢x\033[1;%dm ¢¨¢© \033[m¢x", color);
- else if (flower == 3)
- prints("¢x\033[1;%dm¢ª¢¨¢©¢«\033[m¢x", color);
- else
- prints("¢x\033[1;%dm ¢ª¢« \033[m¢x", color);
- break;
- case 7:
- prints("¢x \033[1;%dm%s\033[m¢x", color, cn[number - 1]);
- break;
- case 8:
- prints("¢¢¢w¢w¢w¢w¢£");
- break;
- }
+ switch (cline) {
+ case 1:
+ prints("¢~¢w¢w¢w¢w¢¡");
+ break;
+ case 2:
+ prints("¢x\033[1;%dm%s\033[m ¢x", color, cn[number - 1]);
+ break;
+ case 3:
+ if (flower == 1)
+ prints("¢x\033[1;%dm¢¨¢©¢¨¢©\033[m¢x", color);
+ else
+ prints("¢x\033[1;%dm ¢¨¢© \033[m¢x", color);
+ break;
+ case 4:
+ if (flower == 1)
+ prints("¢x\033[1;%dm¢i¢i¢i¢i\033[m¢x", color);
+ else if (flower == 3)
+ prints("¢x\033[1;%dm¢©¢i¢i¢¨\033[m¢x", color);
+ else
+ prints("¢x\033[1;%dm¢¨¢i¢i¢©\033[m¢x", color);
+ break;
+ case 5:
+ if (flower == 0)
+ prints("¢x\033[1;%dm¢i¢i¢i¢i\033[m¢x", color);
+ else if (flower == 3)
+ prints("¢x\033[1;%dm¢i¢ª¢«¢i\033[m¢x", color);
+ else
+ prints("¢x\033[1;%dm¢ª¢i¢i¢«\033[m¢x", color);
+ break;
+ case 6:
+ if (flower == 0)
+ prints("¢x\033[1;%dm ¢¨¢© \033[m¢x", color);
+ else if (flower == 3)
+ prints("¢x\033[1;%dm¢ª¢¨¢©¢«\033[m¢x", color);
+ else
+ prints("¢x\033[1;%dm ¢ª¢« \033[m¢x", color);
+ break;
+ case 7:
+ prints("¢x \033[1;%dm%s\033[m¢x", color, cn[number - 1]);
+ break;
+ case 8:
+ prints("¢¢¢w¢w¢w¢w¢£");
+ break;
+ }
}
-static void card_show(int cpu[], int c[], int me[], int m[]) {
- int i, j;
-
- for(j = 0; j < 8; j++) {
- move(2 + j, 0);
- clrtoeol();
- for(i = 0; i < 5 && cpu[i] >= 0; i++)
- card_display(j + 1, card_number(cpu[i]),
- card_flower(cpu[i]), c[i]);
+static void
+card_show(int cpu[], int c[], int me[], int m[])
+{
+ int i, j;
+
+ for (j = 0; j < 8; j++) {
+ move(2 + j, 0);
+ clrtoeol();
+ for (i = 0; i < 5 && cpu[i] >= 0; i++)
+ card_display(j + 1, card_number(cpu[i]),
+ card_flower(cpu[i]), c[i]);
}
- for(j = 0; j < 8; j++) {
- move(11 + j, 0);
- clrtoeol();
- for(i = 0; i < 5 && me[i] >= 0; i++)
- card_display(j + 1, card_number(me[i]), card_flower(me[i]), m[i]);
+ for (j = 0; j < 8; j++) {
+ move(11 + j, 0);
+ clrtoeol();
+ for (i = 0; i < 5 && me[i] >= 0; i++)
+ card_display(j + 1, card_number(me[i]), card_flower(me[i]), m[i]);
}
}
-static void card_new(int cards[]) {
- memset(cards, 0, sizeof(int)*52);
-}
-
-static int card_give(int cards[]) {
- int i, error;
- for(error=0, i=rand()%52; cards[i] == 1 && error<52; error++, i=rand()%52);
- if(error==52) card_new(cards); // Ptt:³oÃ䦳dead lock°ÝÃD
- cards[i] = 1;
+static void
+card_new(int cards[])
+{
+ memset(cards, 0, sizeof(int) * 52);
+}
+
+static int
+card_give(int cards[])
+{
+ int i, error;
+ for (error = 0, i = rand() % 52; cards[i] == 1 && error < 52; error++, i = rand() % 52);
+ if (error == 52)
+ card_new(cards);
+//Ptt:³o à 䦳dead lock ° ÝÃD
+ cards[i] = 1;
return i;
}
-static void card_start(char name[]) {
+static void
+card_start(char name[])
+{
clear();
stand_title(name);
move(1, 0);
prints(" \033[1;33;41m ¹q ¸£ \033[m");
move(10, 0);
prints("\033[1;34;44m¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã"
- "¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»\033[m");
+ "¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»¡ã¡»\033[m");
move(19, 0);
prints(" \033[1;37;42m ¦Û ¤v \033[m");
}
-static int card_99_add(int i, int aom, int count) {
+static int
+card_99_add(int i, int aom, int count)
+{
if (i == 4 || i == 5 || i == 11)
- return count;
- else if(i == 12)
- return count + 20 * aom;
- else if(i == 10)
- return count + 10 * aom;
- else if(i == 13)
- return 99;
+ return count;
+ else if (i == 12)
+ return count + 20 * aom;
+ else if (i == 10)
+ return count + 10 * aom;
+ else if (i == 13)
+ return 99;
else
- return count + i;
+ return count + i;
}
-static int card_99_cpu(int cpu[], int *count) {
- int stop = -1;
- int twenty = -1;
- int ten = -1;
- int kill = -1;
- int temp, num[10];
- int other = -1;
- int think = 99-(*count);
- int i, j;
-
- for(i = 0; i < 10; i++)
- num[i] = -1;
- for(i = 0; i < 5; i++) {
- temp = card_number(cpu[i]);
- if(temp == 4 || temp == 5 || temp == 11)
- stop = i;
- else if(temp == 12)
- twenty = i;
- else if (temp == 10)
- ten = i;
- else if (temp == 13)
- kill = i;
- else {
- other = i;
- num[temp] = i;
- }
+static int
+card_99_cpu(int cpu[], int *count)
+{
+ int stop = -1;
+ int twenty = -1;
+ int ten = -1;
+ int kill = -1;
+ int temp, num[10];
+ int other = -1;
+ int think = 99 - (*count);
+ int i, j;
+
+ for (i = 0; i < 10; i++)
+ num[i] = -1;
+ for (i = 0; i < 5; i++) {
+ temp = card_number(cpu[i]);
+ if (temp == 4 || temp == 5 || temp == 11)
+ stop = i;
+ else if (temp == 12)
+ twenty = i;
+ else if (temp == 10)
+ ten = i;
+ else if (temp == 13)
+ kill = i;
+ else {
+ other = i;
+ num[temp] = i;
+ }
}
- for(j = 9; j > 0; j--)
- if(num[j] >= 0 && j != 4 && j != 5 && think >= j) {
- (*count) += j;
- return num[j];
- }
- if((think >= 20) && (twenty >= 0)) {
- (*count) += 20;
- return twenty;
- } else if((think >= 10) && (ten >= 0)) {
- (*count) += 10;
- return ten;
- } else if(stop >= 0)
- return stop;
+ for (j = 9; j > 0; j--)
+ if (num[j] >= 0 && j != 4 && j != 5 && think >= j) {
+ (*count) += j;
+ return num[j];
+ }
+ if ((think >= 20) && (twenty >= 0)) {
+ (*count) += 20;
+ return twenty;
+ } else if ((think >= 10) && (ten >= 0)) {
+ (*count) += 10;
+ return ten;
+ } else if (stop >= 0)
+ return stop;
else if (kill >= 0) {
- (*count) = 99;
- return kill;
- } else if(ten >= 0) {
- (*count) -= 10;
- return ten;
- } else if(twenty >= 0) {
- (*count) -= 20;
- return twenty;
+ (*count) = 99;
+ return kill;
+ } else if (ten >= 0) {
+ (*count) -= 10;
+ return ten;
+ } else if (twenty >= 0) {
+ (*count) -= 20;
+ return twenty;
} else {
- (*count) += card_number(cpu[0]);
- return 0;
+ (*count) += card_number(cpu[0]);
+ return 0;
}
}
-int card_99() {
- int i, j, turn;
- int cpu[5], c[5], me[5], m[5];
- int cards[52];
- int count = 0;
- char *ff[4] = {"\033[1;36m¶Â®ç", "\033[1;31m¬õ¤ß",
- "\033[1;31m¤è¶ô", "\033[1;36m¶Âªá"};
- char *cn[13] = {"¢Ï", "¢±", "¢²", "¢³", "¢´", "¢µ",
- "¢¶", "¢·", "¢¸", "10", "¢Ø", "¢ß", "¢Ù"};
- for(i = 0; i < 5; i++)
- cpu[i] = c[i] = me[i] = m[i] = -1;
+int
+card_99()
+{
+ int i, j, turn;
+ int cpu[5], c[5], me[5], m[5];
+ int cards[52];
+ int count = 0;
+ char *ff[4] = {"\033[1;36m¶Â®ç", "\033[1;31m¬õ¤ß",
+ "\033[1;31m¤è¶ô", "\033[1;36m¶Âªá"};
+ char *cn[13] = {"¢Ï", "¢±", "¢²", "¢³", "¢´", "¢µ",
+ "¢¶", "¢·", "¢¸", "10", "¢Ø", "¢ß", "¢Ù"};
+ for (i = 0; i < 5; i++)
+ cpu[i] = c[i] = me[i] = m[i] = -1;
setutmpmode(CARD_99);
card_start("¤Ñªø¦a¤[");
card_new(cards);
- for(i = 0; i < 5; i++) {
- cpu[i] = card_give(cards);
- me[i] = card_give(cards);
- m[i] = 1;
+ for (i = 0; i < 5; i++) {
+ cpu[i] = card_give(cards);
+ me[i] = card_give(cards);
+ m[i] = 1;
}
card_show(cpu, c, me, m);
j = 0;
@@ -258,232 +284,244 @@ int card_99() {
clrtoeol();
prints("[0]¥Ø«e %d , ´Ý %d ÂI\n", count, 99 - count);
prints("¥ª¥kÁä²¾°Ê´å¼Ð, [Enter]½T©w, [ + ]ªí¥[¤G¤Q(¥[¤Q), [Q/q]©ñ±ó¹CÀ¸");
- while(1) {
- i = card_select(&j);
- if(i == 0) /*©ñ±ó¹CÀ¸*/
- return 0;
- count = card_99_add(card_number(me[j]), i, count);
- move(21 + (turn / 2) % 2, 0);
- clrtoeol();
- prints("[%d]±z¥X %s%s\033[m ¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
- turn, ff[card_flower(me[j])],
- cn[card_number(me[j]) - 1], count, 99 - count);
- me[j] = card_give(cards);
- turn++;
- if(count < 0)
- count = 0;
- card_show(cpu, c, me, m);
- pressanykey();
- if(count > 99) {
- move(22, 0);
- clrtoeol();
- prints("[%d]µ²ªG..YOU LOSS..¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
- turn, count, 99 - count);
- pressanykey();
- return 0;
- }
- i = card_99_cpu(cpu, &count);
- move(21 + (turn / 2 + 1) % 2, 40);
- prints("[%d]¹q¸£¥X %s%s\033[m ¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
- turn, ff[card_flower(cpu[i])],
- cn[card_number(cpu[i]) - 1], count, 99 - count);
- cpu[i] = card_give(cards);
- turn++;
- if(count < 0)
- count = 0;
- if(count > 99) {
- move(22, 0);
- clrtoeol();
- prints("[%d]µ²ªG..YOU WIN!..¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
- turn, count, 99 - count);
- pressanykey();
- return 0;
- }
- if(!card_remain(cards)) {
- card_new(cards);
- for(i = 0; i < 5; i++) {
- cards[me[i]] = 1;
- cards[cpu[i]] = 1;
- }
- }
+ while (1) {
+ i = card_select(&j);
+ if (i == 0) /* ©ñ±ó¹CÀ¸ */
+ return 0;
+ count = card_99_add(card_number(me[j]), i, count);
+ move(21 + (turn / 2) % 2, 0);
+ clrtoeol();
+ prints("[%d]±z¥X %s%s\033[m ¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
+ turn, ff[card_flower(me[j])],
+ cn[card_number(me[j]) - 1], count, 99 - count);
+ me[j] = card_give(cards);
+ turn++;
+ if (count < 0)
+ count = 0;
+ card_show(cpu, c, me, m);
+ pressanykey();
+ if (count > 99) {
+ move(22, 0);
+ clrtoeol();
+ prints("[%d]µ²ªG..YOU LOSS..¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
+ turn, count, 99 - count);
+ pressanykey();
+ return 0;
+ }
+ i = card_99_cpu(cpu, &count);
+ move(21 + (turn / 2 + 1) % 2, 40);
+ prints("[%d]¹q¸£¥X %s%s\033[m ¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
+ turn, ff[card_flower(cpu[i])],
+ cn[card_number(cpu[i]) - 1], count, 99 - count);
+ cpu[i] = card_give(cards);
+ turn++;
+ if (count < 0)
+ count = 0;
+ if (count > 99) {
+ move(22, 0);
+ clrtoeol();
+ prints("[%d]µ²ªG..YOU WIN!..¥Ø«e \033[1;31m%d/\033[34m%d\033[m ÂI",
+ turn, count, 99 - count);
+ pressanykey();
+ return 0;
+ }
+ if (!card_remain(cards)) {
+ card_new(cards);
+ for (i = 0; i < 5; i++) {
+ cards[me[i]] = 1;
+ cards[cpu[i]] = 1;
+ }
+ }
}
}
#define PMONEY (10)
-#define TEN_HALF (5) /*¤QÂI¥bªºTicket*/
-#define JACK (10) /*¶Â³Ç§JªºTicket*/
-#define NINE99 (99) /*99 ªºTicket*/
+#define TEN_HALF (5) /* ¤QÂI¥bªºTicket */
+#define JACK (10) /* ¶Â³Ç§JªºTicket */
+#define NINE99 (99) /* 99 ªºTicket */
-static int game_log(int type, int money) {
- FILE *fp;
+static int
+game_log(int type, int money)
+{
+ FILE *fp;
- if(money > 0)
+ if (money > 0)
demoney(money);
- switch(type) {
+ switch (type) {
case JACK:
- fp = fopen(BBSHOME "/etc/card/jack.log", "a");
- if(!fp)
- return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
- fclose(fp);
- break;
+ fp = fopen(BBSHOME "/etc/card/jack.log", "a");
+ if (!fp)
+ return 0;
+ fprintf(fp, "%s win:%d\n", cuser.userid, money);
+ fclose(fp);
+ break;
case TEN_HALF:
- fp = fopen(BBSHOME "/etc/card/tenhalf.log", "a");
- if(!fp)
- return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
- fclose(fp);
- break;
+ fp = fopen(BBSHOME "/etc/card/tenhalf.log", "a");
+ if (!fp)
+ return 0;
+ fprintf(fp, "%s win:%d\n", cuser.userid, money);
+ fclose(fp);
+ break;
}
return 0;
}
-static int card_double_ask() {
- char buf[100], buf2[3];
+static int
+card_double_ask()
+{
+ char buf[100], buf2[3];
sprintf(buf, "[ %s ]±z²{¦b¦@¦³ %d P¹ô, ²{¦b­n¤À²Õ(¥[¦¬ %d ¤¸)¶Ü? [y/N]",
- cuser.userid, cuser.money, JACK);
+ cuser.userid, cuser.money, JACK);
reload_money();
- if(cuser.money < JACK)
- return 0;
+ if (cuser.money < JACK)
+ return 0;
getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO);
- if(buf2[0] == 'y' || buf2[0] == 'Y')
- return 1;
+ if (buf2[0] == 'y' || buf2[0] == 'Y')
+ return 1;
return 0;
}
-static int card_ask() {
- char buf[100], buf2[3];
+static int
+card_ask()
+{
+ char buf[100], buf2[3];
sprintf(buf, "[ %s ]±z²{¦b¦@¦³ %d P¹ô, ÁÙ­n¥[µP¶Ü? [y/N]",
- cuser.userid, cuser.money);
- getdata(20, 0 , buf, buf2, sizeof(buf2), LCECHO);
- if(buf2[0] == 'y' || buf2[0] == 'Y')
- return 1;
+ cuser.userid, cuser.money);
+ getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO);
+ if (buf2[0] == 'y' || buf2[0] == 'Y')
+ return 1;
return 0;
}
-static int card_alls_lower(int all[]) {
- int i, count = 0;
+static int
+card_alls_lower(int all[])
+{
+ int i, count = 0;
for (i = 0; i < 5 && all[i] >= 0; i++)
- if(card_number(all[i]) <= 10)
- count += card_number(all[i]);
- else
- count += 10;
+ if (card_number(all[i]) <= 10)
+ count += card_number(all[i]);
+ else
+ count += 10;
return count;
}
-static int card_alls_upper(int all[]) {
- int i, count;
+static int
+card_alls_upper(int all[])
+{
+ int i, count;
count = card_alls_lower(all);
for (i = 0; i < 5 && all[i] >= 0 && count <= 11; i++)
- if (card_number(all[i]) == 1)
- count += 10;
+ if (card_number(all[i]) == 1)
+ count += 10;
return count;
}
-static int card_jack(int *db) {
- int i, j;
- int cpu[5], c[5], me[5], m[5];
- int cards[52];
-
- for(i = 0;i<5;i++)
- cpu[i] = c[i] = me[i] = m[i] = -1;
-
- if((*db)<0) {
- card_new(cards);
- card_start("¶Â³Ç§J");
- for(i = 0; i < 2; i++) {
- cpu[i] = card_give(cards);
- me[i] = card_give(cards);
- }
+static int
+card_jack(int *db)
+{
+ int i, j;
+ int cpu[5], c[5], me[5], m[5];
+ int cards[52];
+
+ for (i = 0; i < 5; i++)
+ cpu[i] = c[i] = me[i] = m[i] = -1;
+
+ if ((*db) < 0) {
+ card_new(cards);
+ card_start("¶Â³Ç§J");
+ for (i = 0; i < 2; i++) {
+ cpu[i] = card_give(cards);
+ me[i] = card_give(cards);
+ }
} else {
- card_start("¶Â³Ç§JDOUBLE°l¥[§½");
- cpu[0] = card_give(cards);
- cpu[1] = card_give(cards);
- me[0] = *db;
- me[1] = card_give(cards);
+ card_start("¶Â³Ç§JDOUBLE°l¥[§½");
+ cpu[0] = card_give(cards);
+ cpu[1] = card_give(cards);
+ me[0] = *db;
+ me[1] = card_give(cards);
}
c[1] = m[0] = m[1] = 1;
card_show(cpu, c, me, m);
- if((card_number(me[0]) == 0 && card_number(me[1]) == 12) ||
- (card_number(me[1]) == 0 && card_number(me[0]) == 12)) {
- if(card_flower(me[0]) == 0 && card_flower(me[1]) == 0) {
- move(b_lines - 1, 0);
- prints("«D±`¤£¿ù­ò! (¶W¯Å¶Â³Ç§J!! ¥[ %d ¤¸)", JACK * 10);
- game_log(JACK, JACK * 10);
- pressanykey();
- return 0;
- } else {
- move(b_lines - 1, 0);
- prints("«Ü¤£¿ù­ò! (¶Â³Ç§J!! ¥[ %d ¤¸)", JACK * 5);
- game_log(JACK, JACK * 5);
- pressanykey();
- return 0;
- }
+ if ((card_number(me[0]) == 0 && card_number(me[1]) == 12) ||
+ (card_number(me[1]) == 0 && card_number(me[0]) == 12)) {
+ if (card_flower(me[0]) == 0 && card_flower(me[1]) == 0) {
+ move(b_lines - 1, 0);
+ prints("«D±`¤£¿ù­ò! (¶W¯Å¶Â³Ç§J!! ¥[ %d ¤¸)", JACK * 10);
+ game_log(JACK, JACK * 10);
+ pressanykey();
+ return 0;
+ } else {
+ move(b_lines - 1, 0);
+ prints("«Ü¤£¿ù­ò! (¶Â³Ç§J!! ¥[ %d ¤¸)", JACK * 5);
+ game_log(JACK, JACK * 5);
+ pressanykey();
+ return 0;
+ }
}
- if((card_number(cpu[0]) == 0 && card_number(cpu[1]) == 12) ||
- (card_number(cpu[1]) == 0 && card_number(cpu[0]) == 12)) {
- c[0] = 1;
- card_show(cpu, c, me, m);
- move(b_lines - 1, 0);
- prints("¼K¼K...¤£¦n·N«ä....¶Â³Ç§J!!");
- game_log(JACK, 0);
- pressanykey();
- return 0;
+ if ((card_number(cpu[0]) == 0 && card_number(cpu[1]) == 12) ||
+ (card_number(cpu[1]) == 0 && card_number(cpu[0]) == 12)) {
+ c[0] = 1;
+ card_show(cpu, c, me, m);
+ move(b_lines - 1, 0);
+ prints("¼K¼K...¤£¦n·N«ä....¶Â³Ç§J!!");
+ game_log(JACK, 0);
+ pressanykey();
+ return 0;
}
- if((*db < 0)&& (card_number(me[0]) == card_number(me[1])) &&
- (card_double_ask())) {
- *db = me[1];
- me[1] = card_give(cards);
- card_show(cpu, c, me, m);
+ if ((*db < 0) && (card_number(me[0]) == card_number(me[1])) &&
+ (card_double_ask())) {
+ *db = me[1];
+ me[1] = card_give(cards);
+ card_show(cpu, c, me, m);
}
i = 2;
- while(i < 5 && card_ask()) {
- me[i] = card_give(cards);
- m[i] = 1;
- card_show(cpu, c, me, m);
- if(card_alls_lower(me) > 21) {
- move(b_lines - 1, 0);
- prints("¶ã¶ã...Ãz±¼¤F!");
- game_log(JACK, 0);
- pressanykey();
- return 0;
- }
- i++;
- if((i == 3) && (card_number(me[0]) == 7) &&
- (card_number(me[1]) == 7) && (card_number(me[2]) == 7)) {
- move(b_lines - 1, 0);
- prints("«Ü¤£¿ù­ò! (©¯¹B¤C¸¹!! ¥[ %d ¤¸)", JACK * 7);
- game_log(JACK, JACK * 7);
- pressanykey();
- return 0;
- }
+ while (i < 5 && card_ask()) {
+ me[i] = card_give(cards);
+ m[i] = 1;
+ card_show(cpu, c, me, m);
+ if (card_alls_lower(me) > 21) {
+ move(b_lines - 1, 0);
+ prints("¶ã¶ã...Ãz±¼¤F!");
+ game_log(JACK, 0);
+ pressanykey();
+ return 0;
+ }
+ i++;
+ if ((i == 3) && (card_number(me[0]) == 7) &&
+ (card_number(me[1]) == 7) && (card_number(me[2]) == 7)) {
+ move(b_lines - 1, 0);
+ prints("«Ü¤£¿ù­ò! (©¯¹B¤C¸¹!! ¥[ %d ¤¸)", JACK * 7);
+ game_log(JACK, JACK * 7);
+ pressanykey();
+ return 0;
+ }
}
- if(i == 5) {/*¹L¤­Ãö*/
- move(b_lines - 1, 0);
- prints("¦n¼F®`­ò! ¹L¤­Ãö¹Æ! ¥[P¹ô %d ¤¸!", 5 * JACK);
- game_log(JACK, JACK * 5);
- pressanykey();
- return 0;
+ if (i == 5) { /* ¹L¤­Ãö */
+ move(b_lines - 1, 0);
+ prints("¦n¼F®`­ò! ¹L¤­Ãö¹Æ! ¥[P¹ô %d ¤¸!", 5 * JACK);
+ game_log(JACK, JACK * 5);
+ pressanykey();
+ return 0;
}
j = 2;
c[0] = 1;
- while((card_alls_upper(cpu) < card_alls_upper(me))||
- ((card_alls_upper(cpu) == card_alls_upper(me) && j < i ) && j < 5)) {
- cpu[j] = card_give(cards);
- c[j] = 1;
- if(card_alls_lower(cpu) > 21) {
- card_show(cpu, c, me, m);
- move(b_lines - 1, 0);
- prints("¨þ¨þ...¹q¸£Ãz±¼¤F! §AŤF! ¥i±oP¹ô %d ¤¸", JACK * 2);
- game_log(JACK, JACK * 2);
- pressanykey();
- return 0;
- }
- j++;
+ while ((card_alls_upper(cpu) < card_alls_upper(me)) ||
+ ((card_alls_upper(cpu) == card_alls_upper(me) && j < i) && j < 5)) {
+ cpu[j] = card_give(cards);
+ c[j] = 1;
+ if (card_alls_lower(cpu) > 21) {
+ card_show(cpu, c, me, m);
+ move(b_lines - 1, 0);
+ prints("¨þ¨þ...¹q¸£Ãz±¼¤F! §AŤF! ¥i±oP¹ô %d ¤¸", JACK * 2);
+ game_log(JACK, JACK * 2);
+ pressanykey();
+ return 0;
+ }
+ j++;
}
card_show(cpu, c, me, m);
move(b_lines - 1, 0);
@@ -493,93 +531,99 @@ static int card_jack(int *db) {
return 0;
}
-int g_card_jack() {
- int db;
- char buf[3];
+int
+g_card_jack()
+{
+ int db;
+ char buf[3];
setutmpmode(JACK_CARD);
- while(1) {
- reload_money();
- if(cuser.money < JACK) {
- outs("±zªº¿ú¤£°÷­ò!¥h¦hµoªí¨Ç¦³·N¸qªº¤å³¹¦A¨Ó~~~");
- return 0;
- }
- getdata(b_lines - 1, 0, "½T©w­nª±¶Â³Ç§J¶Ü ¤@¦¸¤Q¤¸­ò?(Y/N)?[N]",
- buf, 3, LCECHO);
- if((*buf != 'y') && (*buf != 'Y'))
- break;
- else {
- db = -1;
+ while (1) {
+ reload_money();
+ if (cuser.money < JACK) {
+ outs("±zªº¿ú¤£°÷­ò!¥h¦hµoªí¨Ç¦³·N¸qªº¤å³¹¦A¨Ó~~~");
+ return 0;
+ }
+ getdata(b_lines - 1, 0, "½T©w­nª±¶Â³Ç§J¶Ü ¤@¦¸¤Q¤¸­ò?(Y/N)?[N]",
+ buf, 3, LCECHO);
+ if ((*buf != 'y') && (*buf != 'Y'))
+ break;
+ else {
+ db = -1;
vice(PMONEY, "¶Â³Ç§J");
- card_jack(&db);
- if(db >= 0)
- card_jack(&db);
- }
+ card_jack(&db);
+ if (db >= 0)
+ card_jack(&db);
+ }
}
return 0;
}
-static int card_all(int all[]) {
- int i, count = 0;
+static int
+card_all(int all[])
+{
+ int i, count = 0;
for (i = 0; i < 5 && all[i] >= 0; i++)
- if(card_number(all[i]) <= 10)
- count += 2 * card_number(all[i]);
- else
- count += 1;
+ if (card_number(all[i]) <= 10)
+ count += 2 * card_number(all[i]);
+ else
+ count += 1;
return count;
}
-static int ten_helf() {
- int i, j;
- int cpu[5], c[5], me[5], m[5];
- int cards[52];
+static int
+ten_helf()
+{
+ int i, j;
+ int cpu[5], c[5], me[5], m[5];
+ int cards[52];
card_start("¤QÂI¥b");
card_new(cards);
for (i = 0; i < 5; i++)
- cpu[i] = c[i] = me[i] = m[i] = -1;
+ cpu[i] = c[i] = me[i] = m[i] = -1;
cpu[0] = card_give(cards);
me[0] = card_give(cards);
m[0] = 1;
card_show(cpu, c, me, m);
i = 1;
- while(i < 5 && card_ask()) {
- me[i] = card_give(cards);
- m[i] = 1;
- card_show(cpu, c, me, m);
- if(card_all(me) > 21) {
- move(b_lines - 1, 0);
- prints("¶ã¶ã...Ãz±¼¤F!");
- game_log(TEN_HALF, 0);
- pressanykey();
- return 0;
- }
- i++;
+ while (i < 5 && card_ask()) {
+ me[i] = card_give(cards);
+ m[i] = 1;
+ card_show(cpu, c, me, m);
+ if (card_all(me) > 21) {
+ move(b_lines - 1, 0);
+ prints("¶ã¶ã...Ãz±¼¤F!");
+ game_log(TEN_HALF, 0);
+ pressanykey();
+ return 0;
+ }
+ i++;
}
- if(i == 5) {/*¹L¤­Ãö*/
- move(b_lines - 1, 0);
- prints("¦n¼F®`­ò! ¹L¤­Ãö¹Æ! ¥[P¹ô %d ¤¸!", 5 * PMONEY);
- game_log(TEN_HALF, PMONEY * 5);
- pressanykey();
- return 0;
+ if (i == 5) { /* ¹L¤­Ãö */
+ move(b_lines - 1, 0);
+ prints("¦n¼F®`­ò! ¹L¤­Ãö¹Æ! ¥[P¹ô %d ¤¸!", 5 * PMONEY);
+ game_log(TEN_HALF, PMONEY * 5);
+ pressanykey();
+ return 0;
}
j = 1;
c[0] = 1;
- while( j<5 && ((card_all(cpu) < card_all(me)) ||
- (card_all(cpu) == card_all(me) && j < i))) {
- cpu[j] = card_give(cards);
- c[j] = 1;
- if(card_all(cpu) > 21) {
- card_show(cpu, c, me, m);
- move(b_lines - 1, 0);
- prints("¨þ¨þ...¹q¸£Ãz±¼¤F! §AŤF! ¥i±oP¹ô %d ¤¸", PMONEY * 2);
- game_log(TEN_HALF, PMONEY * 2);
- pressanykey();
- return 0;
- }
- j++;
+ while (j < 5 && ((card_all(cpu) < card_all(me)) ||
+ (card_all(cpu) == card_all(me) && j < i))) {
+ cpu[j] = card_give(cards);
+ c[j] = 1;
+ if (card_all(cpu) > 21) {
+ card_show(cpu, c, me, m);
+ move(b_lines - 1, 0);
+ prints("¨þ¨þ...¹q¸£Ãz±¼¤F! §AŤF! ¥i±oP¹ô %d ¤¸", PMONEY * 2);
+ game_log(TEN_HALF, PMONEY * 2);
+ pressanykey();
+ return 0;
+ }
+ j++;
}
card_show(cpu, c, me, m);
move(b_lines - 1, 0);
@@ -589,25 +633,27 @@ static int ten_helf() {
return 0;
}
-int g_ten_helf() {
- char buf[3];
+int
+g_ten_helf()
+{
+ char buf[3];
setutmpmode(TENHALF);
- while(1) {
- reload_money();
- if(cuser.money < TEN_HALF) {
- outs("±zªº¿ú¤£°÷­ò!¥h¦hµoªí¨Ç¦³·N¸qªº¤å³¹¦A¨Ó~~~");
- return 0;
- }
- getdata(b_lines - 1, 0,
- "\033[1;37m½T©w­nª±¤QÂI¥b¶Ü ¤@¦¸¤Q¤¸­ò?(Y/N)?[N]\033[m",
- buf, 3, LCECHO);
- if(buf[0] != 'y' && buf[0] != 'Y')
- return 0;
- else {
- vice(PMONEY, "¤QÂI¥b");
- ten_helf();
- }
+ while (1) {
+ reload_money();
+ if (cuser.money < TEN_HALF) {
+ outs("±zªº¿ú¤£°÷­ò!¥h¦hµoªí¨Ç¦³·N¸qªº¤å³¹¦A¨Ó~~~");
+ return 0;
+ }
+ getdata(b_lines - 1, 0,
+ "\033[1;37m½T©w­nª±¤QÂI¥b¶Ü ¤@¦¸¤Q¤¸­ò?(Y/N)?[N]\033[m",
+ buf, 3, LCECHO);
+ if (buf[0] != 'y' && buf[0] != 'Y')
+ return 0;
+ else {
+ vice(PMONEY, "¤QÂI¥b");
+ ten_helf();
+ }
}
return 0;
}