xref: /csrg-svn/games/monop/jail.c (revision 33208)
1*33208Sbostic /*
2*33208Sbostic  * Copyright (c) 1987 Regents of the University of California.
3*33208Sbostic  * All rights reserved.
4*33208Sbostic  *
5*33208Sbostic  * Redistribution and use in source and binary forms are permitted
6*33208Sbostic  * provided that this notice is preserved and that due credit is given
7*33208Sbostic  * to the University of California at Berkeley. The name of the University
8*33208Sbostic  * may not be used to endorse or promote products derived from this
9*33208Sbostic  * software without specific prior written permission. This software
10*33208Sbostic  * is provided ``as is'' without express or implied warranty.
11*33208Sbostic  */
12*33208Sbostic 
13*33208Sbostic #ifndef lint
14*33208Sbostic static char sccsid[] = "@(#)jail.c	5.1 (Berkeley) 01/02/88";
15*33208Sbostic #endif /* not lint */
16*33208Sbostic 
17*33208Sbostic # include	"monop.ext"
18*33208Sbostic 
19*33208Sbostic /*
20*33208Sbostic  *	This routine uses a get-out-of-jail-free card to get the
21*33208Sbostic  * player out of jail.
22*33208Sbostic  */
23*33208Sbostic card() {
24*33208Sbostic 
25*33208Sbostic 	if (cur_p->loc != JAIL) {
26*33208Sbostic 		printf("But you're not IN Jail\n");
27*33208Sbostic 		return;
28*33208Sbostic 	}
29*33208Sbostic 	if (cur_p->num_gojf == 0) {
30*33208Sbostic 		printf("But you don't HAVE a get out of jail free card\n");
31*33208Sbostic 		return;
32*33208Sbostic 	}
33*33208Sbostic 	ret_card(cur_p);
34*33208Sbostic 	cur_p->loc = 10;			/* just visiting	*/
35*33208Sbostic 	cur_p->in_jail = 0;
36*33208Sbostic }
37*33208Sbostic /*
38*33208Sbostic  *	This routine returns the players get-out-of-jail-free card
39*33208Sbostic  * to a deck.
40*33208Sbostic  */
41*33208Sbostic ret_card(plr)
42*33208Sbostic reg PLAY	*plr; {
43*33208Sbostic 
44*33208Sbostic 	plr->num_gojf--;
45*33208Sbostic 	if (CC_D.gojf_used)
46*33208Sbostic 		CC_D.gojf_used = FALSE;
47*33208Sbostic 	else
48*33208Sbostic 		CH_D.gojf_used = FALSE;
49*33208Sbostic }
50*33208Sbostic /*
51*33208Sbostic  *	This routine deals with paying your way out of jail.
52*33208Sbostic  */
53*33208Sbostic pay() {
54*33208Sbostic 
55*33208Sbostic 	if (cur_p->loc != JAIL) {
56*33208Sbostic 		printf("But you're not IN Jail\n");
57*33208Sbostic 		return;
58*33208Sbostic 	}
59*33208Sbostic 	cur_p->loc = 10;
60*33208Sbostic 	cur_p->money -= 50;
61*33208Sbostic 	cur_p->in_jail = 0;
62*33208Sbostic 	printf("That cost you $50\n");
63*33208Sbostic }
64*33208Sbostic /*
65*33208Sbostic  *	This routine deals with a move in jail
66*33208Sbostic  */
67*33208Sbostic move_jail(r1, r2)
68*33208Sbostic reg int	r1, r2; {
69*33208Sbostic 
70*33208Sbostic 	if (r1 != r2) {
71*33208Sbostic 		printf("Sorry, that doesn't get you out\n");
72*33208Sbostic 		if (++(cur_p->in_jail) == 3) {
73*33208Sbostic 			printf("It's your third turn and you didn't roll doubles.  You have to pay $50\n");
74*33208Sbostic 			cur_p->money -= 50;
75*33208Sbostic moveit:
76*33208Sbostic 			cur_p->loc = 10;
77*33208Sbostic 			cur_p->in_jail = 0;
78*33208Sbostic 			move(r1+r2);
79*33208Sbostic 			r1 = r2 - 1;	/* kludge: stop new roll w/doub	*/
80*33208Sbostic 			return TRUE;
81*33208Sbostic 		}
82*33208Sbostic 		return FALSE;
83*33208Sbostic 	}
84*33208Sbostic 	else {
85*33208Sbostic 		printf("Double roll gets you out.\n");
86*33208Sbostic 		goto moveit;
87*33208Sbostic 	}
88*33208Sbostic }
89*33208Sbostic printturn() {
90*33208Sbostic 
91*33208Sbostic 	if (cur_p->loc != JAIL)
92*33208Sbostic 		return;
93*33208Sbostic 	printf("(This is your ");
94*33208Sbostic 	switch (cur_p->in_jail) {
95*33208Sbostic 	  case 0:
96*33208Sbostic 		printf("1st");
97*33208Sbostic 		break;
98*33208Sbostic 	  case 1:
99*33208Sbostic 		printf("2nd");
100*33208Sbostic 		break;
101*33208Sbostic 	  case 2:
102*33208Sbostic 		printf("3rd (and final)");
103*33208Sbostic 		break;
104*33208Sbostic 	}
105*33208Sbostic 	printf(" turn in JAIL)\n");
106*33208Sbostic }
107