Add new common effect class for Armored Transport, etc and fix #9614

This commit is contained in:
Alex W. Jackson 2022-10-11 22:48:02 -04:00
parent 17be0c11ba
commit 4bf01249a4
25 changed files with 359 additions and 809 deletions

View file

@ -0,0 +1,54 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.constants.Duration;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author awjackson
*/
public class PreventAllDamageToSourceByPermanentsEffect extends PreventAllDamageByAllPermanentsEffect {
public PreventAllDamageToSourceByPermanentsEffect(FilterPermanent filter) {
this(filter, false);
}
public PreventAllDamageToSourceByPermanentsEffect(FilterPermanent filter, boolean onlyCombat) {
this(filter, Duration.WhileOnBattlefield, onlyCombat);
}
public PreventAllDamageToSourceByPermanentsEffect(FilterPermanent filter, Duration duration, boolean onlyCombat) {
super(filter, duration, onlyCombat);
setText();
}
public PreventAllDamageToSourceByPermanentsEffect(final PreventAllDamageToSourceByPermanentsEffect effect) {
super(effect);
}
public PreventAllDamageToSourceByPermanentsEffect copy() {
return new PreventAllDamageToSourceByPermanentsEffect(this);
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return super.applies(event, source, game) && event.getTargetId().equals(source.getSourceId());
}
private void setText() {
StringBuilder sb = new StringBuilder("prevent all ");
if (onlyCombat) {
sb.append("combat ");
}
sb.append("damage that would be dealt to {this} ");
if (duration == Duration.EndOfTurn) {
sb.append("this turn ");
}
sb.append("by ");
sb.append(filter.getMessage());
staticText = sb.toString();
}
}