/*
 *   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.flags;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * ColorMode defines the colors a Region can have
 */
@Getter
@AllArgsConstructor
public enum ColorMode implements Flag.Value<ColorMode> {
    WHITE("FLAG_COLOR_WHITE", 'f'),
    ORANGE("FLAG_COLOR_ORANGE", '6'),
    MAGENTA("FLAG_COLOR_MAGENTA", '5'),
    LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", 'b'),
    YELLOW("FLAG_COLOR_YELLOW", 'e'),
    LIME("FLAG_COLOR_LIME", 'a'),
    PINK("FLAG_COLOR_PINK", 'd'),
    GRAY("FLAG_COLOR_GRAY", '8'),
    LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", '7'),
    CYAN("FLAG_COLOR_CYAN", '3'),
    PURPLE("FLAG_COLOR_PURPLE", '5'),
    BLUE("FLAG_COLOR_BLUE", '9'),
    BROWN("FLAG_COLOR_BROWN", 'e'),
    GREEN("FLAG_COLOR_GREEN", '2'),
    RED("FLAG_COLOR_RED", 'c'),
    BLACK("FLAG_COLOR_BLACK", '1');

    private static ColorMode[] values;
    private final String chatValue;
    private final char colorCode;

    @Override
    public ColorMode[] getValues() {
        if (ColorMode.values == null) {
            ColorMode.values = ColorMode.values();
        }
        return ColorMode.values;
    }

    @Override
    public ColorMode getValue() {
        return this;
    }

    @Override
    public ColorMode getValueOf(final String name) {
        try {
            return ColorMode.valueOf(name.toUpperCase());
        } catch (IllegalArgumentException e) {
            return ColorMode.YELLOW;
        }
    }
}
