/*
 *   This file is a part of the SteamWar software.
 *
 *   Copyright (C) 2025 SteamWar.de-Serverteam
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

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().isEmpty(),
            Region::getBuildArea,
            (region, extension) -> region.getBuildArea().getMinPoint(extension),
            (region, extension) -> region.getBuildArea().getMaxPoint(extension)),
    TESTBLOCK("REGION_TYPE_ONLY_TB",
            region -> !region.getTestblockArea().isEmpty(),
            Region::getTestblockArea,
            (region, extension) -> region.getTestblockArea().getMinPoint(extension),
            (region, extension) -> region.getTestblockArea().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;
}
