package org.project.location;

import org.project.entity.enemies.Enemy;
import org.project.entity.enemies.Goblin;
import org.project.entity.enemies.Skeleton;
import org.project.entity.enemies.Vampire;

import java.util.ArrayList;

public class Location {
    private String name;
//    private Boolean isDiscovered;
    private int skeleton = 0;
    private int vampire = 0;
    private int goblin = 0;



    private ArrayList<Enemy> enemies;
//    private ArrayList<Location> locations;



//    ArrayList<Location> locations
    public Location(String name) {
//        this.locations = locations;
        this.name = name;
        this.enemies = new ArrayList<>();
//        this.isDiscovered = false;
    }



    public int getGoblin() {
        return goblin;
    }

    public int getVampire() {
        return vampire;
    }

    public int getSkeleton() {
        return skeleton;
    }

    public void addEnemy(Enemy enemy)
    {
        enemies.add(enemy);
        if(enemy instanceof Skeleton)
        {
            skeleton++;
        } else if (enemy instanceof Vampire)
        {
            vampire++;
        }
        else if(enemy instanceof Goblin)
        {
            goblin++;
        }

    }

    public void defeatEnemy(Enemy enemy)
    {
        enemies.remove(enemy);
    }

    @Override
    public String toString() {
        StringBuilder s = new StringBuilder();
        s.append(name).append("\n").append("Enemies: \n");
        if(skeleton > 0)
        {
            s.append("Skeleton: ").append(skeleton).append("\n");
        }
        if(vampire > 0)
        {
            s.append("Vampire: ").append(vampire).append("\n");
        }
        if(goblin > 0)
        {
            s.append("Goblin: ").append(goblin).append("\n");
        }
        return s.toString();
    }

    public boolean checkLives()
    {
        for (Enemy enemy : enemies) {
            if (enemy.isAlive()) {
                return true;
            }

        }
        return false;
    }

    public void resetLives()
    {
        for (Enemy enemy : enemies) {
            enemy.setHp(enemy.getMaxHP());
            enemy.setHaveBleed(false);
            enemy.setBleedingRound(0);
        }
    }
    public String getName() {
        return name;
    }

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


//    public Boolean isDiscovered() {
//        return isDiscovered;
//    }
//
//    public void setDiscovered(Boolean discovered) {
//        isDiscovered = discovered;
//    }

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