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