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