121207Sdist /* 221207Sdist * Copyright (c) 1980 Regents of the University of California. 3*33487Sbostic * All rights reserved. 4*33487Sbostic * 5*33487Sbostic * Redistribution and use in source and binary forms are permitted 6*33487Sbostic * provided that this notice is preserved and that due credit is given 7*33487Sbostic * to the University of California at Berkeley. The name of the University 8*33487Sbostic * may not be used to endorse or promote products derived from this 9*33487Sbostic * software without specific prior written permission. This software 10*33487Sbostic * is provided ``as is'' without express or implied warranty. 1121207Sdist */ 126753Srrh 1321207Sdist #ifndef lint 14*33487Sbostic static char sccsid[] = "@(#)check.c 5.2 (Berkeley) 02/16/88"; 15*33487Sbostic #endif /* not lint */ 1621207Sdist 176753Srrh #include "back.h" 186753Srrh 196753Srrh getmove () { 206753Srrh register int i, c; 216753Srrh 226753Srrh c = 0; 236753Srrh for (;;) { 246753Srrh i = checkmove(c); 256753Srrh 266753Srrh switch (i) { 276753Srrh case -1: 286753Srrh if (movokay(mvlim)) { 296753Srrh if (tflag) 306753Srrh curmove (20,0); 316753Srrh else 326753Srrh writec ('\n'); 336753Srrh for (i = 0; i < mvlim; i++) 346753Srrh if (h[i]) 356753Srrh wrhit(g[i]); 366753Srrh nexturn(); 376753Srrh if (*offopp == 15) 386753Srrh cturn *= -2; 396753Srrh if (tflag && pnum) 406753Srrh bflag = pnum; 416753Srrh return; 426753Srrh } 436753Srrh 446753Srrh case -4: 456753Srrh case 0: 466753Srrh if (tflag) 476753Srrh refresh(); 486753Srrh if (i != 0 && i != -4) 496753Srrh break; 506753Srrh if (tflag) 516753Srrh curmove (20,0); 526753Srrh else 536753Srrh writec ('\n'); 546753Srrh writel (*Colorptr); 556753Srrh if (i == -4) 566753Srrh writel (" must make "); 576753Srrh else 586753Srrh writel (" can only make "); 596753Srrh writec (mvlim+'0'); 606753Srrh writel (" move"); 616753Srrh if (mvlim > 1) 626753Srrh writec ('s'); 636753Srrh writec ('.'); 646753Srrh writec ('\n'); 656753Srrh break; 666753Srrh 676753Srrh case -3: 686753Srrh if (quit()) 696753Srrh return; 706753Srrh } 716753Srrh 726753Srrh if (! tflag) 736753Srrh proll (); 746753Srrh else { 756753Srrh curmove (cturn == -1? 18: 19,39); 766753Srrh cline (); 776753Srrh c = -1; 786753Srrh } 796753Srrh } 806753Srrh } 816753Srrh 826753Srrh movokay (mv) 836753Srrh register int mv; 846753Srrh 856753Srrh { 866753Srrh register int i, m; 876753Srrh 886753Srrh if (d0) 896753Srrh swap; 906753Srrh 916753Srrh for (i = 0; i < mv; i++) { 926753Srrh 936753Srrh if (p[i] == g[i]) { 946753Srrh moverr (i); 956753Srrh curmove (20,0); 966753Srrh writel ("Attempt to move to same location.\n"); 976753Srrh return (0); 986753Srrh } 996753Srrh 1006753Srrh if (cturn*(g[i]-p[i]) < 0) { 1016753Srrh moverr (i); 1026753Srrh curmove (20,0); 1036753Srrh writel ("Backwards move.\n"); 1046753Srrh return (0); 1056753Srrh } 1066753Srrh 1076753Srrh if (abs(board[bar]) && p[i] != bar) { 1086753Srrh moverr (i); 1096753Srrh curmove (20,0); 1106753Srrh writel ("Men still on bar.\n"); 1116753Srrh return (0); 1126753Srrh } 1136753Srrh 1146753Srrh if ( (m = makmove(i)) ) { 1156753Srrh moverr (i); 1166753Srrh switch (m) { 1176753Srrh 1186753Srrh case 1: 1196753Srrh writel ("Move not rolled.\n"); 1206753Srrh break; 1216753Srrh 1226753Srrh case 2: 1236753Srrh writel ("Bad starting position.\n"); 1246753Srrh break; 1256753Srrh 1266753Srrh case 3: 1276753Srrh writel ("Destination occupied.\n"); 1286753Srrh break; 1296753Srrh 1306753Srrh case 4: 1316753Srrh writel ("Can't remove men yet.\n"); 1326753Srrh } 1336753Srrh return (0); 1346753Srrh } 1356753Srrh } 1366753Srrh return (1); 1376753Srrh } 138