use of mage.abilities.effects.common.AttachEffect in project mage by magefree.
the class GaleaKindlerOfHopeEffect method makeAbility.
private static Ability makeAbility() {
Ability ability = new EntersBattlefieldTriggeredAbility(new AttachEffect(Outcome.BoostCreature, "attach it to target creature you control"), false).setTriggerPhrase("When this Equipment enters the battlefield, ");
ability.addTarget(new TargetControlledCreaturePermanent());
return ability;
}
use of mage.abilities.effects.common.AttachEffect in project mage by magefree.
the class OldGrowthTrollContinuousEffect method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
if (game.getState().getZoneChangeCounter(source.getSourceId()) > zoneChangeCounter) {
discard();
return false;
}
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (sourceObject == null) {
sourceObject = game.getPermanentEntering(source.getSourceId());
}
if (sourceObject == null) {
return false;
}
Permanent troll = sourceObject;
switch(layer) {
case TypeChangingEffects_4:
troll.removeAllCardTypes(game);
troll.addCardType(game, CardType.ENCHANTMENT);
troll.removeAllSubTypes(game);
troll.addSubType(game, SubType.AURA);
break;
case AbilityAddingRemovingEffects_6:
// Spell Ability can be null with clone effects (ex. Moritte)
if (troll.getSpellAbility() == null) {
troll.addAbility(new SpellAbility(null, null), source.getSourceId(), game);
}
troll.getSpellAbility().getTargets().clear();
troll.getSpellAbility().getEffects().clear();
TargetPermanent auraTarget = new TargetPermanent(filter);
troll.getSpellAbility().addTarget(auraTarget);
troll.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
troll.addAbility(new EnchantAbility(auraTarget.getTargetName()), source.getSourceId(), game);
// add the activated ability
troll.addAbility(makeAbility(), source.getSourceId(), game);
}
return true;
}
use of mage.abilities.effects.common.AttachEffect in project mage by magefree.
the class ScytheOfTheWretchedReanimateEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Effect effect = new AttachEffect(Outcome.AddAbility);
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.apply(game, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.AttachEffect in project mage by magefree.
the class SteamVinesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent steamVines = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (steamVines != null) {
Permanent enchantedLand = game.getPermanentOrLKIBattlefield(steamVines.getAttachedTo());
Player controller = game.getPlayer(source.getControllerId());
if (enchantedLand != null && controller != null) {
Player landsController = game.getPlayer(enchantedLand.getControllerId());
if (game.getState().getZone(enchantedLand.getId()) == Zone.BATTLEFIELD) {
// if 2 or more Steam Vines were on a land
enchantedLand.destroy(source, game, false);
if (landsController != null) {
landsController.damage(1, source.getSourceId(), source, game);
}
}
if (!game.getBattlefield().getAllActivePermanents(CardType.LAND, game).isEmpty()) {
// lands are available on the battlefield
Target target = new TargetLandPermanent();
// not a target, it is chosen
target.setNotTarget(true);
Card steamVinesCard = game.getCard(source.getSourceId());
if (steamVinesCard != null && landsController != null) {
if (landsController.choose(Outcome.DestroyPermanent, target, source.getId(), game)) {
if (target.getFirstTarget() != null) {
Permanent landChosen = game.getPermanent(target.getFirstTarget());
if (landChosen != null) {
for (Target targetTest : steamVinesCard.getSpellAbility().getTargets()) {
Filter filterTest = targetTest.getFilter();
if (filterTest.match(landChosen, game)) {
if (game.getBattlefield().containsPermanent(landChosen.getId())) {
// verify that it is still on the battlefield
game.informPlayers(landsController.getLogName() + " attaches " + steamVines.getLogName() + " to " + landChosen.getLogName());
Effect effect = new AttachEffect(Outcome.Neutral);
effect.setTargetPointer(new FixedTarget(landChosen, game));
return effect.apply(game, source);
}
}
}
}
}
}
}
}
}
}
return false;
}
use of mage.abilities.effects.common.AttachEffect in project mage by magefree.
the class LicidSpecialActionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent licid = (Permanent) source.getSourceObjectIfItStillExists(game);
if (licid != null) {
UUID messageId = UUID.randomUUID();
LicidContinuousEffect effect = new LicidContinuousEffect(messageId);
effect.setTargetPointer(new FixedTarget(licid, game));
game.addEffect(effect, source);
new AttachEffect(Outcome.Neutral).apply(game, source);
SpecialAction specialAction = new LicidSpecialAction(this.specialActionCost, messageId, licid.getIdName());
new CreateSpecialActionEffect(specialAction).apply(game, source);
return true;
}
return false;
}
Aggregations