cortico-world-genesis 2.2.5 → 2.2.6

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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.2.6
2
+
3
+ - 修:四个工具声明下标错位一位——`genesis_inspect` 实际带着 `genesis_remove` 的参数表、`genesis_remove` 带着 `genesis_breed` 的、`genesis_breed` 带着 `genesis_algae` 的,互相串了。表现是 inspect 总说「要指定哪一株」、remove 反而打出详情卡、拔枯株永远拔不掉。现在 breed=36 / algae=37 / inspect=38 / remove=39。
4
+ - 修:拔除阈值把 0–100 的健康值当成 0–1 用(`REMOVE_MIN_HEALTH = 0.2`)——现在是 20,健康低于 20% 或已枯萎都能拔;错误提示里的健康值也不再乘一百(`100.0%` 而不是 `10000%`)。
5
+ - 修:补种的株号改用「这个站点出现过的最大序号 + 1」——以前用「当前株数 + 1」,拔过几株就会和旧株撞号(`#10` 撞 `#10`)。人手自动补种也走同一套编号。
6
+
1
7
  ## 2.2.5
2
8
 
3
9
  - 改:缺肥不再算「应激」——养分不足只让生长变慢、收成打折(按养分因子给 0.5–1 的系数),不会再掉血、不会枯死。温度或湿度出耐受区间仍然是真应激。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-genesis",
3
- "version": "2.2.5",
3
+ "version": "2.2.6",
4
4
  "type": "module",
5
5
  "description": "给 Agent 一颗物理自洽、一次性创世的星球:种子与少量旋钮生成恒星系与行星属性。",
6
6
  "license": "MIT",
package/src/game.ts CHANGED
@@ -2046,9 +2046,11 @@ export function sowAt(
2046
2046
  }
2047
2047
  const planted = nowPlanetHours(state, nowMs);
2048
2048
  const next = [...current];
2049
+ // id 按「这个站点里出现过的最大序号 + 1」往下排:拔掉几株之后不会和新苗撞号。
2050
+ let seq = maxPlantSeq(current);
2049
2051
  for (let n = 0; n < want; n += 1) {
2050
- const id = `${siteKey}#${(state.plants[siteKey]?.length ?? 0) + n + 1}`;
2051
- next.push(newPlant(id, bag.species, bag.genes, planted));
2052
+ seq += 1;
2053
+ next.push(newPlant(`${siteKey}#${seq}`, bag.species, bag.genes, planted));
2052
2054
  }
2053
2055
  const bags = state.seedBags
2054
2056
  .map((b) => (b.id === bagId ? { ...b, count: b.count - want } : b))
@@ -2145,7 +2147,17 @@ export function transplantAt(state: GameState, siteKey: string, plantId: string)
2145
2147
  }
2146
2148
 
2147
2149
  /** 拔掉一株死掉的作物(枯死、或应激到几乎没有生机)。活着的不能拔:收掉或移栽。 */
2148
- export const REMOVE_MIN_HEALTH = 0.2;
2150
+ export const REMOVE_MIN_HEALTH = 20;
2151
+
2152
+ /** 这个站点里出现过的最大株号(`<site>#12` → 12);没编号的按 0 算。 */
2153
+ export function maxPlantSeq(list: PlantRecord[] | undefined): number {
2154
+ let max = 0;
2155
+ for (const plant of list ?? []) {
2156
+ const match = /#(\d+)$/.exec(plant.id);
2157
+ if (match) max = Math.max(max, Number(match[1]));
2158
+ }
2159
+ return max;
2160
+ }
2149
2161
 
2150
2162
  export function removePlant(state: GameState, siteKey: string, plantId: string): { state: GameState; text: string } {
2151
2163
  if (state.transit) throw new Error('移动途中不能清理庄稼。');
@@ -2158,7 +2170,7 @@ export function removePlant(state: GameState, siteKey: string, plantId: string):
2158
2170
  const spec = SPECIES[plant.species];
2159
2171
  const dead = plant.stage === 'withering' || plant.health < REMOVE_MIN_HEALTH;
2160
2172
  if (!dead) {
2161
- throw new Error(`${spec.name}还活着(健康 ${Math.round(plant.health * 100)}%)——想处理它就收掉(如果结实)或者移栽(挖回种子),别直接拔。`);
2173
+ throw new Error(`${spec.name}还活着(健康 ${plant.health.toFixed(1)}%)——想处理它就收掉(如果结实)或者移栽(挖回种子),别直接拔。`);
2162
2174
  }
2163
2175
  const nextList = list.filter((p) => p.id !== plantId);
2164
2176
  return {
@@ -5516,8 +5528,8 @@ export function advanceLabor(system: StarSystem, state: GameState, nowMs: number
5516
5528
  if (spec.medium === 'water' && site.kind !== 'water') continue;
5517
5529
  if (spec.medium === 'land' && site.kind !== 'land') continue;
5518
5530
  if (climate.tempC < spec.tempMinC || climate.tempC > spec.tempMaxC) continue;
5519
- const count = Object.values(plants).reduce((n, l) => n + l.filter((p) => p.species === bag.species).length, 0);
5520
- plants[siteKey] = [...current, newPlant(seedId(bag.species, count + 1), bag.species, bag.genes, nowHours)];
5531
+ const fresh = newPlant(`${siteKey}#${maxPlantSeq(current) + 1}`, bag.species, bag.genes, nowHours);
5532
+ plants[siteKey] = [...current, fresh];
5521
5533
  const idx = next.seedBags.findIndex((b) => b.id === bag.id);
5522
5534
  if (idx >= 0) {
5523
5535
  const left = (next.seedBags[idx]!.count ?? 1) - 1;
package/src/world.ts CHANGED
@@ -1023,7 +1023,7 @@ export class GenesisWorld implements World {
1023
1023
 
1024
1024
  private breedTool(): ToolDef {
1025
1025
  return {
1026
- ...GENESIS_TOOL_DECLS[37]!,
1026
+ ...GENESIS_TOOL_DECLS[36]!,
1027
1027
  handler: async (args) => {
1028
1028
  const ready = await this.readyState();
1029
1029
  if ('error' in ready) return { text: ready.error, failed: true };
@@ -1048,7 +1048,7 @@ export class GenesisWorld implements World {
1048
1048
 
1049
1049
  private algaeTool(): ToolDef {
1050
1050
  return {
1051
- ...GENESIS_TOOL_DECLS[38]!,
1051
+ ...GENESIS_TOOL_DECLS[37]!,
1052
1052
  handler: async (args) => {
1053
1053
  const ready = await this.readyState();
1054
1054
  if ('error' in ready) return { text: ready.error, failed: true };
@@ -1072,7 +1072,7 @@ export class GenesisWorld implements World {
1072
1072
 
1073
1073
  private inspectTool(): ToolDef {
1074
1074
  return {
1075
- ...GENESIS_TOOL_DECLS[39]!,
1075
+ ...GENESIS_TOOL_DECLS[38]!,
1076
1076
  handler: async (args) => {
1077
1077
  const ready = await this.readyState();
1078
1078
  if ('error' in ready) return { text: ready.error, failed: true };
@@ -3997,7 +3997,7 @@ export class GenesisWorld implements World {
3997
3997
  }
3998
3998
 
3999
3999
  private removeTool(): ToolDef {
4000
- return this.uprootTool('remove', 36);
4000
+ return this.uprootTool('remove', 39);
4001
4001
  }
4002
4002
 
4003
4003
  /** 移栽与拔除共用一套「找株 → 动手 → 存盘」;区别只在引擎函数。 */