From a44f27d2808ddf91b2e397d8407544cd385b8fc6 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Thu, 16 May 2013 06:21:15 +0000 Subject: [PATCH] minor rearrangement (just need to get these out of files-to-commit list) --- src/main/java/forge/card/mana/ManaPool.java | 43 +++++-------------- .../card/spellability/AbilityManaPart.java | 8 ++-- 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/src/main/java/forge/card/mana/ManaPool.java b/src/main/java/forge/card/mana/ManaPool.java index d428893bf45..a6115ac2c70 100644 --- a/src/main/java/forge/card/mana/ManaPool.java +++ b/src/main/java/forge/card/mana/ManaPool.java @@ -560,27 +560,17 @@ public class ManaPool { this.owner.updateObservers(); } - /** - *

- * accountFor. - *

- * - * @param sa - * a {@link forge.card.spellability.SpellAbility} object. - * @param ma - * a {@link forge.card.spellability.AbilityMana} object. - * @return a boolean. - */ + private boolean accountFor(final SpellAbility sa, final AbilityManaPart ma) { final ArrayList manaPaid = sa.getPayingMana(); - + if ((manaPaid.size() == 0) && (this.floatingMana.size() == 0)) { return false; } - + final ArrayList removePaying = new ArrayList(); final ArrayList removeFloating = new ArrayList(); - + boolean manaNotAccountedFor = false; // loop over mana produced by mana ability for (Mana mana : ma.getLastProduced()) { @@ -595,13 +585,13 @@ public class ManaPool { break; } } - + // When is it legitimate for all the mana not to be accountable? // Does this condition really indicate an bug in Forge? if (manaNotAccountedFor) { return false; } - + for (int k = 0; k < removePaying.size(); k++) { this.removeManaFrom(manaPaid, removePaying.get(k)); } @@ -611,23 +601,10 @@ public class ManaPool { return true; } - /** - *

- * refundManaPaid. - *

- * - * @param sa - * a {@link forge.card.spellability.SpellAbility} object. - * @param untap - * a boolean. - */ public final void refundManaPaid(final SpellAbility sa, final boolean untap) { - // TODO having some crash in here related to undo and not tracking - // abilities properly - final List payAbs = sa.getPayingManaAbilities(); - - // go through paidAbilities if they are undoable - for (final SpellAbility am : payAbs) { + // TODO having some crash in here related to undo and not tracking abilities properly + + for (final SpellAbility am : sa.getPayingManaAbilities()) { // go through paidAbilities if they are undoable AbilityManaPart m = am.getManaPart(); if (am.isUndoable()) { if (this.accountFor(sa, m)) { @@ -636,7 +613,7 @@ public class ManaPool { // else can't account let clearPay move paying back to floating } } - + // move leftover pay back to floating this.clearManaPaid(sa, true); } diff --git a/src/main/java/forge/card/spellability/AbilityManaPart.java b/src/main/java/forge/card/spellability/AbilityManaPart.java index 2f474cee2e1..c617b2723b8 100644 --- a/src/main/java/forge/card/spellability/AbilityManaPart.java +++ b/src/main/java/forge/card/spellability/AbilityManaPart.java @@ -19,6 +19,7 @@ package forge.card.spellability; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import forge.Card; @@ -306,10 +307,9 @@ public class AbilityManaPart implements java.io.Serializable { return true; } - if (this.getOrigProduced().contains("Chosen")) { - if (this.getSourceCard() != null && !this.getSourceCard().getChosenColor().isEmpty() - && MagicColor.toShortString(this.getSourceCard().getChosenColor().get(0)) - .contains(s)) { + if (this.getOrigProduced().contains("Chosen") && this.getSourceCard() == null ) { + List chosenCol = this.getSourceCard().getChosenColor(); + if ( !chosenCol.isEmpty() && MagicColor.toShortString(chosenCol.get(0)).contains(s)) { return true; } }