DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T p

⟦3707fbce0⟧ TextFile

    Length: 1181 (0x49d)
    Types: TextFile
    Names: »pegs.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Nobs/pegs.c« 

TextFile

#include "defs.h"
#include "globs.h"
#include "window.h"

int
pegcol(n)
int n;
{
	if (n==0) return 0;
	else if (n<31) return n+(n+4)/5;
	else return 74-n-(n+4)/5;
}

resetpegs()
{
	int i, j;
	for (i=0; i<2; i++) for (j=0; j<2; j++) {
		if (peg[i][j] != 0) {
			mvwaddch(Board, 2*i, pegcol(peg[i][j]), ':');
			peg[i][j] = 0;
		}
	}
	for (i=0; i<2; i++) mvwaddch(Board, 2*i, 0, '|');
	wrefresh(Board);
}

setpegs(who)
PLAYER	who;
{
/*
 *	The first peg in the array is the forward peg.
 */

/*	Pick up the hindward peg.  */
	if (peg[who][0] == 0) mvwaddch(Board, 2*who, 0, who? '!': ';');
	else if (peg[who][1] + peg[who][0] == 61)
		mvwaddch(Board, 2*who, pegcol(peg[who][1]),
		(peg[who][1]>30)==who? ';': '!');
	else mvwaddch(Board, 2*who, pegcol(peg[who][1]), ':');
/*
 *	Put it down again.
 */
	peg[who][1] = peg[who][0];
	if (score[who] > 120) peg[who][0] = 0;
	else peg[who][0] = 1+(score[who]-1)%60;
	if (peg[who][0]==0) mvwaddch(Board, 2*who, 0, who? '!': ';');
	else if (peg[who][0] + peg[who][1] == 61)
		mvwaddch(Board, 2*who, pegcol(peg[who][0]), '|');
	else mvwaddch(Board, 2*who, pegcol(peg[who][0]),
		(peg[who][0]>30)==who? '!': ';');
	wrefresh(Board);
	sleep(1);
}