// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.procedurallib.condition;

import java.util.Arrays;
import javax.annotation.Nonnull;

public class DoubleThreshold
{
    public static class Single implements IDoubleThreshold
    {
        protected final double min;
        protected final double max;
        protected final double halfRange;
        
        public Single(final double min, final double max) {
            this.min = min;
            this.max = max;
            this.halfRange = (max - min) * 0.5;
        }
        
        @Override
        public boolean eval(final double d) {
            return this.min <= d && d <= this.max;
        }
        
        @Override
        public boolean eval(final double d, final double factor) {
            final double t0 = this.min + this.halfRange * factor;
            final double t2 = this.max - this.halfRange * factor;
            return t0 <= d && d <= t2;
        }
        
        @Nonnull
        @Override
        public String toString() {
            return "DoubleThreshold.Single{min=" + this.min + ", max=" + this.max + ", halfRange=" + this.halfRange;
        }
    }
    
    public static class Multiple implements IDoubleThreshold
    {
        protected final Single[] singles;
        
        public Multiple(final Single[] singles) {
            this.singles = singles;
        }
        
        @Override
        public boolean eval(final double d) {
            for (final Single single : this.singles) {
                if (single.eval(d)) {
                    return true;
                }
            }
            return false;
        }
        
        @Override
        public boolean eval(final double d, final double factor) {
            for (final Single single : this.singles) {
                if (single.eval(d, factor)) {
                    return true;
                }
            }
            return false;
        }
        
        @Nonnull
        @Override
        public String toString() {
            return "DoubleThreshold.Multiple{singles=" + Arrays.toString(this.singles);
        }
    }
}
