|
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 m
Length: 2658 (0xa62) Types: TextFile Names: »movecycle.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Kriegspiel/movecycle.c«
/* movecycle.c */ #include "externs.h" movecycle () { int from, to, color, pawntries, l; static int pawnattempts = 0; LIST check (), checkdirs; color = WHITE; while (TRUE) { wclear (win [CLOCK]); wclear (win [PROMPT]); wprintw (win [TOMOVE], "%s to move\r", colorname [color]); pawntries = countpawntries (color); if (option [ANNOUNCEPAWNS] && pawntries && pawnattempts < 3) if (pawntries == 1) wprintw (win [PAWNTRIES], "1 pawntry"); else wprintw (win [PAWNTRIES], "%d pawntries", pawntries); checkdirs = check (color); reportchecks (checkdirs, kingloc [color]); if (mate (pawnattempts, color)) { wclear (win [CHECK]); if (checkdirs != NIL) waddstr (win [CHECK], "CHECKMATE !"); else waddstr (win [CHECK], "STALEMATE"); break; } if (insufficient () || (drawok [WHITE] && drawok [BLACK])) { wclear (win [CHECK]); waddstr (win [CHECK], "DRAW"); break; } if (resign) { wclear (win [CHECK]); waddstr (win [CHECK], "RESIGNS"); break; } if (dead) { wclear (win [CHECK]); waddstr (win [CHECK], "DEAD"); wclear (win [MESSAGE]); waddstr (win[MESSAGE], "lost your\nopponent\n(sorry)"); } entermove (&from, &to, color, pawntries); while ((l = legalmove (pawntries, &pawnattempts, checkdirs, from, to, color)) != TRUE && !drawok [color] && !drawok [1 - color] && !resign && !dead) { illegal (l, color); entermove (&from, &to, color, pawntries); } wclear (win [CAPTURE]); wclear (win [PAWNTRIES]); wclear (win [CHECK]); wclear (win [MESSAGE]); if (!drawok [1 - color] && !drawok [color] && !resign && !dead) { pawnattempts = 0; if (occupant [from] == KING && to == from + 2) makemove (from + 3, from + 1, color); if (occupant [from] == KING && to == from - 2) makemove (from - 4, from - 1, color); makemove (from, to, color); lastmovefrom = from; lastmoveto = to; } if (drawok [1 - color] && !drawok [color]) drawok [color] = FALSE; color = 1 - color; } wclear (win [TOMOVE]); wclear (win [CLOCK]); wclear (win [CAPTURE]); wclear (win [PAWNTRIES]); while (TRUE) { waddstr (win [PROMPT], "\rreview game?"); wclear (win [MESSAGE]); waddstr (win [MESSAGE], "type y or n"); wclear (win [INPUT]); waddstr (win [INPUT], ": "); move (win [INPUT]->_cury + win [INPUT]->_begy, win [INPUT]->_curx + win [INPUT]->_begx); refresh (); wclear (win [CHECK]); switch (getchar ()) { case 'y': case 'Y': wclear (win [PROMPT]); wclear (win [MESSAGE]); review(); break; case 'n': case 'N': error ((char *) NULL); default: printf ("\007"); } } }