import { assert } from "../../core/assert.js";
import { seededRandom } from "../../core/math/random/seededRandom.js";

export class TerrainTheme {
    /**
     *
     * @type {TerrainLayerRule[]}
     */
    rules = [];


    /**
     *
     * @param {GridData} grid
     * @param {number} seed
     */
    initialize(grid, seed) {
        assert.equal(grid.isGridData, true, 'grid.isGridData !== true');
        assert.isNumber(seed, 'seed');

        const rules = this.rules;
        const n = rules.length;

        const random = seededRandom(seed);

        for (let i = 0; i < n; i++) {
            const rule = rules[i];

            const ruleSeed = random();

            rule.filter.initialize(grid, ruleSeed);
        }
    }
}
