home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / spezial / 08 / schach / in.inc < prev    next >
Encoding:
Text File  |  1989-05-09  |  4.7 KB  |  130 lines

  1. (********************************************************)
  2. (*                                                      *)
  3. (*   Modul:         IN.INC                              *)
  4. (*   Projekt:       CHESS                               *)
  5. (*   Autor:         Michael Thielscher                  *)
  6. (*   erstellt am:   17.04.89                            *)
  7. (*                                                      *)
  8. (********************************************************)
  9.  
  10. FUNCTION YesNo : BOOLEAN;
  11.   VAR ch: CHAR;
  12.   BEGIN
  13.     Write(' (j/n) ?  ');
  14.     REPEAT
  15.       Read(Kbd, ch);  ch := UpCase(ch)
  16.     UNTIL ch IN ['J','N'];
  17.     Write(ch);  YesNo := (ch = 'J')
  18.   END; (* YesNo *)
  19.  
  20. PROCEDURE StellungsEingabe (VAR Stellung: StellungsTyp);
  21.  
  22.   CONST  Pfeil = #174;
  23.          UP    = #5;
  24.          DOWN  = #24;
  25.          LEFT  = #19;
  26.          RIGHT = #4;
  27.  
  28.          FigurenString = ' BSLTDK';
  29.  
  30.   VAR  xpos, ypos,
  31.        xpos_alt, ypos_alt : 1..8;
  32.        abbruch            : BOOLEAN;
  33.        ch                 : CHAR;
  34.  
  35.   PROCEDURE LeereStellung;
  36.     VAR Feld: FeldTyp;
  37.     BEGIN
  38.       WITH Stellung DO BEGIN
  39.         FOR Feld := 21 TO 98 DO Brett[Feld] := Leer;
  40.         FOR Feld := 0 TO 19 DO BEGIN
  41.           Brett[Feld] := Illegal;  Brett[Feld+100] := Illegal
  42.         END; (* for *)
  43.         FOR Feld := 2 TO 9 DO BEGIN
  44.           Brett[10*Feld] := Illegal;  Brett[10*Feld+9] := Illegal
  45.         END (* for *)
  46.       END (* with *)
  47.     END; (* LeereStellung *)
  48.  
  49.   PROCEDURE FigurenEingabe;
  50.     BEGIN
  51.       GotoXY(4+4*xpos, 20-2*ypos);  Write(ch);
  52.       WITH Stellung DO
  53.         CASE ch OF
  54.           ' ': Brett[10*(ypos+1) + xpos] := Leer;
  55.           'B': Brett[10*(ypos+1) + xpos] := W_Bauer;
  56.           'S': Brett[10*(ypos+1) + xpos] := W_Springer;
  57.           'L': Brett[10*(ypos+1) + xpos] := W_Laeufer;
  58.           'T': Brett[10*(ypos+1) + xpos] := W_Turm;
  59.           'D': Brett[10*(ypos+1) + xpos] := W_Dame;
  60.           'K': Brett[10*(ypos+1) + xpos] := W_Koenig;
  61.           'b': Brett[10*(ypos+1) + xpos] := S_Bauer;
  62.           's': Brett[10*(ypos+1) + xpos] := S_Springer;
  63.           'l': Brett[10*(ypos+1) + xpos] := S_Laeufer;
  64.           't': Brett[10*(ypos+1) + xpos] := S_Turm;
  65.           'd': Brett[10*(ypos+1) + xpos] := S_Dame;
  66.           'k': Brett[10*(ypos+1) + xpos] := S_Koenig
  67.         END (* case *)
  68.     END; (* FigurenEingabe *)
  69.  
  70.   BEGIN   (* StellungsEingabe *)
  71.     LeereStellung;  StellungsAusgabe(Stellung);
  72.     xpos := 1;  ypos := 1;  abbruch := FALSE;
  73.     REPEAT
  74.       GotoXY(5+4*xpos, 20-2*ypos);  Write(Pfeil);
  75.       xpos_alt := xpos;  ypos_alt := ypos;
  76.       Read(Kbd, ch);
  77.       IF Pos(UpCase(ch), FigurenString) > 0 THEN FigurenEingabe
  78.       ELSE BEGIN
  79.         CASE UpCase(ch) OF
  80.           UP   : IF ypos < 8 THEN ypos := SUCC(ypos);
  81.           DOWN : IF ypos > 1 THEN ypos := PRED(ypos);
  82.           LEFT : IF xpos > 1 THEN xpos := PRED(xpos);
  83.           RIGHT: IF xpos < 8 THEN xpos := SUCC(xpos);
  84.           'C'  : BEGIN
  85.                    LeereStellung;  StellungsAusgabe(Stellung);
  86.                    xpos := 1;  ypos := 1
  87.                  END; (* 'L' *)
  88.           'G'  : BEGIN
  89.                    Stellung := GrundStellung;  StellungsAusgabe(Stellung);
  90.                    xpos := 1;  ypos := 1
  91.                  END; (* 'G' *)
  92.           'E'  : abbruch := TRUE
  93.         END; (* case *)
  94.         GotoXY(5+4*xpos_alt, 20-2*ypos_alt);  Write(' ')
  95.       END (* else *)
  96.     UNTIL abbruch;
  97.     WITH Stellung DO BEGIN
  98.       IF Brett[25] = W_Koenig THEN BEGIN
  99.         IF Brett[21] = W_Turm THEN BEGIN
  100.           GotoXY(48, 4);  Write('Lange Rochade Weiß   ');  Rochaden[1] := YesNo
  101.         END (* then *)
  102.         ELSE Rochaden[1] := FALSE;
  103.         IF Brett[28] = W_Turm THEN BEGIN
  104.           GotoXY(48, 5);  Write('Kurze Rochade Weiß   ');  Rochaden[2] := YesNo
  105.         END (* then *)
  106.         ELSE Rochaden[2] := FALSE
  107.       END (* then *)
  108.       ELSE BEGIN
  109.         Rochaden[1] := FALSE;  Rochaden[2] := FALSE
  110.       END; (* else *)
  111.       IF Brett[95] = S_Koenig THEN BEGIN
  112.         IF Brett[91] = S_Turm THEN BEGIN
  113.           GotoXY(48, 6);  Write('Lange Rochade Schwarz');  Rochaden[3] := YesNo
  114.         END (* then *)
  115.         ELSE Rochaden[3] := FALSE;
  116.         IF Brett[98] = S_Turm THEN BEGIN
  117.           GotoXY(48, 7);  Write('Kurze Rochade Schwarz');  Rochaden[4] := YesNo
  118.         END (* then *)
  119.         ELSE Rochaden[4] := FALSE
  120.       END (* then *)
  121.       ELSE BEGIN
  122.         Rochaden[3] := FALSE;  Rochaden[4] := FALSE
  123.       END; (* else *)
  124.  
  125.       GotoXY(48, 9);  Write('en passant (0-8) ?  ');
  126.       REPEAT  Read(Kbd, ch)  UNTIL ch IN ['0'..'8'];
  127.       Write(ch);  en_pass := ORD(ch) - ORD('0')
  128.     END (* with *)
  129.   END; (* StellungsEingabe *)
  130.