package org.academiadecodigo.bootcamp11.pokemon.map;


import org.academiadecodigo.bootcamp11.pokemon.map.city.*;

/**
 * Each map knows what cities exist.
 * Each map can tell what city comes next.
 * A map can give you a message telling you which cities are cleared.
 * In that message, mark an X next to those which are cleared.
 */

public class Map {

    private City[] cities;

    public Map(City homeTown) {
        cities = new City[]{
                homeTown,
                new ViridianCity(),
                new PewterCity(),
                new CeruleanCity(),
                new VermilionCity()
        };
    }

    public City getNextCity(City current) {
        int curCity = 0;
        for (int i = 0; i < this.cities.length; i++) {
            if (current == this.cities[i])
                curCity = i;
        }
        if (curCity == this.cities.length-1)
            return null;
        return this.cities[curCity+1];
    }

    public String showProgress() {
        StringBuilder result = new StringBuilder();
        for (City city : this.cities) {
            result.append(city + " ");
        }
        return result.toString();
    }
}
