package moe.oko.opennaw.model.action;

import moe.oko.opennaw.OpenNAW;
import moe.oko.opennaw.model.City;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

public class CityDefenseAction extends Action {

    //60 seconds for defense action
    public static final long DELAY = 1200L;

    public OfflinePlayer player;

    public City city;

    public CityDefenseAction(OfflinePlayer player, City city) {
        this.timeOfAction = System.currentTimeMillis();
        this.player = player;
        this.city = city;
    }

    public void initiation() {
        for(var player : Bukkit.getOnlinePlayers()) {
            if(player.getLocation().distance(city.getPoint()) < 100) {
                player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + player.getName() + " HAS STARTED DEFENDING THE POINT.");
            }
        }
    }

    public void completion() {
        city.defend();
    }

    public OfflinePlayer getPlayer() {
        return player;
    }
}
