package org.project.location;

import org.project.entity.enemies.Enemy;

import java.util.ArrayList;

public class Location
{
    private String name;
    private ArrayList<Location> locations;
    private ArrayList<Enemy> enemies;

    public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies)
    {
        this.locations = locations;
        this.enemies = enemies;
    }

    public String getName() {return name;}

    public ArrayList<Location> getLocations() {return locations;}

    public ArrayList<Enemy> getEnemies() {return enemies;}

    public void setName(String name) {this.name = name;}

    public void addAdjacentLocation(Location location)
    {
        if (this.locations == null)
        {
            this.locations = new ArrayList<>();
        }
        this.locations.add(location);
    }

    public void addEnemy(Enemy enemy)
    {
        if (this.enemies == null)
        {
            this.enemies = new ArrayList<>();
        }
        this.enemies.add(enemy);
    }

    public boolean hasLivingEnemies()
    {
        if (this.enemies == null) {return false;}

        for (Enemy enemy : enemies)
        {
            if (enemy.isAlive()) {return true;}
        }
        return false;
    }
}
