use of mage.target.Target in project mage by magefree.
the class MassMutinyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
for (Target target : source.getTargets()) {
if (target instanceof TargetCreaturePermanent) {
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null) {
ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect1, source);
ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect2, source);
targetCreature.untap(game);
result = true;
}
}
}
return result;
}
use of mage.target.Target in project mage by magefree.
the class MoltenPrimordialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
for (Target target : source.getTargets()) {
if (target instanceof TargetCreaturePermanent) {
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null) {
ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect1, source);
ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect2, source);
targetCreature.untap(game);
result = true;
}
}
}
return result;
}
use of mage.target.Target in project mage by magefree.
the class NecromanticSelectionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) {
permanent.destroy(source, game, false);
// Meren of the Clan Nel Toth bug #8515
game.checkStateAndTriggered();
if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
cards.add(permanent);
}
}
FilterCard filter = new FilterCreatureCard("creature card put into a graveyard with " + sourceObject.getLogName());
List<Predicate<MageObject>> cardIdPredicates = new ArrayList<>();
for (UUID cardId : cards) {
cardIdPredicates.add(new CardIdPredicate(cardId));
}
filter.add(Predicates.or(cardIdPredicates));
Target target = new TargetCardInGraveyard(filter);
target.setNotTarget(true);
if (controller.chooseTarget(Outcome.Benefit, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
effect.setText("It's a black Zombie in addition to its other colors and types");
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
use of mage.target.Target in project mage by magefree.
the class NecromancyChangeAbilityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantment = game.getPermanent(source.getSourceId());
Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source));
if (controller != null && enchantment != null && cardInGraveyard != null) {
controller.moveCards(cardInGraveyard, Zone.BATTLEFIELD, source, game);
Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId());
if (enchantedCreature != null) {
enchantedCreature.addAttachment(enchantment.getId(), source, game);
FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with " + enchantment.getIdName());
filter.add(new PermanentIdPredicate(cardInGraveyard.getId()));
Target target = new TargetCreaturePermanent(filter);
target.addTarget(enchantedCreature.getId(), source, game);
game.addEffect(new NecromancyChangeAbilityEffect(target), source);
}
return true;
}
return false;
}
use of mage.target.Target in project mage by magefree.
the class NecriteTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(defendingPlayerId));
Target target = new TargetPermanent(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
return false;
}
Aggregations