1*6753Srrh static char sccsid[] = " check.c 1.1 82/05/11 "; 2*6753Srrh 3*6753Srrh #include "back.h" 4*6753Srrh 5*6753Srrh getmove () { 6*6753Srrh register int i, c; 7*6753Srrh 8*6753Srrh c = 0; 9*6753Srrh for (;;) { 10*6753Srrh i = checkmove(c); 11*6753Srrh 12*6753Srrh switch (i) { 13*6753Srrh case -1: 14*6753Srrh if (movokay(mvlim)) { 15*6753Srrh if (tflag) 16*6753Srrh curmove (20,0); 17*6753Srrh else 18*6753Srrh writec ('\n'); 19*6753Srrh for (i = 0; i < mvlim; i++) 20*6753Srrh if (h[i]) 21*6753Srrh wrhit(g[i]); 22*6753Srrh nexturn(); 23*6753Srrh if (*offopp == 15) 24*6753Srrh cturn *= -2; 25*6753Srrh if (tflag && pnum) 26*6753Srrh bflag = pnum; 27*6753Srrh return; 28*6753Srrh } 29*6753Srrh 30*6753Srrh case -4: 31*6753Srrh case 0: 32*6753Srrh if (tflag) 33*6753Srrh refresh(); 34*6753Srrh if (i != 0 && i != -4) 35*6753Srrh break; 36*6753Srrh if (tflag) 37*6753Srrh curmove (20,0); 38*6753Srrh else 39*6753Srrh writec ('\n'); 40*6753Srrh writel (*Colorptr); 41*6753Srrh if (i == -4) 42*6753Srrh writel (" must make "); 43*6753Srrh else 44*6753Srrh writel (" can only make "); 45*6753Srrh writec (mvlim+'0'); 46*6753Srrh writel (" move"); 47*6753Srrh if (mvlim > 1) 48*6753Srrh writec ('s'); 49*6753Srrh writec ('.'); 50*6753Srrh writec ('\n'); 51*6753Srrh break; 52*6753Srrh 53*6753Srrh case -3: 54*6753Srrh if (quit()) 55*6753Srrh return; 56*6753Srrh } 57*6753Srrh 58*6753Srrh if (! tflag) 59*6753Srrh proll (); 60*6753Srrh else { 61*6753Srrh curmove (cturn == -1? 18: 19,39); 62*6753Srrh cline (); 63*6753Srrh c = -1; 64*6753Srrh } 65*6753Srrh } 66*6753Srrh } 67*6753Srrh 68*6753Srrh movokay (mv) 69*6753Srrh register int mv; 70*6753Srrh 71*6753Srrh { 72*6753Srrh register int i, m; 73*6753Srrh 74*6753Srrh if (d0) 75*6753Srrh swap; 76*6753Srrh 77*6753Srrh for (i = 0; i < mv; i++) { 78*6753Srrh 79*6753Srrh if (p[i] == g[i]) { 80*6753Srrh moverr (i); 81*6753Srrh curmove (20,0); 82*6753Srrh writel ("Attempt to move to same location.\n"); 83*6753Srrh return (0); 84*6753Srrh } 85*6753Srrh 86*6753Srrh if (cturn*(g[i]-p[i]) < 0) { 87*6753Srrh moverr (i); 88*6753Srrh curmove (20,0); 89*6753Srrh writel ("Backwards move.\n"); 90*6753Srrh return (0); 91*6753Srrh } 92*6753Srrh 93*6753Srrh if (abs(board[bar]) && p[i] != bar) { 94*6753Srrh moverr (i); 95*6753Srrh curmove (20,0); 96*6753Srrh writel ("Men still on bar.\n"); 97*6753Srrh return (0); 98*6753Srrh } 99*6753Srrh 100*6753Srrh if ( (m = makmove(i)) ) { 101*6753Srrh moverr (i); 102*6753Srrh switch (m) { 103*6753Srrh 104*6753Srrh case 1: 105*6753Srrh writel ("Move not rolled.\n"); 106*6753Srrh break; 107*6753Srrh 108*6753Srrh case 2: 109*6753Srrh writel ("Bad starting position.\n"); 110*6753Srrh break; 111*6753Srrh 112*6753Srrh case 3: 113*6753Srrh writel ("Destination occupied.\n"); 114*6753Srrh break; 115*6753Srrh 116*6753Srrh case 4: 117*6753Srrh writel ("Can't remove men yet.\n"); 118*6753Srrh } 119*6753Srrh return (0); 120*6753Srrh } 121*6753Srrh } 122*6753Srrh return (1); 123*6753Srrh } 124