コード例 #1
0
ファイル: assorted.c プロジェクト: juanfra684/DragonFlyBSD
static void
strike(struct ship *ship, struct ship *from)
{
    int points;

    if (ship->file->struck)
        return;
    Write(W_STRUCK, ship, 1, 0, 0, 0);
    points = ship->specs->pts + from->file->points;
    Write(W_POINTS, from, points, 0, 0, 0);
    unboard(ship, ship, 0);		/* all offense */
    unboard(ship, ship, 1);		/* all defense */
    switch (die()) {
    case 3:
    case 4:		/* ship may sink */
        Write(W_SINK, ship, 1, 0, 0, 0);
        break;
    case 5:
    case 6:		/* ship may explode */
        Write(W_EXPLODE, ship, 1, 0, 0, 0);
        break;
    }
    Writestr(W_SIGNAL, ship, "striking her colours!");
}
コード例 #2
0
ファイル: assorted.c プロジェクト: juanfra684/DragonFlyBSD
void
Cleansnag(struct ship *from, struct ship *to, char all, char flag)
{
    if (flag & 1) {
        Write(W_UNGRAP, from, to->file->index, all, 0, 0);
        Write(W_UNGRAP, to, from->file->index, all, 0, 0);
    }
    if (flag & 2) {
        Write(W_UNFOUL, from, to->file->index, all, 0, 0);
        Write(W_UNFOUL, to, from->file->index, all, 0, 0);
    }
    if (!snagged2(from, to)) {
        if (!snagged(from)) {
            unboard(from, from, 1);		/* defense */
            unboard(from, from, 0);		/* defense */
        } else
            unboard(from, to, 0);		/* offense */
        if (!snagged(to)) {
            unboard(to, to, 1);		/* defense */
            unboard(to, to, 0);		/* defense */
        } else
            unboard(to, from, 0);		/* offense */
    }
}
コード例 #3
0
ファイル: pl_2.c プロジェクト: Kiddinglife/4.4BSD-Lite
play()
{
	register struct ship *sp;

	for (;;) {
		switch (sgetch("~\b", (struct ship *)0, 0)) {
		case 'm':
			acceptmove();
			break;
		case 's':
			acceptsignal();
			break;
		case 'g':
			grapungrap();
			break;
		case 'u':
			unfoulplayer();
			break;
		case 'v':
			Signal("%s", (struct ship *)0, version);
			break;
		case 'b':
			acceptboard();
			break;
		case 'f':
			acceptcombat();
			break;
		case 'l':
			loadplayer();
			break;
		case 'c':
			changesail();
			break;
		case 'r':
			repair();
			break;
		case 'B':
			Signal("'Hands to stations!'", (struct ship *)0);
			unboard(ms, ms, 1);	/* cancel DBP's */
			unboard(ms, ms, 0);	/* cancel offense */
			break;
		case '\f':
			centerview();
			blockalarm();
			draw_board();
			draw_screen();
			unblockalarm();
			break;
		case 'L':
			mf->loadL = L_EMPTY;
			mf->loadR = L_EMPTY;
			mf->readyL = R_EMPTY;
			mf->readyR = R_EMPTY;
			Signal("Broadsides unloaded", (struct ship *)0);
			break;
		case 'q':
			Signal("Type 'Q' to quit", (struct ship *)0);
			break;
		case 'Q':
			leave(LEAVE_QUIT);
			break;
		case 'I':
			foreachship(sp)
				if (sp != ms)
					eyeball(sp);
			break;
		case 'i':
			if ((sp = closestenemy(ms, 0, 1)) == 0)
				Signal("No more ships left.");
			else
				eyeball(sp);
			break;
		case 'C':
			centerview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'U':
			upview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'D':
		case 'N':
			downview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'H':
			leftview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'J':
			rightview();
			blockalarm();
			draw_view();
			unblockalarm();
			break;
		case 'F':
			lookout();
			break;
		case 'S':
			dont_adjust = !dont_adjust;
			blockalarm();
			draw_turn();
			unblockalarm();
			break;
		}
	}
}