last call to gui eliminated in game code, will try to extract module next

This commit is contained in:
Maxmtg
2014-01-20 18:01:12 +00:00
parent 7b47938062
commit f27b3e469a
5 changed files with 264 additions and 265 deletions

2
.gitattributes vendored
View File

@@ -15132,7 +15132,6 @@ forge-gui/src/main/java/forge/game/spellability/AbilityManaPart.java svneol=nati
forge-gui/src/main/java/forge/game/spellability/AbilityStatic.java svneol=native#text/plain
forge-gui/src/main/java/forge/game/spellability/AbilitySub.java svneol=native#text/plain
forge-gui/src/main/java/forge/game/spellability/AbilityTriggered.java svneol=native#text/plain
forge-gui/src/main/java/forge/game/spellability/HumanPlaySpellAbility.java svneol=native#text/plain
forge-gui/src/main/java/forge/game/spellability/ISpellAbility.java -text
forge-gui/src/main/java/forge/game/spellability/OptionalCost.java -text
forge-gui/src/main/java/forge/game/spellability/Spell.java svneol=native#text/plain
@@ -15448,6 +15447,7 @@ forge-gui/src/main/java/forge/gui/menus/MenuUtil.java -text
forge-gui/src/main/java/forge/gui/package-info.java svneol=native#text/plain
forge-gui/src/main/java/forge/gui/player/HumanCostDecision.java -text
forge-gui/src/main/java/forge/gui/player/HumanPlay.java -text
forge-gui/src/main/java/forge/gui/player/HumanPlaySpellAbility.java -text
forge-gui/src/main/java/forge/gui/player/LobbyPlayerHuman.java -text
forge-gui/src/main/java/forge/gui/player/PlayerControllerHuman.java -text
forge-gui/src/main/java/forge/gui/player/TargetSelection.java svneol=native#text/plain

View File

@@ -20,7 +20,6 @@ import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
public class ManaEffect extends SpellAbilityEffect {
@@ -50,28 +49,26 @@ public class ManaEffect extends SpellAbilityEffect {
if (activator.isHuman()) {
//String colorsNeeded = abMana.getExpressChoice();
String[] colorsProduced = abMana.getComboColors().split(" ");
final StringBuilder choiceString = new StringBuilder();
List<String> colorMenu = null;
ColorSet colorOptions = null;
if (!abMana.isAnyMana()) {
colorMenu = new ArrayList<String>();
//loop through colors to make menu
for (int nColor = 0; nColor < colorsProduced.length; nColor++) {
colorMenu.add(forge.card.MagicColor.toLongString(colorsProduced[nColor]));
}
colorOptions = ColorSet.fromNames(colorsProduced);
}
else {
colorMenu = MagicColor.Constant.ONLY_COLORS;
colorOptions = ColorSet.fromNames(MagicColor.Constant.ONLY_COLORS);
}
for (int nMana = 1; nMana <= amount; nMana++) {
String choice = "";
Object o = GuiChoose.one("Select Mana to Produce", colorMenu);
if (o == null) {
byte chosenColor = activator.getController().chooseColor("Select Mana to Produce", sa, colorOptions);
if (chosenColor == 0) {
final StringBuilder sb = new StringBuilder();
sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for ");
sb.append(card.getName());
throw new RuntimeException(sb.toString());
} else {
choice = MagicColor.toShortString((String) o);
choice = MagicColor.toShortString(chosenColor);
if (nMana != 1) {
choiceString.append(" ");
}
@@ -116,26 +113,26 @@ public class ManaEffect extends SpellAbilityEffect {
choice = colorsNeeded;
}
else {
List<String> colorMenu = null;
ColorSet colorMenu = null;
if (colorsNeeded.length() > 1 && colorsNeeded.length() < 5) {
colorMenu = new ArrayList<String>();
byte mask = 0;
//loop through colors to make menu
for (int nChar = 0; nChar < colorsNeeded.length(); nChar++) {
colorMenu.add(forge.card.MagicColor.toLongString(colorsNeeded.substring(nChar, nChar + 1)));
mask |= forge.card.MagicColor.fromName(colorsNeeded.substring(nChar, nChar + 1));
}
colorMenu = ColorSet.fromMask(mask);
}
else {
colorMenu = MagicColor.Constant.ONLY_COLORS;
colorMenu = ColorSet.fromNames(MagicColor.Constant.ONLY_COLORS);
}
String s = GuiChoose.one("Select Mana to Produce", colorMenu);
if (s == null) {
byte val = act.getController().chooseColor("Select Mana to Produce", sa, colorMenu);
if (0 == val) {
final StringBuilder sb = new StringBuilder();
sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for ");
sb.append(card.getName());
throw new RuntimeException(sb.toString());
} else {
choice = MagicColor.toShortString(s);
}
choice = MagicColor.toShortString(val);
}
abMana.setExpressChoice(choice);
}

View File

@@ -3,6 +3,7 @@ package forge.game.ability.effects;
import java.util.Collection;
import java.util.List;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
@@ -10,7 +11,6 @@ import forge.game.card.CardUtil;
import forge.game.player.Player;
import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.SpellAbility;
import forge.gui.GuiChoose;
public class ManaReflectedEffect extends SpellAbilityEffect {
@@ -65,7 +65,7 @@ public class ManaReflectedEffect extends SpellAbilityEffect {
baseMana = MagicColor.toShortString(colors.iterator().next());
} else {
if (player.isHuman()) {
baseMana = GuiChoose.one("Select Mana to Produce", colors);
baseMana = MagicColor.toShortString(player.getController().chooseColor("Select Mana to Produce", sa, ColorSet.fromNames(colors)));
} else {
// AI doesn't really have anything here yet
baseMana = sa.getManaPart().getExpressChoice();

View File

@@ -52,7 +52,6 @@ import forge.game.cost.PaymentDecision;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.player.Player;
import forge.game.spellability.Ability;
import forge.game.spellability.HumanPlaySpellAbility;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.game.spellability;
package forge.gui.player;
import java.util.ArrayList;
@@ -32,8 +32,11 @@ import forge.game.cost.CostPartMana;
import forge.game.cost.CostPayment;
import forge.game.player.Player;
import forge.game.player.PlayerController;
import forge.game.spellability.AbilitySub;
import forge.game.spellability.Spell;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.game.zone.Zone;
import forge.gui.player.HumanCostDecision;
/**
* <p>
@@ -41,7 +44,7 @@ import forge.gui.player.HumanCostDecision;
* </p>
*
* @author Forge
* @version $Id$
* @version $Id: HumanPlaySpellAbility.java 24317 2014-01-17 08:32:39Z Max mtg $
*/
public class HumanPlaySpellAbility {
private final SpellAbility ability;