This commit is contained in:
Alex W. Jackson 2022-10-06 19:13:55 -04:00
parent 32d6525239
commit 4b469c8840

View file

@ -8,9 +8,6 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.Set;
import java.util.UUID;
/**
* @author LevelX2
*/
@ -33,23 +30,9 @@ public class EnchantedPlayerAttackedTriggeredAbility extends TriggeredAbilityImp
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
Player attacker = game.getPlayer(game.getCombat().getAttackingPlayerId());
if (controller == null || attacker == null || enchantment == null) {
return false;
}
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer == null) {
return false;
}
Set<UUID> opponentIds = game.getOpponents(controller.getId());
if (!opponentIds.contains(attacker.getId()) || !opponentIds.contains(enchantedPlayer.getId())) {
return false;
}
return game.getCombat().getPlayerDefenders(game, false).contains(enchantment.getAttachedTo());
return enchantment != null
&& game.getState().getPlayersInRange(getControllerId(), game).contains(game.getCombat().getAttackingPlayerId())
&& game.getCombat().getPlayerDefenders(game, false).contains(enchantment.getAttachedTo());
}
@Override