cortico-world-genesis 2.0.2 → 2.1.4
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/CHANGELOG.md +75 -0
- package/README.md +8 -6
- package/describe.json +173 -6
- package/dist/webui.js +73 -6
- package/package.json +1 -1
- package/src/ENV_PROMPT.md +10 -4
- package/src/definition.ts +24 -3
- package/src/flora.ts +75 -1
- package/src/game.ts +270 -11
- package/src/guide/farm.md +13 -0
- package/src/guide/plan.md +2 -2
- package/src/guide/power.md +2 -2
- package/src/guide/trouble.md +1 -1
- package/src/guide/upgrade.md +1 -1
- package/src/guide-content.ts +5 -5
- package/src/index.ts +5 -0
- package/src/info.ts +76 -0
- package/src/inspect.ts +107 -0
- package/src/panel-types.ts +2 -0
- package/src/trade.ts +7 -8
- package/src/webui/client.ts +82 -6
- package/src/world.ts +421 -19
package/src/info.ts
CHANGED
|
@@ -10,13 +10,16 @@ import {
|
|
|
10
10
|
ARM_MAX_PER_PLANET,
|
|
11
11
|
ARM_RANGE_KM,
|
|
12
12
|
BUILD_SPECS,
|
|
13
|
+
COOLER_COST_KJ,
|
|
13
14
|
DUTY_MAX_SITES,
|
|
14
15
|
DUTY_RANGE_KM,
|
|
16
|
+
HEATER_COST_KJ,
|
|
15
17
|
TERMINAL_BAG_SLOTS,
|
|
16
18
|
TERMINAL_BUFFER_KG,
|
|
17
19
|
storeCapacityKg,
|
|
18
20
|
type StructureRecord,
|
|
19
21
|
} from './game.ts';
|
|
22
|
+
import { COUNTER_COST_KJ, MONITOR_COST_KJ, SAIL_COST_KJ, SAIL_KJ_PER_HOME_HOUR, SAIL_MAX_PER_PLANET } from './power.ts';
|
|
20
23
|
import { RESOURCE_LABELS, SPECIES } from './flora.ts';
|
|
21
24
|
import { LABOR_YIELD_BONUS, LABOR_YIELD_BONUS_MAX, RESIDENTS_PER_LABOR } from './life.ts';
|
|
22
25
|
import { SELL_GOODS } from './trade.ts';
|
|
@@ -242,6 +245,79 @@ export const INFO_ENTRIES: InfoEntry[] = (() => {
|
|
|
242
245
|
});
|
|
243
246
|
}
|
|
244
247
|
|
|
248
|
+
// 只能「安装」、不在 BUILD_SPECS 里的设备(帆、监测器、凌日计数器、气候核心)。
|
|
249
|
+
const devices: Array<{
|
|
250
|
+
id: string;
|
|
251
|
+
label: string;
|
|
252
|
+
aliases: string[];
|
|
253
|
+
facts: string[];
|
|
254
|
+
about: string;
|
|
255
|
+
usage?: string;
|
|
256
|
+
pitfalls?: string;
|
|
257
|
+
}> = [
|
|
258
|
+
{
|
|
259
|
+
id: 'sail',
|
|
260
|
+
label: '太阳能帆',
|
|
261
|
+
aliases: ['帆', '太阳能', '发电', 'solar'],
|
|
262
|
+
facts: [
|
|
263
|
+
`造价:${kj(SAIL_COST_KJ)} + 0 份钨`,
|
|
264
|
+
'施工:立刻(0.1 母星时)',
|
|
265
|
+
'维护:不耗电',
|
|
266
|
+
`产出:白天每母星时 ${SAIL_KJ_PER_HOME_HOUR.toLocaleString('en-US')} kJ,夜里 0`,
|
|
267
|
+
`上限:每颗行星 ${SAIL_MAX_PER_PLANET} 座`,
|
|
268
|
+
],
|
|
269
|
+
about: '最便宜的电:只在白天发电,产量按它自己的经纬度算。',
|
|
270
|
+
usage:
|
|
271
|
+
'站在陆地上 `genesis_install { id: "sail" }`。赤道常年一半一半,高纬冬天短、夏天长,极地有极昼极夜——选址是有意义的;经度错开可以让几座帆交替上班。',
|
|
272
|
+
pitfalls: '水里建不了;气态/冰巨星上建不了;夜里不发电,夜里要靠电池或火电。',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: 'monitor',
|
|
276
|
+
label: '环境监测器',
|
|
277
|
+
aliases: ['监测器', '监控', '观测'],
|
|
278
|
+
facts: [`造价:${kj(MONITOR_COST_KJ)} + 0 份钨`, '维护:不耗电'],
|
|
279
|
+
about: '装上之后,这个天体的属性才是「事实」——面板与工具栏才有它的详细数据。',
|
|
280
|
+
usage: '`genesis_install { id: "monitor" }`;母星装上会解锁恒星全貌。',
|
|
281
|
+
pitfalls: '没装的天体只能靠 `genesis_stargaze` 看个大概,模型不该编它的参数。',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: 'counter',
|
|
285
|
+
label: '凌日计数器',
|
|
286
|
+
aliases: ['凌日', '计数器', 'transit counter'],
|
|
287
|
+
facts: [`造价:${kj(COUNTER_COST_KJ)} + 0 份钨`, '维护:不耗电'],
|
|
288
|
+
about: '盯着恒星看行星从前面划过去,测出周期与大小。',
|
|
289
|
+
usage: '`genesis_install { id: "counter" }`。',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: 'cooler',
|
|
293
|
+
label: '制冷核心',
|
|
294
|
+
aliases: ['制冷', '冷却核心', '温室核心'],
|
|
295
|
+
facts: [`造价:${kj(COOLER_COST_KJ)} + 0 份钨`, '维护:1,500 kJ/母星时'],
|
|
296
|
+
about: '装在温室上,把温室的耐热上限再往上撑 33℃。',
|
|
297
|
+
usage: '先有温室,再 `genesis_install { id: "cooler", site: "<站点>" }`。',
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: 'heater',
|
|
301
|
+
label: '制热核心',
|
|
302
|
+
aliases: ['制热', '加热核心', '温室核心'],
|
|
303
|
+
facts: [`造价:${kj(HEATER_COST_KJ)} + 0 份钨`, '维护:400 kJ/母星时'],
|
|
304
|
+
about: '装在温室上,把温室的耐冷下限再往下撑 33℃。',
|
|
305
|
+
usage: '先有温室,再 `genesis_install { id: "heater", site: "<站点>" }`。',
|
|
306
|
+
},
|
|
307
|
+
];
|
|
308
|
+
for (const device of devices) {
|
|
309
|
+
entries.push({
|
|
310
|
+
id: device.id,
|
|
311
|
+
kind: 'building',
|
|
312
|
+
label: device.label,
|
|
313
|
+
aliases: device.aliases,
|
|
314
|
+
facts: device.facts,
|
|
315
|
+
about: device.about,
|
|
316
|
+
usage: device.usage,
|
|
317
|
+
pitfalls: device.pitfalls,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
245
321
|
for (const [id, label] of Object.entries(RESOURCE_LABELS)) { const note = RESOURCE_NOTES[id];
|
|
246
322
|
const sell = SELL_GOODS.find((good) => good.id === id);
|
|
247
323
|
const facts = sell
|
package/src/inspect.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
growthFactor,
|
|
3
|
+
NUTRIENT_IDS,
|
|
4
|
+
NUTRIENT_LABELS,
|
|
5
|
+
NUTRIENT_NEEDS,
|
|
6
|
+
scarcestNutrient,
|
|
7
|
+
SPECIES,
|
|
8
|
+
type ClimateSample,
|
|
9
|
+
type PlantRecord,
|
|
10
|
+
} from './flora.ts';
|
|
11
|
+
|
|
12
|
+
function pct(value: number): string {
|
|
13
|
+
return `${Math.round(value * 100)}%`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function round2(value: number): number {
|
|
17
|
+
return Math.round(value * 100) / 100;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** 温度和水分两段单独算出来,用于「为什么长得慢」的拆解。 */
|
|
21
|
+
function pieces(plant: PlantRecord, climate: ClimateSample): {
|
|
22
|
+
temp: number;
|
|
23
|
+
water: number;
|
|
24
|
+
nutrient: number;
|
|
25
|
+
fertility: number;
|
|
26
|
+
total: number;
|
|
27
|
+
} {
|
|
28
|
+
const spec = SPECIES[plant.species];
|
|
29
|
+
const t = plant.genes.tempOptC;
|
|
30
|
+
const inBand = climate.tempC >= spec.tempMinC && climate.tempC <= spec.tempMaxC;
|
|
31
|
+
const span = climate.tempC >= t ? Math.max(1e-6, spec.tempMaxC - t) : Math.max(1e-6, t - spec.tempMinC);
|
|
32
|
+
const temp = inBand ? Math.max(0, Math.min(1, 1 - Math.abs(climate.tempC - t) / span)) : 0;
|
|
33
|
+
const water = Math.max(0, Math.min(1, (climate.wetness - plant.genes.waterNeed) / 0.5));
|
|
34
|
+
const need = NUTRIENT_NEEDS[plant.species];
|
|
35
|
+
let nutrient = 1;
|
|
36
|
+
if (climate.nutrients) {
|
|
37
|
+
for (const dim of NUTRIENT_IDS) {
|
|
38
|
+
const limit = need[dim];
|
|
39
|
+
if (limit <= 0) continue;
|
|
40
|
+
nutrient = Math.min(nutrient, Math.max(0, Math.min(1, climate.nutrients[dim] / limit)));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { temp, water, nutrient, fertility: 0.6 + 0.4 * climate.fertility, total: growthFactor(plant, climate) };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 生长因子的一句话拆解。 */
|
|
47
|
+
export function growFactorText(plant: PlantRecord, climate: ClimateSample): string {
|
|
48
|
+
const p = pieces(plant, climate);
|
|
49
|
+
return `温度 ×${round2(p.temp)} · 水分 ×${round2(p.water)} · 养分 ×${round2(p.nutrient)} · 肥力 ×${round2(p.fertility)} → 合计 ×${round2(p.total)}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 按当前气候还要多少母星时。0 表示已经到顶。 */
|
|
53
|
+
function hoursLeft(plant: PlantRecord, climate: ClimateSample): number | null {
|
|
54
|
+
const spec = SPECIES[plant.species];
|
|
55
|
+
const factor = growthFactor(plant, climate);
|
|
56
|
+
if (factor <= 0) return null;
|
|
57
|
+
if (plant.stage === 'ripe' || plant.stage === 'withering') return 0;
|
|
58
|
+
if (spec.model === 'colony') {
|
|
59
|
+
const cap = spec.yieldKg * plant.genes.yield;
|
|
60
|
+
if (cap <= 0) return null;
|
|
61
|
+
const rate = (cap * Math.LN2) / Math.max(1e-6, spec.cycleHomeHours);
|
|
62
|
+
return Math.max(0, Math.round(((cap - plant.biomassKg) / (rate * factor)) * 10) / 10);
|
|
63
|
+
}
|
|
64
|
+
const perHour = (plant.genes.growthRate / Math.max(1e-6, spec.cycleHomeHours)) * factor;
|
|
65
|
+
return Math.max(0, Math.round(((0.9 - plant.progress) / perHour) * 10) / 10);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 一株作物的详情卡:基因、有效温区、当前气候、四维养分、生长因子拆解、预计收成。
|
|
70
|
+
* 纯函数,面板与工具共用。
|
|
71
|
+
*/
|
|
72
|
+
export function inspectPlantText(plant: PlantRecord, climate: ClimateSample, siteLabel: string): string {
|
|
73
|
+
const spec = SPECIES[plant.species];
|
|
74
|
+
const p = pieces(plant, climate);
|
|
75
|
+
const need = NUTRIENT_NEEDS[plant.species];
|
|
76
|
+
const lines: string[] = [];
|
|
77
|
+
lines.push(`${spec.name}(${plant.id})· ${siteLabel}`);
|
|
78
|
+
lines.push(` 阶段:${plant.stage} · 进度 ${pct(plant.progress)} · 健康 ${pct(plant.health)}${plant.stress ? ' · 应激' : ''}`);
|
|
79
|
+
lines.push(
|
|
80
|
+
` 基因:最适 ${plant.genes.tempOptC}℃ · 需水 ${plant.genes.waterNeed} · 长速 ×${plant.genes.growthRate} · 产量 ×${plant.genes.yield} · 耐人工气候 ${plant.genes.climateTolerance ?? 0}`,
|
|
81
|
+
);
|
|
82
|
+
lines.push(` 有效温区:${spec.tempMinC}–${plant.genes.tempOptC}–${spec.tempMaxC}℃(物种 ${spec.tempMinC}–${spec.tempOptC}–${spec.tempMaxC})`);
|
|
83
|
+
lines.push(` 这里:${climate.tempC}℃ · 湿度 ${climate.wetness} · 肥力 ${climate.fertility}`);
|
|
84
|
+
if (climate.nutrients) {
|
|
85
|
+
const parts = NUTRIENT_IDS.map((dim) => {
|
|
86
|
+
const stock = climate.nutrients![dim];
|
|
87
|
+
const ok = need[dim] <= 0 || stock >= need[dim];
|
|
88
|
+
return `${NUTRIENT_LABELS[dim]} ${stock}/${need[dim]}${ok ? '' : '↓'}`;
|
|
89
|
+
});
|
|
90
|
+
const worst = scarcestNutrient(plant, climate);
|
|
91
|
+
lines.push(` 养分:${parts.join(' · ')}${worst ? `(最缺${NUTRIENT_LABELS[worst]})` : ''}`);
|
|
92
|
+
} else {
|
|
93
|
+
lines.push(' 养分:这块地没有养分记录。');
|
|
94
|
+
}
|
|
95
|
+
lines.push(` 生长:${growFactorText(plant, climate)}`);
|
|
96
|
+
const hours = hoursLeft(plant, climate);
|
|
97
|
+
if (p.total <= 0) {
|
|
98
|
+
lines.push(' 现在完全不长:看上面哪一项是 ×0,先把它补上(温度/湿度/养分)。');
|
|
99
|
+
} else if (hours !== null) {
|
|
100
|
+
lines.push(hours <= 0 ? ' 可以收了。' : ` 按这个速度还要 ${hours} 母星时。`);
|
|
101
|
+
}
|
|
102
|
+
if (spec.model === 'individual') {
|
|
103
|
+
const yieldKg = spec.yieldKg * plant.genes.yield * (0.7 + 0.3 * climate.fertility);
|
|
104
|
+
lines.push(` 预计收成:${round2(yieldKg)} kg ${spec.resource}(按当前肥力)`);
|
|
105
|
+
}
|
|
106
|
+
return lines.join('\n');
|
|
107
|
+
}
|
package/src/panel-types.ts
CHANGED
|
@@ -102,6 +102,8 @@ export interface GenesisPanelFlora {
|
|
|
102
102
|
shopWindow: string;
|
|
103
103
|
shopLevel: number;
|
|
104
104
|
sites: { key: string; kind: string; plants: number; ripe: number; latDeg: number; lonDeg: number }[];
|
|
105
|
+
/** 每株/每群的当前状态(移栽时挑得到具体哪一株)。 */
|
|
106
|
+
crops?: { site: string; id: string; species: string; name: string; stage: string; progress: number; ripe: boolean; health: number; dead: boolean }[];
|
|
105
107
|
inventory: { id: string; name: string; amount: number }[];
|
|
106
108
|
bags: { id: string; name: string; count: number; premium: boolean }[];
|
|
107
109
|
/** 种植盆:不占站点、不能当容器,只同时种 3 粒;通电时人工气候。 */
|
package/src/trade.ts
CHANGED
|
@@ -183,12 +183,11 @@ export function telescopeWindow(level: number): string {
|
|
|
183
183
|
/**
|
|
184
184
|
* 【火花塞】:动能发电机的产能升级。
|
|
185
185
|
*
|
|
186
|
-
* 发电机本身是
|
|
187
|
-
* lv1
|
|
188
|
-
*
|
|
189
|
-
* lv1 只要 12,000 kJ(烧 3.2 kg 生物质就够),所以第一级是「应急手段」而不是工程。
|
|
186
|
+
* 发电机本身是 50 kJ/次(人类手摇,0.5 秒冷却),火花塞每级往上抬一档:
|
|
187
|
+
* lv1 200、lv2 350、lv3 500 kJ。它从来不是主电源——真正的电来自烧燃料和太阳能帆;
|
|
188
|
+
* 火花塞只是让「实在没电、又等不到收货」的时候不至于卡死:满级约 40 分钟手摇能攒出 100,000 kJ。
|
|
190
189
|
*/
|
|
191
|
-
export const GENERATOR_BASE_KJ =
|
|
190
|
+
export const GENERATOR_BASE_KJ = 50;
|
|
192
191
|
export const SPARK_PLUG_MAX_LEVEL = 3;
|
|
193
192
|
|
|
194
193
|
export interface SparkPlugLevelSpec {
|
|
@@ -201,9 +200,9 @@ export interface SparkPlugLevelSpec {
|
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
export const SPARK_PLUG_LEVELS: SparkPlugLevelSpec[] = [
|
|
204
|
-
{ level: 1, costKj: 12_000, homeHours: 0.25, materials: { fiber: 0.5 }, outputKj:
|
|
205
|
-
{ level: 2, costKj: 60_000, homeHours: 0.5, materials: { silica: 2, fiber: 1.5 }, outputKj:
|
|
206
|
-
{ level: 3, costKj: 200_000, homeHours: 0.75, materials: { silica: 5, phycocyanin: 0.4 }, outputKj:
|
|
203
|
+
{ level: 1, costKj: 12_000, homeHours: 0.25, materials: { fiber: 0.5 }, outputKj: 200, summary: '手摇一次 200 kJ。' },
|
|
204
|
+
{ level: 2, costKj: 60_000, homeHours: 0.5, materials: { silica: 2, fiber: 1.5 }, outputKj: 350, summary: '手摇一次 350 kJ。' },
|
|
205
|
+
{ level: 3, costKj: 200_000, homeHours: 0.75, materials: { silica: 5, phycocyanin: 0.4 }, outputKj: 500, summary: '手摇一次 500 kJ。' },
|
|
207
206
|
];
|
|
208
207
|
|
|
209
208
|
export function sparkPlugLevel(level: number): SparkPlugLevelSpec | null {
|
package/src/webui/client.ts
CHANGED
|
@@ -71,6 +71,10 @@ interface Text {
|
|
|
71
71
|
floraBags: string;
|
|
72
72
|
floraPlant: string;
|
|
73
73
|
floraHarvest: string;
|
|
74
|
+
floraTransplant: string;
|
|
75
|
+
floraRemove: string;
|
|
76
|
+
floraInspect: string;
|
|
77
|
+
floraBreed: string;
|
|
74
78
|
floraClosed: string;
|
|
75
79
|
storeTitle: string;
|
|
76
80
|
storeRefresh: string;
|
|
@@ -90,6 +94,7 @@ interface Text {
|
|
|
90
94
|
veinsHere: string;
|
|
91
95
|
waitDawn: string;
|
|
92
96
|
waitDusk: string;
|
|
97
|
+
waitNoon: string;
|
|
93
98
|
waitRipe: string;
|
|
94
99
|
waitBuilt: string;
|
|
95
100
|
waitArrive: string;
|
|
@@ -233,7 +238,11 @@ const ZH: Text = {
|
|
|
233
238
|
floraBags: '种子袋',
|
|
234
239
|
floraPlant: '种下',
|
|
235
240
|
floraHarvest: '收成熟',
|
|
236
|
-
|
|
241
|
+
floraTransplant: '移栽',
|
|
242
|
+
floraRemove: '拔掉',
|
|
243
|
+
floraInspect: '详情',
|
|
244
|
+
floraBreed: '留种',
|
|
245
|
+
floraClosed: '商人不在',
|
|
237
246
|
storeTitle: '背包与仓库',
|
|
238
247
|
storeRefresh: '刷新',
|
|
239
248
|
storeDeposit: '存 10 kg',
|
|
@@ -252,6 +261,7 @@ const ZH: Text = {
|
|
|
252
261
|
veinsHere: '扫描矿脉',
|
|
253
262
|
waitDawn: '等到天亮',
|
|
254
263
|
waitDusk: '等到天黑',
|
|
264
|
+
waitNoon: '等到中午(商店开门)',
|
|
255
265
|
waitRipe: '等到作物熟',
|
|
256
266
|
waitBuilt: '等到完工',
|
|
257
267
|
waitArrive: '等到抵达',
|
|
@@ -395,7 +405,11 @@ const EN: Text = {
|
|
|
395
405
|
floraBags: 'Seed bags',
|
|
396
406
|
floraPlant: 'Sow',
|
|
397
407
|
floraHarvest: 'Harvest',
|
|
398
|
-
|
|
408
|
+
floraTransplant: 'Transplant',
|
|
409
|
+
floraRemove: 'Uproot',
|
|
410
|
+
floraInspect: 'Details',
|
|
411
|
+
floraBreed: 'Breed',
|
|
412
|
+
floraClosed: 'Merchant is away',
|
|
399
413
|
storeTitle: 'Backpack & stores',
|
|
400
414
|
storeRefresh: 'Refresh',
|
|
401
415
|
storeDeposit: 'Deposit 10 kg',
|
|
@@ -414,6 +428,7 @@ const EN: Text = {
|
|
|
414
428
|
veinsHere: 'Scan veins',
|
|
415
429
|
waitDawn: 'Wait for dawn',
|
|
416
430
|
waitDusk: 'Wait for dusk',
|
|
431
|
+
waitNoon: 'Wait for noon (shop opens)',
|
|
417
432
|
waitRipe: 'Wait for a crop',
|
|
418
433
|
waitBuilt: 'Wait for build',
|
|
419
434
|
waitArrive: 'Wait for arrival',
|
|
@@ -709,6 +724,7 @@ const panel: WebUiPanel = {
|
|
|
709
724
|
for (const [label, until] of [
|
|
710
725
|
[t.waitDawn, 'dawn'],
|
|
711
726
|
[t.waitDusk, 'dusk'],
|
|
727
|
+
[t.waitNoon, 'noon'],
|
|
712
728
|
[t.waitRipe, 'ripe'],
|
|
713
729
|
[t.waitBuilt, 'built'],
|
|
714
730
|
[t.waitArrive, 'arrive'],
|
|
@@ -774,6 +790,10 @@ const panel: WebUiPanel = {
|
|
|
774
790
|
floraBox.style.gap = '6px';
|
|
775
791
|
const floraLine = ctx.ui.h('div', 'muted');
|
|
776
792
|
floraLine.style.fontSize = '12px';
|
|
793
|
+
// 作物详情:`inspect` 只回文本,不替换整页状态(以前把它当面板状态收下,页面会退回创世前)。
|
|
794
|
+
const floraMsg = ctx.ui.h('pre', 'mono');
|
|
795
|
+
floraMsg.hidden = true;
|
|
796
|
+
floraMsg.style.whiteSpace = 'pre-wrap';
|
|
777
797
|
const floraSites = ctx.ui.h('div');
|
|
778
798
|
floraSites.style.display = 'grid';
|
|
779
799
|
floraSites.style.gap = '4px';
|
|
@@ -794,6 +814,7 @@ const panel: WebUiPanel = {
|
|
|
794
814
|
siteButton,
|
|
795
815
|
floraTrade,
|
|
796
816
|
floraSites,
|
|
817
|
+
floraMsg,
|
|
797
818
|
floraInv,
|
|
798
819
|
floraBags,
|
|
799
820
|
);
|
|
@@ -1183,7 +1204,7 @@ const panel: WebUiPanel = {
|
|
|
1183
1204
|
if (!flora) return;
|
|
1184
1205
|
floraLine.textContent =
|
|
1185
1206
|
`${flora.credits} 信用点(${flora.tier}) · ${Math.floor(flora.energyKj).toLocaleString('en-US')} kJ · ` +
|
|
1186
|
-
(flora.shopOpen ? t.floraShop : t.floraClosed);
|
|
1207
|
+
(flora.shopWindow || (flora.shopOpen ? t.floraShop : t.floraClosed));
|
|
1187
1208
|
floraSites.replaceChildren();
|
|
1188
1209
|
if (flora.sites.length === 0) {
|
|
1189
1210
|
floraSites.append(ctx.ui.h('div', 'muted', t.floraNone));
|
|
@@ -1221,6 +1242,40 @@ const panel: WebUiPanel = {
|
|
|
1221
1242
|
}
|
|
1222
1243
|
floraSites.append(row);
|
|
1223
1244
|
}
|
|
1245
|
+
// 2.0.6:每株都能挖回种子袋(基因不变,代价是不能再收)。
|
|
1246
|
+
for (const crop of flora.crops ?? []) {
|
|
1247
|
+
const row = ctx.ui.h('div');
|
|
1248
|
+
row.style.display = 'flex';
|
|
1249
|
+
row.style.gap = '8px';
|
|
1250
|
+
row.style.alignItems = 'center';
|
|
1251
|
+
row.append(
|
|
1252
|
+
ctx.ui.h('span', 'mono', `${crop.site} · ${crop.name} · ${Math.round(crop.progress * 100)}%${crop.ripe ? ' · 结实' : ''}${crop.dead ? ' · 枯死' : ''}`),
|
|
1253
|
+
);
|
|
1254
|
+
if (crop.dead) {
|
|
1255
|
+
row.append(
|
|
1256
|
+
ctx.ui.button(t.floraRemove, {
|
|
1257
|
+
size: 'sm',
|
|
1258
|
+
onClick: () => void floraDo('remove', [crop.id, crop.site]),
|
|
1259
|
+
}),
|
|
1260
|
+
);
|
|
1261
|
+
} else {
|
|
1262
|
+
row.append(
|
|
1263
|
+
ctx.ui.button(t.floraInspect, {
|
|
1264
|
+
size: 'sm',
|
|
1265
|
+
onClick: () => void inspectCrop(crop.id, crop.site),
|
|
1266
|
+
}),
|
|
1267
|
+
ctx.ui.button(t.floraBreed, {
|
|
1268
|
+
size: 'sm',
|
|
1269
|
+
onClick: () => void floraDo('breed', [crop.id, crop.site]),
|
|
1270
|
+
}),
|
|
1271
|
+
ctx.ui.button(t.floraTransplant, {
|
|
1272
|
+
size: 'sm',
|
|
1273
|
+
onClick: () => void floraDo('transplant', [crop.id, crop.site]),
|
|
1274
|
+
}),
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
floraSites.append(row);
|
|
1278
|
+
}
|
|
1224
1279
|
floraInv.replaceChildren();
|
|
1225
1280
|
floraInv.textContent = flora.inventory.length === 0
|
|
1226
1281
|
? `${t.floraInventory}:${t.floraEmpty}`
|
|
@@ -1311,9 +1366,30 @@ const panel: WebUiPanel = {
|
|
|
1311
1366
|
if (busy) return;
|
|
1312
1367
|
busy = true;
|
|
1313
1368
|
try {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1369
|
+
const result = await ctx.invoke<GenesisPanelState | { text: string }>(method, args);
|
|
1370
|
+
// 有些方法只回一段文字(比如详情)。只有真拿到面板状态才替换 —— 否则整页会退回创世前。
|
|
1371
|
+
if (result && typeof result === 'object' && 'locked' in result && 'power' in result) {
|
|
1372
|
+
state = result as GenesisPanelState;
|
|
1373
|
+
render();
|
|
1374
|
+
void ctx.refresh();
|
|
1375
|
+
} else if (result && typeof result === 'object' && 'text' in result) {
|
|
1376
|
+
floraMsg.hidden = false;
|
|
1377
|
+
floraMsg.textContent = String((result as { text: string }).text);
|
|
1378
|
+
}
|
|
1379
|
+
} catch (error) {
|
|
1380
|
+
fail(error);
|
|
1381
|
+
} finally {
|
|
1382
|
+
busy = false;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
async function inspectCrop(id: string, site: string): Promise<void> {
|
|
1387
|
+
if (busy) return;
|
|
1388
|
+
busy = true;
|
|
1389
|
+
try {
|
|
1390
|
+
const result = await ctx.invoke<{ text: string }>('inspect', [id, site]);
|
|
1391
|
+
floraMsg.hidden = false;
|
|
1392
|
+
floraMsg.textContent = result.text;
|
|
1317
1393
|
} catch (error) {
|
|
1318
1394
|
fail(error);
|
|
1319
1395
|
} finally {
|