1*c34afa68Sdholland /* $NetBSD: jail.c,v 1.10 2012/06/19 05:35:32 dholland Exp $ */
242fb1b9dScgd
361f28255Scgd /*
442fb1b9dScgd * Copyright (c) 1980, 1993
542fb1b9dScgd * The Regents of the University of California. All rights reserved.
661f28255Scgd *
761f28255Scgd * Redistribution and use in source and binary forms, with or without
861f28255Scgd * modification, are permitted provided that the following conditions
961f28255Scgd * are met:
1061f28255Scgd * 1. Redistributions of source code must retain the above copyright
1161f28255Scgd * notice, this list of conditions and the following disclaimer.
1261f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright
1361f28255Scgd * notice, this list of conditions and the following disclaimer in the
1461f28255Scgd * documentation and/or other materials provided with the distribution.
15e5aeb4eaSagc * 3. Neither the name of the University nor the names of its contributors
1661f28255Scgd * may be used to endorse or promote products derived from this software
1761f28255Scgd * without specific prior written permission.
1861f28255Scgd *
1961f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2061f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2161f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2261f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2361f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2461f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2561f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2661f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2761f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2861f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2961f28255Scgd * SUCH DAMAGE.
3061f28255Scgd */
3161f28255Scgd
32b118ad22Schristos #include <sys/cdefs.h>
3361f28255Scgd #ifndef lint
3442fb1b9dScgd #if 0
3542fb1b9dScgd static char sccsid[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93";
3642fb1b9dScgd #else
37*c34afa68Sdholland __RCSID("$NetBSD: jail.c,v 1.10 2012/06/19 05:35:32 dholland Exp $");
3842fb1b9dScgd #endif
3961f28255Scgd #endif /* not lint */
4061f28255Scgd
41b51259daSdholland #include "monop.h"
4261f28255Scgd
4361f28255Scgd /*
4461f28255Scgd * This routine uses a get-out-of-jail-free card to get the
4561f28255Scgd * player out of jail.
4661f28255Scgd */
47b118ad22Schristos void
card(void)48*c34afa68Sdholland card(void)
49b118ad22Schristos {
5061f28255Scgd if (cur_p->loc != JAIL) {
5161f28255Scgd printf("But you're not IN Jail\n");
5261f28255Scgd return;
5361f28255Scgd }
5461f28255Scgd if (cur_p->num_gojf == 0) {
5561f28255Scgd printf("But you don't HAVE a get out of jail free card\n");
5661f28255Scgd return;
5761f28255Scgd }
5861f28255Scgd ret_card(cur_p);
5961f28255Scgd cur_p->loc = 10; /* just visiting */
6061f28255Scgd cur_p->in_jail = 0;
6161f28255Scgd }
62e42b2048Ssimonb
6361f28255Scgd /*
6461f28255Scgd * This routine deals with paying your way out of jail.
6561f28255Scgd */
66b118ad22Schristos void
pay(void)67*c34afa68Sdholland pay(void)
68b118ad22Schristos {
6961f28255Scgd if (cur_p->loc != JAIL) {
7061f28255Scgd printf("But you're not IN Jail\n");
7161f28255Scgd return;
7261f28255Scgd }
7361f28255Scgd cur_p->loc = 10;
7461f28255Scgd cur_p->money -= 50;
7561f28255Scgd cur_p->in_jail = 0;
7661f28255Scgd printf("That cost you $50\n");
7761f28255Scgd }
78e42b2048Ssimonb
7961f28255Scgd /*
8061f28255Scgd * This routine deals with a move in jail
8161f28255Scgd */
82b118ad22Schristos int
move_jail(int r1,int r2)83*c34afa68Sdholland move_jail(int r1, int r2)
84b118ad22Schristos {
8561f28255Scgd if (r1 != r2) {
8661f28255Scgd printf("Sorry, that doesn't get you out\n");
8761f28255Scgd if (++(cur_p->in_jail) == 3) {
88e42b2048Ssimonb printf("It's your third turn and you didn't roll "
89e42b2048Ssimonb "doubles. You have to pay $50\n");
9061f28255Scgd cur_p->money -= 50;
9161f28255Scgd moveit:
9261f28255Scgd cur_p->loc = 10;
9361f28255Scgd cur_p->in_jail = 0;
9461f28255Scgd move(r1+r2);
9561f28255Scgd r1 = r2 - 1; /* kludge: stop new roll w/doub */
9661f28255Scgd return TRUE;
9761f28255Scgd }
9861f28255Scgd return FALSE;
9916168c20Sdholland } else {
10061f28255Scgd printf("Double roll gets you out.\n");
10161f28255Scgd goto moveit;
10261f28255Scgd }
10361f28255Scgd }
104b118ad22Schristos
105b118ad22Schristos void
printturn(void)106*c34afa68Sdholland printturn(void)
107b118ad22Schristos {
10861f28255Scgd if (cur_p->loc != JAIL)
10961f28255Scgd return;
11061f28255Scgd printf("(This is your ");
11161f28255Scgd switch (cur_p->in_jail) {
11261f28255Scgd case 0:
11361f28255Scgd printf("1st");
11461f28255Scgd break;
11561f28255Scgd case 1:
11661f28255Scgd printf("2nd");
11761f28255Scgd break;
11861f28255Scgd case 2:
11961f28255Scgd printf("3rd (and final)");
12061f28255Scgd break;
12161f28255Scgd }
12261f28255Scgd printf(" turn in JAIL)\n");
12361f28255Scgd }
124