mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Code cleanup
This commit is contained in:
@@ -198,13 +198,15 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (sbSize == 0 && mainSize == deckMinSize) {
|
||||
// Skip sideboard loop if there are no sideboarding opportunities
|
||||
newMain = main.toFlatList();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
do {
|
||||
if (newMain != null) {
|
||||
if (newMain.size() < deckMinSize) {
|
||||
String errMsg = String.format("Too few cards in your main deck (minimum %d), please make modifications to your deck again.", deckMinSize);
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), errMsg, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String errMsg = String.format("Too many cards in your sideboard (maximum %d), please make modifications to your deck again.", sbMax);
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), errMsg, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
@@ -241,10 +243,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (defender != null && assignDamageAsIfNotBlocked(attacker)) {
|
||||
map = new HashMap<Card, Integer>();
|
||||
map.put(null, damageDealt);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ((attacker.hasKeyword("Trample") && defender != null) || (blockers.size() > 1)) {
|
||||
map = CMatchUI.SINGLETON_INSTANCE.getDamageToAssign(attacker, blockers, damageDealt, defender, overrideOrder);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
map = new HashMap<Card, Integer>();
|
||||
map.put(blockers.get(0), damageDealt);
|
||||
}
|
||||
@@ -264,13 +268,15 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public Integer announceRequirements(SpellAbility ability, String announce, boolean canChooseZero) {
|
||||
List<Object> options = new ArrayList<Object>();
|
||||
for(int i = canChooseZero ? 0 : 1; i < 10; i++)
|
||||
for (int i = canChooseZero ? 0 : 1; i < 10; i++) {
|
||||
options.add(Integer.valueOf(i));
|
||||
}
|
||||
options.add("Other amount");
|
||||
|
||||
Object chosen = GuiChoose.oneOrNone("Choose " + announce + " for " + ability.getSourceCard().getName(), options);
|
||||
if (chosen instanceof Integer || chosen == null)
|
||||
if (chosen instanceof Integer || chosen == null) {
|
||||
return (Integer)chosen;
|
||||
}
|
||||
|
||||
String message = String.format("How much will you announce for %s?%s", announce, canChooseZero ? "" : " (X cannot be 0)");
|
||||
while (true){
|
||||
@@ -279,9 +285,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
if (StringUtils.isNumeric(str)) {
|
||||
Integer val = Integer.valueOf(str);
|
||||
if (val == 0 && canChooseZero || val > 0)
|
||||
if (val == 0 && canChooseZero || val > 0) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
GuiDialog.message("You have to enter a valid number", "Announce value");
|
||||
}
|
||||
}
|
||||
@@ -300,8 +307,9 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
private List<Card> choosePermanentsTo(int min, int max, List<Card> valid, String outerMessage) {
|
||||
max = Math.min(max, valid.size());
|
||||
if (max <= 0)
|
||||
if (max <= 0) {
|
||||
return new ArrayList<Card>();
|
||||
}
|
||||
|
||||
InputSelectCards inp = new InputSelectCardsFromList(min == 0 ? 1 : min, max, valid);
|
||||
inp.setMessage(outerMessage);
|
||||
@@ -331,10 +339,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public Card chooseSingleCardForEffect(Collection<Card> options, SpellAbility sa, String title, boolean isOptional) {
|
||||
// Human is supposed to read the message and understand from it what to choose
|
||||
if (options.isEmpty())
|
||||
if (options.isEmpty()) {
|
||||
return null;
|
||||
if ( !isOptional && options.size() == 1 )
|
||||
}
|
||||
if (!isOptional && options.size() == 1) {
|
||||
return Iterables.getFirst(options, null);
|
||||
}
|
||||
|
||||
boolean canUseSelectCardsInput = true;
|
||||
for (Card c : options) {
|
||||
@@ -417,8 +427,9 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public void reveal(String string, Collection<Card> cards, ZoneType zone, Player owner) {
|
||||
String message = string;
|
||||
if ( StringUtils.isBlank(message) )
|
||||
if (StringUtils.isBlank(message)) {
|
||||
message = String.format("Looking at %s's %s", owner, zone);
|
||||
}
|
||||
GuiChoose.oneOrNone(message, cards);
|
||||
}
|
||||
|
||||
@@ -428,20 +439,26 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
List<Card> toTop = null;
|
||||
|
||||
if (topN.size() == 1) {
|
||||
if (willPutCardOnTop(topN.get(0)))
|
||||
if (willPutCardOnTop(topN.get(0))) {
|
||||
toTop = topN;
|
||||
else
|
||||
}
|
||||
else {
|
||||
toBottom = topN;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
toBottom = GuiChoose.order("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, topN, null, null);
|
||||
topN.removeAll(toBottom);
|
||||
if ( topN.isEmpty() )
|
||||
if (topN.isEmpty()) {
|
||||
toTop = null;
|
||||
else if ( topN.size() == 1 )
|
||||
}
|
||||
else if (topN.size() == 1) {
|
||||
toTop = topN;
|
||||
else
|
||||
}
|
||||
else {
|
||||
toTop = GuiChoose.order("Arrange cards to be put on top of your library", "Cards arranged", 0, topN, null, null);
|
||||
}
|
||||
}
|
||||
return ImmutablePair.of(toTop, toBottom);
|
||||
}
|
||||
|
||||
@@ -539,7 +556,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
ability.resetTargets();
|
||||
if (select.chooseTargets(oldTarget.getNumTargeted())) {
|
||||
return ability.getTargets();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Return old target, since we had to reset them above
|
||||
return oldTarget;
|
||||
}
|
||||
@@ -556,9 +574,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
protected boolean hasAllTargets() {
|
||||
for (Card c : selected) {
|
||||
if (c.isType(uType))
|
||||
if (c.isType(uType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.hasAllTargets();
|
||||
}
|
||||
};
|
||||
@@ -625,8 +644,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
boolean maySkipPriority = mayAutoPass(phase) || isUiSetToSkipPhase(game.getPhaseHandler().getPlayerTurn(), phase);
|
||||
if (game.getStack().isEmpty() && maySkipPriority) {
|
||||
return;
|
||||
} else
|
||||
}
|
||||
else {
|
||||
autoPassCancel(); // probably cancel, since something has happened
|
||||
}
|
||||
|
||||
SpellAbility chosenSa = null;
|
||||
do {
|
||||
@@ -751,8 +772,9 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
@Override
|
||||
public Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility saSpellskite, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets) {
|
||||
if( allTargets.size() < 2)
|
||||
if (allTargets.size() < 2) {
|
||||
return Iterables.getFirst(allTargets, null);
|
||||
}
|
||||
|
||||
final Function<Pair<SpellAbilityStackInstance, GameObject>, String> fnToString = new Function<Pair<SpellAbilityStackInstance, GameObject>, String>() {
|
||||
@Override
|
||||
@@ -811,7 +833,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
AbilitySub a;
|
||||
if (i < min) {
|
||||
a = GuiChoose.one(modeTitle, choices);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
a = GuiChoose.oneOrNone(modeTitle, choices);
|
||||
}
|
||||
if (null == a) {
|
||||
|
||||
Reference in New Issue
Block a user