package de.kimminich.kata.botwars.effects;

import de.kimminich.kata.botwars.Bot;
import de.kimminich.kata.botwars.messages.Message;

public abstract class AbstractEffect implements Effect {

    private Bot invoker;
    private int duration;

    public AbstractEffect(Bot invoker, Integer duration) {
        this.invoker = invoker;
        this.duration = duration;
    }

    public int getDuration() {
        return duration;
    }

    @Override
    public boolean isExpired() {
        return duration == 0;
    }

    @Override
    public Message apply(Bot target) {
        duration--;
        return applyEffect(invoker, target);
    }

    @Override
    public Message revoke(Bot target) {
        return revokeEffect(invoker, target);
    }

    public abstract Message applyEffect(Bot invoker, Bot target);

    public abstract Message revokeEffect(Bot invoker, Bot target);

    @Override
    public String toString() {
        return this.getClass().getSimpleName() + "(" + duration + ")";
    }
}

@@ -373,71 +373,8 @@
  %7D%0A%0A
-    public int getDuration() %7B%0A        return duration;%0A    %7D%0A%0A
     

Remove unused getter for duration