xref: /csrg-svn/games/monop/jail.c (revision 34788)
133208Sbostic /*
2*34788Sbostic  * Copyright (c) 1980 Regents of the University of California.
333208Sbostic  * All rights reserved.
433208Sbostic  *
533208Sbostic  * Redistribution and use in source and binary forms are permitted
6*34788Sbostic  * provided that the above copyright notice and this paragraph are
7*34788Sbostic  * duplicated in all such forms and that any documentation,
8*34788Sbostic  * advertising materials, and other materials related to such
9*34788Sbostic  * distribution and use acknowledge that the software was developed
10*34788Sbostic  * by the University of California, Berkeley.  The name of the
11*34788Sbostic  * University may not be used to endorse or promote products derived
12*34788Sbostic  * from this software without specific prior written permission.
13*34788Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34788Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34788Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633208Sbostic  */
1733208Sbostic 
1833208Sbostic #ifndef lint
19*34788Sbostic static char sccsid[] = "@(#)jail.c	5.2 (Berkeley) 06/18/88";
2033208Sbostic #endif /* not lint */
2133208Sbostic 
2233208Sbostic # include	"monop.ext"
2333208Sbostic 
2433208Sbostic /*
2533208Sbostic  *	This routine uses a get-out-of-jail-free card to get the
2633208Sbostic  * player out of jail.
2733208Sbostic  */
2833208Sbostic card() {
2933208Sbostic 
3033208Sbostic 	if (cur_p->loc != JAIL) {
3133208Sbostic 		printf("But you're not IN Jail\n");
3233208Sbostic 		return;
3333208Sbostic 	}
3433208Sbostic 	if (cur_p->num_gojf == 0) {
3533208Sbostic 		printf("But you don't HAVE a get out of jail free card\n");
3633208Sbostic 		return;
3733208Sbostic 	}
3833208Sbostic 	ret_card(cur_p);
3933208Sbostic 	cur_p->loc = 10;			/* just visiting	*/
4033208Sbostic 	cur_p->in_jail = 0;
4133208Sbostic }
4233208Sbostic /*
4333208Sbostic  *	This routine returns the players get-out-of-jail-free card
4433208Sbostic  * to a deck.
4533208Sbostic  */
4633208Sbostic ret_card(plr)
4733208Sbostic reg PLAY	*plr; {
4833208Sbostic 
4933208Sbostic 	plr->num_gojf--;
5033208Sbostic 	if (CC_D.gojf_used)
5133208Sbostic 		CC_D.gojf_used = FALSE;
5233208Sbostic 	else
5333208Sbostic 		CH_D.gojf_used = FALSE;
5433208Sbostic }
5533208Sbostic /*
5633208Sbostic  *	This routine deals with paying your way out of jail.
5733208Sbostic  */
5833208Sbostic pay() {
5933208Sbostic 
6033208Sbostic 	if (cur_p->loc != JAIL) {
6133208Sbostic 		printf("But you're not IN Jail\n");
6233208Sbostic 		return;
6333208Sbostic 	}
6433208Sbostic 	cur_p->loc = 10;
6533208Sbostic 	cur_p->money -= 50;
6633208Sbostic 	cur_p->in_jail = 0;
6733208Sbostic 	printf("That cost you $50\n");
6833208Sbostic }
6933208Sbostic /*
7033208Sbostic  *	This routine deals with a move in jail
7133208Sbostic  */
7233208Sbostic move_jail(r1, r2)
7333208Sbostic reg int	r1, r2; {
7433208Sbostic 
7533208Sbostic 	if (r1 != r2) {
7633208Sbostic 		printf("Sorry, that doesn't get you out\n");
7733208Sbostic 		if (++(cur_p->in_jail) == 3) {
7833208Sbostic 			printf("It's your third turn and you didn't roll doubles.  You have to pay $50\n");
7933208Sbostic 			cur_p->money -= 50;
8033208Sbostic moveit:
8133208Sbostic 			cur_p->loc = 10;
8233208Sbostic 			cur_p->in_jail = 0;
8333208Sbostic 			move(r1+r2);
8433208Sbostic 			r1 = r2 - 1;	/* kludge: stop new roll w/doub	*/
8533208Sbostic 			return TRUE;
8633208Sbostic 		}
8733208Sbostic 		return FALSE;
8833208Sbostic 	}
8933208Sbostic 	else {
9033208Sbostic 		printf("Double roll gets you out.\n");
9133208Sbostic 		goto moveit;
9233208Sbostic 	}
9333208Sbostic }
9433208Sbostic printturn() {
9533208Sbostic 
9633208Sbostic 	if (cur_p->loc != JAIL)
9733208Sbostic 		return;
9833208Sbostic 	printf("(This is your ");
9933208Sbostic 	switch (cur_p->in_jail) {
10033208Sbostic 	  case 0:
10133208Sbostic 		printf("1st");
10233208Sbostic 		break;
10333208Sbostic 	  case 1:
10433208Sbostic 		printf("2nd");
10533208Sbostic 		break;
10633208Sbostic 	  case 2:
10733208Sbostic 		printf("3rd (and final)");
10833208Sbostic 		break;
10933208Sbostic 	}
11033208Sbostic 	printf(" turn in JAIL)\n");
11133208Sbostic }
112