use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class WinotaJoinerOfForcesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6));
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, 1, filter);
player.choose(outcome, cards, targetCardInLibrary, game);
Card card = game.getCard(targetCardInLibrary.getFirstTarget());
if (card == null || !player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null)) {
return player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
game.getCombat().addAttackingCreature(permanent.getId(), game);
cards.remove(card);
game.addEffect(new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTarget(permanent, game)), source);
return player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class WingedTempleOfOrazcaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null && creature.isCreature(game)) {
int pow = creature.getPower().getValue();
ContinuousEffect effect = new BoostTargetEffect(pow, pow, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class AlchemistsGiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Ability ability = player.chooseUse(outcome, "Deathtouch or lifelink?", null, "Deathtouch", "Lifelink", source, game) ? DeathtouchAbility.getInstance() : LifelinkAbility.getInstance();
game.addEffect(new BoostTargetEffect(1, 1, Duration.EndOfTurn), source);
game.addEffect(new GainAbilityTargetEffect(ability, Duration.EndOfTurn), source);
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class AngelicGuardianGainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
game.getCombat().getAttackers().stream().map(game::getPermanent).filter(Objects::nonNull).filter(permanent -> permanent.isControlledBy(you.getId())).filter(permanent1 -> permanent1.isCreature(game)).forEach(permanent -> {
ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
});
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class HarmoniousEmergenceEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
Permanent enchantedPermanent = game.getPermanent(event.getTargetId());
if (sourcePermanent == null || enchantedPermanent == null) {
return false;
}
sourcePermanent.sacrifice(source, game);
game.addEffect(new GainAbilityTargetEffect(IndestructibleAbility.getInstance()).setTargetPointer(new FixedTarget(enchantedPermanent, game)), source);
return true;
}
Aggregations