]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - monop/misc.c
1 /* $NetBSD: misc.c,v 1.4 1995/03/23 08:34:47 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
[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
40 static char rcsid
[] = "$NetBSD: misc.c,v 1.4 1995/03/23 08:34:47 cgd Exp $";
49 * This routine executes a truncated set of commands until a
50 * "yes or "no" answer is gotten.
58 if ((com
=getinp(prompt
, yn
)) < 2)
64 * This routine tells the player if he's out of money.
69 printf("That leaves you $%d in debt\n", -cur_p
->money
);
70 else if (cur_p
->money
== 0)
71 printf("that leaves you broke\n");
72 else if (fixing
&& !told_em
&& cur_p
->money
> 0) {
73 printf("-- You are now Solvent ---\n");
78 * This routine switches to the next player
82 player
= ++player
% num_play
;
83 cur_p
= &play
[player
];
87 * This routine gets an integer from the keyboard after the
101 for (sp
= buf
; (*sp
=getchar()) != '\n'; sp
++)
102 if (*sp
== -1) /* check for interrupted system call */
106 for (sp
= buf
; isspace(*sp
); sp
++)
108 for (; isdigit(*sp
); sp
++)
109 num
= num
* 10 + *sp
- '0';
113 printf("I can't understand that\n");
117 * This routine sets the monopoly flag from the list given.
122 reg
int num
; /* general counter */
123 reg MON
*orig
; /* remember starting monop ptr */
124 reg OWN
*op
; /* current owned prop */
125 OWN
*orig_op
; /* origianl prop before loop */
127 op
= play
[pl
].own_list
;
129 printf("op [%d] = play[pl [%d] ].own_list;\n", op
, pl
);
133 printf("op->sqr->type = %d\n", op
->sqr
->type
);
135 switch (op
->sqr
->type
) {
138 printf(" case UTIL:\n");
140 for (num
= 0; op
&& op
->sqr
->type
== UTIL
; op
= op
->next
)
142 play
[pl
].num_util
= num
;
144 printf("play[pl].num_util = num [%d];\n", num
);
149 printf(" case RR:\n");
151 for (num
= 0; op
&& op
->sqr
->type
== RR
; op
= op
->next
) {
153 printf("iter: %d\n", num
);
154 printf("op = %d, op->sqr = %d, op->sqr->type = %d\n", op
, op
->sqr
, op
->sqr
->type
);
158 play
[pl
].num_rr
= num
;
160 printf("play[pl].num_rr = num [%d];\n", num
);
165 printf(" case PRPTY:\n");
167 orig
= op
->sqr
->desc
->mon_desc
;
170 while (op
&& op
->sqr
->desc
->mon_desc
== orig
) {
172 printf("iter: %d\n", num
);
176 printf("op = op->next ");
180 printf("[%d];\n", op
);
184 printf("num = %d\n");
187 printf("panic: bad monopoly descriptor: orig = %d\n", orig
);
188 printf("player # %d\n", pl
+1);
190 printf("orig_op = %d\n", orig_op
);
191 printf("orig_op->sqr->type = %d (PRPTY)\n", op
->sqr
->type
);
192 printf("orig_op->next = %d\n", op
->next
);
193 printf("orig_op->sqr->desc = %d\n", op
->sqr
->desc
);
194 printf("op = %d\n", op
);
195 printf("op->sqr->type = %d (PRPTY)\n", op
->sqr
->type
);
196 printf("op->next = %d\n", op
->next
);
197 printf("op->sqr->desc = %d\n", op
->sqr
->desc
);
198 printf("num = %d\n", num
);
201 printf("orig->num_in = %d\n", orig
->num_in
);
203 if (num
== orig
->num_in
)
212 * This routine sets things up as if it is a new monopoly
222 mp
->num_own
= mp
->num_in
;
223 for (i
= 0; i
< mp
->num_in
; i
++)
224 mp
->sq
[i
]->desc
->monop
= TRUE
;
225 mp
->name
= mp
->mon_n
;
228 * This routine sets things up as if it is no longer a monopoly
237 for (i
= 0; i
< mp
->num_in
; i
++)
238 mp
->sq
[i
]->desc
->monop
= FALSE
;
239 mp
->name
= mp
->not_m
;
242 * This routine gives a list of the current player's routine
249 * This routine gives a list of a given players holdings
255 while ((pl
=getinp("Whose holdings do you want to see? ", name_list
)) < num_play
)
259 * This routine gives the players a chance before it exits.
265 if (getyn("Do you all really want to quit? ", yn
) == 0)
267 signal(SIGINT
, quit
);
270 * This routine copies one structure to another
273 reg
int *s1
, *s2
, size
; {