mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Attempt to fix the AI transforming Azcanta if a copy of the transformed legendary land already exists on the battlefield.
This commit is contained in:
@@ -29,33 +29,10 @@ public class SetStateAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent transform into legendary creature if copy already exists
|
// Prevent transform into legendary creature if copy already exists
|
||||||
// Check first if Legend Rule does still apply
|
if (!isSafeToTransformIntoLegendary(aiPlayer, source)) {
|
||||||
if (!aiPlayer.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
|
|
||||||
if (!source.hasAlternateState()) {
|
|
||||||
System.err.println("Warning: SetState without ALTERNATE on " + source.getName() + ".");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the other side is legendary and if such Card already is in Play
|
|
||||||
final CardState other = source.getAlternateState();
|
|
||||||
|
|
||||||
if (other != null && other.getType().isLegendary() && aiPlayer.isCardInPlay(other.getName())) {
|
|
||||||
if (!other.getType().isCreature()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Card othercard = aiPlayer.getCardsIn(ZoneType.Battlefield, other.getName()).getFirst();
|
|
||||||
|
|
||||||
// for legendary KI counter creatures
|
|
||||||
if (othercard.getCounters(CounterType.KI) >= source.getCounters(CounterType.KI)) {
|
|
||||||
// if the other legendary is useless try to replace it
|
|
||||||
if (!ComputerUtilCard.isUselessCreature(aiPlayer, othercard)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if("Transform".equals(mode) || "Flip".equals(mode)) {
|
if("Transform".equals(mode) || "Flip".equals(mode)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -255,8 +232,44 @@ public class SetStateAi extends SpellAbilityAi {
|
|||||||
return valueCard <= valueTransformed;
|
return valueCard <= valueTransformed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSafeToTransformIntoLegendary(Player aiPlayer, Card source) {
|
||||||
|
// Prevent transform into legendary creature if copy already exists
|
||||||
|
// Check first if Legend Rule does still apply
|
||||||
|
if (!aiPlayer.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
|
||||||
|
if (!source.hasAlternateState()) {
|
||||||
|
System.err.println("Warning: SetState without ALTERNATE on " + source.getName() + ".");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the other side is legendary and if such Card already is in Play
|
||||||
|
final CardState other = source.getAlternateState();
|
||||||
|
|
||||||
|
if (other != null && other.getType().isLegendary() && aiPlayer.isCardInPlay(other.getName())) {
|
||||||
|
if (!other.getType().isCreature()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Card othercard = aiPlayer.getCardsIn(ZoneType.Battlefield, other.getName()).getFirst();
|
||||||
|
|
||||||
|
// for legendary KI counter creatures
|
||||||
|
if (othercard.getCounters(CounterType.KI) >= source.getCounters(CounterType.KI)) {
|
||||||
|
// if the other legendary is useless try to replace it
|
||||||
|
if (!ComputerUtilCard.isUselessCreature(aiPlayer, othercard)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||||
// TODO: improve the AI for when it may want to transform something that's optional to transform
|
// TODO: improve the AI for when it may want to transform something that's optional to transform
|
||||||
|
if (!isSafeToTransformIntoLegendary(player, sa.getHostCard())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user