Annotation of 42BSD/games/backgammon/ttext2.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.