1/*	$OpenBSD: rent.c,v 1.7 2016/01/08 18:20:33 mestre Exp $	*/
2/*	$NetBSD: rent.c,v 1.3 1995/03/23 08:35:11 cgd Exp $	*/
3
4/*
5 * Copyright (c) 1980, 1993
6 *	The Regents of the University of California.  All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <stdio.h>
34
35#include "monop.ext"
36
37/*
38 *	This routine has the player pay rent
39 */
40void
41rent(SQUARE *sqp)
42{
43	int	rnt;
44	PROP	*pp;
45	PLAY	*plp;
46
47	plp = &play[(int)sqp->owner];
48	printf("Owned by %s\n", plp->name);
49	if (sqp->desc->morg) {
50		lucky("The thing is mortgaged.  ");
51		return;
52	}
53	switch (sqp->type) {
54	case PRPTY:
55		pp = sqp->desc;
56		if (pp->monop) {
57			if (pp->houses == 0)
58				printf("rent is %d\n", rnt = pp->rent[0] * 2);
59			else if (pp->houses < 5)
60				printf("with %d house%s, rent is %d\n",
61				    pp->houses, pp->houses == 1 ? "" : "s",
62				    rnt = pp->rent[(int)pp->houses]);
63			else
64				printf("with a hotel, rent is %d\n",
65				    rnt = pp->rent[(int)pp->houses]);
66		} else
67			printf("rent is %d\n", rnt = pp->rent[0]);
68		break;
69	case RR:
70		rnt = 25;
71		rnt <<= (plp->num_rr - 1);
72		if (spec)
73			rnt <<= 1;
74		printf("rent is %d\n", rnt);
75		break;
76	case UTIL:
77		rnt = roll(2, 6);
78		if (plp->num_util == 2 || spec) {
79			printf("rent is 10 * roll (%d) = %d\n", rnt, rnt * 10);
80			rnt *= 10;
81		}
82		else {
83			printf("rent is 4 * roll (%d) = %d\n", rnt, rnt * 4);
84			rnt *= 4;
85		}
86		break;
87	default:	/* Should never be reached */
88		rnt = 0;
89		printf("Warning:  rent() property %d\n", sqp->type);
90		break;
91	}
92	cur_p->money -= rnt;
93	plp->money += rnt;
94}
95