From cda130b23303c10bb69516cbd4a2e5a619458dd4 Mon Sep 17 00:00:00 2001 From: drdev Date: Sun, 7 Sep 2014 18:38:53 +0000 Subject: [PATCH] More code cleanup --- .../forge/game/spellability/SpellAbility.java | 45 +++++++++++-------- .../forge/player/HumanPlaySpellAbility.java | 6 +-- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index 6a05c756d60..3e920acf371 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -131,8 +131,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit public final AbilityManaPart getManaPartRecursive() { SpellAbility tail = this; while (tail != null) { - if(tail.manaPart != null) + if (tail.manaPart != null) { return tail.manaPart; + } tail = tail.getSubAbility(); } return null; @@ -140,14 +141,17 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit public final boolean isManaAbility() { // Check whether spell or ability first - if (this.isSpell()) + if (this.isSpell()) { return false; + } // without a target - if (this.usesTargeting()) return false; - if (getRestrictions() != null && getRestrictions().getPlaneswalker()) + if (this.usesTargeting()) { return false; } + if (getRestrictions() != null && getRestrictions().getPlaneswalker()) { return false; //Loyalty ability, not a mana ability. - if (this.isWrapper() && ((WrappedAbility) this).getTrigger().getMode() != TriggerType.TapsForMana) + } + if (this.isWrapper() && ((WrappedAbility) this).getTrigger().getMode() != TriggerType.TapsForMana) { return false; + } return getManaPartRecursive() != null; } @@ -1127,8 +1131,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit } String[] validTgt = tr.getValidTgts(); - if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getHostCard())) + if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getHostCard())) { return false; + } } // Restrictions coming from target @@ -1298,7 +1303,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit while (null != parent.getParent()) { parent = parent.getParent(); } - return parent; } @@ -1487,10 +1491,10 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit targetChosen.add(card); final String desc; - if (!card.isFaceDown()) { desc = this.getHostCard().getName() + " - targeting " + card; - } else { + } + else { desc = this.getHostCard().getName() + " - targeting Morph(" + card.getUniqueNumber() + ")"; } this.setStackDescription(desc); @@ -1533,7 +1537,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit return ImmutableList.of(); } - public SpellAbility getSATargetingCard() { return targetChosen.isTargetingAnyCard() ? this : getParentTargetingCard(); } @@ -1544,8 +1547,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit parent = ((WrappedAbility) parent).getWrappedAbility(); } while (parent != null) { - if (parent.targetChosen.isTargetingAnyCard()) + if (parent.targetChosen.isTargetingAnyCard()) { return parent; + } parent = parent.getParent(); } return null; @@ -1675,15 +1679,21 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit final String[] incR = restriction.split("\\.", 2); if (incR[0].equals("Spell")) { - if (!this.isSpell()) + if (!this.isSpell()) { return false; - } else if (incR[0].equals("Triggered")) { - if (!this.isTrigger()) + } + } + else if (incR[0].equals("Triggered")) { + if (!this.isTrigger()) { return false; - } else if (incR[0].equals("Activated")) { - if (!(this instanceof AbilityActivated)) + } + } + else if (incR[0].equals("Activated")) { + if (!(this instanceof AbilityActivated)) { return false; - } else { //not a spell/ability type + } + } + else { //not a spell/ability type return false; } @@ -1812,5 +1822,4 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit this.subAbility.setIntrinsic(i); } } - } \ No newline at end of file diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index 68889d69619..b19738c67d1 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -198,7 +198,7 @@ public class HumanPlaySpellAbility { // SA Params as comma delimited list String announce = ability.getParam("Announce"); if (announce != null) { - for(String aVar : announce.split(",")) { + for (String aVar : announce.split(",")) { String varName = aVar.trim(); boolean isX = "X".equalsIgnoreCase(varName); @@ -222,12 +222,12 @@ public class HumanPlaySpellAbility { return true; } + // Announcing Requirements like choosing creature type or number private boolean announceType() { - // Announcing Requirements like choosing creature type or number String announce = ability.getParam("AnnounceType"); PlayerController pc = ability.getActivatingPlayer().getController(); if (announce != null) { - for(String aVar : announce.split(",")) { + for (String aVar : announce.split(",")) { String varName = aVar.trim(); if ("CreatureType".equals(varName)) { String choice = pc.chooseSomeType("Creature", ability, CardType.getCreatureTypes(), new ArrayList());