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

View File

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

View File

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

View File

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