|
|
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 the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)check.c 5.3 (Berkeley) 6/18/88";
20: #endif /* not lint */
21:
22: #include "back.h"
23:
24: getmove () {
25: register int i, c;
26:
27: c = 0;
28: for (;;) {
29: i = checkmove(c);
30:
31: switch (i) {
32: case -1:
33: if (movokay(mvlim)) {
34: if (tflag)
35: curmove (20,0);
36: else
37: writec ('\n');
38: for (i = 0; i < mvlim; i++)
39: if (h[i])
40: wrhit(g[i]);
41: nexturn();
42: if (*offopp == 15)
43: cturn *= -2;
44: if (tflag && pnum)
45: bflag = pnum;
46: return;
47: }
48:
49: case -4:
50: case 0:
51: if (tflag)
52: refresh();
53: if (i != 0 && i != -4)
54: break;
55: if (tflag)
56: curmove (20,0);
57: else
58: writec ('\n');
59: writel (*Colorptr);
60: if (i == -4)
61: writel (" must make ");
62: else
63: writel (" can only make ");
64: writec (mvlim+'0');
65: writel (" move");
66: if (mvlim > 1)
67: writec ('s');
68: writec ('.');
69: writec ('\n');
70: break;
71:
72: case -3:
73: if (quit())
74: return;
75: }
76:
77: if (! tflag)
78: proll ();
79: else {
80: curmove (cturn == -1? 18: 19,39);
81: cline ();
82: c = -1;
83: }
84: }
85: }
86:
87: movokay (mv)
88: register int mv;
89:
90: {
91: register int i, m;
92:
93: if (d0)
94: swap;
95:
96: for (i = 0; i < mv; i++) {
97:
98: if (p[i] == g[i]) {
99: moverr (i);
100: curmove (20,0);
101: writel ("Attempt to move to same location.\n");
102: return (0);
103: }
104:
105: if (cturn*(g[i]-p[i]) < 0) {
106: moverr (i);
107: curmove (20,0);
108: writel ("Backwards move.\n");
109: return (0);
110: }
111:
112: if (abs(board[bar]) && p[i] != bar) {
113: moverr (i);
114: curmove (20,0);
115: writel ("Men still on bar.\n");
116: return (0);
117: }
118:
119: if ( (m = makmove(i)) ) {
120: moverr (i);
121: switch (m) {
122:
123: case 1:
124: writel ("Move not rolled.\n");
125: break;
126:
127: case 2:
128: writel ("Bad starting position.\n");
129: break;
130:
131: case 3:
132: writel ("Destination occupied.\n");
133: break;
134:
135: case 4:
136: writel ("Can't remove men yet.\n");
137: }
138: return (0);
139: }
140: }
141: return (1);
142: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.