mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Checkstyle fixes in StaticAbility_Continuous
This commit is contained in:
@@ -19,7 +19,12 @@ import forge.card.trigger.TriggerHandler;
|
||||
|
||||
public class StaticAbility_Continuous {
|
||||
|
||||
public static void applyContinuousAbility(StaticAbility stAb) {
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
* @param stAb a StaticAbility
|
||||
*/
|
||||
public static void applyContinuousAbility(final StaticAbility stAb) {
|
||||
HashMap<String, String> params = stAb.getMapParams();
|
||||
Card hostCard = stAb.getHostCard();
|
||||
|
||||
@@ -37,13 +42,13 @@ public class StaticAbility_Continuous {
|
||||
int toughnessBonus = 0;
|
||||
int setPower = -1;
|
||||
int setToughness = -1;
|
||||
String addKeywords[] = null;
|
||||
String addAbilities[] = null;
|
||||
String addSVars[] = null;
|
||||
String addTypes[] = null;
|
||||
String removeTypes[] = null;
|
||||
String[] addKeywords = null;
|
||||
String[] addAbilities = null;
|
||||
String[] addSVars = null;
|
||||
String[] addTypes = null;
|
||||
String[] removeTypes = null;
|
||||
String addColors = null;
|
||||
String addTriggers[] = null;
|
||||
String[] addTriggers = null;
|
||||
boolean removeSuperTypes = false;
|
||||
boolean removeCardTypes = false;
|
||||
boolean removeSubTypes = false;
|
||||
@@ -69,8 +74,9 @@ public class StaticAbility_Continuous {
|
||||
else if (params.get("AddPower").equals("Y")) {
|
||||
powerBonus = CardFactoryUtil.xCount(hostCard, hostCard.getSVar("Y"));
|
||||
se.setYValue(powerBonus);
|
||||
} else {
|
||||
powerBonus = Integer.valueOf(params.get("AddPower"));
|
||||
}
|
||||
else powerBonus = Integer.valueOf(params.get("AddPower"));
|
||||
}
|
||||
|
||||
if (params.containsKey("AddToughness")) {
|
||||
@@ -81,26 +87,30 @@ public class StaticAbility_Continuous {
|
||||
else if (params.get("AddToughness").equals("Y")) {
|
||||
toughnessBonus = CardFactoryUtil.xCount(hostCard, hostCard.getSVar("Y"));
|
||||
se.setYValue(toughnessBonus);
|
||||
} else {
|
||||
toughnessBonus = Integer.valueOf(params.get("AddToughness"));
|
||||
}
|
||||
else toughnessBonus = Integer.valueOf(params.get("AddToughness"));
|
||||
}
|
||||
|
||||
if (params.containsKey("AddKeyword"))
|
||||
if (params.containsKey("AddKeyword")) {
|
||||
addKeywords = params.get("AddKeyword").split(" & ");
|
||||
}
|
||||
|
||||
if (params.containsKey("AddAbility")) {
|
||||
String sVars[] = params.get("AddAbility").split(" & ");
|
||||
for(int i = 0 ; i < sVars.length ; i++)
|
||||
String[] sVars = params.get("AddAbility").split(" & ");
|
||||
for (int i = 0; i < sVars.length; i++) {
|
||||
sVars[i] = hostCard.getSVar(sVars[i]);
|
||||
}
|
||||
addAbilities = sVars;
|
||||
}
|
||||
|
||||
if (params.containsKey("AddSVar"))
|
||||
if (params.containsKey("AddSVar")) {
|
||||
addSVars = params.get("AddSVar").split(" & ");
|
||||
}
|
||||
|
||||
if (params.containsKey("AddType")) {
|
||||
addTypes = params.get("AddType").split(" & ");
|
||||
if(addTypes[0].equals("ChosenType")) {
|
||||
if (addTypes[0].equals("ChosenType")) {
|
||||
String chosenType = hostCard.getChosenType();
|
||||
addTypes[0] = chosenType;
|
||||
se.setChosenType(chosenType);
|
||||
@@ -109,7 +119,7 @@ public class StaticAbility_Continuous {
|
||||
|
||||
if (params.containsKey("RemoveType")) {
|
||||
removeTypes = params.get("RemoveType").split(" & ");
|
||||
if(removeTypes[0].equals("ChosenType")) {
|
||||
if (removeTypes[0].equals("ChosenType")) {
|
||||
String chosenType = hostCard.getChosenType();
|
||||
removeTypes[0] = chosenType;
|
||||
se.setChosenType(chosenType);
|
||||
@@ -132,18 +142,22 @@ public class StaticAbility_Continuous {
|
||||
removeCreatureTypes = true;
|
||||
}
|
||||
|
||||
if (params.containsKey("AddColor"))
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(params.get("AddColor").split(" & "))));
|
||||
if (params.containsKey("AddColor")) {
|
||||
addColors = CardUtil.getShortColorsString(
|
||||
new ArrayList<String>(Arrays.asList(params.get("AddColor").split(" & "))));
|
||||
}
|
||||
|
||||
if (params.containsKey("SetColor")) {
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(params.get("SetColor").split(" & "))));
|
||||
addColors = CardUtil.getShortColorsString(
|
||||
new ArrayList<String>(Arrays.asList(params.get("SetColor").split(" & "))));
|
||||
se.setOverwriteColors(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("AddTrigger")) {
|
||||
String sVars[] = params.get("AddTrigger").split(" & ");
|
||||
for(int i = 0 ; i < sVars.length ; i++)
|
||||
String[] sVars = params.get("AddTrigger").split(" & ");
|
||||
for (int i = 0; i < sVars.length; i++) {
|
||||
sVars[i] = hostCard.getSVar(sVars[i]);
|
||||
}
|
||||
addTriggers = sVars;
|
||||
}
|
||||
|
||||
@@ -151,54 +165,66 @@ public class StaticAbility_Continuous {
|
||||
for (Player p : affectedPlayers) {
|
||||
|
||||
// add keywords
|
||||
if (addKeywords != null)
|
||||
for (String keyword : addKeywords)
|
||||
if (addKeywords != null) {
|
||||
for (String keyword : addKeywords) {
|
||||
p.addKeyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//start modifying the cards
|
||||
for (int i = 0; i < affectedCards.size(); i++) {
|
||||
Card affectedCard = affectedCards.get(i);
|
||||
|
||||
// set P/T
|
||||
if(params.containsKey("CharacteristicDefining")) {
|
||||
if (setPower != -1)
|
||||
if (params.containsKey("CharacteristicDefining")) {
|
||||
if (setPower != -1) {
|
||||
affectedCard.setBaseAttack(setPower);
|
||||
if (setToughness != -1)
|
||||
}
|
||||
if (setToughness != -1) {
|
||||
affectedCard.setBaseDefense(setToughness);
|
||||
}
|
||||
}
|
||||
else //non CharacteristicDefining
|
||||
if (setPower != -1 || setToughness != -1)
|
||||
if (setPower != -1 || setToughness != -1) {
|
||||
affectedCard.addNewPT(setPower, setToughness, hostCard.getTimestamp());
|
||||
}
|
||||
|
||||
// add P/T bonus
|
||||
affectedCard.addSemiPermanentAttackBoost(powerBonus);
|
||||
affectedCard.addSemiPermanentDefenseBoost(toughnessBonus);
|
||||
|
||||
// add keywords
|
||||
if (addKeywords != null)
|
||||
for (String keyword : addKeywords)
|
||||
if (addKeywords != null) {
|
||||
for (String keyword : addKeywords) {
|
||||
affectedCard.addExtrinsicKeyword(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
// add abilities
|
||||
if (addAbilities != null)
|
||||
for (String abilty : addAbilities)
|
||||
if (addAbilities != null) {
|
||||
for (String abilty : addAbilities) {
|
||||
if (abilty.startsWith("AB")) { // grant the ability
|
||||
AbilityFactory AF = new AbilityFactory();
|
||||
SpellAbility sa = AF.getAbility(abilty, affectedCard);
|
||||
AbilityFactory af = new AbilityFactory();
|
||||
SpellAbility sa = af.getAbility(abilty, affectedCard);
|
||||
sa.setType("Temporary");
|
||||
affectedCard.addSpellAbility(sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add SVars
|
||||
if (addSVars != null)
|
||||
for (String sVar : addSVars)
|
||||
if (addSVars != null) {
|
||||
for (String sVar : addSVars) {
|
||||
affectedCard.setSVar(sVar, hostCard.getSVar(sVar));
|
||||
}
|
||||
}
|
||||
|
||||
// add Types
|
||||
if (addTypes != null || removeTypes != null)
|
||||
affectedCard.addChangedCardTypes(addTypes, removeTypes, removeSuperTypes, removeCardTypes, removeSubTypes,
|
||||
removeCreatureTypes, hostCard.getTimestamp());
|
||||
if (addTypes != null || removeTypes != null) {
|
||||
affectedCard.addChangedCardTypes(addTypes, removeTypes, removeSuperTypes, removeCardTypes,
|
||||
removeSubTypes, removeCreatureTypes, hostCard.getTimestamp());
|
||||
}
|
||||
|
||||
// add colors
|
||||
if (addColors != null) {
|
||||
@@ -207,13 +233,14 @@ public class StaticAbility_Continuous {
|
||||
}
|
||||
|
||||
// add triggers
|
||||
if (addTriggers != null)
|
||||
if (addTriggers != null) {
|
||||
for (String trigger : addTriggers) {
|
||||
Trigger actualTrigger = TriggerHandler.parseTrigger(trigger,affectedCard, false);
|
||||
Trigger actualTrigger = TriggerHandler.parseTrigger(trigger, affectedCard, false);
|
||||
actualTrigger.setTemporary(true);
|
||||
affectedCard.addTrigger(actualTrigger);
|
||||
AllZone.getTriggerHandler().registerTrigger(actualTrigger);
|
||||
}
|
||||
}
|
||||
|
||||
// remove triggers
|
||||
if (params.containsKey("RemoveTriggers") || params.containsKey("RemoveAllAbilities")) {
|
||||
@@ -226,25 +253,25 @@ public class StaticAbility_Continuous {
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<Player> getAffectedPlayers(StaticAbility stAb) {
|
||||
private static ArrayList<Player> getAffectedPlayers(final StaticAbility stAb) {
|
||||
HashMap<String, String> params = stAb.getMapParams();
|
||||
Card hostCard = stAb.getHostCard();
|
||||
Player controller = hostCard.getController();
|
||||
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
if(!params.containsKey("Affected")) {
|
||||
if (!params.containsKey("Affected")) {
|
||||
return players;
|
||||
}
|
||||
|
||||
String[] strngs = params.get("Affected").split(",");
|
||||
|
||||
for (String str : strngs) {
|
||||
if(str.equals("Player") || str.equals("You")) {
|
||||
if (str.equals("Player") || str.equals("You")) {
|
||||
players.add(controller);
|
||||
}
|
||||
|
||||
if(str.equals("Player") || str.equals("Opponent")) {
|
||||
if (str.equals("Player") || str.equals("Opponent")) {
|
||||
players.add(controller.getOpponent());
|
||||
}
|
||||
}
|
||||
@@ -252,34 +279,39 @@ public class StaticAbility_Continuous {
|
||||
return players;
|
||||
}
|
||||
|
||||
private static CardList getAffectedCards(StaticAbility stAb) {
|
||||
private static CardList getAffectedCards(final StaticAbility stAb) {
|
||||
HashMap<String, String> params = stAb.getMapParams();
|
||||
Card hostCard = stAb.getHostCard();
|
||||
Player controller = hostCard.getController();
|
||||
|
||||
if(params.containsKey("CharacteristicDefining"))
|
||||
if (params.containsKey("CharacteristicDefining")) {
|
||||
return new CardList(hostCard); // will always be the card itself
|
||||
}
|
||||
|
||||
// non - CharacteristicDefining
|
||||
CardList affectedCards;
|
||||
String affectedZone = "Battlefield"; // default
|
||||
|
||||
if (params.containsKey("AffectedZone"))
|
||||
if (params.containsKey("AffectedZone")) {
|
||||
affectedZone = params.get("AffectedZone");
|
||||
}
|
||||
|
||||
affectedCards = AllZoneUtil.getCardsInZone(affectedZone);
|
||||
|
||||
if (params.containsKey("Affected") && !params.get("Affected").contains(",")) {
|
||||
if (params.get("Affected").contains("Self"))
|
||||
if (params.get("Affected").contains("Self")) {
|
||||
affectedCards = new CardList(hostCard);
|
||||
else if (params.get("Affected").contains("EnchantedBy"))
|
||||
} else if (params.get("Affected").contains("EnchantedBy")) {
|
||||
affectedCards = new CardList(hostCard.getEnchantingCard());
|
||||
else if (params.get("Affected").contains("EquippedBy"))
|
||||
} else if (params.get("Affected").contains("EquippedBy")) {
|
||||
affectedCards = new CardList(hostCard.getEquippingCard());
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("Affected"))
|
||||
affectedCards = affectedCards.getValidCards(params.get("Affected").split(","), controller, hostCard);
|
||||
if (params.containsKey("Affected")) {
|
||||
affectedCards = affectedCards.getValidCards(
|
||||
params.get("Affected").split(","), controller, hostCard);
|
||||
}
|
||||
|
||||
return affectedCards;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user