|
|
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[] = "@(#)check.c 5.4 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: #include "back.h" ! 25: ! 26: getmove () { ! 27: register int i, c; ! 28: ! 29: c = 0; ! 30: for (;;) { ! 31: i = checkmove(c); ! 32: ! 33: switch (i) { ! 34: case -1: ! 35: if (movokay(mvlim)) { ! 36: if (tflag) ! 37: curmove (20,0); ! 38: else ! 39: writec ('\n'); ! 40: for (i = 0; i < mvlim; i++) ! 41: if (h[i]) ! 42: wrhit(g[i]); ! 43: nexturn(); ! 44: if (*offopp == 15) ! 45: cturn *= -2; ! 46: if (tflag && pnum) ! 47: bflag = pnum; ! 48: return; ! 49: } ! 50: ! 51: case -4: ! 52: case 0: ! 53: if (tflag) ! 54: refresh(); ! 55: if (i != 0 && i != -4) ! 56: break; ! 57: if (tflag) ! 58: curmove (20,0); ! 59: else ! 60: writec ('\n'); ! 61: writel (*Colorptr); ! 62: if (i == -4) ! 63: writel (" must make "); ! 64: else ! 65: writel (" can only make "); ! 66: writec (mvlim+'0'); ! 67: writel (" move"); ! 68: if (mvlim > 1) ! 69: writec ('s'); ! 70: writec ('.'); ! 71: writec ('\n'); ! 72: break; ! 73: ! 74: case -3: ! 75: if (quit()) ! 76: return; ! 77: } ! 78: ! 79: if (! tflag) ! 80: proll (); ! 81: else { ! 82: curmove (cturn == -1? 18: 19,39); ! 83: cline (); ! 84: c = -1; ! 85: } ! 86: } ! 87: } ! 88: ! 89: movokay (mv) ! 90: register int mv; ! 91: ! 92: { ! 93: register int i, m; ! 94: ! 95: if (d0) ! 96: swap; ! 97: ! 98: for (i = 0; i < mv; i++) { ! 99: ! 100: if (p[i] == g[i]) { ! 101: moverr (i); ! 102: curmove (20,0); ! 103: writel ("Attempt to move to same location.\n"); ! 104: return (0); ! 105: } ! 106: ! 107: if (cturn*(g[i]-p[i]) < 0) { ! 108: moverr (i); ! 109: curmove (20,0); ! 110: writel ("Backwards move.\n"); ! 111: return (0); ! 112: } ! 113: ! 114: if (abs(board[bar]) && p[i] != bar) { ! 115: moverr (i); ! 116: curmove (20,0); ! 117: writel ("Men still on bar.\n"); ! 118: return (0); ! 119: } ! 120: ! 121: if ( (m = makmove(i)) ) { ! 122: moverr (i); ! 123: switch (m) { ! 124: ! 125: case 1: ! 126: writel ("Move not rolled.\n"); ! 127: break; ! 128: ! 129: case 2: ! 130: writel ("Bad starting position.\n"); ! 131: break; ! 132: ! 133: case 3: ! 134: writel ("Destination occupied.\n"); ! 135: break; ! 136: ! 137: case 4: ! 138: writel ("Can't remove men yet.\n"); ! 139: } ! 140: return (0); ! 141: } ! 142: } ! 143: return (1); ! 144: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.