-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwar.txt
More file actions
91 lines (82 loc) · 3.01 KB
/
war.txt
File metadata and controls
91 lines (82 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"The Art of War."
This is a silly card game for CircleMUD.
In interpreter.c, add the following entry to the master command list...
{ "gamble" , POS_STANDING, do_not_here , 0, 0 },
Next, plug the following function in spec_procs.c...
SPECIAL(play_war)
{
int wager;
int player_card;
int dealer_card;
char buf[128];
static char *cards[] =
{"One", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine", "Ten", "Prince", "Knight", "Wizard"};
static char *suits[] =
{"Wands", "Daggers", "Wings", "Fire"};
if (!CMD_IS("gamble"))
return 0;
one_argument(argument, arg); /* Get the arg (amount to wager.) */
if (!*arg) {
send_to_char("How much?\r\n", ch);
return 1;
} else wager = atoi(arg) ;
if(wager <= 0){
send_to_char("Very funny, dick-head.\r\n", ch);
return 1;
} else if (wager > GET_GOLD(ch)){
send_to_char("You don't have that much gold to wager.\r\n", ch);
return 1;
} else {
/* Okay - gamble away! */
player_card=number(0, 12);
dealer_card=number(0, 12);
sprintf(buf, "You are dealt a %s of %s.\r\n"
"The dealer turns up a %s of %s.\r\n",
cards[player_card], suits[number(0, 3)],
cards[dealer_card], suits[number(0, 3)]);
send_to_char(buf, ch);
if(player_card > dealer_card){
/* You win! */
sprintf(buf, "You win! The dealer hands you %d gold coins.\r\n", wager);
act("$n makes a wager and wins!", FALSE, ch, 0, 0, TO_ROOM);
send_to_char(buf, ch);
GET_GOLD(ch) += wager;
} else if (dealer_card > player_card) {
/* You lose */
sprintf(buf, "You lose your wager of %d coins.\r\n"
"The dealer takes your gold.\r\n", wager);
act("$n makes a wager and loses.", FALSE, ch, 0, 0, TO_ROOM);
send_to_char(buf, ch);
GET_GOLD(ch) -= wager;
} else {
/* WAR! */
while (player_card==dealer_card) {
send_to_char("/cRWar!/c0\r\n", ch);
player_card=number(0, 12);
dealer_card=number(0, 12);
sprintf(buf, "You are dealt a %s of %s.\r\n"
"The dealer turns of a %s of %s.\r\n",
cards[player_card], suits[number(0, 3)],
cards[dealer_card], suits[number(0, 3)]);
send_to_char(buf, ch);
}
if(player_card > dealer_card){
/* You win! */
sprintf(buf, "You win! The dealer hands you %d gold "
"coins.\r\n", wager);
act("$n makes a wager and wins!", FALSE, ch, 0, 0, TO_ROOM);
send_to_char(buf, ch);
GET_GOLD(ch) += wager;
} else if (dealer_card > player_card) {
/* You lose */
sprintf(buf, "You lose your wager of %d coins.\r\n"
"The dealer takes your gold.\r\n", wager);
act("$n makes a wager and loses.", FALSE, ch, 0, 0, TO_ROOM);
send_to_char(buf, ch);
GET_GOLD(ch) -= wager;
}
}
return 1;
}
}