date and time created 88/10/19 15:33:10 by bostic
[unix-history] / usr / src / games / trek / play.c
CommitLineData
9758240b
KM
1/*
2 * Copyright (c) 1980 Regents of the University of California.
e9fb6bea
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
d99e6414
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
9758240b
KM
16 */
17
22e26d0f 18#ifndef lint
d99e6414 19static char sccsid[] = "@(#)play.c 5.3 (Berkeley) %G%";
e9fb6bea 20#endif /* not lint */
22e26d0f
KM
21
22# include "trek.h"
23# include "getpar.h"
24
25/*
26** INSTRUCTION READ AND MAIN PLAY LOOP
27**
28** Well folks, this is it. Here we have the guts of the game.
29** This routine executes moves. It sets up per-move variables,
30** gets the command, and executes the command. After the command,
31** it calls events() to use up time, attack() to have Klingons
32** attack if the move was not free, and checkcond() to check up
33** on how we are doing after the move.
34*/
06d69904
KL
35extern int abandon(), capture(), shield(), computer(), dcrept(),
36 destruct(), dock(), help(), impulse(), lrscan(),
37 warp(), dumpgame(), rest(), shell(), srscan(),
38 reset(), torped(), visual(), setwarp(), undock(), phaser();
22e26d0f 39
06d69904 40struct cvntab Comtab[] =
22e26d0f 41{
06d69904
KL
42 "abandon", "", abandon, 0,
43 "ca", "pture", capture, 0,
44 "cl", "oak", shield, -1,
45 "c", "omputer", computer, 0,
46 "da", "mages", dcrept, 0,
47 "destruct", "", destruct, 0,
48 "do", "ck", dock, 0,
49 "help", "", help, 0,
50 "i", "mpulse", impulse, 0,
51 "l", "rscan", lrscan, 0,
52 "m", "ove", warp, 0,
53 "p", "hasers", phaser, 0,
54 "ram", "", warp, 1,
55 "dump", "", dumpgame, 0,
56 "r", "est", rest, 0,
57 "shell", "", shell, 0,
58 "sh", "ield", shield, 0,
59 "s", "rscan", srscan, 0,
60 "st", "atus", srscan, -1,
61 "terminate", "", reset, 0,
62 "t", "orpedo", torped, 0,
63 "u", "ndock", undock, 0,
64 "v", "isual", visual, 0,
65 "w", "arp", setwarp, 0,
22e26d0f
KM
66 0
67};
68
69play()
70{
71 struct cvntab *r;
72
73 while (1)
74 {
75 Move.free = 1;
76 Move.time = 0.0;
77 Move.shldchg = 0;
78 Move.newquad = 0;
79 Move.resting = 0;
80 skiptonl(0);
81 r = getcodpar("\nCommand", Comtab);
82 (*r->value)(r->value2);
83 events(0);
84 attack(0);
85 checkcond();
86 }
87}