package com.codingame.game;

import com.codingame.gameengine.core.MultiplayerGameManager;
import com.codingame.gameengine.core.AbstractMultiplayerPlayer;
import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
class LeagueManager {
    enum CheatLevel {
        ALLOWED,
        TOLERATED,
        FORBIDDEN
    }
    CheatLevel cheatLevel;

    enum MapLevel {
        SINGLE,
        DISCRETE,
        CONTINUOUS
    }
    MapLevel mapLevel;

    enum FixLevel { SOMETIMES, NEVER }
    FixLevel fixLevel;

    @Inject
    LeagueManager(MultiplayerGameManager<AbstractMultiplayerPlayer> gameManager)
    {
        int level = gameManager.getLeagueLevel();
        if (level < 1 || level > 3) {
            throw new InternalError("This game does not implement level " + level);
        }

        cheatLevel = level <= 1 ? CheatLevel.ALLOWED
                   : level <= 2 ? CheatLevel.TOLERATED
                   : CheatLevel.FORBIDDEN;

        mapLevel = level <= 1 ? MapLevel.SINGLE
                 : level <= 2 ? MapLevel.DISCRETE
                 : MapLevel.CONTINUOUS;

        fixLevel = level <= 1 ? FixLevel.SOMETIMES : FixLevel.NEVER;
    }    
}
