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