@fnndsc/brasa 0.43.0 → 0.43.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 (171) hide show
  1. package/dist/buildinfo.json +1 -1
  2. package/dist/builtins/games/trek.d.ts +8 -0
  3. package/dist/builtins/games/trek.js +50 -0
  4. package/dist/builtins/games/trek.js.map +1 -0
  5. package/dist/core/coreCommands.js +1 -1
  6. package/dist/core/coreCommands.js.map +1 -1
  7. package/dist/notes.json +1 -1
  8. package/package.json +3 -3
  9. package/NOTICE +0 -48
  10. package/dist/builtins/games/trek/abandon.d.ts +0 -3
  11. package/dist/builtins/games/trek/abandon.js +0 -159
  12. package/dist/builtins/games/trek/abandon.js.map +0 -1
  13. package/dist/builtins/games/trek/attack.d.ts +0 -3
  14. package/dist/builtins/games/trek/attack.js +0 -185
  15. package/dist/builtins/games/trek/attack.js.map +0 -1
  16. package/dist/builtins/games/trek/autover.d.ts +0 -3
  17. package/dist/builtins/games/trek/autover.js +0 -79
  18. package/dist/builtins/games/trek/autover.js.map +0 -1
  19. package/dist/builtins/games/trek/capture.d.ts +0 -3
  20. package/dist/builtins/games/trek/capture.js +0 -117
  21. package/dist/builtins/games/trek/capture.js.map +0 -1
  22. package/dist/builtins/games/trek/check_out.d.ts +0 -3
  23. package/dist/builtins/games/trek/check_out.js +0 -67
  24. package/dist/builtins/games/trek/check_out.js.map +0 -1
  25. package/dist/builtins/games/trek/checkcond.d.ts +0 -3
  26. package/dist/builtins/games/trek/checkcond.js +0 -101
  27. package/dist/builtins/games/trek/checkcond.js.map +0 -1
  28. package/dist/builtins/games/trek/compkl.d.ts +0 -8
  29. package/dist/builtins/games/trek/compkl.js +0 -66
  30. package/dist/builtins/games/trek/compkl.js.map +0 -1
  31. package/dist/builtins/games/trek/computer.d.ts +0 -3
  32. package/dist/builtins/games/trek/computer.js +0 -310
  33. package/dist/builtins/games/trek/computer.js.map +0 -1
  34. package/dist/builtins/games/trek/consts.d.ts +0 -109
  35. package/dist/builtins/games/trek/consts.js +0 -159
  36. package/dist/builtins/games/trek/consts.js.map +0 -1
  37. package/dist/builtins/games/trek/context.d.ts +0 -27
  38. package/dist/builtins/games/trek/context.js +0 -2
  39. package/dist/builtins/games/trek/context.js.map +0 -1
  40. package/dist/builtins/games/trek/damage.d.ts +0 -3
  41. package/dist/builtins/games/trek/damage.js +0 -87
  42. package/dist/builtins/games/trek/damage.js.map +0 -1
  43. package/dist/builtins/games/trek/damaged.d.ts +0 -3
  44. package/dist/builtins/games/trek/damaged.js +0 -58
  45. package/dist/builtins/games/trek/damaged.js.map +0 -1
  46. package/dist/builtins/games/trek/dcrept.d.ts +0 -3
  47. package/dist/builtins/games/trek/dcrept.js +0 -86
  48. package/dist/builtins/games/trek/dcrept.js.map +0 -1
  49. package/dist/builtins/games/trek/destruct.d.ts +0 -3
  50. package/dist/builtins/games/trek/destruct.js +0 -114
  51. package/dist/builtins/games/trek/destruct.js.map +0 -1
  52. package/dist/builtins/games/trek/dock.d.ts +0 -5
  53. package/dist/builtins/games/trek/dock.js +0 -133
  54. package/dist/builtins/games/trek/dock.js.map +0 -1
  55. package/dist/builtins/games/trek/dumpgame.d.ts +0 -15
  56. package/dist/builtins/games/trek/dumpgame.js +0 -29
  57. package/dist/builtins/games/trek/dumpgame.js.map +0 -1
  58. package/dist/builtins/games/trek/dumpme.d.ts +0 -3
  59. package/dist/builtins/games/trek/dumpme.js +0 -81
  60. package/dist/builtins/games/trek/dumpme.js.map +0 -1
  61. package/dist/builtins/games/trek/dumpssradio.d.ts +0 -6
  62. package/dist/builtins/games/trek/dumpssradio.js +0 -72
  63. package/dist/builtins/games/trek/dumpssradio.js.map +0 -1
  64. package/dist/builtins/games/trek/events.d.ts +0 -3
  65. package/dist/builtins/games/trek/events.js +0 -407
  66. package/dist/builtins/games/trek/events.js.map +0 -1
  67. package/dist/builtins/games/trek/getcodi.d.ts +0 -14
  68. package/dist/builtins/games/trek/getcodi.js +0 -24
  69. package/dist/builtins/games/trek/getcodi.js.map +0 -1
  70. package/dist/builtins/games/trek/getpar.d.ts +0 -40
  71. package/dist/builtins/games/trek/getpar.js +0 -174
  72. package/dist/builtins/games/trek/getpar.js.map +0 -1
  73. package/dist/builtins/games/trek/help.d.ts +0 -3
  74. package/dist/builtins/games/trek/help.js +0 -155
  75. package/dist/builtins/games/trek/help.js.map +0 -1
  76. package/dist/builtins/games/trek/impulse.d.ts +0 -6
  77. package/dist/builtins/games/trek/impulse.js +0 -85
  78. package/dist/builtins/games/trek/impulse.js.map +0 -1
  79. package/dist/builtins/games/trek/initquad.d.ts +0 -17
  80. package/dist/builtins/games/trek/initquad.js +0 -79
  81. package/dist/builtins/games/trek/initquad.js.map +0 -1
  82. package/dist/builtins/games/trek/io.d.ts +0 -102
  83. package/dist/builtins/games/trek/io.js +0 -216
  84. package/dist/builtins/games/trek/io.js.map +0 -1
  85. package/dist/builtins/games/trek/kill.d.ts +0 -21
  86. package/dist/builtins/games/trek/kill.js +0 -194
  87. package/dist/builtins/games/trek/kill.js.map +0 -1
  88. package/dist/builtins/games/trek/klmove.d.ts +0 -3
  89. package/dist/builtins/games/trek/klmove.js +0 -181
  90. package/dist/builtins/games/trek/klmove.js.map +0 -1
  91. package/dist/builtins/games/trek/lose.d.ts +0 -9
  92. package/dist/builtins/games/trek/lose.js +0 -36
  93. package/dist/builtins/games/trek/lose.js.map +0 -1
  94. package/dist/builtins/games/trek/lrscan.d.ts +0 -3
  95. package/dist/builtins/games/trek/lrscan.js +0 -96
  96. package/dist/builtins/games/trek/lrscan.js.map +0 -1
  97. package/dist/builtins/games/trek/main.d.ts +0 -24
  98. package/dist/builtins/games/trek/main.js +0 -37
  99. package/dist/builtins/games/trek/main.js.map +0 -1
  100. package/dist/builtins/games/trek/move.d.ts +0 -3
  101. package/dist/builtins/games/trek/move.js +0 -229
  102. package/dist/builtins/games/trek/move.js.map +0 -1
  103. package/dist/builtins/games/trek/nova.d.ts +0 -3
  104. package/dist/builtins/games/trek/nova.js +0 -135
  105. package/dist/builtins/games/trek/nova.js.map +0 -1
  106. package/dist/builtins/games/trek/out.d.ts +0 -3
  107. package/dist/builtins/games/trek/out.js +0 -52
  108. package/dist/builtins/games/trek/out.js.map +0 -1
  109. package/dist/builtins/games/trek/phaser.d.ts +0 -3
  110. package/dist/builtins/games/trek/phaser.js +0 -341
  111. package/dist/builtins/games/trek/phaser.js.map +0 -1
  112. package/dist/builtins/games/trek/play.d.ts +0 -3
  113. package/dist/builtins/games/trek/play.js +0 -112
  114. package/dist/builtins/games/trek/play.js.map +0 -1
  115. package/dist/builtins/games/trek/printf.d.ts +0 -31
  116. package/dist/builtins/games/trek/printf.js +0 -157
  117. package/dist/builtins/games/trek/printf.js.map +0 -1
  118. package/dist/builtins/games/trek/ram.d.ts +0 -3
  119. package/dist/builtins/games/trek/ram.js +0 -97
  120. package/dist/builtins/games/trek/ram.js.map +0 -1
  121. package/dist/builtins/games/trek/rand.d.ts +0 -29
  122. package/dist/builtins/games/trek/rand.js +0 -109
  123. package/dist/builtins/games/trek/rand.js.map +0 -1
  124. package/dist/builtins/games/trek/rest.d.ts +0 -3
  125. package/dist/builtins/games/trek/rest.js +0 -76
  126. package/dist/builtins/games/trek/rest.js.map +0 -1
  127. package/dist/builtins/games/trek/schedule.d.ts +0 -23
  128. package/dist/builtins/games/trek/schedule.js +0 -55
  129. package/dist/builtins/games/trek/schedule.js.map +0 -1
  130. package/dist/builtins/games/trek/score.d.ts +0 -8
  131. package/dist/builtins/games/trek/score.js +0 -61
  132. package/dist/builtins/games/trek/score.js.map +0 -1
  133. package/dist/builtins/games/trek/setup.d.ts +0 -18
  134. package/dist/builtins/games/trek/setup.js +0 -251
  135. package/dist/builtins/games/trek/setup.js.map +0 -1
  136. package/dist/builtins/games/trek/setwarp.d.ts +0 -8
  137. package/dist/builtins/games/trek/setwarp.js +0 -28
  138. package/dist/builtins/games/trek/setwarp.js.map +0 -1
  139. package/dist/builtins/games/trek/shield.d.ts +0 -3
  140. package/dist/builtins/games/trek/shield.js +0 -139
  141. package/dist/builtins/games/trek/shield.js.map +0 -1
  142. package/dist/builtins/games/trek/snova.d.ts +0 -3
  143. package/dist/builtins/games/trek/snova.js +0 -156
  144. package/dist/builtins/games/trek/snova.js.map +0 -1
  145. package/dist/builtins/games/trek/srscan.d.ts +0 -3
  146. package/dist/builtins/games/trek/srscan.js +0 -176
  147. package/dist/builtins/games/trek/srscan.js.map +0 -1
  148. package/dist/builtins/games/trek/state.d.ts +0 -190
  149. package/dist/builtins/games/trek/state.js +0 -84
  150. package/dist/builtins/games/trek/state.js.map +0 -1
  151. package/dist/builtins/games/trek/style.d.ts +0 -7
  152. package/dist/builtins/games/trek/style.js +0 -93
  153. package/dist/builtins/games/trek/style.js.map +0 -1
  154. package/dist/builtins/games/trek/systemname.d.ts +0 -10
  155. package/dist/builtins/games/trek/systemname.js +0 -12
  156. package/dist/builtins/games/trek/systemname.js.map +0 -1
  157. package/dist/builtins/games/trek/torped.d.ts +0 -3
  158. package/dist/builtins/games/trek/torped.js +0 -232
  159. package/dist/builtins/games/trek/torped.js.map +0 -1
  160. package/dist/builtins/games/trek/trek.d.ts +0 -27
  161. package/dist/builtins/games/trek/trek.js +0 -96
  162. package/dist/builtins/games/trek/trek.js.map +0 -1
  163. package/dist/builtins/games/trek/visual.d.ts +0 -3
  164. package/dist/builtins/games/trek/visual.js +0 -87
  165. package/dist/builtins/games/trek/visual.js.map +0 -1
  166. package/dist/builtins/games/trek/warp.d.ts +0 -5
  167. package/dist/builtins/games/trek/warp.js +0 -173
  168. package/dist/builtins/games/trek/warp.js.map +0 -1
  169. package/dist/builtins/games/trek/win.d.ts +0 -12
  170. package/dist/builtins/games/trek/win.js +0 -34
  171. package/dist/builtins/games/trek/win.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnndsc/brasa",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "description": "BRASA Runs Abstracted Shell Actions - the hostable ChRIS shell engine (kernel)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,8 +16,7 @@
