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