use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class SaheeliSublimeArtificerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent copyTo = game.getPermanent(getTargetPointer().getFirst(game, source));
if (copyTo != null) {
Permanent copyFrom = game.getPermanentOrLKIBattlefield(source.getTargets().get(1).getFirstTarget());
if (copyFrom != null) {
game.copyPermanent(Duration.EndOfTurn, copyFrom, copyTo.getId(), source, new EmptyCopyApplier());
ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT);
effect.setTargetPointer(new FixedTarget(copyTo, game));
game.addEffect(effect, source);
}
}
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class StrefanMaurerProgenitorPlayVampireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInHand(0, 1, vampireCardFilter);
if (!player.choose(outcome, player.getHand(), target, game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
game.getCombat().addAttackingCreature(permanent.getId(), game);
// Gains indestructable until end of turn
ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
game.addEffect(effect, source);
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class TemporalApertureTopCardCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.shuffleLibrary(source, game);
Card topCard = controller.getLibrary().getFromTop(game);
if (topCard != null) {
Cards cards = new CardsImpl(topCard);
controller.revealCards("Top card of " + controller.getName() + "'s library revealed", cards, game);
ContinuousEffect effect = new TemporalApertureTopCardCastEffect(topCard);
game.addEffect(effect, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class WalkingSpongeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
ChoiceImpl chooseAbility = new ChoiceImpl();
chooseAbility.setMessage("Choose an ability to remove (default is flying)");
Set<String> choice = new LinkedHashSet<>();
choice.add("Flying");
choice.add("First strike");
choice.add("Trample");
chooseAbility.setChoices(choice);
// since the player can't pick "no ability", let's default to the first option
Ability ability = FlyingAbility.getInstance();
if (controller.choose(Outcome.UnboostCreature, chooseAbility, game)) {
String chosenAbility = chooseAbility.getChoice();
if (chosenAbility.equals("First strike")) {
ability = FirstStrikeAbility.getInstance();
} else if (chosenAbility.equals("Trample")) {
ability = TrampleAbility.getInstance();
}
} else {
return false;
}
game.informPlayers(controller.getLogName() + " has chosen " + ability.getRule());
ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class WakeToSlaughterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Cards pickedCards = new CardsImpl(getTargetPointer().getTargets(game, source));
if (player != null && !pickedCards.isEmpty()) {
Card cardToHand;
if (pickedCards.size() == 1) {
cardToHand = pickedCards.getRandom(game);
} else {
Player opponent;
Set<UUID> opponents = game.getOpponents(player.getId());
if (opponents.size() == 1) {
opponent = game.getPlayer(opponents.iterator().next());
} else {
Target targetOpponent = new TargetOpponent(true);
player.chooseTarget(Outcome.Detriment, targetOpponent, source, game);
opponent = game.getPlayer(targetOpponent.getFirstTarget());
}
TargetCard target = new TargetCard(1, Zone.GRAVEYARD, new FilterCard());
target.withChooseHint("Card to go to opponent's hand (other goes to battlefield)");
opponent.chooseTarget(outcome, pickedCards, target, source, game);
cardToHand = game.getCard(target.getFirstTarget());
}
for (Card card : pickedCards.getCards(game)) {
if (card == cardToHand) {
player.moveCards(cardToHand, Zone.HAND, source, game);
} else {
player.moveCards(card, Zone.BATTLEFIELD, source, game);
FixedTarget fixedTarget = new FixedTarget(card, game);
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfGame);
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(fixedTarget);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
pickedCards.clear();
return true;
}
return false;
}
Aggregations