|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T l
Length: 2174 (0x87e) Types: TextFile Names: »legalmove.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Kriegspiel/legalmove.c«
/* legalmove.c */ #include "externs.h" legalmove(pawntries, pawnattempts, checkdirs, from, to, color) int from, to, color; int pawntries, *pawnattempts; LIST checkdirs; { LIST lmember(), piecemoves(); int i; static struct { int from; int to; } pawnstried [3]; if (whose [from] != color) return NO_PIECE; else if (occupant [from] == KING && to == from + 2) { /* castle king side */ if (!virgin [from]) return (KING_MOVED); else if (!virgin [from + 3]) return (ROOK_MOVED); else if (whose [from + 1] == color || whose [from + 2] == color) return (PIECE_IN_WAY); else if (checkdirs || whose [from + 1] != EMPTY || whose [from + 2] != EMPTY || moveintocheck (from, from + 1) || moveintocheck (from, from + 2)) return ILLEGAL; else return TRUE; } else if (occupant [from] == KING && to == from - 2) { /* castle queen side */ if (!virgin [from]) return (KING_MOVED); else if (!virgin [from - 4]) return (ROOK_MOVED); else if (whose [from - 1] == color || whose [from - 2] == color || whose [from - 3] == color) return (PIECE_IN_WAY); else if (checkdirs || whose [from - 1] != EMPTY || whose [from - 2] != EMPTY || whose [from - 3] != EMPTY || moveintocheck (from, from - 1) || moveintocheck (from, from - 2)) return ILLEGAL; else return TRUE; } else if (!lmember (to, piecemoves (from, TRUE))) return (NO_MOVE); else if (option [ANNOUNCEPAWNS] == TRUE && from % 10 != to % 10 && occupant [from] == PAWN) { if (pawntries == 0) return NOPAWNTRIES; for (i = 0; i < *pawnattempts; i++) if (pawnstried [i].from == from && pawnstried [i].to == to) return ILLEGAL; if (*pawnattempts == 3) return NOMOREPAWNTRIES; if (lmember (to, piecemoves (from, FALSE))) return TRUE; pawnstried [*pawnattempts].from = from; pawnstried [(*pawnattempts)++].to = to; if (*pawnattempts == 1) wprintw (win [MESSAGE],"1 attempt\r"); else wprintw (win [MESSAGE],"%d attempts\r", *pawnattempts); return ILLEGAL; } else if (!lmember (to, piecemoves (from, FALSE))) return ILLEGAL; else if (moveintocheck (from, to)) return ILLEGAL; else return TRUE; }