16
16
  "types": "dist/index.d.ts",
17
17
  "type": "module",
18
18
  "files": [
19
- "dist",
20
- "NOTICE"
19
+ "dist"
21
20
  ],
22
21
  "exports": {
23
22
  ".": {
@@ -53,6 +52,7 @@
53
52
  "@fnndsc/fond": "^0.4.0",
54
53
  "@fnndsc/cumin": "^3.28.1",
55
54
  "@fnndsc/salsa": "^4.2.0",
55
+ "bsd-trek": "^0.1.0",
56
56
  "chalk": "^4.1.2",
57
57
  "cli-highlight": "^2.1.11",
58
58
  "js-yaml": "^4.1.0",
package/NOTICE DELETED
@@ -1,48 +0,0 @@
1
- @fnndsc/brasa is MIT licensed (package.json). It includes third-party code under its own terms, listed here.
2
-
3
- ================================================================================
4
- trek: src/builtins/games/trek/
5
- ================================================================================
6
-
7
- A TypeScript port of BSD trek(6), from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801). Each ported module names its C sources and their revisions in its header. The port is under the original's license:
8
-
9
-
10
- Copyright (c) 1980, 1993
11
- The Regents of the University of California. All rights reserved.
12
-
13
- Redistribution and use in source and binary forms, with or without
14
- modification, are permitted provided that the following conditions
15
- are met:
16
- 1. Redistributions of source code must retain the above copyright
17
- notice, this list of conditions and the following disclaimer.
18
- 2. Redistributions in binary form must reproduce the above copyright
19
- notice, this list of conditions and the following disclaimer in the
20
- documentation and/or other materials provided with the distribution.
21
- 3. Neither the name of the University nor the names of its contributors
22
- may be used to endorse or promote products derived from this software
23
- without specific prior written permission.
24
-
25
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35
- SUCH DAMAGE.
36
-
37
-
38
- The original's credits (main.c):
39
-
40
- C version by Eric P. Allman 5/76 (U.C. Berkeley) with help from Jeff Poskanzer and Pete Rubinstein. I also want to thank everyone here at Berkeley who where crazy enough to play the undebugged game. I want to particularly thank Nick Whyte, who made considerable suggestions regarding the content of the game. Why, I'll never forget the time he suggested the name for the "capture" command.
41
-
42
- FORTRASH version by Kay R. Fisher (DEC) "and countless others". That was adapted from the "original BASIC program" (ha!) by Mike Mayfield (Centerline Engineering).
43
-
44
- Additional inspiration taken from FORTRAN version by David Matuszek and Paul Reynolds which runs on the CDC 7600 at Lawrence Berkeley Lab, maintained there by Andy Davidson. This version is also available at LLL and at LMSC. In all fairness, this version was the major inspiration for this version of the game (translation: I ripped off a whole lot of code).
45
-
46
- Minor other input from the "Battelle Version 7A" by Joe Miller (Graphics Systems Group, Battelle-Columbus Labs) and Ross Pavlac (Systems Programmer, Battelle Memorial Institute). That version was written in December '74 and extensively modified June '75. It was adapted from the FTN version by Ron Williams of CDC Sunnyvale, which was adapted from the Basic version distributed by DEC. It also had "neat stuff swiped" from T. T. Terry and Jim Korp (University of Texas), Hicks (Penn U.), and Rick Maus (Georgia Tech). Unfortunately, it was not as readable as it could have been and so the translation effort was severely hampered. None the less, I got the idea of inhabited starsystems from this version.
47
-
48
- Permission is given for use, copying, and modification of all or part of this program and related documentation, provided that all reference to the authors are maintained.
@@ -1,3 +0,0 @@
1
- import type { Trek } from './context.js';
2
- /** Abandon Ship */
3
- export declare function abandon(t: Trek, _v: number): Promise<void>;
@@ -1,159 +0,0 @@
1
- /*
2
- * abandon.ts: a TypeScript port of BSD trek(6), from abandon.c.
3
- * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): abandon.c 1.9 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 Abandoning ship: the officers escape, the crew beams down or is
35
- * lost, and the captain is exchanged into the Fairie Queene, or captured.
36
- *
37
- * @module
38
- */
39
- import { CLOAK, DOCKED, E_FIXDV, EMPTY, GREEN, L_CAPTURED, MAXEVENTS, NDEV, NSECTS, QUEENE, SHUTTLE, XPORTER } from './consts.js';
40
- import { compkldist } from './compkl.js';
41
- import { damaged } from './damaged.js';
42
- import { dock } from './dock.js';
43
- import { initquad } from './initquad.js';
44
- import { lose } from './lose.js';
45
- import { out } from './out.js';
46
- import { ranf } from './rand.js';
47
- import { unschedule } from './schedule.js';
48
- import { systemname } from './systemname.js';
49
- /*
50
- ** Abandon Ship
51
- **
52
- ** The ship is abandoned. If your current ship is the Faire
53
- ** Queene, or if your shuttlecraft is dead, you're out of
54
- ** luck. You need the shuttlecraft in order for the captain
55
- ** (that's you!!) to escape.
56
- **
57
- ** Your crew can beam to an inhabited starsystem in the
58
- ** quadrant, if there is one and if the transporter is working.
59
- ** If there is no inhabited starsystem, or if the transporter
60
- ** is out, they are left to die in outer space.
61
- **
62
- ** These currently just count as regular deaths, but they
63
- ** should count very heavily against you.
64
- **
65
- ** If there are no starbases left, you are captured by the
66
- ** Klingons, who torture you mercilessly. However, if there
67
- ** is at least one starbase, you are returned to the
68
- ** Federation in a prisoner of war exchange. Of course, this
69
- ** can't happen unless you have taken some prisoners.
70
- **
71
- ** Uses trace flag 40
72
- */
73
- /** Abandon Ship */
74
- export async function abandon(t, _v) {
75
- let i;
76
- if (t.s.Ship.ship === QUEENE) {
77
- t.io.printf('You may not abandon ye Faire Queene\n');
78
- return;
79
- }
80
- if (t.s.Ship.cond !== DOCKED) {
81
- if (damaged(t, SHUTTLE)) {
82
- await out(t, SHUTTLE);
83
- return;
84
- }
85
- t.io.printf('Officers escape in shuttlecraft\n');
86
- /* decide on fate of crew */
87
- const q = t.s.Quad[t.s.Ship.quadx][t.s.Ship.quady];
88
- if (q.qsystemname === 0 || damaged(t, XPORTER)) {
89
- t.io.printf('Entire crew of %d left to die in outer space\n', t.s.Ship.crew);
90
- t.s.Game.deaths += t.s.Ship.crew;
91
- }
92
- else {
93
- t.io.printf('Crew beams down to planet %s\n', systemname(t, q) ?? '(null)');
94
- }
95
- }
96
- /* see if you can be exchanged */
97
- if (t.s.Now.bases === 0 || t.s.Game.captives < 20 * t.s.Game.skill)
98
- await lose(t, L_CAPTURED);
99
- /* re-outfit new ship */
100
- t.io.printf('You are hereby put in charge of an antiquated but still\n');
101
- t.io.printf(' functional ship, the Fairie Queene.\n');
102
- t.s.Ship.ship = QUEENE;
103
- t.s.Ship.shipname = 'Fairie Queene';
104
- t.s.Param.energy = t.s.Ship.energy = 3000;
105
- t.s.Param.torped = t.s.Ship.torped = 6;
106
- t.s.Param.shield = t.s.Ship.shield = 1250;
107
- t.s.Ship.shldup = 0;
108
- t.s.Ship.cloaked = 0;
109
- t.s.Ship.warp = 5.0;
110
- t.s.Ship.warp2 = 25.0;
111
- t.s.Ship.warp3 = 125.0;
112
- t.s.Ship.cond = GREEN;
113
- /* clear out damages on old ship */
114
- for (i = 0; i < MAXEVENTS; i++) {
115
- const e = t.s.Event[i];
116
- if (e.evcode !== E_FIXDV)
117
- continue;
118
- unschedule(t, i);
119
- }
120
- /* get rid of some devices and redistribute probabilities */
121
- const damprob = t.s.Param.damprob;
122
- i = damprob[SHUTTLE] + damprob[CLOAK];
123
- damprob[SHUTTLE] = damprob[CLOAK] = 0;
124
- while (i > 0) {
125
- for (let j = 0; j < NDEV; j++) {
126
- if (damprob[j] !== 0) {
127
- damprob[j] = damprob[j] + 1;
128
- i--;
129
- if (i <= 0)
130
- break;
131
- }
132
- }
133
- }
134
- /* pick a starbase to restart at */
135
- i = ranf(t.rnd, t.s.Now.bases);
136
- const base = t.s.Now.base[i];
137
- t.s.Ship.quadx = base.x;
138
- t.s.Ship.quady = base.y;
139
- /* setup that quadrant */
140
- while (true) {
141
- await initquad(t, 1);
142
- t.s.Sect[t.s.Ship.sectx][t.s.Ship.secty] = EMPTY;
143
- for (i = 0; i < 5; i++) {
144
- t.s.Ship.sectx = t.s.Etc.starbase.x + ranf(t.rnd, 3) - 1;
145
- if (t.s.Ship.sectx < 0 || t.s.Ship.sectx >= NSECTS)
146
- continue;
147
- t.s.Ship.secty = t.s.Etc.starbase.y + ranf(t.rnd, 3) - 1;
148
- if (t.s.Ship.secty < 0 || t.s.Ship.secty >= NSECTS)
149
- continue;
150
- if (t.s.Sect[t.s.Ship.sectx][t.s.Ship.secty] === EMPTY) {
151
- t.s.Sect[t.s.Ship.sectx][t.s.Ship.secty] = QUEENE;
152
- await dock(t, 0);
153
- compkldist(t, 0);
154
- return;
155
- }
156
- }
157
- }
158
- }
159
- //# sourceMappingURL=abandon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abandon.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/abandon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAElI,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MA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KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC;gBACvD,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;gBAClD,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACjB,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Trek } from './context.js';
2
- /** Klingon Attack Routine. */
3
- export declare function attack(t: Trek, resting: number): Promise<void>;
@@ -1,185 +0,0 @@
1
- /*
2
- * attack.ts: a TypeScript port of BSD trek(6), from attack.c.
3
- * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): attack.c 1.9 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 Klingon attack: each Klingon in the quadrant with power to
35
- * spare fires on the ship, shields absorbing their share; a hit hard
36
- * enough damages a device, and heavy attacks cost crew.
37
- *
38
- * @module
39
- */
40
- import { DOCKED, L_DSTRYD, SHIELD, SRSCAN } from './consts.js';
41
- import { damage } from './damage.js';
42
- import { damaged } from './damaged.js';
43
- import { klmove } from './klmove.js';
44
- import { lose } from './lose.js';
45
- import { franf, ranf } from './rand.js';
46
- /*
47
- ** Klingon Attack Routine
48
- **
49
- ** This routine performs the Klingon attack provided that
50
- ** (1) Something happened this move (i.e., not free), and
51
- ** (2) You are not cloaked. Note that if you issue the
52
- ** cloak command, you are not considered cloaked until you
53
- ** expend some time.
54
- **
55
- ** Klingons are permitted to move both before and after the
56
- ** attack. They will tend to move toward you before the
57
- ** attack and away from you after the attack.
58
- **
59
- ** Under certain conditions you can get a critical hit. This
60
- ** sort of hit damages devices. The probability that a given
61
- ** device is damaged depends on the device. Well protected
62
- ** devices (such as the computer, which is in the core of the
63
- ** ship and has considerable redundancy) almost never get
64
- ** damaged, whereas devices which are exposed (such as the
65
- ** warp engines) or which are particularly delicate (such as
66
- ** the transporter) have a much higher probability of being
67
- ** damaged.
68
- **
69
- ** The actual amount of damage (i.e., how long it takes to fix
70
- ** it) depends on the amount of the hit and the "damfac[]"
71
- ** entry for the particular device.
72
- **
73
- ** Casualties can also occur.
74
- **
75
- ** resting -- set if attack while resting
76
- */
77
- /** Klingon Attack Routine. */
78
- export async function attack(t, resting) {
79
- const { Ship, Move, Etc, Param, Game, Quad } = t.s;
80
- let hit;
81
- let l;
82
- let maxhit;
83
- let tothit;
84
- let shldabsb;
85
- let chgfac;
86
- let propor;
87
- let extradm;
88
- let dustfac;
89
- let tothe;
90
- let cas;
91
- let hitflag;
92
- if (Move.free)
93
- return;
94
- if (Etc.nkling <= 0 || Quad[Ship.quadx][Ship.quady].stars < 0)
95
- return;
96
- if (Ship.cloaked && Ship.cloakgood)
97
- return;
98
- /* move before attack */
99
- await klmove(t, 0);
100
- if (Ship.cond === DOCKED) {
101
- if (!resting)
102
- t.io.printf('Starbase shields protect the %s\n', Ship.shipname);
103
- return;
104
- }
105
- /* setup shield effectiveness */
106
- chgfac = 1.0;
107
- if (Move.shldchg)
108
- chgfac = 0.25 + 0.50 * franf(t.rnd);
109
- maxhit = tothit = 0;
110
- hitflag = 0;
111
- /* let each Klingon do his damndest */
112
- for (let i = 0; i < Etc.nkling; i++) {
113
- /* if he's low on power he won't attack */
114
- if (Etc.klingon[i].power < 20)
115
- continue;
116
- if (!hitflag) {
117
- t.io.printf('\nStardate %.2f: Klingon attack:\n', t.s.Now.date);
118
- hitflag++;
119
- }
120
- /* complete the hit */
121
- dustfac = 0.90 + 0.01 * franf(t.rnd);
122
- tothe = Etc.klingon[i].avgdist;
123
- hit = Math.trunc(Etc.klingon[i].power * Math.pow(dustfac, tothe) * Param.hitfac);
124
- /* deplete his energy */
125
- dustfac = Etc.klingon[i].power;
126
- Etc.klingon[i].power = Math.trunc(dustfac * Param.phasfac * (1.0 + (franf(t.rnd) - 0.5) * 0.2));
127
- /* see how much of hit shields will absorb */
128
- shldabsb = 0;
129
- if (Ship.shldup || Move.shldchg) {
130
- propor = Ship.shield;
131
- propor /= Param.shield;
132
- shldabsb = Math.trunc(propor * chgfac * hit);
133
- if (shldabsb > Ship.shield)
134
- shldabsb = Ship.shield;
135
- Ship.shield -= shldabsb;
136
- }
137
- /* actually do the hit */
138
- t.io.printf('\x07HIT: %d units', hit);
139
- if (!damaged(t, SRSCAN))
140
- t.io.printf(' from %d,%d', Etc.klingon[i].x, Etc.klingon[i].y);
141
- cas = Math.trunc((shldabsb * 100) / hit);
142
- hit -= shldabsb;
143
- if (shldabsb > 0)
144
- t.io.printf(', shields absorb %d%%, effective hit %d\n', cas, hit);
145
- else
146
- t.io.printf('\n');
147
- tothit += hit;
148
- if (hit > maxhit)
149
- maxhit = hit;
150
- Ship.energy -= hit;
151
- /* see if damages occurred */
152
- if (hit >= (15 - Game.skill) * (25 - ranf(t.rnd, 12))) {
153
- t.io.printf('\x07CRITICAL HIT!!!\x07\n');
154
- /* select a device from probability vector */
155
- cas = ranf(t.rnd, 1000);
156
- for (l = 0; cas >= 0; l++)
157
- cas = Math.trunc(cas - Param.damprob[l]);
158
- l -= 1;
159
- /* compute amount of damage */
160
- extradm = (hit * Param.damfac[l]) / (75 + ranf(t.rnd, 25)) + 0.5;
161
- /* damage the device */
162
- await damage(t, l, extradm);
163
- if (damaged(t, SHIELD)) {
164
- if (Ship.shldup)
165
- t.io.printf('Sulu: Shields knocked down, captain.\n');
166
- Ship.shldup = 0;
167
- Move.shldchg = 0;
168
- }
169
- }
170
- if (Ship.energy <= 0)
171
- await lose(t, L_DSTRYD);
172
- }
173
- /* see what our casualities are like */
174
- if (maxhit >= 200 || tothit >= 500) {
175
- cas = Math.trunc(tothit * 0.015 * franf(t.rnd));
176
- if (cas >= 2) {
177
- t.io.printf('McCoy: we suffered %d casualties in that attack.\n', cas);
178
- Game.deaths += cas;
179
- Ship.crew -= cas;
180
- }
181
- }
182
- /* allow Klingons to move after attacking */
183
- await klmove(t, 1);
184
- }
185
- //# sourceMappingURL=attack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attack.js","sourceRo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,CAAC;gBACvE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;gBAChB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;YAAE,MAAM,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,uCAAuC;IACvC,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QACnC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAChD,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACb,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,oDAAoD,EAAE,GAAG,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;YACnB,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC;QACnB,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrB,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Trek } from './context.js';
2
- /** Sends the ship out of a supernova quadrant. */
3
- export declare function autover(t: Trek): Promise<void>;
@@ -1,79 +0,0 @@
1
- /*
2
- * autover.ts: a TypeScript port of BSD trek(6), from autover.c.
3
- * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): autover.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 Automatic override: hurling the ship out of a supernova quadrant
35
- * at a random warp over 6.0.
36
- *
37
- * @module
38
- */
39
- import { attack } from './attack.js';
40
- import { RED } from './consts.js';
41
- import { franf, ranf } from './rand.js';
42
- import { warp } from './warp.js';
43
- /*
44
- ** Automatic Override
45
- **
46
- ** If we should be so unlucky as to be caught in a quadrant
47
- ** with a supernova in it, this routine is called. It is
48
- ** called from checkcond().
49
- **
50
- ** It sets you to a random warp (guaranteed to be over 6.0)
51
- ** and starts sending you off "somewhere" (whereever that is).
52
- **
53
- ** Please note that it is VERY important that you reset your
54
- ** warp speed after the automatic override is called. The new
55
- ** warp factor does not stay in effect for just this routine.
56
- **
57
- ** This routine will never try to send you more than sqrt(2)
58
- ** quadrants, since that is all that is needed.
59
- */
60
- /** Sends the ship out of a supernova quadrant. */
61
- export async function autover(t) {
62
- const { Ship, Etc } = t.s;
63
- let dist;
64
- t.io.printf('\x07RED ALERT: The %s is in a supernova quadrant\n', Ship.shipname);
65
- t.io.printf('*** Emergency override attempts to hurl %s to safety\n', Ship.shipname);
66
- /* let's get our ass out of here */
67
- Ship.warp = 6.0 + 2.0 * franf(t.rnd);
68
- Ship.warp2 = Ship.warp * Ship.warp;
69
- Ship.warp3 = Ship.warp2 * Ship.warp;
70
- dist = 0.75 * Ship.energy / (Ship.warp3 * (Ship.shldup + 1));
71
- if (dist > 1.4142)
72
- dist = 1.4142;
73
- const course = ranf(t.rnd, 360);
74
- Etc.nkling = -1;
75
- Ship.cond = RED;
76
- await warp(t, -1, course, dist);
77
- await attack(t, 0);
78
- }
79
- //# sourceMappingURL=autover.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autover.js","sourceRoot":"","sources":["../../../../src/builtins/games/trek/autover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;EAgBE;AAEF,kDAAkD;AAClD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,CAAO;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAY,CAAC;IAEjB,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,qDAAqD,EAC/D,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjB,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,yDAAyD,EACnE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjB,mCAAmC;IACnC,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;IACpC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,IAAI,GAAG,MAAM;QAAE,IAAI,GAAG,MAAM,CAAC;IACjC,MAAM,MAAM,GAAW,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACxC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAChB,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrB,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Trek } from './context.js';
2
- /** Ask a Klingon To Surrender */
3
- export declare function capture(t: Trek, _v: number): Promise<void>;
@@ -1,117 +0,0 @@
1
- /*
2
- * capture.ts: a TypeScript port of BSD trek(6), from capture.c.
3
- * Ported from NetBSD src/games/trek (trunk 7a9ca154a8f6144307865f23390a3c63b400b801): capture.c 1.12 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 Asking a Klingon to surrender, over the subspace radio.
35
- *
36
- * @module
37
- */
38
- import { SSRADIO } from './consts.js';
39
- import { damaged } from './damaged.js';
40
- import { killk } from './kill.js';
41
- import { out } from './out.js';
42
- import { ranf } from './rand.js';
43
- /*
44
- ** Ask a Klingon To Surrender
45
- **
46
- ** (Fat chance)
47
- **
48
- ** The Subspace Radio is needed to ask a Klingon if he will kindly
49
- ** surrender. A random Klingon from the ones in the quadrant is
50
- ** chosen.
51
- **
52
- ** The Klingon is requested to surrender. The probability of this
53
- ** is a function of that Klingon's remaining power, our power,
54
- ** etc.
55
- */
56
- /** Ask a Klingon To Surrender */
57
- export async function capture(t, _v) {
58
- let i;
59
- /* check for not cloaked */
60
- if (t.s.Ship.cloaked) {
61
- t.io.printf('Ship-ship communications out when cloaked\n');
62
- return;
63
- }
64
- if (damaged(t, SSRADIO)) {
65
- await out(t, SSRADIO);
66
- return;
67
- }
68
- /* find out if there are any at all */
69
- if (t.s.Etc.nkling <= 0) {
70
- t.io.printf('Uhura: Getting no response, sir\n');
71
- return;
72
- }
73
- /* if there is more than one Klingon, find out which one */
74
- const k = selectklingon(t);
75
- t.s.Move.free = 0;
76
- t.s.Move.time = 0.05;
77
- /* check out that Klingon */
78
- k.srndreq++;
79
- let x = t.s.Param.klingpwr;
80
- x *= t.s.Ship.energy;
81
- x /= k.power * t.s.Etc.nkling;
82
- x *= t.s.Param.srndrprob;
83
- i = Math.trunc(x);
84
- if (t.s.Trace)
85
- t.io.printf('Prob = %d (%.4f)\n', i, x);
86
- if (i > ranf(t.rnd, 100)) {
87
- /* guess what, he surrendered!!! */
88
- t.io.printf('Klingon at %d,%d surrenders\n', k.x, k.y);
89
- i = ranf(t.rnd, t.s.Param.klingcrew);
90
- if (i > 0)
91
- t.io.printf('%d klingons commit suicide rather than be taken captive\n', t.s.Param.klingcrew - i);
92
- if (i > t.s.Ship.brigfree)
93
- i = t.s.Ship.brigfree;
94
- t.s.Ship.brigfree -= i;
95
- t.io.printf('%d captives taken\n', i);
96
- await killk(t, k.x, k.y);
97
- return;
98
- }
99
- /* big surprise, he refuses to surrender */
100
- t.io.printf('Fat chance, captain\n');
101
- return;
102
- }
103
- /*
104
- ** SELECT A KLINGON
105
- **
106
- ** Cruddy, just takes one at random. Should ask the captain.
107
- */
108
- /** SELECT A KLINGON */
109
- function selectklingon(t) {
110
- let i;
111
- if (t.s.Etc.nkling < 2)
112
- i = 0;
113
- else
114
- i = ranf(t.rnd, t.s.Etc.nkling);
115
- return t.s.Etc.klingon[i];
116
- }
117
- //# sourceMappingURL=capture.js.map