package eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.common;

import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.IRestriction;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.Restriction;
import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.RestrictionData;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;

public class MaximalPlayeramountGameRestriction implements IRestriction {
    private final int max;

    public MaximalPlayeramountGameRestriction(int max) {
        this.max = max;
    }

    @Override
    public Restriction calculate(RestrictionData data) {
        return new Restriction(
                TranslatedComponent.byId("restriction#maxPlayersInRoom"),
                TranslatedComponent.byId("restriction#maxPlayersInRoomDescription"),
                null,
                data.room().getAllMembers().size() > this.max ? Restriction.Type.FAIL : Restriction.Type.OK
        );
    }
}
