diff --git a/src/main/java/com/fossgalaxy/games/ggj2017/JamApp.java b/src/main/java/com/fossgalaxy/games/ggj2017/JamApp.java index c41cf29692a72248e9bf31a6d9f9280c4e3ac354..cd877676c55ce93c84b3861b86574669cf6e11e3 100644 --- a/src/main/java/com/fossgalaxy/games/ggj2017/JamApp.java +++ b/src/main/java/com/fossgalaxy/games/ggj2017/JamApp.java @@ -14,6 +14,7 @@ import javax.swing.JFrame; import javax.swing.JToolBar; import com.fossgalaxy.games.rts.App; +import com.fossgalaxy.games.rts.GameDef; import com.fossgalaxy.games.rts.GameState; import com.fossgalaxy.games.rts.ai.Controller; import com.fossgalaxy.games.rts.entity.Entity; @@ -21,6 +22,7 @@ import com.fossgalaxy.games.rts.entity.EntityType; import com.fossgalaxy.games.rts.io.SettingsIO; import com.fossgalaxy.games.rts.order.Order; import com.fossgalaxy.games.rts.order.OrderProcessor; +import com.fossgalaxy.games.rts.rules.Rule; import com.fossgalaxy.games.rts.ui.GameAction; import com.fossgalaxy.games.rts.ui.GameModel; import com.fossgalaxy.games.rts.ui.GameView; @@ -40,6 +42,8 @@ public class JamApp //create the initial game state SettingsIO io = new SettingsIO(); GameState state = io.buildGame("map.json"); + + GameDef def = io.getGameDef(); //create the players //TODO clone, without it all moves WILL be applied twice. @@ -53,6 +57,10 @@ public class JamApp //create the thing that's doing the turn tracking. OrderProcessor processor = new OrderProcessor(state, 2); int MAX_TURNS = 100; + + for (Rule rule : def.getRules()) { + processor.addRule(rule); + } //turn loop //TODO this might be better inside the turn processor? @@ -69,7 +77,13 @@ public class JamApp processor.doOrderBulk(orders); processor.finishTurn(); + + if (processor.getWinner() != Rule.NO_WINNER) { + break; + } } + + System.out.println("Game over, player won: "+processor.getWinner()); }