package utilities.GSON;

import gameAuthoring.scenes.actorBuildingScenes.TowerUpgradeGroup;
import gameEngine.actors.behaviors.IBehavior;
import gameEngine.levels.BaseLevel;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import utilities.errorPopup.ErrorPopup;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

public class GSONFileWriter {

    private GsonBuilder gson = new GsonBuilder();

    public void writeGameFile (List<TowerUpgradeGroup> towerGroups,
                               List<BaseLevel> levels,
                               String directory,
                               boolean[][] validLocations) {

    	gson.registerTypeAdapter(IBehavior.class, new IBehaviorClassAdapter());
        writeToFile(directory + "towers.json", gson.create().toJson(towerGroups, new TypeToken<List<TowerUpgradeGroup>>() {}.getType()));
        writeToFile(directory + "levels.json", gson.create().toJson(levels, new TypeToken<List<BaseLevel>>() {}.getType()));
        writeToFile(directory + "locations.json", gson.create().toJson(validLocations, validLocations.getClass()));
    }

    public void writeToFile(String fileName, String json) {
        try{
            File file = new File(fileName);
            FileWriter writer = new FileWriter(file);
            writer.write(json);
            writer.close();				
        }catch(IOException e) {
            new ErrorPopup("File to store actors could not be found.");
        }
    }
    

    
}
@@ -641,67 +641,8 @@
 tory
-,%0A                               boolean%5B%5D%5B%5D validLocations
 ) %7B%0A
@@ -974,32 +974,122 @@
 %7B%7D.getType()));%0A
+    %7D%0A    %0A    public void writeTowerRegions(String directory, boolean%5B%5D%5B%5D validRegions)%7B%0A
         writeToF
@@ -1144,29 +1144,27 @@
 toJson(valid
-Locat
+Reg
 ions, validL
@@ -1166,13 +1166,11 @@
 alid
-Locat
+Reg
 ions
@@ -1190,16 +1190,20 @@
 ;%0A    %7D%0A
+    
 %0A    pub

make separate method for regions