import { assert } from "../../../../core/assert.js";
import { GridTaskGenerator } from "../../GridTaskGenerator.js";

export class GridTaskActionRuleSet extends GridTaskGenerator {

    /**
     *
     * @type {GridActionRuleSet}
     */
    rules = null;

    /**
     *
     * @type {number}
     */
    resolution = 1;

    /**
     *
     * @param {string} [name]
     * @param {GridActionRuleSet} rules
     * @param {number} [resolution=1]
     * @returns {GridTaskActionRuleSet}
     */
    static from({ name, rules, resolution = 1 }) {
        assert.isNumber(resolution, 'resolution');

        const r = new GridTaskActionRuleSet();

        r.rules = rules;
        r.resolution = resolution;

        if (name !== undefined) {
            r.name = name;
        }

        return r;
    }

    build(grid, ecd, seed) {
        return this.rules.process(grid, seed, this.resolution);
    }
}
