package de.steamwar.bausystem.region.utils;

import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.shared.EnumDisplay;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;

@AllArgsConstructor
@Getter
public enum RegionType implements EnumDisplay {
    NORMAL("REGION_TYPE_NORMAL",
            region -> true,
            Region::getArea,
            (region, extension) -> region.getArea().getMinPoint(false),
            (region, extension) -> region.getArea().getMaxPoint(false)),
    BUILD("REGION_TYPE_BUILD",
            region -> region.getBuildArea().isPresent(),
            region -> region.getBuildArea().get(),
            (region, extension) -> region.getBuildArea().get().getMinPoint(extension),
            (region, extension) -> region.getBuildArea().get().getMaxPoint(extension)),
    TESTBLOCK("REGION_TYPE_ONLY_TB",
            region -> region.getTestblockArea().isPresent(),
            region -> region.getTestblockArea().get(),
            (region, extension) -> region.getTestblockArea().get().getMinPoint(extension),
            (region, extension) -> region.getTestblockArea().get().getMaxPoint(extension)),
    ;

    private String chatValue;

    private Predicate<Region> hasType;
    private Function<Region, Region.Area> toInner;
    private BiFunction<Region, Boolean, Point> toMinPoint;
    private BiFunction<Region, Boolean, Point> toMaxPoint;
}
