mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
incremental update for AF_Animate to support removing triggers and abilities as part of the animate.
This commit is contained in:
@@ -1,7 +1,20 @@
|
|||||||
package forge.card.abilityFactory;
|
package forge.card.abilityFactory;
|
||||||
|
|
||||||
import forge.*;
|
|
||||||
import forge.card.spellability.*;
|
import forge.AllZone;
|
||||||
|
import forge.AllZoneUtil;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardList;
|
||||||
|
import forge.CardUtil;
|
||||||
|
import forge.Command;
|
||||||
|
import forge.ComputerUtil;
|
||||||
|
import forge.Constant;
|
||||||
|
|
||||||
|
import forge.card.spellability.Ability_Activated;
|
||||||
|
import forge.card.spellability.Ability_Sub;
|
||||||
|
import forge.card.spellability.Spell;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.card.spellability.Target;
|
||||||
import forge.card.staticAbility.StaticAbility;
|
import forge.card.staticAbility.StaticAbility;
|
||||||
import forge.card.trigger.Trigger;
|
import forge.card.trigger.Trigger;
|
||||||
import forge.card.trigger.TriggerHandler;
|
import forge.card.trigger.TriggerHandler;
|
||||||
@@ -17,7 +30,11 @@ import java.util.Map;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AbilityFactory_Animate {
|
public final class AbilityFactory_Animate {
|
||||||
|
|
||||||
|
private AbilityFactory_Animate() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
//************************** Animate ***************************
|
//************************** Animate ***************************
|
||||||
@@ -419,7 +436,7 @@ public class AbilityFactory_Animate {
|
|||||||
|
|
||||||
final long timestamp = timest;
|
final long timestamp = timest;
|
||||||
|
|
||||||
boolean permanent = params.containsKey("Permanent") ? true : false;
|
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")) {
|
||||||
@@ -498,7 +515,8 @@ public 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, timestamp);
|
final long colorTimestamp = doAnimate(c, af, power, toughness, types,
|
||||||
|
removeTypes, finalDesc, keywords, timestamp);
|
||||||
|
|
||||||
//give abilities
|
//give abilities
|
||||||
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
||||||
@@ -512,6 +530,17 @@ public class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//remove abilities
|
||||||
|
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||||
|
if (params.containsKey("OverwriteAbilities")) {
|
||||||
|
for (SpellAbility ab : c.getSpellAbilities()) {
|
||||||
|
if (ab.isAbility()) {
|
||||||
|
c.removeSpellAbility(ab);
|
||||||
|
removedAbilities.add(ab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//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) {
|
||||||
@@ -523,6 +552,16 @@ public class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//suppress triggers from the animated card
|
||||||
|
final ArrayList<Trigger> removedTriggers = new ArrayList<Trigger>();
|
||||||
|
if (params.containsKey("OverwriteTriggers")) {
|
||||||
|
System.out.println("Suppressing triggers for: "+c);
|
||||||
|
ArrayList<Trigger> triggersToRemove = c.getTriggers();
|
||||||
|
for (Trigger trigger : triggersToRemove) {
|
||||||
|
trigger.setSuppressed(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//give static abilities (should only be used by cards to give itself a static ability)
|
//give static abilities (should only be used by cards to give itself a static ability)
|
||||||
if (stAbs.size() > 0) {
|
if (stAbs.size() > 0) {
|
||||||
for (String s : stAbs) {
|
for (String s : stAbs) {
|
||||||
@@ -546,7 +585,13 @@ public class AbilityFactory_Animate {
|
|||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
doUnanimate(c, af, finalDesc, keywords, addedAbilities, addedTriggers, colorTimestamp,
|
doUnanimate(c, af, finalDesc, keywords, addedAbilities, addedTriggers, colorTimestamp,
|
||||||
givesStAbs, timestamp);
|
givesStAbs, removedAbilities, timestamp);
|
||||||
|
|
||||||
|
//give back suppressed triggers
|
||||||
|
for(Trigger t : removedTriggers) {
|
||||||
|
System.out.println("Unsuppressing triggers for: "+c);
|
||||||
|
t.setSuppressed(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -577,8 +622,8 @@ public class AbilityFactory_Animate {
|
|||||||
* @return a long.
|
* @return a long.
|
||||||
*/
|
*/
|
||||||
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> keywords,
|
final ArrayList<String> types, final ArrayList<String> removeTypes, final String colors,
|
||||||
final long timestamp)
|
final ArrayList<String> keywords, final long timestamp)
|
||||||
{
|
{
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
@@ -658,7 +703,7 @@ public class AbilityFactory_Animate {
|
|||||||
private static void doUnanimate(final Card c, final AbilityFactory af, final String colorDesc,
|
private static void doUnanimate(final Card c, final AbilityFactory af, final String colorDesc,
|
||||||
final ArrayList<String> originalKeywords, final ArrayList<SpellAbility> addedAbilities,
|
final ArrayList<String> originalKeywords, final ArrayList<SpellAbility> addedAbilities,
|
||||||
final ArrayList<Trigger> addedTriggers, final long colorTimestamp,
|
final ArrayList<Trigger> addedTriggers, final long colorTimestamp,
|
||||||
final boolean givesStAbs, final long timestamp)
|
final boolean givesStAbs, final ArrayList<SpellAbility> removedAbilities, final long timestamp)
|
||||||
{
|
{
|
||||||
HashMap<String, String> params = af.getMapParams();
|
HashMap<String, String> params = af.getMapParams();
|
||||||
|
|
||||||
@@ -687,6 +732,10 @@ public class AbilityFactory_Animate {
|
|||||||
c.removeSpellAbility(sa);
|
c.removeSpellAbility(sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (SpellAbility sa : removedAbilities) {
|
||||||
|
c.addSpellAbility(sa);
|
||||||
|
}
|
||||||
|
|
||||||
for (Trigger t : addedTriggers) {
|
for (Trigger t : addedTriggers) {
|
||||||
AllZone.getTriggerHandler().removeRegisteredTrigger(t);
|
AllZone.getTriggerHandler().removeRegisteredTrigger(t);
|
||||||
c.removeTrigger(t);
|
c.removeTrigger(t);
|
||||||
@@ -920,7 +969,7 @@ public class AbilityFactory_Animate {
|
|||||||
|
|
||||||
final long timestamp = timest;
|
final long timestamp = timest;
|
||||||
|
|
||||||
boolean permanent = params.containsKey("Permanent") ? true : false;
|
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")) {
|
||||||
@@ -987,7 +1036,8 @@ public 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, timestamp);
|
final long colorTimestamp = doAnimate(c, af, power, toughness, types,
|
||||||
|
removeTypes, finalDesc, keywords, timestamp);
|
||||||
|
|
||||||
//give abilities
|
//give abilities
|
||||||
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
final ArrayList<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
||||||
@@ -1001,6 +1051,17 @@ public class AbilityFactory_Animate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//remove abilities
|
||||||
|
final ArrayList<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||||
|
if (params.containsKey("OverwriteAbilities")) {
|
||||||
|
for (SpellAbility ab : c.getSpellAbilities()) {
|
||||||
|
if (ab.isAbility()) {
|
||||||
|
c.removeSpellAbility(ab);
|
||||||
|
removedAbilities.add(ab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//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) {
|
||||||
@@ -1017,7 +1078,7 @@ public class AbilityFactory_Animate {
|
|||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
doUnanimate(c, af, finalDesc, keywords, addedAbilities, addedTriggers,
|
doUnanimate(c, af, finalDesc, keywords, addedAbilities, addedTriggers,
|
||||||
colorTimestamp, false, timestamp);
|
colorTimestamp, false, removedAbilities, timestamp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -527,9 +527,9 @@ public abstract class Trigger {
|
|||||||
protected boolean suppressed = false;
|
protected boolean suppressed = false;
|
||||||
protected boolean temporarilySuppressed = false;
|
protected boolean temporarilySuppressed = false;
|
||||||
|
|
||||||
/*public void setSuppressed(boolean supp) {
|
public void setSuppressed(boolean supp) {
|
||||||
suppressed = supp;
|
suppressed = supp;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public void setTemporarilySuppressed(boolean supp) {
|
public void setTemporarilySuppressed(boolean supp) {
|
||||||
temporarilySuppressed = supp;
|
temporarilySuppressed = supp;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class Trigger_Taps extends Trigger {
|
|||||||
}
|
}
|
||||||
copy.setName(name);
|
copy.setName(name);
|
||||||
copy.setID(ID);
|
copy.setID(ID);
|
||||||
|
copy.setSuppressed(suppressed);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user