import Vector from "./Vector";
export default class Random {
    static integer(minimum, maximum) {
        return Math.floor(Math.random() * (maximum - minimum + 1) + minimum);
    }
    static sign() {
        const bit = this.integer(0, 1);
        if (bit)
            return 1;
        return -1;
    }
    static location(point, inner, outer) {
        const x = this.integer(point.x + inner, point.x + outer);
        const y = this.integer(point.y + inner, point.y + outer);
        const z = this.integer(point.z + inner, point.z + outer);
        return Vector.new(x, y, z);
    }
    static probability(array) {
        if (array.length == 0)
            return undefined;
        let total = 0;
        for (let i = 0; i < array.length; i++) {
            if (array[i].probability == undefined)
                return undefined;
            total = total + array[i].probability;
        }
        const random = this.integer(0, total);
        let index = 0;
        for (let i = 0; i < array.length; i++) {
            index = index + array[i].probability;
            if (index >= random)
                return i;
        }
        return 0;
    }
    static value(array) {
        if (array == undefined)
            return undefined;
        return array[this.integer(0, array.length - 1)];
    }
}
