date and time created 88/10/19 19:55:11 by bostic
[unix-history] / usr / src / games / monop / jail.c
CommitLineData
fbd7d885 1/*
d99e6414 2 * Copyright (c) 1980 Regents of the University of California.
fbd7d885
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
d99e6414
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
fbd7d885
KB
16 */
17
18#ifndef lint
d99e6414 19static char sccsid[] = "@(#)jail.c 5.2 (Berkeley) %G%";
fbd7d885
KB
20#endif /* not lint */
21
22# include "monop.ext"
23
24/*
25 * This routine uses a get-out-of-jail-free card to get the
26 * player out of jail.
27 */
28card() {
29
30 if (cur_p->loc != JAIL) {
31 printf("But you're not IN Jail\n");
32 return;
33 }
34 if (cur_p->num_gojf == 0) {
35 printf("But you don't HAVE a get out of jail free card\n");
36 return;
37 }
38 ret_card(cur_p);
39 cur_p->loc = 10; /* just visiting */
40 cur_p->in_jail = 0;
41}
42/*
43 * This routine returns the players get-out-of-jail-free card
44 * to a deck.
45 */
46ret_card(plr)
47reg PLAY *plr; {
48
49 plr->num_gojf--;
50 if (CC_D.gojf_used)
51 CC_D.gojf_used = FALSE;
52 else
53 CH_D.gojf_used = FALSE;
54}
55/*
56 * This routine deals with paying your way out of jail.
57 */
58pay() {
59
60 if (cur_p->loc != JAIL) {
61 printf("But you're not IN Jail\n");
62 return;
63 }
64 cur_p->loc = 10;
65 cur_p->money -= 50;
66 cur_p->in_jail = 0;
67 printf("That cost you $50\n");
68}
69/*
70 * This routine deals with a move in jail
71 */
72move_jail(r1, r2)
73reg int r1, r2; {
74
75 if (r1 != r2) {
76 printf("Sorry, that doesn't get you out\n");
77 if (++(cur_p->in_jail) == 3) {
78 printf("It's your third turn and you didn't roll doubles. You have to pay $50\n");
79 cur_p->money -= 50;
80moveit:
81 cur_p->loc = 10;
82 cur_p->in_jail = 0;
83 move(r1+r2);
84 r1 = r2 - 1; /* kludge: stop new roll w/doub */
85 return TRUE;
86 }
87 return FALSE;
88 }
89 else {
90 printf("Double roll gets you out.\n");
91 goto moveit;
92 }
93}
94printturn() {
95
96 if (cur_p->loc != JAIL)
97 return;
98 printf("(This is your ");
99 switch (cur_p->in_jail) {
100 case 0:
101 printf("1st");
102 break;
103 case 1:
104 printf("2nd");
105 break;
106 case 2:
107 printf("3rd (and final)");
108 break;
109 }
110 printf(" turn in JAIL)\n");
111}