diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 2958ef944d5..124a4a8e9c4 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1120,9 +1120,8 @@ public class AiController { CardCollection discards = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.hasCMC(cmc)); if (discards.isEmpty()) { return null; - } else { - return new CardCollection(ComputerUtilCard.getWorstAI(discards)); } + return new CardCollection(ComputerUtilCard.getWorstAI(discards)); } if (sa.hasParam("AnyNumber")) { diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 309ce371d07..03dceacc08e 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2929,9 +2929,8 @@ public class ComputerUtil { } if (targetSpellCard == null) { return false; - } else { - sa.getTargets().add(targetSpellCard); } + sa.getTargets().add(targetSpellCard); return true; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 45be82de490..00433b71a17 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -1214,10 +1214,9 @@ public class ComputerUtilCard { final float valueNow = Math.max(valueTempo, threat); if (valueNow < 0.2) { //hard floor to reduce ridiculous odds for instants over time return false; - } else { - final float chance = MyRandom.getRandom().nextFloat(); - return chance < valueNow; } + final float chance = MyRandom.getRandom().nextFloat(); + return chance < valueNow; } /** diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 51d282c40a9..acc9fa5c19e 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -162,10 +162,9 @@ public class ComputerUtilCost { Card pref = ComputerUtil.getCardPreference(ai, source, "DiscardCost", typeList); if (pref == null) { return false; - } else { - typeList.remove(pref); - hand.remove(pref); } + typeList.remove(pref); + hand.remove(pref); } } } diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 5cbdf798116..93aec373170 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -108,9 +108,7 @@ public class PlayerControllerAi extends PlayerController { if (abilities.size() == 0) { return null; } - else { - return abilities.get(0); - } + return abilities.get(0); } public AiController getAi() { diff --git a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java index fdd19038669..2e8066cb5bd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java @@ -30,40 +30,38 @@ public class AmassAi extends SpellAbilityAi { if (!aiArmies.isEmpty()) { return CardLists.count(aiArmies, CardPredicates.canReceiveCounters(CounterEnumType.P1P1)) > 0; - } else { - final String tokenScript = "b_0_0_zombie_army"; - final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("Num", "1"), sa); + } + final String tokenScript = "b_0_0_zombie_army"; + final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("Num", "1"), sa); - Card token = TokenInfo.getProtoType(tokenScript, sa, false); + Card token = TokenInfo.getProtoType(tokenScript, sa, false); - if (token == null) { - return false; - } - - token.setController(ai, 0); - token.setLastKnownZone(ai.getZone(ZoneType.Battlefield)); - - boolean result = true; - - // need to check what the cards would be on the battlefield - // do not attach yet, that would cause Events - CardCollection preList = new CardCollection(token); - game.getAction().checkStaticAbilities(false, Sets.newHashSet(token), preList); - - if (token.canReceiveCounters(CounterEnumType.P1P1)) { - token.setCounters(CounterEnumType.P1P1, amount); - } - - if (token.isCreature() && token.getNetToughness() < 1) { - result = false; - } - - //reset static abilities - game.getAction().checkStaticAbilities(false); - - return result; + if (token == null) { + return false; } + token.setController(ai, 0); + token.setLastKnownZone(ai.getZone(ZoneType.Battlefield)); + + boolean result = true; + + // need to check what the cards would be on the battlefield + // do not attach yet, that would cause Events + CardCollection preList = new CardCollection(token); + game.getAction().checkStaticAbilities(false, Sets.newHashSet(token), preList); + + if (token.canReceiveCounters(CounterEnumType.P1P1)) { + token.setCounters(CounterEnumType.P1P1, amount); + } + + if (token.isCreature() && token.getNetToughness() < 1) { + result = false; + } + + //reset static abilities + game.getAction().checkStaticAbilities(false); + + return result; } @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 0a86c7e1018..58ac2740907 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -1452,12 +1452,11 @@ public class ChangeZoneAi extends SpellAbilityAi { if (sa.getTargets().size() == 0 || sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) { sa.resetTargets(); return false; - } else { - if (!ComputerUtil.shouldCastLessThanMax(ai, source)) { - return false; - } - break; + } + if (!ComputerUtil.shouldCastLessThanMax(ai, source)) { + return false; } + break; } list.remove(choice); @@ -1958,9 +1957,8 @@ public class ChangeZoneAi extends SpellAbilityAi { if (choice != null) { sa.getTargets().add(choice); return true; - } else { - return false; } + return false; } private static CardCollection getSafeTargetsIfUnlessCostPaid(Player ai, SpellAbility sa, Iterable potentialTgts) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 519863776c9..1396a1bd6dd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -141,27 +141,26 @@ public class ChooseSourceAi extends SpellAbilityAi { Card bestCreature = ComputerUtilCard.getBestCreatureAI(permanentSources); if (bestCreature != null) { return bestCreature; - } else { - // No optimal creature was found above, so try to broaden the choice. - if (!Iterables.isEmpty(options)) { - List oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES, - Predicates.not(CardPredicates.isOwner(aiChoser)))); - List aiNonCreatures = CardLists.filter(options, Predicates.and(Predicates.not(CardPredicates.Presets.CREATURES), - CardPredicates.Presets.PERMANENTS, CardPredicates.isOwner(aiChoser))); + } + // No optimal creature was found above, so try to broaden the choice. + if (!Iterables.isEmpty(options)) { + List oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES, + Predicates.not(CardPredicates.isOwner(aiChoser)))); + List aiNonCreatures = CardLists.filter(options, Predicates.and(Predicates.not(CardPredicates.Presets.CREATURES), + CardPredicates.Presets.PERMANENTS, CardPredicates.isOwner(aiChoser))); - if (!oppCreatures.isEmpty()) { - return ComputerUtilCard.getBestCreatureAI(oppCreatures); - } else if (!aiNonCreatures.isEmpty()) { - return Aggregates.random(aiNonCreatures); - } else { - return Aggregates.random(options); - } - } else if (!game.getStack().isEmpty()) { - // No permanent for the AI to choose. Should normally not happen unless using dev mode or something, - // but when it does happen, choose the top card on stack if possible (generally it'll be the SA - // source) in order to choose at least something, or the game will hang. - return game.getStack().peekAbility().getHostCard(); + if (!oppCreatures.isEmpty()) { + return ComputerUtilCard.getBestCreatureAI(oppCreatures); + } else if (!aiNonCreatures.isEmpty()) { + return Aggregates.random(aiNonCreatures); + } else { + return Aggregates.random(options); } + } else if (!game.getStack().isEmpty()) { + // No permanent for the AI to choose. Should normally not happen unless using dev mode or something, + // but when it does happen, choose the top card on stack if possible (generally it'll be the SA + // source) in order to choose at least something, or the game will hang. + return game.getStack().peekAbility().getHostCard(); } // Should never get here diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java index e93f30ff733..57d56de1759 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java @@ -140,7 +140,7 @@ public class ControlExchangeAi extends SpellAbilityAi { return false; } - if (aiWorst != null && aiWorst != bestFirstTgt) { + if (aiWorst != bestFirstTgt) { if (bestFirstTgt.isCreature() && aiWorst.isCreature()) { if ((ComputerUtilCard.evaluateCreature(bestFirstTgt) > ComputerUtilCard.evaluateCreature(aiWorst) + creatureThreshold) || sa.isMandatory()) { sa.getTargets().add(aiWorst); diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java index 2e4a66fbcef..9df503fac2a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java @@ -268,9 +268,8 @@ public class ControlGainAi extends SpellAbilityAi { List list = CardLists.getTargetableCards(ai.getCardsIn(ZoneType.Battlefield), sa); if (list.isEmpty()) { return false; - } else { - sa.getTargets().add(ComputerUtilCard.getWorstAI(list)); } + sa.getTargets().add(ComputerUtilCard.getWorstAI(list)); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java index 3fb611d430f..2ee98ae00b4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java @@ -68,7 +68,7 @@ public class CopySpellAbilityAi extends SpellAbilityAi { } } - if (top.isWrapper() || !(top instanceof SpellAbility || top.isActivatedAbility())) { + if (top.isWrapper() || top.isActivatedAbility()) { // Shouldn't even try with triggered or wrapped abilities at this time, will crash return false; } else if (top.getApi() == ApiType.CopySpellAbility) { diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 6216329a0e3..33e3fa8eadd 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -642,10 +642,10 @@ public class BoosterGenerator { if (toAdd == null) { continue; - } else { - itOp.remove(); } + itOp.remove(); + if (invert) { toAdd = Predicates.not(toAdd); } @@ -658,8 +658,6 @@ public class BoosterGenerator { } return Predicates.and(conditions); - } - } diff --git a/forge-game/src/main/java/forge/game/GameLogFormatter.java b/forge-game/src/main/java/forge/game/GameLogFormatter.java index d8c7e19e083..7cb50d14fa8 100644 --- a/forge-game/src/main/java/forge/game/GameLogFormatter.java +++ b/forge-game/src/main/java/forge/game/GameLogFormatter.java @@ -203,7 +203,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base { @Override public GameLogEntry visit(GameEventTurnBegan event) { - String message = Localizer.getInstance().getMessage("lblLogTurnNOwnerByPlayer", String.valueOf(event.turnNumber), event.turnOwner.toString());; + String message = Localizer.getInstance().getMessage("lblLogTurnNOwnerByPlayer", String.valueOf(event.turnNumber), event.turnOwner.toString()); return new GameLogEntry(GameLogEntryType.TURN, message); } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 99160b391ac..985f0f04b76 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -558,7 +558,7 @@ public class AbilityUtils { else if (hType.startsWith("Property") && ability instanceof SpellAbility) { String defined = hType.split("Property")[1]; for (Player p : game.getPlayersInTurnOrder()) { - if (p.hasProperty(defined, ((SpellAbility) ability).getActivatingPlayer(), ability.getHostCard(), (SpellAbility) ability)) { + if (p.hasProperty(defined, ((SpellAbility) ability).getActivatingPlayer(), ability.getHostCard(), ability)) { players.add(p); } } @@ -1105,7 +1105,7 @@ public class AbilityUtils { } // For merged permanent if (c instanceof CardCollection) { - o = ((CardCollection) c).get(0).getController().getOpponents();; + o = ((CardCollection) c).get(0).getController().getOpponents(); } } else if (defParsed.endsWith("Owner")) { @@ -1828,13 +1828,11 @@ public class AbilityUtils { } } - if (ctb instanceof CardTraitBase) { - if (l[0].startsWith("CountersAddedThisTurn")) { - final String[] parts = l[0].split(" "); - CounterType cType = CounterType.getType(parts[1]); + if (l[0].startsWith("CountersAddedThisTurn")) { + final String[] parts = l[0].split(" "); + CounterType cType = CounterType.getType(parts[1]); - return CardFactoryUtil.doXMath(game.getCounterAddedThisTurn(cType, parts[2], parts[3], c, player, ctb), expr, c); - } + return CardFactoryUtil.doXMath(game.getCounterAddedThisTurn(cType, parts[2], parts[3], c, player, ctb), expr, c); } } return CardFactoryUtil.xCount(c, s2); diff --git a/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java index 1b976951a9c..939765a7d83 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java @@ -54,10 +54,9 @@ public class AttachEffect extends SpellAbilityEffect { if (targets.isEmpty()) { return; - } else { - attachTo = targets.get(0); } - + + attachTo = targets.get(0); String attachToName = null; if (attachTo instanceof Card) { attachToName = CardTranslation.getTranslatedName(((Card)attachTo).getName()); diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersMoveEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersMoveEffect.java index b015016a439..9a20378f42e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersMoveEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersMoveEffect.java @@ -261,7 +261,7 @@ public class CountersMoveEffect extends SpellAbilityEffect { } for (final Card dest : tgtCards) { - if (null != source && null != dest) { + if (null != dest) { // rule 121.5: If the first and second objects are the same object, nothing // happens if (source.equals(dest)) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java b/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java index b73c145b42a..adc4a6bb571 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java +++ b/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java @@ -160,10 +160,9 @@ public abstract class TokenEffectBase extends SpellAbilityEffect { tok.attachToEntity(ge); return true; - } else { - // not a GameEntity, cant be attach - return false; } + // not a GameEntity, cant be attach + return false; } protected void addPumpUntil(SpellAbility sa, final Card c, long timestamp) { diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index eb00028ed09..921aa5dd016 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -3565,7 +3565,7 @@ public class Card extends GameEntity implements Comparable, IHasSVars { // values that are printed on card public final void setBasePowerString(final String s) { - currentState.setBasePowerString(s);; + currentState.setBasePowerString(s); } public final void setBaseToughnessString(final String s) { diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index 1decd223815..2bbf26b42c2 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -1508,14 +1508,14 @@ public class CardProperty { String what = property.substring("blocking".length()); if (StringUtils.isEmpty(what)) return combat.isBlocking(card); - if (what.startsWith("Source")) return combat.isBlocking(card, source) ; + if (what.startsWith("Source")) return combat.isBlocking(card, source); if (what.startsWith("CreatureYouCtrl")) { for (final Card c : CardLists.filter(sourceController.getCardsIn(ZoneType.Battlefield), Presets.CREATURES)) if (combat.isBlocking(card, c)) return true; return false; } else { - for(Card c : AbilityUtils.getDefinedCards(source, what, spellAbility)) { + for (Card c : AbilityUtils.getDefinedCards(source, what, spellAbility)) { if (combat.isBlocking(card, c)) { return true; } diff --git a/forge-game/src/main/java/forge/game/cost/CostReveal.java b/forge-game/src/main/java/forge/game/cost/CostReveal.java index 882af6c1920..602021a940e 100644 --- a/forge-game/src/main/java/forge/game/cost/CostReveal.java +++ b/forge-game/src/main/java/forge/game/cost/CostReveal.java @@ -89,22 +89,20 @@ public class CostReveal extends CostPartWithList { } else if (this.getType().equals("SameColor")) { if (amount == null) { return false; - } else { - for (final Card card : handList) { - if (CardLists.filter(handList, new Predicate() { - @Override - public boolean apply(final Card c) { - return c.sharesColorWith(card); - } - }).size() >= amount) { - return true; - } - } - return false; } + for (final Card card : handList) { + if (CardLists.filter(handList, new Predicate() { + @Override + public boolean apply(final Card c) { + return c.sharesColorWith(card); + } + }).size() >= amount) { + return true; + } + } + return false; } else { return (amount == null) || (amount <= getMaxAmountX(ability, payer)); - //System.out.println("revealcost - " + amount + type + handList); } } diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index daa102e97cf..9ead6b4b312 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -198,7 +198,7 @@ public class Player extends GameEntity implements Comparable { private final Map zones = Maps.newEnumMap(ZoneType.class); private final Map adjustLandPlays = Maps.newHashMap(); private final Set adjustLandPlaysInfinite = Sets.newHashSet(); - private Map maingameCardsMap = Maps.newHashMap();; + private Map maingameCardsMap = Maps.newHashMap(); private CardCollection currentPlanes = new CardCollection(); private Set prowl = Sets.newHashSet(); @@ -3448,10 +3448,11 @@ public class Player extends GameEntity implements Comparable { return true; } - if (this.hasKeyword("CantSearchLibrary")) { + if (hasKeyword("CantSearchLibrary")) { return false; - } else return targetPlayer == null || !targetPlayer.equals(sa.getActivatingPlayer()) - || !hasKeyword("Spells and abilities you control can't cause you to search your library."); + } + return targetPlayer == null || !targetPlayer.equals(sa.getActivatingPlayer()) + || !hasKeyword("Spells and abilities you control can't cause you to search your library."); } diff --git a/forge-game/src/main/java/forge/game/spellability/Spell.java b/forge-game/src/main/java/forge/game/spellability/Spell.java index 138a6e74cbd..d24e50672e6 100644 --- a/forge-game/src/main/java/forge/game/spellability/Spell.java +++ b/forge-game/src/main/java/forge/game/spellability/Spell.java @@ -83,7 +83,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable } // do performanceMode only for cases where the activator is different than controller - if (!Spell.performanceMode && activator != null && !card.getController().equals(activator)) { + if (!Spell.performanceMode && !card.getController().equals(activator)) { // always make a lki copy in this case? card = CardUtil.getLKICopy(card); card.setController(activator, 0); diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index b176c6c6526..f716b899fbf 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -290,12 +290,11 @@ public class SpellAbilityCondition extends SpellAbilityVariables { Card first = Iterables.getFirst(tgts, null); if (first == null) { return false; - } else { - byte firstColor = CardUtil.getColors(first).getColor(); - for (Card c : tgts) { - if (CardUtil.getColors(c).getColor() != firstColor) { - return false; - } + } + byte firstColor = CardUtil.getColors(first).getColor(); + for (Card c : tgts) { + if (CardUtil.getColors(c).getColor() != firstColor) { + return false; } } } diff --git a/forge-game/src/main/java/forge/game/spellability/TargetRestrictions.java b/forge-game/src/main/java/forge/game/spellability/TargetRestrictions.java index 4fe5d202490..000d94c5d2e 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetRestrictions.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetRestrictions.java @@ -489,19 +489,18 @@ public class TargetRestrictions { if (this.tgtZone.contains(ZoneType.Stack)) { // Stack Zone targets are considered later return true; - } else { - for (final Card c : game.getCardsIn(this.tgtZone)) { - if (!c.isValid(this.validTgts, sa.getActivatingPlayer(), srcCard, sa)) { - continue; - } - if (isTargeted && !sa.canTarget(c)) { - continue; - } - if (sa.getTargets().contains(c)) { - continue; - } - return true; + } + for (final Card c : game.getCardsIn(this.tgtZone)) { + if (!c.isValid(this.validTgts, sa.getActivatingPlayer(), srcCard, sa)) { + continue; } + if (isTargeted && !sa.canTarget(c)) { + continue; + } + if (sa.getTargets().contains(c)) { + continue; + } + return true; } return false; diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index 57c46819bf4..c1e6e36b939 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -283,13 +283,12 @@ public class MagicStack /* extends MyObservable */ implements Iterable runParams = AbilityKey.newMap(); diff --git a/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java b/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java index 64fda2afdf6..60f6046c551 100644 --- a/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java +++ b/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java @@ -766,22 +766,28 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener { if (deckType.startsWith(NetDeckCategory.PREFIX)) { netDeckCategory = NetDeckCategory.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckCategory.PREFIX.length())); return DeckType.NET_DECK; - } else if (deckType.startsWith(NetDeckArchiveStandard.PREFIX)) { + } + if (deckType.startsWith(NetDeckArchiveStandard.PREFIX)) { NetDeckArchiveStandard = NetDeckArchiveStandard.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveStandard.PREFIX.length())); return DeckType.NET_ARCHIVE_STANDARD_DECK; - } else if (deckType.startsWith(NetDeckArchivePioneer.PREFIX)) { + } + if (deckType.startsWith(NetDeckArchivePioneer.PREFIX)) { NetDeckArchivePioneer = NetDeckArchivePioneer.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchivePioneer.PREFIX.length())); return DeckType.NET_ARCHIVE_PIONEER_DECK; - } else if (deckType.startsWith(NetDeckArchiveModern.PREFIX)) { + } + if (deckType.startsWith(NetDeckArchiveModern.PREFIX)) { NetDeckArchiveModern = NetDeckArchiveModern.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveModern.PREFIX.length())); return DeckType.NET_ARCHIVE_MODERN_DECK; - } else if (deckType.startsWith(NetDeckArchiveLegacy.PREFIX)) { + } + if (deckType.startsWith(NetDeckArchiveLegacy.PREFIX)) { NetDeckArchiveLegacy = NetDeckArchiveLegacy.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveLegacy.PREFIX.length())); return DeckType.NET_ARCHIVE_LEGACY_DECK; - } else if (deckType.startsWith(NetDeckArchiveVintage.PREFIX)) { + } + if (deckType.startsWith(NetDeckArchiveVintage.PREFIX)) { NetDeckArchiveVintage = NetDeckArchiveVintage.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveVintage.PREFIX.length())); return DeckType.NET_ARCHIVE_VINTAGE_DECK; - } else if (deckType.startsWith(NetDeckArchiveBlock.PREFIX)) { + } + if (deckType.startsWith(NetDeckArchiveBlock.PREFIX)) { NetDeckArchiveBlock = NetDeckArchiveBlock.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveBlock.PREFIX.length())); return DeckType.NET_ARCHIVE_BLOCK_DECK; } diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java b/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java index 601be4b4431..8047c2fcb68 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java @@ -715,15 +715,14 @@ public class VLobby implements ILobbyView { if (sel == null) { return; - } else { - if (sel.contains("Use deck's default avatar") && deck != null && deck.has(DeckSection.Avatar)) { - vanguardAvatar = deck.get(DeckSection.Avatar).get(0); - } else { //Only other string is "Random" - if (playerPanels.get(playerIndex).isAi()) { //AI - vanguardAvatar = Aggregates.random(getNonRandomAiAvatars()); - } else { //Human - vanguardAvatar = Aggregates.random(getNonRandomHumanAvatars()); - } + } + if (sel.contains("Use deck's default avatar") && deck != null && deck.has(DeckSection.Avatar)) { + vanguardAvatar = deck.get(DeckSection.Avatar).get(0); + } else { //Only other string is "Random" + if (playerPanels.get(playerIndex).isAi()) { //AI + vanguardAvatar = Aggregates.random(getNonRandomAiAvatars()); + } else { //Human + vanguardAvatar = Aggregates.random(getNonRandomHumanAvatars()); } } } diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/QuickGauntletLister.java b/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/QuickGauntletLister.java index 1a3157d241f..1d5135724c9 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/QuickGauntletLister.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/QuickGauntletLister.java @@ -126,9 +126,7 @@ public class QuickGauntletLister extends JPanel { if (previousSelect == null) { return null; } - else { - return GauntletIO.getGauntletFile(previousSelect.getGauntletData()); - } + return GauntletIO.getGauntletFile(previousSelect.getGauntletData()); } private class DeleteButton extends SkinnedButton { diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java index fde2c8ddfed..305912eb4f1 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java @@ -1357,24 +1357,23 @@ public final class CMatchUI private List getTargets(SpellAbilityStackInstance si, List result){ if(si == null) { return result; - } else { - FCollectionView targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards()); - for(CardView currCardView: targetCards) { - result.add(currCardView); - } - - for(SpellAbility currSA : si.getTargetChoices().getTargetSpells()) { - CardView currCardView = currSA.getCardView(); - result.add(currCardView); - } - - FCollectionView targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers()); - for(PlayerView currPlayerView : targetPlayers) { - result.add(currPlayerView); - } - - return getTargets(si.getSubInstance(),result); } + FCollectionView targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards()); + for(CardView currCardView: targetCards) { + result.add(currCardView); + } + + for(SpellAbility currSA : si.getTargetChoices().getTargetSpells()) { + CardView currCardView = currSA.getCardView(); + result.add(currCardView); + } + + FCollectionView targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers()); + for(PlayerView currPlayerView : targetPlayers) { + result.add(currPlayerView); + } + + return getTargets(si.getSubInstance(),result); } private void addBigImageToStackModalPanel(JPanel mainPanel, SpellAbilityStackInstance si) { diff --git a/forge-gui/src/main/java/forge/download/AutoUpdater.java b/forge-gui/src/main/java/forge/download/AutoUpdater.java index 82428ce1eeb..9741d081690 100644 --- a/forge-gui/src/main/java/forge/download/AutoUpdater.java +++ b/forge-gui/src/main/java/forge/download/AutoUpdater.java @@ -90,9 +90,8 @@ public class AutoUpdater { int option = SOptionPane.showOptionDialog(message, localizer.getMessage("lblManualCheck"), null, options, 0); if (option < 1) { return false; - } else { - updateChannel = options.get(option); } + updateChannel = options.get(option); } if (buildVersion.contains("SNAPSHOT")) { diff --git a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java index 464cadc9ed3..ea81de52bb2 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java @@ -327,17 +327,15 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { // Don't immediately close, wait for win/lose screen return false; } - else { - // since the nextGameDecision might come from somewhere else it will try and concede too - ignoreConcedeChain = true; - for (PlayerView player : getLocalPlayers()) { - if (!player.isAI()) { - getGameController(player).nextGameDecision(NextGameDecision.QUIT); - } + // since the nextGameDecision might come from somewhere else it will try and concede too + ignoreConcedeChain = true; + for (PlayerView player : getLocalPlayers()) { + if (!player.isAI()) { + getGameController(player).nextGameDecision(NextGameDecision.QUIT); } - ignoreConcedeChain = false; - return false; } + ignoreConcedeChain = false; + return false; } else if (spectator == null) { return true; //if no local players or spectator, just quit diff --git a/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java b/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java index 355ca85d951..2af0a82aa28 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java @@ -28,21 +28,20 @@ public class CompatibleObjectDecoder extends LengthFieldBasedFrameDecoder { ByteBuf frame = (ByteBuf)super.decode(ctx, in); if (frame == null) { return null; - } else { - ObjectInputStream ois = GuiBase.hasPropertyConfig() ? - new ObjectInputStream(new LZ4BlockInputStream(new ByteBufInputStream(frame, true))): + } + ObjectInputStream ois = GuiBase.hasPropertyConfig() ? + new ObjectInputStream(new LZ4BlockInputStream(new ByteBufInputStream(frame, true))): new CObjectInputStream(new LZ4BlockInputStream(new ByteBufInputStream(frame, true)),this.classResolver); - Object var5 = null; - try { - var5 = ois.readObject(); - } catch (StreamCorruptedException e) { - System.err.println(String.format("Version Mismatch: %s", e.getMessage())); - } finally { - ois.close(); - } - - return var5; + Object var5 = null; + try { + var5 = ois.readObject(); + } catch (StreamCorruptedException e) { + System.err.println(String.format("Version Mismatch: %s", e.getMessage())); + } finally { + ois.close(); } + + return var5; } } diff --git a/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java b/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java index 048e3c9ed74..c83c86b7b01 100644 --- a/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java +++ b/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java @@ -352,7 +352,7 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base { @Override public Void visit(final GameEventCardAttachment event) { final Game game = event.equipment.getGame(); - final Zone zEq = (Zone)game.getZoneOf(event.equipment); + final Zone zEq = game.getZoneOf(event.equipment); if (event.oldEntiy instanceof Card) { updateZone(game.getZoneOf((Card)event.oldEntiy)); } diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java index 0c7942e92b6..809cacd39e0 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java @@ -393,14 +393,13 @@ public abstract class GuiDownloadService implements Runnable { protected Proxy getProxy() { if (type == 0) { return Proxy.NO_PROXY; - } else { - try { - return new Proxy(TYPES[type], new InetSocketAddress(txtAddress.getText(), Integer.parseInt(txtPort.getText()))); - } catch (final Exception ex) { - BugReporter.reportException(ex, - "Proxy connection could not be established!\nProxy address: %s\nProxy port: %s", - txtAddress.getText(), txtPort.getText()); - } + } + try { + return new Proxy(TYPES[type], new InetSocketAddress(txtAddress.getText(), Integer.parseInt(txtPort.getText()))); + } catch (final Exception ex) { + BugReporter.reportException(ex, + "Proxy connection could not be established!\nProxy address: %s\nProxy port: %s", + txtAddress.getText(), txtPort.getText()); } return null; } diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index 2570987fe0e..ecd093db773 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -725,17 +725,15 @@ public class HumanPlay { if (ability.getSacrificedAsOffering() == null) { System.out.println("Sacrifice input for Offering cancelled"); return false; - } else { - offering = ability.getSacrificedAsOffering(); } + offering = ability.getSacrificedAsOffering(); } if (ability.isEmerge()) { if (ability.getSacrificedAsEmerge() == null) { System.out.println("Sacrifice input for Emerge cancelled"); return false; - } else { - emerge = ability.getSacrificedAsEmerge(); } + emerge = ability.getSacrificedAsEmerge(); } if (!toPay.isPaid()) { // Input is somehow clearing out the offering card? diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 39729c64e77..6c9ac4b51cc 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -694,12 +694,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont } break; } - if (sa != null) { - tempShowCard(show); - boolean result = InputConfirm.confirm(this, ((Card) sa.getHostCard().getFirstRemembered()).getView(), message); - endTempShowCards(); - return result; - } + tempShowCard(show); + boolean result = InputConfirm.confirm(this, ((Card) sa.getHostCard().getFirstRemembered()).getView(), message); + endTempShowCards(); + return result; } // The general case: display the source of the SA in the prompt on mouse over diff --git a/forge-gui/src/main/java/forge/player/TargetSelection.java b/forge-gui/src/main/java/forge/player/TargetSelection.java index 654ff97ad59..4d2558cf992 100644 --- a/forge-gui/src/main/java/forge/player/TargetSelection.java +++ b/forge-gui/src/main/java/forge/player/TargetSelection.java @@ -318,17 +318,15 @@ public class TargetSelection { // Not enough targets, cancel targeting return false; } - else { - Object madeChoice = mandatory ? controller.getGui().one(message, selectOptions) : controller.getGui().oneOrNone(message, selectOptions); - if (madeChoice == null) { - return false; - } - if (madeChoice instanceof StackItemView) { - ability.getTargets().add(stackItemViewCache.get(madeChoice).getSpellAbility(true)); - } - else {// 'FINISH TARGETING' chosen - bTargetingDone = true; - } + Object madeChoice = mandatory ? controller.getGui().one(message, selectOptions) : controller.getGui().oneOrNone(message, selectOptions); + if (madeChoice == null) { + return false; + } + if (madeChoice instanceof StackItemView) { + ability.getTargets().add(stackItemViewCache.get(madeChoice).getSpellAbility(true)); + } + else {// 'FINISH TARGETING' chosen + bTargetingDone = true; } } return true;