use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DarkDecisionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard());
target.setCardLimit(10);
if (controller.searchLibrary(target, source, game)) {
UUID targetId = target.getFirstTarget();
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DanceOfTheManseEffect 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(source.getTargets().stream().map(Target::getTargets).flatMap(Collection::stream).map(game::getCard).filter(Objects::nonNull).collect(Collectors.toSet()));
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
if (source.getManaCostsToPay().getX() < 6) {
return true;
}
cards.stream().map(game::getPermanent).filter(Objects::nonNull).forEach(permanent -> {
ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.CREATURE);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
effect = new SetPowerToughnessTargetEffect(4, 4, Duration.EndOfGame);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
});
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DonateEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetPlayer != null && permanent != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, targetPlayer.getId());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DracoplasmEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
controller.chooseTarget(Outcome.Detriment, target, source, game);
if (!target.getTargets().isEmpty()) {
int power = 0;
int toughness = 0;
for (UUID targetId : target.getTargets()) {
Permanent targetCreature = game.getPermanent(targetId);
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
power = CardUtil.overflowInc(power, targetCreature.getPower().getValue());
toughness = CardUtil.overflowInc(toughness, targetCreature.getToughness().getValue());
}
}
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b);
game.addEffect(effect, source);
}
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class FormOfTheSquirrelCantCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player sourceController = game.getPlayer(source.getControllerId());
if (sourceController != null) {
CreateTokenEffect effect = new CreateTokenEffect(new SquirrelToken());
effect.apply(game, source);
game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
Effect loseGameEffect = new LoseGameTargetPlayerEffect();
loseGameEffect.setTargetPointer(new FixedTarget(sourceController.getId(), game));
LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(loseGameEffect, false);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
game.addEffect(continuousEffect, source);
}
return true;
}
return false;
}
Aggregations