use of mage.abilities.common.BeginningOfUpkeepTriggeredAbility in project mage by magefree.
the class GlyphOfDelusionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (source.getTargets().get(1) != null) {
Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetPermanent != null) {
targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source.getControllerId(), source, game);
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepSourceEffect(), new SourceHasCounterCondition(CounterType.GLYPH)).setText("This creature doesn't untap during your untap step if it has a glyph counter on it"));
GainAbilityTargetEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect, source);
BeginningOfUpkeepTriggeredAbility ability2 = new BeginningOfUpkeepTriggeredAbility(new RemoveCounterSourceEffect(CounterType.GLYPH.createInstance()), TargetController.YOU, false);
GainAbilityTargetEffect effect2 = new GainAbilityTargetEffect(ability2, Duration.Custom);
effect2.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect2, source);
}
}
return false;
}
use of mage.abilities.common.BeginningOfUpkeepTriggeredAbility in project mage by magefree.
the class VesuvanDoppelgangerCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
permanent = game.getPermanentEntering(source.getSourceId());
}
final Permanent sourcePermanent = permanent;
if (controller != null && sourcePermanent != null) {
Target target = new TargetPermanent(new FilterCreaturePermanent("target creature (you copy from)"));
target.setRequired(true);
if (source instanceof SimpleStaticAbility) {
target = new TargetPermanent(new FilterCreaturePermanent("creature (you copy from)"));
target.setRequired(false);
target.setNotTarget(true);
}
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
controller.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
if (copyFromPermanent != null) {
game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new CopyApplier() {
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
blueprint.getColor().setColor(sourcePermanent.getColor(game));
blueprint.getAbilities().add(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new VesuvanDoppelgangerCopyEffect(), TargetController.YOU, true, false, rule2));
return true;
}
});
return true;
}
}
}
return false;
}
use of mage.abilities.common.BeginningOfUpkeepTriggeredAbility in project mage by magefree.
the class CryptoplasmEffect method apply.
@Override
public boolean apply(Game game, final Ability source) {
Permanent creatureToCopy = game.getPermanent(getTargetPointer().getFirst(game, source));
if (creatureToCopy != null) {
CopyApplier applier = new CopyApplier() {
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
blueprint.getAbilities().add(upkeepAbility);
return true;
}
};
game.copyPermanent(creatureToCopy, source.getSourceId(), source, applier);
}
return true;
}
use of mage.abilities.common.BeginningOfUpkeepTriggeredAbility in project mage by magefree.
the class ShiftingShadowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = source.getSourcePermanentIfItStillExists(game);
if (aura == null) {
return false;
}
Permanent permanent = game.getPermanent(aura.getAttachedTo());
if (permanent == null) {
return false;
}
permanent.addAbility(HasteAbility.getInstance(), source.getSourceId(), game);
permanent.addAbility(new BeginningOfUpkeepTriggeredAbility(new ShiftingShadowEffect(aura, game), TargetController.YOU, false), source.getSourceId(), game);
return true;
}
use of mage.abilities.common.BeginningOfUpkeepTriggeredAbility in project mage by magefree.
the class ObsidianFireheartGainAbilityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// If the owner/controller of this card leaves the game, the blaze counters
// presence on the targeted land will continue to deal 1 damage every upkeep
// to the lands controller.
Permanent targetLand = game.getPermanent(source.getFirstTarget());
if (targetLand != null && source.getTargets().get(0) != null) {
ContinuousEffect effect = new ObsidianFireheartGainAbilityEffect(new BeginningOfUpkeepTriggeredAbility(new DamageControllerEffect(1), TargetController.YOU, false), Duration.Custom, "");
// add a new independent ability that is not reliant on the source ability
SimpleStaticAbility gainAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, effect);
// set sourcecard of the independent ability to the targeted permanent of the source ability
gainAbility.setSourceId(targetLand.getId());
// the target of the source ability is added to the new independent ability
gainAbility.getTargets().add(source.getTargets().get(0));
// add the continuous effect to the game with the independent ability
game.addEffect(effect, gainAbility);
return true;
}
return false;
}
Aggregations