mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
* Afflict - Fixed that life loss of triggered afflict ability was not applied if creature with afflict was removed from battlefield before life loss effect resolved (fixes #3694).
This commit is contained in:
parent
52cc8b46b1
commit
d0e610e83b
3 changed files with 58 additions and 10 deletions
|
|
@ -73,7 +73,7 @@ public class LoseLifeDefendingPlayerEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player defender = null;
|
||||
Player defender;
|
||||
if (attackerIsSource) {
|
||||
defender = game.getPlayer(game.getCombat().getDefendingPlayerId(source.getSourceId(), game));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.common.BecomesBlockedTriggeredAbility;
|
||||
import mage.abilities.effects.common.LoseLifeDefendingPlayerEffect;
|
||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
public class AfflictAbility extends BecomesBlockedTriggeredAbility {
|
||||
|
||||
private int lifeLoss;
|
||||
private final int lifeLoss;
|
||||
|
||||
@Override
|
||||
public AfflictAbility copy() {
|
||||
|
|
@ -13,11 +17,23 @@ public class AfflictAbility extends BecomesBlockedTriggeredAbility {
|
|||
}
|
||||
|
||||
public AfflictAbility(int amount) {
|
||||
super(new LoseLifeDefendingPlayerEffect(amount, true)
|
||||
super(new LoseLifeTargetEffect(amount)
|
||||
.setText("Afflict " + amount + " <i>(Whenever this creature becomes blocked, defending player loses " + amount + " life.)</i>"), false);
|
||||
lifeLoss = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
UUID defenderId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
|
||||
if (defenderId != null) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(defenderId));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public AfflictAbility(final AfflictAbility afflictAbility) {
|
||||
super(afflictAbility);
|
||||
lifeLoss = afflictAbility.lifeLoss;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue