✨ Försterkreislauf: Setzlinge beim Fällen, Försterhaus, Förster-Job
- Gefällter Baum → 1–2 tree_seed im Stockpile (zufällig) - Neues Gebäude forester_hut (50 wood): Log-Hütten-Grafik, Klick öffnet Info-Panel - Zonenmarkierung: Edit-Zone-Tool, Radius 5 Tiles, halbtransparente Overlay-Anzeige - Neuer JobType 'forester': Nisse pflanzen Setzlinge auf markierten Zonen-Tiles - Chop-Priorisierung: Zonen-Bäume werden vor natürlichen Bäumen gefällt - Nisse-Panel & Info-Panel zeigen forester-Priorität-Button Closes #25 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ function makeEmptyWorld(seed: number): WorldState {
|
||||
stockpile: { wood: 10, stone: 5, wheat_seed: 10, carrot_seed: 5, wheat: 0, carrot: 0, tree_seed: 5 },
|
||||
treeSeedlings: {},
|
||||
tileRecovery: {},
|
||||
foresterZones: {},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,11 +66,20 @@ class StateManager {
|
||||
w.buildings[action.building.id] = action.building
|
||||
for (const [k, v] of Object.entries(action.costs))
|
||||
w.stockpile[k as ItemId] = Math.max(0, (w.stockpile[k as ItemId] ?? 0) - (v ?? 0))
|
||||
// Automatically create an empty forester zone when a forester hut is placed
|
||||
if (action.building.kind === 'forester_hut') {
|
||||
w.foresterZones[action.building.id] = { buildingId: action.building.id, tiles: [] }
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'REMOVE_BUILDING':
|
||||
delete w.buildings[action.buildingId]; break
|
||||
// Remove associated forester zone when the hut is demolished
|
||||
if (w.buildings[action.buildingId]?.kind === 'forester_hut') {
|
||||
delete w.foresterZones[action.buildingId]
|
||||
}
|
||||
delete w.buildings[action.buildingId]
|
||||
break
|
||||
|
||||
case 'ADD_ITEMS':
|
||||
for (const [k, v] of Object.entries(action.items))
|
||||
@@ -169,6 +179,12 @@ class StateManager {
|
||||
case 'TILE_RECOVERY_START':
|
||||
w.tileRecovery[`${action.tileX},${action.tileY}`] = TILE_RECOVERY_MS
|
||||
break
|
||||
|
||||
case 'FORESTER_ZONE_UPDATE': {
|
||||
const zone = w.foresterZones[action.buildingId]
|
||||
if (zone) zone.tiles = [...action.tiles]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,9 +258,18 @@ class StateManager {
|
||||
if (!p.world.stockpile) p.world.stockpile = {}
|
||||
if (!p.world.treeSeedlings) p.world.treeSeedlings = {}
|
||||
if (!p.world.tileRecovery) p.world.tileRecovery = {}
|
||||
if (!p.world.foresterZones) p.world.foresterZones = {}
|
||||
// Reset in-flight AI states to idle on load so runtime timers start fresh
|
||||
for (const v of Object.values(p.world.villagers)) {
|
||||
if (v.aiState === 'walking' || v.aiState === 'working') v.aiState = 'idle'
|
||||
// Migrate older saves that don't have the forester priority
|
||||
if (typeof (v.priorities as any).forester === 'undefined') v.priorities.forester = 4
|
||||
}
|
||||
// Rebuild forester zones for huts that predate the foresterZones field
|
||||
for (const b of Object.values(p.world.buildings)) {
|
||||
if (b.kind === 'forester_hut' && !p.world.foresterZones[b.id]) {
|
||||
p.world.foresterZones[b.id] = { buildingId: b.id, tiles: [] }
|
||||
}
|
||||
}
|
||||
return p
|
||||
} catch (_) { return null }
|
||||
|
||||
Reference in New Issue
Block a user