mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28: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.CardUtil;
|
||||||
import forge.game.card.token.TokenInfo;
|
import forge.game.card.token.TokenInfo;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
|
import forge.game.combat.CombatUtil;
|
||||||
import forge.game.cost.CostPart;
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.cost.CostPutCounter;
|
import forge.game.cost.CostPutCounter;
|
||||||
import forge.game.cost.CostRemoveCounter;
|
import forge.game.cost.CostRemoveCounter;
|
||||||
@@ -221,8 +222,14 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
&& game.getCombat() != null
|
&& game.getCombat() != null
|
||||||
&& !game.getCombat().getAttackers().isEmpty()
|
&& !game.getCombat().getAttackers().isEmpty()
|
||||||
&& alwaysOnOppAttack) {
|
&& alwaysOnOppAttack) {
|
||||||
|
for (Card attacker : game.getCombat().getAttackers()) {
|
||||||
|
if (CombatUtil.canBlock(attacker, actualToken)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// if the token can't block, then what's the point?
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return MyRandom.getRandom().nextFloat() <= chance;
|
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"));
|
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
|
// Apply static abilities
|
||||||
final Game game = ai.getGame();
|
final Game game = ai.getGame();
|
||||||
ComputerUtilCard.applyStaticContPT(game, result, null);
|
ComputerUtilCard.applyStaticContPT(game, result, null);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import forge.game.Game;
|
|||||||
import forge.game.GameEntity;
|
import forge.game.GameEntity;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.card.CardCollection;
|
||||||
import forge.game.card.CardCollectionView;
|
import forge.game.card.CardCollectionView;
|
||||||
import forge.game.card.CardPredicates;
|
import forge.game.card.CardPredicates;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
@@ -144,7 +145,13 @@ public class StaticAbilityCantAttackBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantBlockBy(final Card attacker, final Card blocker) {
|
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()) {
|
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||||
if (!stAb.checkConditions(CantBlockByMode)) {
|
if (!stAb.checkConditions(CantBlockByMode)) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user