import { createFamily } from "./create_family.js";
import { random } from "./random_utils.js";
/**
* Enriches a location map with event-driven narrative content. Currently populates farm locations
* with family occupants, adding a family tree and roster to each farm's description.
*
* @param {Object} options - Event layer options
* @param {Map} options.map - A location map keyed by location type (e.g. "Farm"). Modified in place.
* @returns {void}
*/
export function createEventLayer({ map } = {}) {
if (!map) {
throw new Error("Map is required to create an event layer.");
}
const farms = map.get("Farm");
if (farms) {
for (const farm of farms) {
const family = createFamily({ generations: random([1, 2, 2, 3]) });
farm.name = `${family.familyName} Family Farm`;
farm.description.unshift(family.toRoster());
farm.description.unshift(family.toFamilyTree());
farm.description.unshift(`This farm is still inhabited by the ${family.familyName} family.`);
}
}
}