mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Made Mizzium Meddler use AI SpellMagnet and thus made it AI-playable.
This commit is contained in:
@@ -28,37 +28,7 @@ public class ChangeTargetsAi extends SpellAbilityAi {
|
||||
|
||||
if (sa.hasParam("AILogic")) {
|
||||
if ("SpellMagnet".equals(sa.getParam("AILogic"))) {
|
||||
// Cards like Spellskite that retarget spells to itself
|
||||
|
||||
if (topSa == null) {
|
||||
// nothing on stack, so nothing to target
|
||||
return false;
|
||||
}
|
||||
if (!topSa.usesTargeting() || topSa.getTargets().getTargetCards().contains(sa.getHostCard())) {
|
||||
// if this does not target at all or already targets host, no need to redirect it again
|
||||
return false;
|
||||
}
|
||||
if (topSa.getHostCard() != null && !topSa.getHostCard().getController().isOpponentOf(aiPlayer)) {
|
||||
// make sure not to redirect our own abilities
|
||||
return false;
|
||||
}
|
||||
if (!topSa.canTarget(sa.getHostCard())) {
|
||||
// don't try targeting it if we can't legally target Spellskite with it in the first place
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("Spellskite".equals(sa.getHostCard().getName())) {
|
||||
int potentialDmg = ComputerUtil.predictDamageFromSpell(topSa, aiPlayer);
|
||||
boolean canPayBlue = ComputerUtilMana.canPayManaCost(new ManaCostBeingPaid(new ManaCost(new ManaCostParser("U"))), sa, aiPlayer);
|
||||
if (potentialDmg != -1 && potentialDmg <= 2 && !canPayBlue && topSa.getTargets().getTargets().contains(aiPlayer)) {
|
||||
// do not pay Phyrexian mana if the spell is a damaging one but it deals less damage or the same damage as we'll pay life
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(topSa);
|
||||
return true;
|
||||
return doSpellMagnet(sa, topSa, aiPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +38,54 @@ public class ChangeTargetsAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final Game game = sa.getHostCard().getGame();
|
||||
final SpellAbility topSa = game.getStack().isEmpty() ? null : ComputerUtilAbility.getTopSpellAbilityOnStack(game, sa);
|
||||
|
||||
if (sa.hasParam("AILogic")) {
|
||||
if ("SpellMagnet".equals(sa.getParam("AILogic"))) {
|
||||
return doSpellMagnet(sa, topSa, aiPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean doSpellMagnet(SpellAbility sa, SpellAbility topSa, Player aiPlayer) {
|
||||
// For cards like Spellskite that retarget spells to itself
|
||||
if (topSa == null) {
|
||||
// nothing on stack, so nothing to target
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() != 0) {
|
||||
// something was already chosen before (e.g. in response to a trigger - Mizzium Meddler), so just proceed
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!topSa.usesTargeting() || topSa.getTargets().getTargetCards().contains(sa.getHostCard())) {
|
||||
// if this does not target at all or already targets host, no need to redirect it again
|
||||
return false;
|
||||
}
|
||||
if (topSa.getHostCard() != null && !topSa.getHostCard().getController().isOpponentOf(aiPlayer)) {
|
||||
// make sure not to redirect our own abilities
|
||||
return false;
|
||||
}
|
||||
if (!topSa.canTarget(sa.getHostCard())) {
|
||||
// don't try targeting it if we can't legally target the host card with it in the first place
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("Spellskite".equals(sa.getHostCard().getName())) {
|
||||
int potentialDmg = ComputerUtil.predictDamageFromSpell(topSa, aiPlayer);
|
||||
boolean canPayBlue = ComputerUtilMana.canPayManaCost(new ManaCostBeingPaid(new ManaCost(new ManaCostParser("U"))), sa, aiPlayer);
|
||||
if (potentialDmg != -1 && potentialDmg <= 2 && !canPayBlue && topSa.getTargets().getTargets().contains(aiPlayer)) {
|
||||
// do not pay Phyrexian mana if the spell is a damaging one but it deals less damage or the same damage as we'll pay life
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(topSa);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ Types:Creature Vedalken Wizard
|
||||
PT:1/4
|
||||
K:Flash
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigChange | OptionalDecider$ You | TriggerDescription$ When CARDNAME enters the battlefield, you may change a target of target spell or ability to CARDNAME.
|
||||
SVar:TrigChange:AB$ ChangeTargets | Cost$ 0 | TargetType$ Spell,Activated,Triggered | ValidTgts$ Card | DefinedMagnet$ Self | ChangeSingleTarget$ True
|
||||
SVar:RemAIDeck:True
|
||||
SVar:TrigChange:AB$ ChangeTargets | Cost$ 0 | TargetType$ Spell,Activated,Triggered | ValidTgts$ Card | DefinedMagnet$ Self | ChangeSingleTarget$ True | AILogic$ SpellMagnet
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/mizzium_meddler.jpg
|
||||
Oracle:Flash (You may cast this spell any time you could cast an instant.)\nWhen Mizzium Meddler enters the battlefield, you may change a target of target spell or ability to Mizzium Meddler.
|
||||
Reference in New Issue
Block a user