This commit is contained in:
Grath 2025-12-16 15:37:14 -06:00 committed by GitHub
commit e1d5937b43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 0 deletions

View file

@ -14,6 +14,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
/** /**
@ -105,6 +107,14 @@ class WarsTollAttackRestrictionEffect extends RestrictionEffect {
return true; return true;
} }
@Override
public boolean updateForcedAttackersAfter(int numberAttackers, Permanent attackingCreature, Ability source, Game game, Map<UUID, Set<UUID>> creaturesForcedToAttack) {
if (numberAttackers == 0) return true;
Set<UUID> opponents = game.getOpponents(attackingCreature.getControllerId());
creaturesForcedToAttack.put(attackingCreature.getId(), opponents);
return true;
}
@Override @Override
public WarsTollAttackRestrictionEffect copy() { public WarsTollAttackRestrictionEffect copy() {
return new WarsTollAttackRestrictionEffect(this); return new WarsTollAttackRestrictionEffect(this);

View file

@ -1,5 +1,7 @@
package mage.abilities.effects; package mage.abilities.effects;
import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -57,6 +59,10 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
return true; return true;
} }
public boolean updateForcedAttackersAfter(int numberAttackers, Permanent attackingCreature, Ability source, Game game, Map<UUID, Set<UUID>> creaturesForcedToAttack) {
return true;
}
/** /**
* @param attacker can be empty for general checks * @param attacker can be empty for general checks
* @param blocker * @param blocker

View file

@ -644,6 +644,16 @@ public class Combat implements Serializable, Copyable<Combat> {
} }
} }
} }
// Allow unconventional forced attacks (War's Toll) to record creatures as having been forced to attack.
for (UUID attackingCreatureId : this.getAttackers()) {
Permanent attackingCreature = game.getPermanent(attackingCreatureId);
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
effect.updateForcedAttackersAfter(numberAttackers, attackingCreature, ability, game, creaturesForcedToAttack);
}
}
}
} }
return true; return true;
} }