* Delaying Shield - Fixed that always only 1 counter was removed but all had to be paid.

This commit is contained in:
LevelX2 2015-07-02 21:24:18 +02:00
parent 27e62a07a3
commit 7375ba2819

View file

@ -62,10 +62,9 @@ public class DelayingShield extends CardImpl {
super(ownerId, 17, "Delaying Shield", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
this.expansionSetCode = "ODY";
// If damage would be dealt to you, put that many delay counters on Delaying Shield instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DelayingShieldReplacementEffect()));
// At the beginning of your upkeep, remove all delay counters from Delaying Shield. For each delay counter removed this way, you lose 1 life unless you pay {1}{W}.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DelayingShieldUpkeepEffect(), TargetController.YOU, false));
}
@ -81,7 +80,7 @@ public class DelayingShield extends CardImpl {
}
class DelayingShieldReplacementEffect extends ReplacementEffectImpl {
DelayingShieldReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.PreventDamage);
staticText = "If damage would be dealt to you, put that many delay counters on {this} instead";
@ -94,7 +93,7 @@ class DelayingShieldReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
new AddCountersSourceEffect(CounterType.DELAY.createInstance(damageEvent.getAmount())).apply(game, source);
new AddCountersSourceEffect(CounterType.DELAY.createInstance(damageEvent.getAmount()), true).apply(game, source);
return true;
}
@ -102,7 +101,7 @@ class DelayingShieldReplacementEffect extends ReplacementEffectImpl {
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGE_PLAYER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId().equals(source.getControllerId());
@ -115,30 +114,30 @@ class DelayingShieldReplacementEffect extends ReplacementEffectImpl {
}
class DelayingShieldUpkeepEffect extends OneShotEffect {
DelayingShieldUpkeepEffect() {
super(Outcome.Benefit);
this.staticText = "remove all delay counters from {this}. For each delay counter removed this way, you lose 1 life unless you pay {1}{W}";
}
DelayingShieldUpkeepEffect(final DelayingShieldUpkeepEffect effect) {
super(effect);
}
@Override
public DelayingShieldUpkeepEffect copy() {
return new DelayingShieldUpkeepEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
if (controller != null && permanent != null) {
int numCounters = permanent.getCounters().getCount(CounterType.DELAY);
permanent.removeCounters(CounterType.DELAY.createInstance(), game);
permanent.removeCounters(CounterType.DELAY.createInstance(numCounters), game);
for (int i = numCounters; i > 0; i--) {
if (player.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {
if (controller.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {
Cost cost = new ManaCostsImpl<>("{1}{W}");
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
continue;