@fnndsc/brasa 0.37.1 → 0.38.1

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.
Files changed (206) hide show
  1. package/NOTICE +48 -0
  2. package/dist/buildinfo.json +1 -1
  3. package/dist/builtins/fs/cp.js +9 -5
  4. package/dist/builtins/fs/cp.js.map +1 -1
  5. package/dist/builtins/fs/destination.d.ts +15 -1
  6. package/dist/builtins/fs/destination.js +35 -2
  7. package/dist/builtins/fs/destination.js.map +1 -1
  8. package/dist/builtins/fs/mv.js +9 -5
  9. package/dist/builtins/fs/mv.js.map +1 -1
  10. package/dist/builtins/fs/rm.js +17 -1
  11. package/dist/builtins/fs/rm.js.map +1 -1
  12. package/dist/builtins/games/lab.js +3 -1
  13. package/dist/builtins/games/lab.js.map +1 -1
  14. package/dist/builtins/games/shelf.js +1 -1
  15. package/dist/builtins/games/shelf.js.map +1 -1
  16. package/dist/builtins/games/stdin.d.ts +0 -13
  17. package/dist/builtins/games/stdin.js +9 -0
  18. package/dist/builtins/games/stdin.js.map +1 -1
  19. package/dist/builtins/games/trek/abandon.d.ts +3 -0
  20. package/dist/builtins/games/trek/abandon.js +159 -0
  21. package/dist/builtins/games/trek/abandon.js.map +1 -0
  22. package/dist/builtins/games/trek/attack.d.ts +3 -0
  23. package/dist/builtins/games/trek/attack.js +185 -0
  24. package/dist/builtins/games/trek/attack.js.map +1 -0
  25. package/dist/builtins/games/trek/autover.d.ts +3 -0
  26. package/dist/builtins/games/trek/autover.js +79 -0
  27. package/dist/builtins/games/trek/autover.js.map +1 -0
  28. package/dist/builtins/games/trek/capture.d.ts +3 -0
  29. package/dist/builtins/games/trek/capture.js +117 -0
  30. package/dist/builtins/games/trek/capture.js.map +1 -0
  31. package/dist/builtins/games/trek/check_out.d.ts +3 -0
  32. package/dist/builtins/games/trek/check_out.js +67 -0
  33. package/dist/builtins/games/trek/check_out.js.map +1 -0
  34. package/dist/builtins/games/trek/checkcond.d.ts +3 -0
  35. package/dist/builtins/games/trek/checkcond.js +101 -0
  36. package/dist/builtins/games/trek/checkcond.js.map +1 -0
  37. package/dist/builtins/games/trek/compkl.d.ts +8 -0
  38. package/dist/builtins/games/trek/compkl.js +66 -0
  39. package/dist/builtins/games/trek/compkl.js.map +1 -0
  40. package/dist/builtins/games/trek/computer.d.ts +3 -0
  41. package/dist/builtins/games/trek/computer.js +310 -0
  42. package/dist/builtins/games/trek/computer.js.map +1 -0
  43. package/dist/builtins/games/trek/consts.d.ts +109 -0
  44. package/dist/builtins/games/trek/consts.js +159 -0
  45. package/dist/builtins/games/trek/consts.js.map +1 -0
  46. package/dist/builtins/games/trek/context.d.ts +27 -0
  47. package/dist/builtins/games/trek/context.js +2 -0
  48. package/dist/builtins/games/trek/context.js.map +1 -0
  49. package/dist/builtins/games/trek/damage.d.ts +3 -0
  50. package/dist/builtins/games/trek/damage.js +87 -0
  51. package/dist/builtins/games/trek/damage.js.map +1 -0
  52. package/dist/builtins/games/trek/damaged.d.ts +3 -0
  53. package/dist/builtins/games/trek/damaged.js +58 -0
  54. package/dist/builtins/games/trek/damaged.js.map +1 -0
  55. package/dist/builtins/games/trek/dcrept.d.ts +3 -0
  56. package/dist/builtins/games/trek/dcrept.js +86 -0
  57. package/dist/builtins/games/trek/dcrept.js.map +1 -0
  58. package/dist/builtins/games/trek/destruct.d.ts +3 -0
  59. package/dist/builtins/games/trek/destruct.js +114 -0
  60. package/dist/builtins/games/trek/destruct.js.map +1 -0
  61. package/dist/builtins/games/trek/dock.d.ts +5 -0
  62. package/dist/builtins/games/trek/dock.js +133 -0
  63. package/dist/builtins/games/trek/dock.js.map +1 -0
  64. package/dist/builtins/games/trek/dumpgame.d.ts +15 -0
  65. package/dist/builtins/games/trek/dumpgame.js +29 -0
  66. package/dist/builtins/games/trek/dumpgame.js.map +1 -0
  67. package/dist/builtins/games/trek/dumpme.d.ts +3 -0
  68. package/dist/builtins/games/trek/dumpme.js +81 -0
  69. package/dist/builtins/games/trek/dumpme.js.map +1 -0
  70. package/dist/builtins/games/trek/dumpssradio.d.ts +6 -0
  71. package/dist/builtins/games/trek/dumpssradio.js +72 -0
  72. package/dist/builtins/games/trek/dumpssradio.js.map +1 -0
  73. package/dist/builtins/games/trek/events.d.ts +3 -0
  74. package/dist/builtins/games/trek/events.js +407 -0
  75. package/dist/builtins/games/trek/events.js.map +1 -0
  76. package/dist/builtins/games/trek/getcodi.d.ts +14 -0
  77. package/dist/builtins/games/trek/getcodi.js +24 -0
  78. package/dist/builtins/games/trek/getcodi.js.map +1 -0
  79. package/dist/builtins/games/trek/getpar.d.ts +40 -0
  80. package/dist/builtins/games/trek/getpar.js +174 -0
  81. package/dist/builtins/games/trek/getpar.js.map +1 -0
  82. package/dist/builtins/games/trek/help.d.ts +3 -0
  83. package/dist/builtins/games/trek/help.js +155 -0
  84. package/dist/builtins/games/trek/help.js.map +1 -0
  85. package/dist/builtins/games/trek/impulse.d.ts +6 -0
  86. package/dist/builtins/games/trek/impulse.js +85 -0
  87. package/dist/builtins/games/trek/impulse.js.map +1 -0
  88. package/dist/builtins/games/trek/initquad.d.ts +17 -0
  89. package/dist/builtins/games/trek/initquad.js +79 -0
  90. package/dist/builtins/games/trek/initquad.js.map +1 -0
  91. package/dist/builtins/games/trek/io.d.ts +102 -0
  92. package/dist/builtins/games/trek/io.js +216 -0
  93. package/dist/builtins/games/trek/io.js.map +1 -0
  94. package/dist/builtins/games/trek/kill.d.ts +21 -0
  95. package/dist/builtins/games/trek/kill.js +194 -0
  96. package/dist/builtins/games/trek/kill.js.map +1 -0
  97. package/dist/builtins/games/trek/klmove.d.ts +3 -0
  98. package/dist/builtins/games/trek/klmove.js +181 -0
  99. package/dist/builtins/games/trek/klmove.js.map +1 -0
  100. package/dist/builtins/games/trek/lose.d.ts +9 -0
  101. package/dist/builtins/games/trek/lose.js +36 -0
  102. package/dist/builtins/games/trek/lose.js.map +1 -0
  103. package/dist/builtins/games/trek/lrscan.d.ts +3 -0
  104. package/dist/builtins/games/trek/lrscan.js +96 -0
  105. package/dist/builtins/games/trek/lrscan.js.map +1 -0
  106. package/dist/builtins/games/trek/main.d.ts +24 -0
  107. package/dist/builtins/games/trek/main.js +37 -0
  108. package/dist/builtins/games/trek/main.js.map +1 -0
  109. package/dist/builtins/games/trek/move.d.ts +3 -0
  110. package/dist/builtins/games/trek/move.js +229 -0
  111. package/dist/builtins/games/trek/move.js.map +1 -0
  112. package/dist/builtins/games/trek/nova.d.ts +3 -0
  113. package/dist/builtins/games/trek/nova.js +135 -0
  114. package/dist/builtins/games/trek/nova.js.map +1 -0
  115. package/dist/builtins/games/trek/out.d.ts +3 -0
  116. package/dist/builtins/games/trek/out.js +52 -0
  117. package/dist/builtins/games/trek/out.js.map +1 -0
  118. package/dist/builtins/games/trek/phaser.d.ts +3 -0
  119. package/dist/builtins/games/trek/phaser.js +341 -0
  120. package/dist/builtins/games/trek/phaser.js.map +1 -0
  121. package/dist/builtins/games/trek/play.d.ts +3 -0
  122. package/dist/builtins/games/trek/play.js +112 -0
  123. package/dist/builtins/games/trek/play.js.map +1 -0
  124. package/dist/builtins/games/trek/printf.d.ts +31 -0
  125. package/dist/builtins/games/trek/printf.js +157 -0
  126. package/dist/builtins/games/trek/printf.js.map +1 -0
  127. package/dist/builtins/games/trek/ram.d.ts +3 -0
  128. package/dist/builtins/games/trek/ram.js +97 -0
  129. package/dist/builtins/games/trek/ram.js.map +1 -0
  130. package/dist/builtins/games/trek/rand.d.ts +29 -0
  131. package/dist/builtins/games/trek/rand.js +109 -0
  132. package/dist/builtins/games/trek/rand.js.map +1 -0
  133. package/dist/builtins/games/trek/rest.d.ts +3 -0
  134. package/dist/builtins/games/trek/rest.js +76 -0
  135. package/dist/builtins/games/trek/rest.js.map +1 -0
  136. package/dist/builtins/games/trek/schedule.d.ts +23 -0
  137. package/dist/builtins/games/trek/schedule.js +55 -0
  138. package/dist/builtins/games/trek/schedule.js.map +1 -0
  139. package/dist/builtins/games/trek/score.d.ts +8 -0
  140. package/dist/builtins/games/trek/score.js +61 -0
  141. package/dist/builtins/games/trek/score.js.map +1 -0
  142. package/dist/builtins/games/trek/setup.d.ts +18 -0
  143. package/dist/builtins/games/trek/setup.js +251 -0
  144. package/dist/builtins/games/trek/setup.js.map +1 -0
  145. package/dist/builtins/games/trek/setwarp.d.ts +8 -0
  146. package/dist/builtins/games/trek/setwarp.js +28 -0
  147. package/dist/builtins/games/trek/setwarp.js.map +1 -0
  148. package/dist/builtins/games/trek/shield.d.ts +3 -0
  149. package/dist/builtins/games/trek/shield.js +139 -0
  150. package/dist/builtins/games/trek/shield.js.map +1 -0
  151. package/dist/builtins/games/trek/snova.d.ts +3 -0
  152. package/dist/builtins/games/trek/snova.js +156 -0
  153. package/dist/builtins/games/trek/snova.js.map +1 -0
  154. package/dist/builtins/games/trek/srscan.d.ts +3 -0
  155. package/dist/builtins/games/trek/srscan.js +176 -0
  156. package/dist/builtins/games/trek/srscan.js.map +1 -0
  157. package/dist/builtins/games/trek/state.d.ts +190 -0
  158. package/dist/builtins/games/trek/state.js +84 -0
  159. package/dist/builtins/games/trek/state.js.map +1 -0
  160. package/dist/builtins/games/trek/style.d.ts +7 -0
  161. package/dist/builtins/games/trek/style.js +93 -0
  162. package/dist/builtins/games/trek/style.js.map +1 -0
  163. package/dist/builtins/games/trek/systemname.d.ts +10 -0
  164. package/dist/builtins/games/trek/systemname.js +12 -0
  165. package/dist/builtins/games/trek/systemname.js.map +1 -0
  166. package/dist/builtins/games/trek/torped.d.ts +3 -0
  167. package/dist/builtins/games/trek/torped.js +232 -0
  168. package/dist/builtins/games/trek/torped.js.map +1 -0
  169. package/dist/builtins/games/trek/trek.d.ts +27 -0
  170. package/dist/builtins/games/trek/trek.js +96 -0
  171. package/dist/builtins/games/trek/trek.js.map +1 -0
  172. package/dist/builtins/games/trek/visual.d.ts +3 -0
  173. package/dist/builtins/games/trek/visual.js +87 -0
  174. package/dist/builtins/games/trek/visual.js.map +1 -0
  175. package/dist/builtins/games/trek/warp.d.ts +5 -0
  176. package/dist/builtins/games/trek/warp.js +173 -0
  177. package/dist/builtins/games/trek/warp.js.map +1 -0
  178. package/dist/builtins/games/trek/win.d.ts +12 -0
  179. package/dist/builtins/games/trek/win.js +34 -0
  180. package/dist/builtins/games/trek/win.js.map +1 -0
  181. package/dist/builtins/help.js +6 -0
  182. package/dist/builtins/help.js.map +1 -1
  183. package/dist/builtins/net/query.js +11 -2
  184. package/dist/builtins/net/query.js.map +1 -1
  185. package/dist/builtins/res/play.js +9 -0
  186. package/dist/builtins/res/play.js.map +1 -1
  187. package/dist/core/cancellation.d.ts +7 -0
  188. package/dist/core/cancellation.js +18 -0
  189. package/dist/core/cancellation.js.map +1 -1
  190. package/dist/core/commandOrder.js +3 -3
  191. package/dist/core/commandOrder.js.map +1 -1
  192. package/dist/core/coreCommands.js +3 -0
  193. package/dist/core/coreCommands.js.map +1 -1
  194. package/dist/core/engine.d.ts +16 -0
  195. package/dist/core/engine.js +12 -2
  196. package/dist/core/engine.js.map +1 -1
  197. package/dist/core/listing.js +9 -0
  198. package/dist/core/listing.js.map +1 -1
  199. package/dist/core/turn.d.ts +50 -0
  200. package/dist/core/turn.js +60 -0
  201. package/dist/core/turn.js.map +1 -0
  202. package/dist/notes.json +1 -1
  203. package/dist/session/recorder.d.ts +0 -15
  204. package/dist/session/recorder.js +9 -0
  205. package/dist/session/recorder.js.map +1 -1
  206. package/package.json +7 -6
