1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if !defined(lint) && defined(DOSCCS)
   8: static char sccsid[] = "@(#)play.c	5.1.1 (2.11BSD GTE) 11/20/94";
   9: #endif
  10: 
  11: # include   "trek.h"
  12: # include   "getpar.h"
  13: # include   <setjmp.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(), shell(), srscan(),
  28:         myreset(), 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:     "shell",        "",         shell,      0,
  48:     "sh",           "ield",         shield, 0,
  49:     "s",            "rscan",        srscan, 0,
  50:     "st",           "atus",         srscan, -1,
  51:     "terminate",        "",         myreset,    0,
  52:     "t",            "orpedo",       torped, 0,
  53:     "u",            "ndock",        undock, 0,
  54:     "v",            "isual",        visual, 0,
  55:     "w",            "arp",          setwarp,    0,
  56:     0
  57: };
  58: 
  59: myreset()
  60: {
  61:     extern  jmp_buf env;
  62: 
  63:     longjmp(env, 1);
  64: }
  65: 
  66: play()
  67: {
  68:     struct cvntab       *r;
  69: 
  70:     while (1)
  71:     {
  72:         Move.free = 1;
  73:         Move.time = 0.0;
  74:         Move.shldchg = 0;
  75:         Move.newquad = 0;
  76:         Move.resting = 0;
  77:         skiptonl(0);
  78:         r = getcodpar("\nCommand", Comtab);
  79:         (*r->value)(r->value2);
  80:         events(0);
  81:         attack(0);
  82:         checkcond();
  83:     }
  84: }

Defined functions

myreset defined in line 59; used 2 times
play defined in line 66; used 1 times

Defined variables

Comtab defined in line 30; used 1 times
  • in line 78
sccsid defined in line 8; never used
Last modified: 1994-11-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2513
Valid CSS Valid XHTML 1.0 Strict