@fnndsc/brasa 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +48 -0
- package/dist/buildinfo.json +1 -1
- package/dist/builtins/fs/cp.js +9 -5
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/destination.d.ts +15 -1
- package/dist/builtins/fs/destination.js +35 -2
- package/dist/builtins/fs/destination.js.map +1 -1
- package/dist/builtins/fs/mv.js +9 -5
- package/dist/builtins/fs/mv.js.map +1 -1
- package/dist/builtins/fs/rm.js +17 -1
- package/dist/builtins/fs/rm.js.map +1 -1
- package/dist/builtins/games/lab.js +3 -1
- package/dist/builtins/games/lab.js.map +1 -1
- package/dist/builtins/games/shelf.js +1 -1
- package/dist/builtins/games/shelf.js.map +1 -1
- package/dist/builtins/games/stdin.d.ts +0 -13
- package/dist/builtins/games/stdin.js +9 -0
- package/dist/builtins/games/stdin.js.map +1 -1
- package/dist/builtins/games/trek/abandon.d.ts +3 -0
- package/dist/builtins/games/trek/abandon.js +159 -0
- package/dist/builtins/games/trek/abandon.js.map +1 -0
- package/dist/builtins/games/trek/attack.d.ts +3 -0
- package/dist/builtins/games/trek/attack.js +185 -0
- package/dist/builtins/games/trek/attack.js.map +1 -0
- package/dist/builtins/games/trek/autover.d.ts +3 -0
- package/dist/builtins/games/trek/autover.js +79 -0
- package/dist/builtins/games/trek/autover.js.map +1 -0
- package/dist/builtins/games/trek/capture.d.ts +3 -0
- package/dist/builtins/games/trek/capture.js +117 -0
- package/dist/builtins/games/trek/capture.js.map +1 -0
- package/dist/builtins/games/trek/check_out.d.ts +3 -0
- package/dist/builtins/games/trek/check_out.js +67 -0
- package/dist/builtins/games/trek/check_out.js.map +1 -0
- package/dist/builtins/games/trek/checkcond.d.ts +3 -0
- package/dist/builtins/games/trek/checkcond.js +101 -0
- package/dist/builtins/games/trek/checkcond.js.map +1 -0
- package/dist/builtins/games/trek/compkl.d.ts +8 -0
- package/dist/builtins/games/trek/compkl.js +66 -0
- package/dist/builtins/games/trek/compkl.js.map +1 -0
- package/dist/builtins/games/trek/computer.d.ts +3 -0
- package/dist/builtins/games/trek/computer.js +310 -0
- package/dist/builtins/games/trek/computer.js.map +1 -0
- package/dist/builtins/games/trek/consts.d.ts +109 -0
- package/dist/builtins/games/trek/consts.js +159 -0
- package/dist/builtins/games/trek/consts.js.map +1 -0
- package/dist/builtins/games/trek/context.d.ts +27 -0
- package/dist/builtins/games/trek/context.js +2 -0
- package/dist/builtins/games/trek/context.js.map +1 -0
- package/dist/builtins/games/trek/damage.d.ts +3 -0
- package/dist/builtins/games/trek/damage.js +87 -0
- package/dist/builtins/games/trek/damage.js.map +1 -0
- package/dist/builtins/games/trek/damaged.d.ts +3 -0
- package/dist/builtins/games/trek/damaged.js +58 -0
- package/dist/builtins/games/trek/damaged.js.map +1 -0
- package/dist/builtins/games/trek/dcrept.d.ts +3 -0
- package/dist/builtins/games/trek/dcrept.js +86 -0
- package/dist/builtins/games/trek/dcrept.js.map +1 -0
- package/dist/builtins/games/trek/destruct.d.ts +3 -0
- package/dist/builtins/games/trek/destruct.js +114 -0
- package/dist/builtins/games/trek/destruct.js.map +1 -0
- package/dist/builtins/games/trek/dock.d.ts +5 -0
- package/dist/builtins/games/trek/dock.js +133 -0
- package/dist/builtins/games/trek/dock.js.map +1 -0
- package/dist/builtins/games/trek/dumpgame.d.ts +15 -0
- package/dist/builtins/games/trek/dumpgame.js +29 -0
- package/dist/builtins/games/trek/dumpgame.js.map +1 -0
- package/dist/builtins/games/trek/dumpme.d.ts +3 -0
- package/dist/builtins/games/trek/dumpme.js +81 -0
- package/dist/builtins/games/trek/dumpme.js.map +1 -0
- package/dist/builtins/games/trek/dumpssradio.d.ts +6 -0
- package/dist/builtins/games/trek/dumpssradio.js +72 -0
- package/dist/builtins/games/trek/dumpssradio.js.map +1 -0
- package/dist/builtins/games/trek/events.d.ts +3 -0
- package/dist/builtins/games/trek/events.js +407 -0
- package/dist/builtins/games/trek/events.js.map +1 -0
- package/dist/builtins/games/trek/getcodi.d.ts +14 -0
- package/dist/builtins/games/trek/getcodi.js +24 -0
- package/dist/builtins/games/trek/getcodi.js.map +1 -0
- package/dist/builtins/games/trek/getpar.d.ts +40 -0
- package/dist/builtins/games/trek/getpar.js +174 -0
- package/dist/builtins/games/trek/getpar.js.map +1 -0
- package/dist/builtins/games/trek/help.d.ts +3 -0
- package/dist/builtins/games/trek/help.js +155 -0
- package/dist/builtins/games/trek/help.js.map +1 -0
- package/dist/builtins/games/trek/impulse.d.ts +6 -0
- package/dist/builtins/games/trek/impulse.js +85 -0
- package/dist/builtins/games/trek/impulse.js.map +1 -0
- package/dist/builtins/games/trek/initquad.d.ts +17 -0
- package/dist/builtins/games/trek/initquad.js +79 -0
- package/dist/builtins/games/trek/initquad.js.map +1 -0
- package/dist/builtins/games/trek/io.d.ts +102 -0
- package/dist/builtins/games/trek/io.js +216 -0
- package/dist/builtins/games/trek/io.js.map +1 -0
- package/dist/builtins/games/trek/kill.d.ts +21 -0
- package/dist/builtins/games/trek/kill.js +194 -0
- package/dist/builtins/games/trek/kill.js.map +1 -0
- package/dist/builtins/games/trek/klmove.d.ts +3 -0
- package/dist/builtins/games/trek/klmove.js +181 -0
- package/dist/builtins/games/trek/klmove.js.map +1 -0
- package/dist/builtins/games/trek/lose.d.ts +9 -0
- package/dist/builtins/games/trek/lose.js +36 -0
- package/dist/builtins/games/trek/lose.js.map +1 -0
- package/dist/builtins/games/trek/lrscan.d.ts +3 -0
- package/dist/builtins/games/trek/lrscan.js +96 -0
- package/dist/builtins/games/trek/lrscan.js.map +1 -0
- package/dist/builtins/games/trek/main.d.ts +24 -0
- package/dist/builtins/games/trek/main.js +37 -0
- package/dist/builtins/games/trek/main.js.map +1 -0
- package/dist/builtins/games/trek/move.d.ts +3 -0
- package/dist/builtins/games/trek/move.js +229 -0
- package/dist/builtins/games/trek/move.js.map +1 -0
- package/dist/builtins/games/trek/nova.d.ts +3 -0
- package/dist/builtins/games/trek/nova.js +135 -0
- package/dist/builtins/games/trek/nova.js.map +1 -0
- package/dist/builtins/games/trek/out.d.ts +3 -0
- package/dist/builtins/games/trek/out.js +52 -0
- package/dist/builtins/games/trek/out.js.map +1 -0
- package/dist/builtins/games/trek/phaser.d.ts +3 -0
- package/dist/builtins/games/trek/phaser.js +341 -0
- package/dist/builtins/games/trek/phaser.js.map +1 -0
- package/dist/builtins/games/trek/play.d.ts +3 -0
- package/dist/builtins/games/trek/play.js +112 -0
- package/dist/builtins/games/trek/play.js.map +1 -0
- package/dist/builtins/games/trek/printf.d.ts +31 -0
- package/dist/builtins/games/trek/printf.js +157 -0
- package/dist/builtins/games/trek/printf.js.map +1 -0
- package/dist/builtins/games/trek/ram.d.ts +3 -0
- package/dist/builtins/games/trek/ram.js +97 -0
- package/dist/builtins/games/trek/ram.js.map +1 -0
- package/dist/builtins/games/trek/rand.d.ts +29 -0
- package/dist/builtins/games/trek/rand.js +109 -0
- package/dist/builtins/games/trek/rand.js.map +1 -0
- package/dist/builtins/games/trek/rest.d.ts +3 -0
- package/dist/builtins/games/trek/rest.js +76 -0
- package/dist/builtins/games/trek/rest.js.map +1 -0
- package/dist/builtins/games/trek/schedule.d.ts +23 -0
- package/dist/builtins/games/trek/schedule.js +55 -0
- package/dist/builtins/games/trek/schedule.js.map +1 -0
- package/dist/builtins/games/trek/score.d.ts +8 -0
- package/dist/builtins/games/trek/score.js +61 -0
- package/dist/builtins/games/trek/score.js.map +1 -0
- package/dist/builtins/games/trek/setup.d.ts +18 -0
- package/dist/builtins/games/trek/setup.js +251 -0
- package/dist/builtins/games/trek/setup.js.map +1 -0
- package/dist/builtins/games/trek/setwarp.d.ts +8 -0
- package/dist/builtins/games/trek/setwarp.js +28 -0
- package/dist/builtins/games/trek/setwarp.js.map +1 -0
- package/dist/builtins/games/trek/shield.d.ts +3 -0
- package/dist/builtins/games/trek/shield.js +139 -0
- package/dist/builtins/games/trek/shield.js.map +1 -0
- package/dist/builtins/games/trek/snova.d.ts +3 -0
- package/dist/builtins/games/trek/snova.js +156 -0
- package/dist/builtins/games/trek/snova.js.map +1 -0
- package/dist/builtins/games/trek/srscan.d.ts +3 -0
- package/dist/builtins/games/trek/srscan.js +176 -0
- package/dist/builtins/games/trek/srscan.js.map +1 -0
- package/dist/builtins/games/trek/state.d.ts +190 -0
- package/dist/builtins/games/trek/state.js +84 -0
- package/dist/builtins/games/trek/state.js.map +1 -0
- package/dist/builtins/games/trek/style.d.ts +7 -0
- package/dist/builtins/games/trek/style.js +93 -0
- package/dist/builtins/games/trek/style.js.map +1 -0
- package/dist/builtins/games/trek/systemname.d.ts +10 -0
- package/dist/builtins/games/trek/systemname.js +12 -0
- package/dist/builtins/games/trek/systemname.js.map +1 -0
- package/dist/builtins/games/trek/torped.d.ts +3 -0
- package/dist/builtins/games/trek/torped.js +232 -0
- package/dist/builtins/games/trek/torped.js.map +1 -0
- package/dist/builtins/games/trek/trek.d.ts +27 -0
- package/dist/builtins/games/trek/trek.js +96 -0
- package/dist/builtins/games/trek/trek.js.map +1 -0
- package/dist/builtins/games/trek/visual.d.ts +3 -0
- package/dist/builtins/games/trek/visual.js +87 -0
- package/dist/builtins/games/trek/visual.js.map +1 -0
- package/dist/builtins/games/trek/warp.d.ts +5 -0
- package/dist/builtins/games/trek/warp.js +173 -0
- package/dist/builtins/games/trek/warp.js.map +1 -0
- package/dist/builtins/games/trek/win.d.ts +12 -0
- package/dist/builtins/games/trek/win.js +34 -0
- package/dist/builtins/games/trek/win.js.map +1 -0
- package/dist/builtins/help.js +6 -0
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/net/query.js +11 -2
- package/dist/builtins/net/query.js.map +1 -1
- package/dist/builtins/res/play.js +9 -0
- package/dist/builtins/res/play.js.map +1 -1
- package/dist/core/cancellation.d.ts +7 -0
- package/dist/core/cancellation.js +18 -0
- package/dist/core/cancellation.js.map +1 -1
- package/dist/core/commandOrder.js +3 -3
- package/dist/core/commandOrder.js.map +1 -1
- package/dist/core/coreCommands.js +3 -0
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/engine.d.ts +16 -0
- package/dist/core/engine.js +12 -2
- package/dist/core/engine.js.map +1 -1
- package/dist/core/listing.js +9 -0
- package/dist/core/listing.js.map +1 -1
- package/dist/core/turn.d.ts +50 -0
- package/dist/core/turn.js +60 -0
- package/dist/core/turn.js.map +1 -0
- package/dist/notes.json +1 -1
- package/dist/session/recorder.d.ts +0 -15
- package/dist/session/recorder.js +9 -0
- package/dist/session/recorder.js.map +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* checkcond.ts: a TypeScript port of BSD trek(6), from checkcond.c.
|
|
3
|
+
* Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): checkcond.c 1.7 2009/05/24.
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 1980, 1993
|
|
6
|
+
* The Regents of the University of California. All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
* 3. Neither the name of the University nor the names of its contributors
|
|
17
|
+
* may be used to endorse or promote products derived from this software
|
|
18
|
+
* without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
21
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
23
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
26
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
27
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
28
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
29
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
30
|
+
* SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @file The ship's condition after a move: lost for want of life support,
|
|
35
|
+
* energy or crew; burnt in a supernova; else green, yellow or red.
|
|
36
|
+
*
|
|
37
|
+
* @module
|
|
38
|
+
*/
|
|
39
|
+
import { DOCKED, GREEN, L_NOCREW, L_NOENGY, L_NOLIFE, L_SNOVA, RED, YELLOW } from './consts.js';
|
|
40
|
+
import { autover } from './autover.js';
|
|
41
|
+
import { killd } from './kill.js';
|
|
42
|
+
import { lose } from './lose.js';
|
|
43
|
+
/*
|
|
44
|
+
** Check for Condition After a Move
|
|
45
|
+
**
|
|
46
|
+
** Various ship conditions are checked. First we check
|
|
47
|
+
** to see if we have already lost the game, due to running
|
|
48
|
+
** out of life support reserves, running out of energy,
|
|
49
|
+
** or running out of crew members. The check for running
|
|
50
|
+
** out of time is in events().
|
|
51
|
+
**
|
|
52
|
+
** If we are in automatic override mode (Etc.nkling < 0), we
|
|
53
|
+
** don't want to do anything else, lest we call autover
|
|
54
|
+
** recursively.
|
|
55
|
+
**
|
|
56
|
+
** In the normal case, if there is a supernova, we call
|
|
57
|
+
** autover() to help us escape. If after calling autover()
|
|
58
|
+
** we are still in the grips of a supernova, we get burnt
|
|
59
|
+
** up.
|
|
60
|
+
**
|
|
61
|
+
** If there are no Klingons in this quadrant, we nullify any
|
|
62
|
+
** distress calls which might exist.
|
|
63
|
+
**
|
|
64
|
+
** We then set the condition code, based on the energy level
|
|
65
|
+
** and battle conditions.
|
|
66
|
+
*/
|
|
67
|
+
/** Check for Condition After a Move */
|
|
68
|
+
export async function checkcond(t) {
|
|
69
|
+
/* see if we are still alive and well */
|
|
70
|
+
if (t.s.Ship.reserves < 0.0)
|
|
71
|
+
await lose(t, L_NOLIFE);
|
|
72
|
+
if (t.s.Ship.energy <= 0)
|
|
73
|
+
await lose(t, L_NOENGY);
|
|
74
|
+
if (t.s.Ship.crew <= 0)
|
|
75
|
+
await lose(t, L_NOCREW);
|
|
76
|
+
/* if in auto override mode, ignore the rest */
|
|
77
|
+
if (t.s.Etc.nkling < 0)
|
|
78
|
+
return;
|
|
79
|
+
/* call in automatic override if appropriate */
|
|
80
|
+
if (t.s.Quad[t.s.Ship.quadx][t.s.Ship.quady].stars < 0)
|
|
81
|
+
await autover(t);
|
|
82
|
+
if (t.s.Quad[t.s.Ship.quadx][t.s.Ship.quady].stars < 0)
|
|
83
|
+
await lose(t, L_SNOVA);
|
|
84
|
+
/* nullify distress call if appropriate */
|
|
85
|
+
if (t.s.Etc.nkling <= 0)
|
|
86
|
+
await killd(t, t.s.Ship.quadx, t.s.Ship.quady, 1);
|
|
87
|
+
/* set condition code */
|
|
88
|
+
if (t.s.Ship.cond === DOCKED)
|
|
89
|
+
return;
|
|
90
|
+
if (t.s.Etc.nkling > 0) {
|
|
91
|
+
t.s.Ship.cond = RED;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (t.s.Ship.energy < t.s.Param.energylow) {
|
|
95
|
+
t.s.Ship.cond = YELLOW;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
t.s.Ship.cond = GREEN;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=checkcond.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkcond.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/checkcond.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AAEF,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,CAAO;IACrC,wCAAwC;IACxC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,GAAG;QAAE,MAAM,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC;QAAE,MAAM,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QAAE,MAAM,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAChD,+CAA+C;IAC/C,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO;IAC/B,+CAA+C;IAC/C,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAA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omputed and sorted.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Trek } from './context.js';
|
|
7
|
+
/** Recomputes the Klingon distances and leaves the list sorted. */
|
|
8
|
+
export declare function compkldist(t: Trek, f: number): void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** compute klingon distances
|
|
3
|
+
**
|
|
4
|
+
** The klingon list has the distances for all klingons recomputed
|
|
5
|
+
** and sorted. The parameter is a Boolean flag which is set if
|
|
6
|
+
** we have just entered a new quadrant.
|
|
7
|
+
**
|
|
8
|
+
** This routine is used every time the Enterprise or the Klingons
|
|
9
|
+
** move.
|
|
10
|
+
**
|
|
11
|
+
** f -- set if new quadrant
|
|
12
|
+
*/
|
|
13
|
+
/** Recomputes the Klingon distances and leaves the list sorted. */
|
|
14
|
+
export function compkldist(t, f) {
|
|
15
|
+
const { Ship, Etc } = t.s;
|
|
16
|
+
let dx;
|
|
17
|
+
let dy;
|
|
18
|
+
let d;
|
|
19
|
+
let temp;
|
|
20
|
+
if (Etc.nkling === 0)
|
|
21
|
+
return;
|
|
22
|
+
for (let i = 0; i < Etc.nkling; i++) {
|
|
23
|
+
/* compute distance to the Klingon */
|
|
24
|
+
dx = Ship.sectx - Etc.klingon[i].x;
|
|
25
|
+
dy = Ship.secty - Etc.klingon[i].y;
|
|
26
|
+
d = dx * dx + dy * dy;
|
|
27
|
+
d = Math.sqrt(d);
|
|
28
|
+
/* compute average of new and old distances to Klingon */
|
|
29
|
+
if (!f) {
|
|
30
|
+
temp = Etc.klingon[i].dist;
|
|
31
|
+
Etc.klingon[i].avgdist = 0.5 * (temp + d);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
/* new quadrant: average is current */
|
|
35
|
+
Etc.klingon[i].avgdist = d;
|
|
36
|
+
}
|
|
37
|
+
Etc.klingon[i].dist = d;
|
|
38
|
+
}
|
|
39
|
+
/* leave them sorted */
|
|
40
|
+
sortkl(t);
|
|
41
|
+
}
|
|
42
|
+
/*
|
|
43
|
+
** sort klingons
|
|
44
|
+
**
|
|
45
|
+
** bubble sort on ascending distance
|
|
46
|
+
*/
|
|
47
|
+
/** Bubble sorts the Klingons on ascending distance (a swap of slots, as the C's struct swap). */
|
|
48
|
+
function sortkl(t) {
|
|
49
|
+
const { Etc } = t.s;
|
|
50
|
+
let f;
|
|
51
|
+
let tk;
|
|
52
|
+
const m = Etc.nkling - 1;
|
|
53
|
+
f = 1;
|
|
54
|
+
while (f) {
|
|
55
|
+
f = 0;
|
|
56
|
+
for (let i = 0; i < m; i++) {
|
|
57
|
+
if (Etc.klingon[i].dist > Etc.klingon[i + 1].dist) {
|
|
58
|
+
tk = Etc.klingon[i];
|
|
59
|
+
Etc.klingon[i] = Etc.klingon[i + 1];
|
|
60
|
+
Etc.klingon[i + 1] = tk;
|
|
61
|
+
f = 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=compkl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compkl.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/compkl.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;;;EAWE;AAEF,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,CAAO,EAAE,CAAS;IAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAU,CAAC;IACf,IAAI,EAAU,CAAC;IACf,IAAI,CAAS,CAAC;IACd,IAAI,IAAY,CAAC;IAEjB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC7B,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,qCAAqC;QACrC,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,C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I,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBAClD,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACpB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;gBACxB,CAAC,GAAG,CAAC,CAAC;YACR,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* computer.ts: a TypeScript port of BSD trek(6), from computer.c.
|
|
3
|
+
* Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): computer.c 1.16 2009/08/12.
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 1980, 1993
|
|
6
|
+
* The Regents of the University of California. All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
* 3. Neither the name of the University nor the names of its contributors
|
|
17
|
+
* may be used to endorse or promote products derived from this software
|
|
18
|
+
* without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
21
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
23
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
26
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
27
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
28
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
29
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
30
|
+
* SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @file The on-board computer: star chart, Klingon trajectories, course
|
|
35
|
+
* computation (and the move along it), score, phaser effectiveness, warp
|
|
36
|
+
* and impulse costs, and the list of distress calls.
|
|
37
|
+
*
|
|
38
|
+
* Deviation: the C's request table carries its case number cast into the
|
|
39
|
+
* function slot; here a parallel table holds it.
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
42
|
+
*/
|
|
43
|
+
import { COMPUTER, E_ENSLV, E_EVENT, E_HIDDEN, E_KDESB, E_REPRO, MAXEVENTS, NQUADS, NSECTS, SRSCAN, Systemname } from './consts.js';
|
|
44
|
+
import { check_out } from './check_out.js';
|
|
45
|
+
import { getcodpar, getfltpar, getintpar, readdelim } from './getpar.js';
|
|
46
|
+
import { EOF } from './io.js';
|
|
47
|
+
import { score } from './score.js';
|
|
48
|
+
import { warp } from './warp.js';
|
|
49
|
+
/*
|
|
50
|
+
** On-Board Computer
|
|
51
|
+
**
|
|
52
|
+
** A computer request is fetched from the captain. The requests
|
|
53
|
+
** are:
|
|
54
|
+
**
|
|
55
|
+
** chart -- print a star chart of the known galaxy. This includes
|
|
56
|
+
** every quadrant that has ever had a long range or
|
|
57
|
+
** a short range scan done of it, plus the location of
|
|
58
|
+
** all starbases. This is of course updated by any sub-
|
|
59
|
+
** space radio broadcasts (unless the radio is out).
|
|
60
|
+
** The format is the same as that of a long range scan
|
|
61
|
+
** except that ".1." indicates that a starbase exists
|
|
62
|
+
** but we know nothing else.
|
|
63
|
+
**
|
|
64
|
+
** trajectory -- gives the course and distance to every know
|
|
65
|
+
** Klingon in the quadrant. Obviously this fails if the
|
|
66
|
+
** short range scanners are out.
|
|
67
|
+
**
|
|
68
|
+
** course -- gives a course computation from whereever you are
|
|
69
|
+
** to any specified location. If the course begins
|
|
70
|
+
** with a slash, the current quadrant is taken.
|
|
71
|
+
** Otherwise the input is quadrant and sector coordi-
|
|
72
|
+
** nates of the target sector.
|
|
73
|
+
**
|
|
74
|
+
** move -- identical to course, except that the move is performed.
|
|
75
|
+
**
|
|
76
|
+
** score -- prints out the current score.
|
|
77
|
+
**
|
|
78
|
+
** pheff -- "PHaser EFFectiveness" at a given distance. Tells
|
|
79
|
+
** you how much stuff you need to make it work.
|
|
80
|
+
**
|
|
81
|
+
** warpcost -- Gives you the cost in time and units to move for
|
|
82
|
+
** a given distance under a given warp speed.
|
|
83
|
+
**
|
|
84
|
+
** impcost -- Same for the impulse engines.
|
|
85
|
+
**
|
|
86
|
+
** distresslist -- Gives a list of the currently known starsystems
|
|
87
|
+
** or starbases which are distressed, together with their
|
|
88
|
+
** quadrant coordinates.
|
|
89
|
+
**
|
|
90
|
+
** If a command is terminated with a semicolon, you remain in
|
|
91
|
+
** the computer; otherwise, you escape immediately to the main
|
|
92
|
+
** command processor.
|
|
93
|
+
*/
|
|
94
|
+
/** The request table. */
|
|
95
|
+
const Cputab = [
|
|
96
|
+
{ abbrev: 'ch', full: 'art', value: null, value2: 0 },
|
|
97
|
+
{ abbrev: 't', full: 'rajectory', value: null, value2: 0 },
|
|
98
|
+
{ abbrev: 'c', full: 'ourse', value: null, value2: 0 },
|
|
99
|
+
{ abbrev: 'm', full: 'ove', value: null, value2: 1 },
|
|
100
|
+
{ abbrev: 's', full: 'core', value: null, value2: 0 },
|
|
101
|
+
{ abbrev: 'p', full: 'heff', value: null, value2: 0 },
|
|
102
|
+
{ abbrev: 'w', full: 'arpcost', value: null, value2: 0 },
|
|
103
|
+
{ abbrev: 'i', full: 'mpcost', value: null, value2: 0 },
|
|
104
|
+
{ abbrev: 'd', full: 'istresslist', value: null, value2: 0 },
|
|
105
|
+
];
|
|
106
|
+
/** The C's `(cmdfun)N` of each Cputab entry, in table order. */
|
|
107
|
+
const CPUCASE = [1, 2, 3, 3, 4, 5, 6, 7, 8];
|
|
108
|
+
/** On-board computer. */
|
|
109
|
+
export async function computer(t, _v) {
|
|
110
|
+
const { Ship, Etc, Param } = t.s;
|
|
111
|
+
let ix;
|
|
112
|
+
let iy;
|
|
113
|
+
let i;
|
|
114
|
+
let j;
|
|
115
|
+
let tqx;
|
|
116
|
+
let tqy;
|
|
117
|
+
let cost;
|
|
118
|
+
let course;
|
|
119
|
+
let dist;
|
|
120
|
+
let time;
|
|
121
|
+
let warpfact;
|
|
122
|
+
if (check_out(t, COMPUTER))
|
|
123
|
+
return;
|
|
124
|
+
while (true) {
|
|
125
|
+
const r = await getcodpar(t, '\nRequest', Cputab);
|
|
126
|
+
request: switch (CPUCASE[Cputab.indexOf(r)]) {
|
|
127
|
+
case 1 /* star chart */:
|
|
128
|
+
t.io.printf('Computer record of galaxy for all long range sensor scans\n\n');
|
|
129
|
+
t.io.printf(' ');
|
|
130
|
+
/* print top header */
|
|
131
|
+
for (i = 0; i < NQUADS; i++)
|
|
132
|
+
t.io.printf('-%d- ', i);
|
|
133
|
+
t.io.printf('\n');
|
|
134
|
+
for (i = 0; i < NQUADS; i++) {
|
|
135
|
+
t.io.printf('%d ', i);
|
|
136
|
+
for (j = 0; j < NQUADS; j++) {
|
|
137
|
+
if (i === Ship.quadx && j === Ship.quady) {
|
|
138
|
+
t.io.printf('$$$ ');
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const q = t.s.Quad[i][j];
|
|
142
|
+
/* 1000 or 1001 is special case */
|
|
143
|
+
if (q.scanned >= 1000) {
|
|
144
|
+
if (q.scanned > 1000)
|
|
145
|
+
t.io.printf('.1. ');
|
|
146
|
+
else
|
|
147
|
+
t.io.printf('/// ');
|
|
148
|
+
}
|
|
149
|
+
else if (q.scanned < 0) {
|
|
150
|
+
t.io.printf('... ');
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
t.io.printf('%3d ', q.scanned);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
t.io.printf('%d\n', i);
|
|
157
|
+
}
|
|
158
|
+
t.io.printf(' ');
|
|
159
|
+
/* print bottom footer */
|
|
160
|
+
for (i = 0; i < NQUADS; i++)
|
|
161
|
+
t.io.printf('-%d- ', i);
|
|
162
|
+
t.io.printf('\n');
|
|
163
|
+
break;
|
|
164
|
+
case 2 /* trajectory */:
|
|
165
|
+
if (check_out(t, SRSCAN)) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (Etc.nkling <= 0) {
|
|
169
|
+
t.io.printf('No Klingons in this quadrant\n');
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
/* for each Klingon, give the course & distance */
|
|
173
|
+
for (i = 0; i < Etc.nkling; i++) {
|
|
174
|
+
t.io.printf('Klingon at %d,%d', Etc.klingon[i].x, Etc.klingon[i].y);
|
|
175
|
+
// as the C: the ship's quadrant is passed as the target quadrant
|
|
176
|
+
const calc = kalc(t, Ship.quadx, Ship.quady, Etc.klingon[i].x, Etc.klingon[i].y);
|
|
177
|
+
prkalc(t, calc.course, calc.dist);
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
case 3 /* course calculation */: {
|
|
181
|
+
if (await readdelim(t, 47)) {
|
|
182
|
+
tqx = Ship.quadx;
|
|
183
|
+
tqy = Ship.quady;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
ix = await getintpar(t, 'Quadrant');
|
|
187
|
+
if (ix < 0 || ix >= NSECTS)
|
|
188
|
+
break request;
|
|
189
|
+
iy = await getintpar(t, 'q-y');
|
|
190
|
+
if (iy < 0 || iy >= NSECTS)
|
|
191
|
+
break request;
|
|
192
|
+
tqx = ix;
|
|
193
|
+
tqy = iy;
|
|
194
|
+
}
|
|
195
|
+
ix = await getintpar(t, 'Sector');
|
|
196
|
+
if (ix < 0 || ix >= NSECTS)
|
|
197
|
+
break;
|
|
198
|
+
iy = await getintpar(t, 's-y');
|
|
199
|
+
if (iy < 0 || iy >= NSECTS)
|
|
200
|
+
break;
|
|
201
|
+
const calc = kalc(t, tqx, tqy, ix, iy);
|
|
202
|
+
course = calc.course;
|
|
203
|
+
dist = calc.dist;
|
|
204
|
+
if (r.value2) {
|
|
205
|
+
await warp(t, -1, course, dist);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
t.io.printf('%d,%d/%d,%d to %d,%d/%d,%d', Ship.quadx, Ship.quady, Ship.sectx, Ship.secty, tqx, tqy, ix, iy);
|
|
209
|
+
prkalc(t, course, dist);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case 4 /* score */:
|
|
213
|
+
score(t);
|
|
214
|
+
break;
|
|
215
|
+
case 5 /* phaser effectiveness */:
|
|
216
|
+
dist = await getfltpar(t, 'range');
|
|
217
|
+
if (dist < 0.0)
|
|
218
|
+
break;
|
|
219
|
+
dist *= 10.0;
|
|
220
|
+
cost = Math.trunc(Math.pow(0.90, dist) * 98.0 + 0.5);
|
|
221
|
+
t.io.printf('Phasers are %d%% effective at that range\n', cost);
|
|
222
|
+
break;
|
|
223
|
+
case 6 /* warp cost (time/energy) */:
|
|
224
|
+
dist = await getfltpar(t, 'distance');
|
|
225
|
+
if (dist < 0.0)
|
|
226
|
+
break;
|
|
227
|
+
warpfact = await getfltpar(t, 'warp factor');
|
|
228
|
+
if (warpfact <= 0.0)
|
|
229
|
+
warpfact = Ship.warp;
|
|
230
|
+
cost = Math.trunc((dist + 0.05) * warpfact * warpfact * warpfact);
|
|
231
|
+
time = (Param.warptime * dist) / (warpfact * warpfact);
|
|
232
|
+
t.io.printf('Warp %.2f distance %.2f cost %.2f stardates %d (%d w/ shlds up) units\n', warpfact, dist, time, cost, cost + cost);
|
|
233
|
+
break;
|
|
234
|
+
case 7 /* impulse cost */:
|
|
235
|
+
dist = await getfltpar(t, 'distance');
|
|
236
|
+
if (dist < 0.0)
|
|
237
|
+
break;
|
|
238
|
+
cost = Math.trunc(20 + 100 * dist);
|
|
239
|
+
time = dist / 0.095;
|
|
240
|
+
t.io.printf('Distance %.2f cost %.2f stardates %d units\n', dist, time, cost);
|
|
241
|
+
break;
|
|
242
|
+
case 8 /* distresslist */:
|
|
243
|
+
j = 1;
|
|
244
|
+
t.io.printf('\n');
|
|
245
|
+
/* scan the event list */
|
|
246
|
+
for (i = 0; i < MAXEVENTS; i++) {
|
|
247
|
+
const e = t.s.Event[i];
|
|
248
|
+
/* ignore hidden entries */
|
|
249
|
+
if (e.evcode & E_HIDDEN)
|
|
250
|
+
continue;
|
|
251
|
+
switch (e.evcode & E_EVENT) {
|
|
252
|
+
case E_KDESB:
|
|
253
|
+
t.io.printf('Klingon is attacking starbase in quadrant %d,%d\n', e.x, e.y);
|
|
254
|
+
j = 0;
|
|
255
|
+
break;
|
|
256
|
+
case E_ENSLV:
|
|
257
|
+
case E_REPRO:
|
|
258
|
+
t.io.printf('Starsystem %s in quadrant %d,%d is distressed\n', Systemname[e.systemname], e.x, e.y);
|
|
259
|
+
j = 0;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (j)
|
|
264
|
+
t.io.printf('No known distress calls are active\n');
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
/*
|
|
268
|
+
* Skip to next semicolon or newline. Semicolon
|
|
269
|
+
* means get new computer request; newline means
|
|
270
|
+
* exit computer mode.
|
|
271
|
+
*/
|
|
272
|
+
while ((i = await t.io.getchar()) !== 59) {
|
|
273
|
+
if (i === EOF)
|
|
274
|
+
t.io.exit(1);
|
|
275
|
+
if (i === 10) {
|
|
276
|
+
t.io.ungetc(i);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/*
|
|
283
|
+
** Course Calculation
|
|
284
|
+
**
|
|
285
|
+
** Computes and outputs the course and distance from position
|
|
286
|
+
** sqx,sqy/ssx,ssy to tqx,tqy/tsx,tsy.
|
|
287
|
+
*/
|
|
288
|
+
/** Course calculation: the course (the C's return) and the distance (its out-parameter). */
|
|
289
|
+
function kalc(t, tqx, tqy, tsx, tsy) {
|
|
290
|
+
const { Ship } = t.s;
|
|
291
|
+
let dx;
|
|
292
|
+
/* normalize to quadrant distances */
|
|
293
|
+
const quadsize = NSECTS;
|
|
294
|
+
dx = Ship.quadx + Ship.sectx / quadsize - (tqx + tsx / quadsize);
|
|
295
|
+
const dy = tqy + tsy / quadsize - (Ship.quady + Ship.secty / quadsize);
|
|
296
|
+
/* get the angle */
|
|
297
|
+
let angle = Math.atan2(dy, dx);
|
|
298
|
+
/* make it 0 -> 2 pi */
|
|
299
|
+
if (angle < 0.0)
|
|
300
|
+
angle += 6.283185307;
|
|
301
|
+
/* convert from radians to degrees */
|
|
302
|
+
const course = Math.trunc(angle * 57.29577951 + 0.5);
|
|
303
|
+
dx = dx * dx + dy * dy;
|
|
304
|
+
return { course, dist: Math.sqrt(dx) };
|
|
305
|
+
}
|
|
306
|
+
/** Prints a course and distance. */
|
|
307
|
+
function prkalc(t, course, dist) {
|
|
308
|
+
t.io.printf(': course %d dist %.3f\n', course, dist);
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=computer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,QAAQ,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAC;IACjE,MAAM,EAAE,GAAW,GAAG,GAAG,GAAG,GAAG,QAAQ,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC;IAE/E,mBAAmB;IACnB,IAAI,KAAK,GAAW,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,uBAAuB;IACvB,IAAI,KAAK,GAAG,GAAG;QAAE,KAAK,IAAI,WAAW,CAAC;IACtC,qCAAqC;IACrC,MAAM,MAAM,GAAW,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,WAAW,GAAG,GAAG,CAAC,CAAC;IAC7D,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACzC,CAAC;AAED,oCAAoC;AACpC,SAAS,MAAM,CAAC,CAAO,EAAE,MAAc,EAAE,IAAY;IACnD,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,0BAA0B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file trek's constants: the dimensions, the sector glyphs, the devices,
|
|
3
|
+
* the event codes, the ways to lose, and the tables `externs.c` defines.
|
|
4
|
+
*
|
|
5
|
+
* Names are the C names, so a reader can hold this beside trek.h.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** Dimensions of a quadrant in sectors. */
|
|
10
|
+
export declare const NSECTS: number;
|
|
11
|
+
/** Dimension of the galaxy in quadrants. */
|
|
12
|
+
export declare const NQUADS: number;
|
|
13
|
+
/** Number of quadrants which are inhabited. */
|
|
14
|
+
export declare const NINHAB: number;
|
|
15
|
+
/** Quad.qsystemname flag: a distress call is out for this quadrant. */
|
|
16
|
+
export declare const Q_DISTRESSED: number;
|
|
17
|
+
/** Quad.qsystemname mask: the starsystem's name index. */
|
|
18
|
+
export declare const Q_SYSTEM: number;
|
|
19
|
+
/** Sector contents. */
|
|
20
|
+
export declare const EMPTY: string;
|
|
21
|
+
export declare const STAR: string;
|
|
22
|
+
export declare const BASE: string;
|
|
23
|
+
export declare const ENTERPRISE: string;
|
|
24
|
+
export declare const QUEENE: string;
|
|
25
|
+
export declare const KLINGON: string;
|
|
26
|
+
export declare const INHABIT: string;
|
|
27
|
+
export declare const HOLE: string;
|
|
28
|
+
/** Max number of devices. */
|
|
29
|
+
export declare const NDEV: number;
|
|
30
|
+
export declare const WARP: number;
|
|
31
|
+
export declare const SRSCAN: number;
|
|
32
|
+
export declare const LRSCAN: number;
|
|
33
|
+
export declare const PHASER: number;
|
|
34
|
+
export declare const TORPED: number;
|
|
35
|
+
export declare const IMPULSE: number;
|
|
36
|
+
export declare const SHIELD: number;
|
|
37
|
+
export declare const COMPUTER: number;
|
|
38
|
+
export declare const SSRADIO: number;
|
|
39
|
+
export declare const LIFESUP: number;
|
|
40
|
+
export declare const SINS: number;
|
|
41
|
+
export declare const CLOAK: number;
|
|
42
|
+
export declare const XPORTER: number;
|
|
43
|
+
export declare const SHUTTLE: number;
|
|
44
|
+
/** Number of different event types. */
|
|
45
|
+
export declare const NEVENTS: number;
|
|
46
|
+
export declare const E_LRTB: number;
|
|
47
|
+
export declare const E_KATSB: number;
|
|
48
|
+
export declare const E_KDESB: number;
|
|
49
|
+
export declare const E_ISSUE: number;
|
|
50
|
+
export declare const E_ENSLV: number;
|
|
51
|
+
export declare const E_REPRO: number;
|
|
52
|
+
export declare const E_FIXDV: number;
|
|
53
|
+
export declare const E_ATTACK: number;
|
|
54
|
+
export declare const E_SNAP: number;
|
|
55
|
+
export declare const E_SNOVA: number;
|
|
56
|
+
export declare const E_GHOST: number;
|
|
57
|
+
export declare const E_HIDDEN: number;
|
|
58
|
+
export declare const E_EVENT: number;
|
|
59
|
+
/** Maximum number of pending events. */
|
|
60
|
+
export declare const MAXEVENTS: number;
|
|
61
|
+
/** Maximum Klingons per quadrant. */
|
|
62
|
+
export declare const MAXKLQUAD: number;
|
|
63
|
+
/** Condition codes. */
|
|
64
|
+
export declare const GREEN: number;
|
|
65
|
+
export declare const DOCKED: number;
|
|
66
|
+
export declare const YELLOW: number;
|
|
67
|
+
export declare const RED: number;
|
|
68
|
+
/** Maximum number of starbases in the galaxy. */
|
|
69
|
+
export declare const MAXBASES: number;
|
|
70
|
+
/** Maximum concurrent distress calls. */
|
|
71
|
+
export declare const MAXDISTR: number;
|
|
72
|
+
/** Number of phaser banks. */
|
|
73
|
+
export declare const NBANKS: number;
|
|
74
|
+
/** Klingon move modes. */
|
|
75
|
+
export declare const KM_OB: number;
|
|
76
|
+
export declare const KM_OA: number;
|
|
77
|
+
export declare const KM_EB: number;
|
|
78
|
+
export declare const KM_EA: number;
|
|
79
|
+
export declare const KM_LB: number;
|
|
80
|
+
export declare const KM_LA: number;
|
|
81
|
+
/** Ways to lose. */
|
|
82
|
+
export declare const L_NOTIME: number;
|
|
83
|
+
export declare const L_NOENGY: number;
|
|
84
|
+
export declare const L_DSTRYD: number;
|
|
85
|
+
export declare const L_NEGENB: number;
|
|
86
|
+
export declare const L_SUICID: number;
|
|
87
|
+
export declare const L_SNOVA: number;
|
|
88
|
+
export declare const L_NOLIFE: number;
|
|
89
|
+
export declare const L_NOHELP: number;
|
|
90
|
+
export declare const L_TOOFAST: number;
|
|
91
|
+
export declare const L_STAR: number;
|
|
92
|
+
export declare const L_DSTRCT: number;
|
|
93
|
+
export declare const L_CAPTURED: number;
|
|
94
|
+
export declare const L_NOCREW: number;
|
|
95
|
+
/** Trace compilation option, kept as in the original. */
|
|
96
|
+
export declare const xTRACE: number;
|
|
97
|
+
/** A number larger than any distance: DBL_MAX / 2. */
|
|
98
|
+
export declare const TOOLARGE: number;
|
|
99
|
+
/** The random source's range, as random() returns: 0 .. RANDOM_MAX. */
|
|
100
|
+
export declare const RANDOM_MAX: number;
|
|
101
|
+
/** A device and the person who fixes it. */
|
|
102
|
+
export interface Device {
|
|
103
|
+
name: string;
|
|
104
|
+
person: string;
|
|
105
|
+
}
|
|
106
|
+
/** The devices, by index (externs.c). */
|
|
107
|
+
export declare const Device: ReadonlyArray<Device>;
|
|
108
|
+
/** The inhabited starsystems' names, by index; 0 is the error entry (externs.c). */
|
|
109
|
+
export declare const Systemname: ReadonlyArray<string>;
|