mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
Fixed Issue#29: It is possible to cancel creature attack even if it must attack
This commit is contained in:
parent
33f9bfc101
commit
1eb230e236
2 changed files with 11 additions and 2 deletions
|
@ -36,6 +36,7 @@ import mage.abilities.*;
|
|||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.*;
|
||||
import mage.abilities.effects.ReplacementEffect;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
|
@ -527,14 +528,22 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
selectDefender(game.getCombat().getDefenders(), attacker.getId(), game);
|
||||
}
|
||||
else if (filterAttack.match(attacker, null, playerId, game) && game.getStack().isEmpty()) {
|
||||
// if (game.getState().getTriggered().isEmpty() && game.getState().getDelayed().isEmpty())
|
||||
game.getCombat().removeAttacker(attacker.getId(), game);
|
||||
removeAttackerIfPossible(game, attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAttackerIfPossible(Game game, Permanent attacker) {
|
||||
for (RequirementEffect effect : game.getContinuousEffects().getApplicableRequirementEffects(attacker, game)) {
|
||||
if (effect.mustAttack(game)) {
|
||||
return; // we can't cancel attacking
|
||||
}
|
||||
}
|
||||
game.getCombat().removeAttacker(attacker.getId(), game);
|
||||
}
|
||||
|
||||
protected boolean selectDefender(Set<UUID> defenders, UUID attackerId, Game game) {
|
||||
if (defenders.size() == 1) {
|
||||
declareAttacker(attackerId, defenders.iterator().next(), game);
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue