|
|
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: 1728 (0x6c0)
Types: TextFile
Names: »makemove.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Kriegspiel/makemove.c«
/* makemove.c */
#include "externs.h"
makemove (from, to, color)
int from, to, color;
{
int victim;
LIST l, lmember ();
MOVELIST newmove;
static MOVELIST lastmove;
char *malloc ();
newmove = (MOVELIST) malloc (sizeof (struct MOVE));
newmove -> from = from;
newmove -> to = to;
newmove -> n = NULL;
if (!movelist)
movelist = newmove;
else
lastmove -> n = newmove;
lastmove = newmove;
victim = findvictim (from, to);
if (victim) {
if (option [ANNOUNCETAKES] || whose [victim] == ourcolor) {
if (occupant [victim] == PAWN)
waddstr (win [CAPTURE], "pawn ");
else
waddstr (win [CAPTURE], "piece ");
if (ourcolor == BLACK && option [REVERSE])
wprintw (win [CAPTURE], "take: %1c%1d\r",
(9 - victim % 10) + 'a' - 1,
victim / 10);
else
wprintw (win [CAPTURE], "take: %1c%1d\r",
victim % 10 + 'a' - 1,
9 - victim / 10);
}
virgin [victim] = FALSE;
whose [victim] = EMPTY;
waddch (square [victim], sqcolor[(victim + victim / 10) % 2]);
lfront (lmember (victim, piecelocs [1 - color]),
piecelocs [1 - color]);
piecelocs [1 - color] = (piecelocs [1 - color])->n;
}
l = lmember (from, piecelocs [color]);
l->i = to;
if (occupant [from] == KING)
kingloc [color] = to;
virgin [from] = FALSE;
whose [to] = color;
occupant [to] = occupant [from];
whose [from] = EMPTY;
occupant [from] = 0;
if (occupant [to] == PAWN
&& ((to / 10 == 1 && color == WHITE)
|| (to / 10 == 8 && color == BLACK))) {
if (option [ANNOUNCETAKES])
waddstr (win [MESSAGE], "pawn promoted\n");
occupant [to] = QUEEN;
}
if (whose [to] == ourcolor) {
waddch (square [from], sqcolor[(from + from / 10) % 2]);
waddch (square [to], symbol [occupant [to]]);
}
}