mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
- Added AI support to AF ExchangeControl.
This commit is contained in:
@@ -4,7 +4,6 @@ Types:Creature Minion
|
|||||||
Text:no text
|
Text:no text
|
||||||
PT:2/2
|
PT:2/2
|
||||||
A:AB$ ExchangeControl | Cost$ 2 U U | Defined$ Self | ValidTgts$ Creature | TgtPrompt$ Select target creature | SpellDescription$ Exchange control of CARDNAME and target creature. (This effect lasts indefinitely.)
|
A:AB$ ExchangeControl | Cost$ 2 U U | Defined$ Self | ValidTgts$ Creature | TgtPrompt$ Select target creature | SpellDescription$ Exchange control of CARDNAME and target creature. (This effect lasts indefinitely.)
|
||||||
SVar:RemAIDeck:True
|
|
||||||
SVar:Rarity:Rare
|
SVar:Rarity:Rare
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/phyrexian_infiltrator.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/phyrexian_infiltrator.jpg
|
||||||
SetInfo:INV|Rare|http://magiccards.info/scans/en/in/116.jpg
|
SetInfo:INV|Rare|http://magiccards.info/scans/en/in/116.jpg
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ ManaCost:4 U
|
|||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
Text:no text
|
Text:no text
|
||||||
A:SP$ ExchangeControl | Cost$ 4 U | ValidTgts$ Creature | TgtPrompt$ Select target creature | TargetMin$ 2 | TargetMax$ 2 | SpellDescription$ Exchange control of two target creatures.
|
A:SP$ ExchangeControl | Cost$ 4 U | ValidTgts$ Creature | TgtPrompt$ Select target creature | TargetMin$ 2 | TargetMax$ 2 | SpellDescription$ Exchange control of two target creatures.
|
||||||
SVar:RemAIDeck:True
|
|
||||||
SVar:Rarity:Uncommon
|
SVar:Rarity:Uncommon
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/switcheroo.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/switcheroo.jpg
|
||||||
SetInfo:M13|Uncommon|http://magiccards.info/scans/en/m13/71.jpg
|
SetInfo:M13|Uncommon|http://magiccards.info/scans/en/m13/71.jpg
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import forge.game.phase.PhaseType;
|
|||||||
import forge.game.player.ComputerUtil;
|
import forge.game.player.ComputerUtil;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
//AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx
|
//AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx
|
||||||
|
|
||||||
@@ -721,17 +722,11 @@ public class AbilityFactoryGainControl {
|
|||||||
this.af.getAbTgt()) {
|
this.af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 8004957182752960518L;
|
private static final long serialVersionUID = 8004957182752960518L;
|
||||||
private final AbilityFactory af = AbilityFactoryGainControl.this.af;
|
private final AbilityFactory af = AbilityFactoryGainControl.this.af;
|
||||||
private final HashMap<String, String> params = this.af.getMapParams();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
if (this.params.containsKey("SpellDescription")) {
|
|
||||||
return af.getHostCard().getName() + " - "
|
|
||||||
+ this.params.get("SpellDescription");
|
|
||||||
} else {
|
|
||||||
return exchangeControlStackDescription(this.af, this);
|
return exchangeControlStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
@@ -841,9 +836,39 @@ public class AbilityFactoryGainControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean exchangeControlCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private boolean exchangeControlCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
Card object1 = null;
|
||||||
|
Card object2 = null;
|
||||||
|
final Target tgt = sa.getTarget();
|
||||||
|
tgt.resetTargets();
|
||||||
|
|
||||||
//final Target tgt = sa.getTarget();
|
CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield);
|
||||||
|
list = list.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), this.hostCard);
|
||||||
|
// AI won't try to grab cards that are filtered out of AI decks on
|
||||||
|
// purpose
|
||||||
|
list = list.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean addCard(final Card c) {
|
||||||
|
final Map<String, String> vars = c.getSVars();
|
||||||
|
return !vars.containsKey("RemAIDeck") && c.canBeTargetedBy(sa);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
object1 = CardFactoryUtil.getBestAI(list);
|
||||||
|
if (params.containsKey("Defined")) {
|
||||||
|
object2 = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa).get(0);
|
||||||
|
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) {
|
||||||
|
CardList list2 = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
||||||
|
list2 = list2.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), this.hostCard);
|
||||||
|
object2 = CardFactoryUtil.getWorstAI(list2);
|
||||||
|
tgt.addTarget(object2);
|
||||||
|
}
|
||||||
|
if (object1 == null || object2 == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (CardFactoryUtil.evaluateCreature(object1) > CardFactoryUtil.evaluateCreature(object2) + 40) {
|
||||||
|
tgt.addTarget(object1);
|
||||||
|
return MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user