Commit | Line | Data |
---|---|---|
e0bbfbf9 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
69fb7db6 KB |
3 | * All rights reserved. |
4 | * | |
af359dea C |
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. 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. | |
20 | * | |
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 | |
31 | * SUCH DAMAGE. | |
e0bbfbf9 DF |
32 | */ |
33 | ||
34 | #ifndef lint | |
1c15e888 | 35 | static char sccsid[] = "@(#)ttext2.c 5.4 (Berkeley) 6/1/90"; |
69fb7db6 | 36 | #endif /* not lint */ |
8ce5c52d RH |
37 | |
38 | #include "back.h" | |
39 | ||
c0cadb59 KM |
40 | char *prompt, *list, *opts; |
41 | ||
8ce5c52d RH |
42 | char *doubl[] = { |
43 | "\nDoubling:", | |
44 | "\n If a player thinks he is in a good position, he may double the", | |
45 | "value of the game. However, his opponent may not accept the pro-", | |
46 | "posal and forfeit the game before the price gets too high. A", | |
47 | "player must double before he rolls, and once his double has been", | |
48 | "accepted, he cannot double again, until his opponent has doubled.", | |
49 | "Thus, unless the game swings back and forth in advantage between", | |
50 | "the two players a great deal, the value of the game should be", | |
51 | "low. At any rate, the value of the game will never go above 64,", | |
52 | "or six doubles. However, if a player wins a backgammon at 64", | |
53 | "points, he wins 192 points!", | |
54 | "", | |
55 | 0}; | |
56 | ||
57 | char *stragy[] = { | |
58 | "\nStrategy:", | |
59 | "\n Some general hints when playing: Try not to leave men open", | |
60 | "unless absolutely necessary. Also, it is good to make as many", | |
61 | "points as possible. Often, two men from different positions can", | |
62 | "be brought together to form a new point. Although walls (six", | |
63 | "points in a row) are difficult to form, many points nestled close-", | |
64 | "ly together produce a formidable barrier. Also, while it is good", | |
65 | "to move back men forward, doing so lessens the opportunity for you", | |
66 | "to hit men. Finally, remember that once the two player's have", | |
67 | "passed each other on the board, there is no chance of either team", | |
68 | "being hit, so the game reduces to a race off the board. Addi-", | |
69 | "tional hints on strategy are presented in the practice game.", | |
70 | "", | |
71 | 0}; | |
72 | \f | |
73 | char *prog[] = { | |
74 | "\nThe Program and How It Works:", | |
75 | "\n A general rule of thumb is when you don't know what to do,", | |
76 | "type a question mark, and you should get some help. When it is", | |
77 | "your turn, only your color will be printed out, with nothing", | |
78 | "after it. You may double by typing a 'd', but if you type a", | |
79 | "space or newline, you will get your roll. (Remember, you must", | |
80 | "double before you roll.) Also, typing a 'r' will reprint the", | |
81 | "board, and a 'q' will quit the game. The program will type", | |
82 | "'Move:' when it wants your move, and you may indicate each die's", | |
83 | "move with <s>-<f>, where <s> is the starting position and <f> is", | |
84 | "the finishing position, or <s>/<r> where <r> is the roll made.", | |
85 | "<s>-<f1>-<f2> is short for <s>-<f1>,<f1>-<f2> and <s>/<r1><r2> is", | |
86 | "short for <s>/<r1>,<s>/<r2>. Moves may be separated by a comma", | |
87 | "or a space.", | |
88 | "", | |
89 | "\n While typing, any input which does not make sense will not be", | |
90 | "echoed, and a bell will sound instead. Also, backspacing and", | |
91 | "killing lines will echo differently than normal. You may examine", | |
92 | "the board by typing a 'r' if you have made a partial move, or be-", | |
93 | "fore you type a newline, to see what the board looks like. You", | |
94 | "must end your move with a newline. If you cannot double, your", | |
95 | "roll will always be printed, and you will not be given the oppor-", | |
96 | "tunity to double. Home and bar are represented by the appropri-", | |
97 | "ate number, 0 or 25 as the case may be, or by the letters 'h' or", | |
98 | "'b' as appropriate. You may also type 'r' or 'q' when the program", | |
99 | "types 'Move:', which has the same effect as above. Finally, you", | |
100 | "will get to decide if you want to play red or white (or both if you", | |
101 | "want to play a friend) at the beginning of the session, and you", | |
102 | "will not get to change your mind later, since the computer keeps", | |
103 | "score.", | |
104 | "", | |
105 | 0}; | |
106 | ||
107 | char *lastch[] = { | |
108 | "\nTutorial (Practice Game):", | |
109 | "\n This tutorial, for simplicity's sake, will let you play one", | |
110 | "predetermined game. All the rolls have been pre-arranged, and", | |
111 | "only one response will let you advance to the next move.", | |
112 | "Although a given roll will may have several legal moves, the tu-", | |
113 | "torial will only accept one (not including the same moves in a", | |
114 | "different order), claiming that that move is 'best.' Obviously,", | |
115 | "a subjective statement. At any rate, be patient with it and have", | |
116 | "fun learning about backgammon. Also, to speed things up a lit-", | |
117 | "tle, doubling will not take place in the tutorial, so you will", | |
118 | "never get that opportunity, and quitting only leaves the tutori-", | |
119 | "al, not the game. You will still be able to play backgammon", | |
120 | "after quitting.", | |
121 | "\n This is your last chance to look over the rules before the tu-", | |
122 | "torial starts.", | |
123 | "", | |
124 | 0}; | |
125 | \f | |
126 | text (txt) | |
127 | char **txt; | |
128 | ||
129 | { | |
130 | char **begin; | |
131 | char *a; | |
132 | char b; | |
133 | char *c; | |
134 | int i; | |
135 | ||
136 | fixtty (noech); | |
137 | begin = txt; | |
138 | while (*txt) { | |
139 | a = *(txt++); | |
140 | if (*a != '\0') { | |
141 | c = a; | |
142 | for (i = 0; *(c++) != '\0'; i--); | |
143 | writel (a); | |
144 | writec ('\n'); | |
145 | } else { | |
146 | fixtty (raw); | |
147 | writel (prompt); | |
148 | for (;;) { | |
149 | if ((b = readc()) == '?') { | |
150 | if (tflag) { | |
151 | if (begscr) { | |
152 | curmove (18,0); | |
153 | clend(); | |
154 | } else | |
155 | clear(); | |
156 | } else | |
157 | writec ('\n'); | |
158 | text (list); | |
159 | writel (prompt); | |
160 | continue; | |
161 | } | |
162 | i = 0; | |
163 | if (b == '\n') | |
164 | break; | |
165 | while (i < 11) { | |
166 | if (b == opts[i]) | |
167 | break; | |
168 | i++; | |
169 | } | |
170 | if (i == 11) | |
171 | writec ('\007'); | |
172 | else | |
173 | break; | |
174 | } | |
175 | if (tflag) { | |
176 | if (begscr) { | |
177 | curmove (18,0); | |
178 | clend(); | |
179 | } else | |
180 | clear(); | |
181 | } else | |
182 | writec ('\n'); | |
183 | if (i) | |
184 | return(i); | |
185 | fixtty (noech); | |
186 | if (tflag) | |
187 | curmove (curr,0); | |
188 | begin = txt; | |
189 | } | |
190 | } | |
191 | fixtty (raw); | |
192 | return (0); | |
193 | } |