Merge pull request #6537 from ThomasArb/fixStormwildCapridorPreventionText

[RFR] Fix issue where Stormwild Capridor don't output a prevention text
This commit is contained in:
LevelX2 2020-06-03 17:36:18 +02:00 committed by GitHub
commit 1e5d836a32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(preventionEffectData.getPreventedDamage()), source, game);
}
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(damage), source, game);
}
return retValue;
return preventionEffectData.isReplaced();
}
@Override