Fixed Will Kenrith first ability duration and second ability not working

This commit is contained in:
Evan Kranzler 2018-05-28 14:08:13 -04:00
parent ea0a677e46
commit a21496ef5f
2 changed files with 16 additions and 8 deletions

View file

@ -32,7 +32,6 @@ import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.CanBeYourCommanderAbility; import mage.abilities.common.CanBeYourCommanderAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardTargetEffect; import mage.abilities.effects.common.DrawCardTargetEffect;
@ -51,7 +50,6 @@ import mage.constants.Outcome;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.command.emblems.WillKenrithEmblem; import mage.game.command.emblems.WillKenrithEmblem;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
@ -72,11 +70,11 @@ public class WillKenrith extends CardImpl {
// +2: Until your next turn, up to two target creatures each have base power and toughness 0/3 and lose all abilities. // +2: Until your next turn, up to two target creatures each have base power and toughness 0/3 and lose all abilities.
Ability ability = new LoyaltyAbility( Ability ability = new LoyaltyAbility(
new SetPowerToughnessTargetEffect(0, 3, Duration.EndOfTurn) new SetPowerToughnessTargetEffect(0, 3, Duration.UntilYourNextTurn)
.setText("until end of turn, up to two target creatures each have base power and toughness 0/3"), .setText("until your next turn, up to two target creatures each have base power and toughness 0/3"),
2 2
); );
ability.addEffect(new LoseAllAbilitiesTargetEffect(Duration.EndOfTurn) ability.addEffect(new LoseAllAbilitiesTargetEffect(Duration.UntilYourNextTurn)
.setText("and lose all abilities") .setText("and lose all abilities")
); );
ability.addTarget(new TargetCreaturePermanent(0, 2)); ability.addTarget(new TargetCreaturePermanent(0, 2));
@ -144,10 +142,9 @@ class WillKenrithCostReductionEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
FilterCard filter2 = filter.copy(); SpellsCostReductionAllEffect effect = new SpellsCostReductionAllEffect(filter, 2);
filter2.add(new ControllerIdPredicate(source.getFirstTarget()));
ContinuousEffect effect = new SpellsCostReductionAllEffect(filter2, 2);
effect.setDuration(Duration.UntilYourNextTurn); effect.setDuration(Duration.UntilYourNextTurn);
effect.setControllerId(source.getFirstTarget());
game.addEffect(effect, source); game.addEffect(effect, source);
return true; return true;
} }

View file

@ -29,6 +29,7 @@ package mage.abilities.effects.common.cost;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility; import mage.abilities.ActivatedAbility;
@ -54,6 +55,7 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
private int amount; private int amount;
private final boolean upTo; private final boolean upTo;
private boolean onlyControlled; private boolean onlyControlled;
private UUID controllerId;
public SpellsCostReductionAllEffect(int amount) { public SpellsCostReductionAllEffect(int amount) {
this(new FilterCard("Spells"), amount); this(new FilterCard("Spells"), amount);
@ -74,6 +76,7 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
this.upTo = upTo; this.upTo = upTo;
this.onlyControlled = onlyControlled; this.onlyControlled = onlyControlled;
this.staticText = filter.getMessage() + " cost " + (upTo ? "up to " : "") + '{' + amount + "} less to cast"; this.staticText = filter.getMessage() + " cost " + (upTo ? "up to " : "") + '{' + amount + "} less to cast";
this.controllerId = null;
} }
protected SpellsCostReductionAllEffect(final SpellsCostReductionAllEffect effect) { protected SpellsCostReductionAllEffect(final SpellsCostReductionAllEffect effect) {
@ -82,6 +85,7 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
this.amount = effect.amount; this.amount = effect.amount;
this.upTo = effect.upTo; this.upTo = effect.upTo;
this.onlyControlled = effect.onlyControlled; this.onlyControlled = effect.onlyControlled;
this.controllerId = effect.controllerId;
} }
@Override @Override
@ -145,6 +149,9 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
if (onlyControlled && !abilityToModify.getControllerId().equals(source.getControllerId())) { if (onlyControlled && !abilityToModify.getControllerId().equals(source.getControllerId())) {
return false; return false;
} }
if (controllerId != null && !abilityToModify.getControllerId().equals(controllerId)) {
return false;
}
if (abilityToModify instanceof SpellAbility) { if (abilityToModify instanceof SpellAbility) {
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
if (spell != null) { if (spell != null) {
@ -158,6 +165,10 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
return false; return false;
} }
public void setControllerId(UUID controllerId) {
this.controllerId = controllerId;
}
@Override @Override
public SpellsCostReductionAllEffect copy() { public SpellsCostReductionAllEffect copy() {
return new SpellsCostReductionAllEffect(this); return new SpellsCostReductionAllEffect(this);