use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class OffspringsRevengeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (player == null || card == null) {
return false;
}
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 1, false, false, null, 1, 1, false);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
player.moveCards(card, Zone.EXILED, source, game);
effect.apply(game, source);
effect.getAddedPermanents().stream().forEach(permanent -> {
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
continuousEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(continuousEffect, source);
});
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class PrismaticBoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ChoiceColor choice = new ChoiceColor();
if (!player.choose(outcome, choice, game)) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(ProtectionAbility.from(choice.getColor()), Duration.EndOfTurn), source);
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class TidalFlatsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Player player = game.getPlayer(game.getActivePlayerId());
if (player == null) {
return false;
}
Cost cost = new ManaCostsImpl("{1}");
List<Permanent> affectedPermanents = new ArrayList<>();
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
cost.clearPaid();
String message = "Pay " + cost.getText() + " for " + permanent.getLogName() + "? If you don't, creatures " + controller.getLogName() + " controls blocking it gain first strike until end of turn.";
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
if (cost.pay(source, game, source, player.getId(), false, null)) {
game.informPlayers(player.getLogName() + " paid " + cost.getText() + " for " + permanent.getLogName());
} else {
game.informPlayers(player.getLogName() + " didn't pay " + cost.getText() + " for " + permanent.getLogName());
affectedPermanents.add(permanent);
}
} else {
game.informPlayers(player.getLogName() + " didn't pay " + cost.getText() + " for " + permanent.getLogName());
affectedPermanents.add(permanent);
}
}
for (Permanent permanent : affectedPermanents) {
CombatGroup group = game.getCombat().findGroup(permanent.getId());
if (group != null) {
for (UUID blockerId : group.getBlockers()) {
Permanent blocker = game.getPermanent(blockerId);
if (blocker != null && Objects.equals(blocker.getControllerId(), controller.getId())) {
ContinuousEffect effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(blocker.getId(), game));
game.addEffect(effect, source);
}
}
}
}
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class UrzasEngineEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
for (UUID bandedId : sourcePermanent.getBandedCards()) {
Permanent banded = game.getPermanent(bandedId);
if (banded != null && banded.isAttacking() && banded.getBandedCards() != null && banded.getBandedCards().contains(sourcePermanent.getId())) {
GainAbilityTargetEffect effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(bandedId, game));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class WarrenWeirdingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player == null) {
return false;
}
FilterControlledPermanent filter = new FilterControlledPermanent("creature");
filter.add(CardType.CREATURE.getPredicate());
filter.add(new ControllerIdPredicate(player.getId()));
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
// had, if thats the case this ability should fizzle.
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
if (filterGoblin.match(permanent, game)) {
for (int i = 0; i < 2; i++) {
Token token = new GoblinRogueToken();
Effect effect = new CreateTokenTargetEffect(token);
effect.setTargetPointer(new FixedTarget(player.getId()));
if (effect.apply(game, source)) {
Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
if (tokenPermanent != null) {
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
hasteEffect.setTargetPointer(new FixedTarget(tokenPermanent.getId()));
game.addEffect(hasteEffect, source);
}
}
}
}
}
return true;
}
return false;
}
Aggregations