Fix the issue where Stormwild Capridor don't output a prevention text in chat
@@ -3,6 +3,7 @@ package mage.cards.s;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
+import mage.abilities.effects.PreventionEffectData;
import mage.abilities.effects.PreventionEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@@ -13,9 +14,7 @@ import mage.constants.SubType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.DamageCreatureEvent;
-import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
-import mage.game.events.PreventDamageEvent;
import mage.game.permanent.Permanent;
import java.util.UUID;
@@ -74,19 +73,14 @@ class StormwildCapridorEffect extends PreventionEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
- boolean retValue = false;
- GameEvent preventEvent = new PreventDamageEvent(source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
- int damage = event.getAmount();
- if (!game.replaceEvent(preventEvent)) {
- event.setAmount(0);
- game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
- retValue = true;
- }
+ PreventionEffectData preventionEffectData = preventDamageAction(event, source, game);
+ if (preventionEffectData.getPreventedDamage() > 0) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
- permanent.addCounters(CounterType.P1P1.createInstance(damage), source, game);
+ permanent.addCounters(CounterType.P1P1.createInstance(preventionEffectData.getPreventedDamage()), source, game);
+ }
}
- return retValue;
+ return preventionEffectData.isReplaced();
}
@Override
