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

Defined functions

getmove defined in line 13; used 5 times
movokay defined in line 76; used 3 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-05-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1179
Valid CSS Valid XHTML 1.0 Strict