package engine.element;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import engine.GameState;
import engine.TowerManager;
import engine.Updateable;
import engine.conditions.Condition;
import engine.element.sprites.Tower;
import engine.element.sprites.TowerFactory;


/**
 * This class holds an instance of an entire tower defense game. It keeps the levels, towers,
 * enemies, and their properties.
 * 
 * @author Qian Wang
 * @author Bojia Chen
 *
 */
public class Game extends GameElement implements Updateable {

    private List<Condition> myConditions;
    private List<Level> myLevels;
    private Layout myLayout;
    private int myActiveLevel;
    public GameState myGameState;

    public Game () {
        myConditions = new ArrayList<Condition>();
        myLevels = new ArrayList<>();
        
        myLayout = new Layout();
        myActiveLevel = 0;
        myGameState = new GameState();
    }

    public void endGame () {

    }

    @Override
    public void update (int counter) {
        myConditions.forEach(c -> c.act(myGameState));
        myLevels.get(myActiveLevel).update(counter);
        myLayout.update(counter);
    }

    protected void addTowers(Map<String,Map<String,Object>> allTowers) {
        myLayout.initializeTowers(allTowers);
    }

    protected void addEnemies(Collection<Map<String,Object>> enemyParameters) {
        for(Map<String,Object> map : enemyParameters){
            myLayout.initializeEnemy(map);
        }
    }
    
    protected void addProjectiles(Collection<Map<String,Object>> projectileParameters){
        for(Map<String,Object> map: projectileParameters){
            myLayout.initializeProjectile(map);
        }
    }
}

@@ -149,36 +149,8 @@
 te;%0A
-import engine.TowerManager;%0A
 impo
@@ -211,89 +211,8 @@
 on;%0A
-import engine.element.sprites.Tower;%0Aimport engine.element.sprites.TowerFactory;%0A
 %0A%0A/*
@@ -739,24 +739,16 @@
 st%3C%3E();%0A
-        
 %0A       
@@ -1086,32 +1086,29 @@
     %7D%0A%0A    p
-rotected
+ublic
  void addTow
@@ -1110,16 +1110,17 @@
 ddTowers
+ 
 (Map%3CStr
@@ -1123,16 +1123,17 @@
 %3CString,
+ 
 Map%3CStri
@@ -1127,32 +1127,33 @@
 ing, Map%3CString,
+ 
 Object%3E%3E allTowe
@@ -1212,32 +1212,29 @@
     %7D%0A%0A    p
-rotected
+ublic
  void addEne
@@ -1237,16 +1237,17 @@
 dEnemies
+ 
 (Collect
@@ -1253,32 +1253,33 @@
 tion%3CMap%3CString,
+ 
 Object%3E%3E enemyPa
@@ -1293,32 +1293,33 @@
 s) %7B%0A        for
+ 
 (Map%3CString,Obje
@@ -1306,32 +1306,33 @@
 for (Map%3CString,
+ 
 Object%3E map : en
@@ -1337,32 +1337,33 @@
 enemyParameters)
+ 
 %7B%0A            my
@@ -1411,26 +1411,19 @@
   %7D%0A
-    
 %0A    p
-rotected
+ublic
  voi
@@ -1438,16 +1438,17 @@
 jectiles
+ 
 (Collect
@@ -1458,24 +1458,25 @@
 %3CMap%3CString,
+ 
 Object%3E%3E pro
@@ -1485,32 +1485,33 @@
 ctileParameters)
+ 
 %7B%0A        for(Ma
@@ -1507,16 +1507,17 @@
      for
+ 
 (Map%3CStr
@@ -1520,16 +1520,17 @@
 %3CString,
+ 
 Object%3E 
@@ -1532,16 +1532,17 @@
 ect%3E map
+ 
 : projec
@@ -1556,16 +1556,17 @@
 ameters)
+ 
 %7B%0A      

Load in sprites and add to right files