125995Smckusick /*
2*60859Sbostic * Copyright (c) 1980, 1993
3*60859Sbostic * The Regents of the University of California. All rights reserved.
434205Sbostic *
542606Sbostic * %sccs.include.redist.c%
625995Smckusick */
725995Smckusick
811688Smckusick #ifndef lint
9*60859Sbostic static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 05/31/93";
1034205Sbostic #endif /* not lint */
1111688Smckusick
1211688Smckusick # include "trek.h"
1311688Smckusick # include "getpar.h"
1444314Sbostic # include <setjmp.h>
1511688Smckusick
1611688Smckusick /*
1711688Smckusick ** INSTRUCTION READ AND MAIN PLAY LOOP
1811688Smckusick **
1911688Smckusick ** Well folks, this is it. Here we have the guts of the game.
2011688Smckusick ** This routine executes moves. It sets up per-move variables,
2111688Smckusick ** gets the command, and executes the command. After the command,
2211688Smckusick ** it calls events() to use up time, attack() to have Klingons
2311688Smckusick ** attack if the move was not free, and checkcond() to check up
2411688Smckusick ** on how we are doing after the move.
2511688Smckusick */
2612738Slayer extern int abandon(), capture(), shield(), computer(), dcrept(),
2712738Slayer destruct(), dock(), help(), impulse(), lrscan(),
2841332Sbostic warp(), dumpgame(), rest(), srscan(),
2944314Sbostic myreset(), torped(), visual(), setwarp(), undock(), phaser();
3011688Smckusick
3112738Slayer struct cvntab Comtab[] =
3211688Smckusick {
3312738Slayer "abandon", "", abandon, 0,
3412738Slayer "ca", "pture", capture, 0,
3512738Slayer "cl", "oak", shield, -1,
3612738Slayer "c", "omputer", computer, 0,
3712738Slayer "da", "mages", dcrept, 0,
3812738Slayer "destruct", "", destruct, 0,
3912738Slayer "do", "ck", dock, 0,
4012738Slayer "help", "", help, 0,
4112738Slayer "i", "mpulse", impulse, 0,
4212738Slayer "l", "rscan", lrscan, 0,
4312738Slayer "m", "ove", warp, 0,
4412738Slayer "p", "hasers", phaser, 0,
4512738Slayer "ram", "", warp, 1,
4612738Slayer "dump", "", dumpgame, 0,
4712738Slayer "r", "est", rest, 0,
4812738Slayer "sh", "ield", shield, 0,
4912738Slayer "s", "rscan", srscan, 0,
5012738Slayer "st", "atus", srscan, -1,
5144314Sbostic "terminate", "", myreset, 0,
5212738Slayer "t", "orpedo", torped, 0,
5312738Slayer "u", "ndock", undock, 0,
5412738Slayer "v", "isual", visual, 0,
5512738Slayer "w", "arp", setwarp, 0,
5611688Smckusick 0
5711688Smckusick };
5811688Smckusick
myreset()5944314Sbostic myreset()
6044314Sbostic {
6144314Sbostic extern jmp_buf env;
6244314Sbostic
6344314Sbostic longjmp(env, 1);
6444314Sbostic }
6544314Sbostic
play()6611688Smckusick play()
6711688Smckusick {
6811688Smckusick struct cvntab *r;
6911688Smckusick
7011688Smckusick while (1)
7111688Smckusick {
7211688Smckusick Move.free = 1;
7311688Smckusick Move.time = 0.0;
7411688Smckusick Move.shldchg = 0;
7511688Smckusick Move.newquad = 0;
7611688Smckusick Move.resting = 0;
7711688Smckusick skiptonl(0);
7811688Smckusick r = getcodpar("\nCommand", Comtab);
7911688Smckusick (*r->value)(r->value2);
8011688Smckusick events(0);
8111688Smckusick attack(0);
8211688Smckusick checkcond();
8311688Smckusick }
8411688Smckusick }
85