mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
checkstyle
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -57,22 +57,22 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return animateCanPlayAI(af, this);
|
return AbilityFactory_Animate.animateCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
animateResolve(af, this);
|
AbilityFactory_Animate.animateResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return animateStackDescription(af, this);
|
return AbilityFactory_Animate.animateStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return animateTriggerAI(af, this, mandatory);
|
return AbilityFactory_Animate.animateTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return abAnimate;
|
return abAnimate;
|
||||||
@@ -93,17 +93,17 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return animateCanPlayAI(af, this);
|
return AbilityFactory_Animate.animateCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
animateResolve(af, this);
|
AbilityFactory_Animate.animateResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return animateStackDescription(af, this);
|
return AbilityFactory_Animate.animateStackDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return spAnimate;
|
return spAnimate;
|
||||||
@@ -124,22 +124,22 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
animateResolve(af, this);
|
AbilityFactory_Animate.animateResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return animatePlayDrawbackAI(af, this);
|
return AbilityFactory_Animate.animatePlayDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return animateStackDescription(af, this);
|
return AbilityFactory_Animate.animateStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return animateTriggerAI(af, this, mandatory);
|
return AbilityFactory_Animate.animateTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return dbAnimate;
|
return dbAnimate;
|
||||||
@@ -157,9 +157,9 @@ public final class AbilityFactory_Animate {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String animateStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String animateStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
Map<String, String> svars = host.getSVars();
|
final Map<String, String> svars = host.getSVars();
|
||||||
|
|
||||||
int power = -1;
|
int power = -1;
|
||||||
if (params.containsKey("Power")) {
|
if (params.containsKey("Power")) {
|
||||||
@@ -170,7 +170,7 @@ public final class AbilityFactory_Animate {
|
|||||||
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
toughness = AbilityFactory.calculateAmount(host, params.get("Toughness"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean permanent = params.containsKey("Permanent");
|
final boolean permanent = params.containsKey("Permanent");
|
||||||
final ArrayList<String> types = new ArrayList<String>();
|
final ArrayList<String> types = new ArrayList<String>();
|
||||||
if (params.containsKey("Types")) {
|
if (params.containsKey("Types")) {
|
||||||
types.addAll(Arrays.asList(params.get("Types").split(",")));
|
types.addAll(Arrays.asList(params.get("Types").split(",")));
|
||||||
@@ -181,18 +181,18 @@ public final class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
// allow SVar substitution for keywords
|
// allow SVar substitution for keywords
|
||||||
for (int i = 0; i < keywords.size(); i++) {
|
for (int i = 0; i < keywords.size(); i++) {
|
||||||
String k = keywords.get(i);
|
final String k = keywords.get(i);
|
||||||
if (svars.containsKey(k)) {
|
if (svars.containsKey(k)) {
|
||||||
keywords.add("\"" + k + "\"");
|
keywords.add("\"" + k + "\"");
|
||||||
keywords.remove(k);
|
keywords.remove(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<String> colors = new ArrayList<String>();
|
final ArrayList<String> colors = new ArrayList<String>();
|
||||||
if (params.containsKey("Colors")) {
|
if (params.containsKey("Colors")) {
|
||||||
colors.addAll(Arrays.asList(params.get("Colors").split(",")));
|
colors.addAll(Arrays.asList(params.get("Colors").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -200,7 +200,7 @@ public final class AbilityFactory_Animate {
|
|||||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
ArrayList<Card> tgts;
|
ArrayList<Card> tgts;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgts = tgt.getTargetCards();
|
tgts = tgt.getTargetCards();
|
||||||
@@ -208,7 +208,7 @@ public final class AbilityFactory_Animate {
|
|||||||
tgts = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
tgts = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card c : tgts) {
|
for (final Card c : tgts) {
|
||||||
sb.append(c).append(" ");
|
sb.append(c).append(" ");
|
||||||
}
|
}
|
||||||
sb.append("become");
|
sb.append("become");
|
||||||
@@ -267,7 +267,7 @@ public final class AbilityFactory_Animate {
|
|||||||
sb.append(".");
|
sb.append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -288,9 +288,9 @@ public final class AbilityFactory_Animate {
|
|||||||
*/
|
*/
|
||||||
private static boolean animateCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean animateCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
boolean useAbility = true;
|
boolean useAbility = true;
|
||||||
|
|
||||||
@@ -309,8 +309,8 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
// don't use instant speed animate abilities outside humans
|
// don't use instant speed animate abilities outside humans
|
||||||
// Combat_Declare_Attackers_InstantAbility step
|
// Combat_Declare_Attackers_InstantAbility step
|
||||||
if ((!AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || AllZone.getCombat()
|
if ((!AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || (AllZone.getCombat()
|
||||||
.getAttackers().length == 0) && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
|
.getAttackers().length == 0)) && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,10 +320,10 @@ public final class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null == tgt) {
|
if (null == tgt) {
|
||||||
ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
final ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||||
|
|
||||||
boolean bFlag = false;
|
boolean bFlag = false;
|
||||||
for (Card c : defined) {
|
for (final Card c : defined) {
|
||||||
bFlag |= (!c.isCreature() && !c.isTapped() && !(c.getTurnInZone() == AllZone.getPhase().getTurn()));
|
bFlag |= (!c.isCreature() && !c.isTapped() && !(c.getTurnInZone() == AllZone.getPhase().getTurn()));
|
||||||
|
|
||||||
// for creatures that could be improved (like Figure of Destiny)
|
// for creatures that could be improved (like Figure of Destiny)
|
||||||
@@ -336,7 +336,7 @@ public final class AbilityFactory_Animate {
|
|||||||
if (params.containsKey("Toughness")) {
|
if (params.containsKey("Toughness")) {
|
||||||
toughness = AbilityFactory.calculateAmount(source, params.get("Toughness"), sa);
|
toughness = AbilityFactory.calculateAmount(source, params.get("Toughness"), sa);
|
||||||
}
|
}
|
||||||
if (power + toughness > c.getCurrentPower() + c.getCurrentToughness()) {
|
if ((power + toughness) > (c.getCurrentPower() + c.getCurrentToughness())) {
|
||||||
bFlag = true;
|
bFlag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,10 +349,10 @@ public final class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
useAbility &= animateTgtAI(af, sa);
|
useAbility &= AbilityFactory_Animate.animateTgtAI(af, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
useAbility &= subAb.chkAIDrawback();
|
useAbility &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -373,11 +373,11 @@ public final class AbilityFactory_Animate {
|
|||||||
*/
|
*/
|
||||||
private static boolean animatePlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean animatePlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI should only activate this during Human's turn
|
// AI should only activate this during Human's turn
|
||||||
boolean chance = animateTgtAI(af, sa);
|
boolean chance = AbilityFactory_Animate.animateTgtAI(af, sa);
|
||||||
|
|
||||||
// TODO - restrict the subAbility a bit
|
// TODO - restrict the subAbility a bit
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ public final class AbilityFactory_Animate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean chance = animateTgtAI(af, sa);
|
boolean chance = AbilityFactory_Animate.animateTgtAI(af, sa);
|
||||||
|
|
||||||
// Improve AI for triggers. If source is a creature with:
|
// Improve AI for triggers. If source is a creature with:
|
||||||
// When ETB, sacrifice a creature. Check to see if the AI has something
|
// When ETB, sacrifice a creature. Check to see if the AI has something
|
||||||
@@ -412,7 +412,7 @@ public final class AbilityFactory_Animate {
|
|||||||
// Eventually, we can call the trigger of ETB abilities with
|
// Eventually, we can call the trigger of ETB abilities with
|
||||||
// not mandatory as part of the checks to cast something
|
// not mandatory as part of the checks to cast something
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -451,10 +451,10 @@ public final class AbilityFactory_Animate {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void animateResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void animateResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
Map<String, String> svars = host.getSVars();
|
final Map<String, String> svars = host.getSVars();
|
||||||
long timest = -1;
|
long timest = -1;
|
||||||
|
|
||||||
// AF specific params
|
// AF specific params
|
||||||
@@ -472,7 +472,7 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
final long timestamp = timest;
|
final long timestamp = timest;
|
||||||
|
|
||||||
boolean permanent = params.containsKey("Permanent");
|
final boolean permanent = params.containsKey("Permanent");
|
||||||
|
|
||||||
final ArrayList<String> types = new ArrayList<String>();
|
final ArrayList<String> types = new ArrayList<String>();
|
||||||
if (params.containsKey("Types")) {
|
if (params.containsKey("Types")) {
|
||||||
@@ -501,7 +501,7 @@ public final class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
// allow SVar substitution for keywords
|
// allow SVar substitution for keywords
|
||||||
for (int i = 0; i < keywords.size(); i++) {
|
for (int i = 0; i < keywords.size(); i++) {
|
||||||
String k = keywords.get(i);
|
final String k = keywords.get(i);
|
||||||
if (svars.containsKey(k)) {
|
if (svars.containsKey(k)) {
|
||||||
keywords.add(svars.get(k));
|
keywords.add(svars.get(k));
|
||||||
keywords.remove(k);
|
keywords.remove(k);
|
||||||
@@ -511,7 +511,7 @@ public final class AbilityFactory_Animate {
|
|||||||
// colors to be added or changed to
|
// colors to be added or changed to
|
||||||
String tmpDesc = "";
|
String tmpDesc = "";
|
||||||
if (params.containsKey("Colors")) {
|
if (params.containsKey("Colors")) {
|
||||||
String colors = params.get("Colors");
|
final String colors = params.get("Colors");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
|
|
||||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
||||||
@@ -522,30 +522,30 @@ public final class AbilityFactory_Animate {
|
|||||||
final String finalDesc = tmpDesc;
|
final String finalDesc = tmpDesc;
|
||||||
|
|
||||||
// abilities to add to the animated being
|
// abilities to add to the animated being
|
||||||
ArrayList<String> abilities = new ArrayList<String>();
|
final ArrayList<String> abilities = new ArrayList<String>();
|
||||||
if (params.containsKey("Abilities")) {
|
if (params.containsKey("Abilities")) {
|
||||||
abilities.addAll(Arrays.asList(params.get("Abilities").split(",")));
|
abilities.addAll(Arrays.asList(params.get("Abilities").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// triggers to add to the animated being
|
// triggers to add to the animated being
|
||||||
ArrayList<String> triggers = new ArrayList<String>();
|
final ArrayList<String> triggers = new ArrayList<String>();
|
||||||
if (params.containsKey("Triggers")) {
|
if (params.containsKey("Triggers")) {
|
||||||
triggers.addAll(Arrays.asList(params.get("Triggers").split(",")));
|
triggers.addAll(Arrays.asList(params.get("Triggers").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static abilities to add to the animated being
|
// static abilities to add to the animated being
|
||||||
ArrayList<String> stAbs = new ArrayList<String>();
|
final ArrayList<String> stAbs = new ArrayList<String>();
|
||||||
if (params.containsKey("staticAbilities")) {
|
if (params.containsKey("staticAbilities")) {
|
||||||
stAbs.addAll(Arrays.asList(params.get("staticAbilities").split(",")));
|
stAbs.addAll(Arrays.asList(params.get("staticAbilities").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// sVars to add to the animated being
|
// sVars to add to the animated being
|
||||||
ArrayList<String> sVars = new ArrayList<String>();
|
final ArrayList<String> sVars = new ArrayList<String>();
|
||||||
if (params.containsKey("sVars")) {
|
if (params.containsKey("sVars")) {
|
||||||
sVars.addAll(Arrays.asList(params.get("sVars").split(",")));
|
sVars.addAll(Arrays.asList(params.get("sVars").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
ArrayList<Card> tgts;
|
ArrayList<Card> tgts;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgts = tgt.getTargetCards();
|
tgts = tgt.getTargetCards();
|
||||||
@@ -555,16 +555,16 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
for (final Card c : tgts) {
|
for (final Card c : tgts) {
|
||||||
|
|
||||||
final long colorTimestamp = doAnimate(c, af, power, toughness, types, removeTypes, finalDesc, keywords,
|
final long colorTimestamp = AbilityFactory_Animate.doAnimate(c, af, power, toughness, types, removeTypes,
|
||||||
hiddenKeywords, timestamp);
|
finalDesc, keywords, hiddenKeywords, timestamp);
|
||||||
|
|
||||||
// give abilities
|
// give abilities
|
||||||
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
||||||
if (abilities.size() > 0) {
|
if (abilities.size() > 0) {
|
||||||
for (String s : abilities) {
|
for (final String s : abilities) {
|
||||||
AbilityFactory newAF = new AbilityFactory();
|
final AbilityFactory newAF = new AbilityFactory();
|
||||||
String actualAbility = host.getSVar(s);
|
final String actualAbility = host.getSVar(s);
|
||||||
SpellAbility grantedAbility = newAF.getAbility(actualAbility, c);
|
final SpellAbility grantedAbility = newAF.getAbility(actualAbility, c);
|
||||||
addedAbilities.add(grantedAbility);
|
addedAbilities.add(grantedAbility);
|
||||||
c.addSpellAbility(grantedAbility);
|
c.addSpellAbility(grantedAbility);
|
||||||
}
|
}
|
||||||
@@ -573,7 +573,7 @@ public final class AbilityFactory_Animate {
|
|||||||
// remove abilities
|
// remove abilities
|
||||||
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||||
if (params.containsKey("OverwriteAbilities") || params.containsKey("RemoveAllAbilities")) {
|
if (params.containsKey("OverwriteAbilities") || params.containsKey("RemoveAllAbilities")) {
|
||||||
for (SpellAbility ab : c.getSpellAbilities()) {
|
for (final SpellAbility ab : c.getSpellAbilities()) {
|
||||||
if (ab.isAbility()) {
|
if (ab.isAbility()) {
|
||||||
c.removeSpellAbility(ab);
|
c.removeSpellAbility(ab);
|
||||||
removedAbilities.add(ab);
|
removedAbilities.add(ab);
|
||||||
@@ -584,9 +584,9 @@ public final class AbilityFactory_Animate {
|
|||||||
// Grant triggers
|
// Grant triggers
|
||||||
final ArrayList<Trigger> addedTriggers = new ArrayList<Trigger>();
|
final ArrayList<Trigger> addedTriggers = new ArrayList<Trigger>();
|
||||||
if (triggers.size() > 0) {
|
if (triggers.size() > 0) {
|
||||||
for (String s : triggers) {
|
for (final String s : triggers) {
|
||||||
String actualTrigger = host.getSVar(s);
|
final String actualTrigger = host.getSVar(s);
|
||||||
Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c, false);
|
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c, false);
|
||||||
addedTriggers.add(c.addTrigger(parsedTrigger));
|
addedTriggers.add(c.addTrigger(parsedTrigger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -594,8 +594,8 @@ public final class AbilityFactory_Animate {
|
|||||||
// suppress triggers from the animated card
|
// suppress triggers from the animated card
|
||||||
final ArrayList<Trigger> removedTriggers = new ArrayList<Trigger>();
|
final ArrayList<Trigger> removedTriggers = new ArrayList<Trigger>();
|
||||||
if (params.containsKey("OverwriteTriggers") || params.containsKey("RemoveAllAbilities")) {
|
if (params.containsKey("OverwriteTriggers") || params.containsKey("RemoveAllAbilities")) {
|
||||||
ArrayList<Trigger> triggersToRemove = c.getTriggers();
|
final ArrayList<Trigger> triggersToRemove = c.getTriggers();
|
||||||
for (Trigger trigger : triggersToRemove) {
|
for (final Trigger trigger : triggersToRemove) {
|
||||||
trigger.setSuppressed(true);
|
trigger.setSuppressed(true);
|
||||||
removedTriggers.add(trigger);
|
removedTriggers.add(trigger);
|
||||||
}
|
}
|
||||||
@@ -604,16 +604,16 @@ public final class AbilityFactory_Animate {
|
|||||||
// give static abilities (should only be used by cards to give
|
// give static abilities (should only be used by cards to give
|
||||||
// itself a static ability)
|
// itself a static ability)
|
||||||
if (stAbs.size() > 0) {
|
if (stAbs.size() > 0) {
|
||||||
for (String s : stAbs) {
|
for (final String s : stAbs) {
|
||||||
String actualAbility = host.getSVar(s);
|
final String actualAbility = host.getSVar(s);
|
||||||
c.addStaticAbility(actualAbility);
|
c.addStaticAbility(actualAbility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// give sVars
|
// give sVars
|
||||||
if (sVars.size() > 0) {
|
if (sVars.size() > 0) {
|
||||||
for (String s : sVars) {
|
for (final String s : sVars) {
|
||||||
String actualsVar = host.getSVar(s);
|
final String actualsVar = host.getSVar(s);
|
||||||
c.setSVar(s, actualsVar);
|
c.setSVar(s, actualsVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -623,12 +623,13 @@ public final class AbilityFactory_Animate {
|
|||||||
final Command unanimate = new Command() {
|
final Command unanimate = new Command() {
|
||||||
private static final long serialVersionUID = -5861759814760561373L;
|
private static final long serialVersionUID = -5861759814760561373L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
doUnanimate(c, af, finalDesc, hiddenKeywords, addedAbilities, addedTriggers, colorTimestamp, givesStAbs,
|
AbilityFactory_Animate.doUnanimate(c, af, finalDesc, hiddenKeywords, addedAbilities, addedTriggers,
|
||||||
removedAbilities, timestamp);
|
colorTimestamp, givesStAbs, removedAbilities, timestamp);
|
||||||
|
|
||||||
// give back suppressed triggers
|
// give back suppressed triggers
|
||||||
for (Trigger t : removedTriggers) {
|
for (final Trigger t : removedTriggers) {
|
||||||
t.setSuppressed(false);
|
t.setSuppressed(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -672,7 +673,7 @@ public final class AbilityFactory_Animate {
|
|||||||
private static long doAnimate(final Card c, final AbilityFactory af, final int power, final int toughness,
|
private static long doAnimate(final Card c, final AbilityFactory af, final int power, final int toughness,
|
||||||
final ArrayList<String> types, final ArrayList<String> removeTypes, final String colors,
|
final ArrayList<String> types, final ArrayList<String> removeTypes, final String colors,
|
||||||
final ArrayList<String> keywords, final ArrayList<String> hiddenKeywords, final long timestamp) {
|
final ArrayList<String> keywords, final ArrayList<String> hiddenKeywords, final long timestamp) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
boolean removeSuperTypes = false;
|
boolean removeSuperTypes = false;
|
||||||
boolean removeCardTypes = false;
|
boolean removeCardTypes = false;
|
||||||
@@ -710,7 +711,7 @@ public final class AbilityFactory_Animate {
|
|||||||
removeCreatureTypes = true;
|
removeCreatureTypes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (power != -1 || toughness != -1) {
|
if ((power != -1) || (toughness != -1)) {
|
||||||
c.addNewPT(power, toughness, timestamp);
|
c.addNewPT(power, toughness, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,11 +722,11 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
c.addChangedCardKeywords(keywords, null, params.containsKey("RemoveAllAbilities"), timestamp);
|
c.addChangedCardKeywords(keywords, null, params.containsKey("RemoveAllAbilities"), timestamp);
|
||||||
|
|
||||||
for (String k : hiddenKeywords) {
|
for (final String k : hiddenKeywords) {
|
||||||
c.addExtrinsicKeyword(k);
|
c.addExtrinsicKeyword(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
long colorTimestamp = c.addColor(colors, c, !params.containsKey("OverwriteColors"), true);
|
final long colorTimestamp = c.addColor(colors, c, !params.containsKey("OverwriteColors"), true);
|
||||||
return colorTimestamp;
|
return colorTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,7 +758,7 @@ public final class AbilityFactory_Animate {
|
|||||||
final ArrayList<String> addedKeywords, final ArrayList<SpellAbility> addedAbilities,
|
final ArrayList<String> addedKeywords, final ArrayList<SpellAbility> addedAbilities,
|
||||||
final ArrayList<Trigger> addedTriggers, final long colorTimestamp, final boolean givesStAbs,
|
final ArrayList<Trigger> addedTriggers, final long colorTimestamp, final boolean givesStAbs,
|
||||||
final ArrayList<SpellAbility> removedAbilities, final long timestamp) {
|
final ArrayList<SpellAbility> removedAbilities, final long timestamp) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
c.removeNewPT(timestamp);
|
c.removeNewPT(timestamp);
|
||||||
|
|
||||||
@@ -775,19 +776,19 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
c.removeColor(colorDesc, c, !params.containsKey("OverwriteColors"), colorTimestamp);
|
c.removeColor(colorDesc, c, !params.containsKey("OverwriteColors"), colorTimestamp);
|
||||||
|
|
||||||
for (String k : addedKeywords) {
|
for (final String k : addedKeywords) {
|
||||||
c.removeExtrinsicKeyword(k);
|
c.removeExtrinsicKeyword(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SpellAbility sa : addedAbilities) {
|
for (final SpellAbility sa : addedAbilities) {
|
||||||
c.removeSpellAbility(sa);
|
c.removeSpellAbility(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SpellAbility sa : removedAbilities) {
|
for (final SpellAbility sa : removedAbilities) {
|
||||||
c.addSpellAbility(sa);
|
c.addSpellAbility(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Trigger t : addedTriggers) {
|
for (final Trigger t : addedTriggers) {
|
||||||
c.removeTrigger(t);
|
c.removeTrigger(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -816,22 +817,22 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return animateAllCanPlayAI(af, this);
|
return AbilityFactory_Animate.animateAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
animateAllResolve(af, this);
|
AbilityFactory_Animate.animateAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return animateAllStackDescription(af, this);
|
return AbilityFactory_Animate.animateAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return animateAllTriggerAI(af, this, mandatory);
|
return AbilityFactory_Animate.animateAllTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return abAnimateAll;
|
return abAnimateAll;
|
||||||
@@ -852,17 +853,17 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return animateAllCanPlayAI(af, this);
|
return AbilityFactory_Animate.animateAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
animateAllResolve(af, this);
|
AbilityFactory_Animate.animateAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return animateAllStackDescription(af, this);
|
return AbilityFactory_Animate.animateAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return spAnimateAll;
|
return spAnimateAll;
|
||||||
@@ -883,22 +884,22 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
animateAllResolve(af, this);
|
AbilityFactory_Animate.animateAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return animateAllPlayDrawbackAI(af, this);
|
return AbilityFactory_Animate.animateAllPlayDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return animateAllStackDescription(af, this);
|
return AbilityFactory_Animate.animateAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return animateAllTriggerAI(af, this, mandatory);
|
return AbilityFactory_Animate.animateAllTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return dbAnimateAll;
|
return dbAnimateAll;
|
||||||
@@ -916,9 +917,9 @@ public final class AbilityFactory_Animate {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String animateAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String animateAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -935,7 +936,7 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
sb.append(desc);
|
sb.append(desc);
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -957,7 +958,7 @@ public final class AbilityFactory_Animate {
|
|||||||
private static boolean animateAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean animateAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
boolean useAbility = false;
|
boolean useAbility = false;
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
useAbility &= subAb.chkAIDrawback();
|
useAbility &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -979,7 +980,7 @@ public final class AbilityFactory_Animate {
|
|||||||
private static boolean animateAllPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean animateAllPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
boolean chance = false;
|
boolean chance = false;
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -1000,15 +1001,14 @@ public final class AbilityFactory_Animate {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean animateAllTriggerAI(final AbilityFactory af,
|
private static boolean animateAllTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
if (!ComputerUtil.canPayCost(sa)) { // If there is a cost payment
|
if (!ComputerUtil.canPayCost(sa)) { // If there is a cost payment
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean chance = false;
|
boolean chance = false;
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -1027,9 +1027,9 @@ public final class AbilityFactory_Animate {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void animateAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void animateAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
Map<String, String> svars = host.getSVars();
|
final Map<String, String> svars = host.getSVars();
|
||||||
long timest = -1;
|
long timest = -1;
|
||||||
|
|
||||||
// AF specific params
|
// AF specific params
|
||||||
@@ -1047,7 +1047,7 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
final long timestamp = timest;
|
final long timestamp = timest;
|
||||||
|
|
||||||
boolean permanent = params.containsKey("Permanent");
|
final boolean permanent = params.containsKey("Permanent");
|
||||||
|
|
||||||
final ArrayList<String> types = new ArrayList<String>();
|
final ArrayList<String> types = new ArrayList<String>();
|
||||||
if (params.containsKey("Types")) {
|
if (params.containsKey("Types")) {
|
||||||
@@ -1076,7 +1076,7 @@ public final class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
// allow SVar substitution for keywords
|
// allow SVar substitution for keywords
|
||||||
for (int i = 0; i < keywords.size(); i++) {
|
for (int i = 0; i < keywords.size(); i++) {
|
||||||
String k = keywords.get(i);
|
final String k = keywords.get(i);
|
||||||
if (svars.containsKey(k)) {
|
if (svars.containsKey(k)) {
|
||||||
keywords.add(svars.get(k));
|
keywords.add(svars.get(k));
|
||||||
keywords.remove(k);
|
keywords.remove(k);
|
||||||
@@ -1086,7 +1086,7 @@ public final class AbilityFactory_Animate {
|
|||||||
// colors to be added or changed to
|
// colors to be added or changed to
|
||||||
String tmpDesc = "";
|
String tmpDesc = "";
|
||||||
if (params.containsKey("Colors")) {
|
if (params.containsKey("Colors")) {
|
||||||
String colors = params.get("Colors");
|
final String colors = params.get("Colors");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
||||||
} else {
|
} else {
|
||||||
@@ -1096,19 +1096,19 @@ public final class AbilityFactory_Animate {
|
|||||||
final String finalDesc = tmpDesc;
|
final String finalDesc = tmpDesc;
|
||||||
|
|
||||||
// abilities to add to the animated being
|
// abilities to add to the animated being
|
||||||
ArrayList<String> abilities = new ArrayList<String>();
|
final ArrayList<String> abilities = new ArrayList<String>();
|
||||||
if (params.containsKey("Abilities")) {
|
if (params.containsKey("Abilities")) {
|
||||||
abilities.addAll(Arrays.asList(params.get("Abilities").split(",")));
|
abilities.addAll(Arrays.asList(params.get("Abilities").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// triggers to add to the animated being
|
// triggers to add to the animated being
|
||||||
ArrayList<String> triggers = new ArrayList<String>();
|
final ArrayList<String> triggers = new ArrayList<String>();
|
||||||
if (params.containsKey("Triggers")) {
|
if (params.containsKey("Triggers")) {
|
||||||
triggers.addAll(Arrays.asList(params.get("Triggers").split(",")));
|
triggers.addAll(Arrays.asList(params.get("Triggers").split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// sVars to add to the animated being
|
// sVars to add to the animated being
|
||||||
ArrayList<String> sVars = new ArrayList<String>();
|
final ArrayList<String> sVars = new ArrayList<String>();
|
||||||
if (params.containsKey("sVars")) {
|
if (params.containsKey("sVars")) {
|
||||||
sVars.addAll(Arrays.asList(params.get("sVars").split(",")));
|
sVars.addAll(Arrays.asList(params.get("sVars").split(",")));
|
||||||
}
|
}
|
||||||
@@ -1122,7 +1122,7 @@ public final class AbilityFactory_Animate {
|
|||||||
CardList list;
|
CardList list;
|
||||||
ArrayList<Player> tgtPlayers = null;
|
ArrayList<Player> tgtPlayers = null;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else if (params.containsKey("Defined")) {
|
} else if (params.containsKey("Defined")) {
|
||||||
@@ -1130,7 +1130,7 @@ public final class AbilityFactory_Animate {
|
|||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tgtPlayers == null || tgtPlayers.isEmpty()) {
|
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
|
||||||
list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
} else {
|
} else {
|
||||||
list = tgtPlayers.get(0).getCardsIn(Zone.Battlefield);
|
list = tgtPlayers.get(0).getCardsIn(Zone.Battlefield);
|
||||||
@@ -1140,16 +1140,16 @@ public final class AbilityFactory_Animate {
|
|||||||
|
|
||||||
for (final Card c : list) {
|
for (final Card c : list) {
|
||||||
|
|
||||||
final long colorTimestamp = doAnimate(c, af, power, toughness, types, removeTypes, finalDesc, keywords,
|
final long colorTimestamp = AbilityFactory_Animate.doAnimate(c, af, power, toughness, types, removeTypes,
|
||||||
hiddenKeywords, timestamp);
|
finalDesc, keywords, hiddenKeywords, timestamp);
|
||||||
|
|
||||||
// give abilities
|
// give abilities
|
||||||
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
||||||
if (abilities.size() > 0) {
|
if (abilities.size() > 0) {
|
||||||
for (String s : abilities) {
|
for (final String s : abilities) {
|
||||||
AbilityFactory newAF = new AbilityFactory();
|
final AbilityFactory newAF = new AbilityFactory();
|
||||||
String actualAbility = host.getSVar(s);
|
final String actualAbility = host.getSVar(s);
|
||||||
SpellAbility grantedAbility = newAF.getAbility(actualAbility, c);
|
final SpellAbility grantedAbility = newAF.getAbility(actualAbility, c);
|
||||||
addedAbilities.add(grantedAbility);
|
addedAbilities.add(grantedAbility);
|
||||||
c.addSpellAbility(grantedAbility);
|
c.addSpellAbility(grantedAbility);
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1158,7 @@ public final class AbilityFactory_Animate {
|
|||||||
// remove abilities
|
// remove abilities
|
||||||
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||||
if (params.containsKey("OverwriteAbilities")) {
|
if (params.containsKey("OverwriteAbilities")) {
|
||||||
for (SpellAbility ab : c.getSpellAbilities()) {
|
for (final SpellAbility ab : c.getSpellAbilities()) {
|
||||||
if (ab.isAbility()) {
|
if (ab.isAbility()) {
|
||||||
c.removeSpellAbility(ab);
|
c.removeSpellAbility(ab);
|
||||||
removedAbilities.add(ab);
|
removedAbilities.add(ab);
|
||||||
@@ -1169,17 +1169,17 @@ public final class AbilityFactory_Animate {
|
|||||||
// Grant triggers
|
// Grant triggers
|
||||||
final ArrayList<Trigger> addedTriggers = new ArrayList<Trigger>();
|
final ArrayList<Trigger> addedTriggers = new ArrayList<Trigger>();
|
||||||
if (triggers.size() > 0) {
|
if (triggers.size() > 0) {
|
||||||
for (String s : triggers) {
|
for (final String s : triggers) {
|
||||||
String actualTrigger = host.getSVar(s);
|
final String actualTrigger = host.getSVar(s);
|
||||||
Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c, false);
|
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c, false);
|
||||||
addedTriggers.add(c.addTrigger(parsedTrigger));
|
addedTriggers.add(c.addTrigger(parsedTrigger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// give sVars
|
// give sVars
|
||||||
if (sVars.size() > 0) {
|
if (sVars.size() > 0) {
|
||||||
for (String s : sVars) {
|
for (final String s : sVars) {
|
||||||
String actualsVar = host.getSVar(s);
|
final String actualsVar = host.getSVar(s);
|
||||||
c.setSVar(s, actualsVar);
|
c.setSVar(s, actualsVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1187,9 +1187,10 @@ public final class AbilityFactory_Animate {
|
|||||||
final Command unanimate = new Command() {
|
final Command unanimate = new Command() {
|
||||||
private static final long serialVersionUID = -5861759814760561373L;
|
private static final long serialVersionUID = -5861759814760561373L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
doUnanimate(c, af, finalDesc, hiddenKeywords, addedAbilities, addedTriggers, colorTimestamp, false,
|
AbilityFactory_Animate.doUnanimate(c, af, finalDesc, hiddenKeywords, addedAbilities, addedTriggers,
|
||||||
removedAbilities, timestamp);
|
colorTimestamp, false, removedAbilities, timestamp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ public class AbilityFactory_Attach {
|
|||||||
if (abilityFactory.getHostCard().isAura()) {
|
if (abilityFactory.getHostCard().isAura()) {
|
||||||
// The 4th parameter is to resolve an issue with SetDescription in
|
// The 4th parameter is to resolve an issue with SetDescription in
|
||||||
// default Spell_Permanent constructor
|
// default Spell_Permanent constructor
|
||||||
spAttach = new Spell_Permanent(abilityFactory.getHostCard(),
|
spAttach = new Spell_Permanent(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
|
||||||
abilityFactory.getAbCost(), abilityFactory.getAbTgt(), false) {
|
abilityFactory.getAbTgt(), false) {
|
||||||
private static final long serialVersionUID = 6631124959690157874L;
|
private static final long serialVersionUID = 6631124959690157874L;
|
||||||
|
|
||||||
private final AbilityFactory af = abilityFactory;
|
private final AbilityFactory af = abilityFactory;
|
||||||
@@ -61,20 +61,21 @@ public class AbilityFactory_Attach {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return attachStackDescription(af, this);
|
return AbilityFactory_Attach.attachStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return attachCanPlayAI(af, this);
|
return AbilityFactory_Attach.attachCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
// The Spell_Permanent (Auras) version of this AF needs to
|
// The Spell_Permanent (Auras) version of this AF needs to
|
||||||
// move the card into play before Attaching
|
// move the card into play before Attaching
|
||||||
Card c = AllZone.getGameAction().moveToPlay(getSourceCard());
|
final Card c = AllZone.getGameAction().moveToPlay(this.getSourceCard());
|
||||||
this.setSourceCard(c);
|
this.setSourceCard(c);
|
||||||
attachResolve(af, this);
|
AbilityFactory_Attach.attachResolve(this.af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -91,16 +92,17 @@ public class AbilityFactory_Attach {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return attachStackDescription(af, this);
|
return AbilityFactory_Attach.attachStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return attachCanPlayAI(af, this);
|
return AbilityFactory_Attach.attachCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
attachResolve(af, this);
|
AbilityFactory_Attach.attachResolve(this.af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -143,7 +145,7 @@ public class AbilityFactory_Attach {
|
|||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String attachStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
public static String attachStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||||
@@ -151,7 +153,7 @@ public class AbilityFactory_Attach {
|
|||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String conditionDesc = af.getMapParams().get("ConditionDescription");
|
final String conditionDesc = af.getMapParams().get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
@@ -161,18 +163,18 @@ public class AbilityFactory_Attach {
|
|||||||
ArrayList<Object> targets;
|
ArrayList<Object> targets;
|
||||||
|
|
||||||
// Should never allow more than one Attachment per card
|
// Should never allow more than one Attachment per card
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
targets = tgt.getTargets();
|
targets = tgt.getTargets();
|
||||||
} else {
|
} else {
|
||||||
targets = AbilityFactory.getDefinedObjects(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
targets = AbilityFactory.getDefinedObjects(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Object o : targets) {
|
for (final Object o : targets) {
|
||||||
sb.append(o).append(" ");
|
sb.append(o).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -199,9 +201,9 @@ public class AbilityFactory_Attach {
|
|||||||
final Map<String, String> params, final Target tgt, final boolean mandatory) {
|
final Map<String, String> params, final Target tgt, final boolean mandatory) {
|
||||||
Object o;
|
Object o;
|
||||||
if (tgt.canTgtPlayer()) {
|
if (tgt.canTgtPlayer()) {
|
||||||
o = attachToPlayerAIPreferences(af, sa, mandatory);
|
o = AbilityFactory_Attach.attachToPlayerAIPreferences(af, sa, mandatory);
|
||||||
} else {
|
} else {
|
||||||
o = attachToCardAIPreferences(af, sa, params, mandatory);
|
o = AbilityFactory_Attach.attachToCardAIPreferences(af, sa, params, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
@@ -227,8 +229,8 @@ public class AbilityFactory_Attach {
|
|||||||
*/
|
*/
|
||||||
public static Card attachToCardAIPreferences(final AbilityFactory af, final SpellAbility sa,
|
public static Card attachToCardAIPreferences(final AbilityFactory af, final SpellAbility sa,
|
||||||
final Map<String, String> params, final boolean mandatory) {
|
final Map<String, String> params, final boolean mandatory) {
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
Card attachSource = sa.getSourceCard();
|
final Card attachSource = sa.getSourceCard();
|
||||||
// TODO AttachSource is currently set for the Source of the Spell, but
|
// TODO AttachSource is currently set for the Source of the Spell, but
|
||||||
// at some point can support attaching a different card
|
// at some point can support attaching a different card
|
||||||
|
|
||||||
@@ -249,9 +251,9 @@ public class AbilityFactory_Attach {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Card c = attachGeneralAI(sa, list, mandatory, attachSource, params.get("AILogic"));
|
Card c = AbilityFactory_Attach.attachGeneralAI(sa, list, mandatory, attachSource, params.get("AILogic"));
|
||||||
|
|
||||||
if (c == null && mandatory) {
|
if ((c == null) && mandatory) {
|
||||||
list.shuffle();
|
list.shuffle();
|
||||||
c = list.get(0);
|
c = list.get(0);
|
||||||
}
|
}
|
||||||
@@ -276,29 +278,29 @@ public class AbilityFactory_Attach {
|
|||||||
*/
|
*/
|
||||||
public static Card attachGeneralAI(final SpellAbility sa, final CardList list, final boolean mandatory,
|
public static Card attachGeneralAI(final SpellAbility sa, final CardList list, final boolean mandatory,
|
||||||
final Card attachSource, final String logic) {
|
final Card attachSource, final String logic) {
|
||||||
Player prefPlayer = "Pump".equals(logic) ? AllZone.getComputerPlayer() : AllZone.getHumanPlayer();
|
final Player prefPlayer = "Pump".equals(logic) ? AllZone.getComputerPlayer() : AllZone.getHumanPlayer();
|
||||||
// Some ChangeType cards are beneficial, and PrefPlayer should be
|
// Some ChangeType cards are beneficial, and PrefPlayer should be
|
||||||
// changed to represent that
|
// changed to represent that
|
||||||
CardList prefList = list.getController(prefPlayer);
|
final CardList prefList = list.getController(prefPlayer);
|
||||||
|
|
||||||
// If there are no preferred cards, and not mandatory bail out
|
// If there are no preferred cards, and not mandatory bail out
|
||||||
if (prefList.size() == 0) {
|
if (prefList.size() == 0) {
|
||||||
return chooseUnpreferred(mandatory, list);
|
return AbilityFactory_Attach.chooseUnpreferred(mandatory, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preferred list has at least one card in it to make to the actual
|
// Preferred list has at least one card in it to make to the actual
|
||||||
// Logic
|
// Logic
|
||||||
Card c = null;
|
Card c = null;
|
||||||
if ("GainControl".equals(logic)) {
|
if ("GainControl".equals(logic)) {
|
||||||
c = attachAIControlPreference(sa, prefList, mandatory, attachSource);
|
c = AbilityFactory_Attach.attachAIControlPreference(sa, prefList, mandatory, attachSource);
|
||||||
} else if ("Curse".equals(logic)) {
|
} else if ("Curse".equals(logic)) {
|
||||||
c = attachAICursePreference(sa, prefList, mandatory, attachSource);
|
c = AbilityFactory_Attach.attachAICursePreference(sa, prefList, mandatory, attachSource);
|
||||||
} else if ("Pump".equals(logic)) {
|
} else if ("Pump".equals(logic)) {
|
||||||
c = attachAIPumpPreference(sa, prefList, mandatory, attachSource);
|
c = AbilityFactory_Attach.attachAIPumpPreference(sa, prefList, mandatory, attachSource);
|
||||||
} else if ("ChangeType".equals(logic)) {
|
} else if ("ChangeType".equals(logic)) {
|
||||||
c = attachAIChangeTypePreference(sa, prefList, mandatory, attachSource);
|
c = AbilityFactory_Attach.attachAIChangeTypePreference(sa, prefList, mandatory, attachSource);
|
||||||
} else if ("KeepTapped".equals(logic)) {
|
} else if ("KeepTapped".equals(logic)) {
|
||||||
c = attachAIKeepTappedPreference(sa, prefList, mandatory, attachSource);
|
c = AbilityFactory_Attach.attachAIKeepTappedPreference(sa, prefList, mandatory, attachSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
@@ -354,8 +356,8 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
// TODO If Not Mandatory, make sure the card is "good enough"
|
// TODO If Not Mandatory, make sure the card is "good enough"
|
||||||
if (c.isCreature()) {
|
if (c.isCreature()) {
|
||||||
int eval = CardFactoryUtil.evaluateCreature(c);
|
final int eval = CardFactoryUtil.evaluateCreature(c);
|
||||||
if (eval < 160 && (eval < 130 || AllZone.getComputerPlayer().getLife() > 5)) {
|
if ((eval < 160) && ((eval < 130) || (AllZone.getComputerPlayer().getLife() > 5))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,15 +391,15 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Card c = CardFactoryUtil.AI_getBest(list);
|
final Card c = CardFactoryUtil.AI_getBest(list);
|
||||||
|
|
||||||
// If Mandatory (brought directly into play without casting) gotta
|
// If Mandatory (brought directly into play without casting) gotta
|
||||||
// choose something
|
// choose something
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return chooseLessPreferred(mandatory, list);
|
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptableChoice(c, mandatory);
|
return AbilityFactory_Attach.acceptableChoice(c, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -427,7 +429,7 @@ public class AbilityFactory_Attach {
|
|||||||
magnetList = list.getEquipMagnets();
|
magnetList = list.getEquipMagnets();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (magnetList != null && !magnetList.isEmpty()) {
|
if ((magnetList != null) && !magnetList.isEmpty()) {
|
||||||
// Always choose something from the Magnet List.
|
// Always choose something from the Magnet List.
|
||||||
// Probably want to "weight" the list by amount of Enchantments and
|
// Probably want to "weight" the list by amount of Enchantments and
|
||||||
// choose the "lightest"
|
// choose the "lightest"
|
||||||
@@ -444,17 +446,17 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
int totToughness = 0;
|
int totToughness = 0;
|
||||||
int totPower = 0;
|
int totPower = 0;
|
||||||
ArrayList<String> keywords = new ArrayList<String>();
|
final ArrayList<String> keywords = new ArrayList<String>();
|
||||||
boolean grantingAbilities = false;
|
boolean grantingAbilities = false;
|
||||||
|
|
||||||
for (StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
||||||
Map<String, String> params = stAbility.getMapParams();
|
final Map<String, String> params = stAbility.getMapParams();
|
||||||
|
|
||||||
if (!params.get("Mode").equals("Continuous")) {
|
if (!params.get("Mode").equals("Continuous")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String affected = params.get("Affected");
|
final String affected = params.get("Affected");
|
||||||
|
|
||||||
if (affected == null) {
|
if (affected == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -465,9 +467,9 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
grantingAbilities |= params.containsKey("AddAbility");
|
grantingAbilities |= params.containsKey("AddAbility");
|
||||||
|
|
||||||
String kws = params.get("AddKeyword");
|
final String kws = params.get("AddKeyword");
|
||||||
if (kws != null) {
|
if (kws != null) {
|
||||||
for (String kw : kws.split(" & ")) {
|
for (final String kw : kws.split(" & ")) {
|
||||||
keywords.add(kw);
|
keywords.add(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -486,11 +488,11 @@ public class AbilityFactory_Attach {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (totToughness == 0 && totPower == 0) {
|
else if ((totToughness == 0) && (totPower == 0)) {
|
||||||
// Just granting Keywords don't assign stacking Keywords
|
// Just granting Keywords don't assign stacking Keywords
|
||||||
Iterator<String> it = keywords.iterator();
|
final Iterator<String> it = keywords.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
String key = it.next();
|
final String key = it.next();
|
||||||
if (CardUtil.isStackingKeyword(key)) {
|
if (CardUtil.isStackingKeyword(key)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
@@ -502,7 +504,7 @@ public class AbilityFactory_Attach {
|
|||||||
// keywords
|
// keywords
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
for (String kw : finalKWs) {
|
for (final String kw : finalKWs) {
|
||||||
if (c.hasKeyword(kw)) {
|
if (c.hasKeyword(kw)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -542,10 +544,10 @@ public class AbilityFactory_Attach {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return chooseLessPreferred(mandatory, list);
|
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptableChoice(c, mandatory);
|
return AbilityFactory_Attach.acceptableChoice(c, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -576,17 +578,17 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
int totToughness = 0;
|
int totToughness = 0;
|
||||||
// int totPower = 0;
|
// int totPower = 0;
|
||||||
ArrayList<String> keywords = new ArrayList<String>();
|
final ArrayList<String> keywords = new ArrayList<String>();
|
||||||
// boolean grantingAbilities = false;
|
// boolean grantingAbilities = false;
|
||||||
|
|
||||||
for (StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
||||||
Map<String, String> params = stAbility.getMapParams();
|
final Map<String, String> params = stAbility.getMapParams();
|
||||||
|
|
||||||
if (!params.get("Mode").equals("Continuous")) {
|
if (!params.get("Mode").equals("Continuous")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String affected = params.get("Affected");
|
final String affected = params.get("Affected");
|
||||||
|
|
||||||
if (affected == null) {
|
if (affected == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -598,9 +600,9 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
// grantingAbilities |= params.containsKey("AddAbility");
|
// grantingAbilities |= params.containsKey("AddAbility");
|
||||||
|
|
||||||
String kws = params.get("AddKeyword");
|
final String kws = params.get("AddKeyword");
|
||||||
if (kws != null) {
|
if (kws != null) {
|
||||||
for (String kw : kws.split(" & ")) {
|
for (final String kw : kws.split(" & ")) {
|
||||||
keywords.add(kw);
|
keywords.add(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -614,7 +616,7 @@ public class AbilityFactory_Attach {
|
|||||||
prefList = list.filter(new CardListFilter() {
|
prefList = list.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
if (!c.hasKeyword("Indestructible") && c.getLethalDamage() <= Math.abs(tgh)) {
|
if (!c.hasKeyword("Indestructible") && (c.getLethalDamage() <= Math.abs(tgh))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,7 +625,7 @@ public class AbilityFactory_Attach {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
Card c = null;
|
Card c = null;
|
||||||
if (prefList == null || prefList.size() == 0) {
|
if ((prefList == null) || (prefList.size() == 0)) {
|
||||||
prefList = new CardList(list);
|
prefList = new CardList(list);
|
||||||
} else {
|
} else {
|
||||||
c = CardFactoryUtil.AI_getBest(prefList);
|
c = CardFactoryUtil.AI_getBest(prefList);
|
||||||
@@ -649,10 +651,10 @@ public class AbilityFactory_Attach {
|
|||||||
c = CardFactoryUtil.AI_getBest(prefList);
|
c = CardFactoryUtil.AI_getBest(prefList);
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return chooseLessPreferred(mandatory, list);
|
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptableChoice(c, mandatory);
|
return AbilityFactory_Attach.acceptableChoice(c, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -674,8 +676,8 @@ public class AbilityFactory_Attach {
|
|||||||
|
|
||||||
String type = "";
|
String type = "";
|
||||||
|
|
||||||
for (StaticAbility stAb : attachSource.getStaticAbilities()) {
|
for (final StaticAbility stAb : attachSource.getStaticAbilities()) {
|
||||||
HashMap<String, String> params = stAb.getMapParams();
|
final HashMap<String, String> params = stAb.getMapParams();
|
||||||
if (params.get("Mode").equals("Continuous") && params.containsKey("AddType")) {
|
if (params.get("Mode").equals("Continuous") && params.containsKey("AddType")) {
|
||||||
type = params.get("AddType");
|
type = params.get("AddType");
|
||||||
}
|
}
|
||||||
@@ -684,7 +686,7 @@ public class AbilityFactory_Attach {
|
|||||||
list = list.getNotType(type); // Filter out Basic Lands that have the
|
list = list.getNotType(type); // Filter out Basic Lands that have the
|
||||||
// same type as the changing type
|
// same type as the changing type
|
||||||
|
|
||||||
Card c = CardFactoryUtil.AI_getBest(list);
|
final Card c = CardFactoryUtil.AI_getBest(list);
|
||||||
|
|
||||||
// TODO Port over some of the existing code, but rewrite most of it.
|
// TODO Port over some of the existing code, but rewrite most of it.
|
||||||
// Ultimately, these spells need to be used to reduce mana base of a
|
// Ultimately, these spells need to be used to reduce mana base of a
|
||||||
@@ -693,10 +695,10 @@ public class AbilityFactory_Attach {
|
|||||||
// cast on
|
// cast on
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return chooseLessPreferred(mandatory, list);
|
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptableChoice(c, mandatory);
|
return AbilityFactory_Attach.acceptableChoice(c, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -715,7 +717,7 @@ public class AbilityFactory_Attach {
|
|||||||
public static Card attachAIKeepTappedPreference(final SpellAbility sa, final CardList list,
|
public static Card attachAIKeepTappedPreference(final SpellAbility sa, final CardList list,
|
||||||
final boolean mandatory, final Card attachSource) {
|
final boolean mandatory, final Card attachSource) {
|
||||||
// AI For Cards like Paralyzing Grasp and Glimmerdust Nap
|
// AI For Cards like Paralyzing Grasp and Glimmerdust Nap
|
||||||
CardList prefList = list.filter(new CardListFilter() {
|
final CardList prefList = list.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
// Don't do Untapped Vigilance cards
|
// Don't do Untapped Vigilance cards
|
||||||
@@ -727,13 +729,13 @@ public class AbilityFactory_Attach {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> auras = c.getEnchantedBy();
|
final ArrayList<Card> auras = c.getEnchantedBy();
|
||||||
Iterator<Card> itr = auras.iterator();
|
final Iterator<Card> itr = auras.iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
Card aura = (Card) itr.next();
|
final Card aura = itr.next();
|
||||||
AbilityFactory af = aura.getSpellPermanent().getAbilityFactory();
|
final AbilityFactory af = aura.getSpellPermanent().getAbilityFactory();
|
||||||
if (af != null && af.getAPI().equals("Attach")) {
|
if ((af != null) && af.getAPI().equals("Attach")) {
|
||||||
Map<String, String> params = af.getMapParams();
|
final Map<String, String> params = af.getMapParams();
|
||||||
if ("KeepTapped".equals(params.get("AILogic"))) {
|
if ("KeepTapped".equals(params.get("AILogic"))) {
|
||||||
// Don't attach multiple KeepTapped Auras to one
|
// Don't attach multiple KeepTapped Auras to one
|
||||||
// card
|
// card
|
||||||
@@ -746,13 +748,13 @@ public class AbilityFactory_Attach {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Card c = CardFactoryUtil.AI_getBest(prefList);
|
final Card c = CardFactoryUtil.AI_getBest(prefList);
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return chooseLessPreferred(mandatory, list);
|
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptableChoice(c, mandatory);
|
return AbilityFactory_Attach.acceptableChoice(c, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -768,7 +770,7 @@ public class AbilityFactory_Attach {
|
|||||||
*/
|
*/
|
||||||
public static Player attachToPlayerAIPreferences(final AbilityFactory af, final SpellAbility sa,
|
public static Player attachToPlayerAIPreferences(final AbilityFactory af, final SpellAbility sa,
|
||||||
final boolean mandatory) {
|
final boolean mandatory) {
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
Player p;
|
Player p;
|
||||||
if (tgt.canOnlyTgtOpponent()) {
|
if (tgt.canOnlyTgtOpponent()) {
|
||||||
// If can Only Target Opponent, do so.
|
// If can Only Target Opponent, do so.
|
||||||
@@ -812,9 +814,9 @@ public class AbilityFactory_Attach {
|
|||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public static boolean attachCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
public static boolean attachCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
Map<String, String> params = af.getMapParams();
|
final Map<String, String> params = af.getMapParams();
|
||||||
Cost abCost = sa.getPayCosts();
|
final Cost abCost = sa.getPayCosts();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
@@ -826,10 +828,10 @@ public class AbilityFactory_Attach {
|
|||||||
boolean chance = r.nextFloat() <= .6667;
|
boolean chance = r.nextFloat() <= .6667;
|
||||||
|
|
||||||
// Attach spells always have a target
|
// Attach spells always have a target
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
if (!attachPreference(af, sa, params, tgt, false)) {
|
if (!AbilityFactory_Attach.attachPreference(af, sa, params, tgt, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -837,7 +839,7 @@ public class AbilityFactory_Attach {
|
|||||||
if (abCost.getTotalMana().contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
if (abCost.getTotalMana().contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value. (Endless Scream and Venarian
|
// Set PayX here to maximum value. (Endless Scream and Venarian
|
||||||
// Gold)
|
// Gold)
|
||||||
int xPay = ComputerUtil.determineLeftoverMana(sa);
|
final int xPay = ComputerUtil.determineLeftoverMana(sa);
|
||||||
|
|
||||||
if (xPay == 0) {
|
if (xPay == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -882,7 +884,7 @@ public class AbilityFactory_Attach {
|
|||||||
// Now are Valid Targets better than my targets?
|
// Now are Valid Targets better than my targets?
|
||||||
|
|
||||||
// check SubAbilities DoTrigger?
|
// check SubAbilities DoTrigger?
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
return abSub.doTrigger(mandatory);
|
return abSub.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -899,12 +901,12 @@ public class AbilityFactory_Attach {
|
|||||||
* the sa
|
* the sa
|
||||||
*/
|
*/
|
||||||
public static void attachResolve(final AbilityFactory af, final SpellAbility sa) {
|
public static void attachResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Map<String, String> params = af.getMapParams();
|
final Map<String, String> params = af.getMapParams();
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
ArrayList<Object> targets;
|
ArrayList<Object> targets;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
targets = tgt.getTargets();
|
targets = tgt.getTargets();
|
||||||
// TODO Remove invalid targets (although more likely this will just
|
// TODO Remove invalid targets (although more likely this will just
|
||||||
@@ -914,8 +916,8 @@ public class AbilityFactory_Attach {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If Cast Targets will be checked on the Stack
|
// If Cast Targets will be checked on the Stack
|
||||||
for (Object o : targets) {
|
for (final Object o : targets) {
|
||||||
handleAttachment(card, o, af);
|
AbilityFactory_Attach.handleAttachment(card, o, af);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,15 +934,15 @@ public class AbilityFactory_Attach {
|
|||||||
public static void handleAttachment(final Card card, final Object o, final AbilityFactory af) {
|
public static void handleAttachment(final Card card, final Object o, final AbilityFactory af) {
|
||||||
|
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
Card c = (Card) o;
|
final Card c = (Card) o;
|
||||||
if (card.isAura()) {
|
if (card.isAura()) {
|
||||||
// Most Auras can enchant permanents, a few can Enchant cards in
|
// Most Auras can enchant permanents, a few can Enchant cards in
|
||||||
// graveyards
|
// graveyards
|
||||||
// Spellweaver Volute, Dance of the Dead, Animate Dead
|
// Spellweaver Volute, Dance of the Dead, Animate Dead
|
||||||
// Although honestly, I'm not sure if the three of those could
|
// Although honestly, I'm not sure if the three of those could
|
||||||
// handle being scripted
|
// handle being scripted
|
||||||
boolean gainControl = "GainControl".equals(af.getMapParams().get("AILogic"));
|
final boolean gainControl = "GainControl".equals(af.getMapParams().get("AILogic"));
|
||||||
handleAura(card, c, gainControl);
|
AbilityFactory_Attach.handleAura(card, c, gainControl);
|
||||||
} else if (card.isEquipment()) {
|
} else if (card.isEquipment()) {
|
||||||
card.equipCard(c);
|
card.equipCard(c);
|
||||||
// else if (card.isFortification())
|
// else if (card.isFortification())
|
||||||
@@ -950,9 +952,9 @@ public class AbilityFactory_Attach {
|
|||||||
// Currently, a few cards can enchant players
|
// Currently, a few cards can enchant players
|
||||||
// Psychic Possession, Paradox Haze, Wheel of Sun and Moon, New
|
// Psychic Possession, Paradox Haze, Wheel of Sun and Moon, New
|
||||||
// Curse cards
|
// Curse cards
|
||||||
Player p = (Player) o;
|
final Player p = (Player) o;
|
||||||
if (card.isAura()) {
|
if (card.isAura()) {
|
||||||
handleAura(card, p, false);
|
AbilityFactory_Attach.handleAura(card, p, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -971,7 +973,7 @@ public class AbilityFactory_Attach {
|
|||||||
if (card.isEnchanting()) {
|
if (card.isEnchanting()) {
|
||||||
// If this Card is already Enchanting something
|
// If this Card is already Enchanting something
|
||||||
// Need to unenchant it, then clear out the commands
|
// Need to unenchant it, then clear out the commands
|
||||||
GameEntity oldEnchanted = card.getEnchanting();
|
final GameEntity oldEnchanted = card.getEnchanting();
|
||||||
card.removeEnchanting(oldEnchanted);
|
card.removeEnchanting(oldEnchanted);
|
||||||
card.clearEnchantCommand();
|
card.clearEnchantCommand();
|
||||||
card.clearUnEnchantCommand();
|
card.clearUnEnchantCommand();
|
||||||
@@ -988,11 +990,12 @@ public class AbilityFactory_Attach {
|
|||||||
pl[0] = (Player) tgt;
|
pl[0] = (Player) tgt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command onEnchant = new Command() {
|
final Command onEnchant = new Command() {
|
||||||
private static final long serialVersionUID = -2519887209491512000L;
|
private static final long serialVersionUID = -2519887209491512000L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
Card crd = card.getEnchantingCard();
|
final Card crd = card.getEnchantingCard();
|
||||||
if (crd == null) {
|
if (crd == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1004,11 +1007,12 @@ public class AbilityFactory_Attach {
|
|||||||
} // execute()
|
} // execute()
|
||||||
}; // Command
|
}; // Command
|
||||||
|
|
||||||
Command onUnEnchant = new Command() {
|
final Command onUnEnchant = new Command() {
|
||||||
private static final long serialVersionUID = 3426441132121179288L;
|
private static final long serialVersionUID = 3426441132121179288L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
Card crd = card.getEnchantingCard();
|
final Card crd = card.getEnchantingCard();
|
||||||
if (crd == null) {
|
if (crd == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1020,12 +1024,13 @@ public class AbilityFactory_Attach {
|
|||||||
} // execute()
|
} // execute()
|
||||||
}; // Command
|
}; // Command
|
||||||
|
|
||||||
Command onChangesControl = new Command() {
|
final Command onChangesControl = new Command() {
|
||||||
/** automatically generated serialVersionUID. */
|
/** automatically generated serialVersionUID. */
|
||||||
private static final long serialVersionUID = -65903786170234039L;
|
private static final long serialVersionUID = -65903786170234039L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
Card crd = card.getEnchantingCard();
|
final Card crd = card.getEnchantingCard();
|
||||||
if (crd == null) {
|
if (crd == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1041,11 +1046,12 @@ public class AbilityFactory_Attach {
|
|||||||
card.addChangeControllerCommand(onChangesControl);
|
card.addChangeControllerCommand(onChangesControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command onLeavesPlay = new Command() {
|
final Command onLeavesPlay = new Command() {
|
||||||
private static final long serialVersionUID = -639204333673364477L;
|
private static final long serialVersionUID = -639204333673364477L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
GameEntity entity = card.getEnchanting();
|
final GameEntity entity = card.getEnchanting();
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1068,9 +1074,9 @@ public class AbilityFactory_Attach {
|
|||||||
public static SpellAbility getAttachSpellAbility(final Card source) {
|
public static SpellAbility getAttachSpellAbility(final Card source) {
|
||||||
SpellAbility aura = null;
|
SpellAbility aura = null;
|
||||||
AbilityFactory af = null;
|
AbilityFactory af = null;
|
||||||
for (SpellAbility sa : source.getSpells()) {
|
for (final SpellAbility sa : source.getSpells()) {
|
||||||
af = sa.getAbilityFactory();
|
af = sa.getAbilityFactory();
|
||||||
if (af != null && af.getAPI().equals("Attach")) {
|
if ((af != null) && af.getAPI().equals("Attach")) {
|
||||||
aura = sa;
|
aura = sa;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1088,18 +1094,18 @@ public class AbilityFactory_Attach {
|
|||||||
public static boolean attachAuraOnIndirectEnterBattlefield(final Card source) {
|
public static boolean attachAuraOnIndirectEnterBattlefield(final Card source) {
|
||||||
// When an Aura ETB without being cast you can choose a valid card to
|
// When an Aura ETB without being cast you can choose a valid card to
|
||||||
// attach it to
|
// attach it to
|
||||||
SpellAbility aura = getAttachSpellAbility(source);
|
final SpellAbility aura = AbilityFactory_Attach.getAttachSpellAbility(source);
|
||||||
|
|
||||||
if (aura == null) {
|
if (aura == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbilityFactory af = aura.getAbilityFactory();
|
final AbilityFactory af = aura.getAbilityFactory();
|
||||||
Target tgt = aura.getTarget();
|
final Target tgt = aura.getTarget();
|
||||||
|
|
||||||
if (source.getController().isHuman()) {
|
if (source.getController().isHuman()) {
|
||||||
if (tgt.canTgtPlayer()) {
|
if (tgt.canTgtPlayer()) {
|
||||||
ArrayList<Player> players = new ArrayList<Player>();
|
final ArrayList<Player> players = new ArrayList<Player>();
|
||||||
|
|
||||||
// TODO Once Player's are gaining Protection we need to add a
|
// TODO Once Player's are gaining Protection we need to add a
|
||||||
// check here
|
// check here
|
||||||
@@ -1109,7 +1115,7 @@ public class AbilityFactory_Attach {
|
|||||||
players.add(AllZone.getHumanPlayer());
|
players.add(AllZone.getHumanPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
Object o = GuiUtils.getChoice(source + " - Select a player to attach to.", players.toArray());
|
final Object o = GuiUtils.getChoice(source + " - Select a player to attach to.", players.toArray());
|
||||||
if (o instanceof Player) {
|
if (o instanceof Player) {
|
||||||
source.enchantEntity((Player) o);
|
source.enchantEntity((Player) o);
|
||||||
return true;
|
return true;
|
||||||
@@ -1118,7 +1124,7 @@ public class AbilityFactory_Attach {
|
|||||||
CardList list = AllZoneUtil.getCardsIn(tgt.getZone());
|
CardList list = AllZoneUtil.getCardsIn(tgt.getZone());
|
||||||
list = list.getValidCards(tgt.getValidTgts(), aura.getActivatingPlayer(), source);
|
list = list.getValidCards(tgt.getValidTgts(), aura.getActivatingPlayer(), source);
|
||||||
|
|
||||||
Object o = GuiUtils.getChoice(source + " - Select a card to attach to.", list.toArray());
|
final Object o = GuiUtils.getChoice(source + " - Select a card to attach to.", list.toArray());
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
source.enchantEntity((Card) o);
|
source.enchantEntity((Card) o);
|
||||||
return true;
|
return true;
|
||||||
@@ -1127,7 +1133,7 @@ public class AbilityFactory_Attach {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (AbilityFactory_Attach.attachPreference(af, aura, af.getMapParams(), tgt, true)) {
|
else if (AbilityFactory_Attach.attachPreference(af, aura, af.getMapParams(), tgt, true)) {
|
||||||
Object o = aura.getTarget().getTargets().get(0);
|
final Object o = aura.getTarget().getTargets().get(0);
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
source.enchantEntity((Card) o);
|
source.enchantEntity((Card) o);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -31,18 +31,18 @@ public class AbilityFactory_ChangeState {
|
|||||||
* @return the change state ability
|
* @return the change state ability
|
||||||
*/
|
*/
|
||||||
public static SpellAbility getChangeStateAbility(final AbilityFactory abilityFactory) {
|
public static SpellAbility getChangeStateAbility(final AbilityFactory abilityFactory) {
|
||||||
SpellAbility ret = new Ability_Activated(abilityFactory.getHostCard(),
|
final SpellAbility ret = new Ability_Activated(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
|
||||||
abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -1083427558368639457L;
|
private static final long serialVersionUID = -1083427558368639457L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeStateStackDescription(abilityFactory, this);
|
return AbilityFactory_ChangeState.changeStateStackDescription(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeStateResolve(abilityFactory, this);
|
AbilityFactory_ChangeState.changeStateResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,17 +57,17 @@ public class AbilityFactory_ChangeState {
|
|||||||
* @return the change state spell
|
* @return the change state spell
|
||||||
*/
|
*/
|
||||||
public static SpellAbility getChangeStateSpell(final AbilityFactory abilityFactory) {
|
public static SpellAbility getChangeStateSpell(final AbilityFactory abilityFactory) {
|
||||||
SpellAbility ret = new Spell(abilityFactory.getHostCard()) {
|
final SpellAbility ret = new Spell(abilityFactory.getHostCard()) {
|
||||||
private static final long serialVersionUID = -7506856902233086859L;
|
private static final long serialVersionUID = -7506856902233086859L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeStateStackDescription(abilityFactory, this);
|
return AbilityFactory_ChangeState.changeStateStackDescription(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeStateResolve(abilityFactory, this);
|
AbilityFactory_ChangeState.changeStateResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,13 +82,13 @@ public class AbilityFactory_ChangeState {
|
|||||||
* @return the change state drawback
|
* @return the change state drawback
|
||||||
*/
|
*/
|
||||||
public static SpellAbility getChangeStateDrawback(final AbilityFactory abilityFactory) {
|
public static SpellAbility getChangeStateDrawback(final AbilityFactory abilityFactory) {
|
||||||
Ability_Sub ret = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
final Ability_Sub ret = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3793247725721587468L;
|
private static final long serialVersionUID = -3793247725721587468L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeStateStackDescription(abilityFactory, this);
|
return AbilityFactory_ChangeState.changeStateStackDescription(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,7 +114,7 @@ public class AbilityFactory_ChangeState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeStateResolve(abilityFactory, this);
|
AbilityFactory_ChangeState.changeStateResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -123,19 +123,19 @@ public class AbilityFactory_ChangeState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String changeStateStackDescription(final AbilityFactory abilityFactory, final SpellAbility sa) {
|
private static String changeStateStackDescription(final AbilityFactory abilityFactory, final SpellAbility sa) {
|
||||||
Map<String, String> params = abilityFactory.getMapParams();
|
final Map<String, String> params = abilityFactory.getMapParams();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card host = abilityFactory.getHostCard();
|
final Card host = abilityFactory.getHostCard();
|
||||||
|
|
||||||
String conditionDesc = params.get("ConditionDescription");
|
final String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = abilityFactory.getAbTgt();
|
final Target tgt = abilityFactory.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -154,9 +154,9 @@ public class AbilityFactory_ChangeState {
|
|||||||
sb.append("Transform ");
|
sb.append("Transform ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
final Iterator<Card> it = tgtCards.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Card tgtC = it.next();
|
final Card tgtC = it.next();
|
||||||
if (tgtC.isFaceDown()) {
|
if (tgtC.isFaceDown()) {
|
||||||
sb.append("Morph ").append("(").append(tgtC.getUniqueNumber()).append(")");
|
sb.append("Morph ").append("(").append(tgtC.getUniqueNumber()).append(")");
|
||||||
} else {
|
} else {
|
||||||
@@ -169,7 +169,7 @@ public class AbilityFactory_ChangeState {
|
|||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ public class AbilityFactory_ChangeState {
|
|||||||
abilityFactory.getMapParams().get("Defined"), sa);
|
abilityFactory.getMapParams().get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card tgt : tgtCards) {
|
for (final Card tgt : tgtCards) {
|
||||||
if (abilityFactory.getAbTgt() != null) {
|
if (abilityFactory.getAbTgt() != null) {
|
||||||
if (!CardFactoryUtil.canTarget(abilityFactory.getHostCard(), tgt)) {
|
if (!CardFactoryUtil.canTarget(abilityFactory.getHostCard(), tgt)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -211,19 +211,19 @@ public class AbilityFactory_ChangeState {
|
|||||||
* @return the change state all ability
|
* @return the change state all ability
|
||||||
*/
|
*/
|
||||||
public static SpellAbility getChangeStateAllAbility(final AbilityFactory abilityFactory) {
|
public static SpellAbility getChangeStateAllAbility(final AbilityFactory abilityFactory) {
|
||||||
SpellAbility ret = new Ability_Activated(abilityFactory.getHostCard(),
|
final SpellAbility ret = new Ability_Activated(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
|
||||||
abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
abilityFactory.getAbTgt()) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7841029107610111992L;
|
private static final long serialVersionUID = 7841029107610111992L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeStateAllStackDescription(abilityFactory, this);
|
return AbilityFactory_ChangeState.changeStateAllStackDescription(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeStateAllResolve(abilityFactory, this);
|
AbilityFactory_ChangeState.changeStateAllResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -239,18 +239,18 @@ public class AbilityFactory_ChangeState {
|
|||||||
* @return the change state all spell
|
* @return the change state all spell
|
||||||
*/
|
*/
|
||||||
public static SpellAbility getChangeStateAllSpell(final AbilityFactory abilityFactory) {
|
public static SpellAbility getChangeStateAllSpell(final AbilityFactory abilityFactory) {
|
||||||
SpellAbility ret = new Spell(abilityFactory.getHostCard()) {
|
final SpellAbility ret = new Spell(abilityFactory.getHostCard()) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4217632586060204603L;
|
private static final long serialVersionUID = 4217632586060204603L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeStateAllStackDescription(abilityFactory, this);
|
return AbilityFactory_ChangeState.changeStateAllStackDescription(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeStateAllResolve(abilityFactory, this);
|
AbilityFactory_ChangeState.changeStateAllResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -265,13 +265,13 @@ public class AbilityFactory_ChangeState {
|
|||||||
* @return the change state all drawback
|
* @return the change state all drawback
|
||||||
*/
|
*/
|
||||||
public static SpellAbility getChangeStateAllDrawback(final AbilityFactory abilityFactory) {
|
public static SpellAbility getChangeStateAllDrawback(final AbilityFactory abilityFactory) {
|
||||||
Ability_Sub ret = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
final Ability_Sub ret = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4047514893482113436L;
|
private static final long serialVersionUID = 4047514893482113436L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return changeStateAllStackDescription(abilityFactory, this);
|
return AbilityFactory_ChangeState.changeStateAllStackDescription(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -293,7 +293,7 @@ public class AbilityFactory_ChangeState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
changeStateAllResolve(abilityFactory, this);
|
AbilityFactory_ChangeState.changeStateAllResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -302,11 +302,11 @@ public class AbilityFactory_ChangeState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void changeStateAllResolve(final AbilityFactory abilityFactory, final SpellAbility sa) {
|
private static void changeStateAllResolve(final AbilityFactory abilityFactory, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = abilityFactory.getMapParams();
|
final HashMap<String, String> params = abilityFactory.getMapParams();
|
||||||
|
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
Target tgt = abilityFactory.getAbTgt();
|
final Target tgt = abilityFactory.getAbTgt();
|
||||||
Player targetPlayer = null;
|
Player targetPlayer = null;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
targetPlayer = tgt.getTargetPlayers().get(0);
|
targetPlayer = tgt.getTargetPlayers().get(0);
|
||||||
@@ -333,7 +333,7 @@ public class AbilityFactory_ChangeState {
|
|||||||
|
|
||||||
list = AbilityFactory.filterListByType(list, valid, sa);
|
list = AbilityFactory.filterListByType(list, valid, sa);
|
||||||
|
|
||||||
boolean remChanged = params.containsKey("RememberChanged");
|
final boolean remChanged = params.containsKey("RememberChanged");
|
||||||
if (remChanged) {
|
if (remChanged) {
|
||||||
card.clearRemembered();
|
card.clearRemembered();
|
||||||
}
|
}
|
||||||
@@ -347,9 +347,9 @@ public class AbilityFactory_ChangeState {
|
|||||||
|
|
||||||
private static String changeStateAllStackDescription(final AbilityFactory abilityFactory, final SpellAbility sa) {
|
private static String changeStateAllStackDescription(final AbilityFactory abilityFactory, final SpellAbility sa) {
|
||||||
|
|
||||||
Card host = abilityFactory.getHostCard();
|
final Card host = abilityFactory.getHostCard();
|
||||||
Map<String, String> params = abilityFactory.getMapParams();
|
final Map<String, String> params = abilityFactory.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -365,7 +365,7 @@ public class AbilityFactory_ChangeState {
|
|||||||
|
|
||||||
sb.append(" permanents.");
|
sb.append(" permanents.");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -39,22 +39,22 @@ public final class AbilityFactory_Charm {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return charmCanPlayAI(af, this);
|
return AbilityFactory_Charm.charmCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
charmResolve(af, this);
|
AbilityFactory_Charm.charmResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return charmStackDescription(af, this);
|
return AbilityFactory_Charm.charmStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return charmCanPlayAI(af, this);
|
return AbilityFactory_Charm.charmCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
}; // Ability_Activated
|
}; // Ability_Activated
|
||||||
|
|
||||||
@@ -76,17 +76,17 @@ public final class AbilityFactory_Charm {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return charmCanPlayAI(af, this);
|
return AbilityFactory_Charm.charmCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
charmResolve(af, this);
|
AbilityFactory_Charm.charmResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return charmStackDescription(af, this);
|
return AbilityFactory_Charm.charmStackDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public final class AbilityFactory_Charm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String charmStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String charmStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -106,7 +106,7 @@ public final class AbilityFactory_Charm {
|
|||||||
// nothing stack specific for Charm
|
// nothing stack specific for Charm
|
||||||
|
|
||||||
// begin standard post
|
// begin standard post
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ public final class AbilityFactory_Charm {
|
|||||||
public static void setupCharmSAs(final SpellAbility sa) {
|
public static void setupCharmSAs(final SpellAbility sa) {
|
||||||
// make Charm choices
|
// make Charm choices
|
||||||
if (sa.isCharm()) {
|
if (sa.isCharm()) {
|
||||||
ArrayList<SpellAbility> choices = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> choices = new ArrayList<SpellAbility>();
|
||||||
choices.addAll(sa.getCharmChoices());
|
choices.addAll(sa.getCharmChoices());
|
||||||
for (int i = 0; i < choices.size(); i++) {
|
for (int i = 0; i < choices.size(); i++) {
|
||||||
if (!sa.canPlay()) {
|
if (!sa.canPlay()) {
|
||||||
@@ -151,7 +151,7 @@ public final class AbilityFactory_Charm {
|
|||||||
if (null == o) {
|
if (null == o) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ability_Sub chosen = (Ability_Sub) o;
|
final Ability_Sub chosen = (Ability_Sub) o;
|
||||||
sa.addCharmChoice(chosen);
|
sa.addCharmChoice(chosen);
|
||||||
choices.remove(chosen);
|
choices.remove(chosen);
|
||||||
|
|
||||||
|
|||||||
@@ -222,8 +222,7 @@ public final class AbilityFactory_Choose {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean chooseTypeTriggerAI(final AbilityFactory af,
|
private static boolean chooseTypeTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
if (!ComputerUtil.canPayCost(sa)) {
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -571,7 +570,7 @@ public final class AbilityFactory_Choose {
|
|||||||
// Note: if (AILogic == MostProminentAttackers) return isDuringCombat();
|
// Note: if (AILogic == MostProminentAttackers) return isDuringCombat();
|
||||||
boolean chance = true;
|
boolean chance = true;
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -591,8 +590,7 @@ public final class AbilityFactory_Choose {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean chooseColorTriggerAI(final AbilityFactory af,
|
private static boolean chooseColorTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -860,8 +858,7 @@ public final class AbilityFactory_Choose {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean chooseNumberTriggerAI(final AbilityFactory af,
|
private static boolean chooseNumberTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1110,8 +1107,7 @@ public final class AbilityFactory_Choose {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean choosePlayerTriggerAI(final AbilityFactory af,
|
private static boolean choosePlayerTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -466,8 +466,7 @@ public final class AbilityFactory_Combat {
|
|||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mustAttackDoTriggerAI(final AbilityFactory af,
|
private static boolean mustAttackDoTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
// If there is a cost payment it's usually not mandatory
|
// If there is a cost payment it's usually not mandatory
|
||||||
if (!ComputerUtil.canPayCost(sa) && !mandatory) {
|
if (!ComputerUtil.canPayCost(sa) && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
@@ -900,8 +899,7 @@ public final class AbilityFactory_Combat {
|
|||||||
return chance;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mustBlockDoTriggerAI(final AbilityFactory af,
|
private static boolean mustBlockDoTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final SpellAbility sa, final boolean mandatory) {
|
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final Target abTgt = sa.getTarget();
|
final Target abTgt = sa.getTarget();
|
||||||
|
|||||||
@@ -59,22 +59,22 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return copyPermanentStackDescription(af, this);
|
return AbilityFactory_Copy.copyPermanentStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return copyPermanentCanPlayAI(af, this);
|
return AbilityFactory_Copy.copyPermanentCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
copyPermanentResolve(af, this);
|
AbilityFactory_Copy.copyPermanentResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return copyPermanentTriggerAI(af, this, mandatory);
|
return AbilityFactory_Copy.copyPermanentTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -96,17 +96,17 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return copyPermanentStackDescription(af, this);
|
return AbilityFactory_Copy.copyPermanentStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return copyPermanentCanPlayAI(af, this);
|
return AbilityFactory_Copy.copyPermanentCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
copyPermanentResolve(af, this);
|
AbilityFactory_Copy.copyPermanentResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -128,12 +128,12 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return copyPermanentStackDescription(af, this);
|
return AbilityFactory_Copy.copyPermanentStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
copyPermanentResolve(af, this);
|
AbilityFactory_Copy.copyPermanentResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,7 +143,7 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return copyPermanentTriggerAI(af, this, mandatory);
|
return AbilityFactory_Copy.copyPermanentTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -162,8 +162,8 @@ public final class AbilityFactory_Copy {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String copyPermanentStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String copyPermanentStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
@@ -173,7 +173,7 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -181,7 +181,7 @@ public final class AbilityFactory_Copy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb.append("Copy ");
|
sb.append("Copy ");
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
final Iterator<Card> it = tgtCards.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
sb.append(it.next());
|
sb.append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
@@ -190,7 +190,7 @@ public final class AbilityFactory_Copy {
|
|||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ public final class AbilityFactory_Copy {
|
|||||||
// Card source = sa.getSourceCard();
|
// Card source = sa.getSourceCard();
|
||||||
// TODO - I'm sure someone can do this AI better
|
// TODO - I'm sure someone can do this AI better
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
if (params.containsKey("AtEOT") && !AllZone.getPhase().is(Constant.Phase.MAIN1)) {
|
if (params.containsKey("AtEOT") && !AllZone.getPhase().is(Constant.Phase.MAIN1)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -222,9 +222,9 @@ public final class AbilityFactory_Copy {
|
|||||||
chance = .667; // 66.7% chance for sorcery speed (since it will
|
chance = .667; // 66.7% chance for sorcery speed (since it will
|
||||||
// never activate EOT)
|
// never activate EOT)
|
||||||
}
|
}
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
if (r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1)) {
|
if (r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1)) {
|
||||||
return copyPermanentTriggerAI(af, sa, false);
|
return AbilityFactory_Copy.copyPermanentTriggerAI(af, sa, false);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,7 @@ public final class AbilityFactory_Copy {
|
|||||||
private static boolean copyPermanentTriggerAI(final AbilityFactory af, final SpellAbility sa,
|
private static boolean copyPermanentTriggerAI(final AbilityFactory af, final SpellAbility sa,
|
||||||
final boolean mandatory) {
|
final boolean mandatory) {
|
||||||
// HashMap<String,String> params = af.getMapParams();
|
// HashMap<String,String> params = af.getMapParams();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
if (!ComputerUtil.canPayCost(sa) && !mandatory) {
|
if (!ComputerUtil.canPayCost(sa) && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
@@ -256,7 +256,7 @@ public final class AbilityFactory_Copy {
|
|||||||
// ////
|
// ////
|
||||||
// Targeting
|
// Targeting
|
||||||
|
|
||||||
Target abTgt = sa.getTarget();
|
final Target abTgt = sa.getTarget();
|
||||||
|
|
||||||
if (abTgt != null) {
|
if (abTgt != null) {
|
||||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
@@ -265,8 +265,8 @@ public final class AbilityFactory_Copy {
|
|||||||
// target loop
|
// target loop
|
||||||
while (abTgt.getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
while (abTgt.getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
if (abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)
|
if ((abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||||
|| abTgt.getNumTargeted() == 0) {
|
|| (abTgt.getNumTargeted() == 0)) {
|
||||||
abTgt.resetTargets();
|
abTgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -283,8 +283,8 @@ public final class AbilityFactory_Copy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (choice == null) { // can't find anything left
|
if (choice == null) { // can't find anything left
|
||||||
if (abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)
|
if ((abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||||
|| abTgt.getNumTargeted() == 0) {
|
|| (abTgt.getNumTargeted() == 0)) {
|
||||||
abTgt.resetTargets();
|
abTgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -302,7 +302,7 @@ public final class AbilityFactory_Copy {
|
|||||||
// end Targeting
|
// end Targeting
|
||||||
|
|
||||||
if (af.hasSubAbility()) {
|
if (af.hasSubAbility()) {
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
return abSub.chkAIDrawback();
|
return abSub.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -322,17 +322,17 @@ public final class AbilityFactory_Copy {
|
|||||||
*/
|
*/
|
||||||
private static void copyPermanentResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void copyPermanentResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
ArrayList<String> keywords = new ArrayList<String>();
|
final ArrayList<String> keywords = new ArrayList<String>();
|
||||||
if (params.containsKey("Keywords")) {
|
if (params.containsKey("Keywords")) {
|
||||||
keywords.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
keywords.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
||||||
}
|
}
|
||||||
int numCopies = params.containsKey("NumCopies") ? AbilityFactory.calculateAmount(hostCard,
|
final int numCopies = params.containsKey("NumCopies") ? AbilityFactory.calculateAmount(hostCard,
|
||||||
params.get("NumCopies"), sa) : 1;
|
params.get("NumCopies"), sa) : 1;
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -341,8 +341,8 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
hostCard.clearClones();
|
hostCard.clearClones();
|
||||||
|
|
||||||
for (Card c : tgtCards) {
|
for (final Card c : tgtCards) {
|
||||||
if (tgt == null || CardFactoryUtil.canTarget(hostCard, c)) {
|
if ((tgt == null) || CardFactoryUtil.canTarget(hostCard, c)) {
|
||||||
|
|
||||||
boolean wasInAlt = false;
|
boolean wasInAlt = false;
|
||||||
if (c.isInAlternateState()) {
|
if (c.isInAlternateState()) {
|
||||||
@@ -353,7 +353,7 @@ public final class AbilityFactory_Copy {
|
|||||||
// start copied Kiki code
|
// start copied Kiki code
|
||||||
int multiplier = AllZoneUtil.getTokenDoublersMagnitude(hostCard.getController());
|
int multiplier = AllZoneUtil.getTokenDoublersMagnitude(hostCard.getController());
|
||||||
multiplier *= numCopies;
|
multiplier *= numCopies;
|
||||||
Card[] crds = new Card[multiplier];
|
final Card[] crds = new Card[multiplier];
|
||||||
|
|
||||||
for (int i = 0; i < multiplier; i++) {
|
for (int i = 0; i < multiplier; i++) {
|
||||||
// TODO Use central copy methods
|
// TODO Use central copy methods
|
||||||
@@ -387,7 +387,7 @@ public final class AbilityFactory_Copy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add keywords from params
|
// add keywords from params
|
||||||
for (String kw : keywords) {
|
for (final String kw : keywords) {
|
||||||
copy.addIntrinsicKeyword(kw);
|
copy.addIntrinsicKeyword(kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,9 +457,10 @@ public final class AbilityFactory_Copy {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Command atEOT = new Command() {
|
final Command atEOT = new Command() {
|
||||||
private static final long serialVersionUID = -4184510100801568140L;
|
private static final long serialVersionUID = -4184510100801568140L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
sac.setStackDescription(params.get("AtEOT") + " " + target[index] + ".");
|
sac.setStackDescription(params.get("AtEOT") + " " + target[index] + ".");
|
||||||
AllZone.getStack().addSimultaneousStackEntry(sac);
|
AllZone.getStack().addSimultaneousStackEntry(sac);
|
||||||
@@ -495,22 +496,22 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return copySpellStackDescription(af, this);
|
return AbilityFactory_Copy.copySpellStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return copySpellCanPlayAI(af, this);
|
return AbilityFactory_Copy.copySpellCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
copySpellResolve(af, this);
|
AbilityFactory_Copy.copySpellResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return copySpellTriggerAI(af, this, mandatory);
|
return AbilityFactory_Copy.copySpellTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -532,17 +533,17 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return copySpellStackDescription(af, this);
|
return AbilityFactory_Copy.copySpellStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return copySpellCanPlayAI(af, this);
|
return AbilityFactory_Copy.copySpellCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
copySpellResolve(af, this);
|
AbilityFactory_Copy.copySpellResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -564,12 +565,12 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return copySpellStackDescription(af, this);
|
return AbilityFactory_Copy.copySpellStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
copySpellResolve(af, this);
|
AbilityFactory_Copy.copySpellResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -579,7 +580,7 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return copySpellTriggerAI(af, this, mandatory);
|
return AbilityFactory_Copy.copySpellTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -598,8 +599,8 @@ public final class AbilityFactory_Copy {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String copySpellStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String copySpellStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||||
@@ -609,7 +610,7 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
ArrayList<SpellAbility> tgtSpells;
|
ArrayList<SpellAbility> tgtSpells;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtSpells = tgt.getTargetSAs();
|
tgtSpells = tgt.getTargetSAs();
|
||||||
} else {
|
} else {
|
||||||
@@ -618,7 +619,7 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
sb.append("Copy ");
|
sb.append("Copy ");
|
||||||
// TODO Someone fix this Description when Copying Charms
|
// TODO Someone fix this Description when Copying Charms
|
||||||
Iterator<SpellAbility> it = tgtSpells.iterator();
|
final Iterator<SpellAbility> it = tgtSpells.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
sb.append(it.next().getSourceCard());
|
sb.append(it.next().getSourceCard());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
@@ -635,7 +636,7 @@ public final class AbilityFactory_Copy {
|
|||||||
sb.append(".");
|
sb.append(".");
|
||||||
// TODO probably add an optional "You may choose new targets..."
|
// TODO probably add an optional "You may choose new targets..."
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -672,10 +673,10 @@ public final class AbilityFactory_Copy {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean copySpellTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean copySpellTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
boolean randomReturn = false;
|
final boolean randomReturn = false;
|
||||||
|
|
||||||
if (af.hasSubAbility()) {
|
if (af.hasSubAbility()) {
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
return randomReturn && abSub.chkAIDrawback();
|
return randomReturn && abSub.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -695,7 +696,7 @@ public final class AbilityFactory_Copy {
|
|||||||
*/
|
*/
|
||||||
private static void copySpellResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void copySpellResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
if (params.containsKey("Amount")) {
|
if (params.containsKey("Amount")) {
|
||||||
@@ -704,7 +705,7 @@ public final class AbilityFactory_Copy {
|
|||||||
|
|
||||||
ArrayList<SpellAbility> tgtSpells;
|
ArrayList<SpellAbility> tgtSpells;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtSpells = tgt.getTargetSAs();
|
tgtSpells = tgt.getTargetSAs();
|
||||||
} else {
|
} else {
|
||||||
@@ -725,7 +726,7 @@ public final class AbilityFactory_Copy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chosenSA.setActivatingPlayer(sa.getActivatingPlayer());
|
chosenSA.setActivatingPlayer(sa.getActivatingPlayer());
|
||||||
if (tgt == null || CardFactoryUtil.canTarget(card, chosenSA.getSourceCard())) {
|
if ((tgt == null) || CardFactoryUtil.canTarget(card, chosenSA.getSourceCard())) {
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
AllZone.getCardFactory().copySpellontoStack(card, chosenSA.getSourceCard(), chosenSA, true);
|
AllZone.getCardFactory().copySpellontoStack(card, chosenSA.getSourceCard(), chosenSA, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ public class AbilityFactory_CounterMagic {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getAbilityCounter(final AbilityFactory abilityFactory) {
|
public final SpellAbility getAbilityCounter(final AbilityFactory abilityFactory) {
|
||||||
final SpellAbility abCounter = new Ability_Activated(abilityFactory.getHostCard(),
|
final SpellAbility abCounter = new Ability_Activated(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
|
||||||
abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -3895990436431818899L;
|
private static final long serialVersionUID = -3895990436431818899L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -118,8 +118,8 @@ public class AbilityFactory_CounterMagic {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getSpellCounter(final AbilityFactory abilityFactory) {
|
public final SpellAbility getSpellCounter(final AbilityFactory abilityFactory) {
|
||||||
final SpellAbility spCounter = new Spell(abilityFactory.getHostCard(),
|
final SpellAbility spCounter = new Spell(abilityFactory.getHostCard(), abilityFactory.getAbCost(),
|
||||||
abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -4272851734871573693L;
|
private static final long serialVersionUID = -4272851734871573693L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -481,9 +481,7 @@ public class AbilityFactory_CounterMagic {
|
|||||||
* a {@link forge.card.spellability.SpellAbility_StackInstance}
|
* a {@link forge.card.spellability.SpellAbility_StackInstance}
|
||||||
* object.
|
* object.
|
||||||
*/
|
*/
|
||||||
private void removeFromStack(final SpellAbility tgtSA,
|
private void removeFromStack(final SpellAbility tgtSA, final SpellAbility srcSA, final SpellAbility_StackInstance si) {
|
||||||
final SpellAbility srcSA, final SpellAbility_StackInstance si)
|
|
||||||
{
|
|
||||||
AllZone.getStack().remove(si);
|
AllZone.getStack().remove(si);
|
||||||
|
|
||||||
if (tgtSA.isAbility()) {
|
if (tgtSA.isAbility()) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -33,9 +33,9 @@ import forge.card.spellability.Target;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AbilityFactory_DealDamage {
|
public class AbilityFactory_DealDamage {
|
||||||
private AbilityFactory AF = null;
|
private AbilityFactory abilityFactory = null;
|
||||||
|
|
||||||
private String damage;
|
private final String damage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -46,9 +46,9 @@ public class AbilityFactory_DealDamage {
|
|||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
*/
|
*/
|
||||||
public AbilityFactory_DealDamage(final AbilityFactory newAF) {
|
public AbilityFactory_DealDamage(final AbilityFactory newAF) {
|
||||||
AF = newAF;
|
this.abilityFactory = newAF;
|
||||||
|
|
||||||
damage = AF.getMapParams().get("NumDmg");
|
this.damage = this.abilityFactory.getMapParams().get("NumDmg");
|
||||||
|
|
||||||
// Note: TgtOpp should not be used, Please use ValidTgts$ Opponent
|
// Note: TgtOpp should not be used, Please use ValidTgts$ Opponent
|
||||||
// instead
|
// instead
|
||||||
@@ -67,27 +67,29 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getAbility() {
|
public final SpellAbility getAbility() {
|
||||||
final SpellAbility abDamage = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility abDamage = new Ability_Activated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
|
||||||
|
this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -7560349014757367722L;
|
private static final long serialVersionUID = -7560349014757367722L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return doCanPlayAI(this);
|
return AbilityFactory_DealDamage.this.doCanPlayAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return damageStackDescription(AF, this);
|
return AbilityFactory_DealDamage.this.damageStackDescription(AbilityFactory_DealDamage.this.abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(this);
|
AbilityFactory_DealDamage.this.doResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return damageDoTriggerAI(AF, this, mandatory);
|
return AbilityFactory_DealDamage.this.damageDoTriggerAI(AbilityFactory_DealDamage.this.abilityFactory, this,
|
||||||
|
mandatory);
|
||||||
}
|
}
|
||||||
}; // Ability_Activated
|
}; // Ability_Activated
|
||||||
|
|
||||||
@@ -102,23 +104,23 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getSpell() {
|
public final SpellAbility getSpell() {
|
||||||
final SpellAbility spDealDamage = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spDealDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 7239608350643325111L;
|
private static final long serialVersionUID = 7239608350643325111L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return doCanPlayAI(this);
|
return AbilityFactory_DealDamage.this.doCanPlayAI(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return damageStackDescription(AF, this);
|
return AbilityFactory_DealDamage.this.damageStackDescription(AbilityFactory_DealDamage.this.abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(this);
|
AbilityFactory_DealDamage.this.doResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Spell
|
}; // Spell
|
||||||
@@ -134,28 +136,29 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getDrawback() {
|
public final SpellAbility getDrawback() {
|
||||||
final SpellAbility dbDealDamage = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbDealDamage = new Ability_Sub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 7239608350643325111L;
|
private static final long serialVersionUID = 7239608350643325111L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
// Make sure there is a valid target
|
// Make sure there is a valid target
|
||||||
return damageDrawback(this);
|
return AbilityFactory_DealDamage.this.damageDrawback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return damageStackDescription(AF, this);
|
return AbilityFactory_DealDamage.this.damageStackDescription(AbilityFactory_DealDamage.this.abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(this);
|
AbilityFactory_DealDamage.this.doResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return damageDoTriggerAI(AF, this, mandatory);
|
return AbilityFactory_DealDamage.this.damageDoTriggerAI(AbilityFactory_DealDamage.this.abilityFactory, this,
|
||||||
|
mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Drawback
|
}; // Drawback
|
||||||
@@ -177,9 +180,9 @@ public class AbilityFactory_DealDamage {
|
|||||||
private String damageStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private String damageStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// when damageStackDescription is called, just build exactly what is
|
// when damageStackDescription is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
String name = af.getHostCard().toString();
|
final String name = af.getHostCard().toString();
|
||||||
int dmg = getNumDamage(sa);
|
final int dmg = this.getNumDamage(sa);
|
||||||
|
|
||||||
ArrayList<Object> tgts;
|
ArrayList<Object> tgts;
|
||||||
if (sa.getTarget() == null) {
|
if (sa.getTarget() == null) {
|
||||||
@@ -193,14 +196,14 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
|
||||||
String conditionDesc = af.getMapParams().get("ConditionDescription");
|
final String conditionDesc = af.getMapParams().get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> definedSources = AbilityFactory.getDefinedCards(sa.getSourceCard(),
|
final ArrayList<Card> definedSources = AbilityFactory.getDefinedCards(sa.getSourceCard(), af.getMapParams()
|
||||||
af.getMapParams().get("DamageSource"), sa);
|
.get("DamageSource"), sa);
|
||||||
Card source = definedSources.get(0);
|
final Card source = definedSources.get(0);
|
||||||
|
|
||||||
if (source != sa.getSourceCard()) {
|
if (source != sa.getSourceCard()) {
|
||||||
sb.append(source.toString()).append(" deals");
|
sb.append(source.toString()).append(" deals");
|
||||||
@@ -215,8 +218,8 @@ public class AbilityFactory_DealDamage {
|
|||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object o = tgts.get(i);
|
final Object o = tgts.get(i);
|
||||||
if (o instanceof Card || o instanceof Player) {
|
if ((o instanceof Card) || (o instanceof Player)) {
|
||||||
sb.append(o.toString());
|
sb.append(o.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,7 +253,7 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
private int getNumDamage(final SpellAbility saMe) {
|
private int getNumDamage(final SpellAbility saMe) {
|
||||||
return AbilityFactory.calculateAmount(saMe.getSourceCard(), damage, saMe);
|
return AbilityFactory.calculateAmount(saMe.getSourceCard(), this.damage, saMe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,16 +266,16 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean damageDrawback(final SpellAbility sa) {
|
private boolean damageDrawback(final SpellAbility sa) {
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
int dmg;
|
int dmg;
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
dmg = ComputerUtil.determineLeftoverMana(sa);
|
dmg = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(dmg));
|
source.setSVar("PayX", Integer.toString(dmg));
|
||||||
} else {
|
} else {
|
||||||
dmg = getNumDamage(sa);
|
dmg = this.getNumDamage(sa);
|
||||||
}
|
}
|
||||||
return damageTargetAI(sa, dmg);
|
return this.damageTargetAI(sa, dmg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -286,18 +289,18 @@ public class AbilityFactory_DealDamage {
|
|||||||
*/
|
*/
|
||||||
private boolean doCanPlayAI(final SpellAbility saMe) {
|
private boolean doCanPlayAI(final SpellAbility saMe) {
|
||||||
|
|
||||||
Cost abCost = AF.getAbCost();
|
final Cost abCost = this.abilityFactory.getAbCost();
|
||||||
Card source = saMe.getSourceCard();
|
final Card source = saMe.getSourceCard();
|
||||||
|
|
||||||
int dmg = 0;
|
int dmg = 0;
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
dmg = ComputerUtil.determineLeftoverMana(saMe);
|
dmg = ComputerUtil.determineLeftoverMana(saMe);
|
||||||
source.setSVar("PayX", Integer.toString(dmg));
|
source.setSVar("PayX", Integer.toString(dmg));
|
||||||
} else {
|
} else {
|
||||||
dmg = getNumDamage(saMe);
|
dmg = this.getNumDamage(saMe);
|
||||||
}
|
}
|
||||||
boolean rr = AF.isSpell();
|
boolean rr = this.abilityFactory.isSpell();
|
||||||
|
|
||||||
if (dmg <= 0) {
|
if (dmg <= 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -326,28 +329,29 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AF.isAbility()) {
|
if (this.abilityFactory.isAbility()) {
|
||||||
Random r = MyRandom.getRandom(); // prevent run-away activations
|
final Random r = MyRandom.getRandom(); // prevent run-away
|
||||||
|
// activations
|
||||||
if (r.nextFloat() <= Math.pow(.6667, saMe.getActivationsThisTurn())) {
|
if (r.nextFloat() <= Math.pow(.6667, saMe.getActivationsThisTurn())) {
|
||||||
rr = true;
|
rr = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean bFlag = damageTargetAI(saMe, dmg);
|
final boolean bFlag = this.damageTargetAI(saMe, dmg);
|
||||||
if (!bFlag) {
|
if (!bFlag) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// If I can kill my target by paying less mana, do it
|
// If I can kill my target by paying less mana, do it
|
||||||
Target tgt = saMe.getTarget();
|
final Target tgt = saMe.getTarget();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
int actualPay = 0;
|
int actualPay = 0;
|
||||||
boolean noPrevention = AF.getMapParams().containsKey("NoPrevention");
|
final boolean noPrevention = this.abilityFactory.getMapParams().containsKey("NoPrevention");
|
||||||
ArrayList<Card> cards = tgt.getTargetCards();
|
final ArrayList<Card> cards = tgt.getTargetCards();
|
||||||
for (Card c : cards) {
|
for (final Card c : cards) {
|
||||||
int adjDamage = c.getEnoughDamageToKill(dmg, source, false, noPrevention);
|
final int adjDamage = c.getEnoughDamageToKill(dmg, source, false, noPrevention);
|
||||||
if (adjDamage > actualPay && adjDamage <= dmg) {
|
if ((adjDamage > actualPay) && (adjDamage <= dmg)) {
|
||||||
actualPay = adjDamage;
|
actualPay = adjDamage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,7 +359,7 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = saMe.getSubAbility();
|
final Ability_Sub subAb = saMe.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
rr &= subAb.chkAIDrawback();
|
rr &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -377,13 +381,13 @@ public class AbilityFactory_DealDamage {
|
|||||||
*/
|
*/
|
||||||
private boolean shouldTgtP(final SpellAbility sa, final int d, final boolean noPrevention) {
|
private boolean shouldTgtP(final SpellAbility sa, final int d, final boolean noPrevention) {
|
||||||
int restDamage = d;
|
int restDamage = d;
|
||||||
Player human = AllZone.getHumanPlayer();
|
final Player human = AllZone.getHumanPlayer();
|
||||||
Player comp = AllZone.getComputerPlayer();
|
final Player comp = AllZone.getComputerPlayer();
|
||||||
|
|
||||||
if (!noPrevention) {
|
if (!noPrevention) {
|
||||||
restDamage = human.predictDamage(restDamage, AF.getHostCard(), false);
|
restDamage = human.predictDamage(restDamage, this.abilityFactory.getHostCard(), false);
|
||||||
} else {
|
} else {
|
||||||
restDamage = human.staticReplaceDamage(restDamage, AF.getHostCard(), false);
|
restDamage = human.staticReplaceDamage(restDamage, this.abilityFactory.getHostCard(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restDamage == 0) {
|
if (restDamage == 0) {
|
||||||
@@ -394,9 +398,9 @@ public class AbilityFactory_DealDamage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList hand = comp.getCardsIn(Zone.Hand);
|
final CardList hand = comp.getCardsIn(Zone.Hand);
|
||||||
|
|
||||||
if (AF.isSpell()) {
|
if (this.abilityFactory.isSpell()) {
|
||||||
// If this is a spell, cast it instead of discarding
|
// If this is a spell, cast it instead of discarding
|
||||||
if ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN) || AllZone.getPhase().is(Constant.Phase.MAIN2))
|
if ((AllZone.getPhase().is(Constant.Phase.END_OF_TURN) || AllZone.getPhase().is(Constant.Phase.MAIN2))
|
||||||
&& AllZone.getPhase().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
&& AllZone.getPhase().isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
||||||
@@ -404,7 +408,7 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (human.getLife() - restDamage < 5) {
|
if ((human.getLife() - restDamage) < 5) {
|
||||||
// drop the human to less than 5
|
// drop the human to less than 5
|
||||||
// life
|
// life
|
||||||
return true;
|
return true;
|
||||||
@@ -429,15 +433,15 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
private Card chooseTgtC(final int d, final boolean noPrevention, final Player pl, final boolean mandatory) {
|
private Card chooseTgtC(final int d, final boolean noPrevention, final Player pl, final boolean mandatory) {
|
||||||
Target tgt = AF.getAbTgt();
|
final Target tgt = this.abilityFactory.getAbTgt();
|
||||||
final Card source = AF.getHostCard();
|
final Card source = this.abilityFactory.getHostCard();
|
||||||
CardList hPlay = pl.getCardsIn(Zone.Battlefield);
|
CardList hPlay = pl.getCardsIn(Zone.Battlefield);
|
||||||
hPlay = hPlay.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source);
|
hPlay = hPlay.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source);
|
||||||
|
|
||||||
ArrayList<Object> objects = tgt.getTargets();
|
final ArrayList<Object> objects = tgt.getTargets();
|
||||||
for (Object o : objects) {
|
for (final Object o : objects) {
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
Card c = (Card) o;
|
final Card c = (Card) o;
|
||||||
if (hPlay.contains(c)) {
|
if (hPlay.contains(c)) {
|
||||||
hPlay.remove(c);
|
hPlay.remove(c);
|
||||||
}
|
}
|
||||||
@@ -445,7 +449,8 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
hPlay = hPlay.getTargetableCards(source);
|
hPlay = hPlay.getTargetableCards(source);
|
||||||
|
|
||||||
CardList killables = hPlay.filter(new CardListFilter() {
|
final CardList killables = hPlay.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return (c.getEnoughDamageToKill(d, source, false, noPrevention) <= d) && !ComputerUtil.canRegenerate(c)
|
return (c.getEnoughDamageToKill(d, source, false, noPrevention) <= d) && !ComputerUtil.canRegenerate(c)
|
||||||
&& !(c.getSVar("SacMe").length() > 0);
|
&& !(c.getSVar("SacMe").length() > 0);
|
||||||
@@ -453,7 +458,7 @@ public class AbilityFactory_DealDamage {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Card targetCard;
|
Card targetCard;
|
||||||
if (pl.isHuman() && killables.size() > 0) {
|
if (pl.isHuman() && (killables.size() > 0)) {
|
||||||
targetCard = CardFactoryUtil.AI_getBestCreature(killables);
|
targetCard = CardFactoryUtil.AI_getBestCreature(killables);
|
||||||
|
|
||||||
return targetCard;
|
return targetCard;
|
||||||
@@ -488,13 +493,13 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean damageTargetAI(final SpellAbility saMe, final int dmg) {
|
private boolean damageTargetAI(final SpellAbility saMe, final int dmg) {
|
||||||
Target tgt = AF.getAbTgt();
|
final Target tgt = this.abilityFactory.getAbTgt();
|
||||||
|
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
return damageChooseNontargeted(saMe, dmg);
|
return this.damageChooseNontargeted(saMe, dmg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return damageChoosingTargets(saMe, tgt, dmg, false);
|
return this.damageChoosingTargets(saMe, tgt, dmg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -512,8 +517,9 @@ public class AbilityFactory_DealDamage {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean damageChoosingTargets(final SpellAbility saMe, final Target tgt, final int dmg, final boolean mandatory) {
|
private boolean damageChoosingTargets(final SpellAbility saMe, final Target tgt, final int dmg,
|
||||||
boolean noPrevention = AF.getMapParams().containsKey("NoPrevention");
|
final boolean mandatory) {
|
||||||
|
final boolean noPrevention = this.abilityFactory.getMapParams().containsKey("NoPrevention");
|
||||||
|
|
||||||
// target loop
|
// target loop
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
@@ -522,13 +528,13 @@ public class AbilityFactory_DealDamage {
|
|||||||
// TODO: Consider targeting the planeswalker
|
// TODO: Consider targeting the planeswalker
|
||||||
if (tgt.canTgtCreatureAndPlayer()) {
|
if (tgt.canTgtCreatureAndPlayer()) {
|
||||||
|
|
||||||
if (shouldTgtP(saMe, dmg, noPrevention)) {
|
if (this.shouldTgtP(saMe, dmg, noPrevention)) {
|
||||||
if (tgt.addTarget(AllZone.getHumanPlayer())) {
|
if (tgt.addTarget(AllZone.getHumanPlayer())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card c = chooseTgtC(dmg, noPrevention, AllZone.getHumanPlayer(), mandatory);
|
final Card c = this.chooseTgtC(dmg, noPrevention, AllZone.getHumanPlayer(), mandatory);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
continue;
|
continue;
|
||||||
@@ -541,13 +547,13 @@ public class AbilityFactory_DealDamage {
|
|||||||
// TODO: add check here if card is about to die from something
|
// TODO: add check here if card is about to die from something
|
||||||
// on the stack
|
// on the stack
|
||||||
// or from taking combat damage
|
// or from taking combat damage
|
||||||
boolean freePing = mandatory || AbilityFactory.playReusable(saMe) || tgt.getNumTargeted() > 0;
|
final boolean freePing = mandatory || AbilityFactory.playReusable(saMe) || (tgt.getNumTargeted() > 0);
|
||||||
|
|
||||||
if (freePing && tgt.addTarget(AllZone.getHumanPlayer())) {
|
if (freePing && tgt.addTarget(AllZone.getHumanPlayer())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (tgt.canTgtCreature()) {
|
} else if (tgt.canTgtCreature()) {
|
||||||
Card c = chooseTgtC(dmg, noPrevention, AllZone.getHumanPlayer(), mandatory);
|
final Card c = this.chooseTgtC(dmg, noPrevention, AllZone.getHumanPlayer(), mandatory);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
continue;
|
continue;
|
||||||
@@ -562,14 +568,14 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fell through all the choices, no targets left?
|
// fell through all the choices, no targets left?
|
||||||
if ((tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe) || tgt.getNumTargeted() == 0)) {
|
if (((tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe)) || (tgt.getNumTargeted() == 0))) {
|
||||||
if (!mandatory) {
|
if (!mandatory) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// If the trigger is mandatory, gotta choose my own stuff
|
// If the trigger is mandatory, gotta choose my own stuff
|
||||||
// now
|
// now
|
||||||
return damageChooseRequiredTargets(saMe, tgt, dmg, mandatory);
|
return this.damageChooseRequiredTargets(saMe, tgt, dmg, mandatory);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO is this good enough? for up to amounts?
|
// TODO is this good enough? for up to amounts?
|
||||||
@@ -592,16 +598,16 @@ public class AbilityFactory_DealDamage {
|
|||||||
*/
|
*/
|
||||||
private boolean damageChooseNontargeted(final SpellAbility saMe, final int dmg) {
|
private boolean damageChooseNontargeted(final SpellAbility saMe, final int dmg) {
|
||||||
// TODO: Improve circumstances where the Defined Damage is unwanted
|
// TODO: Improve circumstances where the Defined Damage is unwanted
|
||||||
ArrayList<Object> objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(),
|
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), this.abilityFactory.getMapParams()
|
||||||
AF.getMapParams().get("Defined"), saMe);
|
.get("Defined"), saMe);
|
||||||
|
|
||||||
for (Object o : objects) {
|
for (final Object o : objects) {
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
// Card c = (Card)o;
|
// Card c = (Card)o;
|
||||||
} else if (o instanceof Player) {
|
} else if (o instanceof Player) {
|
||||||
Player p = (Player) o;
|
final Player p = (Player) o;
|
||||||
int restDamage = p.predictDamage(dmg, AF.getHostCard(), false);
|
final int restDamage = p.predictDamage(dmg, this.abilityFactory.getHostCard(), false);
|
||||||
if (p.isComputer() && p.canLoseLife() && restDamage + 3 >= p.getLife() && restDamage > 0) {
|
if (p.isComputer() && p.canLoseLife() && ((restDamage + 3) >= p.getLife()) && (restDamage > 0)) {
|
||||||
// from
|
// from
|
||||||
// this
|
// this
|
||||||
// spell
|
// spell
|
||||||
@@ -633,14 +639,15 @@ public class AbilityFactory_DealDamage {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean damageChooseRequiredTargets(final SpellAbility saMe, final Target tgt, final int dmg, final boolean mandatory) {
|
private boolean damageChooseRequiredTargets(final SpellAbility saMe, final Target tgt, final int dmg,
|
||||||
|
final boolean mandatory) {
|
||||||
// this is for Triggered targets that are mandatory
|
// this is for Triggered targets that are mandatory
|
||||||
boolean noPrevention = AF.getMapParams().containsKey("NoPrevention");
|
final boolean noPrevention = this.abilityFactory.getMapParams().containsKey("NoPrevention");
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe)) {
|
while (tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe)) {
|
||||||
// TODO: Consider targeting the planeswalker
|
// TODO: Consider targeting the planeswalker
|
||||||
if (tgt.canTgtCreature()) {
|
if (tgt.canTgtCreature()) {
|
||||||
Card c = chooseTgtC(dmg, noPrevention, AllZone.getComputerPlayer(), mandatory);
|
final Card c = this.chooseTgtC(dmg, noPrevention, AllZone.getComputerPlayer(), mandatory);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
continue;
|
continue;
|
||||||
@@ -678,34 +685,34 @@ public class AbilityFactory_DealDamage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
int dmg;
|
int dmg;
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
dmg = ComputerUtil.determineLeftoverMana(sa);
|
dmg = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(dmg));
|
source.setSVar("PayX", Integer.toString(dmg));
|
||||||
} else {
|
} else {
|
||||||
dmg = getNumDamage(sa);
|
dmg = this.getNumDamage(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// If it's not mandatory check a few things
|
// If it's not mandatory check a few things
|
||||||
if (!mandatory && !damageChooseNontargeted(sa, dmg)) {
|
if (!mandatory && !this.damageChooseNontargeted(sa, dmg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!damageChoosingTargets(sa, tgt, dmg, mandatory) && !mandatory) {
|
if (!this.damageChoosingTargets(sa, tgt, dmg, mandatory) && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// If I can kill my target by paying less mana, do it
|
// If I can kill my target by paying less mana, do it
|
||||||
int actualPay = 0;
|
int actualPay = 0;
|
||||||
boolean noPrevention = AF.getMapParams().containsKey("NoPrevention");
|
final boolean noPrevention = this.abilityFactory.getMapParams().containsKey("NoPrevention");
|
||||||
ArrayList<Card> cards = tgt.getTargetCards();
|
final ArrayList<Card> cards = tgt.getTargetCards();
|
||||||
for (Card c : cards) {
|
for (final Card c : cards) {
|
||||||
int adjDamage = c.getEnoughDamageToKill(dmg, source, false, noPrevention);
|
final int adjDamage = c.getEnoughDamageToKill(dmg, source, false, noPrevention);
|
||||||
if (adjDamage > actualPay) {
|
if (adjDamage > actualPay) {
|
||||||
actualPay = adjDamage;
|
actualPay = adjDamage;
|
||||||
}
|
}
|
||||||
@@ -731,11 +738,11 @@ public class AbilityFactory_DealDamage {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private void doResolve(final SpellAbility saMe) {
|
private void doResolve(final SpellAbility saMe) {
|
||||||
HashMap<String, String> params = AF.getMapParams();
|
final HashMap<String, String> params = this.abilityFactory.getMapParams();
|
||||||
|
|
||||||
int dmg = getNumDamage(saMe);
|
final int dmg = this.getNumDamage(saMe);
|
||||||
|
|
||||||
boolean noPrevention = params.containsKey("NoPrevention");
|
final boolean noPrevention = params.containsKey("NoPrevention");
|
||||||
|
|
||||||
ArrayList<Object> tgts;
|
ArrayList<Object> tgts;
|
||||||
if (saMe.getTarget() == null) {
|
if (saMe.getTarget() == null) {
|
||||||
@@ -744,7 +751,7 @@ public class AbilityFactory_DealDamage {
|
|||||||
tgts = saMe.getTarget().getTargets();
|
tgts = saMe.getTarget().getTargets();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean targeted = (AF.getAbTgt() != null);
|
final boolean targeted = (this.abilityFactory.getAbTgt() != null);
|
||||||
|
|
||||||
if (params.containsKey("Radiance") && targeted) {
|
if (params.containsKey("Radiance") && targeted) {
|
||||||
Card origin = null;
|
Card origin = null;
|
||||||
@@ -754,22 +761,23 @@ public class AbilityFactory_DealDamage {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (origin != null) // Can't radiate from a player
|
// Can't radiate from a player
|
||||||
{
|
if (origin != null) {
|
||||||
for (Card c : CardUtil.getRadiance(AF.getHostCard(), origin, params.get("ValidTgts").split(","))) {
|
for (final Card c : CardUtil.getRadiance(this.abilityFactory.getHostCard(), origin,
|
||||||
|
params.get("ValidTgts").split(","))) {
|
||||||
tgts.add(c);
|
tgts.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> definedSources = AbilityFactory.getDefinedCards(saMe.getSourceCard(),
|
final ArrayList<Card> definedSources = AbilityFactory.getDefinedCards(saMe.getSourceCard(),
|
||||||
params.get("DamageSource"), saMe);
|
params.get("DamageSource"), saMe);
|
||||||
Card source = definedSources.get(0);
|
final Card source = definedSources.get(0);
|
||||||
|
|
||||||
for (Object o : tgts) {
|
for (final Object o : tgts) {
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
Card c = (Card) o;
|
final Card c = (Card) o;
|
||||||
if (AllZoneUtil.isCardInPlay(c) && (!targeted || CardFactoryUtil.canTarget(AF.getHostCard(), c))) {
|
if (AllZoneUtil.isCardInPlay(c) && (!targeted || CardFactoryUtil.canTarget(this.abilityFactory.getHostCard(), c))) {
|
||||||
if (noPrevention) {
|
if (noPrevention) {
|
||||||
c.addDamageWithoutPrevention(dmg, source);
|
c.addDamageWithoutPrevention(dmg, source);
|
||||||
} else {
|
} else {
|
||||||
@@ -778,7 +786,7 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (o instanceof Player) {
|
} else if (o instanceof Player) {
|
||||||
Player p = (Player) o;
|
final Player p = (Player) o;
|
||||||
if (!targeted || p.canTarget(saMe)) {
|
if (!targeted || p.canTarget(saMe)) {
|
||||||
if (noPrevention) {
|
if (noPrevention) {
|
||||||
p.addDamageWithoutPrevention(dmg, source);
|
p.addDamageWithoutPrevention(dmg, source);
|
||||||
@@ -803,28 +811,30 @@ public class AbilityFactory_DealDamage {
|
|||||||
*/
|
*/
|
||||||
public final SpellAbility getAbilityDamageAll() {
|
public final SpellAbility getAbilityDamageAll() {
|
||||||
|
|
||||||
final SpellAbility abDamageAll = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility abDamageAll = new Ability_Activated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
|
||||||
|
this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -1831356710492849854L;
|
private static final long serialVersionUID = -1831356710492849854L;
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = AbilityFactory_DealDamage.this.abilityFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return damageAllStackDescription(af, this);
|
return AbilityFactory_DealDamage.this.damageAllStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return damageAllCanPlayAI(af, this);
|
return AbilityFactory_DealDamage.this.damageAllCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
damageAllResolve(af, this);
|
AbilityFactory_DealDamage.this.damageAllResolve(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return damageAllDoTriggerAI(AF, this, mandatory);
|
return AbilityFactory_DealDamage.this.damageAllDoTriggerAI(AbilityFactory_DealDamage.this.abilityFactory, this,
|
||||||
|
mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -839,27 +849,29 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getSpellDamageAll() {
|
public final SpellAbility getSpellDamageAll() {
|
||||||
final SpellAbility spDamageAll = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spDamageAll = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 8004957182752984818L;
|
private static final long serialVersionUID = 8004957182752984818L;
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = AbilityFactory_DealDamage.this.abilityFactory;
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
private final HashMap<String, String> params = this.af.getMapParams();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
if (params.containsKey("SpellDescription")) {
|
if (this.params.containsKey("SpellDescription")) {
|
||||||
return AF.getHostCard().getName() + " - " + params.get("SpellDescription");
|
return AbilityFactory_DealDamage.this.abilityFactory.getHostCard().getName() + " - "
|
||||||
|
+ this.params.get("SpellDescription");
|
||||||
} else {
|
} else {
|
||||||
return damageAllStackDescription(af, this);
|
return AbilityFactory_DealDamage.this.damageAllStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return damageAllCanPlayAI(af, this);
|
return AbilityFactory_DealDamage.this.damageAllCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
damageAllResolve(af, this);
|
AbilityFactory_DealDamage.this.damageAllResolve(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -874,18 +886,18 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getDrawbackDamageAll() {
|
public final SpellAbility getDrawbackDamageAll() {
|
||||||
final SpellAbility dbDamageAll = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbDamageAll = new Ability_Sub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -6169562107675964474L;
|
private static final long serialVersionUID = -6169562107675964474L;
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = AbilityFactory_DealDamage.this.abilityFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return damageAllStackDescription(af, this);
|
return AbilityFactory_DealDamage.this.damageAllStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
damageAllResolve(af, this);
|
AbilityFactory_DealDamage.this.damageAllResolve(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -896,7 +908,8 @@ public class AbilityFactory_DealDamage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return damageAllDoTriggerAI(AF, this, mandatory);
|
return AbilityFactory_DealDamage.this.damageAllDoTriggerAI(AbilityFactory_DealDamage.this.abilityFactory, this,
|
||||||
|
mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -915,18 +928,18 @@ public class AbilityFactory_DealDamage {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String damageAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private String damageAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
String name = af.getHostCard().getName();
|
final String name = af.getHostCard().getName();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
String desc = "";
|
String desc = "";
|
||||||
if (params.containsKey("ValidDescription")) {
|
if (params.containsKey("ValidDescription")) {
|
||||||
desc = params.get("ValidDescription");
|
desc = params.get("ValidDescription");
|
||||||
}
|
}
|
||||||
int dmg = getNumDamage(sa);
|
final int dmg = this.getNumDamage(sa);
|
||||||
|
|
||||||
sb.append(name).append(" - Deals " + dmg + " damage to " + desc);
|
sb.append(name).append(" - Deals " + dmg + " damage to " + desc);
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -948,30 +961,30 @@ public class AbilityFactory_DealDamage {
|
|||||||
private boolean damageAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private boolean damageAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI needs to be expanded, since this function can be pretty complex
|
// AI needs to be expanded, since this function can be pretty complex
|
||||||
// based on what the expected targets could be
|
// based on what the expected targets could be
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
Cost abCost = sa.getPayCosts();
|
final Cost abCost = sa.getPayCosts();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
String validP = "";
|
String validP = "";
|
||||||
|
|
||||||
int dmg;
|
int dmg;
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
dmg = ComputerUtil.determineLeftoverMana(sa);
|
dmg = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(dmg));
|
source.setSVar("PayX", Integer.toString(dmg));
|
||||||
} else {
|
} else {
|
||||||
dmg = getNumDamage(sa);
|
dmg = this.getNumDamage(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("ValidPlayers")) {
|
if (params.containsKey("ValidPlayers")) {
|
||||||
validP = params.get("ValidPlayers");
|
validP = params.get("ValidPlayers");
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList humanList = getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg);
|
final CardList humanList = this.getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg);
|
||||||
CardList computerList = getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg);
|
CardList computerList = this.getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg);
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
sa.getTarget().addTarget(AllZone.getHumanPlayer());
|
sa.getTarget().addTarget(AllZone.getHumanPlayer());
|
||||||
@@ -990,14 +1003,14 @@ public class AbilityFactory_DealDamage {
|
|||||||
// max life
|
// max life
|
||||||
// Don't kill yourself
|
// Don't kill yourself
|
||||||
if (validP.contains("Each")
|
if (validP.contains("Each")
|
||||||
&& AllZone.getComputerPlayer().getLife() <= AllZone.getComputerPlayer().predictDamage(dmg, source,
|
&& (AllZone.getComputerPlayer().getLife() <= AllZone.getComputerPlayer().predictDamage(dmg, source,
|
||||||
false)) {
|
false))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we can kill human, do it
|
// if we can kill human, do it
|
||||||
if ((validP.contains("Each") || validP.contains("EachOpponent"))
|
if ((validP.contains("Each") || validP.contains("EachOpponent"))
|
||||||
&& AllZone.getHumanPlayer().getLife() <= AllZone.getHumanPlayer().predictDamage(dmg, source, false)) {
|
&& (AllZone.getHumanPlayer().getLife() <= AllZone.getHumanPlayer().predictDamage(dmg, source, false))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,12 +1023,12 @@ public class AbilityFactory_DealDamage {
|
|||||||
}
|
}
|
||||||
// evaluate both lists and pass only if human creatures are more
|
// evaluate both lists and pass only if human creatures are more
|
||||||
// valuable
|
// valuable
|
||||||
if (CardFactoryUtil.evaluateCreatureList(computerList) + minGain >= CardFactoryUtil
|
if ((CardFactoryUtil.evaluateCreatureList(computerList) + minGain) >= CardFactoryUtil
|
||||||
.evaluateCreatureList(humanList)) {
|
.evaluateCreatureList(humanList)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -1038,7 +1051,8 @@ public class AbilityFactory_DealDamage {
|
|||||||
* a int.
|
* a int.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
private CardList getKillableCreatures(final AbilityFactory af, final SpellAbility sa, final Player player, final int dmg) {
|
private CardList getKillableCreatures(final AbilityFactory af, final SpellAbility sa, final Player player,
|
||||||
|
final int dmg) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final Card source = af.getHostCard();
|
final Card source = af.getHostCard();
|
||||||
|
|
||||||
@@ -1051,7 +1065,8 @@ public class AbilityFactory_DealDamage {
|
|||||||
CardList list = player.getCardsIn(Zone.Battlefield);
|
CardList list = player.getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(validC.split(","), source.getController(), source);
|
list = list.getValidCards(validC.split(","), source.getController(), source);
|
||||||
|
|
||||||
CardListFilter filterKillable = new CardListFilter() {
|
final CardListFilter filterKillable = new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return (c.predictDamage(dmg, source, false) >= c.getKillDamage());
|
return (c.predictDamage(dmg, source, false) >= c.getKillDamage());
|
||||||
}
|
}
|
||||||
@@ -1086,19 +1101,19 @@ public class AbilityFactory_DealDamage {
|
|||||||
String validP = "";
|
String validP = "";
|
||||||
|
|
||||||
int dmg;
|
int dmg;
|
||||||
if (damage.equals("X") && source.getSVar(damage).equals("Count$xPaid")) {
|
if (this.damage.equals("X") && source.getSVar(this.damage).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
dmg = ComputerUtil.determineLeftoverMana(sa);
|
dmg = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(dmg));
|
source.setSVar("PayX", Integer.toString(dmg));
|
||||||
} else {
|
} else {
|
||||||
dmg = getNumDamage(sa);
|
dmg = this.getNumDamage(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("ValidPlayers")) {
|
if (params.containsKey("ValidPlayers")) {
|
||||||
validP = params.get("ValidPlayers");
|
validP = params.get("ValidPlayers");
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
do { // A little trick to still check the SubAbilities, once we know we
|
do { // A little trick to still check the SubAbilities, once we know we
|
||||||
// want to play it
|
// want to play it
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
@@ -1108,22 +1123,22 @@ public class AbilityFactory_DealDamage {
|
|||||||
} else {
|
} else {
|
||||||
// Don't get yourself killed
|
// Don't get yourself killed
|
||||||
if (validP.contains("Each")
|
if (validP.contains("Each")
|
||||||
&& AllZone.getComputerPlayer().getLife() <= AllZone.getComputerPlayer().predictDamage(dmg,
|
&& (AllZone.getComputerPlayer().getLife() <= AllZone.getComputerPlayer().predictDamage(dmg,
|
||||||
source, false)) {
|
source, false))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we can kill human, do it
|
// if we can kill human, do it
|
||||||
if ((validP.contains("Each") || validP.contains("EachOpponent") || validP.contains("Targeted"))
|
if ((validP.contains("Each") || validP.contains("EachOpponent") || validP.contains("Targeted"))
|
||||||
&& AllZone.getHumanPlayer().getLife() <= AllZone.getHumanPlayer().predictDamage(dmg,
|
&& (AllZone.getHumanPlayer().getLife() <= AllZone.getHumanPlayer().predictDamage(dmg,
|
||||||
source, false)) {
|
source, false))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate creatures getting killed
|
// Evaluate creatures getting killed
|
||||||
CardList humanList = getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg);
|
final CardList humanList = this.getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg);
|
||||||
CardList computerList = getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg);
|
final CardList computerList = this.getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg);
|
||||||
if (CardFactoryUtil.evaluateCreatureList(computerList) + 50 >= CardFactoryUtil
|
if ((CardFactoryUtil.evaluateCreatureList(computerList) + 50) >= CardFactoryUtil
|
||||||
.evaluateCreatureList(humanList)) {
|
.evaluateCreatureList(humanList)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1151,12 +1166,12 @@ public class AbilityFactory_DealDamage {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private void damageAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
private void damageAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
int dmg = getNumDamage(sa);
|
final int dmg = this.getNumDamage(sa);
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
Player targetPlayer = null;
|
Player targetPlayer = null;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
targetPlayer = tgt.getTargetPlayers().get(0);
|
targetPlayer = tgt.getTargetPlayers().get(0);
|
||||||
@@ -1179,15 +1194,18 @@ public class AbilityFactory_DealDamage {
|
|||||||
|
|
||||||
list = AbilityFactory.filterListByType(list, params.get("ValidCards"), sa);
|
list = AbilityFactory.filterListByType(list, params.get("ValidCards"), sa);
|
||||||
|
|
||||||
for (Card c : list)
|
for (final Card c : list) {
|
||||||
c.addDamage(dmg, card);
|
c.addDamage(dmg, card);
|
||||||
|
}
|
||||||
|
|
||||||
if (players.equals("Each")) {
|
if (players.equals("Each")) {
|
||||||
for (Player p : AllZone.getPlayersInGame())
|
for (final Player p : AllZone.getPlayersInGame()) {
|
||||||
p.addDamage(dmg, card);
|
p.addDamage(dmg, card);
|
||||||
|
}
|
||||||
} else if (players.equals("EachOpponent")) {
|
} else if (players.equals("EachOpponent")) {
|
||||||
for (Player p : AllZoneUtil.getOpponents(card.getController()))
|
for (final Player p : AllZoneUtil.getOpponents(card.getController())) {
|
||||||
p.addDamage(dmg, card);
|
p.addDamage(dmg, card);
|
||||||
|
}
|
||||||
} else if (players.equals("Self")) {
|
} else if (players.equals("Self")) {
|
||||||
card.getController().addDamage(dmg, card);
|
card.getController().addDamage(dmg, card);
|
||||||
} else if (players.equals("Targeted")) {
|
} else if (players.equals("Targeted")) {
|
||||||
|
|||||||
@@ -60,22 +60,22 @@ public final class AbilityFactory_Debuff {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return debuffStackDescription(af, this);
|
return AbilityFactory_Debuff.debuffStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return debuffCanPlayAI(af, this);
|
return AbilityFactory_Debuff.debuffCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
debuffResolve(af, this);
|
AbilityFactory_Debuff.debuffResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return debuffTriggerAI(af, this, mandatory);
|
return AbilityFactory_Debuff.debuffTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -97,17 +97,17 @@ public final class AbilityFactory_Debuff {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return debuffStackDescription(af, this);
|
return AbilityFactory_Debuff.debuffStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return debuffCanPlayAI(af, this);
|
return AbilityFactory_Debuff.debuffCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
debuffResolve(af, this);
|
AbilityFactory_Debuff.debuffResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -129,22 +129,22 @@ public final class AbilityFactory_Debuff {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return debuffStackDescription(af, this);
|
return AbilityFactory_Debuff.debuffStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
debuffResolve(af, this);
|
AbilityFactory_Debuff.debuffResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return debuffDrawbackAI(af, this);
|
return AbilityFactory_Debuff.debuffDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return debuffTriggerAI(af, this, mandatory);
|
return AbilityFactory_Debuff.debuffTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -161,7 +161,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
private static ArrayList<String> getKeywords(final HashMap<String, String> params) {
|
private static ArrayList<String> getKeywords(final HashMap<String, String> params) {
|
||||||
ArrayList<String> kws = new ArrayList<String>();
|
final ArrayList<String> kws = new ArrayList<String>();
|
||||||
if (params.containsKey("Keywords")) {
|
if (params.containsKey("Keywords")) {
|
||||||
kws.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
kws.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
|
||||||
}
|
}
|
||||||
@@ -180,13 +180,13 @@ public final class AbilityFactory_Debuff {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String debuffStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String debuffStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
ArrayList<String> kws = getKeywords(params);
|
final ArrayList<String> kws = AbilityFactory_Debuff.getKeywords(params);
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -200,9 +200,9 @@ public final class AbilityFactory_Debuff {
|
|||||||
sb.append(host).append(" - ");
|
sb.append(host).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
final Iterator<Card> it = tgtCards.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Card tgtC = it.next();
|
final Card tgtC = it.next();
|
||||||
if (tgtC.isFaceDown()) {
|
if (tgtC.isFaceDown()) {
|
||||||
sb.append("Morph");
|
sb.append("Morph");
|
||||||
} else {
|
} else {
|
||||||
@@ -226,7 +226,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
sb.append(".");
|
sb.append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -247,12 +247,12 @@ public final class AbilityFactory_Debuff {
|
|||||||
*/
|
*/
|
||||||
private static boolean debuffCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean debuffCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// if there is no target and host card isn't in play, don't activate
|
// if there is no target and host card isn't in play, don't activate
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
if (sa.getTarget() == null && !AllZoneUtil.isCardInPlay(source)) {
|
if ((sa.getTarget() == null) && !AllZoneUtil.isCardInPlay(source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until AI is improved
|
// temporarily disabled until AI is improved
|
||||||
if (!CostUtil.checkCreatureSacrificeCost(cost, source)) {
|
if (!CostUtil.checkCreatureSacrificeCost(cost, source)) {
|
||||||
@@ -267,11 +267,11 @@ public final class AbilityFactory_Debuff {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
SpellAbility_Restriction restrict = sa.getRestrictions();
|
final SpellAbility_Restriction restrict = sa.getRestrictions();
|
||||||
|
|
||||||
// Phase Restrictions
|
// Phase Restrictions
|
||||||
if (AllZone.getStack().size() == 0 && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_BEGIN)) {
|
if ((AllZone.getStack().size() == 0) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_BEGIN)) {
|
||||||
// Instant-speed pumps should not be cast outside of combat when the
|
// Instant-speed pumps should not be cast outside of combat when the
|
||||||
// stack is empty
|
// stack is empty
|
||||||
if (!AbilityFactory.isSorcerySpeed(sa)) {
|
if (!AbilityFactory.isSorcerySpeed(sa)) {
|
||||||
@@ -279,20 +279,20 @@ public final class AbilityFactory_Debuff {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int activations = restrict.getNumberTurnActivations();
|
final int activations = restrict.getNumberTurnActivations();
|
||||||
int sacActivations = restrict.getActivationNumberSacrifice();
|
final int sacActivations = restrict.getActivationNumberSacrifice();
|
||||||
// don't risk sacrificing a creature just to pump it
|
// don't risk sacrificing a creature just to pump it
|
||||||
if (sacActivations != -1 && activations >= (sacActivations - 1)) {
|
if ((sacActivations != -1) && (activations >= (sacActivations - 1))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (af.getAbTgt() == null || !af.getAbTgt().doesTarget()) {
|
if ((af.getAbTgt() == null) || !af.getAbTgt().doesTarget()) {
|
||||||
ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
if (cards.size() == 0) {
|
if (cards.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return debuffTgtAI(af, sa, getKeywords(params), false);
|
return AbilityFactory_Debuff.debuffTgtAI(af, sa, AbilityFactory_Debuff.getKeywords(params), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -310,12 +310,12 @@ public final class AbilityFactory_Debuff {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean debuffDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean debuffDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
if (af.getAbTgt() == null || !af.getAbTgt().doesTarget()) {
|
if ((af.getAbTgt() == null) || !af.getAbTgt().doesTarget()) {
|
||||||
// TODO - copied from AF_Pump.pumpDrawbackAI() - what should be
|
// TODO - copied from AF_Pump.pumpDrawbackAI() - what should be
|
||||||
// here?
|
// here?
|
||||||
} else {
|
} else {
|
||||||
return debuffTgtAI(af, sa, getKeywords(params), false);
|
return AbilityFactory_Debuff.debuffTgtAI(af, sa, AbilityFactory_Debuff.getKeywords(params), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -343,9 +343,9 @@ public final class AbilityFactory_Debuff {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
CardList list = getCurseCreatures(af, sa, kws);
|
CardList list = AbilityFactory_Debuff.getCurseCreatures(af, sa, kws);
|
||||||
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
// several uses here:
|
// several uses here:
|
||||||
@@ -356,7 +356,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
// 3a. remove Persist?
|
// 3a. remove Persist?
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return mandatory && debuffMandatoryTarget(af, sa, mandatory);
|
return mandatory && AbilityFactory_Debuff.debuffMandatoryTarget(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||||
@@ -364,9 +364,9 @@ public final class AbilityFactory_Debuff {
|
|||||||
// boolean goodt = false;
|
// boolean goodt = false;
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
if (tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa) || tgt.getNumTargeted() == 0) {
|
if ((tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (tgt.getNumTargeted() == 0)) {
|
||||||
if (mandatory) {
|
if (mandatory) {
|
||||||
return debuffMandatoryTarget(af, sa, mandatory);
|
return AbilityFactory_Debuff.debuffMandatoryTarget(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
@@ -400,12 +400,13 @@ public final class AbilityFactory_Debuff {
|
|||||||
*/
|
*/
|
||||||
private static CardList getCurseCreatures(final AbilityFactory af, final SpellAbility sa,
|
private static CardList getCurseCreatures(final AbilityFactory af, final SpellAbility sa,
|
||||||
final ArrayList<String> kws) {
|
final ArrayList<String> kws) {
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
||||||
list = list.getTargetableCards(hostCard);
|
list = list.getTargetableCards(hostCard);
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return c.hasAnyKeyword(kws); // don't add duplicate negative
|
return c.hasAnyKeyword(kws); // don't add duplicate negative
|
||||||
// keywords
|
// keywords
|
||||||
@@ -431,7 +432,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
*/
|
*/
|
||||||
private static boolean debuffMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean debuffMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||||
@@ -440,13 +441,13 @@ public final class AbilityFactory_Debuff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove anything that's already been targeted
|
// Remove anything that's already been targeted
|
||||||
for (Card c : tgt.getTargetCards()) {
|
for (final Card c : tgt.getTargetCards()) {
|
||||||
list.remove(c);
|
list.remove(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList pref = list.getController(AllZone.getHumanPlayer());
|
final CardList pref = list.getController(AllZone.getHumanPlayer());
|
||||||
CardList forced = list.getController(AllZone.getComputerPlayer());
|
final CardList forced = list.getController(AllZone.getComputerPlayer());
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||||
if (pref.isEmpty()) {
|
if (pref.isEmpty()) {
|
||||||
@@ -510,16 +511,16 @@ public final class AbilityFactory_Debuff {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
ArrayList<String> kws = getKeywords(params);
|
final ArrayList<String> kws = AbilityFactory_Debuff.getKeywords(params);
|
||||||
|
|
||||||
if (sa.getTarget() == null) {
|
if (sa.getTarget() == null) {
|
||||||
if (mandatory) {
|
if (mandatory) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return debuffTgtAI(af, sa, kws, mandatory);
|
return AbilityFactory_Debuff.debuffTgtAI(af, sa, kws, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -536,13 +537,13 @@ public final class AbilityFactory_Debuff {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void debuffResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void debuffResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
ArrayList<String> kws = getKeywords(params);
|
final ArrayList<String> kws = AbilityFactory_Debuff.getKeywords(params);
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -552,7 +553,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
for (final Card tgtC : tgtCards) {
|
for (final Card tgtC : tgtCards) {
|
||||||
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
|
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(host, tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(host, tgtC)) {
|
||||||
for (String kw : kws) {
|
for (final String kw : kws) {
|
||||||
if (tgtC.getIntrinsicKeyword().contains(kw)) {
|
if (tgtC.getIntrinsicKeyword().contains(kw)) {
|
||||||
hadIntrinsic.add(kw);
|
hadIntrinsic.add(kw);
|
||||||
}
|
}
|
||||||
@@ -564,9 +565,10 @@ public final class AbilityFactory_Debuff {
|
|||||||
AllZone.getEndOfTurn().addUntil(new Command() {
|
AllZone.getEndOfTurn().addUntil(new Command() {
|
||||||
private static final long serialVersionUID = 5387486776282932314L;
|
private static final long serialVersionUID = 5387486776282932314L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
||||||
for (String kw : hadIntrinsic) {
|
for (final String kw : hadIntrinsic) {
|
||||||
tgtC.addIntrinsicKeyword(kw);
|
tgtC.addIntrinsicKeyword(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -597,22 +599,22 @@ public final class AbilityFactory_Debuff {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return debuffAllCanPlayAI(af, this);
|
return AbilityFactory_Debuff.debuffAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return debuffAllStackDescription(af, this);
|
return AbilityFactory_Debuff.debuffAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
debuffAllResolve(af, this);
|
AbilityFactory_Debuff.debuffAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return debuffAllTriggerAI(af, this, mandatory);
|
return AbilityFactory_Debuff.debuffAllTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
@@ -631,22 +633,22 @@ public final class AbilityFactory_Debuff {
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellDebuffAll(final AbilityFactory af) {
|
public static SpellAbility createSpellDebuffAll(final AbilityFactory af) {
|
||||||
SpellAbility spDebuffAll = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
final SpellAbility spDebuffAll = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 399707924254248213L;
|
private static final long serialVersionUID = 399707924254248213L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return debuffAllCanPlayAI(af, this);
|
return AbilityFactory_Debuff.debuffAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return debuffAllStackDescription(af, this);
|
return AbilityFactory_Debuff.debuffAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
debuffAllResolve(af, this);
|
AbilityFactory_Debuff.debuffAllResolve(af, this);
|
||||||
}
|
}
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -664,27 +666,27 @@ public final class AbilityFactory_Debuff {
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createDrawbackDebuffAll(final AbilityFactory af) {
|
public static SpellAbility createDrawbackDebuffAll(final AbilityFactory af) {
|
||||||
SpellAbility dbDebuffAll = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
final SpellAbility dbDebuffAll = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 3262199296469706708L;
|
private static final long serialVersionUID = 3262199296469706708L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return debuffAllStackDescription(af, this);
|
return AbilityFactory_Debuff.debuffAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
debuffAllResolve(af, this);
|
AbilityFactory_Debuff.debuffAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return debuffAllChkDrawbackAI(af, this);
|
return AbilityFactory_Debuff.debuffAllChkDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return debuffAllTriggerAI(af, this, mandatory);
|
return AbilityFactory_Debuff.debuffAllTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -704,12 +706,12 @@ public final class AbilityFactory_Debuff {
|
|||||||
*/
|
*/
|
||||||
private static boolean debuffAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean debuffAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
String valid = "";
|
String valid = "";
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
// final Card source = sa.getSourceCard();
|
// final Card source = sa.getSourceCard();
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to
|
final boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn()); // to
|
||||||
// prevent
|
// prevent
|
||||||
// runaway
|
// runaway
|
||||||
// activations
|
// activations
|
||||||
@@ -727,6 +729,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
|
|
||||||
// only count creatures that can attack
|
// only count creatures that can attack
|
||||||
human = human.filter(new CardListFilter() {
|
human = human.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return CombatUtil.canAttack(c);
|
return CombatUtil.canAttack(c);
|
||||||
}
|
}
|
||||||
@@ -755,9 +758,9 @@ public final class AbilityFactory_Debuff {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void debuffAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void debuffAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
ArrayList<String> kws = getKeywords(params);
|
final ArrayList<String> kws = AbilityFactory_Debuff.getKeywords(params);
|
||||||
String valid = "";
|
String valid = "";
|
||||||
|
|
||||||
if (params.containsKey("ValidCards")) {
|
if (params.containsKey("ValidCards")) {
|
||||||
@@ -770,7 +773,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
for (final Card tgtC : list) {
|
for (final Card tgtC : list) {
|
||||||
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
|
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(hostCard, tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(hostCard, tgtC)) {
|
||||||
for (String kw : kws) {
|
for (final String kw : kws) {
|
||||||
if (tgtC.getIntrinsicKeyword().contains(kw)) {
|
if (tgtC.getIntrinsicKeyword().contains(kw)) {
|
||||||
hadIntrinsic.add(kw);
|
hadIntrinsic.add(kw);
|
||||||
}
|
}
|
||||||
@@ -782,9 +785,10 @@ public final class AbilityFactory_Debuff {
|
|||||||
AllZone.getEndOfTurn().addUntil(new Command() {
|
AllZone.getEndOfTurn().addUntil(new Command() {
|
||||||
private static final long serialVersionUID = 7486231071095628674L;
|
private static final long serialVersionUID = 7486231071095628674L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
||||||
for (String kw : hadIntrinsic) {
|
for (final String kw : hadIntrinsic) {
|
||||||
tgtC.addIntrinsicKeyword(kw);
|
tgtC.addIntrinsicKeyword(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -842,8 +846,8 @@ public final class AbilityFactory_Debuff {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String debuffAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String debuffAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
String desc = "";
|
String desc = "";
|
||||||
if (params.containsKey("SpellDescription")) {
|
if (params.containsKey("SpellDescription")) {
|
||||||
@@ -860,7 +864,7 @@ public final class AbilityFactory_Debuff {
|
|||||||
|
|
||||||
sb.append(desc);
|
sb.append(desc);
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import forge.card.trigger.TriggerHandler;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AbilityFactory_DelayedTrigger {
|
public class AbilityFactory_DelayedTrigger {
|
||||||
/** Constant <code>tempCreator</code> */
|
/** Constant <code>tempCreator</code>. */
|
||||||
private static AbilityFactory tempCreator = new AbilityFactory();
|
private static AbilityFactory tempCreator = new AbilityFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,22 +37,22 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return delTrigCanPlayAI(af, this);
|
return AbilityFactory_DelayedTrigger.delTrigCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(af, this);
|
AbilityFactory_DelayedTrigger.doResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return delTrigStackDescription(af, this);
|
return AbilityFactory_DelayedTrigger.delTrigStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return doTriggerAI(af, this, mandatory);
|
return AbilityFactory_DelayedTrigger.doTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return ability;
|
return ability;
|
||||||
@@ -74,17 +74,17 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return delTrigCanPlayAI(af, this);
|
return AbilityFactory_DelayedTrigger.delTrigCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(af, this);
|
AbilityFactory_DelayedTrigger.doResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return delTrigStackDescription(af, this);
|
return AbilityFactory_DelayedTrigger.delTrigStackDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return spell;
|
return spell;
|
||||||
@@ -95,27 +95,27 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
* getDrawback.
|
* getDrawback.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.Ability_Sub} object.
|
* @return a {@link forge.card.spellability.Ability_Sub} object.
|
||||||
*/
|
*/
|
||||||
public static Ability_Sub getDrawback(final AbilityFactory AF) {
|
public static Ability_Sub getDrawback(final AbilityFactory abilityFactory) {
|
||||||
final Ability_Sub drawback = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final Ability_Sub drawback = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 6192972525033429820L;
|
private static final long serialVersionUID = 6192972525033429820L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return doChkAI_Drawback(AF, this);
|
return AbilityFactory_DelayedTrigger.doChkDrawbackAI(abilityFactory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return doTriggerAI(AF, this, mandatory);
|
return AbilityFactory_DelayedTrigger.doTriggerAI(abilityFactory, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(AF, this);
|
AbilityFactory_DelayedTrigger.doResolve(abilityFactory, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,16 +127,17 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
* doChkAI_Drawback.
|
* doChkAI_Drawback.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param SA
|
* @param spellAbility
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean doChkAI_Drawback(final AbilityFactory AF, final SpellAbility SA) {
|
private static boolean doChkDrawbackAI(final AbilityFactory abilityFactory, final SpellAbility spellAbility) {
|
||||||
HashMap<String, String> params = AF.getMapParams();
|
final HashMap<String, String> params = abilityFactory.getMapParams();
|
||||||
String svarName = params.get("Execute");
|
final String svarName = params.get("Execute");
|
||||||
SpellAbility trigsa = tempCreator.getAbility(AF.getHostCard().getSVar(svarName), AF.getHostCard());
|
final SpellAbility trigsa = AbilityFactory_DelayedTrigger.tempCreator.getAbility(
|
||||||
|
abilityFactory.getHostCard().getSVar(svarName), abilityFactory.getHostCard());
|
||||||
|
|
||||||
if (trigsa instanceof Ability_Sub) {
|
if (trigsa instanceof Ability_Sub) {
|
||||||
return ((Ability_Sub) trigsa).chkAIDrawback();
|
return ((Ability_Sub) trigsa).chkAIDrawback();
|
||||||
@@ -150,16 +151,17 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
* doTriggerAI.
|
* doTriggerAI.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param SA
|
* @param spellAbility
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean doTriggerAI(final AbilityFactory AF, final SpellAbility SA, final boolean mandatory) {
|
private static boolean doTriggerAI(final AbilityFactory abilityFactory, final SpellAbility spellAbility, final boolean mandatory) {
|
||||||
HashMap<String, String> params = AF.getMapParams();
|
final HashMap<String, String> params = abilityFactory.getMapParams();
|
||||||
String svarName = params.get("Execute");
|
final String svarName = params.get("Execute");
|
||||||
SpellAbility trigsa = tempCreator.getAbility(AF.getHostCard().getSVar(svarName), AF.getHostCard());
|
final SpellAbility trigsa = AbilityFactory_DelayedTrigger.tempCreator.getAbility(
|
||||||
|
abilityFactory.getHostCard().getSVar(svarName), abilityFactory.getHostCard());
|
||||||
|
|
||||||
if (!params.containsKey("OptionalDecider")) {
|
if (!params.containsKey("OptionalDecider")) {
|
||||||
return trigsa.doTrigger(true);
|
return trigsa.doTrigger(true);
|
||||||
@@ -180,9 +182,10 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean delTrigCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean delTrigCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
String svarName = params.get("Execute");
|
final String svarName = params.get("Execute");
|
||||||
SpellAbility trigsa = tempCreator.getAbility(af.getHostCard().getSVar(svarName), af.getHostCard());
|
final SpellAbility trigsa = AbilityFactory_DelayedTrigger.tempCreator.getAbility(
|
||||||
|
af.getHostCard().getSVar(svarName), af.getHostCard());
|
||||||
|
|
||||||
return trigsa.canPlayAI();
|
return trigsa.canPlayAI();
|
||||||
}
|
}
|
||||||
@@ -198,9 +201,9 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static String delTrigStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String delTrigStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> mapParams = af.getMapParams();
|
final HashMap<String, String> mapParams = af.getMapParams();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -214,7 +217,7 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
sb.append(mapParams.get("TriggerDescription"));
|
sb.append(mapParams.get("TriggerDescription"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -228,13 +231,13 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
* doResolve.
|
* doResolve.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param SA
|
* @param spellAbility
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void doResolve(final AbilityFactory AF, final SpellAbility SA) {
|
private static void doResolve(final AbilityFactory abilityFactory, final SpellAbility spellAbility) {
|
||||||
HashMap<String, String> mapParams = AF.getMapParams();
|
final HashMap<String, String> mapParams = abilityFactory.getMapParams();
|
||||||
|
|
||||||
if (mapParams.containsKey("Cost")) {
|
if (mapParams.containsKey("Cost")) {
|
||||||
mapParams.remove("Cost");
|
mapParams.remove("Cost");
|
||||||
@@ -245,7 +248,7 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
mapParams.remove("SpellDescription");
|
mapParams.remove("SpellDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
Trigger delTrig = TriggerHandler.parseTrigger(mapParams, AF.getHostCard(), true);
|
final Trigger delTrig = TriggerHandler.parseTrigger(mapParams, abilityFactory.getHostCard(), true);
|
||||||
|
|
||||||
AllZone.getTriggerHandler().registerDelayedTrigger(delTrig);
|
AllZone.getTriggerHandler().registerDelayedTrigger(delTrig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,22 +53,22 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return destroyStackDescription(af, this);
|
return AbilityFactory_Destroy.destroyStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return destroyCanPlayAI(af, this);
|
return AbilityFactory_Destroy.destroyCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
destroyResolve(af, this);
|
AbilityFactory_Destroy.destroyResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return destroyDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_Destroy.destroyDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -90,17 +90,17 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return destroyStackDescription(af, this);
|
return AbilityFactory_Destroy.destroyStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return destroyCanPlayAI(af, this);
|
return AbilityFactory_Destroy.destroyCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
destroyResolve(af, this);
|
AbilityFactory_Destroy.destroyResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -122,7 +122,7 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return destroyStackDescription(af, this);
|
return AbilityFactory_Destroy.destroyStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,12 +132,12 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
destroyResolve(af, this);
|
AbilityFactory_Destroy.destroyResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return destroyDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_Destroy.destroyDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return dbDestroy;
|
return dbDestroy;
|
||||||
@@ -157,11 +157,11 @@ public class AbilityFactory_Destroy {
|
|||||||
private static boolean destroyCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean destroyCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI needs to be expanded, since this function can be pretty complex
|
// AI needs to be expanded, since this function can be pretty complex
|
||||||
// based on what the expected targets could be
|
// based on what the expected targets could be
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
Cost abCost = sa.getPayCosts();
|
final Cost abCost = sa.getPayCosts();
|
||||||
Target abTgt = sa.getTarget();
|
final Target abTgt = sa.getTarget();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final boolean noRegen = params.containsKey("NoRegen");
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
|
|
||||||
CardList list;
|
CardList list;
|
||||||
@@ -178,8 +178,9 @@ public class AbilityFactory_Destroy {
|
|||||||
// TODO filter out things that could regenerate in response?
|
// TODO filter out things that could regenerate in response?
|
||||||
// might be tougher?
|
// might be tougher?
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return (c.getShield() == 0 && !ComputerUtil.canRegenerate(c));
|
return ((c.getShield() == 0) && !ComputerUtil.canRegenerate(c));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -213,8 +214,8 @@ public class AbilityFactory_Destroy {
|
|||||||
// target loop
|
// target loop
|
||||||
while (abTgt.getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
while (abTgt.getNumTargeted() < abTgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
if (abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)
|
if ((abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||||
|| abTgt.getNumTargeted() == 0) {
|
|| (abTgt.getNumTargeted() == 0)) {
|
||||||
abTgt.resetTargets();
|
abTgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -238,8 +239,8 @@ public class AbilityFactory_Destroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (choice == null) { // can't find anything left
|
if (choice == null) { // can't find anything left
|
||||||
if (abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa)
|
if ((abTgt.getNumTargeted() < abTgt.getMinTargets(sa.getSourceCard(), sa))
|
||||||
|| abTgt.getNumTargeted() == 0) {
|
|| (abTgt.getNumTargeted() == 0)) {
|
||||||
abTgt.resetTargets();
|
abTgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -255,7 +256,7 @@ public class AbilityFactory_Destroy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -281,9 +282,9 @@ public class AbilityFactory_Destroy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final boolean noRegen = params.containsKey("NoRegen");
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
|
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
@@ -292,7 +293,7 @@ public class AbilityFactory_Destroy {
|
|||||||
list = list.getTargetableCards(source);
|
list = list.getTargetableCards(source);
|
||||||
list = list.getValidCards(tgt.getValidTgts(), source.getController(), source);
|
list = list.getValidCards(tgt.getValidTgts(), source.getController(), source);
|
||||||
|
|
||||||
if (list.size() == 0 || list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
if ((list.size() == 0) || (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,19 +308,21 @@ public class AbilityFactory_Destroy {
|
|||||||
// TODO filter out things that could regenerate in response?
|
// TODO filter out things that could regenerate in response?
|
||||||
// might be tougher?
|
// might be tougher?
|
||||||
preferred = preferred.filter(new CardListFilter() {
|
preferred = preferred.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return c.getShield() == 0;
|
return c.getShield() == 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card c : preferred) {
|
for (final Card c : preferred) {
|
||||||
list.remove(c);
|
list.remove(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||||
if (preferred.size() == 0) {
|
if (preferred.size() == 0) {
|
||||||
if (tgt.getNumTargeted() == 0 || tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
if ((tgt.getNumTargeted() == 0)
|
||||||
|
|| (tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa))) {
|
||||||
if (!mandatory) {
|
if (!mandatory) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
@@ -367,7 +370,7 @@ public class AbilityFactory_Destroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
return subAb.doTrigger(mandatory);
|
return subAb.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -387,19 +390,19 @@ public class AbilityFactory_Destroy {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String destroyStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String destroyStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final boolean noRegen = params.containsKey("NoRegen");
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
String conditionDesc = params.get("ConditionDescription");
|
final String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -414,9 +417,9 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
sb.append("Destroy ");
|
sb.append("Destroy ");
|
||||||
|
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
final Iterator<Card> it = tgtCards.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Card tgtC = it.next();
|
final Card tgtC = it.next();
|
||||||
if (tgtC.isFaceDown()) {
|
if (tgtC.isFaceDown()) {
|
||||||
sb.append("Morph ").append("(").append(tgtC.getUniqueNumber()).append(")");
|
sb.append("Morph ").append("(").append(tgtC.getUniqueNumber()).append(")");
|
||||||
} else {
|
} else {
|
||||||
@@ -449,7 +452,7 @@ public class AbilityFactory_Destroy {
|
|||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -468,15 +471,15 @@ public class AbilityFactory_Destroy {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void destroyResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void destroyResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
final boolean noRegen = params.containsKey("NoRegen");
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
final ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -484,13 +487,14 @@ public class AbilityFactory_Destroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("Radiance")) {
|
if (params.containsKey("Radiance")) {
|
||||||
for (Card c : CardUtil.getRadiance(af.getHostCard(), tgtCards.get(0), params.get("ValidTgts").split(","))) {
|
for (final Card c : CardUtil.getRadiance(af.getHostCard(), tgtCards.get(0),
|
||||||
|
params.get("ValidTgts").split(","))) {
|
||||||
untargetedCards.add(c);
|
untargetedCards.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card tgtC : tgtCards) {
|
for (final Card tgtC : tgtCards) {
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC) && (tgt == null || CardFactoryUtil.canTarget(card, tgtC))) {
|
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || CardFactoryUtil.canTarget(card, tgtC))) {
|
||||||
if (noRegen) {
|
if (noRegen) {
|
||||||
AllZone.getGameAction().destroyNoRegeneration(tgtC);
|
AllZone.getGameAction().destroyNoRegeneration(tgtC);
|
||||||
} else {
|
} else {
|
||||||
@@ -499,7 +503,7 @@ public class AbilityFactory_Destroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card unTgtC : untargetedCards) {
|
for (final Card unTgtC : untargetedCards) {
|
||||||
if (AllZoneUtil.isCardInPlay(unTgtC)) {
|
if (AllZoneUtil.isCardInPlay(unTgtC)) {
|
||||||
if (noRegen) {
|
if (noRegen) {
|
||||||
AllZone.getGameAction().destroyNoRegeneration(unTgtC);
|
AllZone.getGameAction().destroyNoRegeneration(unTgtC);
|
||||||
@@ -529,26 +533,26 @@ public class AbilityFactory_Destroy {
|
|||||||
private static final long serialVersionUID = -1376444173137861437L;
|
private static final long serialVersionUID = -1376444173137861437L;
|
||||||
|
|
||||||
private final HashMap<String, String> params = af.getMapParams();
|
private final HashMap<String, String> params = af.getMapParams();
|
||||||
private final boolean noRegen = params.containsKey("NoRegen");
|
private final boolean noRegen = this.params.containsKey("NoRegen");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return destroyAllStackDescription(af, this, noRegen);
|
return AbilityFactory_Destroy.destroyAllStackDescription(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return destroyAllCanPlayAI(af, this, noRegen);
|
return AbilityFactory_Destroy.destroyAllCanPlayAI(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
destroyAllResolve(af, this, noRegen);
|
AbilityFactory_Destroy.destroyAllResolve(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return destroyAllCanPlayAI(af, this, noRegen);
|
return AbilityFactory_Destroy.destroyAllCanPlayAI(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -569,25 +573,25 @@ public class AbilityFactory_Destroy {
|
|||||||
private static final long serialVersionUID = -3712659336576469102L;
|
private static final long serialVersionUID = -3712659336576469102L;
|
||||||
|
|
||||||
private final HashMap<String, String> params = af.getMapParams();
|
private final HashMap<String, String> params = af.getMapParams();
|
||||||
private final boolean noRegen = params.containsKey("NoRegen");
|
private final boolean noRegen = this.params.containsKey("NoRegen");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
if (params.containsKey("SpellDescription")) {
|
if (this.params.containsKey("SpellDescription")) {
|
||||||
return af.getHostCard().getName() + " - " + params.get("SpellDescription");
|
return af.getHostCard().getName() + " - " + this.params.get("SpellDescription");
|
||||||
} else {
|
} else {
|
||||||
return destroyAllStackDescription(af, this, noRegen);
|
return AbilityFactory_Destroy.destroyAllStackDescription(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return destroyAllCanPlayAI(af, this, noRegen);
|
return AbilityFactory_Destroy.destroyAllCanPlayAI(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
destroyAllResolve(af, this, noRegen);
|
AbilityFactory_Destroy.destroyAllResolve(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -608,20 +612,20 @@ public class AbilityFactory_Destroy {
|
|||||||
private static final long serialVersionUID = -242160421677518351L;
|
private static final long serialVersionUID = -242160421677518351L;
|
||||||
|
|
||||||
private final HashMap<String, String> params = af.getMapParams();
|
private final HashMap<String, String> params = af.getMapParams();
|
||||||
private final boolean noRegen = params.containsKey("NoRegen");
|
private final boolean noRegen = this.params.containsKey("NoRegen");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
if (params.containsKey("SpellDescription")) {
|
if (this.params.containsKey("SpellDescription")) {
|
||||||
return af.getHostCard().getName() + " - " + params.get("SpellDescription");
|
return af.getHostCard().getName() + " - " + this.params.get("SpellDescription");
|
||||||
} else {
|
} else {
|
||||||
return destroyAllStackDescription(af, this, noRegen);
|
return AbilityFactory_Destroy.destroyAllStackDescription(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
destroyAllResolve(af, this, noRegen);
|
AbilityFactory_Destroy.destroyAllResolve(af, this, this.noRegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -652,21 +656,21 @@ public class AbilityFactory_Destroy {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String destroyAllStackDescription(final AbilityFactory af,
|
private static String destroyAllStackDescription(final AbilityFactory af, final SpellAbility sa,
|
||||||
final SpellAbility sa, final boolean noRegen) {
|
final boolean noRegen) {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
String name = af.getHostCard().getName();
|
final String name = af.getHostCard().getName();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
String conditionDesc = params.get("ConditionDescription");
|
final String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -680,7 +684,7 @@ public class AbilityFactory_Destroy {
|
|||||||
sb.append(" They can't be regenerated");
|
sb.append(" They can't be regenerated");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -704,8 +708,8 @@ public class AbilityFactory_Destroy {
|
|||||||
private static boolean destroyAllCanPlayAI(final AbilityFactory af, final SpellAbility sa, final boolean noRegen) {
|
private static boolean destroyAllCanPlayAI(final AbilityFactory af, final SpellAbility sa, final boolean noRegen) {
|
||||||
// AI needs to be expanded, since this function can be pretty complex
|
// AI needs to be expanded, since this function can be pretty complex
|
||||||
// based on what the expected targets could be
|
// based on what the expected targets could be
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
Cost abCost = sa.getPayCosts();
|
final Cost abCost = sa.getPayCosts();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
String valid = "";
|
String valid = "";
|
||||||
@@ -716,7 +720,7 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
if (valid.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
if (valid.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
int xPay = ComputerUtil.determineLeftoverMana(sa);
|
final int xPay = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(xPay));
|
source.setSVar("PayX", Integer.toString(xPay));
|
||||||
valid = valid.replace("X", Integer.toString(xPay));
|
valid = valid.replace("X", Integer.toString(xPay));
|
||||||
}
|
}
|
||||||
@@ -724,7 +728,7 @@ public class AbilityFactory_Destroy {
|
|||||||
CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
||||||
CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
|
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
@@ -751,25 +755,25 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
// if only creatures are affected evaluate both lists and pass only if
|
// if only creatures are affected evaluate both lists and pass only if
|
||||||
// human creatures are more valuable
|
// human creatures are more valuable
|
||||||
if (humanlist.getNotType("Creature").size() == 0 && computerlist.getNotType("Creature").size() == 0) {
|
if ((humanlist.getNotType("Creature").size() == 0) && (computerlist.getNotType("Creature").size() == 0)) {
|
||||||
if (CardFactoryUtil.evaluateCreatureList(computerlist) + 200 >= CardFactoryUtil
|
if ((CardFactoryUtil.evaluateCreatureList(computerlist) + 200) >= CardFactoryUtil
|
||||||
.evaluateCreatureList(humanlist)) {
|
.evaluateCreatureList(humanlist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // only lands involved
|
} // only lands involved
|
||||||
else if (humanlist.getNotType("Land").size() == 0 && computerlist.getNotType("Land").size() == 0) {
|
else if ((humanlist.getNotType("Land").size() == 0) && (computerlist.getNotType("Land").size() == 0)) {
|
||||||
if (CardFactoryUtil.evaluatePermanentList(computerlist) + 1 >= CardFactoryUtil
|
if ((CardFactoryUtil.evaluatePermanentList(computerlist) + 1) >= CardFactoryUtil
|
||||||
.evaluatePermanentList(humanlist)) {
|
.evaluatePermanentList(humanlist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // otherwise evaluate both lists by CMC and pass only if human
|
} // otherwise evaluate both lists by CMC and pass only if human
|
||||||
// permanents are more valuable
|
// permanents are more valuable
|
||||||
else if (CardFactoryUtil.evaluatePermanentList(computerlist) + 3 >= CardFactoryUtil
|
else if ((CardFactoryUtil.evaluatePermanentList(computerlist) + 3) >= CardFactoryUtil
|
||||||
.evaluatePermanentList(humanlist)) {
|
.evaluatePermanentList(humanlist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -790,11 +794,11 @@ public class AbilityFactory_Destroy {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
private static void destroyAllResolve(final AbilityFactory af, final SpellAbility sa, final boolean noRegen) {
|
private static void destroyAllResolve(final AbilityFactory af, final SpellAbility sa, final boolean noRegen) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
Player targetPlayer = null;
|
Player targetPlayer = null;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
targetPlayer = tgt.getTargetPlayers().get(0);
|
targetPlayer = tgt.getTargetPlayers().get(0);
|
||||||
@@ -821,7 +825,7 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
list = AbilityFactory.filterListByType(list, valid, sa);
|
list = AbilityFactory.filterListByType(list, valid, sa);
|
||||||
|
|
||||||
boolean remDestroyed = params.containsKey("RememberDestroyed");
|
final boolean remDestroyed = params.containsKey("RememberDestroyed");
|
||||||
if (remDestroyed) {
|
if (remDestroyed) {
|
||||||
card.clearRemembered();
|
card.clearRemembered();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import forge.Card;
|
|||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.ComputerUtil;
|
import forge.ComputerUtil;
|
||||||
|
import forge.Constant.Zone;
|
||||||
import forge.MyRandom;
|
import forge.MyRandom;
|
||||||
import forge.Player;
|
import forge.Player;
|
||||||
import forge.Constant.Zone;
|
|
||||||
import forge.card.spellability.Ability_Activated;
|
import forge.card.spellability.Ability_Activated;
|
||||||
import forge.card.spellability.Ability_Sub;
|
import forge.card.spellability.Ability_Sub;
|
||||||
import forge.card.spellability.Spell;
|
import forge.card.spellability.Spell;
|
||||||
@@ -34,36 +34,37 @@ public class AbilityFactory_Effect {
|
|||||||
* createAbilityEffect.
|
* createAbilityEffect.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createAbilityEffect(final AbilityFactory AF) {
|
public static SpellAbility createAbilityEffect(final AbilityFactory abilityFactory) {
|
||||||
|
|
||||||
final SpellAbility abEffect = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility abEffect = new Ability_Activated(abilityFactory.getHostCard(), abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 8869422603616247307L;
|
private static final long serialVersionUID = 8869422603616247307L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return effectStackDescription(af, this);
|
return AbilityFactory_Effect.effectStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return effectCanPlayAI(af, this);
|
return AbilityFactory_Effect.effectCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
effectResolve(af, this);
|
AbilityFactory_Effect.effectResolve(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return effectDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_Effect.effectDoTriggerAI(this.af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -75,30 +76,31 @@ public class AbilityFactory_Effect {
|
|||||||
* createSpellEffect.
|
* createSpellEffect.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellEffect(final AbilityFactory AF) {
|
public static SpellAbility createSpellEffect(final AbilityFactory abilityFactory) {
|
||||||
final SpellAbility spEffect = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spEffect = new Spell(abilityFactory.getHostCard(), abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 6631124959690157874L;
|
private static final long serialVersionUID = 6631124959690157874L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return effectStackDescription(af, this);
|
return AbilityFactory_Effect.effectStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return effectCanPlayAI(af, this);
|
return AbilityFactory_Effect.effectCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
effectResolve(af, this);
|
AbilityFactory_Effect.effectResolve(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -110,30 +112,31 @@ public class AbilityFactory_Effect {
|
|||||||
* createDrawbackEffect.
|
* createDrawbackEffect.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createDrawbackEffect(final AbilityFactory AF) {
|
public static SpellAbility createDrawbackEffect(final AbilityFactory abilityFactory) {
|
||||||
final SpellAbility dbEffect = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbEffect = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 6631124959690157874L;
|
private static final long serialVersionUID = 6631124959690157874L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return effectStackDescription(af, this);
|
return AbilityFactory_Effect.effectStackDescription(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return effectCanPlayAI(af, this);
|
return AbilityFactory_Effect.effectCanPlayAI(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
effectResolve(af, this);
|
AbilityFactory_Effect.effectResolve(this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,7 +146,7 @@ public class AbilityFactory_Effect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return effectDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_Effect.effectDoTriggerAI(this.af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -162,7 +165,7 @@ public class AbilityFactory_Effect {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String effectStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
public static String effectStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -172,7 +175,7 @@ public class AbilityFactory_Effect {
|
|||||||
|
|
||||||
sb.append(sa.getDescription());
|
sb.append(sa.getDescription());
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -192,23 +195,23 @@ public class AbilityFactory_Effect {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean effectCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
public static boolean effectCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
String stackable = params.get("Stackable");
|
final String stackable = params.get("Stackable");
|
||||||
|
|
||||||
if (stackable != null && stackable.equals("False")) {
|
if ((stackable != null) && stackable.equals("False")) {
|
||||||
String name = params.get("Name");
|
String name = params.get("Name");
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = sa.getSourceCard().getName() + "'s Effect";
|
name = sa.getSourceCard().getName() + "'s Effect";
|
||||||
}
|
}
|
||||||
CardList list = sa.getActivatingPlayer().getCardsIn(Zone.Battlefield, name);
|
final CardList list = sa.getActivatingPlayer().getCardsIn(Zone.Battlefield, name);
|
||||||
if (list.size() != 0) {
|
if (list.size() != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
if (tgt.canOnlyTgtOpponent()) {
|
if (tgt.canOnlyTgtOpponent()) {
|
||||||
@@ -244,7 +247,7 @@ public class AbilityFactory_Effect {
|
|||||||
// TODO: Add targeting effects
|
// TODO: Add targeting effects
|
||||||
|
|
||||||
// check SubAbilities DoTrigger?
|
// check SubAbilities DoTrigger?
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
return abSub.doTrigger(mandatory);
|
return abSub.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -263,8 +266,8 @@ public class AbilityFactory_Effect {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static void effectResolve(final AbilityFactory af, final SpellAbility sa) {
|
public static void effectResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
String[] effectAbilities = null;
|
String[] effectAbilities = null;
|
||||||
String[] effectTriggers = null;
|
String[] effectTriggers = null;
|
||||||
@@ -308,8 +311,8 @@ public class AbilityFactory_Effect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player controller = sa.getActivatingPlayer();
|
final Player controller = sa.getActivatingPlayer();
|
||||||
Card eff = new Card();
|
final Card eff = new Card();
|
||||||
eff.setName(name);
|
eff.setName(name);
|
||||||
eff.addType("Effect"); // Or Emblem
|
eff.addType("Effect"); // Or Emblem
|
||||||
eff.setToken(true); // Set token to true, so when leaving play it gets
|
eff.setToken(true); // Set token to true, so when leaving play it gets
|
||||||
@@ -327,50 +330,51 @@ public class AbilityFactory_Effect {
|
|||||||
// Abilities, triggers and SVars work the same as they do for Token
|
// Abilities, triggers and SVars work the same as they do for Token
|
||||||
// Grant abilities
|
// Grant abilities
|
||||||
if (effectAbilities != null) {
|
if (effectAbilities != null) {
|
||||||
for (String s : effectAbilities) {
|
for (final String s : effectAbilities) {
|
||||||
AbilityFactory abFactory = new AbilityFactory();
|
final AbilityFactory abFactory = new AbilityFactory();
|
||||||
String actualAbility = af.getHostCard().getSVar(s);
|
final String actualAbility = af.getHostCard().getSVar(s);
|
||||||
|
|
||||||
SpellAbility grantedAbility = abFactory.getAbility(actualAbility, eff);
|
final SpellAbility grantedAbility = abFactory.getAbility(actualAbility, eff);
|
||||||
eff.addSpellAbility(grantedAbility);
|
eff.addSpellAbility(grantedAbility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant triggers
|
// Grant triggers
|
||||||
if (effectTriggers != null) {
|
if (effectTriggers != null) {
|
||||||
for (String s : effectTriggers) {
|
for (final String s : effectTriggers) {
|
||||||
String actualTrigger = af.getHostCard().getSVar(s);
|
final String actualTrigger = af.getHostCard().getSVar(s);
|
||||||
|
|
||||||
Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, eff, true);
|
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, eff, true);
|
||||||
eff.addTrigger(parsedTrigger);
|
eff.addTrigger(parsedTrigger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant static abilities
|
// Grant static abilities
|
||||||
if (effectStaticAbilities != null) {
|
if (effectStaticAbilities != null) {
|
||||||
for (String s : effectStaticAbilities)
|
for (final String s : effectStaticAbilities) {
|
||||||
eff.addStaticAbility(af.getHostCard().getSVar(s));
|
eff.addStaticAbility(af.getHostCard().getSVar(s));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Grant SVars
|
// Grant SVars
|
||||||
if (effectSVars != null) {
|
if (effectSVars != null) {
|
||||||
for (String s : effectSVars) {
|
for (final String s : effectSVars) {
|
||||||
String actualSVar = af.getHostCard().getSVar(s);
|
final String actualSVar = af.getHostCard().getSVar(s);
|
||||||
eff.setSVar(s, actualSVar);
|
eff.setSVar(s, actualSVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant Keywords
|
// Grant Keywords
|
||||||
if (effectKeywords != null) {
|
if (effectKeywords != null) {
|
||||||
for (String s : effectKeywords) {
|
for (final String s : effectKeywords) {
|
||||||
String actualKeyword = af.getHostCard().getSVar(s);
|
final String actualKeyword = af.getHostCard().getSVar(s);
|
||||||
eff.addIntrinsicKeyword(actualKeyword);
|
eff.addIntrinsicKeyword(actualKeyword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Remembered
|
// Set Remembered
|
||||||
if (effectRemembered != null) {
|
if (effectRemembered != null) {
|
||||||
for (Card c : AbilityFactory.getDefinedCards(card, effectRemembered, sa)) {
|
for (final Card c : AbilityFactory.getDefinedCards(card, effectRemembered, sa)) {
|
||||||
eff.addRemembered(c);
|
eff.addRemembered(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,17 +385,18 @@ public class AbilityFactory_Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Duration
|
// Duration
|
||||||
String duration = params.get("Duration");
|
final String duration = params.get("Duration");
|
||||||
if (duration == null || !duration.equals("Permanent")) {
|
if ((duration == null) || !duration.equals("Permanent")) {
|
||||||
final Command endEffect = new Command() {
|
final Command endEffect = new Command() {
|
||||||
private static final long serialVersionUID = -5861759814760561373L;
|
private static final long serialVersionUID = -5861759814760561373L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
AllZone.getGameAction().exile(e);
|
AllZone.getGameAction().exile(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (duration == null || duration.equals("EndOfTurn")) {
|
if ((duration == null) || duration.equals("EndOfTurn")) {
|
||||||
AllZone.getEndOfTurn().addUntil(endEffect);
|
AllZone.getEndOfTurn().addUntil(endEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,21 +49,22 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return winsGameStackDescription(af, this);
|
return AbilityFactory_EndGameCondition.winsGameStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return winsGameCanPlayAI(af, this);
|
return AbilityFactory_EndGameCondition.winsGameCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
winsGameResolve(af, this);
|
AbilityFactory_EndGameCondition.winsGameResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return winsGameDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_EndGameCondition.winsGameDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -87,21 +88,22 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return winsGameStackDescription(af, this);
|
return AbilityFactory_EndGameCondition.winsGameStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
// if X depends on abCost, the AI needs to choose which card he
|
// if X depends on abCost, the AI needs to choose which card he
|
||||||
// would sacrifice first
|
// would sacrifice first
|
||||||
// then call xCount with that card to properly calculate the
|
// then call xCount with that card to properly calculate the
|
||||||
// amount
|
// amount
|
||||||
// Or choosing how many to sacrifice
|
// Or choosing how many to sacrifice
|
||||||
return winsGameCanPlayAI(af, this);
|
return AbilityFactory_EndGameCondition.winsGameCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
winsGameResolve(af, this);
|
AbilityFactory_EndGameCondition.winsGameResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -125,21 +127,22 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return winsGameStackDescription(af, this);
|
return AbilityFactory_EndGameCondition.winsGameStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
// if X depends on abCost, the AI needs to choose which card he
|
// if X depends on abCost, the AI needs to choose which card he
|
||||||
// would sacrifice first
|
// would sacrifice first
|
||||||
// then call xCount with that card to properly calculate the
|
// then call xCount with that card to properly calculate the
|
||||||
// amount
|
// amount
|
||||||
// Or choosing how many to sacrifice
|
// Or choosing how many to sacrifice
|
||||||
return winsGameCanPlayAI(af, this);
|
return AbilityFactory_EndGameCondition.winsGameCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
winsGameResolve(af, this);
|
AbilityFactory_EndGameCondition.winsGameResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -149,7 +152,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return winsGameDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_EndGameCondition.winsGameDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -168,7 +171,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String winsGameStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
public static String winsGameStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||||
@@ -179,7 +182,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
// Let the spell description also be the stack description
|
// Let the spell description also be the stack description
|
||||||
sb.append(sa.getDescription());
|
sb.append(sa.getDescription());
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -233,7 +236,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
|
|
||||||
// WinGame abilities usually don't have subAbilities but for
|
// WinGame abilities usually don't have subAbilities but for
|
||||||
// consistency...
|
// consistency...
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
return abSub.doTrigger(mandatory);
|
return abSub.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -253,11 +256,11 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
*/
|
*/
|
||||||
public static void winsGameResolve(final AbilityFactory af, final SpellAbility sa) {
|
public static void winsGameResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
ArrayList<Player> players = AbilityFactory.getDefinedPlayers(card, af.getMapParams().get("Defined"), sa);
|
final ArrayList<Player> players = AbilityFactory.getDefinedPlayers(card, af.getMapParams().get("Defined"), sa);
|
||||||
|
|
||||||
for (Player p : players) {
|
for (final Player p : players) {
|
||||||
p.altWinBySpellEffect(card.getName());
|
p.altWinBySpellEffect(card.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,21 +288,22 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return losesGameStackDescription(af, this);
|
return AbilityFactory_EndGameCondition.losesGameStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return losesGameCanPlayAI(af, this);
|
return AbilityFactory_EndGameCondition.losesGameCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
losesGameResolve(af, this);
|
AbilityFactory_EndGameCondition.losesGameResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return losesGameDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_EndGameCondition.losesGameDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -323,21 +327,22 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return losesGameStackDescription(af, this);
|
return AbilityFactory_EndGameCondition.losesGameStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
// if X depends on abCost, the AI needs to choose which card he
|
// if X depends on abCost, the AI needs to choose which card he
|
||||||
// would sacrifice first
|
// would sacrifice first
|
||||||
// then call xCount with that card to properly calculate the
|
// then call xCount with that card to properly calculate the
|
||||||
// amount
|
// amount
|
||||||
// Or choosing how many to sacrifice
|
// Or choosing how many to sacrifice
|
||||||
return losesGameCanPlayAI(af, this);
|
return AbilityFactory_EndGameCondition.losesGameCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
losesGameResolve(af, this);
|
AbilityFactory_EndGameCondition.losesGameResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -361,21 +366,22 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return losesGameStackDescription(af, this);
|
return AbilityFactory_EndGameCondition.losesGameStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
// if X depends on abCost, the AI needs to choose which card he
|
// if X depends on abCost, the AI needs to choose which card he
|
||||||
// would sacrifice first
|
// would sacrifice first
|
||||||
// then call xCount with that card to properly calculate the
|
// then call xCount with that card to properly calculate the
|
||||||
// amount
|
// amount
|
||||||
// Or choosing how many to sacrifice
|
// Or choosing how many to sacrifice
|
||||||
return losesGameCanPlayAI(af, this);
|
return AbilityFactory_EndGameCondition.losesGameCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
losesGameResolve(af, this);
|
AbilityFactory_EndGameCondition.losesGameResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -385,7 +391,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return losesGameDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_EndGameCondition.losesGameDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -404,8 +410,8 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String losesGameStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
public static String losesGameStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(source.getName()).append(" - ");
|
sb.append(source.getName()).append(" - ");
|
||||||
@@ -413,7 +419,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
ArrayList<Player> players = null;
|
ArrayList<Player> players = null;
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null) {
|
||||||
players = tgt.getTargetPlayers();
|
players = tgt.getTargetPlayers();
|
||||||
@@ -421,13 +427,13 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
players = AbilityFactory.getDefinedPlayers(source, af.getMapParams().get("Defined"), sa);
|
players = AbilityFactory.getDefinedPlayers(source, af.getMapParams().get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : players) {
|
for (final Player p : players) {
|
||||||
sb.append(p.getName()).append(" ");
|
sb.append(p.getName()).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("loses the game.");
|
sb.append("loses the game.");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -454,7 +460,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
// Only one SA Lose the Game card right now, which is Door to
|
// Only one SA Lose the Game card right now, which is Door to
|
||||||
// Nothingness
|
// Nothingness
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
@@ -492,7 +498,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
@@ -500,7 +506,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
|
|
||||||
// WinGame abilities usually don't have subAbilities but for
|
// WinGame abilities usually don't have subAbilities but for
|
||||||
// consistency...
|
// consistency...
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
return abSub.doTrigger(mandatory);
|
return abSub.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -520,9 +526,9 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
*/
|
*/
|
||||||
public static void losesGameResolve(final AbilityFactory af, final SpellAbility sa) {
|
public static void losesGameResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
ArrayList<Player> players = null;
|
ArrayList<Player> players = null;
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null) {
|
||||||
players = tgt.getTargetPlayers();
|
players = tgt.getTargetPlayers();
|
||||||
@@ -530,7 +536,7 @@ public final class AbilityFactory_EndGameCondition {
|
|||||||
players = AbilityFactory.getDefinedPlayers(card, af.getMapParams().get("Defined"), sa);
|
players = AbilityFactory.getDefinedPlayers(card, af.getMapParams().get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : players) {
|
for (final Player p : players) {
|
||||||
p.loseConditionMet(GameLossReason.SpellEffect, card.getName());
|
p.loseConditionMet(GameLossReason.SpellEffect, card.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,26 +69,26 @@ public class AbilityFactory_GainControl {
|
|||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
*/
|
*/
|
||||||
public AbilityFactory_GainControl(final AbilityFactory newAF) {
|
public AbilityFactory_GainControl(final AbilityFactory newAF) {
|
||||||
af = newAF;
|
this.af = newAF;
|
||||||
params = af.getMapParams();
|
this.params = this.af.getMapParams();
|
||||||
hostCard = af.getHostCard();
|
this.hostCard = this.af.getHostCard();
|
||||||
if (params.containsKey("LoseControl")) {
|
if (this.params.containsKey("LoseControl")) {
|
||||||
lose = new ArrayList<String>(Arrays.asList(params.get("LoseControl").split(",")));
|
this.lose = new ArrayList<String>(Arrays.asList(this.params.get("LoseControl").split(",")));
|
||||||
}
|
}
|
||||||
if (params.containsKey("Untap")) {
|
if (this.params.containsKey("Untap")) {
|
||||||
bUntap = true;
|
this.bUntap = true;
|
||||||
}
|
}
|
||||||
if (params.containsKey("TapOnLose")) {
|
if (this.params.containsKey("TapOnLose")) {
|
||||||
bTapOnLose = true;
|
this.bTapOnLose = true;
|
||||||
}
|
}
|
||||||
if (params.containsKey("AddKWs")) {
|
if (this.params.containsKey("AddKWs")) {
|
||||||
kws = new ArrayList<String>(Arrays.asList(params.get("AddKWs").split(" & ")));
|
this.kws = new ArrayList<String>(Arrays.asList(this.params.get("AddKWs").split(" & ")));
|
||||||
}
|
}
|
||||||
if (params.containsKey("DestroyTgt")) {
|
if (this.params.containsKey("DestroyTgt")) {
|
||||||
destroyOn = new ArrayList<String>(Arrays.asList(params.get("DestroyTgt").split(",")));
|
this.destroyOn = new ArrayList<String>(Arrays.asList(this.params.get("DestroyTgt").split(",")));
|
||||||
}
|
}
|
||||||
if (params.containsKey("NoRegen")) {
|
if (this.params.containsKey("NoRegen")) {
|
||||||
bNoRegen = true;
|
this.bNoRegen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,22 +101,22 @@ public class AbilityFactory_GainControl {
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getSpellGainControl() {
|
public final SpellAbility getSpellGainControl() {
|
||||||
SpellAbility spControl = new Spell(hostCard, af.getAbCost(), af.getAbTgt()) {
|
final SpellAbility spControl = new Spell(this.hostCard, this.af.getAbCost(), this.af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 3125489644424832311L;
|
private static final long serialVersionUID = 3125489644424832311L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return gainControlTgtAI(this);
|
return AbilityFactory_GainControl.this.gainControlTgtAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
gainControlResolve(this);
|
AbilityFactory_GainControl.this.gainControlResolve(this);
|
||||||
} // resolve
|
} // resolve
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return gainControlStackDescription(this);
|
return AbilityFactory_GainControl.this.gainControlStackDescription(this);
|
||||||
}
|
}
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -133,27 +133,27 @@ public class AbilityFactory_GainControl {
|
|||||||
*/
|
*/
|
||||||
public final SpellAbility getAbilityGainControl() {
|
public final SpellAbility getAbilityGainControl() {
|
||||||
|
|
||||||
final SpellAbility abControl = new Ability_Activated(hostCard, af.getAbCost(), af.getAbTgt()) {
|
final SpellAbility abControl = new Ability_Activated(this.hostCard, this.af.getAbCost(), this.af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -4384705198674678831L;
|
private static final long serialVersionUID = -4384705198674678831L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return gainControlTgtAI(this);
|
return AbilityFactory_GainControl.this.gainControlTgtAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
gainControlResolve(this);
|
AbilityFactory_GainControl.this.gainControlResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return gainControlStackDescription(this);
|
return AbilityFactory_GainControl.this.gainControlStackDescription(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return gainControlTgtAI(this);
|
return AbilityFactory_GainControl.this.gainControlTgtAI(this);
|
||||||
}
|
}
|
||||||
}; // Ability_Activated
|
}; // Ability_Activated
|
||||||
|
|
||||||
@@ -169,32 +169,32 @@ public class AbilityFactory_GainControl {
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getDrawbackGainControl() {
|
public final SpellAbility getDrawbackGainControl() {
|
||||||
SpellAbility dbControl = new Ability_Sub(hostCard, af.getAbTgt()) {
|
final SpellAbility dbControl = new Ability_Sub(this.hostCard, this.af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -5577742598032345880L;
|
private static final long serialVersionUID = -5577742598032345880L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return gainControlTgtAI(this);
|
return AbilityFactory_GainControl.this.gainControlTgtAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return gainControlStackDescription(this);
|
return AbilityFactory_GainControl.this.gainControlStackDescription(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
gainControlResolve(this);
|
AbilityFactory_GainControl.this.gainControlResolve(this);
|
||||||
} // resolve
|
} // resolve
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return gainControlDrawbackAI(this);
|
return AbilityFactory_GainControl.this.gainControlDrawbackAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return gainControlTriggerAI(this, mandatory);
|
return AbilityFactory_GainControl.this.gainControlTriggerAI(this, mandatory);
|
||||||
}
|
}
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ public class AbilityFactory_GainControl {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String gainControlStackDescription(final SpellAbility sa) {
|
private String gainControlStackDescription(final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
@@ -221,22 +221,22 @@ public class AbilityFactory_GainControl {
|
|||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = this.af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
tgtCards = AbilityFactory.getDefinedCards(hostCard, params.get("Defined"), sa);
|
tgtCards = AbilityFactory.getDefinedCards(this.hostCard, this.params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Player> newController = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
final ArrayList<Player> newController = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||||
params.get("NewController"), sa);
|
this.params.get("NewController"), sa);
|
||||||
if (newController.size() == 0) {
|
if (newController.size() == 0) {
|
||||||
newController.add(sa.getActivatingPlayer());
|
newController.add(sa.getActivatingPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(newController).append(" gains control of ");
|
sb.append(newController).append(" gains control of ");
|
||||||
|
|
||||||
for (Card c : tgtCards) {
|
for (final Card c : tgtCards) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
if (c.isFaceDown()) {
|
if (c.isFaceDown()) {
|
||||||
sb.append("Morph");
|
sb.append("Morph");
|
||||||
@@ -246,7 +246,7 @@ public class AbilityFactory_GainControl {
|
|||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ public class AbilityFactory_GainControl {
|
|||||||
boolean hasEnchantment = false;
|
boolean hasEnchantment = false;
|
||||||
boolean hasLand = false;
|
boolean hasLand = false;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = this.af.getAbTgt();
|
||||||
|
|
||||||
// if Defined, then don't worry about targeting
|
// if Defined, then don't worry about targeting
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
@@ -277,13 +277,15 @@ public class AbilityFactory_GainControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(tgt.getValidTgts(), hostCard.getController(), hostCard);
|
list = list.getValidCards(tgt.getValidTgts(), this.hostCard.getController(), this.hostCard);
|
||||||
// AI won't try to grab cards that are filtered out of AI decks on
|
// AI won't try to grab cards that are filtered out of AI decks on
|
||||||
// purpose
|
// purpose
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
Map<String, String> vars = c.getSVars();
|
final Map<String, String> vars = c.getSVars();
|
||||||
return !vars.containsKey("RemAIDeck") && CardFactoryUtil.canTarget(hostCard, c);
|
return !vars.containsKey("RemAIDeck")
|
||||||
|
&& CardFactoryUtil.canTarget(AbilityFactory_GainControl.this.hostCard, c);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -293,13 +295,14 @@ public class AbilityFactory_GainControl {
|
|||||||
|
|
||||||
// Don't steal something if I can't Attack without, or prevent it from
|
// Don't steal something if I can't Attack without, or prevent it from
|
||||||
// blocking at least
|
// blocking at least
|
||||||
if (lose != null && lose.contains("EOT") && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
if ((this.lose != null) && this.lose.contains("EOT")
|
||||||
|
&& AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
while (tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||||
Card t = null;
|
Card t = null;
|
||||||
for (Card c : list) {
|
for (final Card c : list) {
|
||||||
if (c.isCreature()) {
|
if (c.isCreature()) {
|
||||||
hasCreature = true;
|
hasCreature = true;
|
||||||
}
|
}
|
||||||
@@ -315,7 +318,7 @@ public class AbilityFactory_GainControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
if (tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa) || tgt.getNumTargeted() == 0) {
|
if ((tgt.getNumTargeted() < tgt.getMinTargets(sa.getSourceCard(), sa)) || (tgt.getNumTargeted() == 0)) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -359,48 +362,48 @@ public class AbilityFactory_GainControl {
|
|||||||
*/
|
*/
|
||||||
private void gainControlResolve(final SpellAbility sa) {
|
private void gainControlResolve(final SpellAbility sa) {
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
boolean self = params.containsKey("Defined") && params.get("Defined").equals("Self");
|
final boolean self = this.params.containsKey("Defined") && this.params.get("Defined").equals("Self");
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = this.af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
tgtCards = AbilityFactory.getDefinedCards(hostCard, params.get("Defined"), sa);
|
tgtCards = AbilityFactory.getDefinedCards(this.hostCard, this.params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
// tgtCards.add(hostCard);
|
// tgtCards.add(hostCard);
|
||||||
|
|
||||||
ArrayList<Player> newController = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
final ArrayList<Player> newController = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||||
params.get("NewController"), sa);
|
this.params.get("NewController"), sa);
|
||||||
if (newController.size() == 0) {
|
if (newController.size() == 0) {
|
||||||
newController.add(sa.getActivatingPlayer());
|
newController.add(sa.getActivatingPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = tgtCards.size();
|
final int size = tgtCards.size();
|
||||||
for (int j = 0; j < size; j++) {
|
for (int j = 0; j < size; j++) {
|
||||||
final Card tgtC = tgtCards.get(j);
|
final Card tgtC = tgtCards.get(j);
|
||||||
final Player originalController = tgtC.getController();
|
final Player originalController = tgtC.getController();
|
||||||
|
|
||||||
movedCards[j] = tgtC;
|
this.movedCards[j] = tgtC;
|
||||||
if (!self) {
|
if (!self) {
|
||||||
hostCard.addGainControlTarget(tgtC);
|
this.hostCard.addGainControlTarget(tgtC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(hostCard, tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(this.hostCard, tgtC)) {
|
||||||
|
|
||||||
if (params.containsKey("NewController")) {
|
if (this.params.containsKey("NewController")) {
|
||||||
tgtC.addController(newController.get(0));
|
tgtC.addController(newController.get(0));
|
||||||
} else {
|
} else {
|
||||||
tgtC.addController(hostCard);
|
tgtC.addController(this.hostCard);
|
||||||
}
|
}
|
||||||
// AllZone.getGameAction().changeController(new CardList(tgtC),
|
// AllZone.getGameAction().changeController(new CardList(tgtC),
|
||||||
// tgtC.getController(), newController.get(0));
|
// tgtC.getController(), newController.get(0));
|
||||||
|
|
||||||
if (bUntap) {
|
if (this.bUntap) {
|
||||||
tgtC.untap();
|
tgtC.untap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != kws) {
|
if (null != this.kws) {
|
||||||
for (String kw : kws) {
|
for (final String kw : this.kws) {
|
||||||
tgtC.addExtrinsicKeyword(kw);
|
tgtC.addExtrinsicKeyword(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,37 +411,37 @@ public class AbilityFactory_GainControl {
|
|||||||
|
|
||||||
// end copied
|
// end copied
|
||||||
|
|
||||||
if (lose != null) {
|
if (this.lose != null) {
|
||||||
if (lose.contains("LeavesPlay")) {
|
if (this.lose.contains("LeavesPlay")) {
|
||||||
hostCard.addLeavesPlayCommand(getLoseControlCommand(j, originalController));
|
this.hostCard.addLeavesPlayCommand(this.getLoseControlCommand(j, originalController));
|
||||||
}
|
}
|
||||||
if (lose.contains("Untap")) {
|
if (this.lose.contains("Untap")) {
|
||||||
hostCard.addUntapCommand(getLoseControlCommand(j, originalController));
|
this.hostCard.addUntapCommand(this.getLoseControlCommand(j, originalController));
|
||||||
}
|
}
|
||||||
if (lose.contains("LoseControl")) {
|
if (this.lose.contains("LoseControl")) {
|
||||||
hostCard.addChangeControllerCommand(getLoseControlCommand(j, originalController));
|
this.hostCard.addChangeControllerCommand(this.getLoseControlCommand(j, originalController));
|
||||||
}
|
}
|
||||||
if (lose.contains("EOT")) {
|
if (this.lose.contains("EOT")) {
|
||||||
AllZone.getEndOfTurn().addAt(getLoseControlCommand(j, originalController));
|
AllZone.getEndOfTurn().addAt(this.getLoseControlCommand(j, originalController));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyOn != null) {
|
if (this.destroyOn != null) {
|
||||||
if (destroyOn.contains("LeavesPlay")) {
|
if (this.destroyOn.contains("LeavesPlay")) {
|
||||||
hostCard.addLeavesPlayCommand(getDestroyCommand(j));
|
this.hostCard.addLeavesPlayCommand(this.getDestroyCommand(j));
|
||||||
}
|
}
|
||||||
if (destroyOn.contains("Untap")) {
|
if (this.destroyOn.contains("Untap")) {
|
||||||
hostCard.addUntapCommand(getDestroyCommand(j));
|
this.hostCard.addUntapCommand(this.getDestroyCommand(j));
|
||||||
}
|
}
|
||||||
if (destroyOn.contains("LoseControl")) {
|
if (this.destroyOn.contains("LoseControl")) {
|
||||||
hostCard.addChangeControllerCommand(getDestroyCommand(j));
|
this.hostCard.addChangeControllerCommand(this.getDestroyCommand(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for Old Man of the Sea - 0 is hardcoded since it only allows 1
|
// for Old Man of the Sea - 0 is hardcoded since it only allows 1
|
||||||
// target
|
// target
|
||||||
hostCard.clearGainControlReleaseCommands();
|
this.hostCard.clearGainControlReleaseCommands();
|
||||||
hostCard.addGainControlReleaseCommand(getLoseControlCommand(0, originalController));
|
this.hostCard.addGainControlReleaseCommand(this.getLoseControlCommand(0, originalController));
|
||||||
|
|
||||||
} // end foreach target
|
} // end foreach target
|
||||||
}
|
}
|
||||||
@@ -464,7 +467,7 @@ public class AbilityFactory_GainControl {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return gainControlTgtAI(sa);
|
return this.gainControlTgtAI(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -480,10 +483,10 @@ public class AbilityFactory_GainControl {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean gainControlDrawbackAI(final SpellAbility sa) {
|
private boolean gainControlDrawbackAI(final SpellAbility sa) {
|
||||||
if (af.getAbTgt() == null || !af.getAbTgt().doesTarget()) {
|
if ((this.af.getAbTgt() == null) || !this.af.getAbTgt().doesTarget()) {
|
||||||
// all is good
|
// all is good
|
||||||
} else {
|
} else {
|
||||||
return gainControlTgtAI(sa);
|
return this.gainControlTgtAI(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -502,21 +505,24 @@ public class AbilityFactory_GainControl {
|
|||||||
final Command destroy = new Command() {
|
final Command destroy = new Command() {
|
||||||
private static final long serialVersionUID = 878543373519872418L;
|
private static final long serialVersionUID = 878543373519872418L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
final Card c = movedCards[i];
|
final Card c = AbilityFactory_GainControl.this.movedCards[i];
|
||||||
Ability ability = new Ability(hostCard, "0") {
|
final Ability ability = new Ability(AbilityFactory_GainControl.this.hostCard, "0") {
|
||||||
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
|
|
||||||
if (bNoRegen) {
|
if (AbilityFactory_GainControl.this.bNoRegen) {
|
||||||
AllZone.getGameAction().destroyNoRegeneration(c);
|
AllZone.getGameAction().destroyNoRegeneration(c);
|
||||||
} else {
|
} else {
|
||||||
AllZone.getGameAction().destroy(c);
|
AllZone.getGameAction().destroy(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append(hostCard).append(" - destroy ").append(c.getName()).append(".");
|
sb.append(AbilityFactory_GainControl.this.hostCard).append(" - destroy ").append(c.getName())
|
||||||
if (bNoRegen) {
|
.append(".");
|
||||||
|
if (AbilityFactory_GainControl.this.bNoRegen) {
|
||||||
sb.append(" It can't be regenerated.");
|
sb.append(" It can't be regenerated.");
|
||||||
}
|
}
|
||||||
ability.setStackDescription(sb.toString());
|
ability.setStackDescription(sb.toString());
|
||||||
@@ -540,12 +546,14 @@ public class AbilityFactory_GainControl {
|
|||||||
* @return a {@link forge.Command} object.
|
* @return a {@link forge.Command} object.
|
||||||
*/
|
*/
|
||||||
private Command getLoseControlCommand(final int i, final Player originalController) {
|
private Command getLoseControlCommand(final int i, final Player originalController) {
|
||||||
final Card c = movedCards[i];
|
final Card c = this.movedCards[i];
|
||||||
final Command loseControl = new Command() {
|
final Command loseControl = new Command() {
|
||||||
private static final long serialVersionUID = 878543373519872418L;
|
private static final long serialVersionUID = 878543373519872418L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
doLoseControl(c, hostCard, bTapOnLose, kws);
|
AbilityFactory_GainControl.doLoseControl(c, AbilityFactory_GainControl.this.hostCard,
|
||||||
|
AbilityFactory_GainControl.this.bTapOnLose, AbilityFactory_GainControl.this.kws);
|
||||||
} // execute()
|
} // execute()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -567,7 +575,7 @@ public class AbilityFactory_GainControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null != addedKeywords) {
|
if (null != addedKeywords) {
|
||||||
for (String kw : addedKeywords) {
|
for (final String kw : addedKeywords) {
|
||||||
c.removeExtrinsicKeyword(kw);
|
c.removeExtrinsicKeyword(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,25 +40,26 @@ public class AbilityFactory_Mana {
|
|||||||
* createAbilityMana.
|
* createAbilityMana.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param produced
|
* @param produced
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createAbilityMana(final AbilityFactory AF, final String produced) {
|
public static SpellAbility createAbilityMana(final AbilityFactory abilityFactory, final String produced) {
|
||||||
final Ability_Mana abMana = new Ability_Mana(AF.getHostCard(), AF.getAbCost(), produced) {
|
final Ability_Mana abMana = new Ability_Mana(abilityFactory.getHostCard(), abilityFactory.getAbCost(), produced) {
|
||||||
private static final long serialVersionUID = -1933592438783630254L;
|
private static final long serialVersionUID = -1933592438783630254L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return manaCanPlayAI(af);
|
return AbilityFactory_Mana.manaCanPlayAI(this.af);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
manaResolve(this, af, this);
|
AbilityFactory_Mana.manaResolve(this, this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,21 +77,21 @@ public class AbilityFactory_Mana {
|
|||||||
* createSpellMana.
|
* createSpellMana.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param produced
|
* @param produced
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellMana(final AbilityFactory AF, final String produced) {
|
public static SpellAbility createSpellMana(final AbilityFactory abilityFactory, final String produced) {
|
||||||
final SpellAbility spMana = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spMana = new Spell(abilityFactory.getHostCard(), abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -5141246507533353605L;
|
private static final long serialVersionUID = -5141246507533353605L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
// To get the mana to resolve properly, we need the spell to contain
|
// To get the mana to resolve properly, we need the spell to contain
|
||||||
// an Ability_Mana
|
// an Ability_Mana
|
||||||
Cost tmp = new Cost("0", AF.getHostCard().getName(), false);
|
private Cost tmp = new Cost("0", abilityFactory.getHostCard().getName(), false);
|
||||||
Ability_Mana tmpMana = new Ability_Mana(AF.getHostCard(), tmp, produced) {
|
private Ability_Mana tmpMana = new Ability_Mana(abilityFactory.getHostCard(), this.tmp, produced) {
|
||||||
private static final long serialVersionUID = 1454043766057140491L;
|
private static final long serialVersionUID = 1454043766057140491L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,20 +102,21 @@ public class AbilityFactory_Mana {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return manaCanPlayAI(af);
|
return AbilityFactory_Mana.manaCanPlayAI(this.af);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return manaStackDescription(tmpMana, af, this);
|
return AbilityFactory_Mana.manaStackDescription(this.tmpMana, this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
manaResolve(tmpMana, af, this);
|
AbilityFactory_Mana.manaResolve(this.tmpMana, this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -127,21 +129,21 @@ public class AbilityFactory_Mana {
|
|||||||
* createDrawbackMana.
|
* createDrawbackMana.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param produced
|
* @param produced
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.card.spellability.Ability_Sub} object.
|
* @return a {@link forge.card.spellability.Ability_Sub} object.
|
||||||
*/
|
*/
|
||||||
public static Ability_Sub createDrawbackMana(final AbilityFactory AF, final String produced) {
|
public static Ability_Sub createDrawbackMana(final AbilityFactory abilityFactory, final String produced) {
|
||||||
final Ability_Sub dbMana = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final Ability_Sub dbMana = new Ability_Sub(abilityFactory.getHostCard(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -5141246507533353605L;
|
private static final long serialVersionUID = -5141246507533353605L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
// To get the mana to resolve properly, we need the spell to contain
|
// To get the mana to resolve properly, we need the spell to contain
|
||||||
// an Ability_Mana
|
// an Ability_Mana
|
||||||
Cost tmp = new Cost("0", AF.getHostCard().getName(), false);
|
private Cost tmp = new Cost("0", abilityFactory.getHostCard().getName(), false);
|
||||||
Ability_Mana tmpMana = new Ability_Mana(AF.getHostCard(), tmp, produced) {
|
private Ability_Mana tmpMana = new Ability_Mana(abilityFactory.getHostCard(), this.tmp, produced) {
|
||||||
private static final long serialVersionUID = 1454043766057140491L;
|
private static final long serialVersionUID = 1454043766057140491L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,12 +158,12 @@ public class AbilityFactory_Mana {
|
|||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
// when getStackDesc is called, just build exactly what is
|
// when getStackDesc is called, just build exactly what is
|
||||||
// happening
|
// happening
|
||||||
return manaStackDescription(tmpMana, af, this);
|
return AbilityFactory_Mana.manaStackDescription(this.tmpMana, this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
manaResolve(tmpMana, af, this);
|
AbilityFactory_Mana.manaResolve(this.tmpMana, this.af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -207,7 +209,7 @@ public class AbilityFactory_Mana {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String manaStackDescription(final Ability_Mana abMana, final AbilityFactory af, final SpellAbility sa) {
|
public static String manaStackDescription(final Ability_Mana abMana, final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -215,7 +217,7 @@ public class AbilityFactory_Mana {
|
|||||||
sb.append(af.getHostCard()).append(" - ");
|
sb.append(af.getHostCard()).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("Add ").append(generatedMana(abMana, af, sa)).append(" to your mana pool.");
|
sb.append("Add ").append(AbilityFactory_Mana.generatedMana(abMana, af, sa)).append(" to your mana pool.");
|
||||||
|
|
||||||
if (abMana.getSubAbility() != null) {
|
if (abMana.getSubAbility() != null) {
|
||||||
sb.append(abMana.getSubAbility().getStackDescription());
|
sb.append(abMana.getSubAbility().getStackDescription());
|
||||||
@@ -240,20 +242,21 @@ public class AbilityFactory_Mana {
|
|||||||
// Spells are not undoable
|
// Spells are not undoable
|
||||||
abMana.setUndoable(af.isAbility() && abMana.isUndoable());
|
abMana.setUndoable(af.isAbility() && abMana.isUndoable());
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else {
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : tgtPlayers)
|
for (final Player player : tgtPlayers) {
|
||||||
abMana.produceMana(generatedMana(abMana, af, sa), player);
|
abMana.produceMana(AbilityFactory_Mana.generatedMana(abMana, af, sa), player);
|
||||||
|
}
|
||||||
|
|
||||||
// convert these to SubAbilities when appropriate
|
// convert these to SubAbilities when appropriate
|
||||||
if (params.containsKey("Stuck")) {
|
if (params.containsKey("Stuck")) {
|
||||||
@@ -261,16 +264,16 @@ public class AbilityFactory_Mana {
|
|||||||
card.addExtrinsicKeyword("This card doesn't untap during your next untap step.");
|
card.addExtrinsicKeyword("This card doesn't untap during your next untap step.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String deplete = params.get("Deplete");
|
final String deplete = params.get("Deplete");
|
||||||
if (deplete != null) {
|
if (deplete != null) {
|
||||||
int num = card.getCounters(Counters.getType(deplete));
|
final int num = card.getCounters(Counters.getType(deplete));
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
abMana.setUndoable(false);
|
abMana.setUndoable(false);
|
||||||
AllZone.getGameAction().sacrifice(card);
|
AllZone.getGameAction().sacrifice(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doDrawback(af, abMana, card);
|
AbilityFactory_Mana.doDrawback(af, abMana, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -288,8 +291,8 @@ public class AbilityFactory_Mana {
|
|||||||
*/
|
*/
|
||||||
private static String generatedMana(final Ability_Mana abMana, final AbilityFactory af, final SpellAbility sa) {
|
private static String generatedMana(final Ability_Mana abMana, final AbilityFactory af, final SpellAbility sa) {
|
||||||
// Calculate generated mana here for stack description and resolving
|
// Calculate generated mana here for stack description and resolving
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
int amount = params.containsKey("Amount") ? AbilityFactory.calculateAmount(af.getHostCard(),
|
int amount = params.containsKey("Amount") ? AbilityFactory.calculateAmount(af.getHostCard(),
|
||||||
params.get("Amount"), sa) : 1;
|
params.get("Amount"), sa) : 1;
|
||||||
|
|
||||||
@@ -305,7 +308,7 @@ public class AbilityFactory_Mana {
|
|||||||
// ALWAYS be Base
|
// ALWAYS be Base
|
||||||
int bonus = 0;
|
int bonus = 0;
|
||||||
if (params.get("Bonus").equals("UrzaLands")) {
|
if (params.get("Bonus").equals("UrzaLands")) {
|
||||||
if (hasUrzaLands(abMana.getActivatingPlayer())) {
|
if (AbilityFactory_Mana.hasUrzaLands(abMana.getActivatingPlayer())) {
|
||||||
bonus = Integer.parseInt(params.get("BonusProduced"));
|
bonus = Integer.parseInt(params.get("BonusProduced"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,23 +317,23 @@ public class AbilityFactory_Mana {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (params.get("Amount") != null && amount != Integer.parseInt(params.get("Amount"))) {
|
if ((params.get("Amount") != null) && (amount != Integer.parseInt(params.get("Amount")))) {
|
||||||
abMana.setUndoable(false);
|
abMana.setUndoable(false);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException n) {
|
} catch (final NumberFormatException n) {
|
||||||
abMana.setUndoable(false);
|
abMana.setUndoable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
if (amount == 0) {
|
if (amount == 0) {
|
||||||
sb.append("0");
|
sb.append("0");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// if baseMana is an integer(colorless), just multiply amount
|
// if baseMana is an integer(colorless), just multiply amount
|
||||||
// and baseMana
|
// and baseMana
|
||||||
int base = Integer.parseInt(baseMana);
|
final int base = Integer.parseInt(baseMana);
|
||||||
sb.append(base * amount);
|
sb.append(base * amount);
|
||||||
} catch (NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -348,25 +351,26 @@ public class AbilityFactory_Mana {
|
|||||||
* createAbilityManaReflected.
|
* createAbilityManaReflected.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param produced
|
* @param produced
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createAbilityManaReflected(final AbilityFactory AF, final String produced) {
|
public static SpellAbility createAbilityManaReflected(final AbilityFactory abilityFactory, final String produced) {
|
||||||
final Ability_Mana abMana = new Ability_Mana(AF.getHostCard(), AF.getAbCost(), produced) {
|
final Ability_Mana abMana = new Ability_Mana(abilityFactory.getHostCard(), abilityFactory.getAbCost(), produced) {
|
||||||
private static final long serialVersionUID = -1933592438783630254L;
|
private static final long serialVersionUID = -1933592438783630254L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return manaReflectedCanPlayAI(af);
|
return AbilityFactory_Mana.manaReflectedCanPlayAI(this.af);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
manaReflectedResolve(this, af);
|
AbilityFactory_Mana.manaReflectedResolve(this, this.af);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -385,23 +389,23 @@ public class AbilityFactory_Mana {
|
|||||||
* createSpellManaReflected.
|
* createSpellManaReflected.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param AF
|
* @param abilityFactory
|
||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
* @param produced
|
* @param produced
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellManaReflected(final AbilityFactory AF, final String produced) {
|
public static SpellAbility createSpellManaReflected(final AbilityFactory abilityFactory, final String produced) {
|
||||||
// No Spell has Reflected Mana, but might as well put it in for the
|
// No Spell has Reflected Mana, but might as well put it in for the
|
||||||
// future
|
// future
|
||||||
final SpellAbility spMana = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spMana = new Spell(abilityFactory.getHostCard(), abilityFactory.getAbCost(), abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -5141246507533353605L;
|
private static final long serialVersionUID = -5141246507533353605L;
|
||||||
|
|
||||||
final AbilityFactory af = AF;
|
private final AbilityFactory af = abilityFactory;
|
||||||
// To get the mana to resolve properly, we need the spell to contain
|
// To get the mana to resolve properly, we need the spell to contain
|
||||||
// an Ability_Mana
|
// an Ability_Mana
|
||||||
Cost tmp = new Cost("0", AF.getHostCard().getName(), false);
|
private Cost tmp = new Cost("0", abilityFactory.getHostCard().getName(), false);
|
||||||
Ability_Mana tmpMana = new Ability_Mana(AF.getHostCard(), tmp, produced) {
|
private Ability_Mana tmpMana = new Ability_Mana(abilityFactory.getHostCard(), this.tmp, produced) {
|
||||||
private static final long serialVersionUID = 1454043766057140491L;
|
private static final long serialVersionUID = 1454043766057140491L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -416,13 +420,14 @@ public class AbilityFactory_Mana {
|
|||||||
|
|
||||||
// tmpMana.setReflectedMana(true);
|
// tmpMana.setReflectedMana(true);
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return manaReflectedCanPlayAI(af);
|
return AbilityFactory_Mana.manaReflectedCanPlayAI(this.af);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
manaReflectedResolve(tmpMana, af);
|
AbilityFactory_Mana.manaReflectedResolve(this.tmpMana, this.af);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -455,24 +460,25 @@ public class AbilityFactory_Mana {
|
|||||||
*/
|
*/
|
||||||
public static void manaReflectedResolve(final Ability_Mana abMana, final AbilityFactory af) {
|
public static void manaReflectedResolve(final Ability_Mana abMana, final AbilityFactory af) {
|
||||||
// Spells are not undoable
|
// Spells are not undoable
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
abMana.setUndoable(af.isAbility() && abMana.isUndoable());
|
abMana.setUndoable(af.isAbility() && abMana.isUndoable());
|
||||||
|
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
ArrayList<String> colors = reflectableMana(abMana, af, new ArrayList<String>(), new ArrayList<Card>());
|
final ArrayList<String> colors = AbilityFactory_Mana.reflectableMana(abMana, af, new ArrayList<String>(),
|
||||||
|
new ArrayList<Card>());
|
||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else {
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(abMana.getSourceCard(), params.get("Defined"), abMana);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(abMana.getSourceCard(), params.get("Defined"), abMana);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : tgtPlayers) {
|
for (final Player player : tgtPlayers) {
|
||||||
String generated = generatedReflectedMana(abMana, af, colors, player);
|
final String generated = AbilityFactory_Mana.generatedReflectedMana(abMana, af, colors, player);
|
||||||
|
|
||||||
if (abMana.getCanceled()) {
|
if (abMana.getCanceled()) {
|
||||||
abMana.undo();
|
abMana.undo();
|
||||||
@@ -482,7 +488,7 @@ public class AbilityFactory_Mana {
|
|||||||
abMana.produceMana(generated, player);
|
abMana.produceMana(generated, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
doDrawback(af, abMana, card);
|
AbilityFactory_Mana.doDrawback(af, abMana, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add Colors and
|
// add Colors and
|
||||||
@@ -501,24 +507,25 @@ public class AbilityFactory_Mana {
|
|||||||
* a {@link java.util.ArrayList} object.
|
* a {@link java.util.ArrayList} object.
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public static ArrayList<String> reflectableMana(final Ability_Mana abMana, final AbilityFactory af, ArrayList<String> colors,
|
public static ArrayList<String> reflectableMana(final Ability_Mana abMana, final AbilityFactory af,
|
||||||
final ArrayList<Card> parents) {
|
ArrayList<String> colors, final ArrayList<Card> parents) {
|
||||||
// Here's the problem with reflectable Mana. If more than one is out,
|
// Here's the problem with reflectable Mana. If more than one is out,
|
||||||
// they need to Reflect each other,
|
// they need to Reflect each other,
|
||||||
// so we basically need to have a recursive list that send the parents
|
// so we basically need to have a recursive list that send the parents
|
||||||
// so we don't infinite recurse.
|
// so we don't infinite recurse.
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = af.getHostCard();
|
final Card card = af.getHostCard();
|
||||||
|
|
||||||
if (!parents.contains(card)) {
|
if (!parents.contains(card)) {
|
||||||
parents.add(card);
|
parents.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
String colorOrType = params.get("ColorOrType"); // currently Color or
|
final String colorOrType = params.get("ColorOrType"); // currently Color
|
||||||
|
// or
|
||||||
// Type, Type is colors
|
// Type, Type is colors
|
||||||
// + colorless
|
// + colorless
|
||||||
String validCard = params.get("Valid");
|
final String validCard = params.get("Valid");
|
||||||
String reflectProperty = params.get("ReflectProperty"); // Produce
|
final String reflectProperty = params.get("ReflectProperty"); // Produce
|
||||||
// (Reflecting
|
// (Reflecting
|
||||||
// Pool) or Is
|
// Pool) or Is
|
||||||
// (Meteor
|
// (Meteor
|
||||||
@@ -534,48 +541,49 @@ public class AbilityFactory_Mana {
|
|||||||
// Reuse AF_Defined in a slightly different way
|
// Reuse AF_Defined in a slightly different way
|
||||||
if (validCard.startsWith("Defined.")) {
|
if (validCard.startsWith("Defined.")) {
|
||||||
cards = new CardList();
|
cards = new CardList();
|
||||||
for (Card c : AbilityFactory
|
for (final Card c : AbilityFactory.getDefinedCards(card, validCard.replace("Defined.", ""), abMana)) {
|
||||||
.getDefinedCards(card, validCard.replace("Defined.", ""), (SpellAbility) abMana))
|
|
||||||
cards.add(c);
|
cards.add(c);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cards = AllZoneUtil.getCardsIn(Zone.Battlefield).getValidCards(validCard, abMana.getActivatingPlayer(),
|
cards = AllZoneUtil.getCardsIn(Zone.Battlefield).getValidCards(validCard, abMana.getActivatingPlayer(),
|
||||||
card);
|
card);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove anything cards that is already in parents
|
// remove anything cards that is already in parents
|
||||||
for (Card p : parents)
|
for (final Card p : parents) {
|
||||||
if (cards.contains(p)) {
|
if (cards.contains(p)) {
|
||||||
cards.remove(p);
|
cards.remove(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cards.size() == 0 && !reflectProperty.equals("Produced")) {
|
if ((cards.size() == 0) && !reflectProperty.equals("Produced")) {
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reflectProperty.equals("Is")) { // Meteor Crater
|
if (reflectProperty.equals("Is")) { // Meteor Crater
|
||||||
colors = hasProperty(maxChoices, cards, colors);
|
colors = AbilityFactory_Mana.hasProperty(maxChoices, cards, colors);
|
||||||
} else if (reflectProperty.equals("Produced")) {
|
} else if (reflectProperty.equals("Produced")) {
|
||||||
String producedColors = (String) abMana.getTriggeringObject("Produced");
|
final String producedColors = (String) abMana.getTriggeringObject("Produced");
|
||||||
for (String col : Constant.Color.ONLY_COLORS) {
|
for (final String col : Constant.Color.ONLY_COLORS) {
|
||||||
String s = Input_PayManaCostUtil.getShortColorString(col);
|
final String s = Input_PayManaCostUtil.getShortColorString(col);
|
||||||
if (producedColors.contains(s) && !colors.contains(col)) {
|
if (producedColors.contains(s) && !colors.contains(col)) {
|
||||||
colors.add(col);
|
colors.add(col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxChoices == 6 && producedColors.contains("1") && !colors.contains(Constant.Color.COLORLESS)) {
|
if ((maxChoices == 6) && producedColors.contains("1") && !colors.contains(Constant.Color.COLORLESS)) {
|
||||||
colors.add(Constant.Color.COLORLESS);
|
colors.add(Constant.Color.COLORLESS);
|
||||||
}
|
}
|
||||||
} else if (reflectProperty.equals("Produce")) {
|
} else if (reflectProperty.equals("Produce")) {
|
||||||
ArrayList<Ability_Mana> abilities = new ArrayList<Ability_Mana>();
|
final ArrayList<Ability_Mana> abilities = new ArrayList<Ability_Mana>();
|
||||||
for (Card c : cards) {
|
for (final Card c : cards) {
|
||||||
abilities.addAll(c.getManaAbility());
|
abilities.addAll(c.getManaAbility());
|
||||||
}
|
}
|
||||||
// currently reflected mana will ignore other reflected mana
|
// currently reflected mana will ignore other reflected mana
|
||||||
// abilities
|
// abilities
|
||||||
|
|
||||||
ArrayList<Ability_Mana> reflectAbilities = new ArrayList<Ability_Mana>();
|
final ArrayList<Ability_Mana> reflectAbilities = new ArrayList<Ability_Mana>();
|
||||||
|
|
||||||
for (Ability_Mana ab : abilities) {
|
for (final Ability_Mana ab : abilities) {
|
||||||
if (maxChoices == colors.size()) {
|
if (maxChoices == colors.size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -588,18 +596,18 @@ public class AbilityFactory_Mana {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
colors = canProduce(maxChoices, ab, colors);
|
colors = AbilityFactory_Mana.canProduce(maxChoices, ab, colors);
|
||||||
if (!parents.contains(ab.getSourceCard())) {
|
if (!parents.contains(ab.getSourceCard())) {
|
||||||
parents.add(ab.getSourceCard());
|
parents.add(ab.getSourceCard());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Ability_Mana ab : reflectAbilities) {
|
for (final Ability_Mana ab : reflectAbilities) {
|
||||||
if (maxChoices == colors.size()) {
|
if (maxChoices == colors.size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
colors = reflectableMana(ab, ab.getAbilityFactory(), colors, parents);
|
colors = AbilityFactory_Mana.reflectableMana(ab, ab.getAbilityFactory(), colors, parents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,11 +627,12 @@ public class AbilityFactory_Mana {
|
|||||||
* a {@link java.util.ArrayList} object.
|
* a {@link java.util.ArrayList} object.
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
private static ArrayList<String> hasProperty(final int maxChoices, final CardList cards, final ArrayList<String> colors) {
|
private static ArrayList<String> hasProperty(final int maxChoices, final CardList cards,
|
||||||
for (Card c : cards) {
|
final ArrayList<String> colors) {
|
||||||
|
for (final Card c : cards) {
|
||||||
// For each card, go through all the colors and if the card is that
|
// For each card, go through all the colors and if the card is that
|
||||||
// color, add
|
// color, add
|
||||||
for (String col : Constant.Color.ONLY_COLORS) {
|
for (final String col : Constant.Color.ONLY_COLORS) {
|
||||||
if (c.isColor(col) && !colors.contains(col)) {
|
if (c.isColor(col) && !colors.contains(col)) {
|
||||||
colors.add(col);
|
colors.add(col);
|
||||||
if (colors.size() == maxChoices) {
|
if (colors.size() == maxChoices) {
|
||||||
@@ -648,15 +657,16 @@ public class AbilityFactory_Mana {
|
|||||||
* a {@link java.util.ArrayList} object.
|
* a {@link java.util.ArrayList} object.
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
private static ArrayList<String> canProduce(final int maxChoices, final Ability_Mana ab, final ArrayList<String> colors) {
|
private static ArrayList<String> canProduce(final int maxChoices, final Ability_Mana ab,
|
||||||
for (String col : Constant.Color.ONLY_COLORS) {
|
final ArrayList<String> colors) {
|
||||||
String s = Input_PayManaCostUtil.getShortColorString(col);
|
for (final String col : Constant.Color.ONLY_COLORS) {
|
||||||
|
final String s = Input_PayManaCostUtil.getShortColorString(col);
|
||||||
if (ab.canProduce(s) && !colors.contains(col)) {
|
if (ab.canProduce(s) && !colors.contains(col)) {
|
||||||
colors.add(col);
|
colors.add(col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxChoices == 6 && ab.canProduce("1") && !colors.contains(Constant.Color.COLORLESS)) {
|
if ((maxChoices == 6) && ab.canProduce("1") && !colors.contains(Constant.Color.COLORLESS)) {
|
||||||
colors.add(Constant.Color.COLORLESS);
|
colors.add(Constant.Color.COLORLESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,11 +688,11 @@ public class AbilityFactory_Mana {
|
|||||||
* a {@link forge.Player} object.
|
* a {@link forge.Player} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String generatedReflectedMana(final Ability_Mana abMana, final AbilityFactory af, final ArrayList<String> colors,
|
private static String generatedReflectedMana(final Ability_Mana abMana, final AbilityFactory af,
|
||||||
final Player player) {
|
final ArrayList<String> colors, final Player player) {
|
||||||
// Calculate generated mana here for stack description and resolving
|
// Calculate generated mana here for stack description and resolving
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
int amount = params.containsKey("Amount") ? AbilityFactory.calculateAmount(af.getHostCard(),
|
final int amount = params.containsKey("Amount") ? AbilityFactory.calculateAmount(af.getHostCard(),
|
||||||
params.get("Amount"), abMana) : 1;
|
params.get("Amount"), abMana) : 1;
|
||||||
|
|
||||||
String baseMana = "";
|
String baseMana = "";
|
||||||
@@ -693,7 +703,7 @@ public class AbilityFactory_Mana {
|
|||||||
baseMana = Input_PayManaCostUtil.getShortColorString(colors.get(0));
|
baseMana = Input_PayManaCostUtil.getShortColorString(colors.get(0));
|
||||||
} else {
|
} else {
|
||||||
if (player.isHuman()) {
|
if (player.isHuman()) {
|
||||||
Object o = GuiUtils.getChoiceOptional("Select Mana to Produce", colors.toArray());
|
final Object o = GuiUtils.getChoiceOptional("Select Mana to Produce", colors.toArray());
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
// User hit cancel
|
// User hit cancel
|
||||||
abMana.setCanceled(true);
|
abMana.setCanceled(true);
|
||||||
@@ -707,16 +717,16 @@ public class AbilityFactory_Mana {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
if (amount == 0) {
|
if (amount == 0) {
|
||||||
sb.append("0");
|
sb.append("0");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// if baseMana is an integer(colorless), just multiply amount
|
// if baseMana is an integer(colorless), just multiply amount
|
||||||
// and baseMana
|
// and baseMana
|
||||||
int base = Integer.parseInt(baseMana);
|
final int base = Integer.parseInt(baseMana);
|
||||||
sb.append(base * amount);
|
sb.append(base * amount);
|
||||||
} catch (NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -747,7 +757,7 @@ public class AbilityFactory_Mana {
|
|||||||
// if mana production has any type of SubAbility, undoable=false
|
// if mana production has any type of SubAbility, undoable=false
|
||||||
if (af.hasSubAbility()) {
|
if (af.hasSubAbility()) {
|
||||||
abMana.setUndoable(false);
|
abMana.setUndoable(false);
|
||||||
Ability_Sub abSub = abMana.getSubAbility();
|
final Ability_Sub abSub = abMana.getSubAbility();
|
||||||
AbilityFactory.resolve(abSub, false);
|
AbilityFactory.resolve(abSub, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -762,7 +772,7 @@ public class AbilityFactory_Mana {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean hasUrzaLands(final Player p) {
|
private static boolean hasUrzaLands(final Player p) {
|
||||||
CardList landsControlled = p.getCardsIn(Zone.Battlefield);
|
final CardList landsControlled = p.getCardsIn(Zone.Battlefield);
|
||||||
|
|
||||||
return (landsControlled.containsName("Urza's Mine") && landsControlled.containsName("Urza's Tower") && landsControlled
|
return (landsControlled.containsName("Urza's Mine") && landsControlled.containsName("Urza's Tower") && landsControlled
|
||||||
.containsName("Urza's Power Plant"));
|
.containsName("Urza's Power Plant"));
|
||||||
@@ -788,22 +798,22 @@ public class AbilityFactory_Mana {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return drainManaStackDescription(af, this);
|
return AbilityFactory_Mana.drainManaStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return drainManaCanPlayAI(af, this);
|
return AbilityFactory_Mana.drainManaCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
drainManaResolve(af, this);
|
AbilityFactory_Mana.drainManaResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return drainManaTrigger(af, this, mandatory);
|
return AbilityFactory_Mana.drainManaTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -826,17 +836,17 @@ public class AbilityFactory_Mana {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return drainManaStackDescription(af, this);
|
return AbilityFactory_Mana.drainManaStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return drainManaCanPlayAI(af, this);
|
return AbilityFactory_Mana.drainManaCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
drainManaResolve(af, this);
|
AbilityFactory_Mana.drainManaResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -859,22 +869,22 @@ public class AbilityFactory_Mana {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return drainManaStackDescription(af, this);
|
return AbilityFactory_Mana.drainManaStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
drainManaResolve(af, this);
|
AbilityFactory_Mana.drainManaResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return drainManaPlayDrawbackAI(af, this);
|
return AbilityFactory_Mana.drainManaPlayDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return drainManaTrigger(af, this, mandatory);
|
return AbilityFactory_Mana.drainManaTrigger(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -893,9 +903,9 @@ public class AbilityFactory_Mana {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String drainManaStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String drainManaStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -904,14 +914,14 @@ public class AbilityFactory_Mana {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else {
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Player> it = tgtPlayers.iterator();
|
final Iterator<Player> it = tgtPlayers.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
sb.append(it.next());
|
sb.append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
@@ -921,7 +931,7 @@ public class AbilityFactory_Mana {
|
|||||||
|
|
||||||
sb.append(" empties his or her mana pool.");
|
sb.append(" empties his or her mana pool.");
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
sb.append(subAb.getStackDescription());
|
sb.append(subAb.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -943,18 +953,18 @@ public class AbilityFactory_Mana {
|
|||||||
private static boolean drainManaCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean drainManaCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI cannot use this properly until he can use SAs during Humans turn
|
// AI cannot use this properly until he can use SAs during Humans turn
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||||
|
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// assume we are looking to tap human's stuff
|
// assume we are looking to tap human's stuff
|
||||||
// TODO - check for things with untap abilities, and don't tap
|
// TODO - check for things with untap abilities, and don't tap
|
||||||
// those.
|
// those.
|
||||||
ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
||||||
|
|
||||||
if (!defined.contains(AllZone.getHumanPlayer())) {
|
if (!defined.contains(AllZone.getHumanPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -964,7 +974,7 @@ public class AbilityFactory_Mana {
|
|||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
randomReturn &= subAb.chkAIDrawback();
|
randomReturn &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -990,15 +1000,15 @@ public class AbilityFactory_Mana {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
if (null == tgt) {
|
if (null == tgt) {
|
||||||
if (mandatory) {
|
if (mandatory) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
||||||
|
|
||||||
if (!defined.contains(AllZone.getHumanPlayer())) {
|
if (!defined.contains(AllZone.getHumanPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1027,14 +1037,14 @@ public class AbilityFactory_Mana {
|
|||||||
*/
|
*/
|
||||||
private static boolean drainManaPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean drainManaPlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI cannot use this properly until he can use SAs during Humans turn
|
// AI cannot use this properly until he can use SAs during Humans turn
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
boolean randomReturn = true;
|
boolean randomReturn = true;
|
||||||
|
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
final ArrayList<Player> defined = AbilityFactory.getDefinedPlayers(source, params.get("Defined"), sa);
|
||||||
|
|
||||||
if (defined.contains(AllZone.getComputerPlayer())) {
|
if (defined.contains(AllZone.getComputerPlayer())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1044,7 +1054,7 @@ public class AbilityFactory_Mana {
|
|||||||
tgt.addTarget(AllZone.getHumanPlayer());
|
tgt.addTarget(AllZone.getHumanPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
randomReturn &= subAb.chkAIDrawback();
|
randomReturn &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -1063,19 +1073,19 @@ public class AbilityFactory_Mana {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void drainManaResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void drainManaResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else {
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(card, params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(card, params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : tgtPlayers) {
|
for (final Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa)) {
|
if ((tgt == null) || p.canTarget(sa)) {
|
||||||
p.getManaPool().clearPool();
|
p.getManaPool().clearPool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -53,22 +53,22 @@ public class AbilityFactory_PreventDamage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return preventDamageCanPlayAI(af, this);
|
return AbilityFactory_PreventDamage.preventDamageCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
preventDamageResolve(af, this);
|
AbilityFactory_PreventDamage.preventDamageResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return preventDamageStackDescription(af, this);
|
return AbilityFactory_PreventDamage.preventDamageStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return doPreventDamageTriggerAI(af, this, mandatory);
|
return AbilityFactory_PreventDamage.doPreventDamageTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Ability_Activated
|
}; // Ability_Activated
|
||||||
@@ -92,17 +92,17 @@ public class AbilityFactory_PreventDamage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return preventDamageCanPlayAI(af, this);
|
return AbilityFactory_PreventDamage.preventDamageCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
preventDamageResolve(af, this);
|
AbilityFactory_PreventDamage.preventDamageResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return preventDamageStackDescription(af, this);
|
return AbilityFactory_PreventDamage.preventDamageStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Spell
|
}; // Spell
|
||||||
@@ -125,12 +125,12 @@ public class AbilityFactory_PreventDamage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return preventDamageStackDescription(af, this);
|
return AbilityFactory_PreventDamage.preventDamageStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
preventDamageResolve(af, this);
|
AbilityFactory_PreventDamage.preventDamageResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -140,7 +140,7 @@ public class AbilityFactory_PreventDamage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return doPreventDamageTriggerAI(af, this, mandatory);
|
return AbilityFactory_PreventDamage.doPreventDamageTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -160,8 +160,8 @@ public class AbilityFactory_PreventDamage {
|
|||||||
*/
|
*/
|
||||||
private static String preventDamageStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String preventDamageStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
ArrayList<Object> tgts;
|
ArrayList<Object> tgts;
|
||||||
if (sa.getTarget() == null) {
|
if (sa.getTarget() == null) {
|
||||||
@@ -184,9 +184,9 @@ public class AbilityFactory_PreventDamage {
|
|||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object o = tgts.get(i);
|
final Object o = tgts.get(i);
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
Card tgtC = (Card) o;
|
final Card tgtC = (Card) o;
|
||||||
if (tgtC.isFaceDown()) {
|
if (tgtC.isFaceDown()) {
|
||||||
sb.append("Morph");
|
sb.append("Morph");
|
||||||
} else {
|
} else {
|
||||||
@@ -197,7 +197,7 @@ public class AbilityFactory_PreventDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (af.getMapParams().containsKey("Radiance") && sa.getTarget() != null) {
|
if (af.getMapParams().containsKey("Radiance") && (sa.getTarget() != null)) {
|
||||||
sb.append(" and each other ").append(af.getMapParams().get("ValidTgts"))
|
sb.append(" and each other ").append(af.getMapParams().get("ValidTgts"))
|
||||||
.append(" that shares a color with ");
|
.append(" that shares a color with ");
|
||||||
if (tgts.size() > 1) {
|
if (tgts.size() > 1) {
|
||||||
@@ -208,7 +208,7 @@ public class AbilityFactory_PreventDamage {
|
|||||||
}
|
}
|
||||||
sb.append(" this turn.");
|
sb.append(" this turn.");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ public class AbilityFactory_PreventDamage {
|
|||||||
final Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
boolean chance = false;
|
boolean chance = false;
|
||||||
|
|
||||||
Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4)) {
|
if (!CostUtil.checkLifeCost(cost, hostCard, 4)) {
|
||||||
@@ -251,16 +251,17 @@ public class AbilityFactory_PreventDamage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// As far as I can tell these Defined Cards will only have one of
|
// As far as I can tell these Defined Cards will only have one of
|
||||||
// them
|
// them
|
||||||
ArrayList<Object> objects = AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("Defined"), sa);
|
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(sa.getSourceCard(),
|
||||||
|
params.get("Defined"), sa);
|
||||||
|
|
||||||
// react to threats on the stack
|
// react to threats on the stack
|
||||||
if (AllZone.getStack().size() > 0) {
|
if (AllZone.getStack().size() > 0) {
|
||||||
ArrayList<Object> threatenedObjects = AbilityFactory.predictThreatenedObjects(af);
|
final ArrayList<Object> threatenedObjects = AbilityFactory.predictThreatenedObjects(af);
|
||||||
for (Object o : objects) {
|
for (final Object o : objects) {
|
||||||
if (threatenedObjects.contains(o)) {
|
if (threatenedObjects.contains(o)) {
|
||||||
chance = true;
|
chance = true;
|
||||||
}
|
}
|
||||||
@@ -268,12 +269,12 @@ public class AbilityFactory_PreventDamage {
|
|||||||
} else {
|
} else {
|
||||||
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
for (Object o : objects) {
|
for (final Object o : objects) {
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
Card c = (Card) o;
|
final Card c = (Card) o;
|
||||||
flag |= CombatUtil.combatantWouldBeDestroyed(c);
|
flag |= CombatUtil.combatantWouldBeDestroyed(c);
|
||||||
} else if (o instanceof Player) {
|
} else if (o instanceof Player) {
|
||||||
Player p = (Player) o;
|
final Player p = (Player) o;
|
||||||
flag |= (p.isComputer() && ((CombatUtil.wouldLoseLife(AllZone.getCombat()) && sa
|
flag |= (p.isComputer() && ((CombatUtil.wouldLoseLife(AllZone.getCombat()) && sa
|
||||||
.isAbility()) || CombatUtil.lifeInDanger(AllZone.getCombat())));
|
.isAbility()) || CombatUtil.lifeInDanger(AllZone.getCombat())));
|
||||||
}
|
}
|
||||||
@@ -292,18 +293,19 @@ public class AbilityFactory_PreventDamage {
|
|||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
// check stack for something on the stack will kill anything i
|
// check stack for something on the stack will kill anything i
|
||||||
// control
|
// control
|
||||||
ArrayList<Object> objects = new ArrayList<Object>();// AbilityFactory.predictThreatenedObjects(af);
|
final ArrayList<Object> objects = new ArrayList<Object>();
|
||||||
|
// AbilityFactory.predictThreatenedObjects(af);
|
||||||
|
|
||||||
if (objects.contains(AllZone.getComputerPlayer())) {
|
if (objects.contains(AllZone.getComputerPlayer())) {
|
||||||
tgt.addTarget(AllZone.getComputerPlayer());
|
tgt.addTarget(AllZone.getComputerPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList threatenedTargets = new CardList();
|
final CardList threatenedTargets = new CardList();
|
||||||
// filter AIs battlefield by what I can target
|
// filter AIs battlefield by what I can target
|
||||||
CardList targetables = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
CardList targetables = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||||
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
||||||
|
|
||||||
for (Card c : targetables) {
|
for (final Card c : targetables) {
|
||||||
if (objects.contains(c)) {
|
if (objects.contains(c)) {
|
||||||
threatenedTargets.add(c);
|
threatenedTargets.add(c);
|
||||||
}
|
}
|
||||||
@@ -329,10 +331,10 @@ public class AbilityFactory_PreventDamage {
|
|||||||
if (targetables.size() == 0) {
|
if (targetables.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CardList combatants = targetables.getType("Creature");
|
final CardList combatants = targetables.getType("Creature");
|
||||||
CardListUtil.sortByEvaluateCreature(combatants);
|
CardListUtil.sortByEvaluateCreature(combatants);
|
||||||
|
|
||||||
for (Card c : combatants) {
|
for (final Card c : combatants) {
|
||||||
if (CombatUtil.combatantWouldBeDestroyed(c)) {
|
if (CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
chance = true;
|
chance = true;
|
||||||
@@ -342,7 +344,7 @@ public class AbilityFactory_PreventDamage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -363,22 +365,23 @@ public class AbilityFactory_PreventDamage {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean doPreventDamageTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean doPreventDamageTriggerAI(final AbilityFactory af, final SpellAbility sa,
|
||||||
|
final boolean mandatory) {
|
||||||
boolean chance = false;
|
boolean chance = false;
|
||||||
|
|
||||||
if (!ComputerUtil.canPayCost(sa)) {
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// If there's no target on the trigger, just say yes.
|
// If there's no target on the trigger, just say yes.
|
||||||
chance = true;
|
chance = true;
|
||||||
} else {
|
} else {
|
||||||
chance = preventDamageMandatoryTarget(af, sa, mandatory);
|
chance = AbilityFactory_PreventDamage.preventDamageMandatoryTarget(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.doTrigger(mandatory);
|
chance &= subAb.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -399,28 +402,29 @@ public class AbilityFactory_PreventDamage {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean preventDamageMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean preventDamageMandatoryTarget(final AbilityFactory af, final SpellAbility sa,
|
||||||
|
final boolean mandatory) {
|
||||||
final Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
// filter AIs battlefield by what I can target
|
// filter AIs battlefield by what I can target
|
||||||
CardList targetables = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList targetables = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
||||||
CardList compTargetables = targetables.getController(AllZone.getComputerPlayer());
|
final CardList compTargetables = targetables.getController(AllZone.getComputerPlayer());
|
||||||
|
|
||||||
if (targetables.size() == 0) {
|
if (targetables.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mandatory && compTargetables.size() == 0) {
|
if (!mandatory && (compTargetables.size() == 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compTargetables.size() > 0) {
|
if (compTargetables.size() > 0) {
|
||||||
CardList combatants = compTargetables.getType("Creature");
|
final CardList combatants = compTargetables.getType("Creature");
|
||||||
CardListUtil.sortByEvaluateCreature(combatants);
|
CardListUtil.sortByEvaluateCreature(combatants);
|
||||||
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||||
for (Card c : combatants) {
|
for (final Card c : combatants) {
|
||||||
if (CombatUtil.combatantWouldBeDestroyed(c)) {
|
if (CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
return true;
|
return true;
|
||||||
@@ -451,17 +455,17 @@ public class AbilityFactory_PreventDamage {
|
|||||||
*/
|
*/
|
||||||
private static void preventDamageResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void preventDamageResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
int numDam = AbilityFactory.calculateAmount(af.getHostCard(), params.get("Amount"), sa);
|
final int numDam = AbilityFactory.calculateAmount(af.getHostCard(), params.get("Amount"), sa);
|
||||||
|
|
||||||
ArrayList<Object> tgts;
|
ArrayList<Object> tgts;
|
||||||
ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
final ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
||||||
if (sa.getTarget() == null) {
|
if (sa.getTarget() == null) {
|
||||||
tgts = AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("Defined"), sa);
|
tgts = AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
} else {
|
} else {
|
||||||
tgts = sa.getTarget().getTargets();
|
tgts = sa.getTarget().getTargets();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("Radiance") && sa.getTarget() != null) {
|
if (params.containsKey("Radiance") && (sa.getTarget() != null)) {
|
||||||
Card origin = null;
|
Card origin = null;
|
||||||
for (int i = 0; i < tgts.size(); i++) {
|
for (int i = 0; i < tgts.size(); i++) {
|
||||||
if (tgts.get(i) instanceof Card) {
|
if (tgts.get(i) instanceof Card) {
|
||||||
@@ -469,32 +473,32 @@ public class AbilityFactory_PreventDamage {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (origin != null) // Can't radiate from a player
|
if (origin != null) {
|
||||||
{
|
// Can't radiate from a player
|
||||||
for (Card c : CardUtil.getRadiance(af.getHostCard(), origin, params.get("ValidTgts").split(","))) {
|
for (final Card c : CardUtil.getRadiance(af.getHostCard(), origin, params.get("ValidTgts").split(","))) {
|
||||||
untargetedCards.add(c);
|
untargetedCards.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean targeted = (af.getAbTgt() != null);
|
final boolean targeted = (af.getAbTgt() != null);
|
||||||
|
|
||||||
for (Object o : tgts) {
|
for (final Object o : tgts) {
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
Card c = (Card) o;
|
final Card c = (Card) o;
|
||||||
if (AllZoneUtil.isCardInPlay(c) && (!targeted || CardFactoryUtil.canTarget(af.getHostCard(), c))) {
|
if (AllZoneUtil.isCardInPlay(c) && (!targeted || CardFactoryUtil.canTarget(af.getHostCard(), c))) {
|
||||||
c.addPreventNextDamage(numDam);
|
c.addPreventNextDamage(numDam);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (o instanceof Player) {
|
} else if (o instanceof Player) {
|
||||||
Player p = (Player) o;
|
final Player p = (Player) o;
|
||||||
if (!targeted || p.canTarget(sa)) {
|
if (!targeted || p.canTarget(sa)) {
|
||||||
p.addPreventNextDamage(numDam);
|
p.addPreventNextDamage(numDam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card c : untargetedCards) {
|
for (final Card c : untargetedCards) {
|
||||||
if (AllZoneUtil.isCardInPlay(c)) {
|
if (AllZoneUtil.isCardInPlay(c)) {
|
||||||
c.addPreventNextDamage(numDam);
|
c.addPreventNextDamage(numDam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,22 +52,22 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellProtection(final AbilityFactory af) {
|
public static SpellAbility createSpellProtection(final AbilityFactory af) {
|
||||||
SpellAbility spProtect = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
final SpellAbility spProtect = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 4678736312735724916L;
|
private static final long serialVersionUID = 4678736312735724916L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return protectCanPlayAI(af, this);
|
return AbilityFactory_Protection.protectCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return protectStackDescription(af, this);
|
return AbilityFactory_Protection.protectStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
protectResolve(af, this);
|
AbilityFactory_Protection.protectResolve(af, this);
|
||||||
} // resolve
|
} // resolve
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -89,22 +89,22 @@ public final class AbilityFactory_Protection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return protectCanPlayAI(af, this);
|
return AbilityFactory_Protection.protectCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return protectStackDescription(af, this);
|
return AbilityFactory_Protection.protectStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
protectResolve(af, this);
|
AbilityFactory_Protection.protectResolve(af, this);
|
||||||
} // resolve()
|
} // resolve()
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return protectTriggerAI(af, this, mandatory);
|
return AbilityFactory_Protection.protectTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
@@ -122,32 +122,32 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createDrawbackProtection(final AbilityFactory af) {
|
public static SpellAbility createDrawbackProtection(final AbilityFactory af) {
|
||||||
SpellAbility dbProtect = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
final SpellAbility dbProtect = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 8342800124705819366L;
|
private static final long serialVersionUID = 8342800124705819366L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return protectCanPlayAI(af, this);
|
return AbilityFactory_Protection.protectCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return protectStackDescription(af, this);
|
return AbilityFactory_Protection.protectStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
protectResolve(af, this);
|
AbilityFactory_Protection.protectResolve(af, this);
|
||||||
} // resolve
|
} // resolve
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return protectDrawbackAI(af, this);
|
return AbilityFactory_Protection.protectDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return protectTriggerAI(af, this, mandatory);
|
return AbilityFactory_Protection.protectTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -155,22 +155,22 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasProtectionFrom(final Card card, final String color) {
|
private static boolean hasProtectionFrom(final Card card, final String color) {
|
||||||
ArrayList<String> onlyColors = new ArrayList<String>(Arrays.asList(Constant.Color.ONLY_COLORS));
|
final ArrayList<String> onlyColors = new ArrayList<String>(Arrays.asList(Constant.Color.ONLY_COLORS));
|
||||||
|
|
||||||
// make sure we have a valid color
|
// make sure we have a valid color
|
||||||
if (!onlyColors.contains(color)) {
|
if (!onlyColors.contains(color)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String protection = "Protection from " + color;
|
final String protection = "Protection from " + color;
|
||||||
|
|
||||||
return card.hasKeyword(protection);
|
return card.hasKeyword(protection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasProtectionFromAny(final Card card, final ArrayList<String> colors) {
|
private static boolean hasProtectionFromAny(final Card card, final ArrayList<String> colors) {
|
||||||
boolean protect = false;
|
boolean protect = false;
|
||||||
for (String color : colors) {
|
for (final String color : colors) {
|
||||||
protect |= hasProtectionFrom(card, color);
|
protect |= AbilityFactory_Protection.hasProtectionFrom(card, color);
|
||||||
}
|
}
|
||||||
return protect;
|
return protect;
|
||||||
}
|
}
|
||||||
@@ -181,8 +181,8 @@ public final class AbilityFactory_Protection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String color : colors) {
|
for (final String color : colors) {
|
||||||
protect &= hasProtectionFrom(card, color);
|
protect &= AbilityFactory_Protection.hasProtectionFrom(card, color);
|
||||||
}
|
}
|
||||||
return protect;
|
return protect;
|
||||||
}
|
}
|
||||||
@@ -198,17 +198,18 @@ public final class AbilityFactory_Protection {
|
|||||||
*/
|
*/
|
||||||
private static CardList getProtectCreatures(final AbilityFactory af, final SpellAbility sa) {
|
private static CardList getProtectCreatures(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
final ArrayList<String> gains = getProtectionList(hostCard, af.getMapParams());
|
final ArrayList<String> gains = AbilityFactory_Protection.getProtectionList(hostCard, af.getMapParams());
|
||||||
|
|
||||||
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
|
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
if (!CardFactoryUtil.canTarget(hostCard, c)) {
|
if (!CardFactoryUtil.canTarget(hostCard, c)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't add duplicate protections
|
// Don't add duplicate protections
|
||||||
if (hasProtectionFromAll(c, gains)) {
|
if (AbilityFactory_Protection.hasProtectionFromAll(c, gains)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,14 +253,14 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean protectCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean protectCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
// if there is no target and host card isn't in play, don't activate
|
// if there is no target and host card isn't in play, don't activate
|
||||||
if (af.getAbTgt() == null && !AllZoneUtil.isCardInPlay(hostCard)) {
|
if ((af.getAbTgt() == null) && !AllZoneUtil.isCardInPlay(hostCard)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4)) {
|
if (!CostUtil.checkLifeCost(cost, hostCard, 4)) {
|
||||||
@@ -279,7 +280,7 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Phase Restrictions
|
// Phase Restrictions
|
||||||
if (AllZone.getStack().size() == 0 && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
if ((AllZone.getStack().size() == 0) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_FIRST_STRIKE_DAMAGE)) {
|
||||||
// Instant-speed protections should not be cast outside of combat
|
// Instant-speed protections should not be cast outside of combat
|
||||||
// when the stack is empty
|
// when the stack is empty
|
||||||
if (!AbilityFactory.isSorcerySpeed(sa)) {
|
if (!AbilityFactory.isSorcerySpeed(sa)) {
|
||||||
@@ -291,8 +292,8 @@ public final class AbilityFactory_Protection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (af.getAbTgt() == null || !af.getAbTgt().doesTarget()) {
|
if ((af.getAbTgt() == null) || !af.getAbTgt().doesTarget()) {
|
||||||
ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
final ArrayList<Card> cards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
|
|
||||||
if (cards.size() == 0) {
|
if (cards.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -306,7 +307,7 @@ public final class AbilityFactory_Protection {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
return protectTgtAI(af, sa, false);
|
return AbilityFactory_Protection.protectTgtAI(af, sa, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -330,11 +331,11 @@ public final class AbilityFactory_Protection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
CardList list = getProtectCreatures(af, sa);
|
CardList list = AbilityFactory_Protection.getProtectCreatures(af, sa);
|
||||||
|
|
||||||
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
@@ -352,7 +353,7 @@ public final class AbilityFactory_Protection {
|
|||||||
if (AllZone.getStack().size() == 0) {
|
if (AllZone.getStack().size() == 0) {
|
||||||
// If the cost is tapping, don't activate before declare
|
// If the cost is tapping, don't activate before declare
|
||||||
// attack/block
|
// attack/block
|
||||||
if (sa.getPayCosts() != null && sa.getPayCosts().getTap()) {
|
if ((sa.getPayCosts() != null) && sa.getPayCosts().getTap()) {
|
||||||
if (AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
if (AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
|
||||||
&& AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
|
&& AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
|
||||||
list.remove(sa.getSourceCard());
|
list.remove(sa.getSourceCard());
|
||||||
@@ -365,7 +366,7 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return mandatory && protectMandatoryTarget(af, sa, mandatory);
|
return mandatory && AbilityFactory_Protection.protectMandatoryTarget(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||||
@@ -373,9 +374,9 @@ public final class AbilityFactory_Protection {
|
|||||||
// boolean goodt = false;
|
// boolean goodt = false;
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
if (tgt.getNumTargeted() < tgt.getMinTargets(source, sa) || tgt.getNumTargeted() == 0) {
|
if ((tgt.getNumTargeted() < tgt.getMinTargets(source, sa)) || (tgt.getNumTargeted() == 0)) {
|
||||||
if (mandatory) {
|
if (mandatory) {
|
||||||
return protectMandatoryTarget(af, sa, mandatory);
|
return AbilityFactory_Protection.protectMandatoryTarget(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
@@ -413,7 +414,7 @@ public final class AbilityFactory_Protection {
|
|||||||
final Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
|
||||||
@@ -422,24 +423,28 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove anything that's already been targeted
|
// Remove anything that's already been targeted
|
||||||
for (Card c : tgt.getTargetCards()) {
|
for (final Card c : tgt.getTargetCards()) {
|
||||||
list.remove(c);
|
list.remove(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList pref = list.getController(AllZone.getComputerPlayer());
|
CardList pref = list.getController(AllZone.getComputerPlayer());
|
||||||
pref = pref.filter(new CardListFilter() {
|
pref = pref.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return !hasProtectionFromAll(c, getProtectionList(host, params));
|
return !AbilityFactory_Protection.hasProtectionFromAll(c,
|
||||||
|
AbilityFactory_Protection.getProtectionList(host, params));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CardList pref2 = list.getController(AllZone.getComputerPlayer());
|
final CardList pref2 = list.getController(AllZone.getComputerPlayer());
|
||||||
pref = pref.filter(new CardListFilter() {
|
pref = pref.filter(new CardListFilter() {
|
||||||
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return !hasProtectionFromAny(c, getProtectionList(host, params));
|
return !AbilityFactory_Protection.hasProtectionFromAny(c,
|
||||||
|
AbilityFactory_Protection.getProtectionList(host, params));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CardList forced = list.getController(AllZone.getHumanPlayer());
|
final CardList forced = list.getController(AllZone.getHumanPlayer());
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||||
if (pref.isEmpty()) {
|
if (pref.isEmpty()) {
|
||||||
@@ -523,7 +528,7 @@ public final class AbilityFactory_Protection {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return protectTgtAI(af, sa, mandatory);
|
return AbilityFactory_Protection.protectTgtAI(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -541,14 +546,14 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean protectDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean protectDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
if (af.getAbTgt() == null || !af.getAbTgt().doesTarget()) {
|
if ((af.getAbTgt() == null) || !af.getAbTgt().doesTarget()) {
|
||||||
if (host.isCreature()) {
|
if (host.isCreature()) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return protectTgtAI(af, sa, false);
|
return AbilityFactory_Protection.protectTgtAI(af, sa, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -566,17 +571,17 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String protectStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String protectStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
final ArrayList<String> gains = getProtectionList(host, params);
|
final ArrayList<String> gains = AbilityFactory_Protection.getProtectionList(host, params);
|
||||||
boolean choose = (params.containsKey("Choices")) ? true : false;
|
final boolean choose = (params.containsKey("Choices")) ? true : false;
|
||||||
String joiner = choose ? "or" : "and";
|
final String joiner = choose ? "or" : "and";
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -591,9 +596,9 @@ public final class AbilityFactory_Protection {
|
|||||||
sb.append(host).append(" - ");
|
sb.append(host).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
final Iterator<Card> it = tgtCards.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Card tgtC = it.next();
|
final Card tgtC = it.next();
|
||||||
if (tgtC.isFaceDown()) {
|
if (tgtC.isFaceDown()) {
|
||||||
sb.append("Morph");
|
sb.append("Morph");
|
||||||
} else {
|
} else {
|
||||||
@@ -605,7 +610,7 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (af.getMapParams().containsKey("Radiance") && sa.getTarget() != null) {
|
if (af.getMapParams().containsKey("Radiance") && (sa.getTarget() != null)) {
|
||||||
sb.append(" and each other ").append(af.getMapParams().get("ValidTgts"))
|
sb.append(" and each other ").append(af.getMapParams().get("ValidTgts"))
|
||||||
.append(" that shares a color with ");
|
.append(" that shares a color with ");
|
||||||
if (tgtCards.size() > 1) {
|
if (tgtCards.size() > 1) {
|
||||||
@@ -630,7 +635,7 @@ public final class AbilityFactory_Protection {
|
|||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == gains.size() - 1) {
|
if (i == (gains.size() - 1)) {
|
||||||
sb.append(joiner).append(" ");
|
sb.append(joiner).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,7 +649,7 @@ public final class AbilityFactory_Protection {
|
|||||||
sb.append(".");
|
sb.append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -663,24 +668,24 @@ public final class AbilityFactory_Protection {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void protectResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void protectResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
boolean isChoice = params.get("Gains").contains("Choice");
|
final boolean isChoice = params.get("Gains").contains("Choice");
|
||||||
ArrayList<String> choices = getProtectionList(host, params);
|
final ArrayList<String> choices = AbilityFactory_Protection.getProtectionList(host, params);
|
||||||
final ArrayList<String> gains = new ArrayList<String>();
|
final ArrayList<String> gains = new ArrayList<String>();
|
||||||
if (isChoice) {
|
if (isChoice) {
|
||||||
if (sa.getActivatingPlayer().isHuman()) {
|
if (sa.getActivatingPlayer().isHuman()) {
|
||||||
Object o = GuiUtils.getChoice("Choose a protection", choices.toArray());
|
final Object o = GuiUtils.getChoice("Choose a protection", choices.toArray());
|
||||||
|
|
||||||
if (null == o) {
|
if (null == o) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String choice = (String) o;
|
final String choice = (String) o;
|
||||||
gains.add(choice);
|
gains.add(choice);
|
||||||
} else {
|
} else {
|
||||||
// TODO - needs improvement
|
// TODO - needs improvement
|
||||||
String choice = choices.get(0);
|
final String choice = choices.get(0);
|
||||||
gains.add(choice);
|
gains.add(choice);
|
||||||
JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE);
|
||||||
}
|
}
|
||||||
@@ -689,21 +694,22 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
final ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
tgtCards = AbilityFactory.getDefinedCards(host, params.get("Defined"), sa);
|
tgtCards = AbilityFactory.getDefinedCards(host, params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("Radiance") && tgt != null) {
|
if (params.containsKey("Radiance") && (tgt != null)) {
|
||||||
for (Card c : CardUtil.getRadiance(af.getHostCard(), tgtCards.get(0), params.get("ValidTgts").split(","))) {
|
for (final Card c : CardUtil.getRadiance(af.getHostCard(), tgtCards.get(0),
|
||||||
|
params.get("ValidTgts").split(","))) {
|
||||||
untargetedCards.add(c);
|
untargetedCards.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = tgtCards.size();
|
final int size = tgtCards.size();
|
||||||
for (int j = 0; j < size; j++) {
|
for (int j = 0; j < size; j++) {
|
||||||
final Card tgtC = tgtCards.get(j);
|
final Card tgtC = tgtCards.get(j);
|
||||||
|
|
||||||
@@ -713,11 +719,11 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if this is a target, make sure we can still target now
|
// if this is a target, make sure we can still target now
|
||||||
if (tgt != null && !CardFactoryUtil.canTarget(host, tgtC)) {
|
if ((tgt != null) && !CardFactoryUtil.canTarget(host, tgtC)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String gain : gains) {
|
for (final String gain : gains) {
|
||||||
tgtC.addExtrinsicKeyword("Protection from " + gain);
|
tgtC.addExtrinsicKeyword("Protection from " + gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,9 +732,10 @@ public final class AbilityFactory_Protection {
|
|||||||
final Command untilEOT = new Command() {
|
final Command untilEOT = new Command() {
|
||||||
private static final long serialVersionUID = 7682700789217703789L;
|
private static final long serialVersionUID = 7682700789217703789L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
||||||
for (String gain : gains) {
|
for (final String gain : gains) {
|
||||||
tgtC.removeExtrinsicKeyword("Protection from " + gain);
|
tgtC.removeExtrinsicKeyword("Protection from " + gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -748,7 +755,7 @@ public final class AbilityFactory_Protection {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String gain : gains) {
|
for (final String gain : gains) {
|
||||||
unTgtC.addExtrinsicKeyword("Protection from " + gain);
|
unTgtC.addExtrinsicKeyword("Protection from " + gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,9 +764,10 @@ public final class AbilityFactory_Protection {
|
|||||||
final Command untilEOT = new Command() {
|
final Command untilEOT = new Command() {
|
||||||
private static final long serialVersionUID = 7682700789217703789L;
|
private static final long serialVersionUID = 7682700789217703789L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZoneUtil.isCardInPlay(unTgtC)) {
|
if (AllZoneUtil.isCardInPlay(unTgtC)) {
|
||||||
for (String gain : gains) {
|
for (final String gain : gains) {
|
||||||
unTgtC.removeExtrinsicKeyword("Protection from " + gain);
|
unTgtC.removeExtrinsicKeyword("Protection from " + gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -777,7 +785,7 @@ public final class AbilityFactory_Protection {
|
|||||||
private static ArrayList<String> getProtectionList(final Card host, final HashMap<String, String> params) {
|
private static ArrayList<String> getProtectionList(final Card host, final HashMap<String, String> params) {
|
||||||
final ArrayList<String> gains = new ArrayList<String>();
|
final ArrayList<String> gains = new ArrayList<String>();
|
||||||
|
|
||||||
String gainStr = params.get("Gains");
|
final String gainStr = params.get("Gains");
|
||||||
if (gainStr.equals("Choice")) {
|
if (gainStr.equals("Choice")) {
|
||||||
String choices = params.get("Choices");
|
String choices = params.get("Choices");
|
||||||
|
|
||||||
@@ -809,22 +817,22 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createSpellProtectionAll(final AbilityFactory af) {
|
public static SpellAbility createSpellProtectionAll(final AbilityFactory af) {
|
||||||
SpellAbility spProtectAll = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
final SpellAbility spProtectAll = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 7205636088393235571L;
|
private static final long serialVersionUID = 7205636088393235571L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return protectAllCanPlayAI(af, this);
|
return AbilityFactory_Protection.protectAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return protectAllStackDescription(af, this);
|
return AbilityFactory_Protection.protectAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
protectAllResolve(af, this);
|
AbilityFactory_Protection.protectAllResolve(af, this);
|
||||||
} // resolve
|
} // resolve
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -846,22 +854,22 @@ public final class AbilityFactory_Protection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return protectAllCanPlayAI(af, this);
|
return AbilityFactory_Protection.protectAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return protectAllStackDescription(af, this);
|
return AbilityFactory_Protection.protectAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
protectAllResolve(af, this);
|
AbilityFactory_Protection.protectAllResolve(af, this);
|
||||||
} // resolve()
|
} // resolve()
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return protectAllTriggerAI(af, this, mandatory);
|
return AbilityFactory_Protection.protectAllTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
@@ -879,32 +887,32 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static SpellAbility createDrawbackProtectionAll(final AbilityFactory af) {
|
public static SpellAbility createDrawbackProtectionAll(final AbilityFactory af) {
|
||||||
SpellAbility dbProtectAll = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
final SpellAbility dbProtectAll = new Ability_Sub(af.getHostCard(), af.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 5096939345199247701L;
|
private static final long serialVersionUID = 5096939345199247701L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return protectAllCanPlayAI(af, this);
|
return AbilityFactory_Protection.protectAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return protectAllStackDescription(af, this);
|
return AbilityFactory_Protection.protectAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
protectAllResolve(af, this);
|
AbilityFactory_Protection.protectAllResolve(af, this);
|
||||||
} // resolve
|
} // resolve
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return protectAllDrawbackAI(af, this);
|
return AbilityFactory_Protection.protectAllDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return protectAllTriggerAI(af, this, mandatory);
|
return AbilityFactory_Protection.protectAllTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
}; // SpellAbility
|
}; // SpellAbility
|
||||||
|
|
||||||
@@ -923,13 +931,13 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean protectAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean protectAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
// if there is no target and host card isn't in play, don't activate
|
// if there is no target and host card isn't in play, don't activate
|
||||||
if (af.getAbTgt() == null && !AllZoneUtil.isCardInPlay(hostCard)) {
|
if ((af.getAbTgt() == null) && !AllZoneUtil.isCardInPlay(hostCard)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4)) {
|
if (!CostUtil.checkLifeCost(cost, hostCard, 4)) {
|
||||||
@@ -984,7 +992,7 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean protectAllDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean protectAllDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
return protectAllTriggerAI(af, sa, false);
|
return AbilityFactory_Protection.protectAllTriggerAI(af, sa, false);
|
||||||
} // protectAllDrawbackAI()
|
} // protectAllDrawbackAI()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -999,13 +1007,13 @@ public final class AbilityFactory_Protection {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String protectAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String protectAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -1031,7 +1039,7 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -1050,30 +1058,30 @@ public final class AbilityFactory_Protection {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void protectAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void protectAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
boolean isChoice = params.get("Gains").contains("Choice");
|
final boolean isChoice = params.get("Gains").contains("Choice");
|
||||||
ArrayList<String> choices = getProtectionList(host, params);
|
final ArrayList<String> choices = AbilityFactory_Protection.getProtectionList(host, params);
|
||||||
final ArrayList<String> gains = new ArrayList<String>();
|
final ArrayList<String> gains = new ArrayList<String>();
|
||||||
if (isChoice) {
|
if (isChoice) {
|
||||||
if (sa.getActivatingPlayer().isHuman()) {
|
if (sa.getActivatingPlayer().isHuman()) {
|
||||||
Object o = GuiUtils.getChoice("Choose a protection", choices.toArray());
|
final Object o = GuiUtils.getChoice("Choose a protection", choices.toArray());
|
||||||
|
|
||||||
if (null == o) {
|
if (null == o) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String choice = (String) o;
|
final String choice = (String) o;
|
||||||
gains.add(choice);
|
gains.add(choice);
|
||||||
} else {
|
} else {
|
||||||
// TODO - needs improvement
|
// TODO - needs improvement
|
||||||
String choice = choices.get(0);
|
final String choice = choices.get(0);
|
||||||
gains.add(choice);
|
gains.add(choice);
|
||||||
JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Computer chooses " + gains, "" + host, JOptionPane.PLAIN_MESSAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (params.get("Gains").equals("ChosenColor")) {
|
if (params.get("Gains").equals("ChosenColor")) {
|
||||||
for (String color : host.getChosenColor()) {
|
for (final String color : host.getChosenColor()) {
|
||||||
gains.add(color.toLowerCase());
|
gains.add(color.toLowerCase());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1081,13 +1089,13 @@ public final class AbilityFactory_Protection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String valid = params.get("ValidCards");
|
final String valid = params.get("ValidCards");
|
||||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(valid, sa.getActivatingPlayer(), host);
|
list = list.getValidCards(valid, sa.getActivatingPlayer(), host);
|
||||||
|
|
||||||
for (final Card tgtC : list) {
|
for (final Card tgtC : list) {
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
||||||
for (String gain : gains) {
|
for (final String gain : gains) {
|
||||||
tgtC.addExtrinsicKeyword("Protection from " + gain);
|
tgtC.addExtrinsicKeyword("Protection from " + gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1096,9 +1104,10 @@ public final class AbilityFactory_Protection {
|
|||||||
final Command untilEOT = new Command() {
|
final Command untilEOT = new Command() {
|
||||||
private static final long serialVersionUID = -6573962672873853565L;
|
private static final long serialVersionUID = -6573962672873853565L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
if (AllZoneUtil.isCardInPlay(tgtC)) {
|
||||||
for (String gain : gains) {
|
for (final String gain : gains) {
|
||||||
tgtC.removeExtrinsicKeyword("Protection from " + gain);
|
tgtC.removeExtrinsicKeyword("Protection from " + gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -57,22 +57,22 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return regenerateCanPlayAI(af, this);
|
return AbilityFactory_Regenerate.regenerateCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
regenerateResolve(af, this);
|
AbilityFactory_Regenerate.regenerateResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return regenerateStackDescription(af, this);
|
return AbilityFactory_Regenerate.regenerateStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return doTriggerAI(af, this, mandatory);
|
return AbilityFactory_Regenerate.doTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Ability_Activated
|
}; // Ability_Activated
|
||||||
@@ -96,17 +96,17 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return regenerateCanPlayAI(af, this);
|
return AbilityFactory_Regenerate.regenerateCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
regenerateResolve(af, this);
|
AbilityFactory_Regenerate.regenerateResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return regenerateStackDescription(af, this);
|
return AbilityFactory_Regenerate.regenerateStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Spell
|
}; // Spell
|
||||||
@@ -129,12 +129,12 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return regenerateStackDescription(af, this);
|
return AbilityFactory_Regenerate.regenerateStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
regenerateResolve(af, this);
|
AbilityFactory_Regenerate.regenerateResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,7 +144,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return doTriggerAI(af, this, mandatory);
|
return AbilityFactory_Regenerate.doTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -164,11 +164,11 @@ public class AbilityFactory_Regenerate {
|
|||||||
*/
|
*/
|
||||||
private static String regenerateStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String regenerateStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -183,9 +183,9 @@ public class AbilityFactory_Regenerate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb.append("Regenerate ");
|
sb.append("Regenerate ");
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
final Iterator<Card> it = tgtCards.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Card tgtC = it.next();
|
final Card tgtC = it.next();
|
||||||
if (tgtC.isFaceDown()) {
|
if (tgtC.isFaceDown()) {
|
||||||
sb.append("Morph");
|
sb.append("Morph");
|
||||||
} else {
|
} else {
|
||||||
@@ -199,7 +199,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
boolean chance = false;
|
boolean chance = false;
|
||||||
Cost abCost = af.getAbCost();
|
final Cost abCost = af.getAbCost();
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, hostCard, 4)) {
|
if (!CostUtil.checkLifeCost(abCost, hostCard, 4)) {
|
||||||
@@ -238,16 +238,16 @@ public class AbilityFactory_Regenerate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// As far as I can tell these Defined Cards will only have one of
|
// As far as I can tell these Defined Cards will only have one of
|
||||||
// them
|
// them
|
||||||
ArrayList<Card> list = AbilityFactory.getDefinedCards(hostCard, params.get("Defined"), sa);
|
final ArrayList<Card> list = AbilityFactory.getDefinedCards(hostCard, params.get("Defined"), sa);
|
||||||
|
|
||||||
if (AllZone.getStack().size() > 0) {
|
if (AllZone.getStack().size() > 0) {
|
||||||
ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(af);
|
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(af);
|
||||||
|
|
||||||
for (Card c : list) {
|
for (final Card c : list) {
|
||||||
if (objects.contains(c)) {
|
if (objects.contains(c)) {
|
||||||
chance = true;
|
chance = true;
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
||||||
for (Card c : list) {
|
for (final Card c : list) {
|
||||||
if (c.getShield() == 0) {
|
if (c.getShield() == 0) {
|
||||||
flag |= CombatUtil.combatantWouldBeDestroyed(c);
|
flag |= CombatUtil.combatantWouldBeDestroyed(c);
|
||||||
}
|
}
|
||||||
@@ -281,12 +281,12 @@ public class AbilityFactory_Regenerate {
|
|||||||
if (AllZone.getStack().size() > 0) {
|
if (AllZone.getStack().size() > 0) {
|
||||||
// check stack for something on the stack will kill anything i
|
// check stack for something on the stack will kill anything i
|
||||||
// control
|
// control
|
||||||
ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(af);
|
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(af);
|
||||||
|
|
||||||
CardList threatenedTargets = new CardList();
|
final CardList threatenedTargets = new CardList();
|
||||||
|
|
||||||
for (Card c : targetables) {
|
for (final Card c : targetables) {
|
||||||
if (objects.contains(c) && c.getShield() == 0) {
|
if (objects.contains(c) && (c.getShield() == 0)) {
|
||||||
threatenedTargets.add(c);
|
threatenedTargets.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,11 +298,11 @@ public class AbilityFactory_Regenerate {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||||
CardList combatants = targetables.getType("Creature");
|
final CardList combatants = targetables.getType("Creature");
|
||||||
CardListUtil.sortByEvaluateCreature(combatants);
|
CardListUtil.sortByEvaluateCreature(combatants);
|
||||||
|
|
||||||
for (Card c : combatants) {
|
for (final Card c : combatants) {
|
||||||
if (c.getShield() == 0 && CombatUtil.combatantWouldBeDestroyed(c)) {
|
if ((c.getShield() == 0) && CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
chance = true;
|
chance = true;
|
||||||
break;
|
break;
|
||||||
@@ -312,7 +312,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -340,15 +340,15 @@ public class AbilityFactory_Regenerate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// If there's no target on the trigger, just say yes.
|
// If there's no target on the trigger, just say yes.
|
||||||
chance = true;
|
chance = true;
|
||||||
} else {
|
} else {
|
||||||
chance = regenMandatoryTarget(af, sa, mandatory);
|
chance = AbilityFactory_Regenerate.regenMandatoryTarget(af, sa, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.doTrigger(mandatory);
|
chance &= subAb.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -371,27 +371,27 @@ public class AbilityFactory_Regenerate {
|
|||||||
*/
|
*/
|
||||||
private static boolean regenMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean regenMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
final Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
// filter AIs battlefield by what I can target
|
// filter AIs battlefield by what I can target
|
||||||
CardList targetables = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList targetables = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard);
|
||||||
CardList compTargetables = targetables.getController(AllZone.getComputerPlayer());
|
final CardList compTargetables = targetables.getController(AllZone.getComputerPlayer());
|
||||||
|
|
||||||
if (targetables.size() == 0) {
|
if (targetables.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mandatory && compTargetables.size() == 0) {
|
if (!mandatory && (compTargetables.size() == 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compTargetables.size() > 0) {
|
if (compTargetables.size() > 0) {
|
||||||
CardList combatants = compTargetables.getType("Creature");
|
final CardList combatants = compTargetables.getType("Creature");
|
||||||
CardListUtil.sortByEvaluateCreature(combatants);
|
CardListUtil.sortByEvaluateCreature(combatants);
|
||||||
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||||
for (Card c : combatants) {
|
for (final Card c : combatants) {
|
||||||
if (c.getShield() == 0 && CombatUtil.combatantWouldBeDestroyed(c)) {
|
if ((c.getShield() == 0) && CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
// choose my best X without regen
|
// choose my best X without regen
|
||||||
if (compTargetables.getNotType("Creature").size() == 0) {
|
if (compTargetables.getNotType("Creature").size() == 0) {
|
||||||
for (Card c : combatants) {
|
for (final Card c : combatants) {
|
||||||
if (c.getShield() == 0) {
|
if (c.getShield() == 0) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
return true;
|
return true;
|
||||||
@@ -413,7 +413,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
CardListUtil.sortByMostExpensive(compTargetables);
|
CardListUtil.sortByMostExpensive(compTargetables);
|
||||||
for (Card c : compTargetables) {
|
for (final Card c : compTargetables) {
|
||||||
if (c.getShield() == 0) {
|
if (c.getShield() == 0) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
return true;
|
return true;
|
||||||
@@ -439,11 +439,11 @@ public class AbilityFactory_Regenerate {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void regenerateResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void regenerateResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
} else {
|
} else {
|
||||||
@@ -454,12 +454,13 @@ public class AbilityFactory_Regenerate {
|
|||||||
final Command untilEOT = new Command() {
|
final Command untilEOT = new Command() {
|
||||||
private static final long serialVersionUID = 1922050611313909200L;
|
private static final long serialVersionUID = 1922050611313909200L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
tgtC.resetShield();
|
tgtC.resetShield();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (AllZoneUtil.isCardInPlay(tgtC) && (tgt == null || CardFactoryUtil.canTarget(hostCard, tgtC))) {
|
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || CardFactoryUtil.canTarget(hostCard, tgtC))) {
|
||||||
tgtC.addShield();
|
tgtC.addShield();
|
||||||
AllZone.getEndOfTurn().addUntil(untilEOT);
|
AllZone.getEndOfTurn().addUntil(untilEOT);
|
||||||
}
|
}
|
||||||
@@ -486,22 +487,22 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return regenerateAllCanPlayAI(af, this);
|
return AbilityFactory_Regenerate.regenerateAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
regenerateAllResolve(af, this);
|
AbilityFactory_Regenerate.regenerateAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return regenerateAllStackDescription(af, this);
|
return AbilityFactory_Regenerate.regenerateAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return regenerateAllDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_Regenerate.regenerateAllDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Ability_Activated
|
}; // Ability_Activated
|
||||||
@@ -525,17 +526,17 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return regenerateAllCanPlayAI(af, this);
|
return AbilityFactory_Regenerate.regenerateAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
regenerateAllResolve(af, this);
|
AbilityFactory_Regenerate.regenerateAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return regenerateAllStackDescription(af, this);
|
return AbilityFactory_Regenerate.regenerateAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Spell
|
}; // Spell
|
||||||
@@ -558,12 +559,12 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return regenerateAllStackDescription(af, this);
|
return AbilityFactory_Regenerate.regenerateAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
regenerateAllResolve(af, this);
|
AbilityFactory_Regenerate.regenerateAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -573,7 +574,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return regenerateAllDoTriggerAI(af, this, mandatory);
|
return AbilityFactory_Regenerate.regenerateAllDoTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -593,8 +594,8 @@ public class AbilityFactory_Regenerate {
|
|||||||
*/
|
*/
|
||||||
private static String regenerateAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String regenerateAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -611,7 +612,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
|
|
||||||
sb.append(desc);
|
sb.append(desc);
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -634,7 +635,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
final Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
boolean chance = false;
|
boolean chance = false;
|
||||||
Cost abCost = af.getAbCost();
|
final Cost abCost = af.getAbCost();
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkSacrificeCost(abCost, hostCard)) {
|
if (!CostUtil.checkSacrificeCost(abCost, hostCard)) {
|
||||||
@@ -671,10 +672,10 @@ public class AbilityFactory_Regenerate {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
if (AllZone.getPhase().is(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) {
|
||||||
CardList combatants = list.getType("Creature");
|
final CardList combatants = list.getType("Creature");
|
||||||
|
|
||||||
for (Card c : combatants) {
|
for (final Card c : combatants) {
|
||||||
if (c.getShield() == 0 && CombatUtil.combatantWouldBeDestroyed(c)) {
|
if ((c.getShield() == 0) && CombatUtil.combatantWouldBeDestroyed(c)) {
|
||||||
numSaved++;
|
numSaved++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -685,7 +686,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
chance = true;
|
chance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -706,14 +707,15 @@ public class AbilityFactory_Regenerate {
|
|||||||
* a boolean.
|
* a boolean.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean regenerateAllDoTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean regenerateAllDoTriggerAI(final AbilityFactory af, final SpellAbility sa,
|
||||||
|
final boolean mandatory) {
|
||||||
boolean chance = true;
|
boolean chance = true;
|
||||||
|
|
||||||
if (!ComputerUtil.canPayCost(sa)) {
|
if (!ComputerUtil.canPayCost(sa)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.doTrigger(mandatory);
|
chance &= subAb.doTrigger(mandatory);
|
||||||
}
|
}
|
||||||
@@ -732,7 +734,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void regenerateAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void regenerateAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
Card hostCard = af.getHostCard();
|
final Card hostCard = af.getHostCard();
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
String valid = "";
|
String valid = "";
|
||||||
|
|
||||||
@@ -747,6 +749,7 @@ public class AbilityFactory_Regenerate {
|
|||||||
final Command untilEOT = new Command() {
|
final Command untilEOT = new Command() {
|
||||||
private static final long serialVersionUID = 259368227093961103L;
|
private static final long serialVersionUID = 259368227093961103L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
c.resetShield();
|
c.resetShield();
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -51,22 +51,22 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return sacrificeCanPlayAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificeCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
sacrificeResolve(af, this);
|
AbilityFactory_Sacrifice.sacrificeResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return sacrificeDescription(af, this);
|
return AbilityFactory_Sacrifice.sacrificeDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return sacrificeTriggerAI(af, this, mandatory);
|
return AbilityFactory_Sacrifice.sacrificeTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return abSacrifice;
|
return abSacrifice;
|
||||||
@@ -87,17 +87,17 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return sacrificeCanPlayAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificeCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
sacrificeResolve(af, this);
|
AbilityFactory_Sacrifice.sacrificeResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return sacrificeDescription(af, this);
|
return AbilityFactory_Sacrifice.sacrificeDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return spSacrifice;
|
return spSacrifice;
|
||||||
@@ -118,22 +118,22 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
sacrificeResolve(af, this);
|
AbilityFactory_Sacrifice.sacrificeResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chkAIDrawback() {
|
public boolean chkAIDrawback() {
|
||||||
return sacrificePlayDrawbackAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificePlayDrawbackAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return sacrificeDescription(af, this);
|
return AbilityFactory_Sacrifice.sacrificeDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return sacrificeTriggerAI(af, this, mandatory);
|
return AbilityFactory_Sacrifice.sacrificeTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return dbSacrifice;
|
return dbSacrifice;
|
||||||
@@ -151,8 +151,8 @@ public class AbilityFactory_Sacrifice {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String sacrificeDescription(final AbilityFactory af, final SpellAbility sa) {
|
public static String sacrificeDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -160,12 +160,12 @@ public class AbilityFactory_Sacrifice {
|
|||||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String conditionDesc = params.get("ConditionDescription");
|
final String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
ArrayList<Player> tgts;
|
ArrayList<Player> tgts;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgts = tgt.getTargetPlayers();
|
tgts = tgt.getTargetPlayers();
|
||||||
@@ -180,16 +180,17 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
String num = params.get("Amount");
|
String num = params.get("Amount");
|
||||||
num = (num == null) ? "1" : num;
|
num = (num == null) ? "1" : num;
|
||||||
int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa);
|
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa);
|
||||||
|
|
||||||
if (valid.equals("Self")) {
|
if (valid.equals("Self")) {
|
||||||
sb.append("Sacrifice ").append(sa.getSourceCard().toString());
|
sb.append("Sacrifice ").append(sa.getSourceCard().toString());
|
||||||
} else if (valid.equals("Card.AttachedBy")) {
|
} else if (valid.equals("Card.AttachedBy")) {
|
||||||
Card toSac = sa.getSourceCard().getEnchantingCard();
|
final Card toSac = sa.getSourceCard().getEnchantingCard();
|
||||||
sb.append(toSac.getController()).append(" sacrifices ").append(toSac).append(".");
|
sb.append(toSac.getController()).append(" sacrifices ").append(toSac).append(".");
|
||||||
} else {
|
} else {
|
||||||
for (Player p : tgts)
|
for (final Player p : tgts) {
|
||||||
sb.append(p.getName()).append(" ");
|
sb.append(p.getName()).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
String msg = params.get("SacMessage");
|
String msg = params.get("SacMessage");
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
@@ -199,7 +200,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
sb.append("Sacrifices ").append(amount).append(" ").append(msg).append(".");
|
sb.append("Sacrifices ").append(amount).append(" ").append(msg).append(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -220,17 +221,17 @@ public class AbilityFactory_Sacrifice {
|
|||||||
*/
|
*/
|
||||||
public static boolean sacrificeCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
public static boolean sacrificeCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
boolean chance = sacrificeTgtAI(af, sa);
|
boolean chance = AbilityFactory_Sacrifice.sacrificeTgtAI(af, sa);
|
||||||
|
|
||||||
// Some additional checks based on what is being sacrificed, and who is
|
// Some additional checks based on what is being sacrificed, and who is
|
||||||
// sacrificing
|
// sacrificing
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
String valid = params.get("SacValid");
|
final String valid = params.get("SacValid");
|
||||||
String num = params.get("Amount");
|
String num = params.get("Amount");
|
||||||
num = (num == null) ? "1" : num;
|
num = (num == null) ? "1" : num;
|
||||||
int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa);
|
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa);
|
||||||
|
|
||||||
CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
@@ -239,14 +240,15 @@ public class AbilityFactory_Sacrifice {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
if (num.equals("X") && source.getSVar(num).equals("Count$xPaid")) {
|
if (num.equals("X") && source.getSVar(num).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
int xPay = Math.min(ComputerUtil.determineLeftoverMana(sa), amount);
|
final int xPay = Math.min(ComputerUtil.determineLeftoverMana(sa), amount);
|
||||||
source.setSVar("PayX", Integer.toString(xPay));
|
source.setSVar("PayX", Integer.toString(xPay));
|
||||||
}
|
}
|
||||||
|
|
||||||
int half = amount / 2 + amount % 2; // Half of amount rounded up
|
final int half = (amount / 2) + (amount % 2); // Half of amount
|
||||||
|
// rounded up
|
||||||
|
|
||||||
// If the Human has at least half rounded up of the amount to be
|
// If the Human has at least half rounded up of the amount to be
|
||||||
// sacrificed, cast the spell
|
// sacrificed, cast the spell
|
||||||
@@ -255,7 +257,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -276,11 +278,11 @@ public class AbilityFactory_Sacrifice {
|
|||||||
*/
|
*/
|
||||||
public static boolean sacrificePlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
public static boolean sacrificePlayDrawbackAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI should only activate this during Human's turn
|
// AI should only activate this during Human's turn
|
||||||
boolean chance = sacrificeTgtAI(af, sa);
|
boolean chance = AbilityFactory_Sacrifice.sacrificeTgtAI(af, sa);
|
||||||
|
|
||||||
// TODO: restrict the subAbility a bit
|
// TODO: restrict the subAbility a bit
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -307,7 +309,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AI should only activate this during Human's turn
|
// AI should only activate this during Human's turn
|
||||||
boolean chance = sacrificeTgtAI(af, sa);
|
boolean chance = AbilityFactory_Sacrifice.sacrificeTgtAI(af, sa);
|
||||||
|
|
||||||
// Improve AI for triggers. If source is a creature with:
|
// Improve AI for triggers. If source is a creature with:
|
||||||
// When ETB, sacrifice a creature. Check to see if the AI has something
|
// When ETB, sacrifice a creature. Check to see if the AI has something
|
||||||
@@ -316,7 +318,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
// Eventually, we can call the trigger of ETB abilities with not
|
// Eventually, we can call the trigger of ETB abilities with not
|
||||||
// mandatory as part of the checks to cast something
|
// mandatory as part of the checks to cast something
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -337,9 +339,9 @@ public class AbilityFactory_Sacrifice {
|
|||||||
*/
|
*/
|
||||||
public static boolean sacrificeTgtAI(final AbilityFactory af, final SpellAbility sa) {
|
public static boolean sacrificeTgtAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
|
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
@@ -349,7 +351,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String defined = params.get("Defined");
|
final String defined = params.get("Defined");
|
||||||
if (defined == null) {
|
if (defined == null) {
|
||||||
// Self Sacrifice.
|
// Self Sacrifice.
|
||||||
} else if (defined.equals("Each")) {
|
} else if (defined.equals("Each")) {
|
||||||
@@ -358,11 +360,11 @@ public class AbilityFactory_Sacrifice {
|
|||||||
// Only cast it if AI doesn't have the full amount of Valid
|
// Only cast it if AI doesn't have the full amount of Valid
|
||||||
// TODO: Cast if the type is favorable: my "worst" valid is
|
// TODO: Cast if the type is favorable: my "worst" valid is
|
||||||
// worse than his "worst" valid
|
// worse than his "worst" valid
|
||||||
String valid = params.get("SacValid");
|
final String valid = params.get("SacValid");
|
||||||
String num = params.containsKey("Amount") ? params.get("Amount") : "1";
|
final String num = params.containsKey("Amount") ? params.get("Amount") : "1";
|
||||||
int amount = AbilityFactory.calculateAmount(card, num, sa);
|
int amount = AbilityFactory.calculateAmount(card, num, sa);
|
||||||
|
|
||||||
Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
if (num.equals("X") && source.getSVar(num).equals("Count$xPaid")) {
|
if (num.equals("X") && source.getSVar(num).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
amount = Math.min(ComputerUtil.determineLeftoverMana(sa), amount);
|
amount = Math.min(ComputerUtil.determineLeftoverMana(sa), amount);
|
||||||
@@ -399,14 +401,14 @@ public class AbilityFactory_Sacrifice {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public static void sacrificeResolve(final AbilityFactory af, final SpellAbility sa) {
|
public static void sacrificeResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
// Expand Sacrifice keyword here depending on what we need out of it.
|
// Expand Sacrifice keyword here depending on what we need out of it.
|
||||||
String num = params.containsKey("Amount") ? params.get("Amount") : "1";
|
final String num = params.containsKey("Amount") ? params.get("Amount") : "1";
|
||||||
int amount = AbilityFactory.calculateAmount(card, num, sa);
|
final int amount = AbilityFactory.calculateAmount(card, num, sa);
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
ArrayList<Player> tgts;
|
ArrayList<Player> tgts;
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgts = tgt.getTargetPlayers();
|
tgts = tgt.getTargetPlayers();
|
||||||
@@ -426,7 +428,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
msg = "Sacrifice a " + msg;
|
msg = "Sacrifice a " + msg;
|
||||||
|
|
||||||
boolean remSacrificed = params.containsKey("RememberSacrificed");
|
final boolean remSacrificed = params.containsKey("RememberSacrificed");
|
||||||
if (remSacrificed) {
|
if (remSacrificed) {
|
||||||
card.clearRemembered();
|
card.clearRemembered();
|
||||||
}
|
}
|
||||||
@@ -441,7 +443,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
}
|
}
|
||||||
// TODO - maybe this can be done smarter...
|
// TODO - maybe this can be done smarter...
|
||||||
else if (valid.equals("Card.AttachedBy")) {
|
else if (valid.equals("Card.AttachedBy")) {
|
||||||
Card toSac = card.getEnchantingCard();
|
final Card toSac = card.getEnchantingCard();
|
||||||
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) {
|
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) {
|
||||||
AllZone.getGameAction().sacrifice(toSac);
|
AllZone.getGameAction().sacrifice(toSac);
|
||||||
if (remSacrificed) {
|
if (remSacrificed) {
|
||||||
@@ -449,7 +451,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (valid.equals("TriggeredCard")) {
|
} else if (valid.equals("TriggeredCard")) {
|
||||||
Card equipee = (Card) sa.getTriggeringObject("Card");
|
final Card equipee = (Card) sa.getTriggeringObject("Card");
|
||||||
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
|
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
|
||||||
AllZone.getGameAction().sacrifice(equipee);
|
AllZone.getGameAction().sacrifice(equipee);
|
||||||
if (remSacrificed) {
|
if (remSacrificed) {
|
||||||
@@ -458,7 +460,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CardList sacList = null;
|
CardList sacList = null;
|
||||||
for (Player p : tgts) {
|
for (final Player p : tgts) {
|
||||||
|
|
||||||
// TODO - Can only add cards computer sacrificed to remembered
|
// TODO - Can only add cards computer sacrificed to remembered
|
||||||
// list because
|
// list because
|
||||||
@@ -471,14 +473,14 @@ public class AbilityFactory_Sacrifice {
|
|||||||
// then actually sacrifice the cards in this resolve method.
|
// then actually sacrifice the cards in this resolve method.
|
||||||
// (ArsenalNut 09/20/2011)
|
// (ArsenalNut 09/20/2011)
|
||||||
if (p.isComputer()) {
|
if (p.isComputer()) {
|
||||||
sacList = sacrificeAI(p, amount, valid, sa);
|
sacList = AbilityFactory_Sacrifice.sacrificeAI(p, amount, valid, sa);
|
||||||
if (remSacrificed) {
|
if (remSacrificed) {
|
||||||
for (int i = 0; i < sacList.size(); i++) {
|
for (int i = 0; i < sacList.size(); i++) {
|
||||||
card.addRemembered(sacList.get(i));
|
card.addRemembered(sacList.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sacrificeHuman(p, amount, valid, sa, msg);
|
AbilityFactory_Sacrifice.sacrificeHuman(p, amount, valid, sa, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +506,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
CardList list = p.getCardsIn(Zone.Battlefield);
|
CardList list = p.getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
CardList sacList = ComputerUtil.sacrificePermanents(amount, list);
|
final CardList sacList = ComputerUtil.sacrificePermanents(amount, list);
|
||||||
|
|
||||||
return sacList;
|
return sacList;
|
||||||
}
|
}
|
||||||
@@ -525,7 +527,8 @@ public class AbilityFactory_Sacrifice {
|
|||||||
* @param message
|
* @param message
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static void sacrificeHuman(final Player p, final int amount, final String valid, final SpellAbility sa, final String message) {
|
private static void sacrificeHuman(final Player p, final int amount, final String valid, final SpellAbility sa,
|
||||||
|
final String message) {
|
||||||
CardList list = p.getCardsIn(Zone.Battlefield);
|
CardList list = p.getCardsIn(Zone.Battlefield);
|
||||||
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
|
|
||||||
@@ -554,22 +557,22 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return sacrificeAllCanPlayAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
sacrificeAllResolve(af, this);
|
AbilityFactory_Sacrifice.sacrificeAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return sacrificeAllStackDescription(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return sacrificeAllCanPlayAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return abSacrifice;
|
return abSacrifice;
|
||||||
@@ -591,17 +594,17 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return sacrificeAllCanPlayAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
sacrificeAllResolve(af, this);
|
AbilityFactory_Sacrifice.sacrificeAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return sacrificeAllStackDescription(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return spSacrifice;
|
return spSacrifice;
|
||||||
@@ -623,7 +626,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
sacrificeAllResolve(af, this);
|
AbilityFactory_Sacrifice.sacrificeAllResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -633,12 +636,12 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return sacrificeAllStackDescription(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return sacrificeAllCanPlayAI(af, this);
|
return AbilityFactory_Sacrifice.sacrificeAllCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return dbSacrifice;
|
return dbSacrifice;
|
||||||
@@ -659,9 +662,9 @@ public class AbilityFactory_Sacrifice {
|
|||||||
public static String sacrificeAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
public static String sacrificeAllStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// when getStackDesc is called, just build exactly what is happening
|
// when getStackDesc is called, just build exactly what is happening
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
final Card host = af.getHostCard();
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -669,7 +672,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
sb.append(host).append(" - ");
|
sb.append(host).append(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String conditionDesc = params.get("ConditionDescription");
|
final String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
@@ -685,7 +688,7 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
sb.append("Sacrifice permanents.");
|
sb.append("Sacrifice permanents.");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -708,28 +711,28 @@ public class AbilityFactory_Sacrifice {
|
|||||||
public static boolean sacrificeAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
public static boolean sacrificeAllCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
// AI needs to be expanded, since this function can be pretty complex
|
// AI needs to be expanded, since this function can be pretty complex
|
||||||
// based on what the expected targets could be
|
// based on what the expected targets could be
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
Cost abCost = sa.getPayCosts();
|
final Cost abCost = sa.getPayCosts();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
String Valid = "";
|
String valid = "";
|
||||||
|
|
||||||
if (params.containsKey("ValidCards")) {
|
if (params.containsKey("ValidCards")) {
|
||||||
Valid = params.get("ValidCards");
|
valid = params.get("ValidCards");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Valid.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
if (valid.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
int xPay = ComputerUtil.determineLeftoverMana(sa);
|
final int xPay = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(xPay));
|
source.setSVar("PayX", Integer.toString(xPay));
|
||||||
Valid = Valid.replace("X", Integer.toString(xPay));
|
valid = valid.replace("X", Integer.toString(xPay));
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
|
||||||
CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||||
|
|
||||||
humanlist = humanlist.getValidCards(Valid.split(","), source.getController(), source);
|
humanlist = humanlist.getValidCards(valid.split(","), source.getController(), source);
|
||||||
computerlist = computerlist.getValidCards(Valid.split(","), source.getController(), source);
|
computerlist = computerlist.getValidCards(valid.split(","), source.getController(), source);
|
||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for some costs
|
// AI currently disabled for some costs
|
||||||
@@ -743,25 +746,25 @@ public class AbilityFactory_Sacrifice {
|
|||||||
|
|
||||||
// if only creatures are affected evaluate both lists and pass only if
|
// if only creatures are affected evaluate both lists and pass only if
|
||||||
// human creatures are more valuable
|
// human creatures are more valuable
|
||||||
if (humanlist.getNotType("Creature").size() == 0 && computerlist.getNotType("Creature").size() == 0) {
|
if ((humanlist.getNotType("Creature").size() == 0) && (computerlist.getNotType("Creature").size() == 0)) {
|
||||||
if (CardFactoryUtil.evaluateCreatureList(computerlist) + 200 >= CardFactoryUtil
|
if ((CardFactoryUtil.evaluateCreatureList(computerlist) + 200) >= CardFactoryUtil
|
||||||
.evaluateCreatureList(humanlist)) {
|
.evaluateCreatureList(humanlist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // only lands involved
|
} // only lands involved
|
||||||
else if (humanlist.getNotType("Land").size() == 0 && computerlist.getNotType("Land").size() == 0) {
|
else if ((humanlist.getNotType("Land").size() == 0) && (computerlist.getNotType("Land").size() == 0)) {
|
||||||
if (CardFactoryUtil.evaluatePermanentList(computerlist) + 1 >= CardFactoryUtil
|
if ((CardFactoryUtil.evaluatePermanentList(computerlist) + 1) >= CardFactoryUtil
|
||||||
.evaluatePermanentList(humanlist)) {
|
.evaluatePermanentList(humanlist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // otherwise evaluate both lists by CMC and pass only if human
|
} // otherwise evaluate both lists by CMC and pass only if human
|
||||||
// permanents are more valuable
|
// permanents are more valuable
|
||||||
else if (CardFactoryUtil.evaluatePermanentList(computerlist) + 3 >= CardFactoryUtil
|
else if ((CardFactoryUtil.evaluatePermanentList(computerlist) + 3) >= CardFactoryUtil
|
||||||
.evaluatePermanentList(humanlist)) {
|
.evaluatePermanentList(humanlist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
final Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null) {
|
if (subAb != null) {
|
||||||
chance &= subAb.chkAIDrawback();
|
chance &= subAb.chkAIDrawback();
|
||||||
}
|
}
|
||||||
@@ -781,36 +784,37 @@ public class AbilityFactory_Sacrifice {
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public static void sacrificeAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
public static void sacrificeAllResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
|
|
||||||
String Valid = "";
|
String valid = "";
|
||||||
|
|
||||||
if (params.containsKey("ValidCards")) {
|
if (params.containsKey("ValidCards")) {
|
||||||
Valid = params.get("ValidCards");
|
valid = params.get("ValidCards");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ugh. If calculateAmount needs to be called with DestroyAll it _needs_
|
// Ugh. If calculateAmount needs to be called with DestroyAll it _needs_
|
||||||
// to use the X variable
|
// to use the X variable
|
||||||
// We really need a better solution to this
|
// We really need a better solution to this
|
||||||
if (Valid.contains("X")) {
|
if (valid.contains("X")) {
|
||||||
Valid = Valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa)));
|
valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
|
|
||||||
boolean remSacrificed = params.containsKey("RememberSacrificed");
|
final boolean remSacrificed = params.containsKey("RememberSacrificed");
|
||||||
if (remSacrificed) {
|
if (remSacrificed) {
|
||||||
card.clearRemembered();
|
card.clearRemembered();
|
||||||
}
|
}
|
||||||
|
|
||||||
list = list.getValidCards(Valid.split(","), card.getController(), card);
|
list = list.getValidCards(valid.split(","), card.getController(), card);
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (AllZone.getGameAction().sacrifice(list.get(i)) && remSacrificed)
|
if (AllZone.getGameAction().sacrifice(list.get(i)) && remSacrificed) {
|
||||||
card.addRemembered(list.get(i));
|
card.addRemembered(list.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // end class AbilityFactory_Sacrifice
|
} // end class AbilityFactory_Sacrifice
|
||||||
|
|||||||
@@ -32,17 +32,17 @@ import forge.card.trigger.TriggerHandler;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AbilityFactory_Token extends AbilityFactory {
|
public class AbilityFactory_Token extends AbilityFactory {
|
||||||
private AbilityFactory AF = null;
|
private AbilityFactory abilityFactory = null;
|
||||||
|
|
||||||
private String tokenAmount;
|
private final String tokenAmount;
|
||||||
private String tokenName;
|
private final String tokenName;
|
||||||
private String[] tokenTypes;
|
private final String[] tokenTypes;
|
||||||
private String tokenOwner;
|
private String tokenOwner;
|
||||||
private String[] tokenColors;
|
private final String[] tokenColors;
|
||||||
private String[] tokenKeywords;
|
private final String[] tokenKeywords;
|
||||||
private String tokenPower;
|
private final String tokenPower;
|
||||||
private String tokenToughness;
|
private final String tokenToughness;
|
||||||
private String tokenImage;
|
private final String tokenImage;
|
||||||
private String[] tokenAbilities;
|
private String[] tokenAbilities;
|
||||||
private String[] tokenTriggers;
|
private String[] tokenTriggers;
|
||||||
private String[] tokenSVars;
|
private String[] tokenSVars;
|
||||||
@@ -59,9 +59,9 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
* a {@link forge.card.abilityFactory.AbilityFactory} object.
|
||||||
*/
|
*/
|
||||||
public AbilityFactory_Token(final AbilityFactory af) {
|
public AbilityFactory_Token(final AbilityFactory af) {
|
||||||
AF = af;
|
this.abilityFactory = af;
|
||||||
|
|
||||||
HashMap<String, String> mapParams = af.getMapParams();
|
final HashMap<String, String> mapParams = af.getMapParams();
|
||||||
String image;
|
String image;
|
||||||
String[] keywords;
|
String[] keywords;
|
||||||
|
|
||||||
@@ -79,49 +79,49 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mapParams.containsKey("TokenTapped")) {
|
if (mapParams.containsKey("TokenTapped")) {
|
||||||
tokenTapped = mapParams.get("TokenTapped").equals("True");
|
this.tokenTapped = mapParams.get("TokenTapped").equals("True");
|
||||||
} else {
|
} else {
|
||||||
tokenTapped = false;
|
this.tokenTapped = false;
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("TokenAttacking")) {
|
if (mapParams.containsKey("TokenAttacking")) {
|
||||||
tokenAttacking = mapParams.get("TokenAttacking").equals("True");
|
this.tokenAttacking = mapParams.get("TokenAttacking").equals("True");
|
||||||
} else {
|
} else {
|
||||||
tokenAttacking = false;
|
this.tokenAttacking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapParams.containsKey("TokenAbilities")) {
|
if (mapParams.containsKey("TokenAbilities")) {
|
||||||
tokenAbilities = mapParams.get("TokenAbilities").split(",");
|
this.tokenAbilities = mapParams.get("TokenAbilities").split(",");
|
||||||
} else {
|
} else {
|
||||||
tokenAbilities = null;
|
this.tokenAbilities = null;
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("TokenTriggers")) {
|
if (mapParams.containsKey("TokenTriggers")) {
|
||||||
tokenTriggers = mapParams.get("TokenTriggers").split(",");
|
this.tokenTriggers = mapParams.get("TokenTriggers").split(",");
|
||||||
} else {
|
} else {
|
||||||
tokenTriggers = null;
|
this.tokenTriggers = null;
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("TokenSVars")) {
|
if (mapParams.containsKey("TokenSVars")) {
|
||||||
tokenSVars = mapParams.get("TokenSVars").split(",");
|
this.tokenSVars = mapParams.get("TokenSVars").split(",");
|
||||||
} else {
|
} else {
|
||||||
tokenSVars = null;
|
this.tokenSVars = null;
|
||||||
}
|
}
|
||||||
if (mapParams.containsKey("TokenStaticAbilities")) {
|
if (mapParams.containsKey("TokenStaticAbilities")) {
|
||||||
tokenStaticAbilities = mapParams.get("TokenStaticAbilities").split(",");
|
this.tokenStaticAbilities = mapParams.get("TokenStaticAbilities").split(",");
|
||||||
} else {
|
} else {
|
||||||
tokenStaticAbilities = null;
|
this.tokenStaticAbilities = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenAmount = mapParams.get("TokenAmount");
|
this.tokenAmount = mapParams.get("TokenAmount");
|
||||||
tokenPower = mapParams.get("TokenPower");
|
this.tokenPower = mapParams.get("TokenPower");
|
||||||
tokenToughness = mapParams.get("TokenToughness");
|
this.tokenToughness = mapParams.get("TokenToughness");
|
||||||
tokenName = mapParams.get("TokenName");
|
this.tokenName = mapParams.get("TokenName");
|
||||||
tokenTypes = mapParams.get("TokenTypes").split(",");
|
this.tokenTypes = mapParams.get("TokenTypes").split(",");
|
||||||
tokenColors = mapParams.get("TokenColors").split(",");
|
this.tokenColors = mapParams.get("TokenColors").split(",");
|
||||||
tokenKeywords = keywords;
|
this.tokenKeywords = keywords;
|
||||||
tokenImage = image;
|
this.tokenImage = image;
|
||||||
if (mapParams.containsKey("TokenOwner")) {
|
if (mapParams.containsKey("TokenOwner")) {
|
||||||
tokenOwner = mapParams.get("TokenOwner");
|
this.tokenOwner = mapParams.get("TokenOwner");
|
||||||
} else {
|
} else {
|
||||||
tokenOwner = "You";
|
this.tokenOwner = "You";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,27 +134,28 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
*/
|
*/
|
||||||
public final SpellAbility getAbility() {
|
public final SpellAbility getAbility() {
|
||||||
|
|
||||||
final SpellAbility abToken = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility abToken = new Ability_Activated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
|
||||||
|
this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 8460074843405764620L;
|
private static final long serialVersionUID = 8460074843405764620L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return tokenCanPlayAI(this);
|
return AbilityFactory_Token.this.tokenCanPlayAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(this);
|
AbilityFactory_Token.this.doResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return doStackDescription(this);
|
return AbilityFactory_Token.this.doStackDescription(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return tokenDoTriggerAI(this, mandatory);
|
return AbilityFactory_Token.this.tokenDoTriggerAI(this, mandatory);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -169,22 +170,22 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getSpell() {
|
public final SpellAbility getSpell() {
|
||||||
final SpellAbility spToken = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()) {
|
final SpellAbility spToken = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = -8041427947613029670L;
|
private static final long serialVersionUID = -8041427947613029670L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return tokenCanPlayAI(this);
|
return AbilityFactory_Token.this.tokenCanPlayAI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(this);
|
AbilityFactory_Token.this.doResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return doStackDescription(this);
|
return AbilityFactory_Token.this.doStackDescription(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
public final SpellAbility getDrawback() {
|
public final SpellAbility getDrawback() {
|
||||||
final SpellAbility dbDealDamage = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()) {
|
final SpellAbility dbDealDamage = new Ability_Sub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) {
|
||||||
private static final long serialVersionUID = 7239608350643325111L;
|
private static final long serialVersionUID = 7239608350643325111L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -209,17 +210,17 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return doStackDescription(this);
|
return AbilityFactory_Token.this.doStackDescription(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
doResolve(this);
|
AbilityFactory_Token.this.doResolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return tokenDoTriggerAI(this, mandatory);
|
return AbilityFactory_Token.this.tokenDoTriggerAI(this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // Spell
|
}; // Spell
|
||||||
@@ -237,12 +238,12 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private boolean tokenCanPlayAI(final SpellAbility sa) {
|
private boolean tokenCanPlayAI(final SpellAbility sa) {
|
||||||
Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
for (String type : tokenTypes) {
|
for (final String type : this.tokenTypes) {
|
||||||
if (type.equals("Legendary")) {
|
if (type.equals("Legendary")) {
|
||||||
// Don't kill AIs Legendary tokens
|
// Don't kill AIs Legendary tokens
|
||||||
if (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, tokenName).size() > 0) {
|
if (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, this.tokenName).size() > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,7 +251,7 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
|
|
||||||
boolean haste = false;
|
boolean haste = false;
|
||||||
boolean oneShot = false;
|
boolean oneShot = false;
|
||||||
for (String kw : tokenKeywords) {
|
for (final String kw : this.tokenKeywords) {
|
||||||
if (kw.equals("Haste")) {
|
if (kw.equals("Haste")) {
|
||||||
haste = true;
|
haste = true;
|
||||||
}
|
}
|
||||||
@@ -280,11 +281,11 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
// return true;
|
// return true;
|
||||||
|
|
||||||
// prevent run-away activations - first time will always return true
|
// prevent run-away activations - first time will always return true
|
||||||
Random r = MyRandom.getRandom();
|
final Random r = MyRandom.getRandom();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
boolean chance = r.nextFloat() <= Math.pow(.9, sa.getActivationsThisTurn());
|
final boolean chance = r.nextFloat() <= Math.pow(.9, sa.getActivationsThisTurn());
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
if (tgt.canOnlyTgtOpponent()) {
|
if (tgt.canOnlyTgtOpponent()) {
|
||||||
@@ -312,13 +313,13 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenAmount.equals("X")) {
|
if (this.tokenAmount.equals("X")) {
|
||||||
if (source.getSVar(tokenAmount).equals("Count$xPaid")) {
|
if (source.getSVar(this.tokenAmount).equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
int xPay = ComputerUtil.determineLeftoverMana(sa);
|
final int xPay = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(xPay));
|
source.setSVar("PayX", Integer.toString(xPay));
|
||||||
}
|
}
|
||||||
if (AbilityFactory.calculateAmount(AF.getHostCard(), tokenAmount, sa) <= 0) {
|
if (AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenAmount, sa) <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,10 +329,10 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sa.isAbility()) {
|
if (sa.isAbility()) {
|
||||||
return (r.nextFloat() < .9 && chance);
|
return ((r.nextFloat() < .9) && chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (r.nextFloat() < .6667 && chance);
|
return ((r.nextFloat() < .6667) && chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -363,15 +364,15 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String doStackDescription(final SpellAbility sa) {
|
private String doStackDescription(final SpellAbility sa) {
|
||||||
Card host = AF.getHostCard();
|
final Card host = this.abilityFactory.getHostCard();
|
||||||
|
|
||||||
int finalPower = AbilityFactory.calculateAmount(AF.getHostCard(), tokenPower, sa);
|
final int finalPower = AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenPower, sa);
|
||||||
int finalToughness = AbilityFactory.calculateAmount(AF.getHostCard(), tokenToughness, sa);
|
final int finalToughness = AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenToughness, sa);
|
||||||
int finalAmount = AbilityFactory.calculateAmount(AF.getHostCard(), tokenAmount, sa);
|
final int finalAmount = AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenAmount, sa);
|
||||||
|
|
||||||
String substitutedName = tokenName.equals("ChosenType") ? host.getChosenType() : tokenName;
|
final String substitutedName = this.tokenName.equals("ChosenType") ? host.getChosenType() : this.tokenName;
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub) {
|
if (sa instanceof Ability_Sub) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
@@ -386,7 +387,7 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
sb.append(" onto the battlefield");
|
sb.append(" onto the battlefield");
|
||||||
|
|
||||||
if (tokenOwner.equals("Opponent")) {
|
if (this.tokenOwner.equals("Opponent")) {
|
||||||
sb.append(" under your opponent's control.");
|
sb.append(" under your opponent's control.");
|
||||||
} else {
|
} else {
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
@@ -408,12 +409,12 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private void doResolve(final SpellAbility sa) {
|
private void doResolve(final SpellAbility sa) {
|
||||||
Card host = AF.getHostCard();
|
final Card host = this.abilityFactory.getHostCard();
|
||||||
String imageName = "";
|
String imageName = "";
|
||||||
Player controller;
|
Player controller;
|
||||||
String cost = "";
|
String cost = "";
|
||||||
// Construct colors
|
// Construct colors
|
||||||
String[] substitutedColors = Arrays.copyOf(tokenColors, tokenColors.length);
|
final String[] substitutedColors = Arrays.copyOf(this.tokenColors, this.tokenColors.length);
|
||||||
for (int i = 0; i < substitutedColors.length; i++) {
|
for (int i = 0; i < substitutedColors.length; i++) {
|
||||||
if (substitutedColors[i].equals("ChosenColor")) {
|
if (substitutedColors[i].equals("ChosenColor")) {
|
||||||
// this currently only supports 1 chosen color
|
// this currently only supports 1 chosen color
|
||||||
@@ -421,7 +422,7 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String colorDesc = "";
|
String colorDesc = "";
|
||||||
for (String col : substitutedColors) {
|
for (final String col : substitutedColors) {
|
||||||
if (col.equalsIgnoreCase("White")) {
|
if (col.equalsIgnoreCase("White")) {
|
||||||
colorDesc += "W";
|
colorDesc += "W";
|
||||||
} else if (col.equalsIgnoreCase("Blue")) {
|
} else if (col.equalsIgnoreCase("Blue")) {
|
||||||
@@ -436,61 +437,62 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
colorDesc = "C";
|
colorDesc = "C";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tokenImage.equals("")) {
|
if (this.tokenImage.equals("")) {
|
||||||
|
|
||||||
imageName += colorDesc + " " + tokenPower + " " + tokenToughness + " " + tokenName;
|
imageName += colorDesc + " " + this.tokenPower + " " + this.tokenToughness + " " + this.tokenName;
|
||||||
} else {
|
} else {
|
||||||
imageName = tokenImage;
|
imageName = this.tokenImage;
|
||||||
}
|
}
|
||||||
// System.out.println("AF_Token imageName = " + imageName);
|
// System.out.println("AF_Token imageName = " + imageName);
|
||||||
|
|
||||||
for (char c : colorDesc.toCharArray()) {
|
for (final char c : colorDesc.toCharArray()) {
|
||||||
cost += c + ' ';
|
cost += c + ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
cost = colorDesc.replace('C', '1').trim();
|
cost = colorDesc.replace('C', '1').trim();
|
||||||
|
|
||||||
controller = AbilityFactory.getDefinedPlayers(AF.getHostCard(), tokenOwner, sa).get(0);
|
controller = AbilityFactory.getDefinedPlayers(this.abilityFactory.getHostCard(), this.tokenOwner, sa).get(0);
|
||||||
|
|
||||||
int finalPower = AbilityFactory.calculateAmount(AF.getHostCard(), tokenPower, sa);
|
final int finalPower = AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenPower, sa);
|
||||||
int finalToughness = AbilityFactory.calculateAmount(AF.getHostCard(), tokenToughness, sa);
|
final int finalToughness = AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenToughness, sa);
|
||||||
int finalAmount = AbilityFactory.calculateAmount(AF.getHostCard(), tokenAmount, sa);
|
final int finalAmount = AbilityFactory.calculateAmount(this.abilityFactory.getHostCard(), this.tokenAmount, sa);
|
||||||
|
|
||||||
String[] substitutedTypes = Arrays.copyOf(tokenTypes, tokenTypes.length);
|
final String[] substitutedTypes = Arrays.copyOf(this.tokenTypes, this.tokenTypes.length);
|
||||||
for (int i = 0; i < substitutedTypes.length; i++) {
|
for (int i = 0; i < substitutedTypes.length; i++) {
|
||||||
if (substitutedTypes[i].equals("ChosenType")) {
|
if (substitutedTypes[i].equals("ChosenType")) {
|
||||||
substitutedTypes[i] = host.getChosenType();
|
substitutedTypes[i] = host.getChosenType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String substitutedName = tokenName.equals("ChosenType") ? host.getChosenType() : tokenName;
|
final String substitutedName = this.tokenName.equals("ChosenType") ? host.getChosenType() : this.tokenName;
|
||||||
|
|
||||||
String remember = AF.getMapParams().get("RememberTokens");
|
final String remember = this.abilityFactory.getMapParams().get("RememberTokens");
|
||||||
for (int i = 0; i < finalAmount; i++) {
|
for (int i = 0; i < finalAmount; i++) {
|
||||||
CardList tokens = CardFactoryUtil.makeToken(substitutedName, imageName, controller, cost, substitutedTypes,
|
final CardList tokens = CardFactoryUtil.makeToken(substitutedName, imageName, controller, cost,
|
||||||
finalPower, finalToughness, tokenKeywords);
|
substitutedTypes, finalPower, finalToughness, this.tokenKeywords);
|
||||||
|
|
||||||
// Grant abilities
|
// Grant abilities
|
||||||
if (tokenAbilities != null) {
|
if (this.tokenAbilities != null) {
|
||||||
AbilityFactory af = new AbilityFactory();
|
final AbilityFactory af = new AbilityFactory();
|
||||||
for (String s : tokenAbilities) {
|
for (final String s : this.tokenAbilities) {
|
||||||
String actualAbility = AF.getHostCard().getSVar(s);
|
final String actualAbility = this.abilityFactory.getHostCard().getSVar(s);
|
||||||
for (Card c : tokens) {
|
for (final Card c : tokens) {
|
||||||
SpellAbility grantedAbility = af.getAbility(actualAbility, c);
|
final SpellAbility grantedAbility = af.getAbility(actualAbility, c);
|
||||||
c.addSpellAbility(grantedAbility);
|
c.addSpellAbility(grantedAbility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant triggers
|
// Grant triggers
|
||||||
if (tokenTriggers != null) {
|
if (this.tokenTriggers != null) {
|
||||||
|
|
||||||
for (String s : tokenTriggers) {
|
for (final String s : this.tokenTriggers) {
|
||||||
String actualTrigger = AF.getHostCard().getSVar(s);
|
final String actualTrigger = this.abilityFactory.getHostCard().getSVar(s);
|
||||||
|
|
||||||
for (final Card c : tokens) {
|
for (final Card c : tokens) {
|
||||||
|
|
||||||
Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c, true);
|
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, c, true);
|
||||||
String ability = AF.getHostCard().getSVar(parsedTrigger.getMapParams().get("Execute"));
|
final String ability = this.abilityFactory.getHostCard().getSVar(
|
||||||
|
parsedTrigger.getMapParams().get("Execute"));
|
||||||
parsedTrigger.setOverridingAbility(new AbilityFactory().getAbility(ability, c));
|
parsedTrigger.setOverridingAbility(new AbilityFactory().getAbility(ability, c));
|
||||||
c.addTrigger(parsedTrigger);
|
c.addTrigger(parsedTrigger);
|
||||||
}
|
}
|
||||||
@@ -498,34 +500,34 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Grant SVars
|
// Grant SVars
|
||||||
if (tokenSVars != null) {
|
if (this.tokenSVars != null) {
|
||||||
for (String s : tokenSVars) {
|
for (final String s : this.tokenSVars) {
|
||||||
String actualSVar = AF.getHostCard().getSVar(s);
|
final String actualSVar = this.abilityFactory.getHostCard().getSVar(s);
|
||||||
for (Card c : tokens) {
|
for (final Card c : tokens) {
|
||||||
c.setSVar(s, actualSVar);
|
c.setSVar(s, actualSVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant static abilities
|
// Grant static abilities
|
||||||
if (tokenStaticAbilities != null) {
|
if (this.tokenStaticAbilities != null) {
|
||||||
for (String s : tokenStaticAbilities) {
|
for (final String s : this.tokenStaticAbilities) {
|
||||||
String actualAbility = AF.getHostCard().getSVar(s);
|
final String actualAbility = this.abilityFactory.getHostCard().getSVar(s);
|
||||||
for (Card c : tokens) {
|
for (final Card c : tokens) {
|
||||||
c.addStaticAbility(actualAbility);
|
c.addStaticAbility(actualAbility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Card c : tokens) {
|
for (final Card c : tokens) {
|
||||||
if (tokenTapped) {
|
if (this.tokenTapped) {
|
||||||
c.tap();
|
c.tap();
|
||||||
}
|
}
|
||||||
if (tokenAttacking) {
|
if (this.tokenAttacking) {
|
||||||
AllZone.getCombat().addAttacker(c);
|
AllZone.getCombat().addAttacker(c);
|
||||||
}
|
}
|
||||||
if (remember != null) {
|
if (remember != null) {
|
||||||
AF.getHostCard().addRemembered(c);
|
this.abilityFactory.getHostCard().addRemembered(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,22 +41,22 @@ public class AbilityFactory_Turns {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return addTurnStackDescription(af, this);
|
return AbilityFactory_Turns.addTurnStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return addTurnCanPlayAI(af, this);
|
return AbilityFactory_Turns.addTurnCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
addTurnResolve(af, this);
|
AbilityFactory_Turns.addTurnResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return addTurnTriggerAI(af, this, mandatory);
|
return AbilityFactory_Turns.addTurnTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -78,17 +78,17 @@ public class AbilityFactory_Turns {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return addTurnStackDescription(af, this);
|
return AbilityFactory_Turns.addTurnStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return addTurnCanPlayAI(af, this);
|
return AbilityFactory_Turns.addTurnCanPlayAI(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
addTurnResolve(af, this);
|
AbilityFactory_Turns.addTurnResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -110,12 +110,12 @@ public class AbilityFactory_Turns {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStackDescription() {
|
public String getStackDescription() {
|
||||||
return addTurnStackDescription(af, this);
|
return AbilityFactory_Turns.addTurnStackDescription(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
addTurnResolve(af, this);
|
AbilityFactory_Turns.addTurnResolve(af, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -125,7 +125,7 @@ public class AbilityFactory_Turns {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean doTrigger(final boolean mandatory) {
|
||||||
return addTurnTriggerAI(af, this, mandatory);
|
return AbilityFactory_Turns.addTurnTriggerAI(af, this, mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -144,9 +144,9 @@ public class AbilityFactory_Turns {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String addTurnStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
private static String addTurnStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
int numTurns = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumTurns"), sa);
|
final int numTurns = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumTurns"), sa);
|
||||||
|
|
||||||
if (!(sa instanceof Ability_Sub)) {
|
if (!(sa instanceof Ability_Sub)) {
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
@@ -156,14 +156,14 @@ public class AbilityFactory_Turns {
|
|||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else {
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : tgtPlayers) {
|
for (final Player player : tgtPlayers) {
|
||||||
sb.append(player).append(" ");
|
sb.append(player).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ public class AbilityFactory_Turns {
|
|||||||
}
|
}
|
||||||
sb.append(" after this one.");
|
sb.append(" after this one.");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
final Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ public class AbilityFactory_Turns {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
private static boolean addTurnCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
private static boolean addTurnCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||||
return addTurnTriggerAI(af, sa, false);
|
return AbilityFactory_Turns.addTurnTriggerAI(af, sa, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,17 +217,17 @@ public class AbilityFactory_Turns {
|
|||||||
*/
|
*/
|
||||||
private static boolean addTurnTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
private static boolean addTurnTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||||
|
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
Target tgt = sa.getTarget();
|
final Target tgt = sa.getTarget();
|
||||||
|
|
||||||
if (sa.getTarget() != null) {
|
if (sa.getTarget() != null) {
|
||||||
tgt.resetTargets();
|
tgt.resetTargets();
|
||||||
sa.getTarget().addTarget(AllZone.getComputerPlayer());
|
sa.getTarget().addTarget(AllZone.getComputerPlayer());
|
||||||
} else {
|
} else {
|
||||||
ArrayList<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"),
|
final ArrayList<Player> tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||||
sa);
|
params.get("Defined"), sa);
|
||||||
for (Player p : tgtPlayers) {
|
for (final Player p : tgtPlayers) {
|
||||||
if (p.isHuman() && !mandatory) {
|
if (p.isHuman() && !mandatory) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -249,20 +249,20 @@ public class AbilityFactory_Turns {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
*/
|
*/
|
||||||
private static void addTurnResolve(final AbilityFactory af, final SpellAbility sa) {
|
private static void addTurnResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||||
HashMap<String, String> params = af.getMapParams();
|
final HashMap<String, String> params = af.getMapParams();
|
||||||
int numTurns = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumTurns"), sa);
|
final int numTurns = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumTurns"), sa);
|
||||||
|
|
||||||
ArrayList<Player> tgtPlayers;
|
ArrayList<Player> tgtPlayers;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
final Target tgt = af.getAbTgt();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
tgtPlayers = tgt.getTargetPlayers();
|
tgtPlayers = tgt.getTargetPlayers();
|
||||||
} else {
|
} else {
|
||||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : tgtPlayers) {
|
for (final Player p : tgtPlayers) {
|
||||||
if (tgt == null || p.canTarget(sa)) {
|
if ((tgt == null) || p.canTarget(sa)) {
|
||||||
for (int i = 0; i < numTurns; i++) {
|
for (int i = 0; i < numTurns; i++) {
|
||||||
AllZone.getPhase().addExtraTurn(p);
|
AllZone.getPhase().addExtraTurn(p);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user