mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
moved params and api into SpellAbility, made param getters NPE-proof, cut reference to AbilityFactory
This commit is contained in:
@@ -926,7 +926,7 @@ public final class CardUtil {
|
||||
* a {@link java.util.ArrayList} object.
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public static List<String> getReflectableManaColors(final SpellAbility abMana, final Map<String, String> params,
|
||||
public static List<String> getReflectableManaColors(final SpellAbility abMana, final SpellAbility sa,
|
||||
List<String> colors, final List<Card> parents) {
|
||||
// Here's the problem with reflectable Mana. If more than one is out,
|
||||
// they need to Reflect each other,
|
||||
@@ -938,12 +938,12 @@ public final class CardUtil {
|
||||
parents.add(card);
|
||||
}
|
||||
|
||||
final String colorOrType = params.get("ColorOrType"); // currently Color
|
||||
final String colorOrType = sa.getParam("ColorOrType"); // currently Color
|
||||
// or
|
||||
// Type, Type is colors
|
||||
// + colorless
|
||||
final String validCard = params.get("Valid");
|
||||
final String reflectProperty = params.get("ReflectProperty"); // Produce
|
||||
final String validCard = sa.getParam("Valid");
|
||||
final String reflectProperty = sa.getParam("ReflectProperty"); // Produce
|
||||
// (Reflecting Pool) or Is (Meteor Crater)
|
||||
|
||||
int maxChoices = 5; // Color is the default colorOrType
|
||||
@@ -1021,7 +1021,7 @@ public final class CardUtil {
|
||||
break;
|
||||
}
|
||||
|
||||
colors = CardUtil.getReflectableManaColors(ab, params, colors, parents);
|
||||
colors = CardUtil.getReflectableManaColors(ab, sa, colors, parents);
|
||||
}
|
||||
}
|
||||
return colors;
|
||||
|
||||
@@ -1957,8 +1957,7 @@ public class GameAction {
|
||||
public final void playSpellAbility(SpellAbility sa) {
|
||||
sa.setActivatingPlayer(Singletons.getControl().getPlayer());
|
||||
|
||||
AbilityFactory af = sa.getAbilityFactory();
|
||||
if (af != null && af.getAPI() == ApiType.Charm && !sa.isWrapper()) {
|
||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||
CharmEffect.makeChoices(sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -1493,7 +1493,7 @@ public final class GameActionUtil {
|
||||
allSAs.add(sa);
|
||||
Card source = sa.getSourceCard();
|
||||
|
||||
if (!sa.isSpell() || !source.isType("Arcane") || sa.getAbilityFactory() == null) {
|
||||
if (!sa.isSpell() || !source.isType("Arcane") || sa.getApi() == null) {
|
||||
return newSAs;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
|
||||
@@ -67,27 +67,6 @@ public class AbilityFactory {
|
||||
public AbilityFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for AbilityFactory.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a AbilityFactory object.
|
||||
*/
|
||||
public AbilityFactory(final AbilityFactory af) {
|
||||
this.abCost = af.getAbCost();
|
||||
this.abTgt = af.getAbTgt();
|
||||
this.api = af.getAPI();
|
||||
this.hasValid = af.hasValid();
|
||||
this.hostC = af.getHostCard();
|
||||
this.isAb = af.isAbility();
|
||||
this.isDb = af.isDrawback();
|
||||
this.isSp = af.isSpell();
|
||||
this.isTargeted = af.isTargeted();
|
||||
this.mapParams = af.getMapParams();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getHostCard.
|
||||
@@ -129,78 +108,10 @@ public class AbilityFactory {
|
||||
private boolean isSp = false;
|
||||
private boolean isDb = false;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isAbility.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isAbility() {
|
||||
return this.isAb;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isSpell.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isSpell() {
|
||||
return this.isSp;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isDrawback.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isDrawback() {
|
||||
return this.isDb;
|
||||
}
|
||||
|
||||
private Cost abCost = null;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>abCost</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.card.cost.Cost} object.
|
||||
*/
|
||||
public final Cost getAbCost() {
|
||||
return this.abCost;
|
||||
}
|
||||
|
||||
private boolean isTargeted = false;
|
||||
private boolean hasValid = false;
|
||||
private Target abTgt = null;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isTargeted.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isTargeted() {
|
||||
return this.isTargeted;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* hasValid.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasValid() {
|
||||
return this.hasValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>abTgt</code>.
|
||||
@@ -213,18 +124,6 @@ public class AbilityFactory {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isCurse.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isCurse() {
|
||||
return this.mapParams.containsKey("IsCurse");
|
||||
}
|
||||
|
||||
|
||||
private ApiType api = null;
|
||||
|
||||
/**
|
||||
@@ -302,11 +201,12 @@ public class AbilityFactory {
|
||||
throw new RuntimeException("AbilityFactory : getAbility -- no API in " + hostCard.getName());
|
||||
}
|
||||
|
||||
Cost abCost = null;
|
||||
if (!this.isDb) {
|
||||
if (!this.mapParams.containsKey("Cost")) {
|
||||
throw new RuntimeException("AbilityFactory : getAbility -- no Cost in " + hostCard.getName());
|
||||
}
|
||||
this.abCost = new Cost(hostCard, this.mapParams.get("Cost"), this.isAb);
|
||||
abCost = new Cost(hostCard, this.mapParams.get("Cost"), this.isAb);
|
||||
|
||||
}
|
||||
|
||||
@@ -399,11 +299,11 @@ public class AbilityFactory {
|
||||
SpellEffect se = api.getSpellEffect();
|
||||
|
||||
if (this.isAb) {
|
||||
spellAbility = new CommonAbility(this.getHostCard(), this.getAbCost(), this.getAbTgt(), this.getMapParams(), se, ai);
|
||||
spellAbility = new CommonAbility(api, this.getHostCard(), abCost, this.getAbTgt(), this.getMapParams(), se, ai);
|
||||
} else if (this.isSp) {
|
||||
spellAbility = new CommonSpell(this.getHostCard(), this.getAbCost(), this.getAbTgt(), this.getMapParams(), se, ai);
|
||||
spellAbility = new CommonSpell(api, this.getHostCard(), abCost, this.getAbTgt(), this.getMapParams(), se, ai);
|
||||
} else if (this.isDb) {
|
||||
spellAbility = new CommonDrawback(this.getHostCard(), this.getAbTgt(), this.getMapParams(), se, ai);
|
||||
spellAbility = new CommonDrawback(api, this.getHostCard(), this.getAbTgt(), this.getMapParams(), se, ai);
|
||||
}
|
||||
|
||||
|
||||
@@ -424,7 +324,7 @@ public class AbilityFactory {
|
||||
// *********************************************
|
||||
// set universal properties of the SpellAbility
|
||||
|
||||
spellAbility.setAbilityFactory(this);
|
||||
|
||||
|
||||
if (this.mapParams.containsKey("References")) {
|
||||
for (String svar : this.mapParams.get("References").split(",")) {
|
||||
@@ -448,7 +348,7 @@ public class AbilityFactory {
|
||||
if (this.mapParams.containsKey("CostDesc")) {
|
||||
sb.append(this.mapParams.get("CostDesc")).append(" ");
|
||||
} else {
|
||||
sb.append(this.abCost.toString());
|
||||
sb.append(abCost.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,12 +441,12 @@ public class AbilityFactory {
|
||||
return abSub;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getProtectionList(final Map<String, String> params) {
|
||||
public static ArrayList<String> getProtectionList(final SpellAbility sa) {
|
||||
final ArrayList<String> gains = new ArrayList<String>();
|
||||
|
||||
final String gainStr = params.get("Gains");
|
||||
final String gainStr = sa.getParam("Gains");
|
||||
if (gainStr.equals("Choice")) {
|
||||
String choices = params.get("Choices");
|
||||
String choices = sa.getParam("Choices");
|
||||
|
||||
// Replace AnyColor with the 5 colors
|
||||
if (choices.contains("AnyColor")) {
|
||||
@@ -749,8 +649,7 @@ public class AbilityFactory {
|
||||
if (saTargeting.getTarget() != null) {
|
||||
players.addAll(saTargeting.getTarget().getTargetPlayers());
|
||||
} else {
|
||||
players.addAll(AbilityFactory.getDefinedPlayers(card, saTargeting.getAbilityFactory()
|
||||
.getMapParams().get("Defined"), saTargeting));
|
||||
players.addAll(AbilityFactory.getDefinedPlayers(card, saTargeting.getParam("Defined"), saTargeting));
|
||||
}
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
@@ -760,8 +659,7 @@ public class AbilityFactory {
|
||||
if (saTargeting.getTarget() != null) {
|
||||
objects.addAll(saTargeting.getTarget().getTargets());
|
||||
} else {
|
||||
objects.addAll(AbilityFactory.getDefinedObjects(card, saTargeting.getAbilityFactory()
|
||||
.getMapParams().get("Defined"), saTargeting));
|
||||
objects.addAll(AbilityFactory.getDefinedObjects(card, saTargeting.getParam("Defined"), saTargeting));
|
||||
}
|
||||
return CardFactoryUtil.objectXCount(objects, calcX[1], card) * multiplier;
|
||||
}
|
||||
@@ -1398,7 +1296,7 @@ public class AbilityFactory {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static ArrayList<Object> predictThreatenedObjects(final Player aiPlayer, final AbilityFactory saviourAf) {
|
||||
public static ArrayList<Object> predictThreatenedObjects(final Player aiPlayer, final SpellAbility sa) {
|
||||
final ArrayList<Object> objects = new ArrayList<Object>();
|
||||
if (Singletons.getModel().getGame().getStack().size() == 0) {
|
||||
return objects;
|
||||
@@ -1406,7 +1304,7 @@ public class AbilityFactory {
|
||||
|
||||
// check stack for something that will kill this
|
||||
final SpellAbility topStack = Singletons.getModel().getGame().getStack().peekAbility();
|
||||
objects.addAll(AbilityFactory.predictThreatenedObjects(aiPlayer, saviourAf, topStack));
|
||||
objects.addAll(AbilityFactory.predictThreatenedObjects(aiPlayer, sa, topStack));
|
||||
|
||||
return objects;
|
||||
}
|
||||
@@ -1423,34 +1321,28 @@ public class AbilityFactory {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static ArrayList<Object> predictThreatenedObjects(final Player aiPlayer, final AbilityFactory saviourAf, final SpellAbility topStack) {
|
||||
public static ArrayList<Object> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour, final SpellAbility topStack) {
|
||||
ArrayList<Object> objects = new ArrayList<Object>();
|
||||
final ArrayList<Object> threatened = new ArrayList<Object>();
|
||||
ApiType saviourApi = null;
|
||||
Map<String, String> saviourParams = null;
|
||||
if (saviourAf != null) {
|
||||
saviourApi = saviourAf.getAPI();
|
||||
saviourParams = saviourAf.getMapParams();
|
||||
}
|
||||
ApiType saviourApi = saviour.getApi();
|
||||
|
||||
if (topStack == null) {
|
||||
return objects;
|
||||
}
|
||||
|
||||
final Card source = topStack.getSourceCard();
|
||||
final AbilityFactory topAf = topStack.getAbilityFactory();
|
||||
final ApiType threatApi = topStack.getApi();
|
||||
|
||||
// Can only Predict things from AFs
|
||||
if (topAf != null) {
|
||||
if (threatApi != null) {
|
||||
final Target tgt = topStack.getTarget();
|
||||
final Map<String, String> threatParams = topAf.getMapParams();
|
||||
|
||||
if (tgt == null) {
|
||||
if (threatParams.containsKey("Defined")) {
|
||||
objects = AbilityFactory.getDefinedObjects(source, threatParams.get("Defined"), topStack);
|
||||
} else if (threatParams.containsKey("ValidCards")) {
|
||||
if (topStack.hasParam("Defined")) {
|
||||
objects = AbilityFactory.getDefinedObjects(source, topStack.getParam("Defined"), topStack);
|
||||
} else if (topStack.hasParam("ValidCards")) {
|
||||
List<Card> battleField = aiPlayer.getCardsIn(ZoneType.Battlefield);
|
||||
List<Card> cards = CardLists.getValidCards(battleField, threatParams.get("ValidCards").split(","), source.getController(), source);
|
||||
List<Card> cards = CardLists.getValidCards(battleField, topStack.getParam("ValidCards").split(","), source.getController(), source);
|
||||
for (Card card : cards) {
|
||||
objects.add(card);
|
||||
}
|
||||
@@ -1462,13 +1354,11 @@ public class AbilityFactory {
|
||||
// Determine if Defined Objects are "threatened" will be destroyed
|
||||
// due to this SA
|
||||
|
||||
final ApiType threatApi = topAf.getAPI();
|
||||
|
||||
// Lethal Damage => prevent damage/regeneration/bounce/shroud
|
||||
if (threatApi == ApiType.DealDamage || threatApi == ApiType.DamageAll) {
|
||||
// If PredictDamage is >= Lethal Damage
|
||||
final int dmg = AbilityFactory.calculateAmount(topStack.getSourceCard(),
|
||||
topAf.getMapParams().get("NumDmg"), topStack);
|
||||
topStack.getParam("NumDmg"), topStack);
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
@@ -1489,9 +1379,9 @@ public class AbilityFactory {
|
||||
}
|
||||
|
||||
// give Shroud to targeted creatures
|
||||
if (saviourApi == ApiType.Pump && tgt == null && saviourParams.containsKey("KW")
|
||||
&& (saviourParams.get("KW").endsWith("Shroud")
|
||||
|| saviourParams.get("KW").endsWith("Hexproof"))) {
|
||||
if (saviourApi == ApiType.Pump && tgt == null && saviour.hasParam("KW")
|
||||
&& (saviour.getParam("KW").endsWith("Shroud")
|
||||
|| saviour.getParam("KW").endsWith("Hexproof"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1520,7 +1410,7 @@ public class AbilityFactory {
|
||||
// Destroy => regeneration/bounce/shroud
|
||||
else if ((threatApi == ApiType.Destroy || threatApi == ApiType.DestroyAll)
|
||||
&& (((saviourApi == ApiType.Regenerate || saviourApi == ApiType.RegenerateAll )
|
||||
&& !threatParams.containsKey("NoRegen")) || saviourApi == ApiType.ChangeZone || saviourApi == ApiType.Pump)) {
|
||||
&& !topStack.hasParam("NoRegen")) || saviourApi == ApiType.ChangeZone || saviourApi == ApiType.Pump)) {
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
@@ -1535,9 +1425,9 @@ public class AbilityFactory {
|
||||
}
|
||||
|
||||
// give Shroud to targeted creatures
|
||||
if (saviourApi == ApiType.Pump && tgt == null && saviourParams.containsKey("KW")
|
||||
&& (saviourParams.get("KW").endsWith("Shroud")
|
||||
|| saviourParams.get("KW").endsWith("Hexproof"))) {
|
||||
if (saviourApi == ApiType.Pump && tgt == null && saviour.hasParam("KW")
|
||||
&& (saviour.getParam("KW").endsWith("Shroud")
|
||||
|| saviour.getParam("KW").endsWith("Hexproof"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1558,15 +1448,14 @@ public class AbilityFactory {
|
||||
// Exiling => bounce/shroud
|
||||
else if ((threatApi == ApiType.ChangeZone || threatApi == ApiType.ChangeZoneAll)
|
||||
&& (saviourApi == ApiType.ChangeZone || saviourApi == ApiType.Pump)
|
||||
&& threatParams.containsKey("Destination")
|
||||
&& threatParams.get("Destination").equals("Exile")) {
|
||||
&& topStack.hasParam("Destination")
|
||||
&& topStack.getParam("Destination").equals("Exile")) {
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
// give Shroud to targeted creatures
|
||||
if (saviourApi == ApiType.Pump && tgt == null && saviourParams.containsKey("KW")
|
||||
&& (saviourParams.get("KW").endsWith("Shroud")
|
||||
|| saviourParams.get("KW").endsWith("Hexproof"))) {
|
||||
if (saviourApi == ApiType.Pump && tgt == null && saviour.hasParam("KW")
|
||||
&& (saviour.getParam("KW").endsWith("Shroud") || saviour.getParam("KW").endsWith("Hexproof"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1582,7 +1471,7 @@ public class AbilityFactory {
|
||||
}
|
||||
}
|
||||
|
||||
threatened.addAll(AbilityFactory.predictThreatenedObjects(aiPlayer, saviourAf, topStack.getSubAbility()));
|
||||
threatened.addAll(AbilityFactory.predictThreatenedObjects(aiPlayer, saviour, topStack.getSubAbility()));
|
||||
return threatened;
|
||||
}
|
||||
|
||||
@@ -1596,32 +1485,32 @@ public class AbilityFactory {
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*/
|
||||
public static void handleRemembering(final SpellAbility sa, final AbilityFactory af) {
|
||||
final Map<String, String> params = af.getMapParams();
|
||||
public static void handleRemembering(final SpellAbility sa) {
|
||||
|
||||
Card host;
|
||||
|
||||
if (!params.containsKey("RememberTargets") && !params.containsKey("RememberToughness")
|
||||
&& !params.containsKey("RememberCostCards")) {
|
||||
if (!sa.hasParam("RememberTargets") && !sa.hasParam("RememberToughness")
|
||||
&& !sa.hasParam("RememberCostCards")) {
|
||||
return;
|
||||
}
|
||||
|
||||
host = sa.getSourceCard();
|
||||
|
||||
if (params.containsKey("ForgetOtherTargets")) {
|
||||
if (sa.hasParam("ForgetOtherTargets")) {
|
||||
host.clearRemembered();
|
||||
}
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (params.containsKey("RememberTargets")) {
|
||||
if (sa.hasParam("RememberTargets")) {
|
||||
final ArrayList<Object> tgts = (tgt == null) ? new ArrayList<Object>() : tgt.getTargets();
|
||||
for (final Object o : tgts) {
|
||||
host.addRemembered(o);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("RememberCostCards")) {
|
||||
if (params.get("Cost").contains("Exile")) {
|
||||
if (sa.hasParam("RememberCostCards")) {
|
||||
if (sa.getParam("Cost").contains("Exile")) {
|
||||
final List<Card> paidListExiled = sa.getPaidList("Exiled");
|
||||
for (final Card exiledAsCost : paidListExiled) {
|
||||
host.addRemembered(exiledAsCost);
|
||||
@@ -1740,30 +1629,28 @@ public class AbilityFactory {
|
||||
*/
|
||||
public static void passUnlessCost(final SpellAbility sa, final boolean usedStack) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final AbilityFactory af = sa.getAbilityFactory();
|
||||
if (af == null) {
|
||||
final ApiType api = sa.getApi();
|
||||
if (api == null) {
|
||||
sa.resolve();
|
||||
AbilityFactory.resolveSubAbilities(sa, usedStack);
|
||||
return;
|
||||
}
|
||||
final Map<String, String> params = af.getMapParams();
|
||||
|
||||
// Nothing to do
|
||||
if (params.get("UnlessCost") == null) {
|
||||
if (sa.getParam("UnlessCost") == null) {
|
||||
sa.resolve();
|
||||
AbilityFactory.resolveSubAbilities(sa, usedStack);
|
||||
return;
|
||||
}
|
||||
|
||||
// The player who has the chance to cancel the ability
|
||||
final String pays = params.containsKey("UnlessPayer") ? params.get("UnlessPayer") : "TargetedController";
|
||||
final String pays = sa.hasParam("UnlessPayer") ? sa.getParam("UnlessPayer") : "TargetedController";
|
||||
final ArrayList<Player> payers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), pays, sa);
|
||||
|
||||
// The cost
|
||||
String unlessCost = params.get("UnlessCost").trim();
|
||||
String unlessCost = sa.getParam("UnlessCost").trim();
|
||||
|
||||
try {
|
||||
String unlessVar = Integer.toString(AbilityFactory.calculateAmount(source, params.get("UnlessCost").replace(" ", ""), sa));
|
||||
String unlessVar = Integer.toString(AbilityFactory.calculateAmount(source, sa.getParam("UnlessCost").replace(" ", ""), sa));
|
||||
unlessCost = unlessVar;
|
||||
} catch (final NumberFormatException n) {
|
||||
} //This try/catch method enables UnlessCost to parse any svar name
|
||||
@@ -1798,7 +1685,7 @@ public class AbilityFactory {
|
||||
@Override
|
||||
public void execute() {
|
||||
sa.resolve();
|
||||
if (params.containsKey("PowerSink")) {
|
||||
if (sa.hasParam("PowerSink")) {
|
||||
GameActionUtil.doPowerSink(sa.getActivatingPlayer());
|
||||
}
|
||||
AbilityFactory.resolveSubAbilities(sa, usedStack);
|
||||
@@ -1815,7 +1702,7 @@ public class AbilityFactory {
|
||||
if (ComputerUtil.canPayCost(ability, payer) && CostUtil.checkLifeCost(payer, cost, source, 4, sa)
|
||||
&& CostUtil.checkDamageCost(payer, cost, source, 4)
|
||||
&& (!source.getName().equals("Tyrannize") || payer.getCardsIn(ZoneType.Hand).size() > 2)
|
||||
&& (!params.containsKey("UnlessAI") || !params.get("UnlessAI").equals("Never"))
|
||||
&& (!sa.hasParam("UnlessAI") || !sa.getParam("UnlessAI").equals("Never"))
|
||||
&& (!source.getName().equals("Breaking Point") || payer.getCreaturesInPlay().size() > 1)) {
|
||||
// AI was crashing because the blank ability used to pay costs
|
||||
// Didn't have any of the data on the original SA to pay dependant costs
|
||||
@@ -1842,7 +1729,7 @@ public class AbilityFactory {
|
||||
AbilityFactory.resolveSubAbilities(sa, usedStack);
|
||||
} else {
|
||||
sa.resolve();
|
||||
if (params.containsKey("PowerSink")) {
|
||||
if (sa.hasParam("PowerSink")) {
|
||||
GameActionUtil.doPowerSink(payers.get(0));
|
||||
}
|
||||
AbilityFactory.resolveSubAbilities(sa, usedStack);
|
||||
@@ -1865,8 +1752,8 @@ public class AbilityFactory {
|
||||
if (sa == null) {
|
||||
return;
|
||||
}
|
||||
final AbilityFactory af = sa.getAbilityFactory();
|
||||
if (af == null) {
|
||||
final ApiType api = sa.getApi();
|
||||
if (api == null) {
|
||||
sa.resolve();
|
||||
if (sa.getSubAbility() != null) {
|
||||
resolve(sa.getSubAbility(), usedStack);
|
||||
|
||||
@@ -15,14 +15,14 @@ import forge.card.spellability.Target;
|
||||
|
||||
public class CommonAbility extends AbilityActivated {
|
||||
private final SpellEffect effect;
|
||||
private final Map<String,String> params;
|
||||
private final SpellAiLogic ai;
|
||||
|
||||
private static final long serialVersionUID = -4183793555528531978L;
|
||||
|
||||
public CommonAbility(Card sourceCard, Cost abCost, Target tgt, Map<String,String> params0, SpellEffect effect0, SpellAiLogic ai0) {
|
||||
public CommonAbility(ApiType api0, Card sourceCard, Cost abCost, Target tgt, Map<String,String> params0, SpellEffect effect0, SpellAiLogic ai0) {
|
||||
super(sourceCard, abCost, tgt);
|
||||
params = params0;
|
||||
api = api0;
|
||||
effect = effect0;
|
||||
ai = ai0;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class CommonAbility extends AbilityActivated {
|
||||
@Override
|
||||
public AbilityActivated getCopy() {
|
||||
Target tgt = getTarget() == null ? null : new Target(getTarget());
|
||||
AbilityActivated res = new CommonAbility(getSourceCard(), getPayCosts(), tgt, params, effect, ai);
|
||||
AbilityActivated res = new CommonAbility(api, getSourceCard(), getPayCosts(), tgt, params, effect, ai);
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
@@ -56,16 +56,16 @@ public class CommonAbility extends AbilityActivated {
|
||||
*/
|
||||
@Override
|
||||
public void resolve() {
|
||||
effect.resolve(params, this);
|
||||
effect.resolve(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return ai.canPlayAIWithSubs(getActivatingPlayer(), params, this);
|
||||
return ai.canPlayAIWithSubs(getActivatingPlayer(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTrigger(final boolean mandatory) {
|
||||
return ai.doTriggerAI(this.getActivatingPlayer(), params, this, mandatory);
|
||||
return ai.doTriggerAI(this.getActivatingPlayer(), this, mandatory);
|
||||
}
|
||||
}
|
||||
@@ -29,11 +29,11 @@ import forge.card.spellability.Target;
|
||||
public class CommonDrawback extends AbilitySub {
|
||||
private final SpellEffect effect;
|
||||
private final SpellAiLogic ai;
|
||||
private final Map<String, String> params;
|
||||
private static final long serialVersionUID = 6631124959690157874L;
|
||||
|
||||
public CommonDrawback(final Card ca, final Target t, Map<String, String> params0, SpellEffect effect0, SpellAiLogic ai0) {
|
||||
public CommonDrawback(ApiType api0, final Card ca, final Target t, Map<String, String> params0, SpellEffect effect0, SpellAiLogic ai0) {
|
||||
super(ca, t);
|
||||
api = api0;
|
||||
params = params0;
|
||||
ai = ai0;
|
||||
effect = effect0;
|
||||
@@ -44,7 +44,7 @@ public class CommonDrawback extends AbilitySub {
|
||||
@Override
|
||||
public AbilitySub getCopy() {
|
||||
Target t = getTarget() == null ? null : new Target(getTarget());
|
||||
AbilitySub res = new CommonDrawback(getSourceCard(),t, params, effect, ai);
|
||||
AbilitySub res = new CommonDrawback(api, getSourceCard(),t, params, effect, ai);
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
@@ -58,17 +58,17 @@ public class CommonDrawback extends AbilitySub {
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return ai.canPlayAIWithSubs(getActivatingPlayer(), params, this);
|
||||
return ai.canPlayAIWithSubs(getActivatingPlayer(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
effect.resolve(params, this);
|
||||
effect.resolve(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback() {
|
||||
if (!ai.chkAIDrawback(params, this, getActivatingPlayer())) {
|
||||
if (!ai.chkAIDrawback(this, getActivatingPlayer())) {
|
||||
return false;
|
||||
}
|
||||
final AbilitySub subAb = getSubAbility();
|
||||
@@ -80,7 +80,7 @@ public class CommonDrawback extends AbilitySub {
|
||||
|
||||
@Override
|
||||
public boolean doTrigger(final boolean mandatory) {
|
||||
return ai.doTriggerAI(getActivatingPlayer(), params, this, mandatory);
|
||||
return ai.doTriggerAI(getActivatingPlayer(), this, mandatory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ import forge.card.spellability.Target;
|
||||
public class CommonSpell extends Spell {
|
||||
private static final long serialVersionUID = -6741797239508483250L;
|
||||
private final SpellEffect effect;
|
||||
private final Map<String,String> params;
|
||||
private final SpellAiLogic ai;
|
||||
|
||||
public CommonSpell(Card sourceCard, Cost abCost, Target tgt, Map<String,String> params0, SpellEffect effect0, SpellAiLogic ai0) {
|
||||
public CommonSpell(ApiType api0, Card sourceCard, Cost abCost, Target tgt, Map<String,String> params0, SpellEffect effect0, SpellAiLogic ai0) {
|
||||
super(sourceCard, abCost, tgt);
|
||||
params = params0;
|
||||
api = api0;
|
||||
effect = effect0;
|
||||
ai = ai0;
|
||||
|
||||
@@ -36,21 +36,21 @@ public class CommonSpell extends Spell {
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return ai.canPlayAIWithSubs(getActivatingPlayer(), params, this) && super.canPlayAI();
|
||||
return ai.canPlayAIWithSubs(getActivatingPlayer(), this) && super.canPlayAI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
effect.resolve(params, this);
|
||||
effect.resolve(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayFromEffectAI(final boolean mandatory, final boolean withOutManaCost) {
|
||||
boolean chance = false;
|
||||
if (withOutManaCost) {
|
||||
chance = ai.doTriggerNoCostWithSubs(this.getActivatingPlayer(), params, this, mandatory);
|
||||
chance = ai.doTriggerNoCostWithSubs(this.getActivatingPlayer(), this, mandatory);
|
||||
}
|
||||
chance = ai.doTriggerAI(this.getActivatingPlayer(), params, this, mandatory);
|
||||
chance = ai.doTriggerAI(this.getActivatingPlayer(), this, mandatory);
|
||||
return chance;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -9,27 +8,27 @@ import forge.game.player.Player;
|
||||
|
||||
public abstract class SpellAiLogic {
|
||||
|
||||
public final boolean canPlayAIWithSubs(final Player aiPlayer, final Map<String, String> params, final SpellAbility sa) {
|
||||
public final boolean canPlayAIWithSubs(final Player aiPlayer, final SpellAbility sa) {
|
||||
final AbilitySub subAb = sa.getSubAbility();
|
||||
if (subAb != null && !subAb.chkAIDrawback()) {
|
||||
return false;
|
||||
}
|
||||
return canPlayAI(aiPlayer, params, sa);
|
||||
return canPlayAI(aiPlayer, sa);
|
||||
}
|
||||
|
||||
protected abstract boolean canPlayAI(final Player aiPlayer, final Map<String, String> params, final SpellAbility sa);
|
||||
protected abstract boolean canPlayAI(final Player aiPlayer, final SpellAbility sa);
|
||||
|
||||
public final boolean doTriggerAI(final Player aiPlayer, final Map<String, String> params, final SpellAbility sa, final boolean mandatory){
|
||||
public final boolean doTriggerAI(final Player aiPlayer, final SpellAbility sa, final boolean mandatory){
|
||||
if (!ComputerUtil.canPayCost(sa, aiPlayer) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return doTriggerNoCostWithSubs(aiPlayer, params, sa, mandatory);
|
||||
return doTriggerNoCostWithSubs(aiPlayer, sa, mandatory);
|
||||
}
|
||||
|
||||
public final boolean doTriggerNoCostWithSubs(final Player aiPlayer, final Map<String, String> params, final SpellAbility sa, final boolean mandatory)
|
||||
public final boolean doTriggerNoCostWithSubs(final Player aiPlayer, final SpellAbility sa, final boolean mandatory)
|
||||
{
|
||||
if (!doTriggerAINoCost(aiPlayer, params, sa, mandatory)) {
|
||||
if (!doTriggerAINoCost(aiPlayer, sa, mandatory)) {
|
||||
return false;
|
||||
}
|
||||
final AbilitySub subAb = sa.getSubAbility();
|
||||
@@ -39,11 +38,11 @@ public abstract class SpellAiLogic {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean doTriggerAINoCost(final Player aiPlayer, final Map<String, String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
return canPlayAI(aiPlayer, params, sa) || mandatory;
|
||||
protected boolean doTriggerAINoCost(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
|
||||
return canPlayAI(aiPlayer, sa) || mandatory;
|
||||
}
|
||||
|
||||
public boolean chkAIDrawback(final Map<String, String> params, final SpellAbility sa, final Player aiPlayer) {
|
||||
public boolean chkAIDrawback(final SpellAbility sa, final Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,9 @@ import forge.game.player.Player;
|
||||
|
||||
public abstract class SpellEffect {
|
||||
|
||||
public abstract void resolve(final Map<String, String> params, final SpellAbility sa);
|
||||
protected String getStackDescription(final Map<String, String> params, final SpellAbility sa) {
|
||||
public abstract void resolve(final SpellAbility sa);
|
||||
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
// Unless overriden, let the spell description also be the stack description
|
||||
return sa.getDescription();
|
||||
}
|
||||
@@ -66,7 +67,7 @@ import forge.game.player.Player;
|
||||
} else if ( spellDesc != null ) {
|
||||
sb.append( spellDesc.replace("CARDNAME", sa.getSourceCard().getName()) );
|
||||
} else
|
||||
sb.append(this.getStackDescription(params, sa));
|
||||
sb.append(this.getStackDescription(sa));
|
||||
|
||||
|
||||
// This inlcudes all subAbilities
|
||||
@@ -77,21 +78,21 @@ import forge.game.player.Player;
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected List<Card> getTargetCards(SpellAbility sa, final Map<String, String> params) {
|
||||
protected List<Card> getTargetCards(SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
return tgt != null ? tgt.getTargetCards() : AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
return tgt != null ? tgt.getTargetCards() : AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
protected List<Player> getTargetPlayers(SpellAbility sa, final Map<String, String> params) {
|
||||
return getTargetPlayers(sa, params, false, true);
|
||||
protected List<Player> getTargetPlayers(SpellAbility sa) {
|
||||
return getTargetPlayers(sa, false, true);
|
||||
}
|
||||
|
||||
protected List<Player> getTargetPlayersEmptyAsDefault(SpellAbility sa, final Map<String, String> params) {
|
||||
return getTargetPlayers(sa, params, true, true);
|
||||
protected List<Player> getTargetPlayersEmptyAsDefault(SpellAbility sa) {
|
||||
return getTargetPlayers(sa, true, true);
|
||||
}
|
||||
|
||||
protected List<Player> getDefinedPlayersBeforeTargetOnes(SpellAbility sa, final Map<String, String> params) {
|
||||
return getTargetPlayers(sa, params, false, false);
|
||||
protected List<Player> getDefinedPlayersBeforeTargetOnes(SpellAbility sa) {
|
||||
return getTargetPlayers(sa, false, false);
|
||||
}
|
||||
|
||||
// Each AF used its own preference in choosing target players:
|
||||
@@ -99,9 +100,9 @@ import forge.game.player.Player;
|
||||
// Some wanted empty list when params["Defined"] was not set - @see wantEmptyAsDefault
|
||||
// Poor me had to gather it all in a single place
|
||||
private final static List<Player> emptyPlayerList = Collections.unmodifiableList(new ArrayList<Player>());
|
||||
private List<Player> getTargetPlayers(SpellAbility sa, final Map<String, String> params, final boolean wantEmptyAsDefault, final boolean targetIsPreferred) {
|
||||
private List<Player> getTargetPlayers(SpellAbility sa, final boolean wantEmptyAsDefault, final boolean targetIsPreferred) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final String defined = params.get("Defined");
|
||||
final String defined = sa.getParam("Defined");
|
||||
if ( tgt != null && ( targetIsPreferred || ( StringUtils.isEmpty(defined) && !wantEmptyAsDefault ) ) )
|
||||
return tgt.getTargetPlayers();
|
||||
if ( StringUtils.isEmpty(defined) && wantEmptyAsDefault )
|
||||
@@ -109,14 +110,14 @@ import forge.game.player.Player;
|
||||
return AbilityFactory.getDefinedPlayers(sa.getSourceCard(), defined, sa);
|
||||
}
|
||||
|
||||
protected List<SpellAbility> getTargetSpellAbilities(SpellAbility sa, final Map<String, String> params) {
|
||||
protected List<SpellAbility> getTargetSpellAbilities(SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
return tgt != null ? tgt.getTargetSAs() : AbilityFactory.getDefinedSpellAbilities(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
return tgt != null ? tgt.getTargetSAs() : AbilityFactory.getDefinedSpellAbilities(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
protected List<Object> getTargetObjects(SpellAbility sa, final Map<String, String> params) {
|
||||
protected List<Object> getTargetObjects(SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
return tgt != null ? tgt.getTargets() : AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
return tgt != null ? tgt.getTargets() : AbilityFactory.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -38,7 +37,7 @@ public class AddTurnAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Player opp = ai.getOpponent();
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
@@ -52,8 +51,7 @@ public class AddTurnAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
final ArrayList<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||
params.get("Defined"), sa);
|
||||
final ArrayList<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
for (final Player p : tgtPlayers) {
|
||||
if (p.isHuman() && !mandatory) {
|
||||
return false;
|
||||
@@ -66,7 +64,7 @@ public class AddTurnAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,8 +72,8 @@ public class AddTurnAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
return doTriggerAINoCost(aiPlayer, params, sa, false);
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return doTriggerAINoCost(aiPlayer, sa, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -11,7 +10,7 @@ public class AlwaysPlayAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,7 +19,7 @@ public class AlwaysPlayAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
@@ -31,7 +29,7 @@ public class AnimateAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -45,7 +43,7 @@ public class AnimateAi extends SpellAiLogic {
|
||||
if (!Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.COMBAT_BEGIN)
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(aiPlayer)
|
||||
&& !AbilityFactory.isSorcerySpeed(sa)
|
||||
&& !params.containsKey("ActivationPhases") && !params.containsKey("Permanent")) {
|
||||
&& !sa.hasParam("ActivationPhases") && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,26 +65,26 @@ public class AnimateAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
// don't activate during main2 unless this effect is permanent
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN2) && !params.containsKey("Permanent")) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN2) && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == tgt) {
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
|
||||
boolean bFlag = false;
|
||||
for (final Card c : defined) {
|
||||
bFlag |= (!c.isCreature() && !c.isTapped() && !(c.getTurnInZone() == Singletons.getModel().getGame().getPhaseHandler().getTurn()));
|
||||
|
||||
// for creatures that could be improved (like Figure of Destiny)
|
||||
if (c.isCreature() && (params.containsKey("Permanent") || (!c.isTapped() && !c.isSick()))) {
|
||||
if (c.isCreature() && (sa.hasParam("Permanent") || (!c.isTapped() && !c.isSick()))) {
|
||||
int power = -5;
|
||||
if (params.containsKey("Power")) {
|
||||
power = AbilityFactory.calculateAmount(source, params.get("Power"), sa);
|
||||
if (sa.hasParam("Power")) {
|
||||
power = AbilityFactory.calculateAmount(source, sa.getParam("Power"), sa);
|
||||
}
|
||||
int toughness = -5;
|
||||
if (params.containsKey("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(source, params.get("Toughness"), sa);
|
||||
if (sa.hasParam("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(source, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
if ((power + toughness) > (c.getCurrentPower() + c.getCurrentToughness())) {
|
||||
bFlag = true;
|
||||
@@ -101,7 +99,7 @@ public class AnimateAi extends SpellAiLogic {
|
||||
}
|
||||
} else {
|
||||
tgt.resetTargets();
|
||||
if (!animateTgtAI(params, sa)) {
|
||||
if (!animateTgtAI(sa)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -113,10 +111,10 @@ public class AnimateAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
if (sa.getTarget() != null) {
|
||||
sa.getTarget().resetTargets();
|
||||
if (!animateTgtAI(params, sa)) {
|
||||
if (!animateTgtAI(sa)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -128,19 +126,19 @@ public class AnimateAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* animateTriggerAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
if (sa.getTarget() != null && !animateTgtAI(params, sa) && !mandatory) {
|
||||
if (sa.getTarget() != null && !animateTgtAI(sa) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,7 +163,7 @@ public class AnimateAi extends SpellAiLogic {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean animateTgtAI(final Map<String, String> params, final SpellAbility sa) {
|
||||
private boolean animateTgtAI(final SpellAbility sa) {
|
||||
// This is reasonable for now. Kamahl, Fist of Krosa and a sorcery or
|
||||
// two are the only things
|
||||
// that animate a target. Those can just use SVar:RemAIDeck:True until
|
||||
|
||||
@@ -7,12 +7,12 @@ import forge.game.player.Player;
|
||||
public class AnimateAllAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
} // end animateAllCanPlayAI()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AttachAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -54,7 +54,7 @@ public class AttachAi extends SpellAiLogic {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
tgt.resetTargets();
|
||||
if (!attachPreference(sa, params, tgt, false)) {
|
||||
if (!attachPreference(sa, tgt, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class AttachAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !"Curse".equals(params.get("AILogic"))) {
|
||||
&& !"Curse".equals(sa.getParam("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ public class AttachAi extends SpellAiLogic {
|
||||
String type = "";
|
||||
|
||||
for (final StaticAbility stAb : attachSource.getStaticAbilities()) {
|
||||
final HashMap<String, String> params = stAb.getMapParams();
|
||||
if (params.get("Mode").equals("Continuous") && params.containsKey("AddType")) {
|
||||
type = params.get("AddType");
|
||||
final HashMap<String, String> stab = stAb.getMapParams();
|
||||
if (stab.get("Mode").equals("Continuous") && stab.containsKey("AddType")) {
|
||||
type = stab.get("AddType");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,10 +213,9 @@ public class AttachAi extends SpellAiLogic {
|
||||
final Iterator<Card> itr = auras.iterator();
|
||||
while (itr.hasNext()) {
|
||||
final Card aura = itr.next();
|
||||
final AbilityFactory af = aura.getSpellPermanent().getAbilityFactory();
|
||||
if ((af != null) && af.getAPI() == ApiType.Attach) {
|
||||
final Map<String, String> params = af.getMapParams();
|
||||
if ("KeepTapped".equals(params.get("AILogic"))) {
|
||||
SpellAbility auraSA = aura.getSpellPermanent();
|
||||
if (auraSA.getApi() == ApiType.Attach) {
|
||||
if ("KeepTapped".equals(auraSA.getParam("AILogic"))) {
|
||||
// Don't attach multiple KeepTapped Auras to one
|
||||
// card
|
||||
return false;
|
||||
@@ -248,11 +247,11 @@ public class AttachAi extends SpellAiLogic {
|
||||
* the mandatory
|
||||
* @return the player
|
||||
*/
|
||||
private static Player attachToPlayerAIPreferences(final Player aiPlayer, final Map<String, String> params, final SpellAbility sa,
|
||||
private static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
Player p;
|
||||
|
||||
if ("Curse".equals(params.get("AILogic"))) {
|
||||
if (sa.isCurse()) {
|
||||
p = aiPlayer.getOpponent();
|
||||
} else {
|
||||
p = aiPlayer;
|
||||
@@ -380,25 +379,25 @@ public class AttachAi extends SpellAiLogic {
|
||||
// boolean grantingAbilities = false;
|
||||
|
||||
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
||||
final Map<String, String> params = stAbility.getMapParams();
|
||||
final Map<String, String> stabMap = stAbility.getMapParams();
|
||||
|
||||
if (!params.get("Mode").equals("Continuous")) {
|
||||
if (!stabMap.get("Mode").equals("Continuous")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String affected = params.get("Affected");
|
||||
final String affected = stabMap.get("Affected");
|
||||
|
||||
if (affected == null) {
|
||||
continue;
|
||||
}
|
||||
if ((affected.contains(stCheck) || affected.contains("AttachedBy"))) {
|
||||
totToughness += CardFactoryUtil.parseSVar(attachSource, params.get("AddToughness"));
|
||||
totToughness += CardFactoryUtil.parseSVar(attachSource, stabMap.get("AddToughness"));
|
||||
// totPower += CardFactoryUtil.parseSVar(attachSource,
|
||||
// params.get("AddPower"));
|
||||
// sa.get("AddPower"));
|
||||
|
||||
// grantingAbilities |= params.containsKey("AddAbility");
|
||||
// grantingAbilities |= sa.containsKey("AddAbility");
|
||||
|
||||
final String kws = params.get("AddKeyword");
|
||||
final String kws = stabMap.get("AddKeyword");
|
||||
if (kws != null) {
|
||||
for (final String kw : kws.split(" & ")) {
|
||||
keywords.add(kw);
|
||||
@@ -459,23 +458,23 @@ public class AttachAi extends SpellAiLogic {
|
||||
|
||||
/**
|
||||
* Attach do trigger ai.
|
||||
*
|
||||
* @param af
|
||||
* the af
|
||||
* @param sa
|
||||
* the sa
|
||||
* @param mandatory
|
||||
* the mandatory
|
||||
* @param af
|
||||
* the af
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player ai, final Map<String, String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card card = sa.getSourceCard();
|
||||
// Check if there are any valid targets
|
||||
ArrayList<Object> targets = new ArrayList<Object>();
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt == null) {
|
||||
targets = AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
targets = AbilityFactory.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
if (!mandatory && card.isEquipment() && !targets.isEmpty()) {
|
||||
@@ -504,20 +503,20 @@ public class AttachAi extends SpellAiLogic {
|
||||
* the af
|
||||
* @param sa
|
||||
* the sa
|
||||
* @param params
|
||||
* the params
|
||||
* @param sa
|
||||
* the sa
|
||||
* @param tgt
|
||||
* the tgt
|
||||
* @param mandatory
|
||||
* the mandatory
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean attachPreference(final SpellAbility sa, final Map<String, String> params, final Target tgt, final boolean mandatory) {
|
||||
public static boolean attachPreference(final SpellAbility sa, final Target tgt, final boolean mandatory) {
|
||||
Object o;
|
||||
if (tgt.canTgtPlayer()) {
|
||||
o = attachToPlayerAIPreferences(sa.getActivatingPlayer(), params, sa, mandatory);
|
||||
o = attachToPlayerAIPreferences(sa.getActivatingPlayer(), sa, mandatory);
|
||||
} else {
|
||||
o = attachToCardAIPreferences(sa.getActivatingPlayer(), sa, params, mandatory);
|
||||
o = attachToCardAIPreferences(sa.getActivatingPlayer(), sa, mandatory);
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
@@ -590,30 +589,30 @@ public class AttachAi extends SpellAiLogic {
|
||||
boolean grantingAbilities = false;
|
||||
|
||||
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
||||
final Map<String, String> params = stAbility.getMapParams();
|
||||
final Map<String, String> stabMap = stAbility.getMapParams();
|
||||
|
||||
if (!params.get("Mode").equals("Continuous")) {
|
||||
if (!stabMap.get("Mode").equals("Continuous")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String affected = params.get("Affected");
|
||||
final String affected = stabMap.get("Affected");
|
||||
|
||||
if (affected == null) {
|
||||
continue;
|
||||
}
|
||||
if ((affected.contains(stCheck) || affected.contains("AttachedBy"))) {
|
||||
totToughness += CardFactoryUtil.parseSVar(attachSource, params.get("AddToughness"));
|
||||
totPower += CardFactoryUtil.parseSVar(attachSource, params.get("AddPower"));
|
||||
totToughness += CardFactoryUtil.parseSVar(attachSource, stabMap.get("AddToughness"));
|
||||
totPower += CardFactoryUtil.parseSVar(attachSource, stabMap.get("AddPower"));
|
||||
|
||||
grantingAbilities |= params.containsKey("AddAbility");
|
||||
grantingAbilities |= stabMap.containsKey("AddAbility");
|
||||
|
||||
String kws = params.get("AddKeyword");
|
||||
String kws = stabMap.get("AddKeyword");
|
||||
if (kws != null) {
|
||||
for (final String kw : kws.split(" & ")) {
|
||||
keywords.add(kw);
|
||||
}
|
||||
}
|
||||
kws = params.get("AddHiddenKeyword");
|
||||
kws = stabMap.get("AddHiddenKeyword");
|
||||
if (kws != null) {
|
||||
for (final String kw : kws.split(" & ")) {
|
||||
keywords.add(kw);
|
||||
@@ -686,14 +685,13 @@ public class AttachAi extends SpellAiLogic {
|
||||
*
|
||||
* @param sa
|
||||
* the sa
|
||||
* @param params
|
||||
* the params
|
||||
* @param sa
|
||||
* the sa
|
||||
* @param mandatory
|
||||
* the mandatory
|
||||
* @return the card
|
||||
*/
|
||||
private static Card attachToCardAIPreferences(final Player aiPlayer, final SpellAbility sa,
|
||||
final Map<String, String> params, final boolean mandatory) {
|
||||
private static Card attachToCardAIPreferences(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card attachSource = sa.getSourceCard();
|
||||
// TODO AttachSource is currently set for the Source of the Spell, but
|
||||
@@ -721,11 +719,11 @@ public class AttachAi extends SpellAiLogic {
|
||||
return null;
|
||||
}
|
||||
List<Card> prefList = list;
|
||||
if (params.containsKey("AITgts")) {
|
||||
prefList = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), attachSource);
|
||||
if (sa.hasParam("AITgts")) {
|
||||
prefList = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), attachSource);
|
||||
}
|
||||
|
||||
Card c = attachGeneralAI(aiPlayer, sa, prefList, mandatory, attachSource, params.get("AILogic"));
|
||||
Card c = attachGeneralAI(aiPlayer, sa, prefList, mandatory, attachSource, sa.getParam("AILogic"));
|
||||
|
||||
if ((c == null) && mandatory) {
|
||||
CardLists.shuffle(list);
|
||||
|
||||
@@ -34,15 +34,15 @@ public final class BondAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* bondCanPlayAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return true;
|
||||
} // end bondCanPlayAI()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -12,7 +11,7 @@ public class CanPlayAsDrawbackAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,7 +19,7 @@ public class CanPlayAsDrawbackAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,17 +27,17 @@ public class CanPlayAsDrawbackAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* copySpellTriggerAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -11,7 +10,7 @@ public class CannotPlayAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,7 +19,7 @@ public class CannotPlayAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
return canPlayAI(aiPlayer, params, sa);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return canPlayAI(aiPlayer, sa);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -47,24 +46,24 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* changeZoneCanPlayAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
String origin = "";
|
||||
if (params.containsKey("Origin")) {
|
||||
origin = params.get("Origin");
|
||||
if (sa.hasParam("Origin")) {
|
||||
origin = sa.getParam("Origin");
|
||||
}
|
||||
|
||||
if (ZoneType.isHidden(origin, params.containsKey("Hidden"))) {
|
||||
return hiddenOriginCanPlayAI(aiPlayer, params, sa);
|
||||
if (ZoneType.isHidden(origin, sa.hasParam("Hidden"))) {
|
||||
return hiddenOriginCanPlayAI(aiPlayer, sa);
|
||||
} else if (ZoneType.isKnown(origin)) {
|
||||
return knownOriginCanPlayAI(aiPlayer, params, sa);
|
||||
return knownOriginCanPlayAI(aiPlayer, sa);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -74,24 +73,24 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* changeZonePlayDrawbackAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
String origin = "";
|
||||
if (params.containsKey("Origin")) {
|
||||
origin = params.get("Origin");
|
||||
if (sa.hasParam("Origin")) {
|
||||
origin = sa.getParam("Origin");
|
||||
}
|
||||
|
||||
if (ZoneType.isHidden(origin, params.containsKey("Hidden"))) {
|
||||
return hiddenOriginPlayDrawbackAI(aiPlayer, params, sa);
|
||||
if (ZoneType.isHidden(origin, sa.hasParam("Hidden"))) {
|
||||
return hiddenOriginPlayDrawbackAI(aiPlayer, sa);
|
||||
} else if (ZoneType.isKnown(origin)) {
|
||||
return knownOriginPlayDrawbackAI(aiPlayer, params, sa);
|
||||
return knownOriginPlayDrawbackAI(aiPlayer, sa);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -103,26 +102,26 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* changeZoneTriggerAINoCost.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
String origin = "";
|
||||
if (params.containsKey("Origin")) {
|
||||
origin = params.get("Origin");
|
||||
if (sa.hasParam("Origin")) {
|
||||
origin = sa.getParam("Origin");
|
||||
}
|
||||
|
||||
if (ZoneType.isHidden(origin, params.containsKey("Hidden"))) {
|
||||
return hiddenTriggerAI(aiPlayer, params, sa, mandatory);
|
||||
if (ZoneType.isHidden(origin, sa.hasParam("Hidden"))) {
|
||||
return hiddenTriggerAI(aiPlayer, sa, mandatory);
|
||||
} else if (ZoneType.isKnown(origin)) {
|
||||
return knownOriginTriggerAI(aiPlayer, params, sa, mandatory);
|
||||
return knownOriginTriggerAI(aiPlayer, sa, mandatory);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -154,18 +153,18 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean hiddenOriginCanPlayAI(final Player ai, final Map<String, String> params, final SpellAbility sa) {
|
||||
private static boolean hiddenOriginCanPlayAI(final Player ai, final SpellAbility sa) {
|
||||
// Fetching should occur fairly often as it helps cast more spells, and
|
||||
// have access to more mana
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
ZoneType origin = null;
|
||||
final Player opponent = ai.getOpponent();
|
||||
|
||||
if (params.containsKey("Origin")) {
|
||||
origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
if (sa.hasParam("Origin")) {
|
||||
origin = ZoneType.smartValueOf(sa.getParam("Origin"));
|
||||
}
|
||||
final String destination = params.get("Destination");
|
||||
final String destination = sa.getParam("Destination");
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -191,7 +190,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
//Ninjutsu
|
||||
if (params.containsKey("Ninjutsu")) {
|
||||
if (sa.hasParam("Ninjutsu")) {
|
||||
if (source.isType("Legendary") && !Singletons.getModel().getGame().isCardInPlay("Mirror Gallery")) {
|
||||
final List<Card> list = ai.getCardsIn(ZoneType.Battlefield);
|
||||
if (Iterables.any(list, CardPredicates.nameEquals(source.getName()))) {
|
||||
@@ -235,7 +234,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
pDefined.add(source.getController());
|
||||
final Target tgt = sa.getTarget();
|
||||
if ((tgt != null) && tgt.canTgtPlayer()) {
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
boolean isCurse = sa.isCurse();
|
||||
if (isCurse && sa.canTarget(opponent)) {
|
||||
tgt.addTarget(opponent);
|
||||
} else if (!isCurse && sa.canTarget(ai)) {
|
||||
@@ -243,14 +242,14 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
pDefined = tgt.getTargetPlayers();
|
||||
} else {
|
||||
if (params.containsKey("DefinedPlayer")) {
|
||||
pDefined = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("DefinedPlayer"), sa);
|
||||
if (sa.hasParam("DefinedPlayer")) {
|
||||
pDefined = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("DefinedPlayer"), sa);
|
||||
} else {
|
||||
pDefined = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
pDefined = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
}
|
||||
|
||||
String type = params.get("ChangeType");
|
||||
String type = sa.getParam("ChangeType");
|
||||
if (type != null) {
|
||||
if (type.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -275,7 +274,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
|
||||
// don't use fetching to top of library/graveyard before main2
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
if (!destination.equals("Battlefield") && !destination.equals("Hand")) {
|
||||
return false;
|
||||
}
|
||||
@@ -306,13 +305,13 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean hiddenOriginPlayDrawbackAI(final Player aiPlayer, Map<String,String> params, final SpellAbility sa) {
|
||||
private static boolean hiddenOriginPlayDrawbackAI(final Player aiPlayer, final SpellAbility sa) {
|
||||
// if putting cards from hand to library and parent is drawing cards
|
||||
// make sure this will actually do something:
|
||||
final Target tgt = sa.getTarget();
|
||||
final Player opp = aiPlayer.getOpponent();
|
||||
if ((tgt != null) && tgt.canTgtPlayer()) {
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
boolean isCurse = sa.isCurse();
|
||||
if (isCurse && sa.canTarget(opp)) {
|
||||
tgt.addTarget(opp);
|
||||
} else if (!isCurse && sa.canTarget(aiPlayer)) {
|
||||
@@ -338,7 +337,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean hiddenTriggerAI(final Player ai, final Map<String,String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
private static boolean hiddenTriggerAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
// Fetching should occur fairly often as it helps cast more spells, and
|
||||
// have access to more mana
|
||||
|
||||
@@ -346,12 +345,12 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
|
||||
|
||||
List<ZoneType> origin = new ArrayList<ZoneType>();
|
||||
if (params.containsKey("Origin")) {
|
||||
origin = ZoneType.listValueOf(params.get("Origin"));
|
||||
if (sa.hasParam("Origin")) {
|
||||
origin = ZoneType.listValueOf(sa.getParam("Origin"));
|
||||
}
|
||||
|
||||
// this works for hidden because the mana is paid first.
|
||||
final String type = params.get("ChangeType");
|
||||
final String type = sa.getParam("ChangeType");
|
||||
if ((type != null) && type.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int xPay = ComputerUtil.determineLeftoverMana(sa, ai);
|
||||
@@ -362,8 +361,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
final Target tgt = sa.getTarget();
|
||||
if ((tgt != null) && tgt.canTgtPlayer()) {
|
||||
final Player opp = ai.getOpponent();
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
if (isCurse) {
|
||||
if (sa.isCurse()) {
|
||||
if (sa.canTarget(opp)) {
|
||||
tgt.addTarget(opp);
|
||||
} else if (mandatory && sa.canTarget(ai)) {
|
||||
@@ -390,7 +388,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
pDefined = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
pDefined = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
for (final Player p : pDefined) {
|
||||
@@ -398,7 +396,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
|
||||
// Computer should "know" his deck
|
||||
if (p.isComputer()) {
|
||||
list = AbilityFactory.filterListByType(list, params.get("ChangeType"), sa);
|
||||
list = AbilityFactory.filterListByType(list, sa.getParam("ChangeType"), sa);
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
@@ -523,13 +521,13 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean knownOriginCanPlayAI(final Player ai, final Map<String,String> params, final SpellAbility sa) {
|
||||
private static boolean knownOriginCanPlayAI(final Player ai, final SpellAbility sa) {
|
||||
// Retrieve either this card, or target Cards in Graveyard
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(sa.getParam("Origin"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
@@ -557,12 +555,12 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
if (!isPreferredTarget(ai, params, sa, false)) {
|
||||
if (!isPreferredTarget(ai, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// non-targeted retrieval
|
||||
final List<Card> retrieval = sa.knownDetermineDefined(params.get("Defined"));
|
||||
final List<Card> retrieval = sa.knownDetermineDefined(sa.getParam("Defined"));
|
||||
|
||||
if ((retrieval == null) || retrieval.isEmpty()) {
|
||||
return false;
|
||||
@@ -584,7 +582,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
ApiType subAPI = null;
|
||||
if (abSub != null) {
|
||||
subAPI = abSub.getAbilityFactory().getAPI();
|
||||
subAPI = abSub.getApi();
|
||||
}
|
||||
|
||||
// only use blink or bounce effects
|
||||
@@ -593,7 +591,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(ai, sa.getAbilityFactory());
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(ai, sa);
|
||||
boolean contains = false;
|
||||
for (final Card c : retrieval) {
|
||||
if (objects.contains(c)) {
|
||||
@@ -640,12 +638,12 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean knownOriginPlayDrawbackAI(final Player aiPlayer, final Map<String,String> params, final SpellAbility sa) {
|
||||
private static boolean knownOriginPlayDrawbackAI(final Player aiPlayer, final SpellAbility sa) {
|
||||
if (sa.getTarget() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isPreferredTarget(aiPlayer, params, sa, false);
|
||||
return isPreferredTarget(aiPlayer, sa, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,29 +659,27 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean isPreferredTarget(final Player ai, final Map<String,String> params, final SpellAbility sa,
|
||||
private static boolean isPreferredTarget(final Player ai, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final ZoneType origin = ZoneType.listValueOf(params.get("Origin")).get(0);
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
ApiType subAPI = null;
|
||||
String subAffected = "";
|
||||
Map<String, String> subParams = null;
|
||||
if (abSub != null) {
|
||||
subAPI = abSub.getAbilityFactory().getAPI();
|
||||
subParams = abSub.getAbilityFactory().getMapParams();
|
||||
if (subParams.containsKey("Defined")) {
|
||||
subAffected = subParams.get("Defined");
|
||||
subAPI = abSub.getApi();
|
||||
if (abSub.hasParam("Defined")) {
|
||||
subAffected = abSub.getParam("Defined");
|
||||
}
|
||||
}
|
||||
|
||||
tgt.resetTargets();
|
||||
List<Card> list = CardLists.getValidCards(Singletons.getModel().getGame().getCardsIn(origin), tgt.getValidTgts(), ai, source);
|
||||
if (params.containsKey("AITgts")) {
|
||||
list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source);
|
||||
if (sa.hasParam("AITgts")) {
|
||||
list = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), source);
|
||||
}
|
||||
if (source.isInZone(ZoneType.Hand)) {
|
||||
list = CardLists.filter(list, Predicates.not(CardPredicates.nameEquals(source.getName()))); // Don't get the same card back.
|
||||
@@ -715,7 +711,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
// check stack for something on the stack that will kill
|
||||
// anything i control
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(ai, sa.getAbilityFactory());
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(ai, sa);
|
||||
|
||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||
|
||||
@@ -903,15 +899,15 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean isUnpreferredTarget(final Player ai, final Map<String,String> params, final SpellAbility sa,
|
||||
private static boolean isUnpreferredTarget(final Player ai, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
if (!mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(sa.getParam("Origin"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
List<Card> list = CardLists.getValidCards(Singletons.getModel().getGame().getCardsIn(origin), tgt.getValidTgts(), ai, source);
|
||||
@@ -1012,14 +1008,14 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean knownOriginTriggerAI(final Player ai, final Map<String,String> params, final SpellAbility sa,
|
||||
private static boolean knownOriginTriggerAI(final Player ai, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
|
||||
if (sa.getTarget() == null) {
|
||||
// Just in case of Defined cases
|
||||
if (!mandatory && params.containsKey("AttachedTo")) {
|
||||
if (!mandatory && sa.hasParam("AttachedTo")) {
|
||||
final ArrayList<Card> list = AbilityFactory.getDefinedCards(sa.getSourceCard(),
|
||||
params.get("AttachedTo"), sa);
|
||||
sa.getParam("AttachedTo"), sa);
|
||||
if (!list.isEmpty()) {
|
||||
final Card attachedTo = list.get(0);
|
||||
// This code is for the Dragon auras
|
||||
@@ -1028,9 +1024,9 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isPreferredTarget(ai, params, sa, mandatory)) {
|
||||
} else if (isPreferredTarget(ai, sa, mandatory)) {
|
||||
// do nothing
|
||||
} else if (!isUnpreferredTarget(ai, params, sa, mandatory)) {
|
||||
} else if (!isUnpreferredTarget(ai, sa, mandatory)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1049,10 +1045,10 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
* @param player
|
||||
* a {@link forge.game.player.Player} object.
|
||||
*/
|
||||
public static void hiddenOriginResolveAI(final Player ai, final Map<String,String> params, final SpellAbility sa, Player player) {
|
||||
public static void hiddenOriginResolveAI(final Player ai, final SpellAbility sa, Player player) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card card = sa.getSourceCard();
|
||||
final boolean defined = params.containsKey("Defined");
|
||||
final boolean defined = sa.hasParam("Defined");
|
||||
|
||||
if (tgt != null) {
|
||||
if (!tgt.getTargetPlayers().isEmpty()) {
|
||||
@@ -1064,26 +1060,26 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
List<ZoneType> origin = new ArrayList<ZoneType>();
|
||||
if (params.containsKey("Origin")) {
|
||||
origin = ZoneType.listValueOf(params.get("Origin"));
|
||||
if (sa.hasParam("Origin")) {
|
||||
origin = ZoneType.listValueOf(sa.getParam("Origin"));
|
||||
}
|
||||
|
||||
String type = params.get("ChangeType");
|
||||
String type = sa.getParam("ChangeType");
|
||||
if (type == null) {
|
||||
type = "Card";
|
||||
}
|
||||
|
||||
int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card, params.get("ChangeNum"),
|
||||
int changeNum = sa.hasParam("ChangeNum") ? AbilityFactory.calculateAmount(card, sa.getParam("ChangeNum"),
|
||||
sa) : 1;
|
||||
|
||||
List<Card> fetchList;
|
||||
if (defined) {
|
||||
fetchList = new ArrayList<Card>(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa));
|
||||
if (!params.containsKey("ChangeNum")) {
|
||||
fetchList = new ArrayList<Card>(AbilityFactory.getDefinedCards(card, sa.getParam("Defined"), sa));
|
||||
if (!sa.hasParam("ChangeNum")) {
|
||||
changeNum = fetchList.size();
|
||||
}
|
||||
} else if (!origin.contains(ZoneType.Library) && !origin.contains(ZoneType.Hand)
|
||||
&& !params.containsKey("DefinedPlayer")) {
|
||||
&& !sa.hasParam("DefinedPlayer")) {
|
||||
fetchList = Singletons.getModel().getGame().getCardsIn(origin);
|
||||
fetchList = AbilityFactory.filterListByType(fetchList, type, sa);
|
||||
} else {
|
||||
@@ -1091,18 +1087,18 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
fetchList = AbilityFactory.filterListByType(fetchList, type, sa);
|
||||
}
|
||||
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final List<Card> fetched = new ArrayList<Card>();
|
||||
final String remember = params.get("RememberChanged");
|
||||
final String forget = params.get("ForgetChanged");
|
||||
final String imprint = params.get("Imprint");
|
||||
final String remember = sa.getParam("RememberChanged");
|
||||
final String forget = sa.getParam("ForgetChanged");
|
||||
final String imprint = sa.getParam("Imprint");
|
||||
|
||||
if (params.containsKey("Unimprint")) {
|
||||
if (sa.hasParam("Unimprint")) {
|
||||
card.clearImprinted();
|
||||
}
|
||||
|
||||
for (int i = 0; i < changeNum; i++) {
|
||||
if (params.containsKey("DifferentNames")) {
|
||||
if (sa.hasParam("DifferentNames")) {
|
||||
for (Card c : fetched) {
|
||||
fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.nameEquals(c.getName())));
|
||||
}
|
||||
@@ -1113,7 +1109,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
|
||||
// Improve the AI for fetching.
|
||||
Card c = null;
|
||||
if (params.containsKey("AtRandom")) {
|
||||
if (sa.hasParam("AtRandom")) {
|
||||
c = CardUtil.getRandom(fetchList);
|
||||
} else if (defined) {
|
||||
c = fetchList.get(0);
|
||||
@@ -1133,7 +1129,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (player.isHuman() && params.containsKey("GainControl")) {
|
||||
if (player.isHuman() && sa.hasParam("GainControl")) {
|
||||
fetchList = CardLists.filter(fetchList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -1211,27 +1207,26 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
fetchList.remove(c);
|
||||
}
|
||||
|
||||
if (origin.contains(ZoneType.Library) && !defined && !"False".equals(params.get("Shuffle"))) {
|
||||
if (origin.contains(ZoneType.Library) && !defined && !"False".equals(sa.getParam("Shuffle"))) {
|
||||
player.shuffle();
|
||||
}
|
||||
|
||||
for (final Card c : fetched) {
|
||||
Card movedCard = null;
|
||||
if (ZoneType.Library.equals(destination)) {
|
||||
final int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params
|
||||
.get("LibraryPosition")) : 0;
|
||||
final int libraryPos = sa.hasParam("LibraryPosition") ? Integer.parseInt(sa.getParam("LibraryPosition")) : 0;
|
||||
movedCard = Singletons.getModel().getGame().getAction().moveToLibrary(c, libraryPos);
|
||||
} else if (ZoneType.Battlefield.equals(destination)) {
|
||||
if (params.containsKey("Tapped")) {
|
||||
if (sa.hasParam("Tapped")) {
|
||||
c.setTapped(true);
|
||||
}
|
||||
if (params.containsKey("GainControl")) {
|
||||
if (sa.hasParam("GainControl")) {
|
||||
c.addController(sa.getSourceCard());
|
||||
}
|
||||
|
||||
if (params.containsKey("AttachedTo")) {
|
||||
if (sa.hasParam("AttachedTo")) {
|
||||
final ArrayList<Card> list = AbilityFactory.getDefinedCards(sa.getSourceCard(),
|
||||
params.get("AttachedTo"), sa);
|
||||
sa.getParam("AttachedTo"), sa);
|
||||
if (!list.isEmpty()) {
|
||||
final Card attachedTo = list.get(0);
|
||||
if (c.isEnchanting()) {
|
||||
@@ -1246,7 +1241,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("Attacking")) {
|
||||
if (sa.hasParam("Attacking")) {
|
||||
Singletons.getModel().getGame().getCombat().addAttacker(c);
|
||||
}
|
||||
// Auras without Candidates stay in their current location
|
||||
@@ -1258,12 +1253,12 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
movedCard = Singletons.getModel().getGame().getAction().moveTo(c.getController().getZone(destination), c);
|
||||
if (params.containsKey("Tapped")) {
|
||||
if (sa.hasParam("Tapped")) {
|
||||
movedCard.setTapped(true);
|
||||
}
|
||||
} else if (destination.equals(ZoneType.Exile)) {
|
||||
movedCard = Singletons.getModel().getGame().getAction().exile(c);
|
||||
if (params.containsKey("ExileFaceDown")) {
|
||||
if (sa.hasParam("ExileFaceDown")) {
|
||||
movedCard.setState(CardCharacteristicName.FaceDown);
|
||||
}
|
||||
} else {
|
||||
@@ -1283,7 +1278,7 @@ public class ChangeZoneAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if ((origin.contains(ZoneType.Library) && !destination.equals(ZoneType.Library) && !defined)
|
||||
|| (params.containsKey("Shuffle") && "True".equals(params.get("Shuffle")))) {
|
||||
|| (sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle")))) {
|
||||
player.shuffle();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -25,12 +24,12 @@ public class ChangeZoneAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// Change Zone All, can be any type moving from one zone to another
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(sa.getParam("Origin"));
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -56,9 +55,9 @@ public class ChangeZoneAllAi extends SpellAiLogic {
|
||||
// ex. "Return all blocking/blocked by target creature"
|
||||
|
||||
final Player opp = ai.getOpponent();
|
||||
final List<Card> humanType = AbilityFactory.filterListByType(opp.getCardsIn(origin), params.get("ChangeType"), sa);
|
||||
final List<Card> humanType = AbilityFactory.filterListByType(opp.getCardsIn(origin), sa.getParam("ChangeType"), sa);
|
||||
List<Card> computerType = ai.getCardsIn(origin);
|
||||
computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa);
|
||||
computerType = AbilityFactory.filterListByType(computerType, sa.getParam("ChangeType"), sa);
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
// TODO improve restrictions on when the AI would want to use this
|
||||
@@ -124,7 +123,7 @@ public class ChangeZoneAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (destination.equals(ZoneType.Battlefield)) {
|
||||
if (params.get("GainControl") != null) {
|
||||
if (sa.getParam("GainControl") != null) {
|
||||
// Check if the cards are valuable enough
|
||||
if ((CardLists.getNotType(humanType, "Creature").size() == 0) && (CardLists.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerType) + CardFactoryUtil
|
||||
@@ -160,15 +159,15 @@ public class ChangeZoneAllAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* changeZoneAllPlayDrawbackAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// if putting cards from hand to library and parent is drawing cards
|
||||
// make sure this will actually do something:
|
||||
|
||||
@@ -177,16 +176,16 @@ public class ChangeZoneAllAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
// Change Zone All, can be any type moving from one zone to another
|
||||
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
final ZoneType destination = ZoneType.smartValueOf(sa.getParam("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(sa.getParam("Origin"));
|
||||
|
||||
final Player opp = ai.getOpponent();
|
||||
final List<Card> humanType = AbilityFactory.filterListByType(opp.getCardsIn(origin), params.get("ChangeType"), sa);
|
||||
final List<Card> humanType = AbilityFactory.filterListByType(opp.getCardsIn(origin), sa.getParam("ChangeType"), sa);
|
||||
List<Card> computerType = ai.getCardsIn(origin);
|
||||
computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa);
|
||||
computerType = AbilityFactory.filterListByType(computerType, sa.getParam("ChangeType"), sa);
|
||||
|
||||
// TODO improve restrictions on when the AI would want to use this
|
||||
// spBounceAll has some AI we can compare to.
|
||||
@@ -237,7 +236,7 @@ public class ChangeZoneAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (destination.equals(ZoneType.Battlefield)) {
|
||||
if (params.get("GainControl") != null) {
|
||||
if (sa.getParam("GainControl") != null) {
|
||||
// Check if the cards are valuable enough
|
||||
if ((CardLists.getNotType(humanType, "Creature").size() == 0) && (CardLists.getNotType(computerType, "Creature").size() == 0)) {
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerType) + CardFactoryUtil
|
||||
|
||||
@@ -14,14 +14,14 @@ import forge.util.MyRandom;
|
||||
public class CharmAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
final int num = Integer.parseInt(params.containsKey("CharmNum") ? params.get("CharmNum") : "1");
|
||||
final int min = params.containsKey("MinCharmNum") ? Integer.parseInt(params.get("MinCharmNum")) : num;
|
||||
final int num = Integer.parseInt(sa.hasParam("CharmNum") ? sa.getParam("CharmNum") : "1");
|
||||
final int min = sa.hasParam("MinCharmNum") ? Integer.parseInt(sa.getParam("MinCharmNum")) : num;
|
||||
boolean timingRight = sa.isTrigger(); //is there a reason to play the charm now?
|
||||
|
||||
List<AbilitySub> chooseFrom = CharmEffect.makePossibleOptions(sa, params);
|
||||
List<AbilitySub> chooseFrom = CharmEffect.makePossibleOptions(sa);
|
||||
List<AbilitySub> chosenList = chooseOptionsAi(ai, timingRight, chooseFrom, num, min);
|
||||
|
||||
if (chosenList == null || chosenList.isEmpty()) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
@@ -18,7 +17,7 @@ public class ChooseCardAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -30,27 +29,27 @@ public class ChooseCardAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (params.containsKey("AILogic")) {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
ZoneType choiceZone = ZoneType.Battlefield;
|
||||
if (params.containsKey("ChoiceZone")) {
|
||||
choiceZone = ZoneType.smartValueOf(params.get("ChoiceZone"));
|
||||
if (sa.hasParam("ChoiceZone")) {
|
||||
choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone"));
|
||||
}
|
||||
List<Card> choices = Singletons.getModel().getGame().getCardsIn(choiceZone);
|
||||
if (params.containsKey("Choices")) {
|
||||
choices = CardLists.getValidCards(choices, params.get("Choices"), host.getController(), host);
|
||||
if (sa.hasParam("Choices")) {
|
||||
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), host.getController(), host);
|
||||
}
|
||||
if (params.containsKey("TargetControls")) {
|
||||
if (sa.hasParam("TargetControls")) {
|
||||
choices = CardLists.filterControlledBy(choices, ai.getOpponent());
|
||||
}
|
||||
if (params.get("AILogic").equals("AtLeast1")) {
|
||||
if (sa.getParam("AILogic").equals("AtLeast1")) {
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (params.get("AILogic").equals("AtLeast2") || params.get("AILogic").equals("BestBlocker")) {
|
||||
} else if (sa.getParam("AILogic").equals("AtLeast2") || sa.getParam("AILogic").equals("BestBlocker")) {
|
||||
if (choices.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
} else if (params.get("AILogic").equals("Clone")) {
|
||||
} else if (sa.getParam("AILogic").equals("Clone")) {
|
||||
choices = CardLists.getValidCards(choices, "Permanent.YouDontCtrl,Permanent.NonLegendary", host.getController(), host);
|
||||
if (choices.isEmpty()) {
|
||||
return false;
|
||||
@@ -62,7 +61,7 @@ public class ChooseCardAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, params, sa);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
}
|
||||
@@ -10,15 +10,15 @@ public class ChooseCardNameAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
if (params.containsKey("AILogic")) {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
// Don't tap creatures that may be able to block
|
||||
if (ComputerUtil.waitForBlocking(sa)) {
|
||||
return false;
|
||||
@@ -39,7 +39,7 @@ public class ChooseCardNameAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
// TODO - there is no AILogic implemented yet
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ public class ChooseColorAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
if (!params.containsKey("AILogic")) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if (!sa.hasParam("AILogic")) {
|
||||
return false;
|
||||
}
|
||||
boolean chance = MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
@@ -18,14 +18,14 @@ public class ChooseColorAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
return mandatory || canPlayAI(ai, params, sa);
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
return mandatory || canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,28 +10,28 @@ import forge.game.player.Player;
|
||||
|
||||
public class ChooseTypeAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
if (!params.containsKey("AILogic")) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if (!sa.hasParam("AILogic")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return doTriggerAINoCost(aiPlayer, params, sa, false);
|
||||
return doTriggerAINoCost(aiPlayer, sa, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (sa.getTarget() != null) {
|
||||
tgt.resetTargets();
|
||||
sa.getTarget().addTarget(ai);
|
||||
} else {
|
||||
final ArrayList<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
final ArrayList<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
for (final Player p : tgtPlayers) {
|
||||
if (p.isHuman() && !mandatory) {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -13,7 +12,7 @@ public class ClashAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,7 +20,7 @@ public class ClashAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +28,7 @@ public class ClashAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Player opp = ai.getOpponent();
|
||||
if (tgt != null) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
@@ -16,7 +14,7 @@ import forge.game.player.Player;
|
||||
public class CloneAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -39,7 +37,7 @@ public class CloneAi extends SpellAiLogic {
|
||||
// Combat_Begin step
|
||||
if (!phase.is(PhaseType.COMBAT_BEGIN)
|
||||
&& phase.isPlayerTurn(ai) && !AbilityFactory.isSorcerySpeed(sa)
|
||||
&& !params.containsKey("ActivationPhases") && !params.containsKey("Permanent")) {
|
||||
&& !sa.hasParam("ActivationPhases") && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,26 +49,26 @@ public class CloneAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
// don't activate during main2 unless this effect is permanent
|
||||
if (phase.is(PhaseType.MAIN2) && !params.containsKey("Permanent")) {
|
||||
if (phase.is(PhaseType.MAIN2) && !sa.hasParam("Permanent")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == tgt) {
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
|
||||
boolean bFlag = false;
|
||||
for (final Card c : defined) {
|
||||
bFlag |= (!c.isCreature() && !c.isTapped() && !(c.getTurnInZone() == phase.getTurn()));
|
||||
|
||||
// for creatures that could be improved (like Figure of Destiny)
|
||||
if (c.isCreature() && (params.containsKey("Permanent") || (!c.isTapped() && !c.isSick()))) {
|
||||
if (c.isCreature() && (sa.hasParam("Permanent") || (!c.isTapped() && !c.isSick()))) {
|
||||
int power = -5;
|
||||
if (params.containsKey("Power")) {
|
||||
power = AbilityFactory.calculateAmount(source, params.get("Power"), sa);
|
||||
if (sa.hasParam("Power")) {
|
||||
power = AbilityFactory.calculateAmount(source, sa.getParam("Power"), sa);
|
||||
}
|
||||
int toughness = -5;
|
||||
if (params.containsKey("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(source, params.get("Toughness"), sa);
|
||||
if (sa.hasParam("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(source, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
if ((power + toughness) > (c.getCurrentPower() + c.getCurrentToughness())) {
|
||||
bFlag = true;
|
||||
@@ -85,19 +83,19 @@ public class CloneAi extends SpellAiLogic {
|
||||
}
|
||||
} else {
|
||||
tgt.resetTargets();
|
||||
useAbility &= cloneTgtAI(params, sa);
|
||||
useAbility &= cloneTgtAI(sa);
|
||||
}
|
||||
|
||||
return useAbility;
|
||||
} // end cloneCanPlayAI()
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// AI should only activate this during Human's turn
|
||||
boolean chance = true;
|
||||
|
||||
if (sa.getTarget() != null) {
|
||||
chance = cloneTgtAI(params, sa);
|
||||
chance = cloneTgtAI(sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,12 +103,12 @@ public class CloneAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
boolean chance = true;
|
||||
|
||||
if (sa.getTarget() != null) {
|
||||
chance = cloneTgtAI(params, sa);
|
||||
chance = cloneTgtAI(sa);
|
||||
}
|
||||
|
||||
// Improve AI for triggers. If source is a creature with:
|
||||
@@ -134,7 +132,7 @@ public class CloneAi extends SpellAiLogic {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean cloneTgtAI(final Map<String, String> params, final SpellAbility sa) {
|
||||
private boolean cloneTgtAI(final SpellAbility sa) {
|
||||
// This is reasonable for now. Kamahl, Fist of Krosa and a sorcery or
|
||||
// two are the only things
|
||||
// that clone a target. Those can just use SVar:RemAIDeck:True until
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ControlExchangeAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, final SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, final SpellAbility sa) {
|
||||
Card object1 = null;
|
||||
Card object2 = null;
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -40,8 +40,8 @@ public class ControlExchangeAi extends SpellAiLogic {
|
||||
}
|
||||
});
|
||||
object1 = CardFactoryUtil.getBestAI(list);
|
||||
if (params.containsKey("Defined")) {
|
||||
object2 = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa).get(0);
|
||||
if (sa.hasParam("Defined")) {
|
||||
object2 = AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa).get(0);
|
||||
} else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) {
|
||||
List<Card> list2 = ai.getCardsIn(ZoneType.Battlefield);
|
||||
list2 = CardLists.getValidCards(list2, tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
@@ -59,7 +59,7 @@ public class ControlExchangeAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// check AI life before playing this drawback?
|
||||
return true;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ControlExchangeAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import forge.game.zone.ZoneType;
|
||||
|
||||
//AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx
|
||||
|
||||
//GainControl specific params:
|
||||
//GainControl specific sa:
|
||||
// LoseControl - the lose control conditions (as a comma separated list)
|
||||
// -Untap - source card becomes untapped
|
||||
// -LoseControl - you lose control of source card
|
||||
@@ -62,13 +62,13 @@ import forge.game.zone.ZoneType;
|
||||
*/
|
||||
public class ControlGainAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, final SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, final SpellAbility sa) {
|
||||
boolean hasCreature = false;
|
||||
boolean hasArtifact = false;
|
||||
boolean hasEnchantment = false;
|
||||
boolean hasLand = false;
|
||||
|
||||
final List<String> lose = params.containsKey("LoseControl") ? Arrays.asList(params.get("LoseControl").split(",")) : null;
|
||||
final List<String> lose = sa.hasParam("LoseControl") ? Arrays.asList(sa.getParam("LoseControl").split(",")) : null;
|
||||
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -163,36 +163,36 @@ public class ControlGainAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
if (sa.getTarget() == null) {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return this.canPlayAI(ai, params, sa);
|
||||
return this.canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, final Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, final Player ai) {
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
if (params.containsKey("AllValid")) {
|
||||
if (sa.hasParam("AllValid")) {
|
||||
List<Card> tgtCards = CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), ai.getOpponent());
|
||||
tgtCards = AbilityFactory.filterListByType(tgtCards, params.get("AllValid"), sa);
|
||||
tgtCards = AbilityFactory.filterListByType(tgtCards, sa.getParam("AllValid"), sa);
|
||||
if (tgtCards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> lose = params.containsKey("LoseControl") ? Arrays.asList(params.get("LoseControl").split(",")) : null;
|
||||
final List<String> lose = sa.hasParam("LoseControl") ? Arrays.asList(sa.getParam("LoseControl").split(",")) : null;
|
||||
if ((lose != null) && lose.contains("EOT")
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return this.canPlayAI(ai, params, sa);
|
||||
return this.canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -24,11 +23,11 @@ public class CopyPermanentAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// Card source = sa.getSourceCard();
|
||||
// TODO - I'm sure someone can do this AI better
|
||||
|
||||
if (params.containsKey("AtEOT") && !Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
if (sa.hasParam("AtEOT") && !Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN1)) {
|
||||
return false;
|
||||
} else {
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
@@ -38,7 +37,7 @@ public class CopyPermanentAi extends SpellAiLogic {
|
||||
}
|
||||
final Random r = MyRandom.getRandom();
|
||||
if (r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1)) {
|
||||
return this.doTriggerAINoCost(aiPlayer, params, sa, false);
|
||||
return this.doTriggerAINoCost(aiPlayer, sa, false);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -46,12 +45,12 @@ public class CopyPermanentAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
// ////
|
||||
|
||||
@@ -17,9 +17,9 @@ import forge.util.MyRandom;
|
||||
public class CounterAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
boolean toReturn = true;
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
if (Singletons.getModel().getGame().getStack().size() < 1) {
|
||||
return false;
|
||||
@@ -42,8 +42,8 @@ public class CounterAi extends SpellAiLogic {
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getSourceCard(), sa) || topSA.getActivatingPlayer().isComputer()) {
|
||||
return false;
|
||||
}
|
||||
if (params.containsKey("AITgts") && (topSA.getSourceCard() == null
|
||||
|| !topSA.getSourceCard().isValid(params.get("AITgts"), sa.getActivatingPlayer(), source))) {
|
||||
if (sa.hasParam("AITgts") && (topSA.getSourceCard() == null
|
||||
|| !topSA.getSourceCard().isValid(sa.getParam("AITgts"), sa.getActivatingPlayer(), source))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CounterAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
String unlessCost = params.containsKey("UnlessCost") ? params.get("UnlessCost").trim() : null;
|
||||
String unlessCost = sa.hasParam("UnlessCost") ? sa.getParam("UnlessCost").trim() : null;
|
||||
|
||||
if (unlessCost != null && !unlessCost.endsWith(">")) {
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
@@ -100,12 +100,12 @@ public class CounterAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
return doTriggerAINoCost(aiPlayer, params, sa, true);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return doTriggerAINoCost(aiPlayer, sa, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
boolean toReturn = true;
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -122,7 +122,7 @@ public class CounterAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
String unlessCost = params.containsKey("UnlessCost") ? params.get("UnlessCost").trim() : null;
|
||||
String unlessCost = sa.hasParam("UnlessCost") ? sa.getParam("UnlessCost").trim() : null;
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
if (unlessCost != null) {
|
||||
|
||||
@@ -18,12 +18,12 @@ import forge.util.MyRandom;
|
||||
|
||||
public class CountersMoveAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what
|
||||
// the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final String amountStr = params.get("CounterNum");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
|
||||
// TODO handle proper calculation of X values based on Cost
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
@@ -44,18 +44,18 @@ public class CountersMoveAi extends SpellAiLogic {
|
||||
} // moveCounterCanPlayAI
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Target abTgt = sa.getTarget();
|
||||
final String type = params.get("CounterType");
|
||||
final String amountStr = params.get("CounterNum");
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getAbilityFactory().getHostCard(), amountStr, sa);
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
boolean chance = false;
|
||||
boolean preferred = true;
|
||||
|
||||
final Counters cType = Counters.valueOf(params.get("CounterType"));
|
||||
final ArrayList<Card> srcCards = AbilityFactory.getDefinedCards(host, params.get("Source"), sa);
|
||||
final ArrayList<Card> destCards = AbilityFactory.getDefinedCards(host, params.get("Defined"), sa);
|
||||
final Counters cType = Counters.valueOf(sa.getParam("CounterType"));
|
||||
final ArrayList<Card> srcCards = AbilityFactory.getDefinedCards(host, sa.getParam("Source"), sa);
|
||||
final ArrayList<Card> destCards = AbilityFactory.getDefinedCards(host, sa.getParam("Defined"), sa);
|
||||
if (abTgt == null) {
|
||||
if ((srcCards.size() > 0)
|
||||
&& cType.equals(Counters.P1P1) // move +1/+1 counters away
|
||||
@@ -68,8 +68,7 @@ public class CountersMoveAi extends SpellAiLogic {
|
||||
chance = true;
|
||||
}
|
||||
} else { // targeted
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
final Player player = isCurse ? ai.getOpponent() : ai;
|
||||
final Player player = sa.isCurse() ? ai.getOpponent() : ai;
|
||||
List<Card> list = CardLists.getTargetableCards(player.getCardsIn(ZoneType.Battlefield), sa);
|
||||
list = CardLists.getValidCards(list, abTgt.getValidTgts(), host.getController(), host);
|
||||
if (list.isEmpty() && mandatory) {
|
||||
@@ -89,7 +88,7 @@ public class CountersMoveAi extends SpellAiLogic {
|
||||
Card choice = null;
|
||||
|
||||
// Choose targets here:
|
||||
if (isCurse) {
|
||||
if (sa.isCurse()) {
|
||||
if (preferred) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
@@ -17,7 +16,7 @@ import forge.game.zone.ZoneType;
|
||||
public class CountersProliferateAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
boolean chance = true;
|
||||
|
||||
List<Card> cperms = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
|
||||
@@ -51,7 +50,7 @@ public class CountersProliferateAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance = true;
|
||||
|
||||
// TODO Make sure Human has poison counters or there are some counters
|
||||
@@ -64,8 +63,8 @@ public class CountersProliferateAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, params, sa);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -26,7 +25,7 @@ import forge.util.MyRandom;
|
||||
|
||||
public class CountersPutAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, final SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, final SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on
|
||||
// what the expected targets could be
|
||||
@@ -36,11 +35,10 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
final Card source = sa.getSourceCard();
|
||||
List<Card> list;
|
||||
Card choice = null;
|
||||
final String type = params.get("CounterType");
|
||||
final String amountStr = params.get("CounterNum");
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
final Player player = isCurse ? ai.getOpponent() : ai;
|
||||
final Player player = sa.isCurse() ? ai.getOpponent() : ai;
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
@@ -115,7 +113,7 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCurse) {
|
||||
if (sa.isCurse()) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
} else {
|
||||
choice = CountersAi.chooseBoonTarget(list, type);
|
||||
@@ -136,7 +134,7 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
}
|
||||
} else {
|
||||
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(),
|
||||
params.get("Defined"), sa);
|
||||
sa.getParam("Defined"), sa);
|
||||
// Don't activate Curse abilities on my cards and non-curse abilites
|
||||
// on my opponents
|
||||
if (cards.isEmpty() || !cards.get(0).getController().equals(player)) {
|
||||
@@ -154,7 +152,7 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
|
||||
// Don't use non P1P1/M1M1 counters before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")
|
||||
&& !sa.hasParam("ActivationPhases")
|
||||
&& !(type.equals("P1P1") || type.equals("M1M1"))) {
|
||||
return false;
|
||||
}
|
||||
@@ -167,17 +165,16 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
} // putCanPlayAI
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String,String> params, final SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(final SpellAbility sa, Player ai) {
|
||||
boolean chance = true;
|
||||
final Target abTgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
Card choice = null;
|
||||
final String type = params.get("CounterType");
|
||||
final String amountStr = params.get("CounterNum");
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
final Player player = isCurse ? ai.getOpponent() : ai;
|
||||
final Player player = sa.isCurse() ? ai.getOpponent() : ai;
|
||||
|
||||
if (abTgt != null) {
|
||||
List<Card> list =
|
||||
@@ -206,7 +203,7 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCurse) {
|
||||
if (sa.isCurse()) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
} else {
|
||||
choice = CountersAi.chooseBoonTarget(list, type);
|
||||
@@ -231,21 +228,21 @@ public class CountersPutAi extends SpellAiLogic {
|
||||
} // putPlayDrawbackAI
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target abTgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
// boolean chance = true;
|
||||
boolean preferred = true;
|
||||
List<Card> list;
|
||||
boolean isCurse = sa.getAbilityFactory().isCurse();
|
||||
boolean isCurse = sa.isCurse();
|
||||
final Player player = isCurse ? ai.getOpponent() : ai;
|
||||
final String type = params.get("CounterType");
|
||||
final String amountStr = params.get("CounterNum");
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), amountStr, sa);
|
||||
|
||||
if (abTgt == null) {
|
||||
// No target. So must be defined
|
||||
list = new ArrayList<Card>(AbilityFactory.getDefinedCards(source, params.get("Defined"), sa));
|
||||
list = new ArrayList<Card>(AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa));
|
||||
|
||||
if (!mandatory) {
|
||||
// TODO - If Trigger isn't mandatory, when wouldn't we want to
|
||||
|
||||
@@ -24,7 +24,7 @@ import forge.util.MyRandom;
|
||||
|
||||
public class CountersPutAllAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what
|
||||
// the expected targets could be
|
||||
@@ -33,10 +33,10 @@ public class CountersPutAllAi extends SpellAiLogic {
|
||||
final Card source = sa.getSourceCard();
|
||||
List<Card> hList;
|
||||
List<Card> cList;
|
||||
final String type = params.get("CounterType");
|
||||
final String amountStr = params.get("CounterNum");
|
||||
final String valid = params.get("ValidCards");
|
||||
final boolean curse = sa.getAbilityFactory().isCurse();
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String amountStr = sa.getParam("CounterNum");
|
||||
final String valid = sa.getParam("ValidCards");
|
||||
final boolean curse = sa.isCurse();
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
hList = CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
@@ -131,7 +131,7 @@ public class CountersPutAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, params, sa);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import forge.util.MyRandom;
|
||||
public class CountersRemoveAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what
|
||||
// the expected targets could be
|
||||
@@ -28,8 +28,8 @@ public class CountersRemoveAi extends SpellAiLogic {
|
||||
// List<Card> list;
|
||||
// Card choice = null;
|
||||
|
||||
final String type = params.get("CounterType");
|
||||
// String amountStr = params.get("CounterNum");
|
||||
final String type = sa.getParam("CounterType");
|
||||
// String amountStr = sa.get("CounterNum");
|
||||
|
||||
// TODO - currently, not targeted, only for Self
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CountersRemoveAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")
|
||||
&& !sa.hasParam("ActivationPhases")
|
||||
&& !type.equals("M1M1")) {
|
||||
return false;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class CountersRemoveAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what the
|
||||
// expected targets could be
|
||||
|
||||
@@ -26,9 +26,9 @@ public abstract class DamageAiBase extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (!noPrevention) {
|
||||
restDamage = enemy.predictDamage(restDamage, sa.getAbilityFactory().getHostCard(), false);
|
||||
restDamage = enemy.predictDamage(restDamage, sa.getSourceCard(), false);
|
||||
} else {
|
||||
restDamage = enemy.staticReplaceDamage(restDamage, sa.getAbilityFactory().getHostCard(), false);
|
||||
restDamage = enemy.staticReplaceDamage(restDamage, sa.getSourceCard(), false);
|
||||
}
|
||||
|
||||
if (restDamage == 0) {
|
||||
@@ -41,7 +41,7 @@ public abstract class DamageAiBase extends SpellAiLogic {
|
||||
|
||||
final List<Card> hand = comp.getCardsIn(ZoneType.Hand);
|
||||
|
||||
if (sa.getAbilityFactory().isSpell()) {
|
||||
if (sa.isSpell()) {
|
||||
// If this is a spell, cast it instead of discarding
|
||||
if ((Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN) || Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.MAIN2))
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -26,7 +25,7 @@ public class DamageAllAi extends SpellAiLogic
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
@@ -35,7 +34,7 @@ public class DamageAllAi extends SpellAiLogic
|
||||
|
||||
String validP = "";
|
||||
|
||||
final String damage = params.get("NumDmg");
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
|
||||
|
||||
@@ -45,14 +44,14 @@ public class DamageAllAi extends SpellAiLogic
|
||||
source.setSVar("PayX", Integer.toString(dmg));
|
||||
}
|
||||
|
||||
if (params.containsKey("ValidPlayers")) {
|
||||
validP = params.get("ValidPlayers");
|
||||
if (sa.hasParam("ValidPlayers")) {
|
||||
validP = sa.getParam("ValidPlayers");
|
||||
}
|
||||
|
||||
Player opp = ai.getOpponent();
|
||||
|
||||
final List<Card> humanList = this.getKillableCreatures(params, sa.getSourceCard(), opp, dmg);
|
||||
List<Card> computerList = this.getKillableCreatures(params, sa.getSourceCard(), opp, dmg);
|
||||
final List<Card> humanList = this.getKillableCreatures(sa, opp, dmg);
|
||||
List<Card> computerList = this.getKillableCreatures(sa, ai, dmg);
|
||||
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -107,7 +106,7 @@ public class DamageAllAi extends SpellAiLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// check AI life before playing this drawback?
|
||||
return true;
|
||||
}
|
||||
@@ -127,8 +126,9 @@ public class DamageAllAi extends SpellAiLogic
|
||||
* a int.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private List<Card> getKillableCreatures(final Map<String, String> params, final Card source, final Player player, final int dmg) {
|
||||
String validC = params.containsKey("ValidCards") ? params.get("ValidCards") : "";
|
||||
private List<Card> getKillableCreatures(final SpellAbility sa, final Player player, final int dmg) {
|
||||
final Card source = sa.getSourceCard();
|
||||
String validC = sa.hasParam("ValidCards") ? sa.getParam("ValidCards") : "";
|
||||
|
||||
// TODO: X may be something different than X paid
|
||||
List<Card> list =
|
||||
@@ -148,11 +148,11 @@ public class DamageAllAi extends SpellAiLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
String validP = "";
|
||||
|
||||
final String damage = params.get("NumDmg");
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
|
||||
|
||||
@@ -162,8 +162,8 @@ public class DamageAllAi extends SpellAiLogic
|
||||
source.setSVar("PayX", Integer.toString(dmg));
|
||||
}
|
||||
|
||||
if (params.containsKey("ValidPlayers")) {
|
||||
validP = params.get("ValidPlayers");
|
||||
if (sa.hasParam("ValidPlayers")) {
|
||||
validP = sa.getParam("ValidPlayers");
|
||||
}
|
||||
|
||||
Player enemy = ai.getOpponent();
|
||||
@@ -190,8 +190,8 @@ public class DamageAllAi extends SpellAiLogic
|
||||
}
|
||||
|
||||
// Evaluate creatures getting killed
|
||||
final List<Card> humanList = this.getKillableCreatures(params, sa.getSourceCard(), enemy, dmg);
|
||||
final List<Card> computerList = this.getKillableCreatures(params, sa.getSourceCard(), ai, dmg);
|
||||
final List<Card> humanList = this.getKillableCreatures(sa, enemy, dmg);
|
||||
final List<Card> computerList = this.getKillableCreatures(sa, ai, dmg);
|
||||
if ((CardFactoryUtil.evaluateCreatureList(computerList) + 50) >= CardFactoryUtil
|
||||
.evaluateCreatureList(humanList)) {
|
||||
return false;
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -26,8 +25,8 @@ import forge.util.MyRandom;
|
||||
|
||||
public class DamageDealAi extends DamageAiBase {
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
final String damage = params.get("NumDmg");
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -37,19 +36,19 @@ public class DamageDealAi extends DamageAiBase {
|
||||
dmg = ComputerUtil.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(dmg));
|
||||
}
|
||||
if(!this.damageTargetAI(ai, params, sa, dmg)) {
|
||||
if(!this.damageTargetAI(ai, sa, dmg)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final String damage = params.get("NumDmg");
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
@@ -81,7 +80,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
return Singletons.getModel().getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai.getOpponent());
|
||||
}
|
||||
|
||||
if (sa.getAbilityFactory().isAbility()) {
|
||||
if (sa.isAbility()) {
|
||||
final Random r = MyRandom.getRandom(); // prevent run-away
|
||||
// activations
|
||||
if (r.nextFloat() > Math.pow(.9, sa.getActivationsThisTurn())) {
|
||||
@@ -89,7 +88,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.damageTargetAI(ai, params, sa, dmg)) {
|
||||
if (!this.damageTargetAI(ai, sa, dmg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null && tgt.getTargetPlayers().isEmpty()) {
|
||||
int actualPay = 0;
|
||||
final boolean noPrevention = params.containsKey("NoPrevention");
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
final ArrayList<Card> cards = tgt.getTargetCards();
|
||||
for (final Card c : cards) {
|
||||
final int adjDamage = c.getEnoughDamageToKill(dmg, source, false, noPrevention);
|
||||
@@ -127,7 +126,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* a boolean.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
private Card dealDamageChooseTgtC(final Player ai, final Map<String, String> params, final SpellAbility saMe, final int d, final boolean noPrevention,
|
||||
private Card dealDamageChooseTgtC(final Player ai, final SpellAbility saMe, final int d, final boolean noPrevention,
|
||||
final Player pl, final boolean mandatory) {
|
||||
|
||||
// wait until stack is empty (prevents duplicate kills)
|
||||
@@ -139,7 +138,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source);
|
||||
|
||||
final ArrayList<Object> objects = tgt.getTargets();
|
||||
if (params.containsKey("TargetUnique")) {
|
||||
if (saMe.hasParam("TargetUnique")) {
|
||||
objects.addAll(TargetSelection.getUniqueTargets(saMe));
|
||||
}
|
||||
for (final Object o : objects) {
|
||||
@@ -195,14 +194,14 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* a int.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean damageTargetAI(final Player ai, final Map<String, String> params, final SpellAbility saMe, final int dmg) {
|
||||
private boolean damageTargetAI(final Player ai, final SpellAbility saMe, final int dmg) {
|
||||
final Target tgt = saMe.getTarget();
|
||||
|
||||
if (tgt == null) {
|
||||
return this.damageChooseNontargeted(saMe, params, dmg);
|
||||
return this.damageChooseNontargeted(saMe, dmg);
|
||||
}
|
||||
|
||||
return this.damageChoosingTargets(ai, params, saMe, tgt, dmg, false, false);
|
||||
return this.damageChoosingTargets(ai, saMe, tgt, dmg, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,9 +219,9 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean damageChoosingTargets(final Player ai, final Map<String, String> params, final SpellAbility saMe, final Target tgt, final int dmg,
|
||||
private boolean damageChoosingTargets(final Player ai, final SpellAbility saMe, final Target tgt, final int dmg,
|
||||
final boolean isTrigger, final boolean mandatory) {
|
||||
final boolean noPrevention = params.containsKey("NoPrevention");
|
||||
final boolean noPrevention = saMe.hasParam("NoPrevention");
|
||||
final PhaseHandler phase = Singletons.getModel().getGame().getPhaseHandler();
|
||||
|
||||
// target loop
|
||||
@@ -239,7 +238,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
}
|
||||
|
||||
final Card c = this.dealDamageChooseTgtC(ai, params, saMe, dmg, noPrevention, enemy, false);
|
||||
final Card c = this.dealDamageChooseTgtC(ai, saMe, dmg, noPrevention, enemy, false);
|
||||
if (c != null) {
|
||||
tgt.addTarget(c);
|
||||
continue;
|
||||
@@ -260,7 +259,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
continue;
|
||||
}
|
||||
} else if (tgt.canTgtCreature()) {
|
||||
final Card c = this.dealDamageChooseTgtC(ai, params, saMe, dmg, noPrevention, enemy, mandatory);
|
||||
final Card c = this.dealDamageChooseTgtC(ai, saMe, dmg, noPrevention, enemy, mandatory);
|
||||
if (c != null) {
|
||||
tgt.addTarget(c);
|
||||
continue;
|
||||
@@ -290,7 +289,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
} else {
|
||||
// If the trigger is mandatory, gotta choose my own stuff
|
||||
// now
|
||||
return this.damageChooseRequiredTargets(ai, params, saMe, tgt, dmg, mandatory);
|
||||
return this.damageChooseRequiredTargets(ai, saMe, tgt, dmg, mandatory);
|
||||
}
|
||||
} else {
|
||||
// TODO is this good enough? for up to amounts?
|
||||
@@ -311,16 +310,16 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* a int.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean damageChooseNontargeted(final SpellAbility saMe, final Map<String, String> params, final int dmg) {
|
||||
private boolean damageChooseNontargeted(final SpellAbility saMe, final int dmg) {
|
||||
// TODO: Improve circumstances where the Defined Damage is unwanted
|
||||
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), params.get("Defined"), saMe);
|
||||
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), saMe.getParam("Defined"), saMe);
|
||||
|
||||
for (final Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
// Card c = (Card)o;
|
||||
} else if (o instanceof Player) {
|
||||
final Player p = (Player) o;
|
||||
final int restDamage = p.predictDamage(dmg, saMe.getAbilityFactory().getHostCard(), false);
|
||||
final int restDamage = p.predictDamage(dmg, saMe.getSourceCard(), false);
|
||||
if (p.isComputer() && p.canLoseLife() && ((restDamage + 3) >= p.getLife()) && (restDamage > 0)) {
|
||||
// from this spell will kill me
|
||||
return false;
|
||||
@@ -348,15 +347,15 @@ public class DamageDealAi extends DamageAiBase {
|
||||
* a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private boolean damageChooseRequiredTargets(final Player ai, final Map<String, String> params, final SpellAbility saMe, final Target tgt, final int dmg,
|
||||
private boolean damageChooseRequiredTargets(final Player ai, final SpellAbility saMe, final Target tgt, final int dmg,
|
||||
final boolean mandatory) {
|
||||
// this is for Triggered targets that are mandatory
|
||||
final boolean noPrevention = params.containsKey("NoPrevention");
|
||||
final boolean noPrevention = saMe.hasParam("NoPrevention");
|
||||
|
||||
while (tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe)) {
|
||||
// TODO: Consider targeting the planeswalker
|
||||
if (tgt.canTgtCreature()) {
|
||||
final Card c = this.dealDamageChooseTgtC(ai, params, saMe, dmg, noPrevention, ai,
|
||||
final Card c = this.dealDamageChooseTgtC(ai, saMe, dmg, noPrevention, ai,
|
||||
mandatory);
|
||||
if (c != null) {
|
||||
tgt.addTarget(c);
|
||||
@@ -378,10 +377,10 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final String damage = params.get("NumDmg");
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
|
||||
if (damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) {
|
||||
@@ -393,18 +392,18 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt == null) {
|
||||
// If it's not mandatory check a few things
|
||||
if (!mandatory && !this.damageChooseNontargeted(sa, params, dmg)) {
|
||||
if (!mandatory && !this.damageChooseNontargeted(sa, dmg)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!this.damageChoosingTargets(ai, params, sa, tgt, dmg, true, mandatory) && !mandatory) {
|
||||
if (!this.damageChoosingTargets(ai, sa, tgt, dmg, true, mandatory) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
||||
// If I can kill my target by paying less mana, do it
|
||||
int actualPay = 0;
|
||||
final boolean noPrevention = params.containsKey("NoPrevention");
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
final ArrayList<Card> cards = tgt.getTargetCards();
|
||||
//target is a player
|
||||
if (cards.isEmpty()) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -13,7 +12,7 @@ public class DamageEachAi extends DamageAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (tgt != null && sa.canTarget(ai.getOpponent())) {
|
||||
@@ -21,13 +20,13 @@ public class DamageEachAi extends DamageAiBase {
|
||||
sa.getTarget().addTarget(ai.getOpponent());
|
||||
}
|
||||
|
||||
final String damage = params.get("NumDmg");
|
||||
final String damage = sa.getParam("NumDmg");
|
||||
final int iDmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||
return this.shouldTgtP(ai, sa, iDmg, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// check AI life before playing this drawback?
|
||||
return true;
|
||||
}
|
||||
@@ -36,9 +35,9 @@ public class DamageEachAi extends DamageAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
return canPlayAI(ai, params, sa);
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,13 +22,13 @@ import forge.game.zone.ZoneType;
|
||||
|
||||
public class DamagePreventAi extends SpellAiLogic {
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
boolean chance = false;
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -55,11 +55,11 @@ public class DamagePreventAi extends SpellAiLogic {
|
||||
// As far as I can tell these Defined Cards will only have one of
|
||||
// them
|
||||
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(sa.getSourceCard(),
|
||||
params.get("Defined"), sa);
|
||||
sa.getParam("Defined"), sa);
|
||||
|
||||
// react to threats on the stack
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
final ArrayList<Object> threatenedObjects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(), sa.getAbilityFactory());
|
||||
final ArrayList<Object> threatenedObjects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
for (final Object o : objects) {
|
||||
if (threatenedObjects.contains(o)) {
|
||||
chance = true;
|
||||
@@ -151,7 +151,7 @@ public class DamagePreventAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance = false;
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt == null) {
|
||||
@@ -183,7 +183,7 @@ public class DamagePreventAi extends SpellAiLogic {
|
||||
tgt.resetTargets();
|
||||
// filter AIs battlefield by what I can target
|
||||
List<Card> targetables = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getAbilityFactory().getHostCard());
|
||||
targetables = CardLists.getValidCards(targetables, tgt.getValidTgts(), ai, sa.getSourceCard());
|
||||
final List<Card> compTargetables = CardLists.filterControlledBy(targetables, ai);
|
||||
|
||||
if (targetables.size() == 0) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
@@ -17,7 +16,7 @@ public class DamagePreventAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,8 +24,8 @@ public class DamagePreventAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
boolean chance = false;
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -61,7 +60,7 @@ public class DamagePreventAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance = true;
|
||||
|
||||
return chance;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DebuffAi extends SpellAiLogic {
|
||||
// *************************************************************************
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, final java.util.Map<String,String> params, final SpellAbility sa) {
|
||||
protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
|
||||
// if there is no target and host card isn't in play, don't activate
|
||||
final Card source = sa.getSourceCard();
|
||||
if ((sa.getTarget() == null) && !source.isInPlay()) {
|
||||
@@ -72,7 +72,7 @@ public class DebuffAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
List<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
List<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
if (!cards.isEmpty()) {
|
||||
cards = CardLists.filter(cards, new Predicate<Card>() {
|
||||
@@ -82,7 +82,7 @@ public class DebuffAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
// don't add duplicate negative keywords
|
||||
return params.containsKey("Keywords") && c.hasAnyKeyword(Arrays.asList(params.get("Keywords").split(" & ")));
|
||||
return sa.hasParam("Keywords") && c.hasAnyKeyword(Arrays.asList(sa.getParam("Keywords").split(" & ")));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -90,19 +90,19 @@ public class DebuffAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return debuffTgtAI(ai, sa, params.containsKey("Keywords") ? Arrays.asList(params.get("Keywords").split(" & ")) : new ArrayList<String>(), false);
|
||||
return debuffTgtAI(ai, sa, sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>(), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
// TODO - copied from AF_Pump.pumpDrawbackAI() - what should be
|
||||
// here?
|
||||
} else {
|
||||
return debuffTgtAI(ai, sa, params.containsKey("Keywords") ? Arrays.asList(params.get("Keywords").split(" & ")) : new ArrayList<String>(), false);
|
||||
return debuffTgtAI(ai, sa, sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>(), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -279,8 +279,8 @@ public class DebuffAi extends SpellAiLogic {
|
||||
} // pumpMandatoryTarget()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
final List<String> kws = params.containsKey("Keywords") ? Arrays.asList(params.get("Keywords").split(" & ")) : new ArrayList<String>();
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>();
|
||||
|
||||
if (sa.getTarget() == null) {
|
||||
if (mandatory) {
|
||||
|
||||
@@ -18,11 +18,11 @@ import forge.util.MyRandom;
|
||||
|
||||
public class DebuffAllAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
String valid = "";
|
||||
final Random r = MyRandom.getRandom();
|
||||
// final Card source = sa.getSourceCard();
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
final boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to
|
||||
@@ -30,8 +30,8 @@ public class DebuffAllAi extends SpellAiLogic {
|
||||
// runaway
|
||||
// activations
|
||||
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> comp = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid, hostCard.getController(), hostCard);
|
||||
@@ -60,7 +60,7 @@ public class DebuffAllAi extends SpellAiLogic {
|
||||
} // debuffAllCanPlayAI()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,15 +68,15 @@ public class DebuffAllAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* debuffAllChkDrawbackAI.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@ public class DelayedTriggerAi extends SpellAiLogic {
|
||||
private static AbilityFactory tempCreator = new AbilityFactory();
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, forge.game.player.Player aiPlayer) {
|
||||
final String svarName = params.get("Execute");
|
||||
final SpellAbility trigsa = tempCreator.getAbility(sa.getAbilityFactory().getHostCard()
|
||||
.getSVar(svarName), sa.getAbilityFactory().getHostCard());
|
||||
public boolean chkAIDrawback(SpellAbility sa, forge.game.player.Player aiPlayer) {
|
||||
final String svarName = sa.getParam("Execute");
|
||||
final SpellAbility trigsa = tempCreator.getAbility(sa.getSourceCard().getSVar(svarName), sa.getSourceCard());
|
||||
|
||||
if (trigsa instanceof AbilitySub) {
|
||||
return ((AbilitySub) trigsa).chkAIDrawback();
|
||||
@@ -22,22 +21,21 @@ public class DelayedTriggerAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(forge.game.player.Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
final String svarName = params.get("Execute");
|
||||
final SpellAbility trigsa = tempCreator.getAbility(sa.getAbilityFactory().getHostCard()
|
||||
.getSVar(svarName), sa.getAbilityFactory().getHostCard());
|
||||
protected boolean doTriggerAINoCost(forge.game.player.Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final String svarName = sa.getParam("Execute");
|
||||
final SpellAbility trigsa = tempCreator.getAbility(sa.getSourceCard().getSVar(svarName), sa.getSourceCard());
|
||||
|
||||
if (!params.containsKey("OptionalDecider")) {
|
||||
if (!sa.hasParam("OptionalDecider")) {
|
||||
return trigsa.doTrigger(true);
|
||||
} else {
|
||||
return trigsa.doTrigger(!params.get("OptionalDecider").equals("You"));
|
||||
return trigsa.doTrigger(!sa.getParam("OptionalDecider").equals("You"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(forge.game.player.Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final String svarName = params.get("Execute");
|
||||
final SpellAbility trigsa = tempCreator.getAbility(sa.getAbilityFactory().getHostCard().getSVar(svarName), sa.getAbilityFactory().getHostCard());
|
||||
protected boolean canPlayAI(forge.game.player.Player aiPlayer, SpellAbility sa) {
|
||||
final String svarName = sa.getParam("Execute");
|
||||
final SpellAbility trigsa = tempCreator.getAbility(sa.getSourceCard().getSVar(svarName), sa.getSourceCard());
|
||||
return trigsa.canPlayAI();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -30,21 +29,21 @@ public class DestroyAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, params, sa);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Target abTgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final boolean noRegen = params.containsKey("NoRegen");
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
List<Card> list;
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -69,8 +68,8 @@ public class DestroyAi extends SpellAiLogic {
|
||||
abTgt.resetTargets();
|
||||
list = CardLists.getTargetableCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), sa);
|
||||
list = CardLists.getValidCards(list, abTgt.getValidTgts(), source.getController(), source);
|
||||
if (params.containsKey("AITgts")) {
|
||||
list = CardLists.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), source);
|
||||
if (sa.hasParam("AITgts")) {
|
||||
list = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), source);
|
||||
}
|
||||
list = CardLists.getNotKeyword(list, "Indestructible");
|
||||
if (!AbilityFactory.playReusable(ai, sa)) {
|
||||
@@ -135,8 +134,8 @@ public class DestroyAi extends SpellAiLogic {
|
||||
abTgt.addTarget(choice);
|
||||
}
|
||||
} else {
|
||||
if (params.containsKey("Defined")) {
|
||||
list = new ArrayList<Card>(AbilityFactory.getDefinedCards(source, params.get("Defined"), sa));
|
||||
if (sa.hasParam("Defined")) {
|
||||
list = new ArrayList<Card>(AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa));
|
||||
if (list.isEmpty()
|
||||
|| !CardLists.filterControlledBy(list, ai).isEmpty()
|
||||
|| CardLists.getNotKeyword(list, "Indestructible").isEmpty()) {
|
||||
@@ -149,10 +148,10 @@ public class DestroyAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final boolean noRegen = params.containsKey("NoRegen");
|
||||
final boolean noRegen = sa.hasParam("NoRegen");
|
||||
final Player opp = ai.getOpponent();
|
||||
if (tgt != null) {
|
||||
List<Card> list;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -32,15 +31,15 @@ public class DestroyAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
String valid = "";
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
List<Card> humanlist =
|
||||
CardLists.getValidCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source);
|
||||
@@ -74,12 +73,12 @@ public class DestroyAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(final Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
@@ -87,8 +86,8 @@ public class DestroyAllAi extends SpellAiLogic {
|
||||
final Card source = sa.getSourceCard();
|
||||
String valid = "";
|
||||
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
if (valid.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Singletons;
|
||||
@@ -19,7 +18,7 @@ public class DigAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
if (AbilityFactory.isSorcerySpeed(sa)) {
|
||||
chance = .667; // 66.7% chance for sorcery speed (since it will
|
||||
@@ -48,8 +47,8 @@ public class DigAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")
|
||||
&& !params.containsKey("DestinationZone")) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")
|
||||
&& !sa.hasParam("DestinationZone")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,12 +60,12 @@ public class DigAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (sa.getTarget() != null) {
|
||||
|
||||
@@ -14,7 +14,7 @@ public class DigUntilAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
double chance = .4; // 40 percent chance with instant speed stuff
|
||||
if (AbilityFactory.isSorcerySpeed(sa)) {
|
||||
chance = .667; // 66.7% chance for sorcery speed (since it will
|
||||
@@ -46,12 +46,12 @@ public class DigUntilAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -21,7 +20,7 @@ import forge.util.MyRandom;
|
||||
public class DiscardAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
@@ -55,7 +54,7 @@ public class DiscardAi extends SpellAiLogic {
|
||||
} else {
|
||||
// TODO: Add appropriate restrictions
|
||||
final List<Player> players = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||
params.get("Defined"), sa);
|
||||
sa.getParam("Defined"), sa);
|
||||
|
||||
if (players.size() == 1) {
|
||||
if (players.get(0).isComputer()) {
|
||||
@@ -75,8 +74,8 @@ public class DiscardAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.get("Mode").equals("Hand") && !params.get("Mode").equals("RevealDiscardAll")) {
|
||||
if (params.get("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
if (!sa.getParam("Mode").equals("Hand") && !sa.getParam("Mode").equals("RevealDiscardAll")) {
|
||||
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtil.determineLeftoverMana(sa, ai), ai.getOpponent()
|
||||
.getCardsIn(ZoneType.Hand).size());
|
||||
@@ -86,12 +85,12 @@ public class DiscardAi extends SpellAiLogic {
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't tap creatures that may be able to block
|
||||
if (ComputerUtil.waitForBlocking(sa) && !params.containsKey("ActivationPhases")) {
|
||||
if (ComputerUtil.waitForBlocking(sa) && !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ public class DiscardAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
Player opp = ai.getOpponent();
|
||||
@@ -140,7 +139,7 @@ public class DiscardAi extends SpellAiLogic {
|
||||
} // discardTrigger()
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// Drawback AI improvements
|
||||
// if parent draws cards, make sure cards in hand + cards drawn > 0
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -15,7 +14,7 @@ import forge.util.MyRandom;
|
||||
public class DrainManaAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -28,7 +27,7 @@ public class DrainManaAi extends SpellAiLogic {
|
||||
// assume we are looking to tap human's stuff
|
||||
// TODO - check for things with untap abilities, and don't tap
|
||||
// those.
|
||||
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
||||
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, sa.getParam("Defined"), sa);
|
||||
|
||||
if (!defined.contains(opp)) {
|
||||
return false;
|
||||
@@ -42,7 +41,7 @@ public class DrainManaAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Player opp = ai.getOpponent();
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -52,7 +51,7 @@ public class DrainManaAi extends SpellAiLogic {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
} else {
|
||||
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
||||
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, sa.getParam("Defined"), sa);
|
||||
|
||||
if (!defined.contains(opp)) {
|
||||
return false;
|
||||
@@ -69,7 +68,7 @@ public class DrainManaAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -77,7 +76,7 @@ public class DrainManaAi extends SpellAiLogic {
|
||||
boolean randomReturn = true;
|
||||
|
||||
if (tgt == null) {
|
||||
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
||||
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, sa.getParam("Defined"), sa);
|
||||
|
||||
if (defined.contains(ai)) {
|
||||
return false;
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
@@ -48,7 +47,7 @@ public class DrawAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -85,7 +84,7 @@ public class DrawAi extends SpellAiLogic {
|
||||
|
||||
}
|
||||
|
||||
final boolean bFlag = targetAI(ai, params, sa, false);
|
||||
final boolean bFlag = targetAI(ai, sa, false);
|
||||
|
||||
if (!bFlag) {
|
||||
return false;
|
||||
@@ -100,7 +99,7 @@ public class DrawAi extends SpellAiLogic {
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -128,7 +127,7 @@ public class DrawAi extends SpellAiLogic {
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
private boolean targetAI(final Player ai, final Map<String, String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
private boolean targetAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -145,12 +144,12 @@ public class DrawAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
int numCards = 1;
|
||||
if (params.containsKey("NumCards")) {
|
||||
numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumCards"), sa);
|
||||
if (sa.hasParam("NumCards")) {
|
||||
numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
|
||||
}
|
||||
|
||||
boolean xPaid = false;
|
||||
final String num = params.get("NumCards");
|
||||
final String num = sa.getParam("NumCards");
|
||||
if ((num != null) && num.equals("X") && source.getSVar(num).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
if (sa instanceof AbilitySub) {
|
||||
@@ -206,7 +205,7 @@ public class DrawAi extends SpellAiLogic {
|
||||
} else {
|
||||
// Don't draw too many cards and then risk discarding cards
|
||||
// at EOT
|
||||
if (!(params.containsKey("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
|
||||
if (!(sa.hasParam("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +242,7 @@ public class DrawAi extends SpellAiLogic {
|
||||
&& !sa.isTrigger()) {
|
||||
// Don't draw too many cards and then risk discarding cards at
|
||||
// EOT
|
||||
if (!(params.containsKey("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
|
||||
if (!(sa.hasParam("NextUpkeep") || (sa instanceof AbilitySub)) && !mandatory) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -253,8 +252,8 @@ public class DrawAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
return targetAI(ai, params, sa, mandatory);
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
return targetAI(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ import forge.util.MyRandom;
|
||||
|
||||
public class EffectAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final GameState game = Singletons.getModel().getGame();
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean randomReturn = r.nextFloat() <= .6667;
|
||||
final Player opp = ai.getOpponent();
|
||||
String logic = "";
|
||||
|
||||
if (params.containsKey("AILogic")) {
|
||||
logic = params.get("AILogic");
|
||||
if (sa.hasParam("AILogic")) {
|
||||
logic = sa.getParam("AILogic");
|
||||
final PhaseHandler phase = game.getPhaseHandler();
|
||||
if (logic.equals("BeginningOfOppTurn")) {
|
||||
if (phase.isPlayerTurn(ai) || phase.getPhase().isAfter(PhaseType.DRAW)) {
|
||||
@@ -93,10 +93,10 @@ public class EffectAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
final String stackable = params.get("Stackable");
|
||||
final String stackable = sa.getParam("Stackable");
|
||||
|
||||
if ((stackable != null) && stackable.equals("False")) {
|
||||
String name = params.get("Name");
|
||||
String name = sa.getParam("Name");
|
||||
if (name == null) {
|
||||
name = sa.getSourceCard().getName() + "'s Effect";
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class EffectAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
// TODO: Add targeting effects
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -13,18 +12,18 @@ import forge.game.player.Player;
|
||||
public class EndTurnAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) { return false; }
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) { return false; }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -20,7 +19,7 @@ public class FightAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
|
||||
@@ -41,7 +40,7 @@ public class FightAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params.containsKey("TargetsFromDifferentZone")) {
|
||||
if (sa.hasParam("TargetsFromDifferentZone")) {
|
||||
if (humCreatures.size() > 0 && aiCreatures.size() > 0) {
|
||||
for (Card humanCreature : humCreatures) {
|
||||
for (Card aiCreature : aiCreatures) {
|
||||
@@ -66,7 +65,7 @@ public class FightAi extends SpellAiLogic {
|
||||
if (creature1.equals(creature2)) {
|
||||
continue;
|
||||
}
|
||||
if (params.containsKey("TargetsWithoutSameCreatureType")
|
||||
if (sa.hasParam("TargetsWithoutSameCreatureType")
|
||||
&& creature1.sharesCreatureTypeWith(creature2)) {
|
||||
continue;
|
||||
}
|
||||
@@ -84,7 +83,7 @@ public class FightAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// check AI life before playing this drawback?
|
||||
return true;
|
||||
}
|
||||
@@ -93,7 +92,7 @@ public class FightAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
@@ -15,7 +14,7 @@ public class FogAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI should only activate this during Human's Declare Blockers phase
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) {
|
||||
return false;
|
||||
@@ -39,7 +38,7 @@ public class FogAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// AI should only activate this during Human's turn
|
||||
boolean chance;
|
||||
|
||||
@@ -54,7 +53,7 @@ public class FogAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance;
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getOpponent())) {
|
||||
chance = Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
|
||||
@@ -7,7 +7,7 @@ import forge.game.player.Player;
|
||||
|
||||
public class GameLossAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Player opp = ai.getOpponent();
|
||||
if (opp.cantLose()) {
|
||||
return false;
|
||||
@@ -28,12 +28,12 @@ public class GameLossAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
// Phage the Untouchable
|
||||
// (Final Fortune would need to attach it's delayed trigger to a
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -11,7 +10,7 @@ public class GameWinAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
if (ai.cantWin()) {
|
||||
return false;
|
||||
}
|
||||
@@ -27,12 +26,12 @@ public class GameWinAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
@@ -20,7 +19,7 @@ public class LifeExchangeAi extends SpellAiLogic {
|
||||
* forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final int myLife = aiPlayer.getLife();
|
||||
Player opponent = aiPlayer.getOpponent();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -29,13 +28,13 @@ public class LifeGainAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.AbilityFactoryAlterLife.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final int life = ai.getLife();
|
||||
final String amountStr = params.get("LifeAmount");
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int lifeAmount = 0;
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -63,7 +62,7 @@ public class LifeGainAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
boolean lifeCritical = life <= 5;
|
||||
@@ -94,7 +93,7 @@ public class LifeGainAi extends SpellAiLogic {
|
||||
|
||||
// Don't use lifegain before main 2 if possible
|
||||
if (!lifeCritical && Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,18 +132,18 @@ public class LifeGainAi extends SpellAiLogic {
|
||||
* <p>
|
||||
* gainLifeDoTriggerAINoCost.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @param sa
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @param mandatory
|
||||
* a boolean.
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player ai, final Map<String, String> params,
|
||||
final SpellAbility sa, final boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
|
||||
// If the Target is gaining life, target self.
|
||||
// if the Target is modifying how much life is gained, this needs to be
|
||||
@@ -162,7 +161,7 @@ public class LifeGainAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final String amountStr = params.get("LifeAmount");
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int xPay = ComputerUtil.determineLeftoverMana(sa, ai);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -23,14 +22,14 @@ public class LifeLoseAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.AbilityFactoryAlterLife.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
boolean priority = false;
|
||||
|
||||
final String amountStr = params.get("LifeAmount");
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
// TODO handle proper calculation of X values based on Cost and what
|
||||
// would be paid
|
||||
@@ -81,7 +80,7 @@ public class LifeLoseAi extends SpellAiLogic {
|
||||
|
||||
// Don't use loselife before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases") && !priority) {
|
||||
&& !sa.hasParam("ActivationPhases") && !priority) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,8 +109,8 @@ public class LifeLoseAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(final Player ai, final Map<String, String> params,
|
||||
final SpellAbility sa, final boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
if (sa.canTarget(ai.getOpponent())) {
|
||||
@@ -124,7 +123,7 @@ public class LifeLoseAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
final String amountStr = params.get("LifeAmount");
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
int amount = 0;
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
@@ -139,7 +138,7 @@ public class LifeLoseAi extends SpellAiLogic {
|
||||
if (tgt != null) {
|
||||
tgtPlayers = tgt.getTargetPlayers();
|
||||
} else {
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
if (!mandatory && tgtPlayers.contains(ai)) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -18,14 +17,14 @@ import forge.util.MyRandom;
|
||||
public class LifeSetAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
// Ability_Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ai.getOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
final String amountStr = params.get("LifeAmount");
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
if (!ai.canGainLife()) {
|
||||
return false;
|
||||
@@ -33,7 +32,7 @@ public class LifeSetAi extends SpellAiLogic {
|
||||
|
||||
// Don't use setLife before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ public class LifeSetAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (params.containsKey("Each") && params.get("Defined").equals("Each")) {
|
||||
if (sa.hasParam("Each") && sa.getParam("Defined").equals("Each")) {
|
||||
if (amount == 0) {
|
||||
return false;
|
||||
} else if (myLife > amount) { // will decrease computer's
|
||||
@@ -103,13 +102,13 @@ public class LifeSetAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ai.getOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final String amountStr = params.get("LifeAmount");
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
int amount;
|
||||
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -21,7 +20,7 @@ import forge.util.MyRandom;
|
||||
public class MillAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
|
||||
@@ -45,14 +44,14 @@ public class MillAi extends SpellAiLogic {
|
||||
|
||||
}
|
||||
|
||||
if (!targetAI(ai, params, sa, false)) {
|
||||
if (!targetAI(ai, sa, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
// Don't use draw abilities before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !params.containsKey("ActivationPhases")) {
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +73,7 @@ public class MillAi extends SpellAiLogic {
|
||||
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
||||
|
||||
if (params.get("NumCards").equals("X") && source.getSVar("X").startsWith("Count$xPaid")) {
|
||||
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").startsWith("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard =
|
||||
Math.min(ComputerUtil.determineLeftoverMana(sa, ai), ai.getOpponent().getCardsIn(ZoneType.Library).size());
|
||||
@@ -92,7 +91,7 @@ public class MillAi extends SpellAiLogic {
|
||||
return randomReturn;
|
||||
}
|
||||
|
||||
private boolean targetAI(final Player ai, final Map<String, String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
private boolean targetAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
Player opp = ai.getOpponent();
|
||||
|
||||
@@ -106,7 +105,7 @@ public class MillAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumCards"), sa);
|
||||
final int numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
|
||||
|
||||
final List<Card> pLibrary = opp.getCardsIn(ZoneType.Library);
|
||||
|
||||
@@ -136,19 +135,19 @@ public class MillAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
return targetAI(aiPlayer, params, sa, true);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return targetAI(aiPlayer, sa, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
if (!targetAI(aiPlayer, params, sa, mandatory)) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
if (!targetAI(aiPlayer, sa, mandatory)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
if (params.get("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtil.determineLeftoverMana(sa, aiPlayer), aiPlayer.getOpponent()
|
||||
.getCardsIn(ZoneType.Library).size());
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -9,13 +8,13 @@ import forge.game.player.Player;
|
||||
public class MustAttackAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// disabled for the AI for now. Only for Gideon Jura at this time.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// AI should only activate this during Human's turn
|
||||
// TODO - implement AI
|
||||
return false;
|
||||
@@ -25,7 +24,7 @@ public class MustAttackAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
boolean chance;
|
||||
|
||||
|
||||
@@ -22,19 +22,19 @@ import forge.game.zone.ZoneType;
|
||||
public class MustBlockAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// disabled for the AI until he/she can make decisions about who to make
|
||||
// block
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target abTgt = sa.getTarget();
|
||||
|
||||
@@ -44,9 +44,9 @@ public class MustBlockAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
Card attacker = null;
|
||||
if (params.containsKey("DefinedAttacker")) {
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(),
|
||||
params.get("DefinedAttacker"), sa);
|
||||
sa.getParam("DefinedAttacker"), sa);
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -22,7 +21,7 @@ public class PhasesAi extends SpellAiLogic
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// This still needs to be fleshed out
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -32,7 +31,7 @@ public class PhasesAi extends SpellAiLogic
|
||||
|
||||
ArrayList<Card> tgtCards;
|
||||
if (tgt == null) {
|
||||
tgtCards = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||
tgtCards = AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
if (tgtCards.contains(source)) {
|
||||
// Protect it from something
|
||||
} else {
|
||||
@@ -52,7 +51,7 @@ public class PhasesAi extends SpellAiLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (tgt == null)
|
||||
@@ -69,7 +68,7 @@ public class PhasesAi extends SpellAiLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
boolean randomReturn = true;
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -25,14 +24,14 @@ public class PlayAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Card source = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
|
||||
@@ -72,8 +71,8 @@ public class PlayAi extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
tgt.addTarget(CardFactoryUtil.getBestAI(cards));
|
||||
} else if (!params.containsKey("Valid")) {
|
||||
cards = new ArrayList<Card>(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa));
|
||||
} else if (!sa.hasParam("Valid")) {
|
||||
cards = new ArrayList<Card>(AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa));
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
@@ -26,7 +25,7 @@ public class PoisonAi extends SpellAiLogic {
|
||||
* forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
// int humanPoison = AllZone.getHumanPlayer().getPoisonCounters();
|
||||
@@ -52,7 +51,7 @@ public class PoisonAi extends SpellAiLogic {
|
||||
|
||||
// Don't use poison before main 2 if possible
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,14 +71,14 @@ public class PoisonAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
tgt.addTarget(ai.getOpponent());
|
||||
} else {
|
||||
final ArrayList<Player> players = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||
params.get("Defined"), sa);
|
||||
sa.getParam("Defined"), sa);
|
||||
for (final Player p : players) {
|
||||
if (!mandatory && p.isComputer() && (p.getPoisonCounters() > p.getOpponent().getPoisonCounters())) {
|
||||
return false;
|
||||
|
||||
@@ -3,8 +3,6 @@ package forge.card.abilityfactory.ai;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
@@ -66,8 +64,8 @@ public class ProtectAi extends SpellAiLogic {
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private static List<Card> getProtectCreatures(final Player ai, final Map<String,String> params, final SpellAbility sa) {
|
||||
final ArrayList<String> gains = AbilityFactory.getProtectionList(params);
|
||||
private static List<Card> getProtectCreatures(final Player ai, final SpellAbility sa) {
|
||||
final ArrayList<String> gains = AbilityFactory.getProtectionList(sa);
|
||||
|
||||
List<Card> list = ai.getCreaturesInPlay();
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -110,8 +108,8 @@ public class ProtectAi extends SpellAiLogic {
|
||||
} // getProtectCreatures()
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
// if there is no target and host card isn't in play, don't activate
|
||||
if ((sa.getTarget() == null) && !hostCard.isInPlay()) {
|
||||
return false;
|
||||
@@ -150,7 +148,7 @@ public class ProtectAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
if (cards.size() == 0) {
|
||||
return false;
|
||||
@@ -164,13 +162,13 @@ public class ProtectAi extends SpellAiLogic {
|
||||
* }
|
||||
*/
|
||||
} else {
|
||||
return protectTgtAI(ai, params, sa, false);
|
||||
return protectTgtAI(ai, sa, false);
|
||||
}
|
||||
|
||||
return false;
|
||||
} // protectPlayAI()
|
||||
|
||||
private boolean protectTgtAI(final Player ai, final Map<String, String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
private boolean protectTgtAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
if (!mandatory && Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||
return false;
|
||||
}
|
||||
@@ -179,7 +177,7 @@ public class ProtectAi extends SpellAiLogic {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
List<Card> list = getProtectCreatures(ai, params, sa);
|
||||
List<Card> list = getProtectCreatures(ai, sa);
|
||||
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
|
||||
@@ -210,7 +208,7 @@ public class ProtectAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return mandatory && protectMandatoryTarget(ai, params, sa, mandatory);
|
||||
return mandatory && protectMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
// Don't target cards that will die.
|
||||
@@ -229,7 +227,7 @@ public class ProtectAi extends SpellAiLogic {
|
||||
if (list.isEmpty()) {
|
||||
if ((tgt.getNumTargeted() < tgt.getMinTargets(source, sa)) || (tgt.getNumTargeted() == 0)) {
|
||||
if (mandatory) {
|
||||
return protectMandatoryTarget(ai, params, sa, mandatory);
|
||||
return protectMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
tgt.resetTargets();
|
||||
@@ -248,7 +246,7 @@ public class ProtectAi extends SpellAiLogic {
|
||||
return true;
|
||||
} // protectTgtAI()
|
||||
|
||||
private static boolean protectMandatoryTarget(final Player ai, final Map<String, String> params, final SpellAbility sa, final boolean mandatory) {
|
||||
private static boolean protectMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
@@ -269,14 +267,14 @@ public class ProtectAi extends SpellAiLogic {
|
||||
pref = CardLists.filter(pref, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !hasProtectionFromAll(c, AbilityFactory.getProtectionList(params));
|
||||
return !hasProtectionFromAll(c, AbilityFactory.getProtectionList(sa));
|
||||
}
|
||||
});
|
||||
final List<Card> pref2 = CardLists.filterControlledBy(list, ai);
|
||||
pref = CardLists.filter(pref, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !hasProtectionFromAny(c, AbilityFactory.getProtectionList(params));
|
||||
return !hasProtectionFromAny(c, AbilityFactory.getProtectionList(sa));
|
||||
}
|
||||
});
|
||||
final List<Card> forced = CardLists.filterControlledBy(list, ai);
|
||||
@@ -342,27 +340,27 @@ public class ProtectAi extends SpellAiLogic {
|
||||
} // protectMandatoryTarget()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
if (sa.getTarget() == null) {
|
||||
if (mandatory) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return protectTgtAI(ai, params, sa, mandatory);
|
||||
return protectTgtAI(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
return true;
|
||||
} // protectTriggerAI
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
final Card host = sa.getAbilityFactory().getHostCard();
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final Card host = sa.getSourceCard();
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
if (host.isCreature()) {
|
||||
// TODO
|
||||
}
|
||||
} else {
|
||||
return protectTgtAI(ai, params, sa, false);
|
||||
return protectTgtAI(ai, sa, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
@@ -12,8 +11,8 @@ import forge.game.player.Player;
|
||||
public class ProtectAllAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
// if there is no target and host card isn't in play, don't activate
|
||||
if ((sa.getTarget() == null) && !hostCard.isInPlay()) {
|
||||
return false;
|
||||
@@ -43,7 +42,7 @@ public class ProtectAllAi extends SpellAiLogic {
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,7 +50,7 @@ public class ProtectAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
} // protectAllDrawbackAI()
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package forge.card.abilityfactory.ai;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
@@ -30,12 +28,12 @@ public class PumpAi extends PumpAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost cost = sa.getPayCosts();
|
||||
final PhaseHandler ph = Singletons.getModel().getGame().getPhaseHandler();
|
||||
final List<String> keywords = params.containsKey("KW") ? Arrays.asList(params.get("KW").split(" & ")) : new ArrayList<String>();
|
||||
final String numDefense = params.containsKey("NumDef") ? params.get("NumDef") : "";
|
||||
final String numAttack = params.containsKey("NumAtt") ? params.get("NumAtt") : "";
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
|
||||
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
|
||||
|
||||
if (!CostUtil.checkLifeCost(ai, cost, sa.getSourceCard(), 4, null)) {
|
||||
return false;
|
||||
@@ -69,7 +67,7 @@ public class PumpAi extends PumpAiBase {
|
||||
if ((Singletons.getModel().getGame().getStack().size() == 0) && ph.getPhase().isBefore(PhaseType.COMBAT_BEGIN)) {
|
||||
// Instant-speed pumps should not be cast outside of combat when the
|
||||
// stack is empty
|
||||
if (!sa.getAbilityFactory().isCurse() && !AbilityFactory.isSorcerySpeed(sa)) {
|
||||
if (!sa.isCurse() && !AbilityFactory.isSorcerySpeed(sa)) {
|
||||
return false;
|
||||
}
|
||||
} else if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
@@ -126,9 +124,9 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
|
||||
//Untargeted
|
||||
if ((sa.getAbilityFactory().getAbTgt() == null) || !sa.getAbilityFactory().getAbTgt().doesTarget()) {
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(),
|
||||
params.get("Defined"), sa);
|
||||
sa.getParam("Defined"), sa);
|
||||
|
||||
if (cards.size() == 0) {
|
||||
return false;
|
||||
@@ -137,7 +135,7 @@ public class PumpAi extends PumpAiBase {
|
||||
// when this happens we need to expand AI to consider if its ok for
|
||||
// everything?
|
||||
for (final Card card : cards) {
|
||||
if (sa.getAbilityFactory().isCurse()) {
|
||||
if (sa.isCurse()) {
|
||||
if (card.getController().isComputer()) {
|
||||
return false;
|
||||
}
|
||||
@@ -155,22 +153,22 @@ public class PumpAi extends PumpAiBase {
|
||||
return false;
|
||||
}
|
||||
//Targeted
|
||||
if (!this.pumpTgtAI(ai, sa, params, defense, attack, false)) {
|
||||
if (!this.pumpTgtAI(ai, sa, defense, attack, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // pumpPlayAI()
|
||||
|
||||
private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final Map<String, String> params, final int defense, final int attack, final boolean mandatory) {
|
||||
final List<String> keywords = params.containsKey("KW") ? Arrays.asList(params.get("KW").split(" & ")) : new ArrayList<String>();
|
||||
private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defense, final int attack, final boolean mandatory) {
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
|
||||
if (!mandatory
|
||||
&& !sa.isTrigger()
|
||||
&& Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !(sa.getAbilityFactory().isCurse() && (defense < 0))
|
||||
&& !(sa.isCurse() && (defense < 0))
|
||||
&& !this.containsNonCombatKeyword(keywords)
|
||||
&& !sa.getAbilityFactory().getMapParams().containsKey("UntilYourNextTurn")) {
|
||||
&& !sa.hasParam("UntilYourNextTurn")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -178,8 +176,8 @@ public class PumpAi extends PumpAiBase {
|
||||
final Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
List<Card> list = new ArrayList<Card>();
|
||||
if (params.containsKey("AILogic")) {
|
||||
if (params.get("AILogic").equals("HighestPower")) {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
if (sa.getParam("AILogic").equals("HighestPower")) {
|
||||
list = CardLists.getValidCards(CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
CardLists.sortAttack(list);
|
||||
@@ -190,7 +188,7 @@ public class PumpAi extends PumpAiBase {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (sa.getAbilityFactory().isCurse()) {
|
||||
} else if (sa.isCurse()) {
|
||||
if (sa.canTarget(opp)) {
|
||||
tgt.addTarget(opp);
|
||||
return true;
|
||||
@@ -229,7 +227,7 @@ public class PumpAi extends PumpAiBase {
|
||||
return mandatory && this.pumpMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
if (!sa.getAbilityFactory().isCurse()) {
|
||||
if (!sa.isCurse()) {
|
||||
// Don't target cards that will die.
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -286,7 +284,7 @@ public class PumpAi extends PumpAiBase {
|
||||
List<Card> forced;
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
if (sa.getAbilityFactory().isCurse()) {
|
||||
if (sa.isCurse()) {
|
||||
pref = CardLists.filterControlledBy(list, opp);
|
||||
forced = CardLists.filterControlledBy(list, ai);
|
||||
} else {
|
||||
@@ -337,10 +335,10 @@ public class PumpAi extends PumpAiBase {
|
||||
} // pumpMandatoryTarget()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final String numDefense = params.containsKey("NumDef") ? params.get("NumDef") : "";
|
||||
final String numAttack = params.containsKey("NumAtt") ? params.get("NumAtt") : "";
|
||||
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
|
||||
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
|
||||
|
||||
int defense;
|
||||
if (numDefense.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
@@ -373,19 +371,19 @@ public class PumpAi extends PumpAiBase {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return this.pumpTgtAI(ai, sa, params, defense, attack, mandatory);
|
||||
return this.pumpTgtAI(ai, sa, defense, attack, mandatory);
|
||||
}
|
||||
|
||||
return true;
|
||||
} // pumpTriggerAI
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final String numDefense = params.containsKey("NumDef") ? params.get("NumDef") : "";
|
||||
final String numAttack = params.containsKey("NumAtt") ? params.get("NumAtt") : "";
|
||||
final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
|
||||
final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";
|
||||
|
||||
int defense;
|
||||
if (numDefense.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
@@ -401,7 +399,7 @@ public class PumpAi extends PumpAiBase {
|
||||
attack = AbilityFactory.calculateAmount(sa.getSourceCard(), numAttack, sa);
|
||||
}
|
||||
|
||||
if ((sa.getAbilityFactory().getAbTgt() == null) || !sa.getAbilityFactory().getAbTgt().doesTarget()) {
|
||||
if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) {
|
||||
if (source.isCreature()) {
|
||||
if (!source.hasKeyword("Indestructible")
|
||||
&& ((source.getNetDefense() + defense) <= source.getDamage())) {
|
||||
@@ -413,7 +411,7 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
} else {
|
||||
//Targeted
|
||||
if (!this.pumpTgtAI(ai, sa, params, defense, attack, false)) {
|
||||
if (!this.pumpTgtAI(ai, sa, defense, attack, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ public abstract class PumpAiBase extends SpellAiLogic {
|
||||
|
||||
public boolean containsUsefulKeyword(final Player ai, final List<String> keywords, final Card card, final SpellAbility sa, final int attack) {
|
||||
for (final String keyword : keywords) {
|
||||
if (!sa.getAbilityFactory().isCurse() && isUsefulPumpKeyword(ai, keyword, card, sa, attack)) {
|
||||
if (!sa.isCurse() && isUsefulPumpKeyword(ai, keyword, card, sa, attack)) {
|
||||
return true;
|
||||
}
|
||||
if (sa.getAbilityFactory().isCurse() && isUsefulCurseKeyword(ai, keyword, card, sa)) {
|
||||
if (sa.isCurse() && isUsefulCurseKeyword(ai, keyword, card, sa)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public abstract class PumpAiBase extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.endsWith("CARDNAME can't attack or block.")) {
|
||||
if (sa.getAbilityFactory().getMapParams().containsKey("UntilYourNextTurn")) {
|
||||
if (sa.hasParam("UntilYourNextTurn")) {
|
||||
if (CombatUtil.canAttack(card, human) || CombatUtil.canBlock(card, true)) {
|
||||
return true;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public abstract class PumpAiBase extends SpellAiLogic {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) {
|
||||
if (!AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(), sa.getAbilityFactory()).contains(card)) {
|
||||
if (!AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card)) {
|
||||
return false;
|
||||
}
|
||||
} else if (keyword.equals("Islandwalk")) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.card.abilityfactory.ai;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
@@ -26,13 +25,13 @@ public class PumpAllAi extends PumpAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, Map<String, String> params, final SpellAbility sa) {
|
||||
protected boolean canPlayAI(final Player ai, final SpellAbility sa) {
|
||||
String valid = "";
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
final int power = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumAtt"), sa);
|
||||
final int defense = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumDef"), sa);
|
||||
final List<String> keywords = params.containsKey("KW") ? Arrays.asList(params.get("KW").split(" & ")) : new ArrayList<String>();
|
||||
final int power = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumAtt"), sa);
|
||||
final int defense = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumDef"), sa);
|
||||
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>();
|
||||
|
||||
final PhaseType phase = Singletons.getModel().getGame().getPhaseHandler().getPhase();
|
||||
|
||||
@@ -40,8 +39,8 @@ public class PumpAllAi extends PumpAiBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
final Player opp = ai.getOpponent();
|
||||
@@ -49,13 +48,13 @@ public class PumpAllAi extends PumpAiBase {
|
||||
List<Card> human = CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null && sa.canTarget(opp) && params.containsKey("IsCurse")) {
|
||||
if (tgt != null && sa.canTarget(opp) && sa.hasParam("IsCurse")) {
|
||||
tgt.resetTargets();
|
||||
sa.getTarget().addTarget(opp);
|
||||
comp = new ArrayList<Card>();
|
||||
}
|
||||
|
||||
if (params.containsKey("IsCurse")) {
|
||||
if (sa.hasParam("IsCurse")) {
|
||||
if (defense < 0) { // try to destroy creatures
|
||||
comp = CardLists.filter(comp, new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -141,7 +140,7 @@ public class PumpAllAi extends PumpAiBase {
|
||||
} // pumpAllCanPlayAI()
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ public class PumpAllAi extends PumpAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -12,7 +11,7 @@ public class RearrangeTopOfLibraryAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,7 +19,7 @@ public class RearrangeTopOfLibraryAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
|
||||
@@ -56,10 +56,10 @@ public class RegenerateAi extends SpellAiLogic {
|
||||
// **************************************************************
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
boolean chance = false;
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
if (!CostUtil.checkLifeCost(ai, abCost, hostCard, 4, null)) {
|
||||
@@ -79,10 +79,10 @@ public class RegenerateAi extends SpellAiLogic {
|
||||
if (tgt == null) {
|
||||
// As far as I can tell these Defined Cards will only have one of
|
||||
// them
|
||||
final ArrayList<Card> list = AbilityFactory.getDefinedCards(hostCard, params.get("Defined"), sa);
|
||||
final ArrayList<Card> list = AbilityFactory.getDefinedCards(hostCard, sa.getParam("Defined"), sa);
|
||||
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(),sa.getAbilityFactory());
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(),sa);
|
||||
|
||||
for (final Card c : list) {
|
||||
if (objects.contains(c)) {
|
||||
@@ -118,7 +118,7 @@ public class RegenerateAi extends SpellAiLogic {
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
// check stack for something on the stack will kill anything i
|
||||
// control
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(), sa.getAbilityFactory());
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||
|
||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||
|
||||
@@ -153,7 +153,7 @@ public class RegenerateAi extends SpellAiLogic {
|
||||
} // regenerateCanPlayAI
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance = false;
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -168,12 +168,12 @@ public class RegenerateAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean regenMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
// filter AIs battlefield by what I can target
|
||||
|
||||
@@ -20,10 +20,10 @@ import forge.game.zone.ZoneType;
|
||||
public class RegenerateAllAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final Card hostCard = sa.getAbilityFactory().getHostCard();
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
boolean chance = false;
|
||||
final Cost abCost = sa.getAbilityFactory().getAbCost();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
if (!CostUtil.checkSacrificeCost(ai, abCost, hostCard)) {
|
||||
@@ -42,8 +42,8 @@ public class RegenerateAllAi extends SpellAiLogic {
|
||||
// filter AIs battlefield by what I can target
|
||||
String valid = "";
|
||||
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
@@ -56,7 +56,7 @@ public class RegenerateAllAi extends SpellAiLogic {
|
||||
|
||||
int numSaved = 0;
|
||||
if (Singletons.getModel().getGame().getStack().size() > 0) {
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(),sa.getAbilityFactory());
|
||||
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(sa.getActivatingPlayer(),sa);
|
||||
|
||||
for (final Card c : list) {
|
||||
if (objects.contains(c) && c.getShield() == 0) {
|
||||
@@ -83,12 +83,12 @@ public class RegenerateAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance = true;
|
||||
|
||||
return chance;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -9,13 +8,13 @@ import forge.game.player.Player;
|
||||
public class RemoveFromCombatAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// disabled for the AI for now. Only for Gideon Jura at this time.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// AI should only activate this during Human's turn
|
||||
|
||||
// TODO - implement AI
|
||||
@@ -26,7 +25,7 @@ public class RemoveFromCombatAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
boolean chance;
|
||||
|
||||
// TODO - implement AI
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -10,7 +9,7 @@ import forge.game.player.Player;
|
||||
public class RepeatAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Player opp = ai.getOpponent();
|
||||
if (tgt != null) {
|
||||
@@ -27,7 +26,7 @@ public class RepeatAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
@@ -16,7 +15,7 @@ public class RestartGameAi extends SpellAiLogic {
|
||||
* forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// The only card that uses this is Karn Liberated
|
||||
|
||||
// TODO Add Logic, check if AI is losing game state, or life
|
||||
@@ -27,7 +26,7 @@ public class RestartGameAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
// This trigger AI is completely unused, but return true just in case
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import forge.util.MyRandom;
|
||||
|
||||
public class RevealAi extends RevealAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -54,7 +54,7 @@ public class RevealAi extends RevealAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
if (!revealHandTargetAI(ai, sa, false, mandatory)) {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -38,7 +37,7 @@ public abstract class RevealAiBase extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return revealHandTargetAI(ai, sa, false, false);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -17,7 +16,7 @@ public class RevealHandAi extends RevealAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI cannot use this properly until he can use SAs during Humans turn
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -59,7 +58,7 @@ public class RevealHandAi extends RevealAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
if (!revealHandTargetAI(ai, sa, false, mandatory)) {
|
||||
return false;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
@@ -20,15 +18,15 @@ public class SacrificeAi extends SpellAiLogic {
|
||||
// **************************************************************
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
boolean chance = sacrificeTgtAI(ai, params, sa);
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
boolean chance = sacrificeTgtAI(ai, sa);
|
||||
|
||||
// Some additional checks based on what is being sacrificed, and who is
|
||||
// sacrificing
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
final String valid = params.get("SacValid");
|
||||
String num = params.get("Amount");
|
||||
final String valid = sa.getParam("SacValid");
|
||||
String num = sa.getParam("Amount");
|
||||
num = (num == null) ? "1" : num;
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa);
|
||||
|
||||
@@ -60,16 +58,16 @@ public class SacrificeAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// AI should only activate this during Human's turn
|
||||
|
||||
return sacrificeTgtAI(ai, params, sa);
|
||||
return sacrificeTgtAI(ai, sa);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
// AI should only activate this during Human's turn
|
||||
boolean chance = sacrificeTgtAI(ai, params, sa);
|
||||
boolean chance = sacrificeTgtAI(ai, sa);
|
||||
|
||||
// Improve AI for triggers. If source is a creature with:
|
||||
// When ETB, sacrifice a creature. Check to see if the AI has something
|
||||
@@ -81,7 +79,7 @@ public class SacrificeAi extends SpellAiLogic {
|
||||
return chance || mandatory;
|
||||
}
|
||||
|
||||
private boolean sacrificeTgtAI(final Player ai, final Map<String, String> params, final SpellAbility sa) {
|
||||
private boolean sacrificeTgtAI(final Player ai, final SpellAbility sa) {
|
||||
|
||||
final Card card = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -97,8 +95,8 @@ public class SacrificeAi extends SpellAiLogic {
|
||||
}
|
||||
}
|
||||
|
||||
final String defined = params.get("Defined");
|
||||
final String valid = params.get("SacValid");
|
||||
final String defined = sa.getParam("Defined");
|
||||
final String valid = sa.getParam("SacValid");
|
||||
if (defined == null) {
|
||||
// Self Sacrifice.
|
||||
} else if (defined.equals("Each")
|
||||
@@ -108,7 +106,7 @@ public class SacrificeAi extends SpellAiLogic {
|
||||
// Only cast it if AI doesn't have the full amount of Valid
|
||||
// TODO: Cast if the type is favorable: my "worst" valid is
|
||||
// worse than his "worst" valid
|
||||
final String num = params.containsKey("Amount") ? params.get("Amount") : "1";
|
||||
final String num = sa.hasParam("Amount") ? sa.getParam("Amount") : "1";
|
||||
int amount = AbilityFactory.calculateAmount(card, num, sa);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -18,7 +18,7 @@ import forge.util.MyRandom;
|
||||
public class SacrificeAllAi extends SpellAiLogic
|
||||
{
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// AI needs to be expanded, since this function can be pretty complex
|
||||
// based on what the expected targets could be
|
||||
final Random r = MyRandom.getRandom();
|
||||
@@ -26,8 +26,8 @@ public class SacrificeAllAi extends SpellAiLogic
|
||||
final Card source = sa.getSourceCard();
|
||||
String valid = "";
|
||||
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
if (valid.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
@@ -76,7 +76,7 @@ public class SacrificeAllAi extends SpellAiLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
@@ -16,7 +15,7 @@ public class ScryAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (tgt != null) { // It doesn't appear that Scry ever targets
|
||||
@@ -30,13 +29,13 @@ public class ScryAi extends SpellAiLogic {
|
||||
} // scryTargetAI()
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
return doTriggerAINoCost(ai, params, sa, false);
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
return doTriggerAINoCost(ai, sa, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
// Card source = sa.getSourceCard();
|
||||
|
||||
double chance = .4; // 40 percent chance of milling with instant speed
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -8,12 +7,12 @@ import forge.game.player.Player;
|
||||
|
||||
public class SetStateAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// Gross generalization, but this always considers alternate
|
||||
// states more powerful
|
||||
return !sa.getSourceCard().isInAlternateState();
|
||||
@@ -24,7 +23,7 @@ public class SetStateAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -11,7 +10,7 @@ public class SetStateAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,7 +18,7 @@ public class SetStateAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#chkAIDrawback(java.util.Map, forge.card.spellability.SpellAbility, forge.game.player.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean chkAIDrawback(Map<String, String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
// Gross generalization, but this always considers alternate
|
||||
// states more powerful
|
||||
if (sa.getSourceCard().isInAlternateState()) {
|
||||
@@ -33,7 +32,7 @@ public class SetStateAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import forge.game.player.Player;
|
||||
|
||||
public class ShuffleAi extends SpellAiLogic {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// not really sure when the compy would use this; maybe only after a
|
||||
// human
|
||||
// deliberately put a card on top of their library
|
||||
@@ -27,7 +27,7 @@ public class ShuffleAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return shuffleTargetAI(sa, false, false);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ShuffleAi extends SpellAiLogic {
|
||||
} // shuffleTargetAI()
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
if (!shuffleTargetAI(sa, false, mandatory)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.game.player.Player;
|
||||
public class StoreSVarAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
//Tree of Redemption
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -24,14 +24,14 @@ public class StoreSVarAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import forge.util.MyRandom;
|
||||
|
||||
public class TapAi extends TapAiBase {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class TapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
if (tgt == null) {
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
|
||||
boolean bFlag = false;
|
||||
for (final Card c : defined) {
|
||||
@@ -58,7 +58,7 @@ public class TapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -84,7 +84,7 @@ public class TapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -24,7 +23,7 @@ public class TapAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(final Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(final Player ai, SpellAbility sa) {
|
||||
// If tapping all creatures do it either during declare attackers of AIs
|
||||
// turn
|
||||
// or during upkeep/begin combat?
|
||||
@@ -37,8 +36,8 @@ public class TapAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
String valid = "";
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> validTappables = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
@@ -99,12 +98,12 @@ public class TapAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
String valid = "";
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> validTappables = getTapAllTargets(valid, source);
|
||||
@@ -149,7 +148,7 @@ public class TapAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -17,7 +16,7 @@ public class TapOrUntapAi extends TapAiBase {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -28,7 +27,7 @@ public class TapOrUntapAi extends TapAiBase {
|
||||
// assume we are looking to tap human's stuff
|
||||
// TODO - check for things with untap abilities, and don't tap
|
||||
// those.
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
|
||||
boolean bFlag = false;
|
||||
for (final Card c : defined) {
|
||||
@@ -49,7 +48,7 @@ public class TapOrUntapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
@@ -74,7 +73,7 @@ public class TapOrUntapAi extends TapAiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -43,30 +42,30 @@ public class TokenAi extends SpellAiLogic {
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
*/
|
||||
private void readParameters(final Map<String, String> mapParams ) {
|
||||
private void readParameters(final SpellAbility mapParams ) {
|
||||
String[] keywords;
|
||||
|
||||
if (mapParams.containsKey("TokenKeywords")) {
|
||||
if (mapParams.hasParam("TokenKeywords")) {
|
||||
// TODO: Change this Split to a semicolon or something else
|
||||
keywords = mapParams.get("TokenKeywords").split("<>");
|
||||
keywords = mapParams.getParam("TokenKeywords").split("<>");
|
||||
} else {
|
||||
keywords = new String[0];
|
||||
}
|
||||
|
||||
|
||||
this.tokenAmount = mapParams.get("TokenAmount");
|
||||
this.tokenPower = mapParams.get("TokenPower");
|
||||
this.tokenToughness = mapParams.get("TokenToughness");
|
||||
this.tokenName = mapParams.get("TokenName");
|
||||
this.tokenTypes = mapParams.get("TokenTypes").split(",");
|
||||
this.tokenAmount = mapParams.getParam("TokenAmount");
|
||||
this.tokenPower = mapParams.getParam("TokenPower");
|
||||
this.tokenToughness = mapParams.getParam("TokenToughness");
|
||||
this.tokenName = mapParams.getParam("TokenName");
|
||||
this.tokenTypes = mapParams.getParam("TokenTypes").split(",");
|
||||
this.tokenKeywords = keywords;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Cost cost = sa.getPayCosts();
|
||||
readParameters(params);
|
||||
readParameters(sa);
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
@@ -98,13 +97,13 @@ public class TokenAi extends SpellAiLogic {
|
||||
// Don't generate tokens without haste before main 2 if possible
|
||||
if (ph.getPhase().isBefore(PhaseType.MAIN2)
|
||||
&& ph.isPlayerTurn(ai) && !haste
|
||||
&& !params.containsKey("ActivationPhases")) {
|
||||
&& !sa.hasParam("ActivationPhases")) {
|
||||
return false;
|
||||
}
|
||||
if ((ph.isPlayerTurn(ai)
|
||||
|| ph.getPhase().isBefore(
|
||||
PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))
|
||||
&& !params.containsKey("ActivationPhases") && !params.containsKey("PlayerTurn")
|
||||
&& !sa.hasParam("ActivationPhases") && !sa.hasParam("PlayerTurn")
|
||||
&& !AbilityFactory.isSorcerySpeed(sa) && !haste) {
|
||||
return false;
|
||||
}
|
||||
@@ -173,8 +172,8 @@ public class TokenAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
readParameters(params);
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
readParameters(sa);
|
||||
final Card source = sa.getSourceCard();
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
@@ -19,17 +18,17 @@ public class TwoPilesAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
ZoneType zone = null;
|
||||
|
||||
if (params.containsKey("Zone")) {
|
||||
zone = ZoneType.smartValueOf(params.get("Zone"));
|
||||
if (sa.hasParam("Zone")) {
|
||||
zone = ZoneType.smartValueOf(sa.getParam("Zone"));
|
||||
}
|
||||
|
||||
String valid = "";
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
ArrayList<Player> tgtPlayers;
|
||||
@@ -43,13 +42,13 @@ public class TwoPilesAi extends SpellAiLogic {
|
||||
}
|
||||
tgtPlayers = tgt.getTargetPlayers();
|
||||
} else {
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
final Player p = tgtPlayers.get(0);
|
||||
List<Card> pool = new ArrayList<Card>();
|
||||
if (params.containsKey("DefinedCards")) {
|
||||
pool = new ArrayList<Card>(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("DefinedCards"), sa));
|
||||
if (sa.hasParam("DefinedCards")) {
|
||||
pool = new ArrayList<Card>(AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("DefinedCards"), sa));
|
||||
} else {
|
||||
pool = p.getCardsIn(zone);
|
||||
}
|
||||
@@ -59,7 +58,7 @@ public class TwoPilesAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ public class TwoPilesAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -24,7 +23,7 @@ public class UnattachAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Random r = MyRandom.getRandom();
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getSourceCard();
|
||||
@@ -53,7 +52,7 @@ public class UnattachAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
|
||||
&& !"Curse".equals(params.get("AILogic"))) {
|
||||
&& !"Curse".equals(sa.getParam("AILogic"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,14 +64,14 @@ public class UnattachAllAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#doTriggerAINoCost(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card card = sa.getSourceCard();
|
||||
final Player opp = ai.getOpponent();
|
||||
// Check if there are any valid targets
|
||||
ArrayList<Object> targets = new ArrayList<Object>();
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt == null) {
|
||||
targets = AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
targets = AbilityFactory.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
if (!mandatory && card.isEquipment() && !targets.isEmpty()) {
|
||||
@@ -95,9 +94,9 @@ public class UnattachAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
// AI should only activate this during Human's turn
|
||||
return canPlayAI(ai, params, sa);
|
||||
return canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.Card;
|
||||
@@ -27,7 +26,7 @@ public class UntapAi extends SpellAiLogic {
|
||||
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Target tgt = sa.getTarget();
|
||||
final Card source = sa.getSourceCard();
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -40,7 +39,7 @@ public class UntapAi extends SpellAiLogic {
|
||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn() + 1);
|
||||
|
||||
if (tgt == null) {
|
||||
final ArrayList<Card> pDefined = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"),
|
||||
final ArrayList<Card> pDefined = AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"),
|
||||
sa);
|
||||
if ((pDefined != null) && pDefined.get(0).isUntapped() && pDefined.get(0).getController().isComputer()) {
|
||||
return false;
|
||||
@@ -55,7 +54,7 @@ public class UntapAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
if (tgt == null) {
|
||||
@@ -64,7 +63,7 @@ public class UntapAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
// TODO: use Defined to determine, if this is an unfavorable result
|
||||
final ArrayList<Card> pDefined = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"),
|
||||
final ArrayList<Card> pDefined = AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"),
|
||||
sa);
|
||||
if ((pDefined != null) && pDefined.get(0).isUntapped() && pDefined.get(0).getController().isComputer()) {
|
||||
return false;
|
||||
@@ -84,7 +83,7 @@ public class UntapAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player ai) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
boolean randomReturn = true;
|
||||
@@ -120,7 +119,7 @@ public class UntapAi extends SpellAiLogic {
|
||||
|
||||
Player targetController = ai;
|
||||
|
||||
if (sa.getAbilityFactory().isCurse()) {
|
||||
if (sa.isCurse()) {
|
||||
targetController = ai.getOpponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ import forge.game.player.Player;
|
||||
public class UntapAllAi extends SpellAiLogic {
|
||||
|
||||
@Override
|
||||
public boolean chkAIDrawback(java.util.Map<String,String> params, SpellAbility sa, Player aiPlayer) {
|
||||
public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
// check SubAbilities DoTrigger?
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
@@ -23,7 +23,7 @@ public class UntapAllAi extends SpellAiLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, java.util.Map<String,String> params, SpellAbility sa, boolean mandatory) {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ import forge.game.player.Player;
|
||||
public class AddTurnEffect extends SpellEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final int numTurns = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumTurns"), sa);
|
||||
final int numTurns = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumTurns"), sa);
|
||||
|
||||
List<Player> tgtPlayers = getTargetPlayers(sa, params);
|
||||
List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
|
||||
for (final Player player : tgtPlayers) {
|
||||
@@ -38,8 +38,8 @@ public class AddTurnEffect extends SpellEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(java.util.Map<String,String> params, SpellAbility sa) {
|
||||
final int numTurns = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumTurns"), sa);
|
||||
public void resolve(SpellAbility sa) {
|
||||
final int numTurns = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumTurns"), sa);
|
||||
|
||||
ArrayList<Player> tgtPlayers;
|
||||
|
||||
@@ -47,17 +47,17 @@ public class AddTurnEffect extends SpellEffect {
|
||||
if (tgt != null) {
|
||||
tgtPlayers = tgt.getTargetPlayers();
|
||||
} else {
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
for (int i = 0; i < numTurns; i++) {
|
||||
ExtraTurn extra = Singletons.getModel().getGame().getPhaseHandler().addExtraTurn(p);
|
||||
if (params.containsKey("LoseAtEndStep")) {
|
||||
if (sa.hasParam("LoseAtEndStep")) {
|
||||
extra.setLoseAtEndStep(true);
|
||||
}
|
||||
if (params.containsKey("SkipUntap")) {
|
||||
if (sa.hasParam("SkipUntap")) {
|
||||
extra.setSkipUntap(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,24 @@ import forge.game.zone.ZoneType;
|
||||
public class AnimateAllEffect extends AnimateEffectBase
|
||||
{
|
||||
@Override
|
||||
protected String getStackDescription(java.util.Map<String,String> params, SpellAbility sa) {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
return "Animate all valid cards.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(final java.util.Map<String,String> params, SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
long timest = -1;
|
||||
|
||||
// AF specific params
|
||||
// AF specific sa
|
||||
int power = -1;
|
||||
if (params.containsKey("Power")) {
|
||||
power = AbilityFactory.calculateAmount(host, params.get("Power"), sa);
|
||||
if (sa.hasParam("Power")) {
|
||||
power = AbilityFactory.calculateAmount(host, sa.getParam("Power"), sa);
|
||||
}
|
||||
int toughness = -1;
|
||||
if (params.containsKey("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
||||
if (sa.hasParam("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(host, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
|
||||
// Every Animate event needs a unique time stamp
|
||||
@@ -48,16 +48,16 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
final long timestamp = timest;
|
||||
|
||||
final boolean permanent = params.containsKey("Permanent");
|
||||
final boolean permanent = sa.hasParam("Permanent");
|
||||
|
||||
final ArrayList<String> types = new ArrayList<String>();
|
||||
if (params.containsKey("Types")) {
|
||||
types.addAll(Arrays.asList(params.get("Types").split(",")));
|
||||
if (sa.hasParam("Types")) {
|
||||
types.addAll(Arrays.asList(sa.getParam("Types").split(",")));
|
||||
}
|
||||
|
||||
final ArrayList<String> removeTypes = new ArrayList<String>();
|
||||
if (params.containsKey("RemoveTypes")) {
|
||||
removeTypes.addAll(Arrays.asList(params.get("RemoveTypes").split(",")));
|
||||
if (sa.hasParam("RemoveTypes")) {
|
||||
removeTypes.addAll(Arrays.asList(sa.getParam("RemoveTypes").split(",")));
|
||||
}
|
||||
|
||||
// allow ChosenType - overrides anything else specified
|
||||
@@ -67,13 +67,13 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
}
|
||||
|
||||
final ArrayList<String> keywords = new ArrayList<String>();
|
||||
if (params.containsKey("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
||||
if (sa.hasParam("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & ")));
|
||||
}
|
||||
|
||||
final ArrayList<String> hiddenKeywords = new ArrayList<String>();
|
||||
if (params.containsKey("HiddenKeywords")) {
|
||||
hiddenKeywords.addAll(Arrays.asList(params.get("HiddenKeywords").split(" & ")));
|
||||
if (sa.hasParam("HiddenKeywords")) {
|
||||
hiddenKeywords.addAll(Arrays.asList(sa.getParam("HiddenKeywords").split(" & ")));
|
||||
}
|
||||
// allow SVar substitution for keywords
|
||||
for (int i = 0; i < keywords.size(); i++) {
|
||||
@@ -86,8 +86,8 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
// colors to be added or changed to
|
||||
String tmpDesc = "";
|
||||
if (params.containsKey("Colors")) {
|
||||
final String colors = params.get("Colors");
|
||||
if (sa.hasParam("Colors")) {
|
||||
final String colors = sa.getParam("Colors");
|
||||
if (colors.equals("ChosenColor")) {
|
||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
||||
} else {
|
||||
@@ -98,26 +98,26 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
// abilities to add to the animated being
|
||||
final ArrayList<String> abilities = new ArrayList<String>();
|
||||
if (params.containsKey("Abilities")) {
|
||||
abilities.addAll(Arrays.asList(params.get("Abilities").split(",")));
|
||||
if (sa.hasParam("Abilities")) {
|
||||
abilities.addAll(Arrays.asList(sa.getParam("Abilities").split(",")));
|
||||
}
|
||||
|
||||
// triggers to add to the animated being
|
||||
final ArrayList<String> triggers = new ArrayList<String>();
|
||||
if (params.containsKey("Triggers")) {
|
||||
triggers.addAll(Arrays.asList(params.get("Triggers").split(",")));
|
||||
if (sa.hasParam("Triggers")) {
|
||||
triggers.addAll(Arrays.asList(sa.getParam("Triggers").split(",")));
|
||||
}
|
||||
|
||||
// sVars to add to the animated being
|
||||
final ArrayList<String> sVars = new ArrayList<String>();
|
||||
if (params.containsKey("sVars")) {
|
||||
sVars.addAll(Arrays.asList(params.get("sVars").split(",")));
|
||||
if (sa.hasParam("sVars")) {
|
||||
sVars.addAll(Arrays.asList(sa.getParam("sVars").split(",")));
|
||||
}
|
||||
|
||||
String valid = "";
|
||||
|
||||
if (params.containsKey("ValidCards")) {
|
||||
valid = params.get("ValidCards");
|
||||
if (sa.hasParam("ValidCards")) {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
List<Card> list;
|
||||
@@ -126,9 +126,9 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
final Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
tgtPlayers = tgt.getTargetPlayers();
|
||||
} else if (params.containsKey("Defined")) {
|
||||
} else if (sa.hasParam("Defined")) {
|
||||
// use it
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
|
||||
@@ -141,7 +141,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
for (final Card c : list) {
|
||||
|
||||
final long colorTimestamp = doAnimate(c, params, power, toughness, types, removeTypes,
|
||||
final long colorTimestamp = doAnimate(c, sa, power, toughness, types, removeTypes,
|
||||
finalDesc, keywords, null, hiddenKeywords, timestamp);
|
||||
|
||||
// give abilities
|
||||
@@ -158,7 +158,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
// remove abilities
|
||||
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||
if (params.containsKey("OverwriteAbilities") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteAbilities") || sa.hasParam("RemoveAllAbilities")) {
|
||||
for (final SpellAbility ab : c.getSpellAbilities()) {
|
||||
if (ab.isAbility()) {
|
||||
c.removeSpellAbility(ab);
|
||||
@@ -179,7 +179,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
// suppress triggers from the animated card
|
||||
final ArrayList<Trigger> removedTriggers = new ArrayList<Trigger>();
|
||||
if (params.containsKey("OverwriteTriggers") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteTriggers") || sa.hasParam("RemoveAllAbilities")) {
|
||||
final List<Trigger> triggersToRemove = c.getTriggers();
|
||||
for (final Trigger trigger : triggersToRemove) {
|
||||
trigger.setSuppressed(true);
|
||||
@@ -189,7 +189,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
// suppress static abilities from the animated card
|
||||
final ArrayList<StaticAbility> removedStatics = new ArrayList<StaticAbility>();
|
||||
if (params.containsKey("OverwriteStatics") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteStatics") || sa.hasParam("RemoveAllAbilities")) {
|
||||
final ArrayList<StaticAbility> staticsToRemove = c.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticsToRemove) {
|
||||
stAb.setTemporarilySuppressed(true);
|
||||
@@ -199,7 +199,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
// suppress static abilities from the animated card
|
||||
final ArrayList<ReplacementEffect> removedReplacements = new ArrayList<ReplacementEffect>();
|
||||
if (params.containsKey("OverwriteReplacements") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteReplacements") || sa.hasParam("RemoveAllAbilities")) {
|
||||
final ArrayList<ReplacementEffect> replacementsToRemove = c.getReplacementEffects();
|
||||
for (final ReplacementEffect re : replacementsToRemove) {
|
||||
re.setTemporarilySuppressed(true);
|
||||
@@ -220,7 +220,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
doUnanimate(c, params, finalDesc, hiddenKeywords, addedAbilities, addedTriggers,
|
||||
doUnanimate(c, sa, finalDesc, hiddenKeywords, addedAbilities, addedTriggers,
|
||||
colorTimestamp, false, removedAbilities, timestamp);
|
||||
|
||||
// give back suppressed triggers
|
||||
@@ -241,7 +241,7 @@ public class AnimateAllEffect extends AnimateEffectBase
|
||||
};
|
||||
|
||||
if (!permanent) {
|
||||
if (params.containsKey("UntilEndOfCombat")) {
|
||||
if (sa.hasParam("UntilEndOfCombat")) {
|
||||
Singletons.getModel().getGame().getEndOfCombat().addUntil(unanimate);
|
||||
} else {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(unanimate);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void resolve(final Map<String, String> params, SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
final Card host = sa.getSourceCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
@@ -31,24 +31,24 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
String animateRemembered = null;
|
||||
|
||||
//if host is not on the battlefield don't apply
|
||||
if (params.containsKey("UntilHostLeavesPlay")
|
||||
if (sa.hasParam("UntilHostLeavesPlay")
|
||||
&& !sa.getSourceCard().isInPlay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember Objects
|
||||
if (params.containsKey("RememberObjects")) {
|
||||
animateRemembered = params.get("RememberObjects");
|
||||
if (sa.hasParam("RememberObjects")) {
|
||||
animateRemembered = sa.getParam("RememberObjects");
|
||||
}
|
||||
|
||||
// AF specific params
|
||||
// AF specific sa
|
||||
int power = -1;
|
||||
if (params.containsKey("Power")) {
|
||||
power = AbilityFactory.calculateAmount(host, params.get("Power"), sa);
|
||||
if (sa.hasParam("Power")) {
|
||||
power = AbilityFactory.calculateAmount(host, sa.getParam("Power"), sa);
|
||||
}
|
||||
int toughness = -1;
|
||||
if (params.containsKey("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
||||
if (sa.hasParam("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(host, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
|
||||
// Every Animate event needs a unique time stamp
|
||||
@@ -56,16 +56,16 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
final long timestamp = timest;
|
||||
|
||||
final boolean permanent = params.containsKey("Permanent");
|
||||
final boolean permanent = sa.hasParam("Permanent");
|
||||
|
||||
final ArrayList<String> types = new ArrayList<String>();
|
||||
if (params.containsKey("Types")) {
|
||||
types.addAll(Arrays.asList(params.get("Types").split(",")));
|
||||
if (sa.hasParam("Types")) {
|
||||
types.addAll(Arrays.asList(sa.getParam("Types").split(",")));
|
||||
}
|
||||
|
||||
final ArrayList<String> removeTypes = new ArrayList<String>();
|
||||
if (params.containsKey("RemoveTypes")) {
|
||||
removeTypes.addAll(Arrays.asList(params.get("RemoveTypes").split(",")));
|
||||
if (sa.hasParam("RemoveTypes")) {
|
||||
removeTypes.addAll(Arrays.asList(sa.getParam("RemoveTypes").split(",")));
|
||||
}
|
||||
|
||||
// allow ChosenType - overrides anything else specified
|
||||
@@ -75,18 +75,18 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
final ArrayList<String> keywords = new ArrayList<String>();
|
||||
if (params.containsKey("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
||||
if (sa.hasParam("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & ")));
|
||||
}
|
||||
|
||||
final ArrayList<String> removeKeywords = new ArrayList<String>();
|
||||
if (params.containsKey("RemoveKeywords")) {
|
||||
removeKeywords.addAll(Arrays.asList(params.get("RemoveKeywords").split(" & ")));
|
||||
if (sa.hasParam("RemoveKeywords")) {
|
||||
removeKeywords.addAll(Arrays.asList(sa.getParam("RemoveKeywords").split(" & ")));
|
||||
}
|
||||
|
||||
final ArrayList<String> hiddenKeywords = new ArrayList<String>();
|
||||
if (params.containsKey("HiddenKeywords")) {
|
||||
hiddenKeywords.addAll(Arrays.asList(params.get("HiddenKeywords").split(" & ")));
|
||||
if (sa.hasParam("HiddenKeywords")) {
|
||||
hiddenKeywords.addAll(Arrays.asList(sa.getParam("HiddenKeywords").split(" & ")));
|
||||
}
|
||||
// allow SVar substitution for keywords
|
||||
for (int i = 0; i < keywords.size(); i++) {
|
||||
@@ -99,8 +99,8 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
// colors to be added or changed to
|
||||
String tmpDesc = "";
|
||||
if (params.containsKey("Colors")) {
|
||||
final String colors = params.get("Colors");
|
||||
if (sa.hasParam("Colors")) {
|
||||
final String colors = sa.getParam("Colors");
|
||||
if (colors.equals("ChosenColor")) {
|
||||
|
||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
||||
@@ -112,26 +112,26 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
// abilities to add to the animated being
|
||||
final ArrayList<String> abilities = new ArrayList<String>();
|
||||
if (params.containsKey("Abilities")) {
|
||||
abilities.addAll(Arrays.asList(params.get("Abilities").split(",")));
|
||||
if (sa.hasParam("Abilities")) {
|
||||
abilities.addAll(Arrays.asList(sa.getParam("Abilities").split(",")));
|
||||
}
|
||||
|
||||
// triggers to add to the animated being
|
||||
final ArrayList<String> triggers = new ArrayList<String>();
|
||||
if (params.containsKey("Triggers")) {
|
||||
triggers.addAll(Arrays.asList(params.get("Triggers").split(",")));
|
||||
if (sa.hasParam("Triggers")) {
|
||||
triggers.addAll(Arrays.asList(sa.getParam("Triggers").split(",")));
|
||||
}
|
||||
|
||||
// static abilities to add to the animated being
|
||||
final ArrayList<String> stAbs = new ArrayList<String>();
|
||||
if (params.containsKey("staticAbilities")) {
|
||||
stAbs.addAll(Arrays.asList(params.get("staticAbilities").split(",")));
|
||||
if (sa.hasParam("staticAbilities")) {
|
||||
stAbs.addAll(Arrays.asList(sa.getParam("staticAbilities").split(",")));
|
||||
}
|
||||
|
||||
// sVars to add to the animated being
|
||||
final ArrayList<String> sVars = new ArrayList<String>();
|
||||
if (params.containsKey("sVars")) {
|
||||
sVars.addAll(Arrays.asList(params.get("sVars").split(",")));
|
||||
if (sa.hasParam("sVars")) {
|
||||
sVars.addAll(Arrays.asList(sa.getParam("sVars").split(",")));
|
||||
}
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -139,12 +139,12 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
if (tgt != null) {
|
||||
tgts = tgt.getTargetCards();
|
||||
} else {
|
||||
tgts = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||
tgts = AbilityFactory.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
}
|
||||
|
||||
for (final Card c : tgts) {
|
||||
|
||||
final long colorTimestamp = doAnimate(c, params, power, toughness, types, removeTypes,
|
||||
final long colorTimestamp = doAnimate(c, sa, power, toughness, types, removeTypes,
|
||||
finalDesc, keywords, removeKeywords, hiddenKeywords, timestamp);
|
||||
|
||||
// give abilities
|
||||
@@ -161,7 +161,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
// remove abilities
|
||||
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||
if (params.containsKey("OverwriteAbilities") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteAbilities") || sa.hasParam("RemoveAllAbilities")) {
|
||||
for (final SpellAbility ab : c.getSpellAbilities()) {
|
||||
if (ab.isAbility()) {
|
||||
c.removeSpellAbility(ab);
|
||||
@@ -182,7 +182,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
// suppress triggers from the animated card
|
||||
final ArrayList<Trigger> removedTriggers = new ArrayList<Trigger>();
|
||||
if (params.containsKey("OverwriteTriggers") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteTriggers") || sa.hasParam("RemoveAllAbilities")) {
|
||||
final List<Trigger> triggersToRemove = c.getTriggers();
|
||||
for (final Trigger trigger : triggersToRemove) {
|
||||
trigger.setSuppressed(true);
|
||||
@@ -209,7 +209,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
// suppress static abilities from the animated card
|
||||
final ArrayList<StaticAbility> removedStatics = new ArrayList<StaticAbility>();
|
||||
if (params.containsKey("OverwriteStatics") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteStatics") || sa.hasParam("RemoveAllAbilities")) {
|
||||
final ArrayList<StaticAbility> staticsToRemove = c.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticsToRemove) {
|
||||
stAb.setTemporarilySuppressed(true);
|
||||
@@ -219,7 +219,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
// suppress static abilities from the animated card
|
||||
final ArrayList<ReplacementEffect> removedReplacements = new ArrayList<ReplacementEffect>();
|
||||
if (params.containsKey("OverwriteReplacements") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (sa.hasParam("OverwriteReplacements") || sa.hasParam("RemoveAllAbilities")) {
|
||||
final ArrayList<ReplacementEffect> replacementsToRemove = c.getReplacementEffects();
|
||||
for (final ReplacementEffect re : replacementsToRemove) {
|
||||
re.setTemporarilySuppressed(true);
|
||||
@@ -241,7 +241,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
doUnanimate(c, params, finalDesc, hiddenKeywords, addedAbilities, addedTriggers,
|
||||
doUnanimate(c, sa, finalDesc, hiddenKeywords, addedAbilities, addedTriggers,
|
||||
colorTimestamp, givesStAbs, removedAbilities, timestamp);
|
||||
|
||||
// give back suppressed triggers
|
||||
@@ -262,15 +262,15 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
};
|
||||
|
||||
if (!permanent) {
|
||||
if (params.containsKey("UntilEndOfCombat")) {
|
||||
if (sa.hasParam("UntilEndOfCombat")) {
|
||||
Singletons.getModel().getGame().getEndOfCombat().addUntil(unanimate);
|
||||
} else if (params.containsKey("UntilHostLeavesPlay")) {
|
||||
} else if (sa.hasParam("UntilHostLeavesPlay")) {
|
||||
host.addLeavesPlayCommand(unanimate);
|
||||
} else if (params.containsKey("UntilYourNextUpkeep")) {
|
||||
} else if (sa.hasParam("UntilYourNextUpkeep")) {
|
||||
Singletons.getModel().getGame().getUpkeep().addUntil(host.getController(), unanimate);
|
||||
} else if (params.containsKey("UntilControllerNextUntap")) {
|
||||
} else if (sa.hasParam("UntilControllerNextUntap")) {
|
||||
Singletons.getModel().getGame().getUntap().addUntil(c.getController(), unanimate);
|
||||
} else if (params.containsKey("UntilYourNextTurn")) {
|
||||
} else if (sa.hasParam("UntilYourNextTurn")) {
|
||||
Singletons.getModel().getGame().getCleanup().addUntilYourNextTurn(host.getController(), unanimate);
|
||||
} else {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addUntil(unanimate);
|
||||
@@ -283,27 +283,27 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(Map<String, String> params, SpellAbility sa) {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final Card host = sa.getSourceCard();
|
||||
final Map<String, String> svars = host.getSVars();
|
||||
|
||||
int power = -1;
|
||||
if (params.containsKey("Power")) {
|
||||
power = AbilityFactory.calculateAmount(host, params.get("Power"), sa);
|
||||
if (sa.hasParam("Power")) {
|
||||
power = AbilityFactory.calculateAmount(host, sa.getParam("Power"), sa);
|
||||
}
|
||||
int toughness = -1;
|
||||
if (params.containsKey("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
||||
if (sa.hasParam("Toughness")) {
|
||||
toughness = AbilityFactory.calculateAmount(host, sa.getParam("Toughness"), sa);
|
||||
}
|
||||
|
||||
final boolean permanent = params.containsKey("Permanent");
|
||||
final boolean permanent = sa.hasParam("Permanent");
|
||||
final ArrayList<String> types = new ArrayList<String>();
|
||||
if (params.containsKey("Types")) {
|
||||
types.addAll(Arrays.asList(params.get("Types").split(",")));
|
||||
if (sa.hasParam("Types")) {
|
||||
types.addAll(Arrays.asList(sa.getParam("Types").split(",")));
|
||||
}
|
||||
final ArrayList<String> keywords = new ArrayList<String>();
|
||||
if (params.containsKey("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
||||
if (sa.hasParam("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & ")));
|
||||
}
|
||||
// allow SVar substitution for keywords
|
||||
for (int i = 0; i < keywords.size(); i++) {
|
||||
@@ -314,14 +314,14 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
}
|
||||
}
|
||||
final ArrayList<String> colors = new ArrayList<String>();
|
||||
if (params.containsKey("Colors")) {
|
||||
colors.addAll(Arrays.asList(params.get("Colors").split(",")));
|
||||
if (sa.hasParam("Colors")) {
|
||||
colors.addAll(Arrays.asList(sa.getParam("Colors").split(",")));
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final List<Card> tgts = tgt != null ? tgt.getTargetCards() : AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||
final List<Card> tgts = tgt != null ? tgt.getTargetCards() : AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
for (final Card c : tgts) {
|
||||
sb.append(c).append(" ");
|
||||
@@ -369,13 +369,13 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
// sb.append(abilities)
|
||||
// sb.append(triggers)
|
||||
if (!permanent) {
|
||||
if (params.containsKey("UntilEndOfCombat")) {
|
||||
if (sa.hasParam("UntilEndOfCombat")) {
|
||||
sb.append(" until end of combat.");
|
||||
} else if (params.containsKey("UntilHostLeavesPlay")) {
|
||||
} else if (sa.hasParam("UntilHostLeavesPlay")) {
|
||||
sb.append(" until ").append(host).append(" leaves the battlefield.");
|
||||
} else if (params.containsKey("UntilYourNextUpkeep")) {
|
||||
} else if (sa.hasParam("UntilYourNextUpkeep")) {
|
||||
sb.append(" until your next upkeep.");
|
||||
} else if (params.containsKey("UntilControllerNextUntap")) {
|
||||
} else if (sa.hasParam("UntilControllerNextUntap")) {
|
||||
sb.append(" until its controller's next untap step.");
|
||||
} else {
|
||||
sb.append(" until end of turn.");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user