use of mage.abilities.effects.common.continuous.GainAbilityControllerEffect in project mage by magefree.
the class SehtsTigerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
ChoiceColor choice = new ChoiceColor();
if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityControllerEffect in project mage by magefree.
the class FaithsShieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
if (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor();
if (!controller.choose(Outcome.Protect, choice, game)) {
return false;
}
if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
} else {
game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityControllerEffect 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.effects.common.continuous.GainAbilityControllerEffect 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;
}
use of mage.abilities.effects.common.continuous.GainAbilityControllerEffect in project mage by magefree.
the class GuardianArchonProtectionAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(ChooseSecretOpponentEffect.getChosenPlayer(source, game));
if (player == null) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(new GuardianArchonProtectionAbility(player.getId()), Duration.EndOfTurn), source);
game.addEffect(new GainAbilityControllerEffect(new GuardianArchonProtectionAbility(player.getId()), Duration.EndOfTurn), source);
return true;
}
Aggregations