mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Do not tap just animated manlands to animate another manland.
This commit is contained in:
@@ -40,10 +40,17 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class AiCardMemory {
|
public class AiCardMemory {
|
||||||
|
|
||||||
private Set<Card> memMandatoryAttackers = new HashSet<Card>();
|
private final Set<Card> memMandatoryAttackers;
|
||||||
private Set<Card> memHeldManaSources = new HashSet<Card>();
|
private final Set<Card> memHeldManaSources;
|
||||||
private Set<Card> memAttachedThisTurn = new HashSet<Card>();
|
private final Set<Card> memAttachedThisTurn;
|
||||||
//private HashSet<Card> memRevealedCards = new HashSet<Card>();
|
private final Set<Card> memAnimatedThisTurn;
|
||||||
|
|
||||||
|
public AiCardMemory() {
|
||||||
|
this.memMandatoryAttackers = new HashSet<>();
|
||||||
|
this.memHeldManaSources = new HashSet<>();
|
||||||
|
this.memAttachedThisTurn = new HashSet<>();
|
||||||
|
this.memAnimatedThisTurn = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the memory set in which the card is remembered
|
* Defines the memory set in which the card is remembered
|
||||||
@@ -54,6 +61,7 @@ public class AiCardMemory {
|
|||||||
MANDATORY_ATTACKERS,
|
MANDATORY_ATTACKERS,
|
||||||
HELD_MANA_SOURCES,
|
HELD_MANA_SOURCES,
|
||||||
ATTACHED_THIS_TURN,
|
ATTACHED_THIS_TURN,
|
||||||
|
ANIMATED_THIS_TURN,
|
||||||
//REVEALED_CARDS // stub, not linked to AI code yet
|
//REVEALED_CARDS // stub, not linked to AI code yet
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +73,8 @@ public class AiCardMemory {
|
|||||||
return memHeldManaSources;
|
return memHeldManaSources;
|
||||||
case ATTACHED_THIS_TURN:
|
case ATTACHED_THIS_TURN:
|
||||||
return memAttachedThisTurn;
|
return memAttachedThisTurn;
|
||||||
|
case ANIMATED_THIS_TURN:
|
||||||
|
return memAnimatedThisTurn;
|
||||||
//case REVEALED_CARDS:
|
//case REVEALED_CARDS:
|
||||||
// return memRevealedCards;
|
// return memRevealedCards;
|
||||||
default:
|
default:
|
||||||
@@ -236,5 +246,6 @@ public class AiCardMemory {
|
|||||||
clearMemorySet(MemorySet.MANDATORY_ATTACKERS);
|
clearMemorySet(MemorySet.MANDATORY_ATTACKERS);
|
||||||
clearMemorySet(MemorySet.HELD_MANA_SOURCES);
|
clearMemorySet(MemorySet.HELD_MANA_SOURCES);
|
||||||
clearMemorySet(MemorySet.ATTACHED_THIS_TURN);
|
clearMemorySet(MemorySet.ATTACHED_THIS_TURN);
|
||||||
|
clearMemorySet(MemorySet.ANIMATED_THIS_TURN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
|
import forge.ai.ability.AnimateAi;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
@@ -201,12 +202,19 @@ public class ComputerUtilMana {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For abilities like Genju of the Cedars, make sure that we're not activating the aura ability by tapping the enchanted card for mana
|
if (sa.getHostCard() != null && sa.getApi() == ApiType.Animate) {
|
||||||
if (sa.getHostCard() != null && sa.getApi() == ApiType.Animate && sa.getHostCard().isAura()
|
// For abilities like Genju of the Cedars, make sure that we're not activating the aura ability by tapping the enchanted card for mana
|
||||||
&& "Enchanted".equals(sa.getParam("Defined"))
|
if (sa.getHostCard().isAura() && "Enchanted".equals(sa.getParam("Defined"))
|
||||||
&& ma.getHostCard() == sa.getHostCard().getEnchantingCard()
|
&& ma.getHostCard() == sa.getHostCard().getEnchantingCard()
|
||||||
&& ma.getPayCosts().hasTapCost()) {
|
&& ma.getPayCosts().hasTapCost()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a manland was previously animated this turn, do not tap it to animate another manland
|
||||||
|
if (sa.getHostCard().isLand() && ma.getHostCard().isLand()
|
||||||
|
&& AnimateAi.isAnimatedThisTurn(ai, ma.getHostCard())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String typeRes = cost.getSourceRestriction();
|
final String typeRes = cost.getSourceRestriction();
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import java.util.Map;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import forge.ai.AiCardMemory;
|
||||||
|
|
||||||
import forge.ai.ComputerUtilCard;
|
import forge.ai.ComputerUtilCard;
|
||||||
import forge.ai.ComputerUtilCost;
|
import forge.ai.ComputerUtilCost;
|
||||||
|
import forge.ai.PlayerControllerAi;
|
||||||
import forge.ai.SpellAbilityAi;
|
import forge.ai.SpellAbilityAi;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -182,6 +184,7 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
&& !ComputerUtilCard.doesSpecifiedCreatureBlock(aiPlayer, animatedCopy)) {
|
&& !ComputerUtilCard.doesSpecifiedCreatureBlock(aiPlayer, animatedCopy)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
this.rememberAnimatedThisTurn(aiPlayer, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bFlag; // All of the defined stuff is animated, not very useful
|
return bFlag; // All of the defined stuff is animated, not very useful
|
||||||
@@ -221,7 +224,9 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sa.getTargets().add(ComputerUtilCard.getWorstAI(list));
|
Card toAnimate = ComputerUtilCard.getWorstAI(list);
|
||||||
|
this.rememberAnimatedThisTurn(aiPlayer, toAnimate);
|
||||||
|
sa.getTargets().add(toAnimate);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -323,6 +328,7 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
// select the worst of the best
|
// select the worst of the best
|
||||||
final Card worst = ComputerUtilCard.getWorstAI(maxList);
|
final Card worst = ComputerUtilCard.getWorstAI(maxList);
|
||||||
|
this.rememberAnimatedThisTurn(ai, worst);
|
||||||
sa.getTargets().add(worst);
|
sa.getTargets().add(worst);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -602,4 +608,14 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
ComputerUtilCard.applyStaticContPT(game, card, null);
|
ComputerUtilCard.applyStaticContPT(game, card, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rememberAnimatedThisTurn(Player ai, Card c) {
|
||||||
|
AiCardMemory mem = ((PlayerControllerAi)ai.getController()).getAi().getCardMemory();
|
||||||
|
mem.rememberCard(c, AiCardMemory.MemorySet.ANIMATED_THIS_TURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAnimatedThisTurn(Player ai, Card c) {
|
||||||
|
AiCardMemory mem = ((PlayerControllerAi)ai.getController()).getAi().getCardMemory();
|
||||||
|
return mem.isRememberedCard(c, AiCardMemory.MemorySet.ANIMATED_THIS_TURN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user