feat(livestreamassist): expose current cluster string

This commit is contained in:
soarqin committed 2026-09-20 14:46:15 +08:00
1 parent 3e3e995d55
commit c0c4f51312
9 files changed
+59 -4

No files matched your search

+5
View File
@@ -105,6 +105,11 @@ Pass an array of positive integer item ids to share the factory scan; duplicates
- `getTechState(techId)` reads `history.techStates[techId]`.
- `getCurrentResearch()` reads `history.currentTech`, then that tech's state. `techId === 0` means no active research. `progressPercent` uses integer hash math, same as the sample overlay.
### Current cluster
- `getClusterString()` reads `game.gameDesc.clusterString`, the current Dyson Sphere Program star-cluster seed/address string.
- The result is `{ clusterString, sessionId, gameTick }`; the string is sampled on the game thread and is not cached across sessions.
### Dyson power
`getDysonPower()` sums `game.dysonSpheres[i].energyGenCurrentTick` across non-null spheres, projecting energy fields in collection pages. `getDysonPower({ starIndex })` reads only that sphere. Watts are `joulesPerTick * 60` (DSP ticks per second). `originalWatts` is the pre-Dark-Fog-debuff figure. Star display names use `overrideName` or `name` because `displayName` is a getter and is not readable through the API. Empty results retain their session metadata.
+13
View File
@@ -516,6 +516,19 @@
});
};
GameQuery.prototype.getClusterString = function () {
var self = this;
var context = {};
return this._read({ root: "game", path: ["gameDesc", "clusterString"] }, context).then(function (result) {
self._assertSession(context);
return {
clusterString: result.value == null ? "" : String(result.value),
sessionId: result.sessionId,
gameTick: result.gameTick
};
});
};
GameQuery.prototype._factoryIds = function (scope, context) {
if (scope === "localPlanet") {
return this._read({ root: "localPlanet", path: ["factoryIndex"] }, context).then(function (result) {
@@ -76,6 +76,15 @@ test("research from different saves is not combined", async () => {
await assert.rejects(query.getCurrentResearch(), { kind: "SESSION_CHANGED" });
});
test("cluster string reads the active game description", async () => {
const { query, calls } = createQuery(() => result("12345678-64-A10"));
const cluster = await query.getClusterString();
assert.equal(cluster.clusterString, "12345678-64-A10");
assert.equal(cluster.sessionId, "save-a");
assert.equal(calls[0].root, "game");
assert.equal(calls[0].path.join("."), "gameDesc.clusterString");
});
test("research progress keeps integer precision", async () => {
const { query } = createQuery(() => result({
hashUploaded: "9007199254740993", hashNeeded: "18014398509481986", curLevel: 1
+13
View File
@@ -126,6 +126,19 @@
});
};
GameQuery.prototype.getClusterString = function () {
var self = this;
var context = {};
return this._read({ root: "game", path: ["gameDesc", "clusterString"] }, context).then(function (result) {
self._assertSession(context);
return {
clusterString: result.value == null ? "" : String(result.value),
sessionId: result.sessionId,
gameTick: result.gameTick
};
});
};
GameQuery.prototype._factoryIds = function (scope, context) {
if (scope === "localPlanet") {
return this._read({ root: "localPlanet", path: ["factoryIndex"] }, context).then(function (result) {