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