mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Code cleanup
This commit is contained in:
@@ -300,7 +300,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
boolean cardsAreInMyHandOrBattlefield = true;
|
boolean cardsAreInMyHandOrBattlefield = true;
|
||||||
for(Card c : sourceList) {
|
for(Card c : sourceList) {
|
||||||
Zone z = c.getZone();
|
Zone z = c.getZone();
|
||||||
if ( z != null && ( z.is(ZoneType.Battlefield) || z.is(ZoneType.Hand, player)))
|
if (z != null && (z.is(ZoneType.Battlefield) || z.is(ZoneType.Hand, player)))
|
||||||
continue;
|
continue;
|
||||||
cardsAreInMyHandOrBattlefield = false;
|
cardsAreInMyHandOrBattlefield = false;
|
||||||
break;
|
break;
|
||||||
@@ -448,7 +448,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
message = "Looking at cards in {player's} " + zone.name();
|
message = "Looking at cards in {player's} " + zone.name();
|
||||||
}
|
}
|
||||||
String fm = formatMessage(message, owner);
|
String fm = formatMessage(message, owner);
|
||||||
if ( !cards.isEmpty() )
|
if (!cards.isEmpty())
|
||||||
GuiChoose.reveal(fm, cards);
|
GuiChoose.reveal(fm, cards);
|
||||||
else
|
else
|
||||||
GuiDialog.message("There are no cards in the named location", fm);
|
GuiDialog.message("There are no cards in the named location", fm);
|
||||||
@@ -710,7 +710,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
||||||
if ( sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero()
|
if (sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero()
|
||||||
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS))
|
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -909,7 +909,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
private byte chooseColorCommon(String message, Card c, ColorSet colors, boolean withColorless) {
|
private byte chooseColorCommon(String message, Card c, ColorSet colors, boolean withColorless) {
|
||||||
int cntColors = colors.countColors();
|
int cntColors = colors.countColors();
|
||||||
if( withColorless ) cntColors++;
|
if(withColorless) cntColors++;
|
||||||
String[] colorNames = new String[cntColors];
|
String[] colorNames = new String[cntColors];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if(withColorless)
|
if(withColorless)
|
||||||
@@ -998,8 +998,9 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
InputProliferate inp = new InputProliferate();
|
InputProliferate inp = new InputProliferate();
|
||||||
inp.setCancelAllowed(true);
|
inp.setCancelAllowed(true);
|
||||||
inp.showAndWait();
|
inp.showAndWait();
|
||||||
if ( inp.hasCancelled() )
|
if (inp.hasCancelled()) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return inp.getProliferationMap();
|
return inp.getProliferationMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1007,7 +1008,6 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
public boolean chooseTargetsFor(SpellAbility currentAbility) {
|
public boolean chooseTargetsFor(SpellAbility currentAbility) {
|
||||||
final TargetSelection select = new TargetSelection(currentAbility);
|
final TargetSelection select = new TargetSelection(currentAbility);
|
||||||
return select.chooseTargets(null);
|
return select.chooseTargets(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package forge.player;
|
package forge.player;
|
||||||
|
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@@ -65,12 +68,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A prototype for player controller class
|
* A prototype for player controller class
|
||||||
@@ -119,16 +116,6 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
return null; //TODO: delay ability until choice made
|
return null; //TODO: delay ability until choice made
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @param c
|
|
||||||
*/
|
|
||||||
/**public void playFromSuspend(Card c) {
|
|
||||||
c.setSuspendCast(true);
|
|
||||||
HumanPlay.playCardWithoutPayingManaCost(player, c);
|
|
||||||
}**/
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.game.player.PlayerController#mayPlaySpellAbilityForFree(forge.card.spellability.SpellAbility)
|
* @see forge.game.player.PlayerController#mayPlaySpellAbilityForFree(forge.card.spellability.SpellAbility)
|
||||||
*/
|
*/
|
||||||
@@ -155,7 +142,6 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
CardPool main = deck.get(DeckSection.Main);
|
CardPool main = deck.get(DeckSection.Main);
|
||||||
|
|
||||||
|
|
||||||
int mainSize = main.countAll();
|
int mainSize = main.countAll();
|
||||||
int sbSize = sideboard.countAll();
|
int sbSize = sideboard.countAll();
|
||||||
int combinedDeckSize = mainSize + sbSize;
|
int combinedDeckSize = mainSize + sbSize;
|
||||||
@@ -258,7 +244,6 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
return Lists.newArrayList(inp.getSelected());
|
return Lists.newArrayList(inp.getSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.game.player.PlayerController#chooseCardsForEffect(java.util.Collection, forge.card.spellability.SpellAbility, java.lang.String, int, boolean)
|
* @see forge.game.player.PlayerController#chooseCardsForEffect(java.util.Collection, forge.card.spellability.SpellAbility, java.lang.String, int, boolean)
|
||||||
*/
|
*/
|
||||||
@@ -274,15 +259,16 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
// try to use InputSelectCardsFromList when possible
|
// try to use InputSelectCardsFromList when possible
|
||||||
boolean cardsAreInMyHandOrBattlefield = true;
|
boolean cardsAreInMyHandOrBattlefield = true;
|
||||||
for(Card c : sourceList) {
|
for (Card c : sourceList) {
|
||||||
Zone z = c.getZone();
|
Zone z = c.getZone();
|
||||||
if ( z != null && ( z.is(ZoneType.Battlefield) || z.is(ZoneType.Hand, player)))
|
if (z != null && (z.is(ZoneType.Battlefield) || z.is(ZoneType.Hand, player))) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
cardsAreInMyHandOrBattlefield = false;
|
cardsAreInMyHandOrBattlefield = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cardsAreInMyHandOrBattlefield) {
|
if (cardsAreInMyHandOrBattlefield) {
|
||||||
InputSelectCardsFromList sc = new InputSelectCardsFromList(min, max, sourceList);
|
InputSelectCardsFromList sc = new InputSelectCardsFromList(min, max, sourceList);
|
||||||
sc.setMessage(title);
|
sc.setMessage(title);
|
||||||
sc.setCancelAllowed(isOptional);
|
sc.setCancelAllowed(isOptional);
|
||||||
@@ -418,7 +404,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
message = "Looking at cards in {player's} " + zone.name();
|
message = "Looking at cards in {player's} " + zone.name();
|
||||||
}
|
}
|
||||||
String fm = formatMessage(message, owner);
|
String fm = formatMessage(message, owner);
|
||||||
if ( !cards.isEmpty() )
|
if (!cards.isEmpty())
|
||||||
GuiChoose.reveal(fm, cards);
|
GuiChoose.reveal(fm, cards);
|
||||||
else
|
else
|
||||||
GuiDialog.message("There are no cards in the named location", fm);
|
GuiDialog.message("There are no cards in the named location", fm);
|
||||||
@@ -590,7 +576,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional) {
|
public String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional) {
|
||||||
if(isOptional)
|
if (isOptional)
|
||||||
return GuiChoose.oneOrNone("Choose a " + kindOfType.toLowerCase() + " type", validTypes);
|
return GuiChoose.oneOrNone("Choose a " + kindOfType.toLowerCase() + " type", validTypes);
|
||||||
else
|
else
|
||||||
return GuiChoose.one("Choose a " + kindOfType.toLowerCase() + " type", validTypes);
|
return GuiChoose.one("Choose a " + kindOfType.toLowerCase() + " type", validTypes);
|
||||||
@@ -680,7 +666,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
||||||
if ( sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero()
|
if (sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero()
|
||||||
&& !FModel.getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS))
|
&& !FModel.getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -793,7 +779,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String formatMessage(String message, Object related) {
|
private String formatMessage(String message, Object related) {
|
||||||
if(related instanceof Player && message.indexOf("{player") >= 0)
|
if (related instanceof Player && message.indexOf("{player") >= 0)
|
||||||
message = message.replace("{player}", mayBeYou(related)).replace("{player's}", Lang.getPossesive(mayBeYou(related)));
|
message = message.replace("{player}", mayBeYou(related)).replace("{player's}", Lang.getPossesive(mayBeYou(related)));
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
@@ -879,10 +865,10 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
private byte chooseColorCommon(String message, Card c, ColorSet colors, boolean withColorless) {
|
private byte chooseColorCommon(String message, Card c, ColorSet colors, boolean withColorless) {
|
||||||
int cntColors = colors.countColors();
|
int cntColors = colors.countColors();
|
||||||
if( withColorless ) cntColors++;
|
if (withColorless) { cntColors++; }
|
||||||
String[] colorNames = new String[cntColors];
|
String[] colorNames = new String[cntColors];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if(withColorless)
|
if (withColorless)
|
||||||
colorNames[i++] = MagicColor.toLongString((byte)0);
|
colorNames[i++] = MagicColor.toLongString((byte)0);
|
||||||
for (byte b : colors) {
|
for (byte b : colors) {
|
||||||
colorNames[i++] = MagicColor.toLongString(b);
|
colorNames[i++] = MagicColor.toLongString(b);
|
||||||
@@ -919,7 +905,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReplacementEffect chooseSingleReplacementEffect(String prompt, List<ReplacementEffect> possibleReplacers, HashMap<String, Object> runParams) {
|
public ReplacementEffect chooseSingleReplacementEffect(String prompt, List<ReplacementEffect> possibleReplacers, HashMap<String, Object> runParams) {
|
||||||
if(possibleReplacers.size() == 1)
|
if (possibleReplacers.size() == 1)
|
||||||
return possibleReplacers.get(0);
|
return possibleReplacers.get(0);
|
||||||
return GuiChoose.one(prompt, possibleReplacers);
|
return GuiChoose.one(prompt, possibleReplacers);
|
||||||
}
|
}
|
||||||
@@ -987,7 +973,8 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
final String p2Str = String.format("Pile 2 (%s cards)", pile2.size());
|
final String p2Str = String.format("Pile 2 (%s cards)", pile2.size());
|
||||||
final String[] possibleValues = { p1Str , p2Str };
|
final String[] possibleValues = { p1Str , p2Str };
|
||||||
return GuiDialog.confirm(sa.getHostCard(), "Choose a Pile", possibleValues);
|
return GuiDialog.confirm(sa.getHostCard(), "Choose a Pile", possibleValues);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
final Card[] disp = new Card[pile1.size() + pile2.size() + 2];
|
final Card[] disp = new Card[pile1.size() + pile2.size() + 2];
|
||||||
disp[0] = new Card(-1);
|
disp[0] = new Card(-1);
|
||||||
disp[0].setName("Pile 1");
|
disp[0].setName("Pile 1");
|
||||||
@@ -1053,8 +1040,9 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
while(true) {
|
while(true) {
|
||||||
cp = chooseSinglePaperCard(sa, message, cpp, sa.getHostCard().getName());
|
cp = chooseSinglePaperCard(sa, message, cpp, sa.getHostCard().getName());
|
||||||
Card instanceForPlayer = Card.fromPaperCard(cp, player); // the Card instance for test needs a game to be tested
|
Card instanceForPlayer = Card.fromPaperCard(cp, player); // the Card instance for test needs a game to be tested
|
||||||
if (instanceForPlayer.isValid(valid, sa.getHostCard().getController(), sa.getHostCard()))
|
if (instanceForPlayer.isValid(valid, sa.getHostCard().getController(), sa.getHostCard())) {
|
||||||
return cp.getName();
|
return cp.getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user