Debug the CG SDK. Errr… I mean leaguify maps.
[troll.git] / src / main / java / com / codingame / game / Model.java
index 6eb0546..96140f5 100644 (file)
@@ -9,6 +9,8 @@ import com.google.inject.Inject;
 
 class Model {
     @Inject private MultiplayerGameManager<com.codingame.game.Player> gameManager;
 
 class Model {
     @Inject private MultiplayerGameManager<com.codingame.game.Player> gameManager;
+    @Inject private LeagueManager league;
+    long seed;
     Random random;
     int roadLength;
     int initialStones;
     Random random;
     int roadLength;
     int initialStones;
@@ -18,8 +20,17 @@ class Model {
     class Player {
         com.codingame.game.Player gp;
         int index;
     class Player {
         com.codingame.game.Player gp;
         int index;
+        boolean hit;
 
 
-        Player(int i) { index = i; }
+        Player(int i) {
+            index = i;
+            hit = false;
+        }
+
+        void loseRound() {
+            hit = true;
+            winner = 1 - index;
+        }
 
         private int castlePosition;
         public int getCastlePosition() { return castlePosition; }
 
         private int castlePosition;
         public int getCastlePosition() { return castlePosition; }
@@ -76,24 +87,39 @@ class Model {
         }
     }
 
         }
     }
 
-    void init(long seed) {
+    void init() {
+        seed = gameManager.getSeed();
         random = new Random(seed);
         random = new Random(seed);
-        switch (random.nextInt(4)) {
-        case 0:
+
+        switch(league.mapLevel) {
+        case SINGLE:
             roadLength = 6;
             initialStones = 15;
             break;
             roadLength = 6;
             initialStones = 15;
             break;
-        case 1:
-            roadLength = 6;
-            initialStones = 30;
-            break;
-        case 2:
-            roadLength = 14;
-            initialStones = 30;
+        case DISCRETE:
+            int i = random.nextInt(4);
+            switch (i) {
+            case 0:
+                roadLength = 6;
+                initialStones = 15;
+                break;
+            case 1:
+                roadLength = 6;
+                initialStones = 30;
+                break;
+            case 2:
+                roadLength = 14;
+                initialStones = 30;
+                break;
+            case 3:
+                roadLength = 14;
+                initialStones = 50;
+                break;
+            }
             break;
             break;
-        case 3:
-            roadLength = 14;
-            initialStones = 50;
+        case CONTINUOUS:
+            roadLength = 2 * (3 + random.nextInt(7-3+1));
+            initialStones = 15 + random.nextInt(50-15+1);
             break;
         }
 
             break;
         }