package moe.oko.opennaw.model.action;

import moe.oko.opennaw.OpenNAW;
import moe.oko.opennaw.model.City;
import moe.oko.opennaw.model.Nation;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;

public class CityAttackAction extends Action{
    public static final long DELAY = 200L;

    public OfflinePlayer player;

    public City city;

    public OfflinePlayer getPlayer() {
        return player;
    }

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

    public void initiation() {
        city.getPoint().getWorld().playSound(city.getPoint(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1, 1);
        if(!city.underSiege()) {
            var nation = OpenNAW.getInstance().getNationHandler().getNationByPlayer(player.getUniqueId());
            //Initiate siege.
            city.startSiege(nation);
        }
    }

    public void completion() {
        //Completion logic...
        if(!player.isOnline()) { return; }
        var online = player.getPlayer();
        online.sendMessage(ChatColor.GREEN + "Action Completed");
        city.damage();
    }
}
