FIX: IT belongs in a MODEL!
[troll.git] / src / main / java / com / codingame / game / LeagueManager.java
1 package com.codingame.game;
2
3 import com.codingame.gameengine.core.MultiplayerGameManager;
4 import com.codingame.gameengine.core.AbstractMultiplayerPlayer;
5 import com.google.inject.Inject;
6 import com.google.inject.Singleton;
7
8 @Singleton
9 class LeagueManager {
10     enum CheatLevel {
11         ALLOWED,
12         TOLERATED,
13         FORBIDDEN
14     }
15     CheatLevel cheatLevel;
16
17     enum MapLevel {
18         SINGLE,
19         DISCRETE,
20         CONTINUOUS
21     }
22     MapLevel mapLevel;
23
24     enum FixLevel { SOMETIMES, NEVER }
25     FixLevel fixLevel;
26
27     @Inject
28     LeagueManager(MultiplayerGameManager<AbstractMultiplayerPlayer> gameManager)
29     {
30         int level = gameManager.getLeagueLevel();
31         if (level < 1 || level > 3) {
32             throw new InternalError("This game does not implement level " + level);
33         }
34
35         cheatLevel = level <= 1 ? CheatLevel.ALLOWED
36                    : level <= 2 ? CheatLevel.TOLERATED
37                    : CheatLevel.FORBIDDEN;
38
39         mapLevel = level <= 1 ? MapLevel.SINGLE
40                  : level <= 2 ? MapLevel.DISCRETE
41                  : MapLevel.CONTINUOUS;
42
43         fixLevel = level <= 1 ? FixLevel.SOMETIMES : FixLevel.NEVER;
44     }    
45 }