@@ -0,0 +1,159 @@
1
+ /*
2
+ * consts.ts: a TypeScript port of BSD trek(6), from trek.h, externs.c.
3
+ * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): trek.h 1.19 2024/02/10; externs.c 1.10 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 trek's constants: the dimensions, the sector glyphs, the devices,
35
+ * the event codes, the ways to lose, and the tables `externs.c` defines.
36
+ *
37
+ * Names are the C names, so a reader can hold this beside trek.h.
38
+ *
39
+ * @module
40
+ */
41
+ /** Dimensions of a quadrant in sectors. */
42
+ export const NSECTS = 10;
43
+ /** Dimension of the galaxy in quadrants. */
44
+ export const NQUADS = 8;
45
+ /** Number of quadrants which are inhabited. */
46
+ export const NINHAB = 32;
47
+ /** Quad.qsystemname flag: a distress call is out for this quadrant. */
48
+ export const Q_DISTRESSED = 0o200;
49
+ /** Quad.qsystemname mask: the starsystem's name index. */
50
+ export const Q_SYSTEM = 0o77;
51
+ /** Sector contents. */
52
+ export const EMPTY = '.';
53
+ export const STAR = '*';
54
+ export const BASE = '#';
55
+ export const ENTERPRISE = 'E';
56
+ export const QUEENE = 'Q';
57
+ export const KLINGON = 'K';
58
+ export const INHABIT = '@';
59
+ export const HOLE = ' ';
60
+ /** Max number of devices. */
61
+ export const NDEV = 16;
62
+ export const WARP = 0;
63
+ export const SRSCAN = 1;
64
+ export const LRSCAN = 2;
65
+ export const PHASER = 3;
66
+ export const TORPED = 4;
67
+ export const IMPULSE = 5;
68
+ export const SHIELD = 6;
69
+ export const COMPUTER = 7;
70
+ export const SSRADIO = 8;
71
+ export const LIFESUP = 9;
72
+ export const SINS = 10;
73
+ export const CLOAK = 11;
74
+ export const XPORTER = 12;
75
+ export const SHUTTLE = 13;
76
+ /** Number of different event types. */
77
+ export const NEVENTS = 12;
78
+ export const E_LRTB = 1;
79
+ export const E_KATSB = 2;
80
+ export const E_KDESB = 3;
81
+ export const E_ISSUE = 4;
82
+ export const E_ENSLV = 5;
83
+ export const E_REPRO = 6;
84
+ export const E_FIXDV = 7;
85
+ export const E_ATTACK = 8;
86
+ export const E_SNAP = 9;
87
+ export const E_SNOVA = 10;
88
+ export const E_GHOST = 0o100;
89
+ export const E_HIDDEN = 0o200;
90
+ export const E_EVENT = 0o77;
91
+ /** Maximum number of pending events. */
92
+ export const MAXEVENTS = 25;
93
+ /** Maximum Klingons per quadrant. */
94
+ export const MAXKLQUAD = 9;
95
+ /** Condition codes. */
96
+ export const GREEN = 0;
97
+ export const DOCKED = 1;
98
+ export const YELLOW = 2;
99
+ export const RED = 3;
100
+ /** Maximum number of starbases in the galaxy. */
101
+ export const MAXBASES = 9;
102
+ /** Maximum concurrent distress calls. */
103
+ export const MAXDISTR = 5;
104
+ /** Number of phaser banks. */
105
+ export const NBANKS = 6;
106
+ /** Klingon move modes. */
107
+ export const KM_OB = 0;
108
+ export const KM_OA = 1;
109
+ export const KM_EB = 2;
110
+ export const KM_EA = 3;
111
+ export const KM_LB = 4;
112
+ export const KM_LA = 5;
113
+ /** Ways to lose. */
114
+ export const L_NOTIME = 1;
115
+ export const L_NOENGY = 2;
116
+ export const L_DSTRYD = 3;
117
+ export const L_NEGENB = 4;
118
+ export const L_SUICID = 5;
119
+ export const L_SNOVA = 6;
120
+ export const L_NOLIFE = 7;
121
+ export const L_NOHELP = 8;
122
+ export const L_TOOFAST = 9;
123
+ export const L_STAR = 10;
124
+ export const L_DSTRCT = 11;
125
+ export const L_CAPTURED = 12;
126
+ export const L_NOCREW = 13;
127
+ /** Trace compilation option, kept as in the original. */
128
+ export const xTRACE = 1;
129
+ /** A number larger than any distance: DBL_MAX / 2. */
130
+ export const TOOLARGE = Number.MAX_VALUE / 2;
131
+ /** The random source's range, as random() returns: 0 .. RANDOM_MAX. */
132
+ export const RANDOM_MAX = 0x7fffffff;
133
+ /** The devices, by index (externs.c). */
134
+ export const Device = [
135
+ { name: 'warp drive', person: 'Scotty' },
136
+ { name: 'S.R. scanners', person: 'Scotty' },
137
+ { name: 'L.R. scanners', person: 'Scotty' },
138
+ { name: 'phasers', person: 'Sulu' },
139
+ { name: 'photon tubes', person: 'Sulu' },
140
+ { name: 'impulse engines', person: 'Scotty' },
141
+ { name: 'shield control', person: 'Sulu' },
142
+ { name: 'computer', person: 'Spock' },
143
+ { name: 'subspace radio', person: 'Uhura' },
144
+ { name: 'life support', person: 'Scotty' },
145
+ { name: 'navigation system', person: 'Chekov' },
146
+ { name: 'cloaking device', person: 'Scotty' },
147
+ { name: 'transporter', person: 'Scotty' },
148
+ { name: 'shuttlecraft', person: 'Scotty' },
149
+ { name: '*ERR 14*', person: 'Nobody' },
150
+ { name: '*ERR 15*', person: 'Nobody' },
151
+ ];
152
+ /** The inhabited starsystems' names, by index; 0 is the error entry (externs.c). */
153
+ export const Systemname = [
154
+ 'ERROR', 'Talos IV', 'Rigel III', 'Deneb VII', 'Canopus V', 'Icarus I', 'Prometheus II', 'Omega VII',
155
+ 'Elysium I', 'Scalos IV', 'Procyon IV', 'Arachnid I', 'Argo VIII', 'Triad III', 'Echo IV', 'Nimrod III',
156
+ 'Nemisis IV', 'Centarurus I', 'Kronos III', 'Spectros V', 'Beta III', 'Gamma Tranguli VI', 'Pyris III', 'Triachus',
157
+ 'Marcus XII', 'Kaland', 'Ardana', 'Stratos', 'Eden', 'Arrikis', 'Epsilon Eridani IV', 'Exo III',
158
+ ];
159
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/consts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;;;GAOG;AAEH,2CAA2C;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAW,EAAE,CAAC;AACjC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAW,CAAC,CAAC;AAChC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,MAAM,GAAW,EAAE,CAAC;AAEjC,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAW,KAAK,CAAC;AAC1C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAW,IAAI,CAAC;AAErC,uBAAuB;AACvB,MAAM,CAAC,MAAM,KAAK,GAAW,GAAG,CAAC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAW,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAW,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAW,GAAG,CAAC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAW,GAAG,CAAC;AAClC,MAAM,CAAC,MAAM,OAAO,GAAW,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,OAAO,GAAW,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,IAAI,GAAW,GAAG,CAAC;AAEhC,6BAA6B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EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE;IAC3C,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC1C,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC/C,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC7C,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE;IACzC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC1C,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACvC,CAAC;AAEF,oFAAoF;AACpF,MAAM,CAAC,MAAM,UAAU,GAA0B;IAC/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW;IACpG,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY;IACvG,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU;IAClH,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,SAAS;CAChG,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @file One game of trek: its state, its terminal and its random source,
3
+ * handed to every routine as `t` (the C kept all three global).
4
+ *
5
+ * @module
6
+ */
7
+ import type { TrekIO } from './io.js';
8
+ import type { TrekRandom } from './rand.js';
9
+ import type { TrekState } from './state.js';
10
+ /** One game. */
11
+ export interface Trek {
12
+ /** The game's state (the C's globals). */
13
+ s: TrekState;
14
+ /** Its terminal. */
15
+ io: TrekIO;
16
+ /** Its random source. */
17
+ rnd: TrekRandom;
18
+ /** Where `dump` keeps a game for `restart`: the C's trek.dump file, held by the session. */
19
+ dump: TrekDump;
20
+ }
21
+ /** The saved game slot. */
22
+ export interface TrekDump {
23
+ /** The saved game, or null when none was dumped. */
24
+ saved: object | null;
25
+ }
26
+ /** A command routine, as Comtab and the other conversion tables hold them: `void f(int)` in C. */
27
+ export type CmdFun = (t: Trek, v: number) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { Trek } from './context.js';
2
+ /** Schedule Ship.damages to a Device */
3
+ export declare function damage(t: Trek, dev1: number, dam: number): Promise<void>;
@@ -0,0 +1,87 @@
1
+ /*
2
+ * damage.ts: a TypeScript port of BSD trek(6), from damage.c.
3
+ * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): damage.c 1.8 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 Damage to a device: a repair scheduled, or added to the one
35
+ * already waiting.
36
+ *
37
+ * @module
38
+ */
39
+ import { Device, DOCKED, E_FIXDV, MAXEVENTS } from './consts.js';
40
+ import { damaged } from './damaged.js';
41
+ import { reschedule, schedule } from './schedule.js';
42
+ /*
43
+ ** Schedule Ship.damages to a Device
44
+ **
45
+ ** Device `dev1' is damaged in an amount `dam'. Dam is measured
46
+ ** in stardates, and is an additional amount of damage. It should
47
+ ** be the amount to occur in non-docked mode. The adjustment
48
+ ** to docked mode occurs automatically if we are docked.
49
+ **
50
+ ** Note that the repair of the device occurs on a DATE, meaning
51
+ ** that the dock() and undock() have to reschedule the event.
52
+ **
53
+ ** dev1 -- device index
54
+ ** dam -- time to repair
55
+ */
56
+ /** Schedule Ship.damages to a Device */
57
+ export async function damage(t, dev1, dam) {
58
+ let e;
59
+ /* ignore zero damages */
60
+ if (dam <= 0.0)
61
+ return;
62
+ const dev = dev1;
63
+ t.io.printf('\t%s damaged\n', Device[dev].name);
64
+ /* find actual length till it will be fixed */
65
+ if (t.s.Ship.cond === DOCKED)
66
+ dam *= t.s.Param.dockfac;
67
+ /* set the damage flag */
68
+ const f = damaged(t, dev);
69
+ if (!f) {
70
+ /* new damages -- schedule a fix */
71
+ schedule(t, E_FIXDV, dam, 0, 0, dev);
72
+ return;
73
+ }
74
+ /* device already damaged -- add to existing damages */
75
+ /* scan for old damages */
76
+ for (let i = 0; i < MAXEVENTS; i++) {
77
+ e = t.s.Event[i];
78
+ if (e.evcode !== E_FIXDV || e.systemname !== dev)
79
+ continue;
80
+ /* got the right one; add on the new damages */
81
+ reschedule(t, i, e.date - t.s.Now.date + dam);
82
+ return;
83
+ }
84
+ t.io.printf('trek: Cannot find old damages %d\n', dev);
85
+ t.io.exit(1);
86
+ }
87
+ //# sourceMappingURL=damage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"damage.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/damage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;;;;;;;;;EAaE;AAEF,wCAAwC;AACxC,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,CAAO,EAAE,IAAY,EAAE,GAAW;IAC7D,IAAI,CAAY,CAAC;IAEjB,yBAAyB;IACzB,IAAI,GAAG,IAAI,GAAG;QAAE,OAAO;IACvB,MAAM,GAAG,GAAW,IAAI,CAAC;IAEzB,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAG,MAAM,CAAC,GAAG,CAAY,CAAC,IAAI,CAAC,CAAC;IAE5D,8CAA8C;IAC9C,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IACvD,yBAAyB;IACzB,MAAM,CAAC,GAAW,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,mCAAmC;QACnC,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IACD,uDAAuD;IACvD,0BAA0B;IAC1B,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAc,CAAC;QAC9B,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,UAAU,KAAK,GAAG;YAAE,SAAS;QAC3D,+CAA+C;QAC/C,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IACD,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Trek } from './context.js';
2
+ /** DAMAGED -- check for device damaged */
3
+ export declare function damaged(t: Trek, dev: number): number;
@@ -0,0 +1,58 @@
1
+ /*
2
+ * damaged.ts: a TypeScript port of BSD trek(6), from damaged.c.
3
+ * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): damaged.c 1.8 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 Whether a device is broken: a repair for it is on the event list.
35
+ *
36
+ * @module
37
+ */
38
+ import { E_FIXDV, MAXEVENTS } from './consts.js';
39
+ /* DAMAGED -- check for device damaged
40
+ **
41
+ ** This is a boolean function which returns non-zero if the
42
+ ** specified device is broken. It does this by checking the
43
+ ** event list for a "device fix" action on that device.
44
+ */
45
+ /** DAMAGED -- check for device damaged */
46
+ export function damaged(t, dev) {
47
+ const d = dev;
48
+ for (let i = 0; i < MAXEVENTS; i++) {
49
+ const e = t.s.Event[i];
50
+ if (e.evcode !== E_FIXDV)
51
+ continue;
52
+ if (e.systemname === d)
53
+ return 1;
54
+ }
55
+ /* device fix not in event list -- device must not be broken */
56
+ return 0;
57
+ }
58
+ //# sourceMappingURL=damaged.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"damaged.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/damaged.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIjD;;;;;EAKE;AAEF,0CAA0C;AAC1C,MAAM,UAAU,OAAO,CAAC,CAAO,EAAE,GAAW;IAC1C,MAAM,CAAC,GAAW,GAAG,CAAC;IAEtB,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAc,CAAC;QAC/C,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO;YAAE,SAAS;QACnC,IAAI,CAAC,CAAC,UAAU,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,+DAA+D;IAC/D,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Trek } from './context.js';
2
+ /** damage control report */
3
+ export declare function dcrept(t: Trek, _v: number): Promise<void>;
@@ -0,0 +1,86 @@
1
+ /*
2
+ * dcrept.ts: a TypeScript port of BSD trek(6), from dcrept.c.
3
+ * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): dcrept.c 1.11 2022/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 damage control report: each broken device and its repair
35
+ * time in flight and docked.
36
+ *
37
+ * @module
38
+ */
39
+ import { Device, DOCKED, E_FIXDV, MAXEVENTS } from './consts.js';
40
+ /*
41
+ ** damage control report
42
+ **
43
+ ** Print damages and time to fix. This is taken from the event
44
+ ** list. A couple of factors are set up, based on whether or not
45
+ ** we are docked. (One of these factors will always be 1.0.)
46
+ ** The event list is then scanned for damage fix events, the
47
+ ** time until they occur is determined, and printed out. The
48
+ ** magic number DAMFAC is used to tell how much faster you can
49
+ ** fix things if you are docked.
50
+ */
51
+ /** damage control report */
52
+ export async function dcrept(t, _v) {
53
+ let m1;
54
+ let m2;
55
+ /* set up the magic factors to output the time till fixed */
56
+ if (t.s.Ship.cond === DOCKED) {
57
+ m1 = 1.0 / t.s.Param.dockfac;
58
+ m2 = 1.0;
59
+ }
60
+ else {
61
+ m1 = 1.0;
62
+ m2 = t.s.Param.dockfac;
63
+ }
64
+ t.io.printf('Damage control report:\n');
65
+ let f = 1;
66
+ /* scan for damages */
67
+ for (let i = 0; i < MAXEVENTS; i++) {
68
+ const e = t.s.Event[i];
69
+ if (e.evcode !== E_FIXDV)
70
+ continue;
71
+ /* output the title first time */
72
+ if (f) {
73
+ t.io.printf('\t\t\t repair times\n');
74
+ t.io.printf('device\t\t\tin flight docked\n');
75
+ f = 0;
76
+ }
77
+ /* compute time till fixed, then adjust by the magic factors */
78
+ const x = e.date - t.s.Now.date;
79
+ t.io.printf('%-24s%7.2f %7.2f\n', Device[e.systemname].name, x * m1 + 0.005, x * m2 + 0.005);
80
+ /* do a little consistency checking */
81
+ }
82
+ /* if everything was ok, reassure the nervous captain */
83
+ if (f)
84
+ t.io.printf('All devices functional\n');
85
+ }
86
+ //# sourceMappingURL=dcrept.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dcrept.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/dcrept.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIjE;;;;;;;;;;EAUE;AAEF,4BAA4B;AAC5B,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,CAAO,EAAE,E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C;QAE1G,sCAAsC;IACxC,CAAC;IAED,wDAAwD;IACxD,IAAI,CAAC;QAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Trek } from './context.js';
2
+ /** Self Destruct Sequence */
3
+ export declare function destruct(t: Trek, _v: number): Promise<void>;
@@ -0,0 +1,114 @@
1
+ /*
2
+ * destruct.ts: a TypeScript port of BSD trek(6), from destruct.c.
3
+ * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): destruct.c 1.10 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 self destruct sequence: a countdown, the game's password, and
35
+ * whatever is near enough to go up with the ship.
36
+ *
37
+ * @module
38
+ */
39
+ import { COMPUTER, L_DSTRCT } from './consts.js';
40
+ import { damaged } from './damaged.js';
41
+ import { getstrpar, skiptonl } from './getpar.js';
42
+ import { killk } from './kill.js';
43
+ import { lose } from './lose.js';
44
+ import { out } from './out.js';
45
+ /*
46
+ ** Self Destruct Sequence
47
+ **
48
+ ** The computer starts up the self destruct sequence. Obviously,
49
+ ** if the computer is out nothing can happen. You get a countdown
50
+ ** and a request for password. This must match the password that
51
+ ** you entered at the start of the game.
52
+ **
53
+ ** You get to destroy things when you blow up; hence, it is
54
+ ** possible to win the game by destructing if you take the last
55
+ ** Klingon with you.
56
+ **
57
+ ** By the way, the \032 in the message is a ^Z, which is because
58
+ ** the terminal in my office is an ADM-3, which uses that char-
59
+ ** acter to clear the screen. I also stick in a \014 (form feed)
60
+ ** because that clears some other screens.
61
+ **
62
+ ** Uses trace flag 41
63
+ */
64
+ /** Self Destruct Sequence */
65
+ export async function destruct(t, _v) {
66
+ let i;
67
+ if (damaged(t, COMPUTER)) {
68
+ await out(t, COMPUTER);
69
+ return;
70
+ }
71
+ t.io.printf('\n\x07 --- WORKING ---\x07\n');
72
+ await t.io.sleep(3);
73
+ /* output the count 10 9 8 7 6 */
74
+ for (i = 10; i > 5; i--) {
75
+ for (let j = 10; j > i; j--)
76
+ t.io.printf(' ');
77
+ t.io.printf('%d\n', i);
78
+ await t.io.sleep(1);
79
+ }
80
+ /* check for password on new line only */
81
+ await skiptonl(t, 0);
82
+ const checkpass = await getstrpar(t, 'Enter password verification', 14, null);
83
+ await t.io.sleep(2);
84
+ if (checkpass !== t.s.Game.passwd) {
85
+ t.io.printf('Self destruct sequence aborted\n');
86
+ return;
87
+ }
88
+ t.io.printf('Password verified; self destruct sequence continues:\n');
89
+ await t.io.sleep(2);
90
+ /* output count 5 4 3 2 1 0 */
91
+ for (i = 5; i >= 0; i--) {
92
+ await t.io.sleep(1);
93
+ for (let j = 5; j > i; j--)
94
+ t.io.printf(' ');
95
+ t.io.printf('%d\n', i);
96
+ }
97
+ await t.io.sleep(2);
98
+ t.io.printf('\x1a\x0c***** %s destroyed *****\n', t.s.Ship.shipname);
99
+ t.s.Game.killed = 1;
100
+ /* let's see what we can blow up!!!! */
101
+ const zap = 20.0 * t.s.Ship.energy;
102
+ t.s.Game.deaths += t.s.Ship.crew;
103
+ for (i = 0; i < t.s.Etc.nkling;) {
104
+ const k = t.s.Etc.klingon[i];
105
+ if (k.power * k.dist <= zap)
106
+ await killk(t, k.x, k.y);
107
+ else
108
+ i++;
109
+ }
110
+ /* if we didn't kill the last Klingon (detected by killk), */
111
+ /* then we lose.... */
112
+ await lose(t, L_DSTRCT);
113
+ }
114
+ //# sourceMappingURL=destruct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destruct.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/destruct.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B;;;;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,CAAC,CAAC,CAAC,CAAC;;YACjD,CAAC,EAAE,CAAC;IACX,CAAC;IACD,6DAA6D;IAC7D,sBAAsB;IACtB,MAAM,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Trek } from './context.js';
2
+ /** The dock command. */
3
+ export declare function dock(t: Trek, _v: number): Promise<void>;
4
+ /** The undock command. */
5
+ export declare function undock(t: Trek, _v: number): Promise<void>;