xref: /dragonfly/games/mille/extern.c (revision 280ba0e6038b5c3e9ed0cc83bd855afafd386b1c)
1 /*-
2  * Copyright (c) 1982, 1993
3  *        The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * @(#)extern.c     8.1 (Berkeley) 5/31/93
30  * $FreeBSD: src/games/mille/extern.c,v 1.3 1999/11/30 03:49:01 billf Exp $
31  */
32 
33 #include "mille.h"
34 
35 /*
36  * @(#)extern.c     1.1 (Berkeley) 4/1/82
37  */
38 
39 bool      Debug,                        /* set if debugging code on             */
40           Finished,           /* set if current hand is finished      */
41           Next,                         /* set if changing players              */
42           On_exit,            /* set if game saved on exiting                   */
43           Order,                        /* set if hand should be sorted                   */
44           Saved;                        /* set if game just saved               */
45 
46 char      Initstr[100];                 /* initial string for error field       */
47 const char *C_fmt = "%-18.18s";         /* format for printing cards            */
48 const char *Fromfile = NULL;  /* startup file for game                */
49 static const char *const _cn[NUM_CARDS] = {       /* Card name buffer           */
50                     "",
51                     "25",
52                     "50",
53                     "75",
54                     "100",
55                     "200",
56                     "Out of Gas",
57                     "Flat Tire",
58                     "Accident",
59                     "Stop",
60                     "Speed Limit",
61                     "Gasoline",
62                     "Spare Tire",
63                     "Repairs",
64                     "Go",
65                     "End of Limit",
66                     "Extra Tank",
67                     "Puncture Proof",
68                     "Driving Ace",
69                     "Right of Way"
70 };
71 const char *const *C_name = &_cn[1];    /* Card names                           */
72 
73 int       Card_no,            /* Card number for current move                   */
74           End,                          /* End value for current hand           */
75           Handstart = COMP,   /* Player who starts hand               */
76           Movetype,           /* Current move type                              */
77           Play,                         /* Current player                       */
78           Numgos,                       /* Number of Go cards used by computer  */
79           Window = W_SMALL,   /* Current window wanted                */
80           Numseen[NUM_CARDS]; /* Number of cards seen in current hand */
81 
82 const int Value[NUM_MILES] = {          /* Value of mileage cards     */
83                     25, 50, 75, 100, 200
84           },
85           Numcards[NUM_CARDS] = {       /* Number of cards in deck              */
86                     10,       /* C_25 */
87                     10,       /* C_50 */
88                     10,       /* C_75 */
89                     12,       /* C_100 */
90                     4,        /* C_200 */
91                     2,        /* C_EMPTY */
92                     2,        /* C_FLAT */
93                     2,        /* C_CRASH */
94                     4,        /* C_STOP */
95                     3,        /* C_LIMIT */
96                     6,        /* C_GAS */
97                     6,        /* C_SPARE */
98                     6,        /* C_REPAIRS */
99                     14,       /* C_GO */
100                     6,        /* C_END_LIMIT */
101                     1,        /* C_GAS_SAFE */
102                     1,        /* C_SPARE_SAFE */
103                     1,        /* C_DRIVE_SAFE */
104                     1,        /* C_RIGHT_WAY */
105                     0         /* C_INIT */
106           };
107 int       Numneed[NUM_CARDS] = {        /* number of cards needed per hand      */
108                     0,        /* C_25 */
109                     0,        /* C_50 */
110                     0,        /* C_75 */
111                     0,        /* C_100 */
112                     0,        /* C_200 */
113                     2,        /* C_EMPTY */
114                     2,        /* C_FLAT */
115                     2,        /* C_CRASH */
116                     4,        /* C_STOP */
117                     3,        /* C_LIMIT */
118                     2,        /* C_GAS */
119                     2,        /* C_SPARE */
120                     2,        /* C_REPAIRS */
121                     10,       /* C_GO */
122                     3,        /* C_END_LIMIT */
123                     1,        /* C_GAS_SAFE */
124                     1,        /* C_SPARE_SAFE */
125                     1,        /* C_DRIVE_SAFE */
126                     1,        /* C_RIGHT_WAY */
127                     0         /* C_INIT */
128           };
129 
130 CARD      Discard,            /* Top of discard pile                            */
131           Sh_discard,                   /* Last discard card shown              */
132           *Topcard;           /* Pointer to next card to be picked    */
133 const CARD          Opposite[NUM_CARDS] = {       /* Opposites of each card               */
134                     C_25, C_50, C_75, C_100, C_200, C_GAS, C_SPARE,
135                     C_REPAIRS, C_GO, C_END_LIMIT, C_EMPTY, C_FLAT, C_CRASH,
136                     C_STOP, C_LIMIT, C_EMPTY, C_FLAT, C_CRASH, C_STOP, C_INIT
137           };
138 CARD      Deck[DECK_SZ] = {   /* Current deck                                   */
139                     C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25,
140                     C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50,
141                     C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75,
142                     C_100, C_100, C_100, C_100, C_100, C_100, C_100, C_100, C_100,
143                     C_100, C_100, C_100,
144                     C_200, C_200, C_200, C_200,
145                     C_EMPTY, C_EMPTY,
146                     C_FLAT, C_FLAT,
147                     C_CRASH, C_CRASH,
148                     C_STOP, C_STOP, C_STOP, C_STOP,
149                     C_LIMIT, C_LIMIT, C_LIMIT,
150                     C_GAS, C_GAS, C_GAS, C_GAS, C_GAS, C_GAS,
151                     C_SPARE, C_SPARE, C_SPARE, C_SPARE, C_SPARE, C_SPARE,
152                     C_REPAIRS, C_REPAIRS, C_REPAIRS, C_REPAIRS, C_REPAIRS,
153                               C_REPAIRS,
154                     C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, C_END_LIMIT,
155                               C_END_LIMIT,
156                     C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO,
157                               C_GO, C_GO, C_GO, C_GO,
158                     C_GAS_SAFE, C_SPARE_SAFE, C_DRIVE_SAFE, C_RIGHT_WAY
159           };
160 
161 FILE      *outf;
162 
163 PLAY      Player[2];                    /* Player descriptions                            */
164 
165 WINDOW    *Board,                       /* Playing field screen                           */
166           *Miles,                       /* Mileage screen                       */
167           *Score;                       /* Score screen                                   */
168 
169