]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/prop.c
2 * Copyright (c) 1980 Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 static char sccsid
[] = "@(#)prop.c 5.6 (Berkeley) 6/1/90";
40 extern char *calloc();
43 * This routine deals with buying property, setting all the
52 add_list(player
, &(play
[player
].own_list
), cur_p
->loc
);
55 * This routine adds an item to the list.
57 add_list(plr
, head
, op_sqr
)
63 reg OWN
*tp
, *last_tp
;
67 op
= (OWN
*)calloc(1, sizeof (OWN
));
68 op
->sqr
= &board
[op_sqr
];
71 for (tp
= *head
; tp
&& value(tp
->sqr
) < val
; tp
= tp
->next
)
72 if (val
== value(tp
->sqr
)) {
87 * This routine deletes property from the list.
89 del_list(plr
, head
, op_sqr
)
95 reg OWN
*op
, *last_op
;
97 switch (board
[op_sqr
].type
) {
99 board
[op_sqr
].desc
->mon_desc
->num_own
--;
105 play
[plr
].num_util
--;
109 for (op
= *head
; op
; op
= op
->next
)
110 if (op
->sqr
== &board
[op_sqr
])
117 last_op
->next
= op
->next
;
122 * This routine calculates the value for sorting of the
134 default: /* Specials, etc */
144 return 8 + (sqp
->desc
) - prop
;
148 * This routine accepts bids for the current peice
153 static bool in
[MAX_PL
];
154 reg
int i
, num_in
, cur_max
;
158 printf("\nSo it goes up for auction. Type your bid after your name\n");
159 for (i
= 0; i
< num_play
; i
++)
164 while (num_in
> 1 || (cur_max
== 0 && num_in
> 0)) {
168 (void)sprintf(buf
, "%s: ", name_list
[i
]);
169 cur_bid
= get_int(buf
);
175 else if (cur_bid
<= cur_max
) {
176 printf("You must bid higher than %d to stay in\n", cur_max
);
177 printf("(bid of 0 drops you out)\n");
179 } while (cur_bid
!= 0 && cur_bid
<= cur_max
);
180 cur_max
= (cur_bid
? cur_bid
: cur_max
);
186 printf("It goes to %s (%d) for $%d\n",play
[i
].name
,i
+1,cur_max
);
187 buy(i
, &board
[cur_p
->loc
]);
188 play
[i
].money
-= cur_max
;
191 printf("Nobody seems to want it, so we'll leave it for later\n");
194 * This routine calculates the value of the property
204 for (op
= plp
->own_list
; op
; op
= op
->next
) {
205 if (op
->sqr
->type
== PRPTY
&& op
->sqr
->desc
->monop
)
206 worth
+= op
->sqr
->desc
->mon_desc
->h_cost
* 50 *
207 op
->sqr
->desc
->houses
;
208 worth
+= op
->sqr
->cost
;