xref: /original-bsd/games/trek/play.c (revision 92d3de31)
1 #ifndef lint
2 static char sccsid[] = "@(#)play.c	4.1	(Berkeley)	03/23/83";
3 #endif not lint
4 
5 # include	"trek.h"
6 # include	"getpar.h"
7 
8 /*
9 **  INSTRUCTION READ AND MAIN PLAY LOOP
10 **
11 **	Well folks, this is it.  Here we have the guts of the game.
12 **	This routine executes moves.  It sets up per-move variables,
13 **	gets the command, and executes the command.  After the command,
14 **	it calls events() to use up time, attack() to have Klingons
15 **	attack if the move was not free, and checkcond() to check up
16 **	on how we are doing after the move.
17 */
18 
19 struct cvntab	Comtab[]
20 {
21 	"abandon",		"",			&abandon,		0,
22 	"ca",			"pture",		&capture,		0,
23 	"cl",			"oak",			&shield,		-1,
24 	"c",			"omputer",		&computer,		0,
25 	"da",			"mages",		&dcrept,		0,
26 	"destruct",		"",			&destruct,		0,
27 	"do",			"ck",			&dock,			0,
28 	"help",			"",			&help,			0,
29 	"i",			"mpulse",		&impulse,		0,
30 	"l",			"rscan",		&lrscan,		0,
31 	"m",			"ove",			&warp,			0,
32 	"p",			"hasers",		&phaser,		0,
33 	"ram",			"",			&warp,			1,
34 	"dump",			"",			&dumpgame,		0,
35 	"r",			"est",			&rest,			0,
36 	"shell",		"",			&shell,			0,
37 	"sh",			"ield",			&shield,		0,
38 	"s",			"rscan",		&srscan,		0,
39 	"st",			"atus",			&srscan,		-1,
40 	"terminate",		"",			&reset,			0,
41 	"t",			"orpedo",		&torped,		0,
42 	"u",			"ndock",		&undock,		0,
43 	"v",			"isual",		&visual,		0,
44 	"w",			"arp",			&setwarp,		0,
45 	0
46 };
47 
48 play()
49 {
50 	struct cvntab		*r;
51 
52 	while (1)
53 	{
54 		Move.free = 1;
55 		Move.time = 0.0;
56 		Move.shldchg = 0;
57 		Move.newquad = 0;
58 		Move.resting = 0;
59 		skiptonl(0);
60 		r = getcodpar("\nCommand", Comtab);
61 		(*r->value)(r->value2);
62 		events(0);
63 		attack(0);
64 		checkcond();
65 	}
66 }
67