use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.
the class RazorBarrierEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (player.chooseUse(outcome, "Give the targeted permanent protection from artifacts?", null, "Yes", "No (choose a color instead)", source, game)) {
game.addEffect(new GainAbilityTargetEffect(new ProtectionAbility(filter), Duration.EndOfTurn), source);
return true;
}
game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
return true;
}
use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.
the class MirrorGolemEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanent(source.getSourceId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
if (sourceObject == null || sourceObject.getImprinted() == null) {
return false;
}
for (UUID imprinted : sourceObject.getImprinted()) {
if (imprinted != null && exileZone.contains(imprinted)) {
Card card = game.getCard(imprinted);
if (card != null) {
for (CardType cardType : card.getCardType(game)) {
FilterCard filterCard;
if (cardType.equals(CardType.SORCERY)) {
filterCard = new FilterCard("sorceries");
} else if (cardType.equals(CardType.TRIBAL)) {
filterCard = new FilterCard("tribal");
} else {
filterCard = new FilterCard(cardType.toString() + "s");
}
filterCard.add(cardType.getPredicate());
sourceObject.addAbility(new ProtectionAbility(filterCard), source.getSourceId(), game);
}
}
}
}
return true;
}
use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.
the class RunedHaloSetProtectionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (controller != null && cardName != null && !cardName.isEmpty()) {
FilterObject filter = new FilterObject("the card name [" + cardName + ']');
filter.add(new NamePredicate(cardName));
ContinuousEffect effect = new GainAbilityControllerEffect(new ProtectionAbility(filter), Duration.Custom);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.
the class EarnestFellowshipEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (permanent.getColor(game).hasColor()) {
List<ColorPredicate> colorPredicates = new ArrayList<>();
for (ObjectColor color : permanent.getColor(game).getColors()) {
colorPredicates.add(new ColorPredicate(color));
}
FilterCard filterColors = new FilterCard("its colors");
filterColors.add(Predicates.or(colorPredicates));
Ability ability = new ProtectionAbility(filterColors);
permanent.addAbility(ability, source.getSourceId(), game);
}
}
return true;
}
use of mage.abilities.keyword.ProtectionAbility in project mage by magefree.
the class EonFrolickerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
return false;
}
game.getState().getTurnMods().add(new TurnMod(player.getId(), false));
FilterPlayer filter = new FilterPlayer(player.getName());
filter.add(new PlayerIdPredicate(player.getId()));
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControlledEffect(ability, Duration.UntilYourNextTurn, StaticFilters.FILTER_PERMANENT_PLANESWALKER), source);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.UntilYourNextTurn), source);
return true;
}
Aggregations