use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class HallOfTheBanditLordWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.MANA_PAID) {
MageObject target = game.getObject(event.getTargetId());
if (event.getSourceId() != null && event.getSourceId().equals(this.getSourceId()) && target != null && target.isCreature(game) && event.getFlag()) {
if (target instanceof Spell) {
this.creatures.add(((Spell) target).getCard().getId());
}
}
}
if (event.getType() == GameEvent.EventType.COUNTERED) {
if (creatures.contains(event.getTargetId())) {
creatures.remove(event.getSourceId());
}
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
if (creatures.contains(event.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
// spell was e.g. exiled and goes again to stack, so previous cast has not resolved.
if (zEvent.getToZone() == Zone.STACK) {
creatures.remove(event.getSourceId());
}
}
}
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
if (creatures.contains(event.getSourceId())) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
game.addEffect(effect, source);
creatures.remove(event.getSourceId());
}
}
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class HuatliWarriorPoetDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (source.getTargets().isEmpty()) {
return true;
}
Target multiTarget = source.getTargets().get(0);
for (UUID target : multiTarget.getTargets()) {
Permanent permanent = game.getPermanent(target);
if (permanent != null && permanent.damage(multiTarget.getTargetAmount(target), source.getSourceId(), source, game, false, true) > 0) {
ContinuousEffect effect = new CantBlockTargetEffect(Duration.EndOfTurn);
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 InventTarget method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID targetId : targetPointer.getTargets(game, source)) {
ContinuousEffect effect = new SwitchPowerToughnessTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(targetId, game));
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class InsurrectionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
ContinuousEffect gainControl = new GainControlTargetEffect(Duration.EndOfTurn);
ContinuousEffect gainHaste = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
for (Permanent creature : game.getBattlefield().getAllActivePermanents(CardType.CREATURE, game)) {
creature.untap(game);
gainControl.setTargetPointer(new FixedTarget(creature.getId(), game));
gainHaste.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(gainControl, source);
game.addEffect(gainHaste, source);
result = true;
}
return result;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class KillerInstinctEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (player == null || sourceObject == null) {
return false;
}
Library library = player.getLibrary();
if (library == null || !library.hasCards()) {
return false;
}
Card card = library.getFromTop(game);
if (card == null) {
return false;
}
player.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (card.isCreature(game) && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
FixedTarget ft = new FixedTarget(permanent, game);
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(ft);
game.addEffect(effect, source);
Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice it at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(ft);
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
}
return true;
}
return false;
}
Aggregations