mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
TokenAi: do not create Token that can't block in Response
This commit is contained in:
@@ -27,6 +27,7 @@ import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.token.TokenInfo;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPutCounter;
|
||||
import forge.game.cost.CostRemoveCounter;
|
||||
@@ -221,7 +222,13 @@ public class TokenAi extends SpellAbilityAi {
|
||||
&& game.getCombat() != null
|
||||
&& !game.getCombat().getAttackers().isEmpty()
|
||||
&& alwaysOnOppAttack) {
|
||||
return true;
|
||||
for (Card attacker : game.getCombat().getAttackers()) {
|
||||
if (CombatUtil.canBlock(attacker, actualToken)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// if the token can't block, then what's the point?
|
||||
return false;
|
||||
}
|
||||
|
||||
return MyRandom.getRandom().nextFloat() <= chance;
|
||||
@@ -364,6 +371,9 @@ public class TokenAi extends SpellAbilityAi {
|
||||
throw new RuntimeException("don't find Token for TokenScript: " + sa.getParam("TokenScript"));
|
||||
}
|
||||
|
||||
// set battlefield zone for LKI checks
|
||||
result.setLastKnownZone(ai.getZone(ZoneType.Battlefield));
|
||||
|
||||
// Apply static abilities
|
||||
final Game game = ai.getGame();
|
||||
ComputerUtilCard.applyStaticContPT(game, result, null);
|
||||
|
||||
@@ -26,6 +26,7 @@ import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.cost.Cost;
|
||||
@@ -144,7 +145,13 @@ public class StaticAbilityCantAttackBlock {
|
||||
}
|
||||
|
||||
public static boolean cantBlockBy(final Card attacker, final Card blocker) {
|
||||
for (final Card ca : attacker.getGame().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
CardCollection list = new CardCollection(attacker.getGame().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES));
|
||||
// add attacker and blocker in case of LKI
|
||||
list.add(attacker);
|
||||
if (blocker != null) {
|
||||
list.add(blocker);
|
||||
}
|
||||
for (final Card ca : list) {
|
||||
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||
if (!stAb.checkConditions(CantBlockByMode)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user