cortico-world-genesis 2.2.7 → 2.6.0

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/src/world.ts CHANGED
@@ -12,6 +12,23 @@ import {
12
12
  bodyProbeId,
13
13
  bodyKeyOf,
14
14
  burnBiomass,
15
+ STAFF_PER_HOUSING,
16
+ startWonder,
17
+ WONDER_SPECS,
18
+ buyCharter,
19
+ setSpeed,
20
+ minutesPerHomeHour,
21
+ interiorComfortable,
22
+ structureInteriorC,
23
+ LODGE_COMFORT_C,
24
+ STAFF_COMFORT_C,
25
+ realMsPerHomeHour,
26
+ DEFAULT_SPEED,
27
+ dailyShopSpecies,
28
+ MAX_SPEED,
29
+ MIN_SPEED,
30
+ CHARTER_TECH_KJ,
31
+ CHARTER_TOURISM_CREDITS,
15
32
  buySeeds,
16
33
  deployCounter,
17
34
  deployMonitor,
@@ -78,6 +95,10 @@ import {
78
95
  WAIT_MAX_HOME_HOURS,
79
96
  buyCylinders,
80
97
  buyChart,
98
+ CHART_PRICE_CREDITS,
99
+ ENERGY_BLOCK_CREDITS,
100
+ ENERGY_BLOCK_KJ,
101
+ TUNGSTEN_PRICE_CREDITS,
81
102
  currentOrders,
82
103
  deliverOrder,
83
104
  habitatStatus,
@@ -125,14 +146,14 @@ import { sparkPlugOutputKj } from './trade.ts';
125
146
  import { orderText } from './orders.ts';
126
147
  import { CHAPTER_TITLES, protocolStatus, protocolText } from './protocol.ts';
127
148
  import { NUTRIENT_NEEDS, SPECIES, SPECIES_IDS, RESOURCE_LABELS, bagWeightKg, speciesTempLabel, type SpeciesId } from './flora.ts';
128
- import { RESIDENTS_PER_LABOR } from './life.ts';
149
+ import { CYLINDER_COST_CREDITS, RESIDENTS_PER_LABOR } from './life.ts';
129
150
  import { climateAt, siteKeyOf, type Site } from './site.ts';
130
- import { BUY_GOODS, SELL_GOODS, creditTier, dayIndexOf, sellPriceTable, shopOpen, shopWindowText, telescopeWindow } from './trade.ts';
151
+ import { BUY_GOODS, PREMIUM_SEED_PRICE_CREDITS, SELL_GOODS, buyDailyLimitFor, creditTier, dayIndexOf, fertilizerPriceKj, randomSeedPriceKj, sellPriceTable, shopOpen, shopWindowText, telescopeWindow } from './trade.ts';
131
152
  import { BUILD_SPECS, applyFertilizer, buyFertilizer, useCanned } from './game.ts';
132
153
  import { GENERATOR_COOLDOWN_MS } from './power.ts';
133
154
  import { GameStore } from './game-store.ts';
134
155
  import { GENESIS_DEFAULTS, GENESIS_LIMITS, validateSpec, type GenesisSpec, type StarSystem, type TerrestrialSurface } from './model.ts';
135
- import type { GenesisBody, GenesisDraft, GenesisPanelProtocol, GenesisPanelState, GenesisPlanetRow, GenesisProtocolPanel, GenesisSurfaceMap } from './panel-types.ts';
156
+ import type { GenesisBody, GenesisDraft, GenesisPanelProtocol, GenesisPanelState, GenesisPlanetRow, GenesisProtocolPanel, GenesisShopOrder, GenesisShopPanel, GenesisShopRow, GenesisSurfaceMap } from './panel-types.ts';
136
157
  import { GenesisStore } from './store.ts';
137
158
  import { stargazeText } from './stargaze.ts';
138
159
  import { createSystem, deriveGenesisShape, describeGenesisMenu, GENESIS_SHAPE } from './system.ts';
@@ -141,6 +162,7 @@ import { planetVisibility, terrainPatch, terrainPatchText, type TerrainBody } fr
141
162
  import { targetBiomeFor, terraCellsFor, type TerraMap } from './terra.ts';
142
163
  import { guideText, guideTopics } from './guide.ts';
143
164
  import { infoText } from './info.ts';
165
+ import { toolsSearch } from './tools-doc.ts';
144
166
  import { ProfileStore, consumeRecreate, exportProfile, recreateBlockers } from './profile.ts';
145
167
  import { applyAlgae, breedAt, greenhouseClimate, PLANTER_CLIMATE, PLANTER_SUBSTRATE, PUMP_MAX_WETNESS } from './game.ts';
146
168
  import { inspectPlantText } from './inspect.ts';
@@ -308,7 +330,7 @@ const BUY_PARAMETERS = {
308
330
  type: 'object',
309
331
  additionalProperties: false,
310
332
  properties: {
311
- kind: { type: 'string', enum: ['random', 'premium', 'giant_plant', 'cylinder', 'energy', 'tungsten', 'chart', 'fertilizer'], description: 'fertilizer = 复合肥(按公斤,花 kJ,每买一公斤下一公斤更贵,一天 30 kg);random = 随机基因种子(花 kJ);premium = 高级种子(花信用点);giant_plant = 大型植物(还没开通);cylinder = 高强度钢瓶(花信用点,多买有折扣);energy = 能量块(5,000 kJ,120 信用点,直接进电池不损耗);tungsten = 钨 1 份(700 信用点);chart = 星图(300 信用点,每天一张):画一颗你还没见过的天体,拿到就不用等观星窗口。' },
333
+ kind: { type: 'string', enum: ['random', 'premium', 'giant_plant', 'broadcast_tourism', 'broadcast_tech', 'cylinder', 'energy', 'tungsten', 'chart', 'fertilizer'], description: 'fertilizer = 复合肥(按公斤,花 kJ,每买一公斤下一公斤更贵,一天 30 kg);random = 随机基因种子(花 kJ);premium = 高级种子(花信用点);giant_plant = 大型植物(还没开通);cylinder = 高强度钢瓶(花信用点,多买有折扣);energy = 能量块(5,000 kJ,120 信用点,直接进电池不损耗);tungsten = 钨 1 份(700 信用点);chart = 星图(300 信用点,每天一张):画一颗你还没见过的天体,拿到就不用等观星窗口。' },
312
334
  species: { type: 'string', enum: [...SPECIES_IDS], description: '要买哪种种子(kind=random/premium 时用)。' },
313
335
  count: { type: 'number', minimum: 1, maximum: 100, description: 'kind=cylinder 时买几个。' },
314
336
  kg: { type: 'number', minimum: 0.5, maximum: 30, description: 'kind=fertilizer 时买多少公斤(默认 5)。' },
@@ -391,6 +413,15 @@ const REMOVE_PARAMETERS = {
391
413
  required: ['plant'],
392
414
  } as const;
393
415
 
416
+ const TOOLS_PARAMETERS = {
417
+ type: 'object',
418
+ additionalProperties: false,
419
+ properties: {
420
+ query: { type: 'string', description: '可选:工具名、中文名或关键词(比如「种地」「机械臂」「wait」)。不传给整张表。' },
421
+ },
422
+ required: [],
423
+ } as const;
424
+
394
425
  const BUILD_PARAMETERS = {
395
426
  type: 'object',
396
427
  additionalProperties: false,
@@ -920,6 +951,42 @@ export const GENESIS_TOOL_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
920
951
  tags: ['write'],
921
952
  parameters: REMOVE_PARAMETERS,
922
953
  },
954
+ {
955
+ name: 'genesis_speed',
956
+ description:
957
+ '调时间倍速(1–200 倍):不影响历法与产量,只影响「现实时间过去多久算一个母星时」。调高后,等待、施工、旅行、作物生长在现实时间里都会变快。',
958
+ parameters: {
959
+ type: 'object',
960
+ additionalProperties: false,
961
+ properties: {
962
+ speed: { type: 'integer', minimum: 1, maximum: 200, description: '目标倍速,1–200。' },
963
+ },
964
+ required: ['speed'],
965
+ },
966
+ tags: ['read'],
967
+ },
968
+ {
969
+ name: 'genesis_wonder',
970
+ description: '开一座奇观(一次只能建一座,建完才能开下一座;奇观线独立于普通施工)。id:sky_ring 天穹环 / under_ice_eye 冰下之眼(旅游),silicon_valley 硅谷 / orbital_mirror 轨道镜阵(技术)。',
971
+ parameters: {
972
+ type: 'object',
973
+ additionalProperties: false,
974
+ properties: {
975
+ id: { type: 'string', enum: ['sky_ring', 'under_ice_eye', 'silicon_valley', 'orbital_mirror', 's2_engine'], description: '奇观 id。' },
976
+ },
977
+ required: ['id'],
978
+ },
979
+ tags: ['write'],
980
+ },
981
+ {
982
+ name: 'genesis_tools',
983
+ description:
984
+ '工具总表:全部 40 个工具各一行——做什么、关键参数、一句提醒。' +
985
+ '不带 query 给整张表;带 query 就只挑和它有关的几行(工具名、中文名、关键词都行)。' +
986
+ '忘了哪个工具叫什么、参数怎么填的时候查它。',
987
+ tags: ['read'],
988
+ parameters: TOOLS_PARAMETERS,
989
+ },
923
990
  ];
924
991
 
925
992
  export interface GenesisWorldOptions {
@@ -930,6 +997,11 @@ export interface GenesisWorldOptions {
930
997
  now?: () => number;
931
998
  }
932
999
 
1000
+ /** 1 倍速下「一个母星时 = 多少现实分钟」,滑杆拖动时用它换算。 */
1001
+ function msPerPlanetHourBase(game: GameState): number {
1002
+ return game.msPerPlanetHour / 60_000;
1003
+ }
1004
+
933
1005
  export class GenesisWorld implements World {
934
1006
  readonly id = 'genesis';
935
1007
 
@@ -1015,11 +1087,14 @@ export class GenesisWorld implements World {
1015
1087
  this.dutyTool(),
1016
1088
  this.resetTool(),
1017
1089
  this.infoTool(),
1090
+ this.wonderTool(),
1091
+ this.speedTool(),
1018
1092
  this.transplantTool(),
1019
1093
  this.removeTool(),
1020
1094
  this.breedTool(),
1021
1095
  this.algaeTool(),
1022
1096
  this.inspectTool(),
1097
+ this.toolsTool(),
1023
1098
  ];
1024
1099
  }
1025
1100
 
@@ -1109,7 +1184,7 @@ export class GenesisWorld implements World {
1109
1184
  id: 'system',
1110
1185
  title: '这一颗星球',
1111
1186
  description: '开局在这里创世:种子、恒星质量、行星数、卫星上限,还有恒星与母星的名字。写进存档后锁定,删档才能重选。',
1112
- getMethods: ['state', 'create', 'reset', 'map', 'press', 'monitor', 'sell', 'site', 'plant', 'harvest', 'transplant', 'remove', 'breed', 'algae', 'inspect', 'burn', 'build', 'install', 'store', 'storeDo', 'look', 'veins', 'survey', 'wait', 'order', 'cylinder', 'chart', 'fertilizer', 'fertilize', 'mutate', 'wake', 'preview'],
1187
+ getMethods: ['state', 'create', 'reset', 'map', 'press', 'monitor', 'site', 'plant', 'harvest', 'transplant', 'remove', 'breed', 'algae', 'inspect', 'burn', 'build', 'install', 'store', 'storeDo', 'look', 'veins', 'survey', 'wait', 'fertilize', 'mutate', 'wake', 'preview', 'speed'],
1113
1188
  },
1114
1189
  {
1115
1190
  id: 'upgrade',
@@ -1123,11 +1198,17 @@ export class GenesisWorld implements World {
1123
1198
  description: '叫醒船上的人要做的事,分三章:活下来、住得下、叫醒他们。全部完成之后,这里的按钮就能把休眠舱打开。',
1124
1199
  getMethods: ['state', 'wake'],
1125
1200
  },
1201
+ {
1202
+ id: 'shop',
1203
+ title: '商店',
1204
+ description: '买卖都在这儿:卖货、买种子/钢瓶/星图/钨/能量块/复合肥、交基因订单。商人只在营业时间来,关张时按钮是灰的。',
1205
+ getMethods: ['state', 'buy', 'sell', 'order'],
1206
+ },
1126
1207
  {
1127
1208
  id: 'guide',
1128
1209
  title: '手册',
1129
1210
  description: '和 genesis_guide 同一份教程,翻着看比叫模型念一遍省事。正文在 src/guide/*.md,改文案不用碰代码。',
1130
- getMethods: ['topics', 'read', 'search'],
1211
+ getMethods: ['topics', 'read', 'search', 'tools'],
1131
1212
  },
1132
1213
  ],
1133
1214
  invoke: async (panel, method, args) => this.invoke(panel, method, args),
@@ -1304,6 +1385,12 @@ export class GenesisWorld implements World {
1304
1385
  throw new Error(`「协议」面板没有方法:${method}`);
1305
1386
  }
1306
1387
  }
1388
+ if (panel === 'shop') {
1389
+ return this.shopAction(method, args);
1390
+ }
1391
+ if (method === 'speed') {
1392
+ return this.speedFromPanel(args[0]);
1393
+ }
1307
1394
  if (panel === 'guide') {
1308
1395
  switch (method) {
1309
1396
  case 'topics':
@@ -1318,6 +1405,10 @@ export class GenesisWorld implements World {
1318
1405
  const query = typeof args[0] === 'string' ? args[0] : '';
1319
1406
  return { text: infoText(query) };
1320
1407
  }
1408
+ case 'tools': {
1409
+ const query = typeof args[0] === 'string' && args[0].trim() !== '' ? args[0].trim() : undefined;
1410
+ return { text: toolsSearch(query) };
1411
+ }
1321
1412
  default:
1322
1413
  throw new Error(`「手册」面板没有方法:${method}`);
1323
1414
  }
@@ -1479,6 +1570,190 @@ export class GenesisWorld implements World {
1479
1570
  return { text: waited.reason, state: await this.panelState() };
1480
1571
  }
1481
1572
 
1573
+
1574
+ /** 「商店」页签:开没开张、货架、收购价、订单。 */
1575
+ private shopPayload(): GenesisShopPanel {
1576
+ const game = this.game!;
1577
+ const level = game.upgrades.telescope;
1578
+ const now = this.now();
1579
+ const hours = nowPlanetHours(game, now);
1580
+ const open = shopOpen(hours, level);
1581
+ const day = dayIndexOf(hours);
1582
+ const soldToday = (id: string): number => (game.daily.day === day ? (game.daily.sold['sell:' + id] ?? 0) : 0);
1583
+ const boughtToday = (key: string): number => (game.daily.day === day ? (game.daily.bought[key] ?? 0) : 0);
1584
+ const heldOf = (id: string): number => {
1585
+ let sum = game.inventory[id] ?? 0;
1586
+ for (const store of Object.values(game.siteStores)) sum += store[id] ?? 0;
1587
+ for (const container of Object.values(game.stores)) sum += container[id] ?? 0;
1588
+ return round3(sum);
1589
+ };
1590
+ const sellables: GenesisShopRow[] = sellPriceTable(day, level).map((row) => {
1591
+ const left = Number.isFinite(row.limit) ? Math.max(0, Math.floor(row.limit - soldToday(row.id))) : Number.POSITIVE_INFINITY;
1592
+ return {
1593
+ id: row.id,
1594
+ name: row.name,
1595
+ priceLabel: row.price.toLocaleString('en-US') + ' 信用点/' + row.unit,
1596
+ limitLabel: Number.isFinite(left) ? '今天还能卖 ' + left + ' ' + row.unit : '不限量',
1597
+ held: heldOf(row.id),
1598
+ };
1599
+ });
1600
+ const premium = BUY_GOODS.find((good) => good.id === 'premium_seed')!;
1601
+ const premiumLeft = Math.max(0, buyDailyLimitFor(premium, level) - boughtToday('buy:premium_seed'));
1602
+ const buyables: GenesisShopRow[] = [
1603
+ {
1604
+ id: 'random_seed',
1605
+ name: '随机基因种子(5 粒)· 今日货:' + SPECIES[dailyShopSpecies(game, this.now())].name,
1606
+ priceLabel: randomSeedPriceKj(game.seedsPurchased).toLocaleString('en-US') + ' kJ',
1607
+ limitLabel: '不限量',
1608
+ species: dailyShopSpecies(game, this.now()),
1609
+ note: '每买一袋,下一袋贵 200 kJ。今天的货明天会换。',
1610
+ },
1611
+ {
1612
+ id: 'premium_seed',
1613
+ name: '高级种子(耐寒·高产,5 粒)· 今日货:' + SPECIES[dailyShopSpecies(game, this.now())].name,
1614
+ species: dailyShopSpecies(game, this.now()),
1615
+ priceLabel: PREMIUM_SEED_PRICE_CREDITS.toLocaleString('en-US') + ' 信用点',
1616
+ limitLabel: '今天还能买 ' + premiumLeft + ' 袋',
1617
+ note: '要余额 500 信用点。',
1618
+ },
1619
+ {
1620
+ id: 'fertilizer',
1621
+ name: '复合肥(按公斤)',
1622
+ priceLabel: fertilizerPriceKj(game.fertilizerBought ?? 0).toLocaleString('en-US') + ' kJ/kg',
1623
+ limitLabel: '今天还能买 ' + Math.max(0, 30 - boughtToday('buy:fertilizer')) + ' kg',
1624
+ note: '每买一公斤,下一公斤贵 250 kJ。',
1625
+ },
1626
+ {
1627
+ id: 'broadcast_tourism',
1628
+ name: '星际广播 · 旅游星系',
1629
+ priceLabel: CHARTER_TOURISM_CREDITS.toLocaleString('en-US') + ' 信用点',
1630
+ limitLabel: game.charter ? (game.charter === 'tourism' ? '已选择旅游星系' : '已售罄(选了技术星系)') : '一局只能买一张',
1631
+ note: '买了才能造观光塔台与访客驿站;技术星系的广播会永久锁死。',
1632
+ },
1633
+ {
1634
+ id: 'broadcast_tech',
1635
+ name: '星际广播 · 技术星系',
1636
+ priceLabel: CHARTER_TECH_KJ.toLocaleString('en-US') + ' kJ',
1637
+ limitLabel: game.charter ? (game.charter === 'tech' ? '已选择技术星系' : '已售罄(选了旅游星系)') : '一局只能买一张',
1638
+ note: '买了才能造招募站、员工公寓与晶圆厂;旅游星系的广播会永久锁死。',
1639
+ },
1640
+ {
1641
+ id: 'cylinder',
1642
+ name: '高强度钢瓶',
1643
+ priceLabel: CYLINDER_COST_CREDITS.toLocaleString('en-US') + ' 信用点/个',
1644
+ limitLabel: '不限量',
1645
+ note: '装液氨、氧气用;用完返九成。',
1646
+ },
1647
+ {
1648
+ id: 'chart',
1649
+ name: '星图(一颗天体)',
1650
+ priceLabel: CHART_PRICE_CREDITS.toLocaleString('en-US') + ' 信用点',
1651
+ limitLabel: '今天还能买 ' + Math.max(0, 1 - boughtToday('buy:chart')) + ' 张',
1652
+ note: '拿到就不用等观星窗口。',
1653
+ },
1654
+ {
1655
+ id: 'tungsten',
1656
+ name: '钨(1 份 = 1 kg)',
1657
+ priceLabel: TUNGSTEN_PRICE_CREDITS.toLocaleString('en-US') + ' 信用点/份',
1658
+ limitLabel: '不限量',
1659
+ },
1660
+ {
1661
+ id: 'energy',
1662
+ name: '能量块(' + ENERGY_BLOCK_KJ.toLocaleString('en-US') + ' kJ)',
1663
+ priceLabel: ENERGY_BLOCK_CREDITS.toLocaleString('en-US') + ' 信用点',
1664
+ limitLabel: '不限量',
1665
+ },
1666
+ ];
1667
+ const orders: GenesisShopOrder[] = currentOrders(game, now).map((order) => ({
1668
+ id: order.id,
1669
+ label: orderText(order, SPECIES[order.species].name),
1670
+ note: '交货用「交货」按钮。',
1671
+ }));
1672
+ return {
1673
+ open,
1674
+ window: shopWindowText(hours, level),
1675
+ nextOpenHours: open ? 0 : Math.round(((12 - hours + 24) % 24) * 10) / 10,
1676
+ level,
1677
+ credits: game.credits,
1678
+ energyKj: game.energyKj,
1679
+ tungsten: game.tungsten,
1680
+ buyables,
1681
+ sellables,
1682
+ orders,
1683
+ closedNote: open ? undefined : '商人不在:按钮先灰着,等开张了再点。',
1684
+ };
1685
+ }
1686
+
1687
+ /** 「商店」页签的方法:state / buy / sell / order。 */
1688
+ private async shopAction(method: string, args: unknown[]): Promise<unknown> {
1689
+ await this.sync();
1690
+ if (!this.game) throw new Error('还没有创世。');
1691
+ if (method === 'state') return this.shopPayload();
1692
+ const input = (args[0] ?? {}) as Record<string, unknown>;
1693
+ const now = this.now();
1694
+ if (method === 'order') {
1695
+ const delivered = deliverOrder(this.game, String(input.id ?? ''), now);
1696
+ this.game = delivered.state;
1697
+ await this.saveGame();
1698
+ return { text: delivered.text, state: this.shopPayload() };
1699
+ }
1700
+ if (method === 'sell') {
1701
+ const sold = sellToMerchant(this.game, String(input.id ?? '') as never, Number(input.amount ?? 1), now);
1702
+ this.game = sold.state;
1703
+ await this.saveGame();
1704
+ return { text: sold.text, state: this.shopPayload() };
1705
+ }
1706
+ if (method === 'buy') {
1707
+ const kind = String(input.kind ?? '');
1708
+ if (kind === 'random_seed' || kind === 'premium_seed') {
1709
+ const species = String(
1710
+ input.species ?? dailyShopSpecies(this.game!, now),
1711
+ ) as SpeciesId;
1712
+ if (!SPECIES[species]) throw new Error('没有这种植物:' + species + '。');
1713
+ const bought = buySeeds(this.game, kind === 'random_seed' ? 'random' : 'premium', species, now);
1714
+ this.game = bought.state;
1715
+ await this.saveGame();
1716
+ return { text: bought.text, state: this.shopPayload() };
1717
+ }
1718
+ if (kind === 'fertilizer') {
1719
+ const kg = typeof input.kg === 'number' && input.kg > 0 ? input.kg : 5;
1720
+ const bought = buyFertilizer(this.game, kg, now);
1721
+ this.game = bought.state;
1722
+ await this.saveGame();
1723
+ return { text: bought.text, state: this.shopPayload() };
1724
+ }
1725
+ if (kind === 'cylinder') {
1726
+ const count = Math.max(1, Math.floor(Number(input.count ?? 1)));
1727
+ const bought = buyCylinders(this.game, count, now);
1728
+ this.game = bought.state;
1729
+ await this.saveGame();
1730
+ return { text: bought.text, state: this.shopPayload() };
1731
+ }
1732
+ if (kind === 'chart') {
1733
+ const system = await this.readSystem();
1734
+ if (!system) throw new Error('还没有创世。');
1735
+ const bought = buyChart(system, this.game, now);
1736
+ this.game = bought.state;
1737
+ await this.saveGame();
1738
+ return { text: bought.text, state: this.shopPayload() };
1739
+ }
1740
+ if (kind === 'broadcast_tourism' || kind === 'broadcast_tech') {
1741
+ const bought = buyCharter(this.game, kind === 'broadcast_tourism' ? 'tourism' : 'tech', now);
1742
+ this.game = bought.state;
1743
+ await this.saveGame();
1744
+ return { text: bought.text, state: this.shopPayload() };
1745
+ }
1746
+ if (kind === 'tungsten' || kind === 'energy') {
1747
+ const bought = buyMerchandise(this.game, kind, now);
1748
+ this.game = bought.state;
1749
+ await this.saveGame();
1750
+ return { text: bought.text, state: this.shopPayload() };
1751
+ }
1752
+ throw new Error('商店里没有这种东西:' + (kind || '(空)') + '。');
1753
+ }
1754
+ throw new Error('「商店」面板没有方法:' + method);
1755
+ }
1756
+
1482
1757
  /** 面板「交货」:把一张订单交掉,然后刷新面板。 */
1483
1758
  private async orderFromPanel(input: unknown): Promise<{ text: string; state: GenesisPanelState }> {
1484
1759
  await this.sync();
@@ -1884,6 +2159,28 @@ export class GenesisWorld implements World {
1884
2159
  energyKj: game.energyKj,
1885
2160
  tungsten: game.tungsten,
1886
2161
  ship: shipSupplyStatus(game),
2162
+ charter: {
2163
+ charter: game.charter ?? null,
2164
+ reputation: round1(game.reputation ?? 0),
2165
+ compute: round1(game.compute ?? 0),
2166
+ staff: game.staff ?? 0,
2167
+ staffCap: staffCapOf(game),
2168
+ visitors: game.visitorsYesterday ?? 0,
2169
+ speed: game.speed ?? DEFAULT_SPEED,
2170
+ baseMinutesPerHomeHour: msPerPlanetHourBase(game),
2171
+ minutesPerHomeHour: minutesPerHomeHour(game),
2172
+ lodgeBeds: this.lodgeBedsNow(game),
2173
+ housingBeds: this.housingBedsNow(game),
2174
+ tempBlocked: this.tempBlockedNow(game),
2175
+ docks: game.structures.filter((s) => s.kind === 'tourism_dock').length,
2176
+ lodges: game.structures.filter((s) => s.kind === 'visitor_lodge').length,
2177
+ offices: game.structures.filter((s) => s.kind === 'recruit_office').length,
2178
+ fabs: game.structures.filter((s) => s.kind === 'fab').length,
2179
+ wonder: game.wonder
2180
+ ? { id: game.wonder.id, label: WONDER_SPECS[game.wonder.id as keyof typeof WONDER_SPECS]?.label ?? game.wonder.id, progress: Math.round(game.wonder.progress * 100) }
2181
+ : null,
2182
+ wonders: game.wonders ?? [],
2183
+ },
1887
2184
  grid: this.gridPanel(game),
1888
2185
  sails: game.sails.length,
1889
2186
  generatorKj: sparkPlugOutputKj(game.upgrades.sparkPlug),
@@ -2758,7 +3055,7 @@ export class GenesisWorld implements World {
2758
3055
  || id === 'kiln' || id === 'purifier' || id === 'sealer' || id === 'atmo_extractor'
2759
3056
  || id === 'habitat' || id === 'mutation_room' || id === 'cold_store' || id === 'inert_room'
2760
3057
  || id === 'miner' || id === 'rectifier' || id === 'terminal' || id === 'storage_terminal' || id === 'arm'
2761
- || id === 'planter' || id === 'duty' || id === 'carrier' || id === 'wind' || id === 'fire' || id === 'converter') {
3058
+ || id === 'planter' || id === 'duty' || id === 'carrier' || id === 'wind' || id === 'fire' || id === 'converter' || id === 'tour_line' || id === 'souvenir' || id === 'compute_array' || id === 'heavy_water' || id === 'enrichment') {
2762
3059
  const rawSite = typeof args.site === 'string' ? args.site.trim() : '';
2763
3060
  const siteKey = rawSite.startsWith('carrier:')
2764
3061
  ? rawSite
@@ -3045,6 +3342,16 @@ export class GenesisWorld implements World {
3045
3342
  return { text: error instanceof Error ? error.message : String(error), failed: true };
3046
3343
  }
3047
3344
  }
3345
+ if (kind === 'broadcast_tourism' || kind === 'broadcast_tech') {
3346
+ try {
3347
+ const bought = buyCharter(game, kind === 'broadcast_tourism' ? 'tourism' : 'tech', this.now());
3348
+ this.game = bought.state;
3349
+ await this.saveGame();
3350
+ return bought.text;
3351
+ } catch (error) {
3352
+ return { text: error instanceof Error ? error.message : String(error), failed: true };
3353
+ }
3354
+ }
3048
3355
  if (kind === 'chart') {
3049
3356
  try {
3050
3357
  const bought = buyChart(system, game, this.now());
@@ -3066,7 +3373,7 @@ export class GenesisWorld implements World {
3066
3373
  }
3067
3374
  }
3068
3375
  if (kind !== 'random' && kind !== 'premium') {
3069
- return { text: 'kind 只能是 random、premium、cylinder、energy、tungsten、chart 或 giant_plant。', failed: true };
3376
+ return { text: 'kind 只能是 random、premium、cylinder、energy、tungsten、chart、giant_plant、broadcast_tourism 或 broadcast_tech。', failed: true };
3070
3377
  }
3071
3378
  const species = String(args.species ?? 'grass') as SpeciesId;
3072
3379
  if (!SPECIES[species]) return { text: `没有这种植物:${species}`, failed: true };
@@ -3979,6 +4286,90 @@ export class GenesisWorld implements World {
3979
4286
  };
3980
4287
  }
3981
4288
 
4289
+ private speedTool(): ToolDef {
4290
+ return {
4291
+ ...GENESIS_TOOL_DECLS[40]!,
4292
+ handler: async (args: Record<string, unknown>): Promise<{ text: string }> => {
4293
+ await this.sync();
4294
+ if (!this.game) return { text: '还没有创世:先 genesis_create。' };
4295
+ this.game = setSpeed(this.game, Number(args.speed ?? 1), this.now());
4296
+ await this.saveGame();
4297
+ return {
4298
+ text:
4299
+ '时间倍速调到了 ' +
4300
+ (this.game.speed ?? DEFAULT_SPEED) +
4301
+ ' 倍(' +
4302
+ MIN_SPEED +
4303
+ '–' +
4304
+ MAX_SPEED +
4305
+ ')。现在一个母星时只花 ' +
4306
+ minutesPerHomeHour(this.game).toFixed(2) +
4307
+ ' 分钟现实时间。',
4308
+ };
4309
+ },
4310
+ };
4311
+ }
4312
+
4313
+ /** 只算「住得下」的访客床位:太热、太冷或没通电的驿站不算。 */
4314
+ private lodgeBedsNow(game: GameState): number {
4315
+ if (!this.system) return game.structures.filter((s) => s.kind === 'visitor_lodge').length * 30;
4316
+ return (
4317
+ game.structures.filter(
4318
+ (s) => s.kind === 'visitor_lodge' && structurePowered(game, s) && interiorComfortable(structureInteriorC(this.system!, game, s, this.now()), LODGE_COMFORT_C),
4319
+ ).length * 30
4320
+ );
4321
+ }
4322
+
4323
+ /** 只算「住得下」的员工床位。 */
4324
+ private housingBedsNow(game: GameState): number {
4325
+ if (!this.system) return game.structures.filter((s) => s.kind === 'staff_housing').length * RESIDENTS_PER_LABOR * 4;
4326
+ return (
4327
+ game.structures.filter(
4328
+ (s) => s.kind === 'staff_housing' && structurePowered(game, s) && interiorComfortable(structureInteriorC(this.system!, game, s, this.now()), STAFF_COMFORT_C),
4329
+ ).length * 20
4330
+ );
4331
+ }
4332
+
4333
+ /** 因为太热/太冷而白建的住所,直接说给玩家听。 */
4334
+ private tempBlockedNow(game: GameState): string[] {
4335
+ if (!this.system) return [];
4336
+ const out: string[] = [];
4337
+ for (const s of game.structures) {
4338
+ if (s.kind !== 'visitor_lodge' && s.kind !== 'staff_housing') continue;
4339
+ const inside = structureInteriorC(this.system, game, s, this.now());
4340
+ const range = s.kind === 'visitor_lodge' ? LODGE_COMFORT_C : STAFF_COMFORT_C;
4341
+ if (interiorComfortable(inside, range)) continue;
4342
+ const label = s.kind === 'visitor_lodge' ? '访客驿站' : '员工公寓';
4343
+ out.push(label + '(室内 ' + inside + '℃)');
4344
+ }
4345
+ return out;
4346
+ }
4347
+ private async speedFromPanel(raw: unknown): Promise<{ text: string; state: unknown }> {
4348
+ await this.sync();
4349
+ if (!this.game) throw new Error('还没有创世。');
4350
+ this.game = setSpeed(this.game, Number(raw ?? 1), this.now());
4351
+ await this.saveGame();
4352
+ return { text: '时间倍速:' + (this.game.speed ?? DEFAULT_SPEED) + ' 倍。', state: await this.panelState() };
4353
+ }
4354
+
4355
+ private wonderTool(): ToolDef {
4356
+ return {
4357
+ ...GENESIS_TOOL_DECLS[41]!,
4358
+ handler: async (args: Record<string, unknown>): Promise<{ text: string; failed?: true }> => {
4359
+ await this.sync();
4360
+ if (!this.game) return { text: '还没有创世:先 genesis_create。' };
4361
+ try {
4362
+ const started = startWonder(this.game, String(args.id ?? ''), this.now());
4363
+ this.game = started.state;
4364
+ await this.saveGame();
4365
+ return { text: started.text };
4366
+ } catch (error) {
4367
+ return { text: error instanceof Error ? error.message : String(error), failed: true };
4368
+ }
4369
+ },
4370
+ };
4371
+ }
4372
+
3982
4373
  private infoTool(): ToolDef {
3983
4374
  return {
3984
4375
  ...GENESIS_TOOL_DECLS[34]!,
@@ -3993,6 +4384,20 @@ export class GenesisWorld implements World {
3993
4384
  };
3994
4385
  }
3995
4386
 
4387
+ private toolsTool(): ToolDef {
4388
+ return {
4389
+ ...GENESIS_TOOL_DECLS[42]!,
4390
+ handler: async (args) => {
4391
+ const query = typeof args.query === 'string' && args.query.trim() !== '' ? args.query.trim() : undefined;
4392
+ try {
4393
+ return toolsSearch(query);
4394
+ } catch (error) {
4395
+ return { text: errorText(error), failed: true };
4396
+ }
4397
+ },
4398
+ };
4399
+ }
4400
+
3996
4401
  private transplantTool(): ToolDef {
3997
4402
  return this.uprootTool('transplant', 35);
3998
4403
  }
@@ -4248,6 +4653,15 @@ export class GenesisWorld implements World {
4248
4653
  const STAR_NAMES = ['启明', '长庚', '天狼', '织女', '南门', '毕宿', '参宿', '心宿', '镇星', '岁星'];
4249
4654
  const HOME_NAMES = ['栖原', '临渊', '望舒', '沧鸣', '岩湾', '新野', '白岸', '孤屿', '沉岛', '霜原'];
4250
4655
 
4656
+ function round1(value: number): number {
4657
+ return Math.round(value * 10) / 10;
4658
+ }
4659
+
4660
+ function staffCapOf(game: GameState): number {
4661
+ const housing = game.structures.filter((s) => s.kind === 'staff_housing').length;
4662
+ return housing * STAFF_PER_HOUSING;
4663
+ }
4664
+
4251
4665
  function autoNames(seed: GenesisSpec['seed'], runs: number): { starName: string; homeName: string } {
4252
4666
  const key = typeof seed === 'number' ? `n:${seed}` : `s:${seed}`;
4253
4667
  const star = STAR_NAMES[hashSeed(`star:${key}`) % STAR_NAMES.length]!;