1*21207Sdist /* 2*21207Sdist * Copyright (c) 1980 Regents of the University of California. 3*21207Sdist * All rights reserved. The Berkeley software License Agreement 4*21207Sdist * specifies the terms and conditions for redistribution. 5*21207Sdist */ 66753Srrh 7*21207Sdist #ifndef lint 8*21207Sdist static char sccsid[] = "@(#)check.c 5.1 (Berkeley) 05/29/85"; 9*21207Sdist #endif not lint 10*21207Sdist 116753Srrh #include "back.h" 126753Srrh 136753Srrh getmove () { 146753Srrh register int i, c; 156753Srrh 166753Srrh c = 0; 176753Srrh for (;;) { 186753Srrh i = checkmove(c); 196753Srrh 206753Srrh switch (i) { 216753Srrh case -1: 226753Srrh if (movokay(mvlim)) { 236753Srrh if (tflag) 246753Srrh curmove (20,0); 256753Srrh else 266753Srrh writec ('\n'); 276753Srrh for (i = 0; i < mvlim; i++) 286753Srrh if (h[i]) 296753Srrh wrhit(g[i]); 306753Srrh nexturn(); 316753Srrh if (*offopp == 15) 326753Srrh cturn *= -2; 336753Srrh if (tflag && pnum) 346753Srrh bflag = pnum; 356753Srrh return; 366753Srrh } 376753Srrh 386753Srrh case -4: 396753Srrh case 0: 406753Srrh if (tflag) 416753Srrh refresh(); 426753Srrh if (i != 0 && i != -4) 436753Srrh break; 446753Srrh if (tflag) 456753Srrh curmove (20,0); 466753Srrh else 476753Srrh writec ('\n'); 486753Srrh writel (*Colorptr); 496753Srrh if (i == -4) 506753Srrh writel (" must make "); 516753Srrh else 526753Srrh writel (" can only make "); 536753Srrh writec (mvlim+'0'); 546753Srrh writel (" move"); 556753Srrh if (mvlim > 1) 566753Srrh writec ('s'); 576753Srrh writec ('.'); 586753Srrh writec ('\n'); 596753Srrh break; 606753Srrh 616753Srrh case -3: 626753Srrh if (quit()) 636753Srrh return; 646753Srrh } 656753Srrh 666753Srrh if (! tflag) 676753Srrh proll (); 686753Srrh else { 696753Srrh curmove (cturn == -1? 18: 19,39); 706753Srrh cline (); 716753Srrh c = -1; 726753Srrh } 736753Srrh } 746753Srrh } 756753Srrh 766753Srrh movokay (mv) 776753Srrh register int mv; 786753Srrh 796753Srrh { 806753Srrh register int i, m; 816753Srrh 826753Srrh if (d0) 836753Srrh swap; 846753Srrh 856753Srrh for (i = 0; i < mv; i++) { 866753Srrh 876753Srrh if (p[i] == g[i]) { 886753Srrh moverr (i); 896753Srrh curmove (20,0); 906753Srrh writel ("Attempt to move to same location.\n"); 916753Srrh return (0); 926753Srrh } 936753Srrh 946753Srrh if (cturn*(g[i]-p[i]) < 0) { 956753Srrh moverr (i); 966753Srrh curmove (20,0); 976753Srrh writel ("Backwards move.\n"); 986753Srrh return (0); 996753Srrh } 1006753Srrh 1016753Srrh if (abs(board[bar]) && p[i] != bar) { 1026753Srrh moverr (i); 1036753Srrh curmove (20,0); 1046753Srrh writel ("Men still on bar.\n"); 1056753Srrh return (0); 1066753Srrh } 1076753Srrh 1086753Srrh if ( (m = makmove(i)) ) { 1096753Srrh moverr (i); 1106753Srrh switch (m) { 1116753Srrh 1126753Srrh case 1: 1136753Srrh writel ("Move not rolled.\n"); 1146753Srrh break; 1156753Srrh 1166753Srrh case 2: 1176753Srrh writel ("Bad starting position.\n"); 1186753Srrh break; 1196753Srrh 1206753Srrh case 3: 1216753Srrh writel ("Destination occupied.\n"); 1226753Srrh break; 1236753Srrh 1246753Srrh case 4: 1256753Srrh writel ("Can't remove men yet.\n"); 1266753Srrh } 1276753Srrh return (0); 1286753Srrh } 1296753Srrh } 1306753Srrh return (1); 1316753Srrh } 132