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