mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
SetStateAi: use more generic way to check if a Card should be transformed or not. Also does check if Legendary Rule does still apply for that.
This commit is contained in:
@@ -1158,7 +1158,7 @@ public class AiController {
|
|||||||
|
|
||||||
// check on legendary
|
// check on legendary
|
||||||
if (card.getType().isLegendary() && !game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
|
if (card.getType().isLegendary() && !game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
|
||||||
if (Iterables.any(player.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(card.getName()))) {
|
if (player.isCardInPlay(card.getName())) {
|
||||||
return AiPlayDecision.WouldDestroyLegend;
|
return AiPlayDecision.WouldDestroyLegend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package forge.ai.ability;
|
|||||||
|
|
||||||
|
|
||||||
import forge.ai.SpellAbilityAi;
|
import forge.ai.SpellAbilityAi;
|
||||||
|
import forge.game.GlobalRuleChange;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardCollection;
|
import forge.game.card.CardState;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
@@ -12,12 +13,14 @@ public class SetStateAi extends SpellAbilityAi {
|
|||||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||||
// Prevent transform into legendary creature if copy already exists
|
// Prevent transform into legendary creature if copy already exists
|
||||||
final Card source = sa.getHostCard();
|
final Card source = sa.getHostCard();
|
||||||
if ("Westvale Abbey".equals(source.getName())) {
|
|
||||||
CardCollection list = aiPlayer.getCreaturesInPlay();
|
// Check first if Legend Rule does still apply
|
||||||
for (Card c : list) {
|
if (!aiPlayer.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
|
||||||
if (c.getName().equals("Ormendahl, Profane Prince")) {
|
|
||||||
return false;
|
// check if the other side is legendary and if such Card already is in Play
|
||||||
}
|
final CardState other = source.getAlternateState();
|
||||||
|
if (other.getType().isLegendary() && aiPlayer.isCardInPlay(other.getName())) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user