xref: /netbsd-src/games/monop/spec.c (revision c34afa686bf074a6dcc7f17157faae72111dde9a)
1*c34afa68Sdholland /*	$NetBSD: spec.c,v 1.11 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[] = "@(#)spec.c	8.1 (Berkeley) 5/31/93";
3642fb1b9dScgd #else
37*c34afa68Sdholland __RCSID("$NetBSD: spec.c,v 1.11 2012/06/19 05:35:32 dholland Exp $");
3842fb1b9dScgd #endif
3961f28255Scgd #endif /* not lint */
4061f28255Scgd 
41b51259daSdholland #include "monop.h"
42b51259daSdholland #include "deck.h"
4361f28255Scgd 
44092d3130Sjsm static const char	*const perc[]	= {
4561f28255Scgd 	"10%", "ten percent", "%", "$200", "200", 0
4661f28255Scgd 	};
4761f28255Scgd 
48e084c008Sdholland /*
49e084c008Sdholland  * collect income tax
50e084c008Sdholland  */
51b118ad22Schristos void
inc_tax(void)52*c34afa68Sdholland inc_tax(void)
53e084c008Sdholland {
54b118ad22Schristos 	int worth, com_num;
5561f28255Scgd 
563a2a525cSdholland 	com_num = getinp("Do you wish to lose 10% of your total worth or "
57e42b2048Ssimonb 	    "$200? ", perc);
5861f28255Scgd 	worth = cur_p->money + prop_worth(cur_p);
5961f28255Scgd 	printf("You were worth $%d", worth);
6061f28255Scgd 	worth /= 10;
6161f28255Scgd 	if (com_num > 2) {
6261f28255Scgd 		if (worth < 200)
6361f28255Scgd 			printf(".  Good try, but not quite.\n");
6461f28255Scgd 		else if (worth > 200)
6561f28255Scgd 			lucky(".\nGood guess.  ");
6661f28255Scgd 		cur_p->money -= 200;
6761f28255Scgd 	}
6861f28255Scgd 	else {
6961f28255Scgd 		printf(", so you pay $%d", worth);
7061f28255Scgd 		if (worth > 200)
7161f28255Scgd 			printf("  OUCH!!!!.\n");
7261f28255Scgd 		else if (worth < 200)
7361f28255Scgd 			lucky("\nGood guess.  ");
7461f28255Scgd 		cur_p->money -= worth;
7561f28255Scgd 	}
7661f28255Scgd 	if (worth == 200)
7761f28255Scgd 		lucky("\nIt makes no difference!  ");
7861f28255Scgd }
79b118ad22Schristos 
80e084c008Sdholland /*
81e084c008Sdholland  * move player to jail
82e084c008Sdholland  */
83b118ad22Schristos void
goto_jail(void)84*c34afa68Sdholland goto_jail(void)
85e084c008Sdholland {
8661f28255Scgd 	cur_p->loc = JAIL;
8761f28255Scgd }
88b118ad22Schristos 
89e084c008Sdholland /*
90e084c008Sdholland  * landing on luxury tax
91e084c008Sdholland  */
92b118ad22Schristos void
lux_tax(void)93*c34afa68Sdholland lux_tax(void)
94e084c008Sdholland {
9561f28255Scgd 	printf("You lose $75\n");
9661f28255Scgd 	cur_p->money -= 75;
9761f28255Scgd }
98b118ad22Schristos 
99e084c008Sdholland /*
100e084c008Sdholland  * draw community chest card
101e084c008Sdholland  */
102b118ad22Schristos void
cc(void)103*c34afa68Sdholland cc(void)
104e084c008Sdholland {
10561f28255Scgd 	get_card(&CC_D);
10661f28255Scgd }
107b118ad22Schristos 
108e084c008Sdholland /*
109e084c008Sdholland  * draw chance card
110e084c008Sdholland  */
111b118ad22Schristos void
chance(void)112*c34afa68Sdholland chance(void)
113e084c008Sdholland {
11461f28255Scgd 	get_card(&CH_D);
11561f28255Scgd }
116