Exemplo n.º 1
0
tutor ()  {
	register int	i, j;

	i = 0;
	begscr = 18;
	cturn = -1;
	home = 0;
	bar = 25;
	inptr = &in[0];
	inopp = &in[1];
	offptr = &off[0];
	offopp = &off[1];
	Colorptr = &color[0];
	colorptr = &color[2];
	colen = 5;
	wrboard();

	while (1)  {
		if (! brdeq(test[i].brd,board))  {
			if (tflag && curr == 23)
				curmove (18,0);
			writel (better);
			nexturn();
			movback (mvlim);
			if (tflag)  {
				refresh();
				clrest ();
			}
			if ((! tflag) || curr == 19)  {
				proll();
				writec ('\t');
			}
			else
				curmove (curr > 19? curr-2: curr+4,25);
			getmove();
			if (cturn == 0)
				leave();
			continue;
		}
		if (tflag)
			curmove (18,0);
		text (*test[i].com);
		if (! tflag)
			writec ('\n');
		if (i == maxmoves)
			break;
		D0 = test[i].roll1;
		D1 = test[i].roll2;
		d0 = 0;
		mvlim = 0;
		for (j = 0; j < 4; j++)  {
			if (test[i].mp[j] == test[i].mg[j])
				break;
			p[j] = test[i].mp[j];
			g[j] = test[i].mg[j];
			mvlim++;
		}
		if (mvlim)
			for (j = 0; j < mvlim; j++)
				if (makmove(j))
					writel ("AARGH!!!\n");
		if (tflag)
			refresh();
		nexturn();
		D0 = test[i].new1;
		D1 = test[i].new2;
		d0 = 0;
		i++;
		mvlim = movallow();
		if (mvlim)  {
			if (tflag)
				clrest();
			proll();
			writec('\t');
			getmove();
			if (tflag)
				refresh();
			if (cturn == 0)
				leave();
		}
	}
	leave();
}
Exemplo n.º 2
0
void
tutor(void)
{
	int     i, j, k;
	int     wrongans;

	wrongans = 0;
	i = 0;
	begscr = 18;
	cturn = -1;
	home = 0;
	bar = 25;
	inptr = &in[0];
	inopp = &in[1];
	offptr = &off[0];
	offopp = &off[1];
	Colorptr = &color[0];
	colorptr = &color[2];
	colen = 5;
	wrboard();

	while (1) {
		if (!brdeq(test[i].brd, board)) {
			wrongans++;
			move(18, 0);
			if (wrongans >= 3) {
				wrongans = 0;
				text(*test[i].ans);
				memcpy(board,test[i].brd,26*sizeof(int));
				/* and have to fix *inptr, *offptr; player is red (+ve) */
				k = 0;
				for (j = 19; j < 26; j++)
					k += (board[j] > 0 ? board[j] : 0);
				*inopp = k;
				for (j = 0; j < 19; j++)
					k += (board[j] > 0 ? board[j] : 0);
				*offopp = k - 30;  /* -15 at start */
				moveplayers();
				clrest();
			} else {
				addstr(better);
				nexturn();
				movback(mvlim);
				moveplayers();
				clrest();
				getyx(stdscr, j, k);
				if (j == 19) {
					proll();
					addch('\t');
				} else
					move(j > 19 ? j - 2 : j + 4, 25);
				getmove();
				if (cturn == 0)
					leave();
				continue;
			}
		} else
			wrongans = 0;
		move(18, 0);
		text(*test[i].com);
		move(19, 0);
		if (i == maxmoves)
			break;
		D0 = test[i].roll1;
		D1 = test[i].roll2;
		d0 = 0;
		mvlim = 0;
		for (j = 0; j < 4; j++) {
			if (test[i].mp[j] == test[i].mg[j])
				break;
			p[j] = test[i].mp[j];
			g[j] = test[i].mg[j];
			mvlim++;
		}
		if (mvlim)
			for (j = 0; j < mvlim; j++)
				if (makmove(j))
					addstr("AARGH!!!\n");
		moveplayers();
		nexturn();
		D0 = test[i].new1;
		D1 = test[i].new2;
		d0 = 0;
		i++;
		mvlim = movallow();
		if (mvlim) {
			clrest();
			proll();
			addch('\t');
			getmove();
			moveplayers();
			if (cturn == 0)
				leave();
		}
	}
	leave();
}