Annotation of 43BSDTahoe/games/backgammon/ttext2.c, revision 1.1

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

unix.superglobalmegacorp.com

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