package eu.mhsl.minenet.minigames.instance.game.stateless.types.spleef;

import eu.mhsl.minenet.minigames.instance.game.Game;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.RestrictionHandler;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.common.MinimalPlayeramountGameRestriction;
import eu.mhsl.minenet.minigames.instance.room.Room;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import net.minestom.server.item.Material;

import java.util.Map;

public class SpleefFactory implements GameFactory {
    @Override
    public TranslatedComponent name() {
        return TranslatedComponent.byId("game_Spleef#name");
    }

    @Override
    public RestrictionHandler globalRestrictions() {
        return new RestrictionHandler()
                .addRestriction(new MinimalPlayeramountGameRestriction(2));
    }

    @Override
    public Material symbol() {
        return Material.DIAMOND_SHOVEL;
    }

    @Override
    public ConfigManager configuration() {
        return new ConfigManager()
                .addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30))
                .addOption(new NumericOption("stackCount", Material.SCAFFOLDING, TranslatedComponent.byId("game_Spleef#stackCount"), 1, 2, 3, 4, 5));
    }

    @Override
    public TranslatedComponent description() {
        return TranslatedComponent.byId("game_Spleef#description");
    }

    @Override
    public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
        return new Spleef(configuration.get("radius").getAsInt(), configuration.get("stackCount").getAsInt()).setParent(parent);
    }
}
