]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/houses.c
1 /* $NetBSD: houses.c,v 1.6 1999/09/08 21:17:51 jsm Exp $ */
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/cdefs.h>
39 static char sccsid
[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93";
41 __RCSID("$NetBSD: houses.c,v 1.6 1999/09/08 21:17:51 jsm Exp $");
47 static const char *names
[N_MON
+2];
48 static char cur_prop
[80];
50 static MON
*monops
[N_MON
];
52 static void buy_h
__P((MON
*));
53 static void sell_h
__P((MON
*));
54 static void list_cur
__P((MON
*));
56 * These routines deal with buying and selling houses
71 for (op
= cur_p
->own_list
; op
&& op
->sqr
->type
!= PRPTY
; op
= op
->next
)
74 if (op
->sqr
->desc
->monop
) {
75 mp
= op
->sqr
->desc
->mon_desc
;
76 names
[num_mon
] = (monops
[num_mon
]=mp
)->name
;
78 got_morg
= good
= FALSE
;
79 for (i
= 0; i
< mp
->num_in
; i
++) {
80 if (op
->sqr
->desc
->morg
)
82 if (op
->sqr
->desc
->houses
!= 5)
86 if (!good
|| got_morg
)
93 printf("You can't build on mortgaged monopolies.\n");
95 printf("You can't build any more.\n");
97 printf("But you don't have any monopolies!!\n");
103 names
[num_mon
++] = "done";
104 names
[num_mon
--] = 0;
106 "Which property do you wish to buy houses for? ",
121 short input
[3],temp
[3];
126 price
= mp
->h_cost
* 50;
129 printf("Houses will cost $%d\n", price
);
130 printf("How many houses do you wish to buy for\n");
131 for (i
= 0; i
< mp
->num_in
; i
++) {
132 pp
= mp
->sq
[i
]->desc
;
134 if (pp
->houses
== 5) {
135 printf("%s (H):\n", mp
->sq
[i
]->name
);
140 (void)sprintf(cur_prop
, "%s (%d): ",
141 mp
->sq
[i
]->name
, pp
->houses
);
142 input
[i
] = get_int(cur_prop
);
143 temp
[i
] = input
[i
] + pp
->houses
;
145 printf("That's too many. The most you can buy is %d\n",
150 if (mp
->num_in
== 3 && (abs(temp
[0] - temp
[1]) > 1 ||
151 abs(temp
[0] - temp
[2]) > 1 || abs(temp
[1] - temp
[2]) > 1)) {
152 err
: printf("That makes the spread too wide. Try again\n");
155 else if (mp
->num_in
== 2 && abs(temp
[0] - temp
[1]) > 1)
157 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
160 printf("You asked for %d houses for $%d\n", tot
, tot
* price
);
161 if (getyn("Is that ok? ") == 0) {
162 cur_p
->money
-= tot
* price
;
163 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
164 mp
->sq
[i
]->desc
->houses
= temp
[i
];
170 * This routine sells houses.
184 for (op
= cur_p
->own_list
; op
; op
= op
->next
)
185 if (op
->sqr
->type
== PRPTY
&& op
->sqr
->desc
->monop
) {
186 mp
= op
->sqr
->desc
->mon_desc
;
187 names
[num_mon
] = (monops
[num_mon
]=mp
)->name
;
191 if (!good
&& op
->sqr
->desc
->houses
!= 0)
193 while (op
->next
&& op
->sqr
->desc
->mon_desc
== mp
199 printf("You don't have any houses to sell!!\n");
205 names
[num_mon
++] = "done";
206 names
[num_mon
--] = 0;
208 "Which property do you wish to sell houses from? ",
224 short input
[3],temp
[3];
229 price
= mp
->h_cost
* 25;
231 printf("Houses will get you $%d apiece\n", price
);
233 printf("How many houses do you wish to sell from\n");
234 for (i
= 0; i
< mp
->num_in
; i
++) {
235 pp
= mp
->sq
[i
]->desc
;
237 if (pp
->houses
== 0) {
238 printf("%s (0):\n", mp
->sq
[i
]->name
);
239 input
[i
] = temp
[i
] = 0;
243 (void)sprintf(cur_prop
,"%s (%d): ",
244 mp
->sq
[i
]->name
,pp
->houses
);
246 (void)sprintf(cur_prop
,"%s (H): ",mp
->sq
[i
]->name
);
247 input
[i
] = get_int(cur_prop
);
248 temp
[i
] = pp
->houses
- input
[i
];
251 "That's too many. The most you can sell is %d\n",
256 if (mp
->num_in
== 3 && (abs(temp
[0] - temp
[1]) > 1 ||
257 abs(temp
[0] - temp
[2]) > 1 || abs(temp
[1] - temp
[2]) > 1)) {
258 err
: printf("That makes the spread too wide. Try again\n");
261 else if (mp
->num_in
== 2 && abs(temp
[0] - temp
[1]) > 1)
263 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
266 printf("You asked to sell %d houses for $%d\n",tot
,tot
* price
);
267 if (getyn("Is that ok? ") == 0) {
268 cur_p
->money
+= tot
* price
;
269 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
270 mp
->sq
[i
]->desc
->houses
= temp
[i
];
282 for (i
= 0; i
< mp
->num_in
; i
++) {
284 if (sqp
->desc
->houses
== 5)
285 printf("%s (H) ", sqp
->name
);
287 printf("%s (%d) ", sqp
->name
, sqp
->desc
->houses
);