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