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

Defined functions

text defined in line 99; used 1 times

Defined variables

doubl defined in line 15; never used
lastch defined in line 80; never used
list defined in line 13; used 1 times
opts defined in line 13; used 1 times
prog defined in line 46; never used
prompt defined in line 13; used 2 times
sccsid defined in line 8; never used
stragy defined in line 30; never used
Last modified: 1985-05-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 994
Valid CSS Valid XHTML 1.0 Strict