xref: /original-bsd/games/monop/rent.c (revision 9a897be2)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)rent.c	5.3 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"monop.ext"
13 
14 /*
15  *	This routine has the player pay rent
16  */
17 rent(sqp)
18 reg SQUARE	*sqp; {
19 
20 	reg int		rnt;
21 	reg PROP	*pp;
22 	PLAY		*plp;
23 
24 	plp = &play[sqp->owner];
25 	printf("Owned by %s\n", plp->name);
26 	if (sqp->desc->morg) {
27 		lucky("The thing is mortgaged.  ");
28 		return;
29 	}
30 	switch (sqp->type) {
31 	  case PRPTY:
32 		pp = sqp->desc;
33 		if (pp->monop)
34 			if (pp->houses == 0)
35 				printf("rent is %d\n", rnt=pp->rent[0] * 2);
36 			else if (pp->houses < 5)
37 				printf("with %d houses, rent is %d\n",
38 				    pp->houses, rnt=pp->rent[pp->houses]);
39 			else
40 				printf("with a hotel, rent is %d\n",
41 				    rnt=pp->rent[pp->houses]);
42 		else
43 			printf("rent is %d\n", rnt = pp->rent[0]);
44 		break;
45 	  case RR:
46 		rnt = 25;
47 		rnt <<= (plp->num_rr - 1);
48 		if (spec)
49 			rnt <<= 1;
50 		printf("rent is %d\n", rnt);
51 		break;
52 	  case UTIL:
53 		rnt = roll(2, 6);
54 		if (plp->num_util == 2 || spec) {
55 			printf("rent is 10 * roll (%d) = %d\n", rnt, rnt * 10);
56 			rnt *= 10;
57 		}
58 		else {
59 			printf("rent is 4 * roll (%d) = %d\n", rnt, rnt * 4);
60 			rnt *= 4;
61 		}
62 		break;
63 	}
64 	cur_p->money -= rnt;
65 	plp->money += rnt;
66 }
67