ravensight-playtest 0.19.0 → 0.20.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.
- package/README.md +49 -8
- package/docs/ADAPTERS.md +2 -0
- package/docs/DESKTOP.md +46 -2
- package/docs/UNITY.md +40 -0
- package/docs/UNREAL.md +43 -0
- package/docs/godot-driver.md +11 -0
- package/package.json +1 -1
- package/src/cli.js +18 -1
- package/src/commands/run.js +21 -3
- package/src/hosted/status.js +13 -1
- package/src/run/anygame/genre.js +51 -10
- package/src/run/anygame/genre2d.js +99 -3
- package/src/run/anygame/index.js +4 -2
- package/src/run/anygame/scene3d.js +53 -20
- package/src/run/anygame/shared-hashes.json +3 -3
- package/src/run/args.js +12 -3
- package/src/run/drivers/desktop/app.js +1 -1
- package/src/run/drivers/desktop/common.js +59 -1
- package/src/run/drivers/desktop/driver.js +99 -27
- package/src/run/drivers/desktop/runHome.js +158 -0
- package/src/run/drivers/godot.js +8 -1
- package/src/run/drivers/mobile/native.js +5 -3
- package/src/run/drivers/mobile/target.js +3 -2
- package/src/run/drivers/stdio.js +6 -3
- package/src/run/drivers/unreal/driver.js +142 -52
- package/src/run/drivers/web.js +1 -1
- package/src/run/drivers/webdriver.js +4 -2
- package/src/run/launchArgs.js +58 -0
- package/src/run/pauseHook.js +128 -5
- package/src/run/personaLoop.js +30 -5
- package/src/run/replay.js +3 -1
- package/src/run/reportChecks.js +8 -1
- package/src/run/resume.js +4 -0
- package/src/run/sessions.js +11 -6
- package/src/run/slowMotion.js +151 -0
- package/src/run/startFrom.js +42 -9
|
@@ -61,14 +61,17 @@ export const STYLES_2D = Object.freeze({
|
|
|
61
61
|
line: 'A twin stick game: move with the keys and aim with the pointer at the same time, in one timed sequence (the movement key held, presses of the mouse at the target inside it); on a phone, hold the left stick with one finger while a second finger taps or holds on the right.',
|
|
62
62
|
helper: 'Keep moving while you aim; do not stop to fire.' },
|
|
63
63
|
fighting: { kinds: ['twitch'], words: ['fighting', 'fighter', 'brawler', 'beat_em_up', 'versus'],
|
|
64
|
-
line: 'A fighting game: a combo is
|
|
64
|
+
line: 'A fighting game: a combo is one timed sequence of keys, written once and played in the window the game gives between presses. When the game says how long (such as "a quarter to half a second"), put each press in the middle of that window; when it does not, space them about 350 ms apart (0, 350 and 700 ms). Presses closer than the window break the combo as surely as late ones. To block, hold the block key (or back) from the moment the rival\'s warning shows until its attack is over. Read the health bars after each exchange and change what you do when one is losing.',
|
|
65
65
|
helper: 'Play the combo the plan wrote, in its timing; do not mash.' },
|
|
66
|
-
racing: { kinds: ['twitch'], words: ['racing', 'racer', 'kart', 'driving', 'race'],
|
|
66
|
+
racing: { kinds: ['twitch', 'vehicle'], words: ['racing', 'racer', 'kart', 'driving', 'race'],
|
|
67
67
|
line: 'A racing game: hold the accelerator for the whole stretch and steer with short taps inside the same timed sequence; ease off before a sharp bend, and plan only a second or two of driving at a time.',
|
|
68
68
|
helper: 'Keep the accelerator held; correct the steering in small taps.' },
|
|
69
69
|
roguelike: { kinds: [], words: ['roguelike', 'roguelite', 'rogue_like', 'rogue_lite', 'dungeon_crawler', 'permadeath'],
|
|
70
70
|
line: 'A roguelike: dying ends the run and is part of the game, not a fault. After a death, start a new run with the game\'s own button or key, and note what changed (a new map, items lost or kept). Report a death only when the game was unfair in a way you saw.',
|
|
71
|
-
helper: 'After a death, start the new run the plan named; do not keep pressing on the death screen.'
|
|
71
|
+
helper: 'After a death, start the new run the plan named; do not keep pressing on the death screen.',
|
|
72
|
+
// A roguelike played in turns is not tactics: one hero walks a dungeon, there are no units to select and no turn to end.
|
|
73
|
+
over: { turn_based: { label: 'a turn-based roguelike',
|
|
74
|
+
pacing: 'Nothing moves until you act, and each move key is one turn: a step, or an attack on a monster you walk into. Plan up to 8 steps toward something you can see (a door, a gap in a wall, the stairs). A step that changes nothing means a wall is in the way: look for the opening and walk to it instead of pressing the same key again.' } } },
|
|
72
75
|
match_three: { kinds: ['puzzle'], words: ['match_three', 'match3', 'match_3', 'gem_swap'],
|
|
73
76
|
line: 'Match three: swap two neighbouring pieces with a drag from one onto the other; look for a move that lines up three or more before you drag.',
|
|
74
77
|
helper: 'Swap only the pair the plan named.' },
|
|
@@ -95,6 +98,99 @@ export function parseStyle(v) {
|
|
|
95
98
|
return null;
|
|
96
99
|
}
|
|
97
100
|
|
|
101
|
+
// The planner's own one-line description of the game ("about") names its style more often than its kind answer does: on the
|
|
102
|
+
// release 19 paid proofs it wrote "a fighting mini-game", "a turn-based crypt crawler" and "a kart racing game" while its kind
|
|
103
|
+
// answers were twitch, turn_based and vehicle with no style. Only plain names of a kind of game count here, never a verb that
|
|
104
|
+
// any game uses ("fight the raiders", "race to the flag") or a word with another meaning ("a space fighter").
|
|
105
|
+
const DESCRIBED = [
|
|
106
|
+
['shmup', /\b(?:shmup|shoot[ -]?['’]?e?m[ -]?up|bullet[ -]hell|(?:vertical|horizontal|side|scrolling)[ -](?:scrolling )?shooter)\b/],
|
|
107
|
+
['twin_stick', /\b(?:twin[ -]?stick|arena shooter|top[ -]down shooter)\b/],
|
|
108
|
+
['fighting', /\b(?:fighting|versus) (?:mini[ -]?)?game\b|\b(?:brawler|beat[ -]?['’]?e?m[ -]?up|martial arts)\b/],
|
|
109
|
+
['racing', /\b(?:kart|racing|racer)\b|\blaps?\b/],
|
|
110
|
+
['roguelike', /\brogue[ -]?(?:like|lite)\b|\b(?:dungeon|crypt|cave) crawl(?:er|ing)?\b|\bperma[ -]?death\b|\bthe run ends\b/],
|
|
111
|
+
['match_three', /\bmatch[ -]?(?:3|three)\b/],
|
|
112
|
+
['sliding', /\bsliding (?:tiles?|blocks?|puzzle)\b|\b(?:15|fifteen)[ -]puzzle\b/],
|
|
113
|
+
['logic', /\b(?:lights[ -]out|nonogram|sudoku|picross|logic (?:puzzle|grid|board))\b/],
|
|
114
|
+
['physics', /\b(?:slingshot|physics (?:puzzle|shot))\b/]
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
/** A 2D style named in a plain description of the game (the planner's "about"), or null. The first named in the text wins. */
|
|
118
|
+
export function describeStyle(text) {
|
|
119
|
+
const t = String(text ?? '').toLowerCase();
|
|
120
|
+
if (!t.trim()) return null;
|
|
121
|
+
let best = null, at = Infinity;
|
|
122
|
+
for (const [id, re] of DESCRIBED) { const m = re.exec(t); if (m && m.index < at) { best = id; at = m.index; } }
|
|
123
|
+
return best;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// What a fighting game's own screen says before play: a combo of punches and kicks. On the release 20 paid proof Dojo Duel's
|
|
127
|
+
// title read "J punches, K kicks, hold L to block. Combo: J, J, K, each a quarter to half a second after the last." and the
|
|
128
|
+
// style settled only at step 23 of 35, after 3 of its 4 combo tries were planned. Only words a fighting game's screen shows
|
|
129
|
+
// together count: a combo with a punch or a kick named beside it.
|
|
130
|
+
const ON_SCREEN = [
|
|
131
|
+
['fighting', t => /\bcombos?\b/.test(t) && /\b(?:punch(?:es)?|kicks?)\b/.test(t)]
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
/** A 2D style named by what the game's own screen says (the planner's copy of it), or null. Stricter than describeStyle. */
|
|
135
|
+
export function screenStyle(text) {
|
|
136
|
+
const t = String(text ?? '').toLowerCase();
|
|
137
|
+
if (!t.trim()) return null;
|
|
138
|
+
for (const [id, cue] of ON_SCREEN) if (cue(t)) return id;
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The one kind a style fits, or null when it fits several or any (racing, roguelike). */
|
|
143
|
+
export const styleKind = style => (STYLES_2D[style]?.kinds.length === 1 ? STYLES_2D[style].kinds[0] : null);
|
|
144
|
+
|
|
145
|
+
// The gap between combo presses when the game does not say: the fighting line's own "about 350 ms apart".
|
|
146
|
+
export const COMBO_GAP_MS = 350;
|
|
147
|
+
// What counts as a press in a combo, and how many: a tap (held this long at most), two to six of them.
|
|
148
|
+
export const COMBO_TAP_MS = 200;
|
|
149
|
+
export const COMBO_PRESSES = [2, 6];
|
|
150
|
+
const FRACTION_MS = { quarter: 250, third: 333, half: 500 };
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The time a game gives between combo presses, from its own words: `{ min, max }` in ms, or null when the text names none.
|
|
154
|
+
* Reads "a quarter to half a second", "0.25 to 0.55 s", "250 to 550 ms" and "between 250 and 550 milliseconds".
|
|
155
|
+
*/
|
|
156
|
+
export function comboWindow(text) {
|
|
157
|
+
const t = String(text ?? '').toLowerCase().replace(/\s+/g, ' ');
|
|
158
|
+
if (!t.trim()) return null;
|
|
159
|
+
const ok = (min, max) => (Number.isFinite(min) && Number.isFinite(max) && min >= 50 && max <= 2000 && max > min ? { min: Math.round(min), max: Math.round(max) } : null);
|
|
160
|
+
const words = /\b(?:an? |one )?(quarter|third|half)(?: of)?(?: an? second)? ?(?:to|and|or|-) ?(?:an? |one )?(quarter|third|half)(?: of)? an? second\b/.exec(t);
|
|
161
|
+
if (words) { const w = ok(FRACTION_MS[words[1]], FRACTION_MS[words[2]]); if (w) return w; }
|
|
162
|
+
const nums = /\b(\d+(?:\.\d+)?) ?(?:to|and|-) ?(\d+(?:\.\d+)?) ?(ms|milliseconds?|s|secs?|seconds?)\b/.exec(t);
|
|
163
|
+
if (nums) {
|
|
164
|
+
const k = /^m/.test(nums[3]) ? 1 : 1000;
|
|
165
|
+
const w = ok(Number(nums[1]) * k, Number(nums[2]) * k);
|
|
166
|
+
if (w) return w;
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A combo the planner wrote as one timed sequence of key taps, played inside the window the game gives between presses:
|
|
173
|
+
* the steps with each press `gap` ms after the last, where `gap` is the middle of `window` (COMBO_GAP_MS when the game
|
|
174
|
+
* gave none). Answers null when the sequence is not a combo (a click or a move in it, a key held, two keys at once, too
|
|
175
|
+
* few or too many presses) or when every gap already sits inside the window.
|
|
176
|
+
*/
|
|
177
|
+
export function spaceCombo(steps, window = null) {
|
|
178
|
+
if (!Array.isArray(steps)) return null;
|
|
179
|
+
const n = steps.length;
|
|
180
|
+
if (n < COMBO_PRESSES[0] || n > COMBO_PRESSES[1]) return null;
|
|
181
|
+
if (!steps.every(s => s && typeof s === 'object' && typeof s.key === 'string' && s.key.trim() && !s.key.includes('+') && s.click === undefined && s.move === undefined && Number.isFinite(Number(s.at)) && !(Number(s.holdMs) > COMBO_TAP_MS))) return null;
|
|
182
|
+
const at = steps.map(s => Number(s.at));
|
|
183
|
+
for (let i = 1; i < n; i++) if (!(at[i] > at[i - 1])) return null;
|
|
184
|
+
const win = window && Number.isFinite(window.min) && Number.isFinite(window.max) ? window : { min: Math.round(COMBO_GAP_MS * 0.75), max: Math.round(COMBO_GAP_MS * 1.5) };
|
|
185
|
+
const gaps = at.slice(1).map((v, i) => v - at[i]);
|
|
186
|
+
if (gaps.every(g => g >= win.min && g <= win.max)) return null;
|
|
187
|
+
const gap = window ? Math.round((win.min + win.max) / 2) : COMBO_GAP_MS;
|
|
188
|
+
return steps.map((s, i) => ({ ...s, at: i * gap }));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** What a settled kind is called and how it is paced under a style that changes them (a roguelike played in turns), or null. */
|
|
192
|
+
export const styleOver = (style, kind) => STYLES_2D[style]?.over?.[kind] || null;
|
|
193
|
+
|
|
98
194
|
/** Whether a style fits a kind. */
|
|
99
195
|
export const styleFits = (style, kind) => Boolean(STYLES_2D[style]) && (!STYLES_2D[style].kinds.length || STYLES_2D[style].kinds.includes(kind));
|
|
100
196
|
|
package/src/run/anygame/index.js
CHANGED
|
@@ -130,7 +130,8 @@ export function createLocalAnyGame({ briefText = '', controls = null, touch = fa
|
|
|
130
130
|
let overSaid = false;
|
|
131
131
|
const book = createControlBook({ touch, given: controls });
|
|
132
132
|
// `is3d`: the page has shown a 3D scene (a measured pose), so "rts" or "racing" names the 3D kind (./genre.js).
|
|
133
|
-
|
|
133
|
+
// `touch`: a run played with a finger is never told to hold keys to move.
|
|
134
|
+
const genre = createGenre({ is3d, touch: () => touch });
|
|
134
135
|
const briefLanguage = detectLanguage(briefText);
|
|
135
136
|
const report = reportLanguage(briefText, { explicit: reportLanguageHint });
|
|
136
137
|
let sound = null, soundTest = null;
|
|
@@ -214,7 +215,8 @@ export function createLocalAnyGame({ briefText = '', controls = null, touch = fa
|
|
|
214
215
|
if (note.kind && note.kind !== 'reaction') { memory.noticed(text, action); return 'reported'; }
|
|
215
216
|
const kind = KIND_NOTE.exec(text);
|
|
216
217
|
if (kind) { genre.read(kind[1].trim(), action); genre.read(kind[1].trim(), action); return 'kind'; }
|
|
217
|
-
|
|
218
|
+
// The description also names the game's 2D style when the kind note did not ("a fighting mini-game", genre2d describeStyle).
|
|
219
|
+
if (ABOUT_NOTE.test(text)) { const about = text.replace(ABOUT_NOTE, ''); memory.setAbout(about, action); genre.describe(about); return 'about'; }
|
|
218
220
|
if (OVER_NOTE.test(text)) overSaid = true;
|
|
219
221
|
for (const [re, t] of KEEP) {
|
|
220
222
|
if (!re.test(text)) continue;
|
|
@@ -443,27 +443,33 @@ export function world3dFindings(steps, { won = false } = {}) {
|
|
|
443
443
|
} else i = Math.max(i + 1, j);
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
// Fell out of the world: below the level's lowest point, still going down at the end of play
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
446
|
+
// Fell out of the world: below the level's lowest point, still going down at the end of play (or when the run loaded the game
|
|
447
|
+
// again because of it, a step of kind `restart`), and far below it. The first such fall is the finding.
|
|
448
|
+
const segments = [];
|
|
449
|
+
let seg = [];
|
|
450
|
+
for (const t of list) {
|
|
451
|
+
if (t.kind === 'restart') { if (seg.length) segments.push({ steps: seg, restartAt: t.step }); seg = []; continue; }
|
|
452
|
+
if (posed(t)) seg.push(t);
|
|
453
|
+
}
|
|
454
|
+
if (seg.length) segments.push({ steps: seg, restartAt: null });
|
|
455
|
+
for (const { steps: posedSteps, restartAt } of segments) {
|
|
456
|
+
const last = posedSteps.at(-1);
|
|
457
|
+
if (!last || last.after.floorY === null) continue;
|
|
458
|
+
const floorY = last.after.floorY;
|
|
459
|
+
const tail = fallTail(posedSteps.map(t => t.after), floorY);
|
|
460
|
+
if (!tail) continue;
|
|
461
|
+
const f = posedSteps[posedSteps.length - tail.length];
|
|
455
462
|
// Play reached the game: an input it received came at or before the fall, so the pose is not the page's word alone.
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
463
|
+
if (!list.some(t => t.step <= f.step && (t.received === true || t.captured === true))) continue;
|
|
464
|
+
const endY = last.after.pos[1];
|
|
465
|
+
out.push({
|
|
466
|
+
kind: 'fell_out', key: 'world3d:fell', atStep: f.step, severity: 'major', category: 'bug',
|
|
467
|
+
title: 'The player fell out of the world',
|
|
468
|
+
description: `At step ${f.step} the player (${f.after.subject === 'camera' ? 'the camera' : `"${f.after.subject}"`}) went below the lowest point of the level (height ${floorY.toFixed(1)}) and never came back: ${restartAt === null ? `at the end of play, step ${last.step}, it was at height ${endY.toFixed(1)} and still falling. Nothing put it back on the level.` : `at step ${last.step} it was at height ${endY.toFixed(1)} and still falling, and nothing had put it back on the level, so the run loaded the game again at step ${restartAt}.`}`,
|
|
469
|
+
steps: [list[list.indexOf(f) - 1], f, last].filter(Boolean).map(t => t.step), shots: shots([f, last]),
|
|
470
|
+
facts: { floorY, at: f.after.pos, endY, ...(restartAt === null ? {} : { restartAt }), toStep: last.step }
|
|
471
|
+
});
|
|
472
|
+
break;
|
|
467
473
|
}
|
|
468
474
|
|
|
469
475
|
// The camera inside a solid: the first input the page received after which the camera was inside a box the game draws as solid.
|
|
@@ -533,6 +539,33 @@ export function world3dFindings(steps, { won = false } = {}) {
|
|
|
533
539
|
return out;
|
|
534
540
|
}
|
|
535
541
|
|
|
542
|
+
/**
|
|
543
|
+
* The poses of a fall out of the world at the end of `poses` (in order, each with `pos`), or null: below `floorY` by more
|
|
544
|
+
* than fallBelow from the first of them on, still going down at the last, and more than fallDepth below at the last.
|
|
545
|
+
*/
|
|
546
|
+
function fallTail(poses, floorY) {
|
|
547
|
+
if (!Number.isFinite(floorY)) return null;
|
|
548
|
+
const y = p => p.pos[1];
|
|
549
|
+
const first = poses.findIndex(p => y(p) < floorY - L.fallBelow);
|
|
550
|
+
const tail = first >= 0 ? poses.slice(first) : [];
|
|
551
|
+
if (tail.length < 2 || !tail.every(p => y(p) < floorY - L.fallBelow)) return null;
|
|
552
|
+
if (!(y(tail.at(-1)) < y(tail.at(-2))) || !(y(tail.at(-1)) < floorY - L.fallDepth)) return null;
|
|
553
|
+
return tail;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Whether the poses measured since the game was last loaded show the player falling out of the world now (the fall rule of
|
|
558
|
+
* world3dFindings, as play goes): a run that sees it loads the game again instead of walking on in the void. `{ floorY, y, from }`
|
|
559
|
+
* (`from` the index of the first pose below the level) or null. Only a measured pose counts; a picture never does.
|
|
560
|
+
*/
|
|
561
|
+
export function fallingOut(poses) {
|
|
562
|
+
const list = (Array.isArray(poses) ? poses : []).filter(p => p && Array.isArray(p.pos) && Number.isFinite(p.pos[1]));
|
|
563
|
+
const last = list.at(-1);
|
|
564
|
+
if (!last || !Number.isFinite(last.floorY)) return null;
|
|
565
|
+
const tail = fallTail(list, last.floorY);
|
|
566
|
+
return tail ? { floorY: last.floorY, y: last.pos[1], from: list.length - tail.length } : null;
|
|
567
|
+
}
|
|
568
|
+
|
|
536
569
|
/**
|
|
537
570
|
* Movement inputs of `among` that something stopped: held long enough, received, and moved the player less than blockedShare of
|
|
538
571
|
* the run's usual distance for that time (the median over the run's movement inputs that moved), one a place (places at least
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"language": "2b95828c77a8e82440c53d330381b7ba830796312d2ae9b7edc8fd95ff72e1ef",
|
|
5
5
|
"memory": "76ad175baeb3f066ff566f76460d4b414c545f683fe4fe0ab16b0125a63d3fce",
|
|
6
6
|
"controlbook": "1b388c0dd0c60f332131a095cf89eb4ee181671c60a2b4e45750a0a918c6ea9e",
|
|
7
|
-
"genre": "
|
|
8
|
-
"genre2d": "
|
|
7
|
+
"genre": "5b26e7a610622599f8e0b2dcdeff3748e00e47f89a3be282abafac359a73443c",
|
|
8
|
+
"genre2d": "e8d8c607f61d1049a8a031263ac464dc15db2988a88fb0796bca05ab5da1ef4e",
|
|
9
9
|
"sound": "bc1264cb971417f4c6c6966ecba217721e59bc30dc069b48ade0bf8174e1444e",
|
|
10
10
|
"gamenotes": "f0ab9c9be900c17824d6e37beeead7210bfe280573860e4d0ecd4ac2edd36678",
|
|
11
11
|
"claimwords": "6cd99897a09dae67d0b657a110476fb0f8b27ae4124da9c60b79b2b0d28133b7",
|
|
12
12
|
"events": "8b1cbb4cf48b1e1e1f1de064e2f3cbf4ecd8473d4a518c20caa3c8953a3a1708",
|
|
13
13
|
"eventclaims": "11dfdd3e0928447ce3e21408c7b2f9eedb499e92ada39ca8b48222646cadc23b",
|
|
14
14
|
"egress": "65053e3fc47f9746f9662da8a5bfa2c31b7252d8c66528849fd0bf0b0006dd80",
|
|
15
|
-
"scene3d": "
|
|
15
|
+
"scene3d": "43d4ed85c9f2e0b2de93507b270c979e6e2b898d22902e34e381523b1d33486e"
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/run/args.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import { startProblems } from './startFrom.js';
|
|
14
14
|
import { sessionProblems } from './sessions.js';
|
|
15
|
+
import { launchArgProblems } from './launchArgs.js';
|
|
16
|
+
import { slowMotionProblems } from './slowMotion.js';
|
|
15
17
|
|
|
16
18
|
/** Options that take a value. */
|
|
17
19
|
const VALUED = new Map([
|
|
@@ -43,6 +45,8 @@ const VALUED = new Map([
|
|
|
43
45
|
['--godot-path', 'godotPath'],
|
|
44
46
|
['--cli', 'cli'],
|
|
45
47
|
['--max-actions', 'maxActions'],
|
|
48
|
+
// Slow motion through the SDK pause hook (./slowMotion.js): the share of its speed the game runs at while the persona decides.
|
|
49
|
+
['--time-scale', 'timeScale'],
|
|
46
50
|
['--concurrency', 'concurrency'],
|
|
47
51
|
['--quality', 'quality'],
|
|
48
52
|
['--key-modifier', 'keyModifier'],
|
|
@@ -62,7 +66,9 @@ const REPEATED = new Map([
|
|
|
62
66
|
['--focus', 'focus'],
|
|
63
67
|
['--avoid', 'avoid'],
|
|
64
68
|
// A save file a native local run starts from, up to eight (./startFrom.js).
|
|
65
|
-
['--save', 'save']
|
|
69
|
+
['--save', 'save'],
|
|
70
|
+
// An argument handed to a native build this machine starts, never through a shell (./launchArgs.js).
|
|
71
|
+
['--launch-arg', 'launchArg']
|
|
66
72
|
]);
|
|
67
73
|
|
|
68
74
|
/** Options that are just present or absent. */
|
|
@@ -104,6 +110,8 @@ const BOOLEAN = new Map([
|
|
|
104
110
|
// godot_driver only: let the game run in real time between actions instead
|
|
105
111
|
// of pausing it while the persona thinks.
|
|
106
112
|
['--realtime', 'realtime'],
|
|
113
|
+
// Keep a --realtime action game at full speed: no slow motion (./slowMotion.js).
|
|
114
|
+
['--no-slow-motion', 'noSlowMotion'],
|
|
107
115
|
// Native drivers only: register without the free automation probe first.
|
|
108
116
|
['--skip-preflight', 'skipPreflight'],
|
|
109
117
|
// Resume only: replay an interrupted run from the start instead of writing a
|
|
@@ -123,7 +131,7 @@ const BOOLEAN = new Map([
|
|
|
123
131
|
]);
|
|
124
132
|
|
|
125
133
|
/** Options whose value is a number. */
|
|
126
|
-
const NUMERIC = new Set(['maxActions', 'concurrency', 'minutes', 'sessions']);
|
|
134
|
+
const NUMERIC = new Set(['maxActions', 'concurrency', 'minutes', 'sessions', 'timeScale']);
|
|
127
135
|
|
|
128
136
|
/**
|
|
129
137
|
* @param {string[]} argv the leftovers commander handed over
|
|
@@ -275,7 +283,8 @@ export function scopeProblems(options = {}, driverName = '') {
|
|
|
275
283
|
if (typeof options.start !== 'string' || !/^[?#][^\s\\]{0,199}$/.test(options.start)) problems.push('Choose --start as a query or hash on the build, such as ?level=3 or #boss.');
|
|
276
284
|
else if (driverName && driverName !== 'playwright_web') problems.push(`--start opens a web build at a query or hash, and this run uses ${driverName}. A native run starts from --save or --start-spec.`);
|
|
277
285
|
}
|
|
278
|
-
problems.push(...startProblems(options, driverName), ...sessionProblems(options, driverName));
|
|
286
|
+
problems.push(...startProblems(options, driverName), ...sessionProblems(options, driverName), ...launchArgProblems(options, driverName));
|
|
287
|
+
problems.push(...slowMotionProblems(options, driverName));
|
|
279
288
|
return problems;
|
|
280
289
|
}
|
|
281
290
|
|
|
@@ -23,7 +23,7 @@ export const MAX_GAME_ARG_CHARS = 1024;
|
|
|
23
23
|
export function gameArgs(args) {
|
|
24
24
|
if (args === undefined || args === null) return [];
|
|
25
25
|
if (!Array.isArray(args) || args.length > MAX_GAME_ARGS || !args.every(arg => typeof arg === 'string' && arg.length <= MAX_GAME_ARG_CHARS && !arg.includes('\0'))) {
|
|
26
|
-
throw new Error(`native.args must be a list of at most ${MAX_GAME_ARGS} strings.`);
|
|
26
|
+
throw new Error(`The game's arguments (native.args and --launch-arg together) must be a list of at most ${MAX_GAME_ARGS} strings, each at most ${MAX_GAME_ARG_CHARS} characters.`);
|
|
27
27
|
}
|
|
28
28
|
return [...args];
|
|
29
29
|
}
|
|
@@ -333,4 +333,62 @@ export function describeEnd({ exited, crash, lastError = null, recent = [] }) {
|
|
|
333
333
|
return { kind: 'exited', message: `The game process stopped during play (${status}); it left no crash report, so the game itself quit${exited.code && lastError ? `. The last error it printed: ${String(lastError).slice(0, 300)}` : ''}`, ...tail };
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
/** How long a game is given to quit after Command-Q between sessions, then after a stop signal. */
|
|
337
|
+
export const QUIT_WAIT_MS = 10000;
|
|
338
|
+
export const TERM_WAIT_MS = 5000;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Quit a game the way a player does, between two sessions of a run
|
|
342
|
+
* (../../sessions.js): Command-Q first, its own Quit, so a game that saves on
|
|
343
|
+
* quit saves; then a polite stop signal (SIGTERM, which SDL and Unreal read
|
|
344
|
+
* as a quit); then a kill. Answers how it went: quit, stop_signal, killed or
|
|
345
|
+
* already_gone.
|
|
346
|
+
*
|
|
347
|
+
* @param {{exitPromise: Promise<unknown>, kill: (signal: string) => unknown}} game
|
|
348
|
+
* @param {{exited: () => unknown, commandQ?: (() => Promise<unknown>)|null, quitWaitMs?: number, termWaitMs?: number}} options
|
|
349
|
+
*/
|
|
350
|
+
export async function quitLikeAPlayer(game, { exited, commandQ = null, quitWaitMs = QUIT_WAIT_MS, termWaitMs = TERM_WAIT_MS }) {
|
|
351
|
+
const grace = ms => new Promise(resolve => setTimeout(resolve, ms).unref?.());
|
|
352
|
+
const gone = ms => Promise.race([game.exitPromise.then(() => true), grace(ms).then(() => false)]);
|
|
353
|
+
if (exited()) return 'already_gone';
|
|
354
|
+
if (commandQ) {
|
|
355
|
+
await commandQ().catch(() => null);
|
|
356
|
+
if (await gone(quitWaitMs)) return 'quit';
|
|
357
|
+
}
|
|
358
|
+
game.kill('SIGTERM');
|
|
359
|
+
if (await gone(termWaitMs)) return 'stop_signal';
|
|
360
|
+
game.kill('SIGKILL');
|
|
361
|
+
await gone(2000);
|
|
362
|
+
return 'killed';
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* The pause hook's summary across a run's sessions: the first launch's answer, with the times the game resumed
|
|
367
|
+
* by itself added up over every launch, and an end said when a launch's channel closed early.
|
|
368
|
+
*/
|
|
369
|
+
export function sessionTimeSummary(earlier = [], current = null) {
|
|
370
|
+
const all = [...earlier, ...(current ? [current] : [])].filter(Boolean);
|
|
371
|
+
if (!all.length) return null;
|
|
372
|
+
if (all.length === 1) return all[0];
|
|
373
|
+
const first = all.find(entry => entry.hook) || all[0];
|
|
374
|
+
const sum = key => all.reduce((total, entry) => total + (Number.isFinite(entry[key]) ? entry[key] : 0), 0);
|
|
375
|
+
const ended = all.find(entry => entry.ended);
|
|
376
|
+
const { ended: _ended, ...rest } = first;
|
|
377
|
+
const slowMotion = sessionSlowMotion(all);
|
|
378
|
+
return { ...rest, ...(first.hook ? { auto_resumed: sum('auto_resumed'), auto_resume_refused: sum('auto_resume_refused') } : {}), ...(ended ? { ended: ended.ended } : {}), ...(slowMotion ? { slow_motion: slowMotion } : {}) };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Slow motion across sessions (../../slowMotion.js): the first launch that slowed the game, with the slowed time of every launch added up. */
|
|
382
|
+
function sessionSlowMotion(all) {
|
|
383
|
+
const records = all.map(entry => entry.slow_motion).filter(record => record && typeof record === 'object');
|
|
384
|
+
if (!records.length) return null;
|
|
385
|
+
const base = records.find(record => record.status === 'on') || records[0];
|
|
386
|
+
const timed = records.filter(record => Number.isFinite(record.slowed_wall_ms));
|
|
387
|
+
if (!timed.length) return base;
|
|
388
|
+
const { measured_scale: _measured, ...kept } = base;
|
|
389
|
+
const gameMs = timed.reduce((total, record) => total + (Number.isFinite(record.slowed_game_ms) ? record.slowed_game_ms : 0), 0);
|
|
390
|
+
const wallMs = timed.reduce((total, record) => total + record.slowed_wall_ms, 0);
|
|
391
|
+
return { ...kept, slowed_game_ms: gameMs, slowed_wall_ms: wallMs, ...(wallMs > 0 ? { measured_scale: Math.round((gameMs / wallMs) * 1000) / 1000 } : {}) };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export default { quitLikeAPlayer, sessionTimeSummary, gameEnvironment, screenPoint, gamePixel, lookSteps, captureWindow, launchGame, stopGame, startFrameRecorder, runScreenshot, viewText, describeEnd, abnormalExit, DESKTOP_LOCK };
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
// feeds the world watch (../../world3d.js). What the game prints is read for
|
|
14
14
|
// its errors (./output.js), and when it dies, the report macOS left says why.
|
|
15
15
|
// No automation server, no network, nothing outside this run.
|
|
16
|
+
//
|
|
17
|
+
// A run that starts from a save or plays several sessions gives the game a
|
|
18
|
+
// home folder of its own (./runHome.js) with the saves in it, and the start
|
|
19
|
+
// spec in its environment (RAVENSIGHT_PLAYTEST_START, first launch only).
|
|
20
|
+
// Between sessions the game is quit the way a player quits it (relaunch)
|
|
21
|
+
// and started again on the same home.
|
|
16
22
|
import { spawn } from 'node:child_process';
|
|
17
23
|
import { randomBytes } from 'node:crypto';
|
|
18
24
|
import fs from 'node:fs/promises';
|
|
@@ -35,7 +41,9 @@ import { describeGame, inspectDesktopApp } from './app.js';
|
|
|
35
41
|
import { startDesktopHelper } from './helper.js';
|
|
36
42
|
import { actionKeyCodes } from './keys.js';
|
|
37
43
|
import { createOutputTail } from './output.js';
|
|
38
|
-
import {
|
|
44
|
+
import { createRunHome, needsRunHome, startAnswerOf } from './runHome.js';
|
|
45
|
+
import { START_ENV } from '../../startFrom.js';
|
|
46
|
+
import { bundleOf, crashWait, quitLikeAPlayer, QUIT_WAIT_MS, TERM_WAIT_MS, sessionTimeSummary, captureWindow, launchThroughLaunchServices, DESKTOP_LOCK, describeEnd, gameEnvironment, launchGame, lookSteps, MODEL_LONG_EDGE, RECORD_INTERVAL_MS, runScreenshot, screenPoint, startFrameRecorder, stopGame as stopProcess, viewText } from './common.js';
|
|
39
47
|
|
|
40
48
|
export const DRIVER_NAME = 'desktop_driver';
|
|
41
49
|
/** The most notches one scroll turns the wheel. */
|
|
@@ -60,9 +68,18 @@ export function createDesktopAppDriver({
|
|
|
60
68
|
native: plan = {}, startHelper = startDesktopHelper, spawnGame = spawn, lock = lockDevice, inspect = inspectDesktopApp,
|
|
61
69
|
digest = buildDigest, windowCapture = captureWindow, encode = encodeFrames, now = Date.now, platform = process.platform,
|
|
62
70
|
settleMs = 200, windowTimeoutMs = 90000, helloTimeoutMs = 10000, recordIntervalMs = RECORD_INTERVAL_MS,
|
|
63
|
-
playtest = null, pauseHook = true, timeControl:
|
|
64
|
-
findCrashImpl = findCrash, launchServices = true, launchApp = launchThroughLaunchServices
|
|
71
|
+
playtest = null, pauseHook = true, slowMotion = null, timeControl: givenTimeControl = createTimeControl, home = os.homedir(), crashWaitMs = 6000,
|
|
72
|
+
findCrashImpl = findCrash, launchServices = true, launchApp = launchThroughLaunchServices,
|
|
73
|
+
makeRunHome = createRunHome, quitWaitMs = QUIT_WAIT_MS, termWaitMs = TERM_WAIT_MS
|
|
65
74
|
} = {}) {
|
|
75
|
+
// The time control is made again for each session's launch, with the options of the first (relaunch).
|
|
76
|
+
let timeOptions = null;
|
|
77
|
+
// Slow motion asked for after a hello (an action game, ../../slowMotion.js) is asked of each relaunch's hook again.
|
|
78
|
+
let slowAsked = null;
|
|
79
|
+
const makeTimeControl = options => { timeOptions = options; return givenTimeControl(options); };
|
|
80
|
+
// Where the run starts (../../startFrom.js): a home of the run's own, with the saves in it, and the start spec.
|
|
81
|
+
const start = plan.start && ((plan.start.saves && plan.start.saves.length) || plan.start.spec) ? plan.start : null;
|
|
82
|
+
let runHome = null, launchToken = null, timeSummaries = [];
|
|
66
83
|
let metadata, runDirectory, signal, unlock, helper, game, source, window, frame, pendingFrame, startedAt, stopPromise, access;
|
|
67
84
|
let step = 0, shots = 0, gameEnded = null, exited = null, launched = false, pointerAt = null;
|
|
68
85
|
let recorder = null;
|
|
@@ -84,7 +101,7 @@ export function createDesktopAppDriver({
|
|
|
84
101
|
await stopPromise.catch(() => {});
|
|
85
102
|
stopPromise = null; unlock = null; helper = null; game = null; source = null; window = null; frame = null; pendingFrame = null;
|
|
86
103
|
gameEnded = null; exited = null; launched = false; pointerAt = null; recorder = null; time = null; lastView = undefined;
|
|
87
|
-
output = null; ending = null; access = null; step = 0; shots = 0;
|
|
104
|
+
output = null; ending = null; access = null; step = 0; shots = 0; runHome = null; timeSummaries = []; slowAsked = null; driver.sessions = 0;
|
|
88
105
|
heldErrors.length = 0; world = createWorldWatch(); Object.assign(metrics, freshMetrics());
|
|
89
106
|
}
|
|
90
107
|
const label = () => describeGame(metadata);
|
|
@@ -129,13 +146,13 @@ export function createDesktopAppDriver({
|
|
|
129
146
|
if (stopPromise) return stopPromise;
|
|
130
147
|
stopPromise = (async () => {
|
|
131
148
|
let result = { videoPath: null };
|
|
132
|
-
const timeControl = time ? time.summary() : null;
|
|
149
|
+
const timeControl = sessionTimeSummary(timeSummaries, time ? time.summary() : null);
|
|
133
150
|
try {
|
|
134
151
|
if (recorder) result = await recorder.stop(exited && !['stopped', 'preflight', 'completed'].includes(reason) ? 'game_exited' : reason);
|
|
135
152
|
// Resume the game before it is stopped, so nothing is left frozen.
|
|
136
153
|
if (time) await time.close().catch(() => {});
|
|
137
154
|
} finally {
|
|
138
|
-
try { await stopGame(); await helper?.stop(); }
|
|
155
|
+
try { await stopGame(); await helper?.stop(); await runHome?.remove(); }
|
|
139
156
|
finally { await unlock?.(); }
|
|
140
157
|
}
|
|
141
158
|
return timeControl ? { ...result, timeControl } : result;
|
|
@@ -166,15 +183,45 @@ export function createDesktopAppDriver({
|
|
|
166
183
|
const raised = await helper.send({ kind: 'raise', pid: game.pid, ...point });
|
|
167
184
|
if (!raised.onTop) throw new Error('Another window covers the game and the game could not be brought to the front; the input was not sent.');
|
|
168
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Start the game once with `env` (cleaned of credentials, the pause hook's variables added), the run's home and,
|
|
188
|
+
* on the first launch only, the start spec; then wait for its window. A later session plays on from what it saved.
|
|
189
|
+
*/
|
|
190
|
+
async function openGame(env, { first }) {
|
|
191
|
+
const token = {};
|
|
192
|
+
launchToken = token;
|
|
193
|
+
const onExit = ended => { if (launchToken === token) exited = ended; };
|
|
194
|
+
const full = { ...env, ...(runHome ? runHome.env : {}), ...(first && start && start.spec ? { [START_ENV]: start.spec } : {}) };
|
|
195
|
+
// An app (and the LÖVE runtime, an app too) starts through LaunchServices, so macOS lets it come to
|
|
196
|
+
// the front for clicks; a bare executable is started directly.
|
|
197
|
+
const bundle = launchServices ? bundleOf(metadata) : null;
|
|
198
|
+
metrics.launch = bundle ? 'launch-services' : 'direct';
|
|
199
|
+
const { child } = bundle
|
|
200
|
+
? await launchApp(bundle, metadata.executablePath, metadata.args || [], { env: full, now, find: request => helper.send({ kind: 'find', ...request }), onExit })
|
|
201
|
+
: launchGame(metadata.executablePath, metadata.args || [], { stdio: ['ignore', 'pipe', 'pipe'], env: full, cwd: metadata.cwd || undefined, spawnGame, now, onExit });
|
|
202
|
+
game = child;
|
|
203
|
+
output = createOutputTail([child.stdout, child.stderr]);
|
|
204
|
+
const deadline = now() + windowTimeoutMs;
|
|
205
|
+
while (!exited && !await refreshWindow()) {
|
|
206
|
+
if (now() > deadline) throw new Error('The game did not open a window in time.');
|
|
207
|
+
await sleep(250, signal);
|
|
208
|
+
}
|
|
209
|
+
if (exited) {
|
|
210
|
+
await endedBy();
|
|
211
|
+
throw new Error(`The game exited during launch (${exited.signal || `code ${exited.code}`}).${output.last ? ` It printed: ${output.last}` : ''}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
169
214
|
const driver = {
|
|
170
215
|
name: DRIVER_NAME, touch: false, exactScreenshots: true, supportsHold: true,
|
|
171
216
|
supportedActions: ['click', 'key', 'type', 'wait'],
|
|
172
217
|
/** Frozen between actions while the SDK pause hook holds the game. */
|
|
173
218
|
get frozenBetweenActions() { return Boolean(time && time.engaged); },
|
|
219
|
+
/** Slow the game while the playtester decides, once its kind is settled as an action game (../../slowMotion.js). */
|
|
220
|
+
async slowDown(options) { slowAsked = { ...(options || {}) }; return time ? time.slowDown(options) : { status: 'not_supported', reason: 'style', scale: null }; },
|
|
174
221
|
/** Drag, hover and mouse look, and the wheel; no gamepad (there is no virtual pad without an engine module). */
|
|
175
222
|
pointerTools: ['drag', 'look', 'hover', 'scroll'],
|
|
176
223
|
get playNote() {
|
|
177
|
-
const timing = time && time.engaged ? 'The game is paused while you decide; it runs during each input and for half a second after it.' : 'The game runs continuously while you think: timers and enemies do not pause.';
|
|
224
|
+
const timing = time && time.engaged ? 'The game is paused while you decide; it runs during each input and for half a second after it.' : (time && time.timingLine()) || 'The game runs continuously while you think: timers and enemies do not pause.';
|
|
178
225
|
return `This is a desktop game (${label()}) running in a window on this computer. Read each current screenshot and use its x,y coordinates for the mouse. click is a mouse click (button, double and hold_ms work); drag presses, moves and releases the mouse; hover with x and y moves the pointer there. key presses physical keyboard keys: hold_ms holds a key while the game runs, to walk or steer, and with_keys holds more keys at once. hover with dx and dy moves the mouse by that much, as mouse look reads it (turns a first person view or orbits a camera), and with_keys walks while it turns. scroll turns the mouse wheel. ${timing} There is no touch and no gamepad in this runner. If repeated inputs do not produce the expected change, reassess the target and try another input the game asks for instead of repeating the same one.`;
|
|
179
226
|
},
|
|
180
227
|
async launch({ target, runDir, recordVideo = false, signal: abort }) {
|
|
@@ -188,6 +235,8 @@ export function createDesktopAppDriver({
|
|
|
188
235
|
metadata = plan.metadata || await inspect(file, { args: plan.args });
|
|
189
236
|
metrics.engine = metadata.engine;
|
|
190
237
|
unlock = await lock(DESKTOP_LOCK);
|
|
238
|
+
// Saves and sessions play in a home of the run's own, never the developer's (./runHome.js).
|
|
239
|
+
if (needsRunHome(plan)) runHome = await makeRunHome({ plan, metadata, bundle: bundleOf(metadata) });
|
|
191
240
|
helper = await startHelper({ signal });
|
|
192
241
|
access = await helper.send({ kind: 'access' });
|
|
193
242
|
if (!access.accessibility) throw new Error('macOS has not allowed this terminal to send mouse and keyboard input (System Settings, Privacy and Security, Accessibility).');
|
|
@@ -196,29 +245,13 @@ export function createDesktopAppDriver({
|
|
|
196
245
|
let env = gameEnvironment();
|
|
197
246
|
if (pauseHook !== false) {
|
|
198
247
|
const identity = playtest && playtest.token && playtest.runId ? playtest : { token: 'local-check', runId: `check_${randomBytes(6).toString('hex')}` };
|
|
199
|
-
time = makeTimeControl({ playtest: identity, realtime: pauseHook === 'realtime' });
|
|
248
|
+
time = makeTimeControl({ playtest: identity, realtime: pauseHook === 'realtime', ...(slowMotion ? { slowMotion } : {}) });
|
|
200
249
|
const extra = await time.start();
|
|
201
250
|
if (Object.keys(extra).length) env = { ...env, ...extra };
|
|
202
251
|
else time = null;
|
|
203
252
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const bundle = launchServices ? bundleOf(metadata) : null;
|
|
207
|
-
metrics.launch = bundle ? 'launch-services' : 'direct';
|
|
208
|
-
const { child } = bundle
|
|
209
|
-
? await launchApp(bundle, metadata.executablePath, metadata.args || [], { env, now, find: request => helper.send({ kind: 'find', ...request }), onExit: ended => { exited = ended; } })
|
|
210
|
-
: launchGame(metadata.executablePath, metadata.args || [], { stdio: ['ignore', 'pipe', 'pipe'], env, cwd: metadata.cwd || undefined, spawnGame, now, onExit: ended => { exited = ended; } });
|
|
211
|
-
game = child;
|
|
212
|
-
output = createOutputTail([child.stdout, child.stderr]);
|
|
213
|
-
const deadline = now() + windowTimeoutMs;
|
|
214
|
-
while (!exited && !await refreshWindow()) {
|
|
215
|
-
if (now() > deadline) throw new Error('The game did not open a window in time.');
|
|
216
|
-
await sleep(250, signal);
|
|
217
|
-
}
|
|
218
|
-
if (exited) {
|
|
219
|
-
await endedBy();
|
|
220
|
-
throw new Error(`The game exited during launch (${exited.signal || `code ${exited.code}`}).${output.last ? ` It printed: ${output.last}` : ''}`);
|
|
221
|
-
}
|
|
253
|
+
await openGame(env, { first: true });
|
|
254
|
+
driver.sessions = 1;
|
|
222
255
|
// The SDK connects a moment after the game starts; give it that before the first look.
|
|
223
256
|
if (time) await time.waitForHello(helloTimeoutMs);
|
|
224
257
|
if (time && time.offersFrame) source = 'game';
|
|
@@ -233,11 +266,50 @@ export function createDesktopAppDriver({
|
|
|
233
266
|
throw new DriverError(error.message, { fatal: true });
|
|
234
267
|
}
|
|
235
268
|
},
|
|
269
|
+
/** What the game was told about where to start: it reads the spec itself, so the run only knows it was sent. */
|
|
270
|
+
get startAnswer() { return startAnswerOf(start, runHome); },
|
|
271
|
+
/** Launches of the game so far in this run. */
|
|
272
|
+
sessions: 0,
|
|
273
|
+
/**
|
|
274
|
+
* A new session of the same run (../../sessions.js): the game is quit the way a player quits it and started
|
|
275
|
+
* again on the run's own home, with what it saved there and no start spec. The video goes on through it.
|
|
276
|
+
*/
|
|
277
|
+
async relaunch() {
|
|
278
|
+
if (!launched || !game) throw new Error('The game has not launched.');
|
|
279
|
+
if (exited) throw new Error('The game has exited.');
|
|
280
|
+
// The hook's close lets the game run, so it can save as it quits.
|
|
281
|
+
if (time) { timeSummaries.push(time.summary()); await time.close().catch(() => {}); time = null; }
|
|
282
|
+
// Command-Q goes through macOS, so it needs the input permission; without it the game gets the stop signal.
|
|
283
|
+
const commandQ = access && access.accessibility ? async () => { await forward(); await helper.send({ kind: 'keys', pid: game.pid, codes: actionKeyCodes({ key: 'Meta+q' }), holdMs: 0 }); } : null;
|
|
284
|
+
const closed = await quitLikeAPlayer(game, { exited: () => exited, commandQ, quitWaitMs, termWaitMs });
|
|
285
|
+
if (output) heldErrors.push(...await output.read());
|
|
286
|
+
exited = null; ending = null; gameEnded = null; window = null; pendingFrame = null; lastView = undefined; pointerAt = null;
|
|
287
|
+
let env = gameEnvironment();
|
|
288
|
+
if (timeOptions) {
|
|
289
|
+
time = makeTimeControl(timeOptions);
|
|
290
|
+
const extra = await time.start();
|
|
291
|
+
if (Object.keys(extra).length) env = { ...env, ...extra };
|
|
292
|
+
else time = null;
|
|
293
|
+
}
|
|
294
|
+
const cameBack = async () => {
|
|
295
|
+
await openGame(env, { first: false });
|
|
296
|
+
if (time) await time.waitForHello(helloTimeoutMs);
|
|
297
|
+
if (time && time.offersFrame) source = 'game';
|
|
298
|
+
else if (access.screenCapture) source = 'window';
|
|
299
|
+
else throw new Error('The game came back without sending its own frames, and macOS has not allowed this terminal to record the screen.');
|
|
300
|
+
frame = await capture();
|
|
301
|
+
};
|
|
302
|
+
// A game that dies as it starts again is said as that, whichever step saw it go.
|
|
303
|
+
await cameBack().catch(error => { throw exited && !/exited during launch/.test(error.message) ? new Error(`The game exited as it started again (${exited.signal || `code ${exited.code}`}).`) : error; });
|
|
304
|
+
if (time && slowAsked) await time.slowDown(slowAsked).catch(() => null);
|
|
305
|
+
driver.sessions += 1;
|
|
306
|
+
return { session: driver.sessions, scene: null, files: runHome ? await runHome.savedFiles().catch(() => null) : null, closed };
|
|
307
|
+
},
|
|
236
308
|
async observe() {
|
|
237
309
|
if (time && !pendingFrame) await time.park();
|
|
238
310
|
frame = pendingFrame || await capture(); pendingFrame = null;
|
|
239
311
|
if (time && time.offersView3d && lastView === undefined) lastView = await time.view3d();
|
|
240
|
-
const timing = time && time.engaged ? 'The game is paused until your next input.' : 'The game is running in real time.';
|
|
312
|
+
const timing = time && time.engaged ? 'The game is paused until your next input.' : (time && time.timingLine()) || 'The game is running in real time.';
|
|
241
313
|
const view = viewText(lastView || null);
|
|
242
314
|
return { step: ++step, text: `Desktop game window on macOS (${label()}), ${frame.width} by ${frame.height} pixels. Use x,y screenshot coordinates. ${timing}${view ? `\n${view}` : ''}`, screenshotBase64: frame.png.toString('base64'), screenshotMediaType: 'image/png', elapsedMs: now() - startedAt };
|
|
243
315
|
},
|