/// <reference path="../Shuffler.ts" />
/// <reference path="RoomRandomMap.ts" />
class ShufflerDirection extends Shuffler<number> {
    private preferredGrowth : number;
    private directionsArray : Array<number>;
    public runner : number = 0;

    public constructor (array : Array<number>, preferredGrowth : number, rng? : () => number) {
        super(array, rng);
        this.preferredGrowth = preferredGrowth;

        let goodDirections = [];
        let badDirections = [];

        for (let direction = this.getOne(); direction != undefined; direction = this.getOne()) {
            if (RoomRandomMap.isDirectionPreferred(direction, this.preferredGrowth)) {
                goodDirections.push(direction);
            } else {
                badDirections.push(direction);
            }
        }

        this.directionsArray = goodDirections.concat(badDirections);
    }

    public  getDirection () {
        return this.directionsArray[this.runner++];
    }
}