// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
//      Magicbane Emulator Project © 2013 - 2022
//                www.magicbane.com


package engine.powers.poweractions;

import engine.jobs.TrackJob;
import engine.math.Vector3fImmutable;
import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject;
import engine.powers.ActionsBase;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import engine.wpak.data.PowerAction;

import java.util.HashMap;


public class TrackPowerAction extends AbstractPowerAction {

    private String effectID;
    private EffectsBase effect;
    public PowerAction powerAction;

    public TrackPowerAction(PowerAction powerAction, HashMap<String, EffectsBase> effects) {
        super(powerAction);
        this.effectID = powerAction.effects.get(0).effect_id;
        this.effect = effects.get(this.effectID);
        this.powerAction = powerAction;
    }

    public String getEffectID() {
        return this.effectID;
    }

    public EffectsBase getEffect() {
        return this.effect;
    }

    @Override
    protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
        if (source == null || awo == null || this.effect == null || pb == null || ab == null) {
            //TODO log error here
            return;
        }

        //add schedule job to end it if needed and add effect to pc
        int duration = MBServerStatics.TRACK_ARROW_SENSITIVITY;
        String stackType = ab.getStackType();
        TrackJob eff = new TrackJob(source, awo, stackType, trains, ab, pb, this.effect, this);
        source.addEffect(stackType, duration, eff, this.effect, trains);
    }

    @Override
    protected void _handleChant(AbstractCharacter source, AbstractWorldObject target, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
    }

    @Override
    protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc,
                                int numTrains, ActionsBase ab, PowersBase pb, int duration) {
        // TODO Auto-generated method stub

    }
}
