mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Merge branch 'master' into 'master'
Fix AI for Karn, the Great Creator. See merge request core-developers/forge!1798
This commit is contained in:
@@ -10,6 +10,7 @@ import forge.game.ability.AbilityFactory;
|
|||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.card.*;
|
import forge.game.card.*;
|
||||||
|
import forge.game.cost.CostPutCounter;
|
||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -109,11 +110,11 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
if (ph.is(PhaseType.MAIN2) && !sa.hasParam("Permanent") && !sa.hasParam("UntilYourNextTurn")) {
|
if (ph.is(PhaseType.MAIN2) && !sa.hasParam("Permanent") && !sa.hasParam("UntilYourNextTurn")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Don't animate if the AI won't attack anyway
|
// Don't animate if the AI won't attack anyway or use as a potential blocker
|
||||||
Player opponent = ai.getWeakestOpponent();
|
Player opponent = ai.getWeakestOpponent();
|
||||||
if (ph.isPlayerTurn(ai) && ai.getLife() < 6 && opponent.getLife() > 6
|
if (ph.isPlayerTurn(ai) && ai.getLife() < 6 && opponent.getLife() > 6
|
||||||
&& Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)
|
&& Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)
|
||||||
&& !sa.hasParam("AILogic") && !sa.hasParam("Permanent")) {
|
&& !sa.hasParam("AILogic") && !sa.hasParam("Permanent") && !sa.hasParam("UntilYourNextTurn")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -245,6 +246,10 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
private boolean animateTgtAI(final SpellAbility sa) {
|
private boolean animateTgtAI(final SpellAbility sa) {
|
||||||
final Player ai = sa.getActivatingPlayer();
|
final Player ai = sa.getActivatingPlayer();
|
||||||
final PhaseHandler ph = ai.getGame().getPhaseHandler();
|
final PhaseHandler ph = ai.getGame().getPhaseHandler();
|
||||||
|
final boolean alwaysActivatePWAbility = sa.hasParam("Planeswalker")
|
||||||
|
&& sa.getPayCosts().hasSpecificCostType(CostPutCounter.class)
|
||||||
|
&& sa.getTargetRestrictions() != null
|
||||||
|
&& sa.getTargetRestrictions().getMinTargets(sa.getHostCard(), sa) == 0;
|
||||||
|
|
||||||
final CardType types = new CardType();
|
final CardType types = new CardType();
|
||||||
if (sa.hasParam("Types")) {
|
if (sa.hasParam("Types")) {
|
||||||
@@ -264,7 +269,7 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, false);
|
list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, false);
|
||||||
|
|
||||||
// list is empty, no possible targets
|
// list is empty, no possible targets
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty() && !alwaysActivatePWAbility) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +322,7 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// data is empty, no good targets
|
// data is empty, no good targets
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty() && !alwaysActivatePWAbility) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,10 +371,16 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
Integer power = null;
|
Integer power = null;
|
||||||
if (sa.hasParam("Power")) {
|
if (sa.hasParam("Power")) {
|
||||||
power = AbilityUtils.calculateAmount(source, sa.getParam("Power"), sa);
|
power = AbilityUtils.calculateAmount(source, sa.getParam("Power"), sa);
|
||||||
|
if (power == 0 && "PTByCMC".equals(sa.getParam("AILogic"))) {
|
||||||
|
power = card.getManaCost().getCMC();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Integer toughness = null;
|
Integer toughness = null;
|
||||||
if (sa.hasParam("Toughness")) {
|
if (sa.hasParam("Toughness")) {
|
||||||
toughness = AbilityUtils.calculateAmount(source, sa.getParam("Toughness"), sa);
|
toughness = AbilityUtils.calculateAmount(source, sa.getParam("Toughness"), sa);
|
||||||
|
if (toughness == 0 && "PTByCMC".equals(sa.getParam("AILogic"))) {
|
||||||
|
toughness = card.getManaCost().getCMC();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CardType types = new CardType();
|
final CardType types = new CardType();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Types:Legendary Planeswalker Karn
|
|||||||
Loyalty:5
|
Loyalty:5
|
||||||
S:Mode$ Continuous | Affected$ Artifact.OppCtrl | AddHiddenKeyword$ CARDNAME's activated abilities can't be activated. | Description$ Activated abilities of artifacts your opponents control can't be activated.
|
S:Mode$ Continuous | Affected$ Artifact.OppCtrl | AddHiddenKeyword$ CARDNAME's activated abilities can't be activated. | Description$ Activated abilities of artifacts your opponents control can't be activated.
|
||||||
SVar:NonStackingEffect:True
|
SVar:NonStackingEffect:True
|
||||||
A:AB$ Animate | Cost$ AddCounter<1/LOYALTY> | TargetMin$ 0 | TargetMax$ 1 | Planeswalker$ True | ValidTgts$ Artifact.nonCreature | TgtPrompt$ Select target noncreature artifact | Power$ X | Toughness$ X | Types$ Artifact,Creature | References$ X | UntilYourNextTurn$ True | SpellDescription$ Until your next turn, up to one target noncreature artifact becomes an artifact creature with power and toughness equal to its converted mana cost.
|
A:AB$ Animate | Cost$ AddCounter<1/LOYALTY> | TargetMin$ 0 | TargetMax$ 1 | Planeswalker$ True | ValidTgts$ Artifact.nonCreature | TgtPrompt$ Select target noncreature artifact | Power$ X | Toughness$ X | Types$ Artifact,Creature | References$ X | UntilYourNextTurn$ True | AILogic$ PTByCMC | SpellDescription$ Until your next turn, up to one target noncreature artifact becomes an artifact creature with power and toughness equal to its converted mana cost.
|
||||||
SVar:X:Targeted$CardManaCost
|
SVar:X:Targeted$CardManaCost
|
||||||
A:AB$ ChangeZone | Cost$ SubCounter<2/LOYALTY> | Planeswalker$ True | Origin$ Sideboard,Exile | Destination$ Hand | ChangeType$ Artifact.YouOwn | ChangeNum$ 1 | SpellDescription$ You may choose an artifact card you own from outside the game or in exile, reveal that card, and put it into your hand.
|
A:AB$ ChangeZone | Cost$ SubCounter<2/LOYALTY> | Planeswalker$ True | Origin$ Sideboard,Exile | Destination$ Hand | ChangeType$ Artifact.YouOwn | ChangeNum$ 1 | SpellDescription$ You may choose an artifact card you own from outside the game or in exile, reveal that card, and put it into your hand.
|
||||||
AI:RemoveDeck:Random
|
AI:RemoveDeck:Random
|
||||||
|
|||||||
Reference in New Issue
Block a user