use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class AureliasFuryDamagedByWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
AureliasFuryDamagedByWatcher watcher = game.getState().getWatcher(AureliasFuryDamagedByWatcher.class, source.getSourceId());
if (watcher != null) {
for (UUID creatureId : watcher.getDamagedCreatures()) {
Permanent permanent = game.getPermanent(creatureId);
if (permanent != null) {
permanent.tap(source, game);
}
}
for (UUID playerId : watcher.getDamagedPlayers()) {
ContinuousEffect effect = new AureliasFuryCantCastEffect();
effect.setTargetPointer(new FixedTarget(playerId));
game.addEffect(effect, source);
}
watcher.reset();
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class ProtectionChosenColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (!controller.choose(Outcome.Benefit, colorChoice, game)) {
return false;
}
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
if (protectColor != null) {
ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
game.addEffect(effect, source);
ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) {
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
return true;
}
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class BondOfPassionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
permanent.untap(game);
effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
Permanent permanent2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent2 != null) {
permanent2.damage(2, source.getSourceId(), source, game);
} else {
Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (player != null) {
player.damage(2, source.getSourceId(), source, game);
}
}
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class BondOfRevivalEffect 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;
}
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class CheeringFanaticEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
new ChooseACardNameEffect(TypeOfName.ALL).apply(game, source);
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (cardName == null) {
return false;
}
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(cardName));
ContinuousEffect effect = new SpellsCostReductionAllEffect(filter, 1);
effect.setDuration(Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
Aggregations