- Cleanup of stAnimate.

This commit is contained in:
Sloth
2011-09-25 08:13:00 +00:00
parent 38b6e1453d
commit f60f0b52c9
4 changed files with 2 additions and 312 deletions

View File

@@ -1566,11 +1566,6 @@ public class Card extends GameEntity implements Comparable<Card> {
if (keyword.get(i).toString().contains("StaticEffect")) { if (keyword.get(i).toString().contains("StaticEffect")) {
String[] k = keyword.get(i).split(":"); String[] k = keyword.get(i).split(":");
sbLong.append(k[5]).append("\r\n"); sbLong.append(k[5]).append("\r\n");
/*} else if (keyword.get(i).toString().contains("stAnimate")) {
String[] k = keyword.get(i).split(":", 8);
if (!k[7].contains("no text")) {
sbLong.append(k[7]).append("\r\n");
}*/
} else if (keyword.get(i).toString().contains("Protection:")) { } else if (keyword.get(i).toString().contains("Protection:")) {
String[] k = keyword.get(i).split(":"); String[] k = keyword.get(i).split(":");
sbLong.append(k[2]).append("\r\n"); sbLong.append(k[2]).append("\r\n");

View File

@@ -702,8 +702,6 @@ public class GameAction {
com.execute(); com.execute();
} }
//GameActionUtil.stAnimate.execute();
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
Card c; Card c;

View File

@@ -2412,307 +2412,6 @@ public final class GameActionUtil {
///The commands above are in alphabetical order by cardname. ///The commands above are in alphabetical order by cardname.
} }
/** Constant <code>stAnimate</code>. */
//public static Command stAnimate = new Command() {
/** stAnimate
* Syntax:[ k[0] stAnimate[All][Self][Enchanted] : k[1] AnimateValid :
* k[2] P/T/Keyword : k[3] extra types : k[4] extra colors :
* k[5] Abilities : k[6] Special Conditions : k[7] Description
*
*/
/*private static final long serialVersionUID = -1404133561787349004L;
// storage stores the source card and the cards it gave its bonus to, to know what to remove
private ArrayList<StaticEffect> storage = new ArrayList<StaticEffect>();
public void execute() {
// remove all static effects
for (int i = 0; i < storage.size(); i++) {
removeStaticEffect(storage.get(i));
}
//clear the list
storage = new ArrayList<StaticEffect>();
//Gather Cards on the Battlefield with the stPump Keyword
CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield);
cards.getKeywordsContain("stAnimate");
// check each card
for (int i = 0; i < cards.size(); i++) {
Card cardWithKeyword = cards.get(i);
ArrayList<String> keywords = cardWithKeyword.getKeyword();
// check each keyword of the card
for (int j = 0; j < keywords.size(); j++) {
String keyword = keywords.get(j);
if (keyword.startsWith("stAnimate")) {
StaticEffect se = new StaticEffect(); //create a new StaticEffect
se.setSource(cardWithKeyword);
se.setKeywordNumber(j);
//get the affected cards
String[] k = keyword.split(":", 8);
if (specialConditionsMet(cardWithKeyword, k[6])) { //special conditions are isPresent, isValid
final String affected = k[1];
final String[] specific = affected.split(",");
// options are All, Self, Enchanted etc.
CardList affectedCards = getAffectedCards(cardWithKeyword, k, specific);
se.setAffectedCards(affectedCards);
String[] pt = k[2].split("/");
if (!k[2].equals("no changes") && pt.length > 1) {
int x = 0;
if (pt[0].contains("X") || pt[1].contains("X")) {
x = CardFactoryUtil.xCount(
cardWithKeyword, cardWithKeyword.getSVar("X").split("\\$")[1]);
}
se.setXValue(x);
int y = 0;
if (pt[1].contains("Y")) {
y = CardFactoryUtil.xCount(
cardWithKeyword, cardWithKeyword.getSVar("Y").split("\\$")[1]);
}
se.setYValue(y);
}
ArrayList<String> types = new ArrayList<String>();
if (!k[3].equalsIgnoreCase("no types")) {
types.addAll(Arrays.asList(k[3].split(",")));
if (types.contains("Overwrite")) {
types.remove("Overwrite");
se.setOverwriteTypes(true);
}
if (types.contains("KeepSupertype")) {
types.remove("KeepSupertype");
se.setKeepSupertype(true);
}
if (types.contains("RemoveSubTypes")) {
types.remove("RemoveSubTypes");
se.setRemoveSubTypes(true);
}
}
String colors = "";
if (!k[4].equalsIgnoreCase("no colors")) {
colors = k[4];
if (colors.contains(",Overwrite") || colors.contains("Overwrite")) {
colors = colors.replace(",Overwrite", "");
colors = colors.replace("Overwrite", "");
se.setOverwriteColors(true);
}
colors = CardUtil.getShortColorsString(
new ArrayList<String>(Arrays.asList(k[4].split(","))));
}
if (k[2].contains("Overwrite")) {
se.setOverwriteKeywords(true);
}
if (k[5].contains("Overwrite")) {
se.setOverwriteAbilities(true);
}
//give the boni to the affected cards
addStaticEffects(se, cardWithKeyword, affectedCards, k[2], types, colors);
storage.add(se); // store the information
}
}
}
}
} // execute()
private void addStaticEffects(final StaticEffect se, final Card source, final CardList affectedCards,
final String details, final ArrayList<String> types, final String colors)
{
for (int i = 0; i < affectedCards.size(); i++) {
Card affectedCard = affectedCards.get(i);
if (!details.equals("no changes")) {
String[] keyword = details.split("/", 3);
String powerStr = keyword[0];
String toughStr = keyword[1];
//copied from stSetPT power/toughness
if (!powerStr.equals("no change")) {
int power = powerStr.matches("[0-9][0-9]?") ? Integer.parseInt(powerStr) : CardFactoryUtil.xCount(affectedCard, powerStr);
se.addOriginalPT(affectedCard, affectedCard.getBaseAttack(), affectedCard.getBaseDefense());
affectedCard.setBaseAttack(power);
}
if (!toughStr.equals("no change")) {
int toughness = toughStr.matches("[0-9][0-9]?") ? Integer.parseInt(toughStr) : CardFactoryUtil.xCount(affectedCard, toughStr);
se.addOriginalPT(affectedCard, affectedCard.getBaseAttack(), affectedCard.getBaseDefense());
affectedCard.setBaseDefense(toughness);
}
if (se.isOverwriteKeywords()) {
se.addOriginalKeywords(affectedCard, affectedCard.getIntrinsicKeyword());
affectedCard.clearAllKeywords();
} else {
if (keyword.length != 2) {
int index = 2;
if (keyword.length == 1) {
index = 0;
}
String[] keywords = keyword[index].split(" & ");
for (int j = 0; j < keywords.length; j++) {
String kw = keywords[j];
affectedCard.addExtrinsicKeyword(kw);
}
}
}
}
if (se.isOverwriteTypes()) {
se.addOriginalTypes(affectedCard, affectedCard.getType());
if (!se.isKeepSupertype()) {
affectedCard.clearAllTypes();
} else {
ArrayList<String> acTypes = affectedCard.getType();
for (String t : acTypes) {
if (!CardUtil.isASuperType(t)) {
affectedCard.removeType(t);
}
}
}
}
if (se.isRemoveSubTypes()) {
se.addOriginalTypes(affectedCard, affectedCard.getType());
ArrayList<String> acTypes = affectedCard.getType();
for (String t : acTypes) {
if (CardUtil.isASubType(t)) {
affectedCard.removeType(t);
}
}
}
for (String type : types) {
if (!affectedCard.isType(type)) {
affectedCard.addType(type);
se.addType(affectedCard, type);
} else {
se.removeType(affectedCard, type);
}
}
//Abilities
if (se.isOverwriteAbilities()) {
se.addOriginalAbilities(affectedCard, affectedCard.getAllButFirstSpellAbility());
affectedCard.clearAllButFirstSpellAbility();
} else {
//TODO - adding SpellAbilities statically here not supported at this time
}
long t = affectedCard.addColor(colors, affectedCard, !se.isOverwriteColors(), true);
se.addTimestamp(affectedCard, t);
} //end for
}
void removeStaticEffect(final StaticEffect se) {
Card source = se.getSource();
CardList affected = se.getAffectedCards();
int num = se.getKeywordNumber();
String parse = source.getKeyword().get(num).toString();
String[] k = parse.split(":");
for (int i = 0; i < affected.size(); i++) {
Card c = affected.get(i);
removeStaticEffect(se, source, c, k);
}
se.clearAllTypes();
se.clearTimestamps();
}
private void removeStaticEffect(final StaticEffect se, final Card source,
final Card affectedCard, final String[] details)
{
String[] kw = details[2].split("/", 3);
if (!details[2].equals("no changes")) {
if (!kw[0].equals("no change")) {
affectedCard.setBaseAttack(se.getOriginalPower(affectedCard));
}
if (!kw[1].equals("no change")) {
affectedCard.setBaseDefense(se.getOriginalToughness(affectedCard));
}
}
for (String type : se.getTypes(affectedCard)) {
affectedCard.removeType(type);
}
if (se.isOverwriteTypes()) {
for (String type : se.getOriginalTypes(affectedCard)) {
if (!se.isKeepSupertype() || (se.isKeepSupertype() && !CardUtil.isASuperType(type))) {
affectedCard.addType(type);
}
}
}
if (se.isRemoveSubTypes()) {
for (String type : se.getOriginalTypes(affectedCard)) {
if (CardUtil.isASubType(type)) {
affectedCard.addType(type);
}
}
}
if (se.isOverwriteKeywords()) {
for (String keyw : se.getOriginalKeywords(affectedCard)) {
affectedCard.addIntrinsicKeyword(keyw);
}
} else {
if (kw.length != 2) {
int index = 2;
if (kw.length == 1) {
index = 0;
}
String[] keywords = kw[index].split(" & ");
for (int j = 0; j < keywords.length; j++) {
String keyw = keywords[j];
affectedCard.removeExtrinsicKeyword(keyw);
}
}
}
//Abilities
if (se.isOverwriteAbilities()) {
for (SpellAbility sa : se.getOriginalAbilities(affectedCard)) {
affectedCard.addSpellAbility(sa);
}
} else {
//TODO - adding SpellAbilities statically here not supported at this time
}
affectedCard.removeColor(se.getColorDesc(), affectedCard, !se.isOverwriteColors(),
se.getTimestamp(affectedCard));
} //end removeStaticEffects
private CardList getAffectedCards(final Card source, final String[] details, final String[] specific) {
// [Self], [All], [Enchanted]
CardList affected = new CardList();
String range = details[0].replaceFirst("stAnimate", "");
if (range.equals("Self")) {
affected.add(source);
} else if (range.equals("All")) {
affected.addAll(AllZoneUtil.getCardsIn(Zone.Battlefield));
} else if (range.equals("Enchanted")) {
Card en = source.getEnchantingCard();
if (en != null) {
affected.add(en);
}
}
affected = affected.getValidCards(specific, source.getController(), source);
return affected;
} //end getAffectedCards()
};*/
/** /**
* <p>doPowerSink.</p> * <p>doPowerSink.</p>

View File

@@ -288,16 +288,14 @@ public final class AbilityFactory_Animate {
if (!AllZone.getPhase().is(Constant.Phase.Combat_Begin) if (!AllZone.getPhase().is(Constant.Phase.Combat_Begin)
&& AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())
&& !AbilityFactory.isSorcerySpeed(sa) && !params.containsKey("ActivatingPhases") && !AbilityFactory.isSorcerySpeed(sa) && !params.containsKey("ActivatingPhases")
&& !params.containsKey("Permanent")) && !params.containsKey("Permanent")) {
{
return false; return false;
} }
//don't use instant speed animate abilities outside humans Combat_Declare_Attackers_InstantAbility step //don't use instant speed animate abilities outside humans Combat_Declare_Attackers_InstantAbility step
if ((!AllZone.getPhase().is(Constant.Phase.Combat_Declare_Attackers_InstantAbility) if ((!AllZone.getPhase().is(Constant.Phase.Combat_Declare_Attackers_InstantAbility)
|| AllZone.getCombat().getAttackers().length == 0) || AllZone.getCombat().getAttackers().length == 0)
&& AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) && AllZone.getPhase().isPlayerTurn(AllZone.getHumanPlayer())) {
{
return false; return false;
} }