mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Continuous static abilities with "RemoveAllAbilities" will now also remove keywords.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -9561,6 +9561,7 @@ src/main/java/forge/CardPowerToughness.java svneol=native#text/plain
|
||||
src/main/java/forge/CardReader.java svneol=native#text/plain
|
||||
src/main/java/forge/CardUtil.java svneol=native#text/plain
|
||||
src/main/java/forge/Card_Color.java svneol=native#text/plain
|
||||
src/main/java/forge/Card_Keywords.java -text
|
||||
src/main/java/forge/Card_Type.java svneol=native#text/plain
|
||||
src/main/java/forge/Color.java svneol=native#text/plain
|
||||
src/main/java/forge/ColorChanger.java -text
|
||||
|
||||
@@ -68,6 +68,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private ArrayList<Card_Color> cardColor = new ArrayList<Card_Color>();
|
||||
//changes by AF animate and continuous static effects
|
||||
private ArrayList<Card_Type> changedCardTypes = new ArrayList<Card_Type>();
|
||||
private ArrayList<Card_Keywords> changedCardKeywords = new ArrayList<Card_Keywords>();
|
||||
private ArrayList<StaticAbility> staticAbilities = new ArrayList<StaticAbility>();
|
||||
|
||||
private ArrayList<Object> rememberedObjects = new ArrayList<Object>();
|
||||
@@ -3903,34 +3904,16 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<String> getKeyword() {
|
||||
ArrayList<String> a1 = new ArrayList<String>(getIntrinsicKeyword());
|
||||
ArrayList<String> a2 = new ArrayList<String>(getExtrinsicKeyword());
|
||||
ArrayList<String> keywords = getUnhiddenKeyword();
|
||||
ArrayList<String> a4 = new ArrayList<String>(getHiddenExtrinsicKeyword());
|
||||
a1.addAll(a2);
|
||||
a1.addAll(a4);
|
||||
keywords.addAll(a4);
|
||||
|
||||
// SOL Changes for Mana
|
||||
//for(Ability_Mana sa:getManaAbility())
|
||||
// if(sa.isBasic()) a1.add((sa).orig);
|
||||
|
||||
return a1;
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public int getKeywordAmount(final String keyword) {
|
||||
int res = 0;
|
||||
for (String k : getIntrinsicKeyword()) {
|
||||
if (k.equals(keyword)) {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
|
||||
for (String k : getExtrinsicKeyword()) {
|
||||
if (k.equals(keyword)) {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
|
||||
for (String k : getHiddenExtrinsicKeyword()) {
|
||||
for (String k : getKeyword()) {
|
||||
if (k.equals(keyword)) {
|
||||
res++;
|
||||
}
|
||||
@@ -3939,7 +3922,43 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return res;
|
||||
}
|
||||
|
||||
//keywords are like flying, fear, first strike, etc...
|
||||
public void setChangedCardKeywords(ArrayList<Card_Keywords> kw) {
|
||||
changedCardKeywords = kw;
|
||||
}
|
||||
|
||||
public ArrayList<Card_Keywords> getChangedCardKeywords() {
|
||||
return changedCardKeywords;
|
||||
}
|
||||
|
||||
public void addChangedCardKeywords(ArrayList<String> keywords, ArrayList<String> removeKeywords, boolean removeAllKeywords,
|
||||
long timestamp) {
|
||||
|
||||
changedCardKeywords.add(new Card_Keywords(keywords, removeKeywords, removeAllKeywords, timestamp));
|
||||
}
|
||||
|
||||
public void addChangedCardKeywords(String[] keywords, String[] removeKeywords, boolean removeAllKeywords, long timestamp) {
|
||||
ArrayList<String> keywordsList = null;
|
||||
ArrayList<String> removeKeywordsList = null;
|
||||
if(keywords != null) {
|
||||
keywordsList = new ArrayList<String>(Arrays.asList(keywords));
|
||||
}
|
||||
|
||||
if(removeKeywords != null) {
|
||||
removeKeywordsList = new ArrayList<String>(Arrays.asList(removeKeywords));
|
||||
}
|
||||
|
||||
addChangedCardKeywords(keywordsList, removeKeywordsList, removeAllKeywords, timestamp);
|
||||
}
|
||||
|
||||
public void removeChangedCardKeywords(long timestamp) {
|
||||
for (int i = 0; i < changedCardKeywords.size(); i++) {
|
||||
Card_Keywords cardK = changedCardKeywords.get(i);
|
||||
if (cardK.getTimestamp() == timestamp) {
|
||||
changedCardKeywords.remove(cardK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hidden keywords will be left out
|
||||
/**
|
||||
* <p>getUnhiddenKeyword.</p>
|
||||
@@ -3947,15 +3966,32 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<String> getUnhiddenKeyword() {
|
||||
ArrayList<String> a1 = new ArrayList<String>(getIntrinsicKeyword());
|
||||
ArrayList<String> keywords = new ArrayList<String>(getIntrinsicKeyword());
|
||||
ArrayList<String> a2 = new ArrayList<String>(getExtrinsicKeyword());
|
||||
a1.addAll(a2);
|
||||
keywords.addAll(a2);
|
||||
|
||||
// SOL Changes for Mana
|
||||
//for(Ability_Mana sa:getManaAbility())
|
||||
// if(sa.isBasic()) a1.add((sa).orig);
|
||||
// see if keyword changes are in effect
|
||||
if (!changedCardKeywords.isEmpty()) {
|
||||
|
||||
return a1;
|
||||
ArrayList<Card_Keywords> newKeywords = changedCardKeywords;
|
||||
Collections.sort(newKeywords); // sorts newKeywords by timeStamp
|
||||
|
||||
for (Card_Keywords ck : newKeywords) {
|
||||
|
||||
if(ck.isRemoveAllKeywords()) {
|
||||
keywords.clear();
|
||||
} else if (ck.getRemoveKeywords() != null) {
|
||||
keywords.removeAll(ck.getRemoveKeywords());
|
||||
}
|
||||
|
||||
if (ck.getKeywords() != null) {
|
||||
keywords.addAll(ck.getKeywords());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
60
src/main/java/forge/Card_Keywords.java
Normal file
60
src/main/java/forge/Card_Keywords.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package forge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Card_Keywords class.</p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id: Card_Keywords.java 10217 2011-09-04 10:14:19Z Sloth $
|
||||
*/
|
||||
public class Card_Keywords implements Comparable<Card_Keywords>{
|
||||
// takes care of individual card types
|
||||
private ArrayList<String> keywords = new ArrayList<String>();
|
||||
private ArrayList<String> removeKeywords = new ArrayList<String>();
|
||||
private boolean removeAllKeywords =false;
|
||||
private long timeStamp = 0;
|
||||
|
||||
/**
|
||||
* <p>getTimestamp.</p>
|
||||
*
|
||||
* @return a long.
|
||||
*/
|
||||
public final long getTimestamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
Card_Keywords(final ArrayList<String> keywordList, final ArrayList<String> removeKeywordList, final boolean removeAll,
|
||||
final long stamp) {
|
||||
keywords = keywordList;
|
||||
removeKeywords = removeKeywordList;
|
||||
removeAllKeywords = removeAll;
|
||||
timeStamp = stamp;
|
||||
}
|
||||
|
||||
public final ArrayList<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public final ArrayList<String> getRemoveKeywords() {
|
||||
return removeKeywords;
|
||||
}
|
||||
|
||||
public final boolean isRemoveAllKeywords() {
|
||||
return removeAllKeywords;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int compareTo(final Card_Keywords anotherCardKeywords) {
|
||||
int returnValue = 0;
|
||||
long anotherTimeStamp = anotherCardKeywords.getTimestamp();
|
||||
if (this.timeStamp < anotherTimeStamp) {
|
||||
returnValue = -1;
|
||||
} else if (this.timeStamp > anotherTimeStamp) {
|
||||
returnValue = 1;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,10 +87,6 @@ public class StaticEffects {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("AddKeyword")) {
|
||||
addKeywords = params.get("AddKeyword").split(" & ");
|
||||
}
|
||||
|
||||
if (params.containsKey("AddColor")) {
|
||||
addColors = CardUtil.getShortColorsString(
|
||||
new ArrayList<String>(Arrays.asList(params.get("AddColor").split(" & "))));
|
||||
@@ -103,6 +99,9 @@ public class StaticEffects {
|
||||
|
||||
//modify players
|
||||
for (Player p : affectedPlayers) {
|
||||
if (params.containsKey("AddKeyword")) {
|
||||
addKeywords = params.get("AddKeyword").split(" & ");
|
||||
}
|
||||
|
||||
// add keywords
|
||||
if (addKeywords != null)
|
||||
@@ -124,10 +123,8 @@ public class StaticEffects {
|
||||
affectedCard.addSemiPermanentDefenseBoost(toughnessBonus * -1);
|
||||
|
||||
//remove keywords
|
||||
if (addKeywords != null) {
|
||||
for (String keyword : addKeywords) {
|
||||
affectedCard.removeExtrinsicKeyword(keyword);
|
||||
}
|
||||
if (params.containsKey("AddKeyword") || params.containsKey("RemoveKeyword") || params.containsKey("RemoveAllAbilities")) {
|
||||
affectedCard.removeChangedCardKeywords(se.getTimestamp());
|
||||
}
|
||||
|
||||
//remove abilities
|
||||
@@ -142,10 +139,11 @@ public class StaticEffects {
|
||||
|
||||
//remove abilities
|
||||
if (params.containsKey("RemoveAllAbilities")) {
|
||||
SpellAbility[] spellAbility = affectedCard.getSpellAbility();
|
||||
for (SpellAbility s : spellAbility) {
|
||||
s.setTemporarilySuppressed(false);
|
||||
ArrayList<SpellAbility> abilities = affectedCard.getSpellAbilities();
|
||||
for (SpellAbility ab : abilities) {
|
||||
ab.setTemporarilySuppressed(false);
|
||||
}
|
||||
|
||||
ArrayList<StaticAbility> staticAbilities = affectedCard.getStaticAbilities();
|
||||
for (StaticAbility stA : staticAbilities) {
|
||||
stA.setTemporarilySuppressed(false);
|
||||
|
||||
@@ -43,12 +43,14 @@ public class StaticAbility_Continuous {
|
||||
int setPower = -1;
|
||||
int setToughness = -1;
|
||||
String[] addKeywords = null;
|
||||
String[] removeKeywords = null;
|
||||
String[] addAbilities = null;
|
||||
String[] addSVars = null;
|
||||
String[] addTypes = null;
|
||||
String[] removeTypes = null;
|
||||
String addColors = null;
|
||||
String[] addTriggers = null;
|
||||
boolean removeAllAbilities = false ;
|
||||
boolean removeSuperTypes = false;
|
||||
boolean removeCardTypes = false;
|
||||
boolean removeSubTypes = false;
|
||||
@@ -96,6 +98,14 @@ public class StaticAbility_Continuous {
|
||||
addKeywords = params.get("AddKeyword").split(" & ");
|
||||
}
|
||||
|
||||
if (params.containsKey("RemoveKeyword")) {
|
||||
removeKeywords = params.get("RemoveKeyword").split(" & ");
|
||||
}
|
||||
|
||||
if (params.containsKey("RemoveAllAbilities")) {
|
||||
removeAllAbilities = true;
|
||||
}
|
||||
|
||||
if (params.containsKey("AddAbility")) {
|
||||
String[] sVars = params.get("AddAbility").split(" & ");
|
||||
for (int i = 0; i < sVars.length; i++) {
|
||||
@@ -195,10 +205,8 @@ public class StaticAbility_Continuous {
|
||||
affectedCard.addSemiPermanentDefenseBoost(toughnessBonus);
|
||||
|
||||
// add keywords
|
||||
if (addKeywords != null) {
|
||||
for (String keyword : addKeywords) {
|
||||
affectedCard.addExtrinsicKeyword(keyword);
|
||||
}
|
||||
if (addKeywords != null || removeKeywords != null || removeAllAbilities) {
|
||||
affectedCard.addChangedCardKeywords(addKeywords, removeKeywords, removeAllAbilities, hostCard.getTimestamp());
|
||||
}
|
||||
|
||||
// add abilities
|
||||
@@ -243,7 +251,7 @@ public class StaticAbility_Continuous {
|
||||
}
|
||||
|
||||
// remove triggers
|
||||
if (params.containsKey("RemoveTriggers") || params.containsKey("RemoveAllAbilities")) {
|
||||
if (params.containsKey("RemoveTriggers") || removeAllAbilities) {
|
||||
ArrayList<Trigger> triggers = affectedCard.getTriggers();
|
||||
for (Trigger trigger : triggers) {
|
||||
trigger.setTemporarilySuppressed(true);
|
||||
@@ -251,7 +259,7 @@ public class StaticAbility_Continuous {
|
||||
}
|
||||
|
||||
// remove activated and static abilities
|
||||
if (params.containsKey("RemoveAllAbilities")) {
|
||||
if (removeAllAbilities) {
|
||||
ArrayList<SpellAbility> abilities = affectedCard.getSpellAbilities();
|
||||
for (SpellAbility ab : abilities) {
|
||||
ab.setTemporarilySuppressed(true);
|
||||
|
||||
Reference in New Issue
Block a user