<commit_before>package gameEngine.model;

import gameEngine.factory.gridFactory.GridFactory;
import gameEngine.factory.temporaryBarrier.TemporaryBarrierFactory;
import gameEngine.factory.towerfactory.TowerFactory;
import gameEngine.model.effect.CreateEffect;
import gameEngine.model.enemy.Enemy;
import gameEngine.model.purchase.PurchaseInfo;
import gameEngine.model.tile.Tile;
import gameEngine.model.tower.Tower;
import gameEngine.model.warehouse.EnemyWarehouse;
import gameEngine.model.warehouse.TemporaryBarrierWarehouse;
import gameEngine.model.warehouse.TowerWarehouse;
import gameEngine.parser.Parser;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import jgame.impl.JGEngineInterface;


public class Model {

    /**
     * @author Yuhua
     * 
     * warehouse - store different kinds of tower, enemy warehouse
     * 
     */
    
    private Scanner scanner;
    private Parser parser;
    private GameInfo gameInfo;
    private TowerWarehouse towerWarehouse;
    private EnemyWarehouse enemyWarehouse;
    private TemporaryBarrierWarehouse temporaryBarrierWarehouse;
    private GridFactory gridFactory;
    private LinkedList<Tile> path;
    private JGEngineInterface myEng;
    private Rule rule; // how each waves created, ruleStart, ruleStop
    private ArrayList<ArrayList<Tile>> grid;
    private ArrayList<Tile> barriers;
    private ArrayList<Enemy> spawnedEnemies;

    public Model () {
         
    }

    public void newGame (File jsonFile) throws Exception {        
        scanner = new Scanner(jsonFile);
        parser = new Parser(scanner);

        gridFactory = new GridFactory(parser);
        gridFactory.initialize();
        path = gridFactory.getPathList();
        grid = gridFactory.getGridList();
        barriers = gridFactory.getBarrierList();
        spawnedEnemies = new ArrayList<Enemy>();
        temporaryBarrierWarehouse = new TemporaryBarrierWarehouse(parser);
        towerWarehouse = new TowerWarehouse(parser);
        enemyWarehouse = new EnemyWarehouse(parser, this);
       
        gameInfo = new GameInfo(parser);
    }
    // Fabio Changed it (added win and life reset)
    public void startGame () {
        gameInfo.SetIsWin(false);
        gameInfo.setLife(parser.getInt("numberOfLives"));
        gameInfo.setLife(parser.getInt("gold"));
//        rule.ruleStart();
        //Edited by Alex, call reset() instead of start()
        rule.reset();

    }

    //Yuhua change it
    //    public List<Tile> getPathList () {
    public LinkedList<Tile> getPathList () {
        return path;
    }
    
    public ArrayList<Tile> getBarrierList () {
        return barriers;
    }

    /**
     * @author Yuhua
     * Tower Related Method
     */

    /**
     * return all kinds of TowerFactory<commit_msg>Fixed bug in restarting gold<commit_after>package gameEngine.model;

import gameEngine.factory.gridFactory.GridFactory;
import gameEngine.factory.temporaryBarrier.TemporaryBarrierFactory;
import gameEngine.factory.towerfactory.TowerFactory;
import gameEngine.model.effect.CreateEffect;
import gameEngine.model.enemy.Enemy;
import gameEngine.model.purchase.PurchaseInfo;
import gameEngine.model.tile.Tile;
import gameEngine.model.tower.Tower;
import gameEngine.model.warehouse.EnemyWarehouse;
import gameEngine.model.warehouse.TemporaryBarrierWarehouse;
import gameEngine.model.warehouse.TowerWarehouse;
import gameEngine.parser.Parser;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import jgame.impl.JGEngineInterface;


public class Model {

    /**
     * @author Yuhua
     * 
     * warehouse - store different kinds of tower, enemy warehouse
     * 
     */
    
    private Scanner scanner;
    private Parser parser;
    private GameInfo gameInfo;
    private TowerWarehouse towerWarehouse;
    private EnemyWarehouse enemyWarehouse;
    private TemporaryBarrierWarehouse temporaryBarrierWarehouse;
    private GridFactory gridFactory;
    private LinkedList<Tile> path;
    private JGEngineInterface myEng;
    private Rule rule; // how each waves created, ruleStart, ruleStop
    private ArrayList<ArrayList<Tile>> grid;
    private ArrayList<Tile> barriers;
    private ArrayList<Enemy> spawnedEnemies;

    public Model () {
         
    }

    public void newGame (File jsonFile) throws Exception {        
        scanner = new Scanner(jsonFile);
        parser = new Parser(scanner);

        gridFactory = new GridFactory(parser);
        gridFactory.initialize();
        path = gridFactory.getPathList();
        grid = gridFactory.getGridList();
        barriers = gridFactory.getBarrierList();
        spawnedEnemies = new ArrayList<Enemy>();
        temporaryBarrierWarehouse = new TemporaryBarrierWarehouse(parser);
        towerWarehouse = new TowerWarehouse(parser);
        enemyWarehouse = new EnemyWarehouse(parser, this);
       
        gameInfo = new GameInfo(parser);
    }
    // Fabio Changed it (added win and life reset)
    public void startGame () {
        gameInfo.SetIsWin(false);
        gameInfo.setLife(parser.getInt("numberOfLives"));
        gameInfo.setGold(parser.getInt("gold"));
//        rule.ruleStart();
        //Edited by Alex, call reset() instead of start()
        rule.reset();

    }

    //Yuhua change it
    //    public List<Tile> getPathList () {
    public LinkedList<Tile> getPathList () {
        return path;
    }
    
    public ArrayList<Tile> getBarrierList () {
        return barriers;
    }

    /**
     * @author Yuhua
     * Tower Related Method
     */

    /**
     * return all kinds of TowerFactory
{'fraction_non_alphanumeric': 0.08960882302257453, 'fraction_numerical': 0.0, 'mean_word_length': 3.2027516292541636, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3199420', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1657, 'n_words': 385}