Merge branch 'fearsome' into 'master'

Fix some card scripts

Closes #2064

See merge request core-developers/forge!6047
This commit is contained in:
Michael Kamensky
2022-01-15 13:12:01 +00:00
10 changed files with 19 additions and 30 deletions

View File

@@ -93,15 +93,14 @@ public class AiAttackController {
this.defendingOpponent = choosePreferredDefenderPlayer(ai); this.defendingOpponent = choosePreferredDefenderPlayer(ai);
this.oppList = getOpponentCreatures(this.defendingOpponent); this.oppList = getOpponentCreatures(this.defendingOpponent);
this.myList = ai.getCreaturesInPlay(); this.myList = ai.getCreaturesInPlay();
this.nextTurn = nextTurn;
this.attackers = new ArrayList<>(); this.attackers = new ArrayList<>();
for (Card c : myList) { for (Card c : myList) {
if (nextTurn && CombatUtil.canAttackNextTurn(c, this.defendingOpponent) || if (canAttackWrapper(c, this.defendingOpponent)) {
CombatUtil.canAttack(c, this.defendingOpponent)) {
attackers.add(c); attackers.add(c);
} }
} }
this.blockers = getPossibleBlockers(oppList, this.attackers); this.blockers = getPossibleBlockers(oppList, this.attackers, this.nextTurn);
this.nextTurn = nextTurn;
} // overloaded constructor to evaluate attackers that should attack next turn } // overloaded constructor to evaluate attackers that should attack next turn
public AiAttackController(final Player ai, Card attacker) { public AiAttackController(final Player ai, Card attacker) {
@@ -109,12 +108,12 @@ public class AiAttackController {
this.defendingOpponent = choosePreferredDefenderPlayer(ai); this.defendingOpponent = choosePreferredDefenderPlayer(ai);
this.oppList = getOpponentCreatures(this.defendingOpponent); this.oppList = getOpponentCreatures(this.defendingOpponent);
this.myList = ai.getCreaturesInPlay(); this.myList = ai.getCreaturesInPlay();
this.nextTurn = false;
this.attackers = new ArrayList<>(); this.attackers = new ArrayList<>();
if (CombatUtil.canAttack(attacker, this.defendingOpponent)) { if (CombatUtil.canAttack(attacker, this.defendingOpponent)) {
attackers.add(attacker); attackers.add(attacker);
} }
this.blockers = getPossibleBlockers(oppList, this.attackers); this.blockers = getPossibleBlockers(oppList, this.attackers, this.nextTurn);
this.nextTurn = false;
} // overloaded constructor to evaluate single specified attacker } // overloaded constructor to evaluate single specified attacker
public static List<Card> getOpponentCreatures(final Player defender) { public static List<Card> getOpponentCreatures(final Player defender) {
@@ -273,28 +272,19 @@ public class AiAttackController {
return false; return false;
} }
public final static List<Card> getPossibleBlockers(final List<Card> blockers, final List<Card> attackers) { public final static List<Card> getPossibleBlockers(final List<Card> blockers, final List<Card> attackers, final boolean nextTurn) {
List<Card> possibleBlockers = new ArrayList<>(blockers); List<Card> possibleBlockers = new ArrayList<>(blockers);
possibleBlockers = CardLists.filter(possibleBlockers, new Predicate<Card>() { possibleBlockers = CardLists.filter(possibleBlockers, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return canBlockAnAttacker(c, attackers, false); return canBlockAnAttacker(c, attackers, nextTurn);
} }
}); });
return possibleBlockers; return possibleBlockers;
} }
public final static boolean canBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) { public final static boolean canBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) {
final List<Card> attackerList = new ArrayList<>(attackers); return getCardCanBlockAnAttacker(c, attackers, nextTurn) != null;
if (!c.isCreature()) {
return false;
}
for (final Card attacker : attackerList) {
if (CombatUtil.canBlock(attacker, c, nextTurn)) {
return true;
}
}
return false;
} }
public final static Card getCardCanBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) { public final static Card getCardCanBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) {
@@ -383,7 +373,7 @@ public class AiAttackController {
int blockersNeeded = opponentsAttackers.size(); int blockersNeeded = opponentsAttackers.size();
// don't hold back creatures that can't block any of the human creatures // don't hold back creatures that can't block any of the human creatures
final List<Card> list = getPossibleBlockers(attackers, opponentsAttackers); final List<Card> list = getPossibleBlockers(attackers, opponentsAttackers, nextTurn);
//Calculate the amount of creatures necessary //Calculate the amount of creatures necessary
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
@@ -1413,11 +1403,11 @@ public class AiAttackController {
*/ */
public String toProtectAttacker(SpellAbility sa) { public String toProtectAttacker(SpellAbility sa) {
//AiAttackController is created with the selected attacker as the only entry in "attackers" //AiAttackController is created with the selected attacker as the only entry in "attackers"
if (sa.getApi() != ApiType.Protection || oppList.isEmpty() || getPossibleBlockers(oppList, attackers).isEmpty()) { if (sa.getApi() != ApiType.Protection || oppList.isEmpty() || getPossibleBlockers(oppList, attackers, nextTurn).isEmpty()) {
return null; //not protection sa or attacker is already unblockable return null; //not protection sa or attacker is already unblockable
} }
final List<String> choices = ProtectEffect.getProtectionList(sa); final List<String> choices = ProtectEffect.getProtectionList(sa);
String color = ComputerUtilCard.getMostProminentColor(getPossibleBlockers(oppList, attackers)), artifact = null; String color = ComputerUtilCard.getMostProminentColor(getPossibleBlockers(oppList, attackers, nextTurn)), artifact = null;
if (choices.contains("artifacts")) { if (choices.contains("artifacts")) {
artifact = "artifacts"; //flag to indicate that protection from artifacts is available artifact = "artifacts"; //flag to indicate that protection from artifacts is available
} }

View File

@@ -199,7 +199,6 @@ public class ChooseGenericEffectAi extends SpellAbilityAi {
// Todo if hand is empty or mostly empty, skip main phase // Todo if hand is empty or mostly empty, skip main phase
// Todo if hand has gas, skip draw // Todo if hand has gas, skip draw
return Aggregates.random(spells); return Aggregates.random(spells);
} else if ("SinProdder".equals(logic)) { } else if ("SinProdder".equals(logic)) {
SpellAbility allow = null, deny = null; SpellAbility allow = null, deny = null;
for (final SpellAbility sp : spells) { for (final SpellAbility sp : spells) {

View File

@@ -3,7 +3,7 @@ ManaCost:6
Types:Artifact Creature Juggernaut Types:Artifact Creature Juggernaut
PT:3/5 PT:3/5
A:AB$ MustBlock | Cost$ 1 | ValidTgts$ Creature.Artifact | TgtPrompt$ Select target artifact creature to block this creature | SpellDescription$ Target artifact creature blocks CARDNAME this turn if able. A:AB$ MustBlock | Cost$ 1 | ValidTgts$ Creature.Artifact | TgtPrompt$ Select target artifact creature to block this creature | SpellDescription$ Target artifact creature blocks CARDNAME this turn if able.
A:AB$ Effect | Cost$ 1 | ValidTgts$ Creature.Artifact | TgtPrompt$ Select target artifact creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target artifact creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ 1 | ValidTgts$ Creature.Artifact | TgtPrompt$ Select target artifact creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target artifact creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:{1}: Target artifact creature blocks Auriok Siege Sled this turn if able.\n{1}: Target artifact creature can't block Auriok Siege Sled this turn. Oracle:{1}: Target artifact creature blocks Auriok Siege Sled this turn if able.\n{1}: Target artifact creature can't block Auriok Siege Sled this turn.

View File

@@ -3,7 +3,7 @@ ManaCost:2 R G
Types:Creature Viashino Berserker Types:Creature Viashino Berserker
PT:2/2 PT:2/2
K:Bloodthirst:1 K:Bloodthirst:1
A:AB$ Effect | Cost$ 2 R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ 2 R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
A:AB$ MustBlock | Cost$ 2 G | ValidTgts$ Creature | TgtPrompt$ Select target creature that must block this creature this turn | SpellDescription$ Target creature blocks CARDNAME this turn if able. A:AB$ MustBlock | Cost$ 2 G | ValidTgts$ Creature | TgtPrompt$ Select target creature that must block this creature this turn | SpellDescription$ Target creature blocks CARDNAME this turn if able.
AI:RemoveDeck:All AI:RemoveDeck:All

View File

@@ -2,7 +2,7 @@ Name:Duct Crawler
ManaCost:R ManaCost:R
Types:Creature Insect Types:Creature Insect
PT:1/1 PT:1/1
A:AB$ Effect | Cost$ 1 R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ 1 R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
AI:RemoveDeck:All AI:RemoveDeck:All
SVar:Picture:http://www.wizards.com/global/images/magic/general/duct_crawler.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/duct_crawler.jpg

View File

@@ -4,6 +4,6 @@ Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 2 R | ValidTgts$ Creature | AILogic$ Pump A:SP$ Attach | Cost$ 2 R | ValidTgts$ Creature | AILogic$ Pump
S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddPower$ 2 | AddToughness$ 2 | AddAbility$ CantBlockFT | Description$ Enchanted creature gets +2/+2 and has "{2}{R}: Target creature can't block this creature this turn." S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddPower$ 2 | AddToughness$ 2 | AddAbility$ CantBlockFT | Description$ Enchanted creature gets +2/+2 and has "{2}{R}: Target creature can't block this creature this turn."
SVar:CantBlockFT:AB$ Effect | Cost$ 2 R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. SVar:CantBlockFT:AB$ Effect | Cost$ 2 R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
Oracle:Enchant creature\nEnchanted creature gets +2/+2 and has "{2}{R}: Target creature can't block this creature this turn." Oracle:Enchant creature\nEnchanted creature gets +2/+2 and has "{2}{R}: Target creature can't block this creature this turn."

View File

@@ -2,7 +2,7 @@ Name:Kozilek's Pathfinder
ManaCost:6 ManaCost:6
Types:Creature Eldrazi Types:Creature Eldrazi
PT:5/5 PT:5/5
A:AB$ Effect | Cost$ C | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ C | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
DeckHints:Ability$Mana.Colorless DeckHints:Ability$Mana.Colorless
Oracle:{C}: Target creature can't block Kozilek's Pathfinder this turn. ({C} represents colorless mana.) Oracle:{C}: Target creature can't block Kozilek's Pathfinder this turn. ({C} represents colorless mana.)

View File

@@ -3,6 +3,6 @@ ManaCost:3 W
Types:Creature Griffin Types:Creature Griffin
PT:2/2 PT:2/2
K:Flying K:Flying
A:AB$ Effect | Cost$ R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
Oracle:Flying\n{R}: Target creature can't block Screeching Griffin this turn. Oracle:Flying\n{R}: Target creature can't block Screeching Griffin this turn.

View File

@@ -3,7 +3,7 @@ ManaCost:3 UR
Types:Creature Elemental Types:Creature Elemental
PT:6/6 PT:6/6
K:etbCounter:M1M1:4 K:etbCounter:M1M1:4
A:AB$ Effect | Cost$ UR | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ UR | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
T:Mode$ SpellCast | ValidCard$ Card.Red | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigRemoveCounter | TriggerDescription$ Whenever you cast a red spell, remove a -1/-1 counter from CARDNAME. T:Mode$ SpellCast | ValidCard$ Card.Red | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigRemoveCounter | TriggerDescription$ Whenever you cast a red spell, remove a -1/-1 counter from CARDNAME.
T:Mode$ SpellCast | ValidCard$ Card.Blue | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigRemoveCounter | TriggerDescription$ Whenever you cast a blue spell, remove a -1/-1 counter from CARDNAME. T:Mode$ SpellCast | ValidCard$ Card.Blue | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigRemoveCounter | TriggerDescription$ Whenever you cast a blue spell, remove a -1/-1 counter from CARDNAME.

View File

@@ -2,7 +2,7 @@ Name:Spin Engine
ManaCost:3 ManaCost:3
Types:Artifact Creature Construct Types:Artifact Creature Construct
PT:3/1 PT:3/1
A:AB$ Effect | Cost$ R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ TargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn. A:AB$ Effect | Cost$ R | ValidTgts$ Creature | TgtPrompt$ Select target creature that can't block this creature this turn | IsCurse$ True | RememberObjects$ ThisTargetedCard | ForgetOnMoved$ Battlefield | StaticAbilities$ KWPump | Duration$ UntilHostLeavesPlayOrEOT | StackDescription$ {c:Targeted} can't block CARDNAME this turn. | SpellDescription$ Target creature can't block CARDNAME this turn.
SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn. SVar:KWPump:Mode$ CantBlockBy | ValidAttacker$ Creature.EffectSource | ValidBlocker$ Creature.IsRemembered | Description$ {c:Remembered} can't block EFFECTSOURCE this turn.
DeckNeeds:Color$Red DeckNeeds:Color$Red
Oracle:{R}: Target creature can't block Spin Engine this turn. Oracle:{R}: Target creature can't block Spin Engine this turn.