]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/houses.c
1 /* $NetBSD: houses.c,v 1.3 1995/03/23 08:34:40 cgd 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
38 static char sccsid
[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93";
40 static char rcsid
[] = "$NetBSD: houses.c,v 1.3 1995/03/23 08:34:40 cgd Exp $";
46 static char *names
[N_MON
+2],
49 static MON
*monops
[N_MON
];
52 * These routines deal with buying and selling houses
66 for (op
= cur_p
->own_list
; op
&& op
->sqr
->type
!= PRPTY
; op
= op
->next
)
69 if (op
->sqr
->desc
->monop
) {
70 mp
= op
->sqr
->desc
->mon_desc
;
71 names
[num_mon
] = (monops
[num_mon
]=mp
)->name
;
73 got_morg
= good
= FALSE
;
74 for (i
= 0; i
< mp
->num_in
; i
++) {
75 if (op
->sqr
->desc
->morg
)
77 if (op
->sqr
->desc
->houses
!= 5)
81 if (!good
|| got_morg
)
88 printf("You can't build on mortgaged monopolies.\n");
90 printf("You can't build any more.\n");
92 printf("But you don't have any monopolies!!\n");
98 names
[num_mon
++] = "done";
100 if ((p
=getinp("Which property do you wish to buy houses for? ", names
)) == num_mon
)
113 shrt input
[3],temp
[3];
118 price
= mp
->h_cost
* 50;
121 printf("Houses will cost $%d\n", price
);
122 printf("How many houses do you wish to buy for\n");
123 for (i
= 0; i
< mp
->num_in
; i
++) {
124 pp
= mp
->sq
[i
]->desc
;
126 if (pp
->houses
== 5) {
127 printf("%s (H):\n", mp
->sq
[i
]->name
);
132 (void)sprintf(cur_prop
, "%s (%d): ",
133 mp
->sq
[i
]->name
, pp
->houses
);
134 input
[i
] = get_int(cur_prop
);
135 temp
[i
] = input
[i
] + pp
->houses
;
137 printf("That's too many. The most you can buy is %d\n",
142 if (mp
->num_in
== 3 && (abs(temp
[0] - temp
[1]) > 1 ||
143 abs(temp
[0] - temp
[2]) > 1 || abs(temp
[1] - temp
[2]) > 1)) {
144 err
: printf("That makes the spread too wide. Try again\n");
147 else if (mp
->num_in
== 2 && abs(temp
[0] - temp
[1]) > 1)
149 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
152 printf("You asked for %d houses for $%d\n", tot
, tot
* price
);
153 if (getyn("Is that ok? ", yn
) == 0) {
154 cur_p
->money
-= tot
* price
;
155 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
156 mp
->sq
[i
]->desc
->houses
= temp
[i
];
162 * This routine sells houses.
175 for (op
= cur_p
->own_list
; op
; op
= op
->next
)
176 if (op
->sqr
->type
== PRPTY
&& op
->sqr
->desc
->monop
) {
177 mp
= op
->sqr
->desc
->mon_desc
;
178 names
[num_mon
] = (monops
[num_mon
]=mp
)->name
;
182 if (!good
&& op
->sqr
->desc
->houses
!= 0)
184 while (op
->next
&& op
->sqr
->desc
->mon_desc
== mp
190 printf("You don't have any houses to sell!!\n");
196 names
[num_mon
++] = "done";
197 names
[num_mon
--] = 0;
198 if ((p
=getinp("Which property do you wish to sell houses from? ", names
)) == num_mon
)
212 shrt input
[3],temp
[3];
217 price
= mp
->h_cost
* 25;
219 printf("Houses will get you $%d apiece\n", price
);
221 printf("How many houses do you wish to sell from\n");
222 for (i
= 0; i
< mp
->num_in
; i
++) {
223 pp
= mp
->sq
[i
]->desc
;
225 if (pp
->houses
== 0) {
226 printf("%s (0):\n", mp
->sq
[i
]->name
);
227 input
[i
] = temp
[i
] = 0;
231 (void)sprintf(cur_prop
,"%s (%d): ",
232 mp
->sq
[i
]->name
,pp
->houses
);
234 (void)sprintf(cur_prop
,"%s (H): ",mp
->sq
[i
]->name
);
235 input
[i
] = get_int(cur_prop
);
236 temp
[i
] = pp
->houses
- input
[i
];
238 printf("That's too many. The most you can sell is %d\n", pp
->houses
);
242 if (mp
->num_in
== 3 && (abs(temp
[0] - temp
[1]) > 1 ||
243 abs(temp
[0] - temp
[2]) > 1 || abs(temp
[1] - temp
[2]) > 1)) {
244 err
: printf("That makes the spread too wide. Try again\n");
247 else if (mp
->num_in
== 2 && abs(temp
[0] - temp
[1]) > 1)
249 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
252 printf("You asked to sell %d houses for $%d\n",tot
,tot
* price
);
253 if (getyn("Is that ok? ", yn
) == 0) {
254 cur_p
->money
+= tot
* price
;
255 for (tot
= i
= 0; i
< mp
->num_in
; i
++)
256 mp
->sq
[i
]->desc
->houses
= temp
[i
];
267 for (i
= 0; i
< mp
->num_in
; i
++) {
269 if (sqp
->desc
->houses
== 5)
270 printf("%s (H) ", sqp
->name
);
272 printf("%s (%d) ", sqp
->name
, sqp
->desc
->houses
);