From c38bae910a01dd7f0c30738cb834aa6d4ca85bdc Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 2 Sep 2019 18:08:56 +0800 Subject: [PATCH 1/5] Refactor/Code Cleanup --- forge-ai/src/main/java/forge/ai/AIOption.java | 2 +- .../java/forge/ai/AiAttackController.java | 13 +- .../main/java/forge/ai/AiBlockController.java | 14 +- .../src/main/java/forge/ai/AiCardMemory.java | 4 +- .../src/main/java/forge/ai/AiController.java | 31 +- .../main/java/forge/ai/AiCostDecision.java | 8 +- .../main/java/forge/ai/AiPlayDecision.java | 2 +- .../src/main/java/forge/ai/ComputerUtil.java | 85 +- .../main/java/forge/ai/ComputerUtilCard.java | 14 +- .../java/forge/ai/ComputerUtilCombat.java | 36 +- .../main/java/forge/ai/ComputerUtilCost.java | 4 +- .../main/java/forge/ai/ComputerUtilMana.java | 6 +- .../src/main/java/forge/ai/GameState.java | 4 +- .../java/forge/ai/PlayerControllerAi.java | 6 +- .../src/main/java/forge/ai/SpecialCardAi.java | 82 +- .../main/java/forge/ai/SpellAbilityAi.java | 5 +- .../forge/ai/ability/ActivateAbilityAi.java | 5 +- .../main/java/forge/ai/ability/AddTurnAi.java | 6 +- .../main/java/forge/ai/ability/AmassAi.java | 9 +- .../main/java/forge/ai/ability/AnimateAi.java | 18 +- .../java/forge/ai/ability/AnimateAllAi.java | 6 +- .../main/java/forge/ai/ability/AttachAi.java | 145 ++-- .../java/forge/ai/ability/ChangeZoneAi.java | 57 +- .../forge/ai/ability/ChangeZoneAllAi.java | 31 +- .../java/forge/ai/ability/ChooseCardAi.java | 30 +- .../java/forge/ai/ability/ChooseColorAi.java | 5 +- .../forge/ai/ability/ChooseDirectionAi.java | 4 +- .../ai/ability/ChooseGenericEffectAi.java | 4 +- .../java/forge/ai/ability/ChooseSourceAi.java | 9 +- .../main/java/forge/ai/ability/CloneAi.java | 5 +- .../java/forge/ai/ability/ControlGainAi.java | 13 +- .../java/forge/ai/ability/CountersMoveAi.java | 33 +- .../forge/ai/ability/CountersMultiplyAi.java | 19 +- .../ai/ability/CountersProliferateAi.java | 7 +- .../java/forge/ai/ability/CountersPutAi.java | 22 +- .../forge/ai/ability/CountersRemoveAi.java | 2 +- .../java/forge/ai/ability/DamageAiBase.java | 4 +- .../java/forge/ai/ability/DamageAllAi.java | 16 +- .../java/forge/ai/ability/DamageDealAi.java | 18 +- .../main/java/forge/ai/ability/DebuffAi.java | 2 +- .../forge/ai/ability/DelayedTriggerAi.java | 2 +- .../main/java/forge/ai/ability/DestroyAi.java | 23 +- .../java/forge/ai/ability/DestroyAllAi.java | 14 +- .../java/forge/ai/ability/DrainManaAi.java | 5 +- .../main/java/forge/ai/ability/DrawAi.java | 24 +- .../main/java/forge/ai/ability/EffectAi.java | 12 +- .../main/java/forge/ai/ability/FightAi.java | 12 +- .../java/forge/ai/ability/FlipACoinAi.java | 4 +- .../main/java/forge/ai/ability/GameWinAi.java | 5 +- .../ai/ability/LifeExchangeVariantAi.java | 4 +- .../java/forge/ai/ability/LifeGainAi.java | 22 +- .../java/forge/ai/ability/LifeLoseAi.java | 20 +- .../java/forge/ai/ability/ManaEffectAi.java | 9 +- .../java/forge/ai/ability/ManifestAi.java | 13 +- .../main/java/forge/ai/ability/MillAi.java | 26 +- .../forge/ai/ability/PeekAndRevealAi.java | 4 +- .../java/forge/ai/ability/PermanentAi.java | 9 +- .../forge/ai/ability/PermanentCreatureAi.java | 14 +- .../ai/ability/PermanentNoncreatureAi.java | 11 +- .../main/java/forge/ai/ability/PhasesAi.java | 4 +- .../main/java/forge/ai/ability/PlayAi.java | 6 +- .../main/java/forge/ai/ability/PoisonAi.java | 24 +- .../main/java/forge/ai/ability/ProtectAi.java | 11 +- .../main/java/forge/ai/ability/PumpAi.java | 45 +- .../java/forge/ai/ability/PumpAiBase.java | 310 +++----- .../main/java/forge/ai/ability/PumpAllAi.java | 5 +- .../forge/ai/ability/RemoveFromCombatAi.java | 4 +- .../main/java/forge/ai/ability/RepeatAi.java | 4 +- .../java/forge/ai/ability/RepeatEachAi.java | 8 +- .../main/java/forge/ai/ability/RevealAi.java | 6 +- .../java/forge/ai/ability/RevealHandAi.java | 6 +- .../forge/ai/ability/RollPlanarDiceAi.java | 2 +- .../java/forge/ai/ability/SacrificeAi.java | 4 +- .../main/java/forge/ai/ability/ScryAi.java | 4 +- .../java/forge/ai/ability/SetStateAi.java | 23 +- .../java/forge/ai/ability/SkipTurnAi.java | 5 +- .../main/java/forge/ai/ability/SurveilAi.java | 4 +- .../src/main/java/forge/ai/ability/TapAi.java | 9 +- .../main/java/forge/ai/ability/TapAiBase.java | 14 +- .../main/java/forge/ai/ability/TapAllAi.java | 4 +- .../main/java/forge/ai/ability/TokenAi.java | 20 +- .../java/forge/ai/ability/UnattachAllAi.java | 4 +- .../main/java/forge/ai/ability/UntapAi.java | 34 +- .../ai/simulation/PossibleTargetSelector.java | 2 +- .../SpellAbilityChoicesIterator.java | 2 +- .../ai/simulation/SpellAbilityPicker.java | 4 +- .../main/java/forge/CardStorageReader.java | 2 +- forge-core/src/main/java/forge/ImageKeys.java | 6 +- .../src/main/java/forge/LobbyPlayer.java | 9 +- .../src/main/java/forge/card/CardDb.java | 4 +- .../src/main/java/forge/card/CardEdition.java | 2 +- .../src/main/java/forge/card/CardFace.java | 4 +- .../java/forge/card/CardFacePredicates.java | 7 +- .../src/main/java/forge/card/CardRarity.java | 2 +- .../java/forge/card/CardRulesPredicates.java | 4 +- .../main/java/forge/card/CardSplitType.java | 2 +- .../src/main/java/forge/card/CardType.java | 7 +- .../src/main/java/forge/card/ICardFace.java | 2 +- .../src/main/java/forge/card/MagicColor.java | 2 +- .../main/java/forge/card/mana/ManaAtom.java | 2 +- .../main/java/forge/card/mana/ManaCost.java | 2 +- .../java/forge/card/mana/ManaCostShard.java | 4 +- .../src/main/java/forge/deck/DeckFormat.java | 11 +- .../main/java/forge/deck/DeckRecognizer.java | 5 +- .../src/main/java/forge/deck/DeckSection.java | 2 +- .../deck/generation/DeckGeneratorBase.java | 2 +- .../src/main/java/forge/item/PaperCard.java | 12 +- .../src/main/java/forge/util/Base64Coder.java | 5 +- .../main/java/forge/util/ComparableOp.java | 2 +- .../src/main/java/forge/util/ImageUtil.java | 3 +- forge-core/src/main/java/forge/util/Lang.java | 2 +- .../util/LocalizationChangeObserver.java | 2 +- .../src/main/java/forge/util/Localizer.java | 16 +- .../java/forge/util/storage/StorageBase.java | 2 +- .../src/main/java/forge/GameCommand.java | 2 +- .../main/java/forge/game/CardTraitBase.java | 8 +- .../src/main/java/forge/game/ForgeScript.java | 122 +-- forge-game/src/main/java/forge/game/Game.java | 2 +- .../src/main/java/forge/game/GameAction.java | 4 +- .../main/java/forge/game/GameActionUtil.java | 2 +- .../src/main/java/forge/game/GameEntity.java | 6 +- .../src/main/java/forge/game/GameFormat.java | 2 +- .../java/forge/game/GameLogEntryType.java | 2 +- .../java/forge/game/GameLogFormatter.java | 8 +- .../src/main/java/forge/game/GameStage.java | 2 +- .../src/main/java/forge/game/GameType.java | 4 +- .../java/forge/game/GlobalRuleChange.java | 2 +- .../main/java/forge/game/IIdentifiable.java | 4 +- .../forge/game/ability/AbilityFactory.java | 2 +- .../java/forge/game/ability/AbilityUtils.java | 9 +- .../effects/ActivateAbilityEffect.java | 2 +- .../ability/effects/AssignGroupEffect.java | 2 +- .../game/ability/effects/BidLifeEffect.java | 2 +- .../ability/effects/ChangeTextEffect.java | 4 +- .../ability/effects/ChangeZoneEffect.java | 2 +- .../ability/effects/ChooseCardEffect.java | 2 +- .../ability/effects/ChooseGenericEffect.java | 4 +- .../game/ability/effects/CloneEffect.java | 2 +- .../ability/effects/ControlGainEffect.java | 2 +- .../ability/effects/CopyPermanentEffect.java | 2 +- .../ability/effects/CountersRemoveEffect.java | 2 +- .../ability/effects/DelayedTriggerEffect.java | 4 +- .../effects/ImmediateTriggerEffect.java | 4 +- .../game/ability/effects/LifeLoseEffect.java | 4 +- .../ability/effects/ProtectAllEffect.java | 2 +- .../game/ability/effects/ProtectEffect.java | 2 +- .../game/ability/effects/PumpEffect.java | 10 +- .../src/main/java/forge/game/card/Card.java | 53 +- .../java/forge/game/card/CardFactory.java | 10 +- .../java/forge/game/card/CardFactoryUtil.java | 36 +- .../java/forge/game/card/CardPlayOption.java | 2 +- .../java/forge/game/card/CardPredicates.java | 4 +- .../java/forge/game/card/CardProperty.java | 733 +++++------------- .../main/java/forge/game/card/CardState.java | 4 +- .../main/java/forge/game/card/CardUtil.java | 12 +- .../main/java/forge/game/card/CardView.java | 14 +- .../java/forge/game/card/token/TokenInfo.java | 2 +- .../forge/game/combat/AttackConstraints.java | 8 +- .../forge/game/combat/AttackRequirement.java | 4 +- .../main/java/forge/game/combat/Combat.java | 12 +- .../java/forge/game/combat/CombatLki.java | 2 +- .../java/forge/game/combat/CombatUtil.java | 23 +- .../game/combat/GlobalAttackRestrictions.java | 2 +- .../java/forge/game/cost/CostAdjustment.java | 11 +- .../java/forge/game/cost/CostDiscard.java | 15 +- .../main/java/forge/game/cost/CostExert.java | 4 +- .../main/java/forge/game/cost/CostExile.java | 4 +- .../forge/game/cost/CostExileFromStack.java | 6 +- .../java/forge/game/cost/CostGainControl.java | 5 +- .../forge/game/cost/CostPartWithList.java | 2 +- .../java/forge/game/cost/CostPayLife.java | 6 +- .../forge/game/cost/CostPutCardToLib.java | 4 +- .../java/forge/game/cost/CostPutCounter.java | 9 +- .../forge/game/cost/CostRemoveCounter.java | 8 +- .../main/java/forge/game/cost/CostReturn.java | 9 +- .../main/java/forge/game/cost/CostReveal.java | 11 +- .../java/forge/game/cost/CostSacrifice.java | 9 +- .../java/forge/game/cost/CostTapType.java | 6 +- .../java/forge/game/cost/CostUnattach.java | 13 +- .../java/forge/game/cost/CostUntapType.java | 5 +- .../java/forge/game/cost/ICostVisitor.java | 58 +- .../game/event/GameEventCardDamaged.java | 2 +- .../game/event/GameEventCardStatsChanged.java | 2 +- .../forge/game/event/IGameEventVisitor.java | 2 +- .../main/java/forge/game/keyword/Keyword.java | 6 +- .../forge/game/keyword/KeywordInstance.java | 8 +- .../forge/game/keyword/KeywordInterface.java | 24 +- .../game/keyword/KeywordWithCostAndType.java | 2 +- .../java/forge/game/keyword/Ninjutsu.java | 2 +- .../main/java/forge/game/mana/ManaPool.java | 7 +- .../forge/game/mulligan/MulliganService.java | 2 +- .../java/forge/game/phase/PhaseHandler.java | 2 +- .../main/java/forge/game/phase/PhaseType.java | 4 +- .../src/main/java/forge/game/phase/Untap.java | 17 +- .../main/java/forge/game/player/Player.java | 62 +- .../forge/game/player/PlayerController.java | 4 +- .../forge/game/player/PlayerProperty.java | 170 +--- .../game/replacement/ReplaceAddCounter.java | 4 +- .../game/replacement/ReplaceCounter.java | 4 +- .../game/replacement/ReplaceDestroy.java | 4 +- .../game/replacement/ReplaceDiscard.java | 4 +- .../forge/game/replacement/ReplaceDraw.java | 8 +- .../game/replacement/ReplaceDrawCards.java | 4 +- .../game/replacement/ReplaceGainLife.java | 4 +- .../game/replacement/ReplaceGameLoss.java | 4 +- .../forge/game/replacement/ReplaceMoved.java | 4 +- .../game/replacement/ReplaceProduceMana.java | 4 +- .../game/replacement/ReplaceSetInMotion.java | 4 +- .../game/replacement/ReplaceSurveil.java | 4 +- .../forge/game/replacement/ReplaceToken.java | 4 +- .../game/replacement/ReplaceTurnFaceUp.java | 4 +- .../forge/game/replacement/ReplaceUntap.java | 4 +- .../game/replacement/ReplacementResult.java | 2 +- .../game/replacement/ReplacementType.java | 2 +- .../game/spellability/AbilityManaPart.java | 11 +- .../forge/game/spellability/SpellAbility.java | 17 +- .../spellability/SpellAbilityCondition.java | 4 +- .../spellability/SpellAbilityRestriction.java | 22 +- .../SpellAbilityStackInstance.java | 2 +- .../game/spellability/SpellPermanent.java | 2 +- .../game/spellability/TargetRestrictions.java | 4 +- .../game/staticability/StaticAbility.java | 12 +- .../StaticAbilityCantAttach.java | 4 +- .../StaticAbilityCantAttackBlock.java | 6 +- .../StaticAbilityCantBeCast.java | 20 +- .../StaticAbilityCantPutCounter.java | 22 +- .../StaticAbilityCantTarget.java | 2 +- .../StaticAbilityContinuous.java | 2 +- .../staticability/StaticAbilityETBTapped.java | 8 +- .../main/java/forge/game/trigger/Trigger.java | 22 +- .../forge/game/trigger/TriggerAbandoned.java | 6 +- .../java/forge/game/trigger/TriggerAdapt.java | 6 +- .../forge/game/trigger/TriggerAttached.java | 4 +- .../game/trigger/TriggerAttackerBlocked.java | 4 +- .../TriggerAttackerBlockedByCreature.java | 8 +- .../trigger/TriggerAttackerUnblocked.java | 6 +- .../trigger/TriggerAttackerUnblockedOnce.java | 6 +- .../trigger/TriggerAttackersDeclared.java | 4 +- .../forge/game/trigger/TriggerAttacks.java | 4 +- .../game/trigger/TriggerBecomeMonarch.java | 6 +- .../game/trigger/TriggerBecomeMonstrous.java | 6 +- .../game/trigger/TriggerBecomeRenowned.java | 6 +- .../game/trigger/TriggerBecomesTarget.java | 4 +- .../trigger/TriggerBecomesTargetOnce.java | 4 +- .../forge/game/trigger/TriggerBlocks.java | 6 +- .../forge/game/trigger/TriggerChampioned.java | 6 +- .../trigger/TriggerChangesController.java | 6 +- .../game/trigger/TriggerChangesZoneAll.java | 6 +- .../forge/game/trigger/TriggerClashed.java | 4 +- .../game/trigger/TriggerCounterAdded.java | 4 +- .../game/trigger/TriggerCounterAddedAll.java | 6 +- .../game/trigger/TriggerCounterAddedOnce.java | 6 +- .../game/trigger/TriggerCounterRemoved.java | 4 +- .../trigger/TriggerCounterRemovedOnce.java | 4 +- .../forge/game/trigger/TriggerCountered.java | 4 +- .../forge/game/trigger/TriggerCycled.java | 6 +- .../game/trigger/TriggerDamageDealtOnce.java | 4 +- .../game/trigger/TriggerDamageDoneOnce.java | 4 +- .../forge/game/trigger/TriggerDestroyed.java | 4 +- .../forge/game/trigger/TriggerDevoured.java | 6 +- .../forge/game/trigger/TriggerDiscarded.java | 4 +- .../java/forge/game/trigger/TriggerDrawn.java | 6 +- .../forge/game/trigger/TriggerEvolved.java | 6 +- .../forge/game/trigger/TriggerExerted.java | 6 +- .../forge/game/trigger/TriggerExiled.java | 6 +- .../forge/game/trigger/TriggerExploited.java | 6 +- .../forge/game/trigger/TriggerExplores.java | 6 +- .../java/forge/game/trigger/TriggerFight.java | 6 +- .../game/trigger/TriggerFlippedCoin.java | 4 +- .../forge/game/trigger/TriggerHandler.java | 6 +- .../game/trigger/TriggerInvestigated.java | 4 +- .../forge/game/trigger/TriggerLandPlayed.java | 4 +- .../forge/game/trigger/TriggerLifeGained.java | 4 +- .../forge/game/trigger/TriggerLifeLost.java | 4 +- .../forge/game/trigger/TriggerLosesGame.java | 6 +- .../trigger/TriggerPayCumulativeUpkeep.java | 6 +- .../forge/game/trigger/TriggerPayEcho.java | 6 +- .../forge/game/trigger/TriggerPayLife.java | 4 +- .../java/forge/game/trigger/TriggerPhase.java | 6 +- .../forge/game/trigger/TriggerPhaseIn.java | 6 +- .../forge/game/trigger/TriggerPhaseOut.java | 10 +- .../forge/game/trigger/TriggerPlanarDice.java | 4 +- .../game/trigger/TriggerRegenerated.java | 4 +- .../forge/game/trigger/TriggerRevealed.java | 4 +- .../forge/game/trigger/TriggerSacrificed.java | 3 +- .../java/forge/game/trigger/TriggerScry.java | 6 +- .../game/trigger/TriggerSearchedLibrary.java | 4 +- .../game/trigger/TriggerSetInMotion.java | 8 +- .../forge/game/trigger/TriggerShuffled.java | 4 +- .../game/trigger/TriggerSpellAbilityCast.java | 4 +- .../game/trigger/TriggerSpellAbilityCopy.java | 6 +- .../forge/game/trigger/TriggerSurveil.java | 4 +- .../java/forge/game/trigger/TriggerTaps.java | 8 +- .../game/trigger/TriggerTapsForMana.java | 4 +- .../game/trigger/TriggerTransformed.java | 6 +- .../forge/game/trigger/TriggerTurnBegin.java | 6 +- .../forge/game/trigger/TriggerTurnFaceUp.java | 6 +- .../java/forge/game/trigger/TriggerType.java | 2 +- .../forge/game/trigger/TriggerUnattach.java | 6 +- .../forge/game/trigger/TriggerUntaps.java | 6 +- .../main/java/forge/game/zone/MagicStack.java | 2 +- .../main/java/forge/game/zone/PlayerZone.java | 5 +- .../src/main/java/forge/game/zone/Zone.java | 8 +- .../main/java/forge/game/zone/ZoneType.java | 4 +- .../forge/trackable/TrackableProperty.java | 4 +- .../src/main/java/forge/util/MessageUtil.java | 2 +- .../deckeditor/controllers/CEditorQuest.java | 2 +- .../controllers/CEditorQuestCardShop.java | 8 +- .../controllers/CEditorTokenViewer.java | 8 +- .../home/gauntlet/ContestGauntletLister.java | 4 +- .../home/gauntlet/QuickGauntletLister.java | 4 +- .../screens/home/quest/VSubmenuQuestData.java | 2 +- .../forge/screens/home/quest/ViewItem.java | 2 +- .../java/forge/screens/match/CMatchUI.java | 1 - .../forge/screens/match/VAssignDamage.java | 2 +- .../forge/toolbox/imaging/FImagePanel.java | 2 +- .../toolbox/special/PlayerDetailsPanel.java | 2 +- .../java/forge/view/arcane/CardPanel.java | 2 +- .../PlanarConquestCommanderGeneraterGA.java | 2 +- .../PlanarConquestGeneraterGA.java | 6 +- forge-gui-mobile-dev/src/forge/app/Main.java | 2 +- .../src/forge/animation/AbilityEffect.java | 2 +- .../src/forge/animation/GifDecoder.java | 4 +- .../src/forge/assets/BitmapFontWriter.java | 4 +- forge-gui-mobile/src/forge/card/CardZoom.java | 2 +- .../src/forge/deck/FDeckEditor.java | 2 +- .../src/forge/itemmanager/ItemManager.java | 5 +- .../src/forge/menu/FDropDown.java | 5 +- .../src/forge/menu/FDropDownMenu.java | 5 +- .../screens/constructed/PlayerPanel.java | 2 +- .../screens/gauntlet/NewGauntletScreen.java | 6 +- .../src/forge/screens/home/LoadGameMenu.java | 2 +- .../src/forge/screens/home/NewGameMenu.java | 2 +- .../src/forge/screens/match/views/VStack.java | 2 +- .../src/forge/screens/online/OnlineMenu.java | 2 +- .../src/forge/sound/AudioClip.java | 5 +- .../src/forge/toolbox/FDialog.java | 6 +- .../src/forge/toolbox/FEvent.java | 2 +- .../src/forge/toolbox/FScrollPane.java | 4 +- .../achievement/AchievementCollection.java | 4 +- .../achievement/ChallengeAchievements.java | 9 +- .../forge/achievement/MatchWinStreak.java | 5 +- .../java/forge/achievement/VariantWins.java | 4 +- .../src/main/java/forge/assets/FSkinProp.java | 2 +- .../main/java/forge/card/CardDetailUtil.java | 2 +- .../forge/card/CardReaderExperiments.java | 2 +- .../java/forge/card/CardScriptParser.java | 20 +- .../forge/deck/CardArchetypeLDAGenerator.java | 2 +- .../deck/CardRelationMatrixGenerator.java | 6 +- .../src/main/java/forge/deck/DeckType.java | 2 +- .../forge/download/GuiDownloadZipService.java | 2 +- .../java/forge/error/ExceptionHandler.java | 2 +- .../java/forge/gauntlet/GauntletData.java | 2 +- .../java/forge/interfaces/IDevModeCheats.java | 2 +- .../java/forge/interfaces/IMayViewCards.java | 2 +- .../forge/itemmanager/AdvancedSearch.java | 6 +- .../forge/itemmanager/ItemColumnConfig.java | 2 +- .../forge/itemmanager/ItemManagerConfig.java | 2 +- .../forge/itemmanager/ItemManagerModel.java | 2 +- .../forge/itemmanager/SItemManagerUtil.java | 4 +- .../main/java/forge/limited/BoosterDraft.java | 2 +- .../CardThemedConquestDeckBuilder.java | 2 +- .../forge/limited/CardThemedDeckBuilder.java | 2 +- .../java/forge/limited/LimitedPoolType.java | 2 +- .../src/main/java/forge/match/GameLobby.java | 6 +- .../main/java/forge/match/HostedMatch.java | 4 +- .../src/main/java/forge/match/LobbySlot.java | 2 +- .../main/java/forge/match/LobbySlotType.java | 2 +- .../src/main/java/forge/match/LocalLobby.java | 5 +- .../java/forge/match/NextGameDecision.java | 2 +- .../java/forge/match/input/InputLockUI.java | 2 +- .../src/main/java/forge/model/CardBlock.java | 5 +- .../src/main/java/forge/model/FModel.java | 2 +- .../src/main/java/forge/model/MetaSet.java | 2 +- .../src/main/java/forge/net/OfflineLobby.java | 5 +- .../main/java/forge/net/ProtocolMethod.java | 10 +- .../forge/net/client/GameClientHandler.java | 2 +- .../java/forge/net/server/FServerManager.java | 2 +- .../forge/net/server/ServerGameLobby.java | 5 +- .../planarconquest/ConquestCommander.java | 5 +- .../planarconquest/ConquestPreferences.java | 2 +- .../forge/planarconquest/ConquestUtil.java | 7 +- .../java/forge/player/GamePlayerUtil.java | 2 +- .../java/forge/player/HumanCostDecision.java | 4 +- .../src/main/java/forge/player/HumanPlay.java | 8 +- .../forge/player/HumanPlaySpellAbility.java | 2 +- .../forge/player/PlayerControllerHuman.java | 19 +- .../java/forge/player/PlayerZoneUpdates.java | 2 +- .../java/forge/properties/ForgeConstants.java | 2 +- .../forge/properties/ForgePreferences.java | 2 +- .../properties/ForgeProfileProperties.java | 2 +- .../src/main/java/forge/puzzle/Puzzle.java | 2 +- .../java/forge/quest/QuestController.java | 2 +- .../java/forge/quest/QuestDraftUtils.java | 6 +- .../forge/quest/QuestEventDifficulty.java | 2 +- .../java/forge/quest/QuestEventDraft.java | 1 - .../forge/quest/QuestEventDuelManager.java | 2 +- .../forge/quest/QuestEventLDADuelManager.java | 2 +- .../java/forge/quest/QuestRewardCard.java | 4 +- .../src/main/java/forge/quest/QuestUtil.java | 2 +- .../java/forge/quest/QuestUtilUnlockSets.java | 2 +- .../src/main/java/forge/quest/SellRules.java | 6 +- .../java/forge/quest/StartingPoolType.java | 2 +- .../forge/quest/bazaar/QuestItemType.java | 4 +- .../java/forge/quest/data/StarRating.java | 6 +- .../java/forge/sound/EventVisualizer.java | 2 +- .../src/main/java/forge/sound/IAudioClip.java | 8 +- .../main/java/forge/sound/MusicPlaylist.java | 2 +- .../java/forge/tournament/TournamentData.java | 2 +- .../tournament/system/TournamentSwiss.java | 2 +- .../main/java/forge/util/ImageFetcher.java | 4 +- 411 files changed, 1354 insertions(+), 3010 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AIOption.java b/forge-ai/src/main/java/forge/ai/AIOption.java index 3eea52dfc7e..66925e7f6b8 100644 --- a/forge-ai/src/main/java/forge/ai/AIOption.java +++ b/forge-ai/src/main/java/forge/ai/AIOption.java @@ -1,5 +1,5 @@ package forge.ai; public enum AIOption { - USE_SIMULATION; + USE_SIMULATION } diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 1a374d80660..35b2d140432 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -602,11 +602,7 @@ public class AiAttackController { return true; } - if (totalPoisonDamage >= 10 - opp.getPoisonCounters()) { - return true; - } - - return false; + return totalPoisonDamage >= 10 - opp.getPoisonCounters(); } private final GameEntity chooseDefender(final Combat c, final boolean bAssault) { @@ -1021,7 +1017,7 @@ public class AiAttackController { } // stay at home to block if ( LOG_AI_ATTACKS ) - System.out.println(String.valueOf(this.aiAggression) + " = ai aggression"); + System.out.println(this.aiAggression + " = ai aggression"); // **************** // Evaluation the end @@ -1454,10 +1450,7 @@ public class AiAttackController { if (color != null) { return color; } - if (artifact != null) { - return artifact; - } - return null; //should never get here + return artifact;//should never get here } private void doLightmineFieldAttackLogic(List attackersLeft, int numForcedAttackers, boolean playAggro) { diff --git a/forge-ai/src/main/java/forge/ai/AiBlockController.java b/forge-ai/src/main/java/forge/ai/AiBlockController.java index e948d3cebfc..82df82ef46f 100644 --- a/forge-ai/src/main/java/forge/ai/AiBlockController.java +++ b/forge-ai/src/main/java/forge/ai/AiBlockController.java @@ -859,7 +859,7 @@ public class AiBlockController { damageToPW += ComputerUtilCombat.predictDamageTo((Card) def, pwatkr.getNetCombatDamage(), pwatkr, true); } } - if ((!onlyIfLethal && damageToPW > 0) || damageToPW >= ((Card) def).getCounters(CounterType.LOYALTY)) { + if ((!onlyIfLethal && damageToPW > 0) || damageToPW >= def.getCounters(CounterType.LOYALTY)) { threatenedPWs.add((Card) def); } } @@ -879,7 +879,7 @@ public class AiBlockController { if (!chumpPWDefenders.isEmpty()) { for (final Card attacker : attackers) { GameEntity def = combat.getDefenderByAttacker(attacker); - if (def instanceof Card && threatenedPWs.contains((Card) def)) { + if (def instanceof Card && threatenedPWs.contains(def)) { if (attacker.hasKeyword(Keyword.TRAMPLE)) { // don't bother trying to chump a trampling creature continue; @@ -914,7 +914,7 @@ public class AiBlockController { pwDefenders.addAll(combat.getBlockers(pwAtk)); } else { isFullyBlocked = false; - damageToPW += ComputerUtilCombat.predictDamageTo((Card) pw, pwAtk.getNetCombatDamage(), pwAtk, true); + damageToPW += ComputerUtilCombat.predictDamageTo(pw, pwAtk.getNetCombatDamage(), pwAtk, true); } } if (!isFullyBlocked && damageToPW >= pw.getCounters(CounterType.LOYALTY)) { @@ -1329,13 +1329,9 @@ public class AiBlockController { && ((Card) combat.getDefenderByAttacker(attacker)).isPlaneswalker(); boolean wantToTradeDownToSavePW = chanceToTradeDownToSaveWalker > 0; - if (((evalBlk <= evalAtk + 1) || (wantToSavePlaneswalker && wantToTradeDownToSavePW)) // "1" accounts for tapped. + return ((evalBlk <= evalAtk + 1) || (wantToSavePlaneswalker && wantToTradeDownToSavePW)) // "1" accounts for tapped. && powerParityOrHigher && (creatureParityOrAllowedDiff || wantToTradeWithCreatInHand) - && (MyRandom.percentTrue(chance) || wantToSavePlaneswalker)) { - return true; - } - - return false; + && (MyRandom.percentTrue(chance) || wantToSavePlaneswalker); } } diff --git a/forge-ai/src/main/java/forge/ai/AiCardMemory.java b/forge-ai/src/main/java/forge/ai/AiCardMemory.java index e0794076723..9e203710dd9 100644 --- a/forge-ai/src/main/java/forge/ai/AiCardMemory.java +++ b/forge-ai/src/main/java/forge/ai/AiCardMemory.java @@ -137,7 +137,7 @@ public class AiCardMemory { Set memorySet = getMemorySet(set); - return memorySet == null ? false : memorySet.contains(c); + return memorySet != null && memorySet.contains(c); } /** @@ -291,7 +291,7 @@ public class AiCardMemory { * @return true, if the given memory set contains no remembered cards. */ public boolean isMemorySetEmpty(MemorySet set) { - return set == null ? true : getMemorySet(set).isEmpty(); + return set == null || getMemorySet(set).isEmpty(); } /** diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index bc548e7079f..3a10b030309 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1516,13 +1516,9 @@ public class AiController { // Hopefully there's not much to do with the extra mana immediately, can wait for Main 2 return true; } - if ((predictedMana <= totalCMCInHand && canCastWithLandDrop) || (hasRelevantAbsOTB && !isTapLand) || hasLandBasedEffect) { - // Might need an extra land to cast something, or for some kind of an ETB ability with a cost or an - // alternative cost (if we cast it in Main 1), or to use an activated ability on the battlefield - return false; - } - - return true; + // Might need an extra land to cast something, or for some kind of an ETB ability with a cost or an + // alternative cost (if we cast it in Main 1), or to use an activated ability on the battlefield + return (predictedMana > totalCMCInHand || !canCastWithLandDrop) && (!hasRelevantAbsOTB || isTapLand) && !hasLandBasedEffect; } private final SpellAbility getSpellAbilityToPlay() { @@ -1641,12 +1637,8 @@ public class AiController { return SpellApiToAi.Converter.get(spell.getApi()).doTriggerAI(player, spell, mandatory); if (spell instanceof WrappedAbility) return doTrigger(((WrappedAbility)spell).getWrappedAbility(), mandatory); - if (spell.getPayCosts() == Cost.Zero && spell.getTargetRestrictions() == null) { - // For non-converted triggers (such as Cumulative Upkeep) that don't have costs or targets to worry about - return true; - } - - return false; + // For non-converted triggers (such as Cumulative Upkeep) that don't have costs or targets to worry about + return spell.getPayCosts() == Cost.Zero && spell.getTargetRestrictions() == null; } /** @@ -1690,16 +1682,11 @@ public class AiController { left = AbilityUtils.calculateAmount(hostCard, svarToCheck, sa); } System.out.println("aiShouldRun?" + left + comparator + compareTo); - if (Expressions.compare(left, comparator, compareTo)) { - return true; - } + return Expressions.compare(left, comparator, compareTo); } else if (effect.getMapParams().containsKey("AICheckDredge")) { return player.getCardsIn(ZoneType.Library).size() > 8 || player.isCardInPlay("Laboratory Maniac"); - } else if (sa != null && doTrigger(sa, false)) { - return true; - } + } else return sa != null && doTrigger(sa, false); - return false; } public List chooseSaToActivateFromOpeningHand(List usableFromOpeningHand) { @@ -2078,9 +2065,7 @@ public class AiController { // AI-specific restrictions specified as activation parameters in spell abilities if (sa.hasParam("AILifeThreshold")) { - if (player.getLife() <= Integer.parseInt(sa.getParam("AILifeThreshold"))) { - return false; - } + return player.getLife() > Integer.parseInt(sa.getParam("AILifeThreshold")); } return true; diff --git a/forge-ai/src/main/java/forge/ai/AiCostDecision.java b/forge-ai/src/main/java/forge/ai/AiCostDecision.java index c5ae2738f94..47dfbbd4d4b 100644 --- a/forge-ai/src/main/java/forge/ai/AiCostDecision.java +++ b/forge-ai/src/main/java/forge/ai/AiCostDecision.java @@ -56,7 +56,7 @@ public class AiCostDecision extends CostDecisionMakerBase { @Override public PaymentDecision visit(CostChooseCreatureType cost) { String choice = player.getController().chooseSomeType("Creature", ability, CardType.getAllCreatureTypes(), - Lists.newArrayList()); + Lists.newArrayList()); return PaymentDecision.type(choice); } @@ -475,7 +475,7 @@ public class AiCostDecision extends CostDecisionMakerBase { if (ability.getPayCosts().hasTapCost() && typeList.contains(ability.getHostCard())) { c--; } - source.setSVar("ChosenX", "Number$" + Integer.toString(c)); + source.setSVar("ChosenX", "Number$" + c); } else { if (!isVehicle) { c = AbilityUtils.calculateAmount(source, amount, ability); @@ -809,7 +809,7 @@ public class AiCostDecision extends CostDecisionMakerBase { final String sVar = ability.getSVar(amount); if (sVar.equals("XChoice")) { c = AbilityUtils.calculateAmount(source, "ChosenX", ability); - source.setSVar("ChosenX", "Number$" + String.valueOf(c)); + source.setSVar("ChosenX", "Number$" + c); } else if (amount.equals("All")) { c = source.getCounters(cost.counter); } else if (sVar.equals("Targeted$CardManaCost")) { @@ -865,7 +865,7 @@ public class AiCostDecision extends CostDecisionMakerBase { } typeList = CardLists.filter(typeList, Presets.TAPPED); c = typeList.size(); - source.setSVar("ChosenX", "Number$" + Integer.toString(c)); + source.setSVar("ChosenX", "Number$" + c); } else { c = AbilityUtils.calculateAmount(source, amount, ability); } diff --git a/forge-ai/src/main/java/forge/ai/AiPlayDecision.java b/forge-ai/src/main/java/forge/ai/AiPlayDecision.java index c3c41cd20ba..692badb6bd8 100644 --- a/forge-ai/src/main/java/forge/ai/AiPlayDecision.java +++ b/forge-ai/src/main/java/forge/ai/AiPlayDecision.java @@ -17,5 +17,5 @@ public enum AiPlayDecision { WouldBecomeZeroToughnessCreature, WouldDestroyWorldEnchantment, BadEtbEffects, - CurseEffects; + CurseEffects } \ No newline at end of file diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index baf97df8181..ffc4d8815dd 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -423,7 +423,7 @@ public class ComputerUtil { int mana = ComputerUtilMana.getAvailableManaEstimate(ai, false); boolean cantAffordSoon = activate.getCMC() > mana + 1; - boolean wrongColor = !activate.determineColor().hasNoColorsExcept(ColorSet.fromNames(ComputerUtilCost.getAvailableManaColors(ai, ImmutableList.of())).getColor()); + boolean wrongColor = !activate.determineColor().hasNoColorsExcept(ColorSet.fromNames(ComputerUtilCost.getAvailableManaColors(ai, ImmutableList.of())).getColor()); // Only do this for spells, not activated abilities // We can't pay for this spell even if we play another land, or have wrong colors @@ -524,7 +524,7 @@ public class ComputerUtil { typeList = CardLists.filter(typeList, CardPredicates.canBeSacrificedBy(ability)); - if ((target != null) && target.getController() == ai && typeList.contains(target)) { + if ((target != null) && target.getController() == ai) { typeList.remove(target); // don't sacrifice the card we're pumping } @@ -554,7 +554,7 @@ public class ComputerUtil { final Card target, final int amount) { CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate, null); - if ((target != null) && target.getController() == ai && typeList.contains(target)) { + if ((target != null) && target.getController() == ai) { typeList.remove(target); // don't exile the card we're pumping } @@ -575,7 +575,7 @@ public class ComputerUtil { final Card target, final int amount) { CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(zone), type.split(";"), activate.getController(), activate, null); - if ((target != null) && target.getController() == ai && typeList.contains(target)) { + if ((target != null) && target.getController() == ai) { typeList.remove(target); // don't move the card we're pumping } @@ -704,7 +704,7 @@ public class ComputerUtil { public static CardCollection chooseReturnType(final Player ai, final String type, final Card activate, final Card target, final int amount) { final CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate, null); - if ((target != null) && target.getController() == ai && typeList.contains(target)) { + if ((target != null) && target.getController() == ai) { // don't bounce the card we're pumping typeList.remove(target); } @@ -794,12 +794,8 @@ public class ComputerUtil { if (c.hasSVar("SacMe") || ComputerUtilCard.evaluateCreature(c) < sacThreshold) { return true; } - - if (ComputerUtilCard.hasActiveUndyingOrPersist(c)) { - return true; - } - - return false; + + return ComputerUtilCard.hasActiveUndyingOrPersist(c); } }); } @@ -1107,10 +1103,8 @@ public class ComputerUtil { creatures2.add(creatures.get(i)); } } - if (((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0)).size()) > 1) - && card.isCreature() && card.getManaCost().getCMC() <= 3) { - return true; - } + return ((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0)).size()) > 1) + && card.isCreature() && card.getManaCost().getCMC() <= 3; } return false; } @@ -1161,30 +1155,25 @@ public class ComputerUtil { final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, CardPredicates.Accessors.fnGetCmc)); final int discardCMC = discard.getCMC(); if (discard.isLand()) { - if (landsInPlay.size() >= highestCMC + // Don't need more land. + return landsInPlay.size() >= highestCMC || (landsInPlay.size() + landsInHand.size() > 6 && landsInHand.size() > 1) - || (landsInPlay.size() > 3 && nonLandsInHand.size() == 0)) { - // Don't need more land. - return true; - } + || (landsInPlay.size() > 3 && nonLandsInHand.size() == 0); } else { //non-land if (discardCMC > landsInPlay.size() + landsInHand.size() + 2) { // not castable for some time. return true; - } else if (!game.getPhaseHandler().isPlayerTurn(ai) + } else // Probably don't need small stuff now. + if (!game.getPhaseHandler().isPlayerTurn(ai) && game.getPhaseHandler().getPhase().isAfter(PhaseType.MAIN2) && discardCMC > landsInPlay.size() + landsInHand.size() && discardCMC > landsInPlay.size() + 1 && nonLandsInHand.size() > 1) { // not castable for at least one other turn. return true; - } else if (landsInPlay.size() > 5 && discard.getCMC() <= 1 - && !discard.hasProperty("hasXCost", ai, null, null)) { - // Probably don't need small stuff now. - return true; - } + } else return landsInPlay.size() > 5 && discard.getCMC() <= 1 + && !discard.hasProperty("hasXCost", ai, null, null); } - return false; } // returns true if it's better to wait until blockers are declared @@ -1925,16 +1914,12 @@ public class ComputerUtil { if (predictThreatenedObjects(ai, null).contains(source)) { return true; } - if (game.getPhaseHandler().inCombat() && - ComputerUtilCombat.combatantWouldBeDestroyed(ai, source, game.getCombat())) { - return true; - } + return game.getPhaseHandler().inCombat() && + ComputerUtilCombat.combatantWouldBeDestroyed(ai, source, game.getCombat()); } else if (zone.getZoneType() == ZoneType.Exile && sa.getMayPlay() != null) { // play cards in exile that can only be played that turn if (game.getPhaseHandler().getPhase() == PhaseType.MAIN2) { - if (source.mayPlay(sa.getMayPlay()) != null) { - return true; - } + return source.mayPlay(sa.getMayPlay()) != null; } } return false; @@ -1967,11 +1952,8 @@ public class ComputerUtil { final CardCollectionView lands = CardLists.filter(handList, new Predicate() { @Override public boolean apply(final Card c) { - if (c.getManaCost().getCMC() > 0 || c.hasSVar("NeedsToPlay") - || (!c.getType().isLand() && !c.getType().isArtifact())) { - return false; - } - return true; + return c.getManaCost().getCMC() <= 0 && !c.hasSVar("NeedsToPlay") + && (c.getType().isLand() || c.getType().isArtifact()); } }); @@ -1986,10 +1968,7 @@ public class ComputerUtil { final CardCollectionView castables = CardLists.filter(handList, new Predicate() { @Override public boolean apply(final Card c) { - if (c.getManaCost().getCMC() > 0 && c.getManaCost().getCMC() <= landSize) { - return false; - } - return true; + return c.getManaCost().getCMC() <= 0 || c.getManaCost().getCMC() > landSize; } }); @@ -2186,10 +2165,7 @@ public class ComputerUtil { CardCollection goodChoices = CardLists.filter(validCards, new Predicate() { @Override public boolean apply(final Card c) { - if (c.hasSVar("DiscardMeByOpp") || c.hasSVar("DiscardMe")) { - return false; - } - return true; + return !c.hasSVar("DiscardMeByOpp") && !c.hasSVar("DiscardMe"); } }); if (goodChoices.isEmpty()) { @@ -2225,7 +2201,7 @@ public class ComputerUtil { public static String chooseSomeType(Player ai, String kindOfType, String logic, List invalidTypes) { if (invalidTypes == null) { - invalidTypes = ImmutableList.of(); + invalidTypes = ImmutableList.of(); } final Game game = ai.getGame(); @@ -2546,8 +2522,7 @@ public class ComputerUtil { @Override public boolean apply(final Card c) { if (c.getController() == ai) { - if (c.getSVar("Targeting").equals("Dies") || c.getSVar("Targeting").equals("Counter")) - return false; + return !c.getSVar("Targeting").equals("Dies") && !c.getSVar("Targeting").equals("Counter"); } return true; } @@ -2872,11 +2847,8 @@ public class ComputerUtil { return false; } else if (Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LoseLife"))) { return false; - } else if (Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LichDraw"))) { - return false; - } + } else return !Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LichDraw")); - return true; } public static boolean lifegainNegative(final Player player, final Card source) { @@ -3074,10 +3046,7 @@ public class ComputerUtil { if ((serious) && (ComputerUtilCombat.lifeInSeriousDanger(ai, combat, payment))) { return true; } - if ((!serious) && (ComputerUtilCombat.lifeInDanger(ai, combat, payment))) { - return true; - } - return false; + return (!serious) && (ComputerUtilCombat.lifeInDanger(ai, combat, payment)); } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 843bc7c4e37..b00dccd66b5 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -368,7 +368,7 @@ public class ComputerUtilCard { } if (hasEnchantmants || hasArtifacts) { - final List ae = CardLists.filter(list, Predicates.and(Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS), new Predicate() { + final List ae = CardLists.filter(list, Predicates.and(Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS), new Predicate() { @Override public boolean apply(Card card) { return !card.hasSVar("DoNotDiscardIfAble"); @@ -1301,7 +1301,7 @@ public class ComputerUtilCard { combatTrick = true; final List kws = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) - : Lists.newArrayList(); + : Lists.newArrayList(); for (String kw : kws) { if (!kw.equals("Trample") && !kw.equals("First Strike") && !kw.equals("Double Strike")) { combatTrick = false; @@ -1742,20 +1742,14 @@ public class ComputerUtilCard { if (!c.isCreature()) { return false; } - if (c.hasKeyword("CARDNAME can't attack or block.") || (c.hasKeyword("CARDNAME doesn't untap during your untap step.") && c.isTapped()) || (c.getOwner() == ai && ai.getOpponents().contains(c.getController()))) { - return true; - } - return false; + return c.hasKeyword("CARDNAME can't attack or block.") || (c.hasKeyword("CARDNAME doesn't untap during your untap step.") && c.isTapped()) || (c.getOwner() == ai && ai.getOpponents().contains(c.getController())); } public static boolean hasActiveUndyingOrPersist(final Card c) { if (c.hasKeyword(Keyword.UNDYING) && c.getCounters(CounterType.P1P1) == 0) { return true; } - if (c.hasKeyword(Keyword.PERSIST) && c.getCounters(CounterType.M1M1) == 0) { - return true; - } - return false; + return c.hasKeyword(Keyword.PERSIST) && c.getCounters(CounterType.M1M1) == 0; } public static boolean isPresentOnBattlefield(final Game game, final String cardName) { diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java index 4a38704d130..5c56a8f84a6 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java @@ -84,7 +84,7 @@ public class ComputerUtilCombat { return Iterables.any(defenders, new Predicate() { @Override public boolean apply(final GameEntity input) { return ComputerUtilCombat.canAttackNextTurn(attacker, input); - }; + } }); } // canAttackNextTurn(Card) @@ -119,11 +119,7 @@ public class ComputerUtilCombat { } // The creature won't untap next turn - if (atacker.isTapped() && !Untap.canUntap(atacker)) { - return false; - } - - return true; + return !atacker.isTapped() || Untap.canUntap(atacker); } // canAttackNextTurn(Card, GameEntity) /** @@ -889,12 +885,10 @@ public class ComputerUtilCombat { || CardTraitBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source))) { return true; } - if (CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source) + return CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source) && attacker.getNetCombatDamage() > 0 && (!trigParams.containsKey("ValidTarget") - || CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source))) { - return true; - } + || CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source)); } return false; } @@ -1414,7 +1408,7 @@ public class ComputerUtilCombat { if (att.matches("[0-9][0-9]?") || att.matches("-" + "[0-9][0-9]?")) { power += Integer.parseInt(att); } else { - String bonus = new String(source.getSVar(att)); + String bonus = source.getSVar(att); if (bonus.contains("TriggerCount$NumBlockers")) { bonus = TextUtil.fastReplace(bonus, "TriggerCount$NumBlockers", "Number$1"); } else if (bonus.contains("TriggeredPlayersDefenders$Amount")) { // for Melee @@ -1655,7 +1649,7 @@ public class ComputerUtilCombat { if (def.matches("[0-9][0-9]?") || def.matches("-" + "[0-9][0-9]?")) { toughness += Integer.parseInt(def); } else { - String bonus = new String(source.getSVar(def)); + String bonus = source.getSVar(def); if (bonus.contains("TriggerCount$NumBlockers")) { bonus = TextUtil.fastReplace(bonus, "TriggerCount$NumBlockers", "Number$1"); } else if (bonus.contains("TriggeredPlayersDefenders$Amount")) { // for Melee @@ -1795,11 +1789,7 @@ public class ComputerUtilCombat { } // all damage will be prevented - if (attacker.hasKeyword("PreventAllDamageBy Creature.blockingSource")) { - return true; - } - - return false; + return attacker.hasKeyword("PreventAllDamageBy Creature.blockingSource"); } // can the blocker destroy the attacker? @@ -1922,9 +1912,7 @@ public class ComputerUtilCombat { return false; } } - if (attackerLife <= 2 * defenderDamage) { - return true; - } + return attackerLife <= 2 * defenderDamage; } // defender double strike else { // no double strike for defender @@ -1948,7 +1936,7 @@ public class ComputerUtilCombat { return defenderDamage >= attackerLife; } // defender no double strike - return false; // should never arrive here + // should never arrive here } // canDestroyAttacker // For AI safety measures like Regeneration @@ -2169,9 +2157,7 @@ public class ComputerUtilCombat { return false; } } - if (defenderLife <= 2 * attackerDamage) { - return true; - } + return defenderLife <= 2 * attackerDamage; } // attacker double strike else { // no double strike for attacker @@ -2195,7 +2181,7 @@ public class ComputerUtilCombat { return attackerDamage >= defenderLife; } // attacker no double strike - return false; // should never arrive here + // should never arrive here } // canDestroyBlocker diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 43c942f94a2..bdbf2abf61c 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -424,7 +424,7 @@ public class ComputerUtilCost { continue; } final int remainingLife = ai.getLife(); - final int lifeCost = ((CostPayLife) part).convertAmount(); + final int lifeCost = part.convertAmount(); if ((remainingLife - lifeCost) < 10) { return false; //Don't pay life if it would put AI under 10 life } else if ((remainingLife / lifeCost) < 4) { @@ -552,7 +552,7 @@ public class ComputerUtilCost { final Card source = sa.getHostCard(); final String aiLogic = sa.getParam("UnlessAI"); boolean payForOwnOnly = "OnlyOwn".equals(aiLogic); - boolean payOwner = sa.hasParam("UnlessAI") ? aiLogic.startsWith("Defined") : false; + boolean payOwner = sa.hasParam("UnlessAI") && aiLogic.startsWith("Defined"); boolean payNever = "Never".equals(aiLogic); boolean shockland = "Shockland".equals(aiLogic); boolean isMine = sa.getActivatingPlayer().equals(payer); diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 7aae37dc721..5ac65671de7 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -905,10 +905,8 @@ public class ComputerUtilMana { AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2); } else { - if (AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2)) { - // This mana source is held elsewhere for a Main Phase 2 spell. - return true; - } + // This mana source is held elsewhere for a Main Phase 2 spell. + return AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2); } return false; diff --git a/forge-ai/src/main/java/forge/ai/GameState.java b/forge-ai/src/main/java/forge/ai/GameState.java index a7477639ce4..deb1a7d021b 100644 --- a/forge-ai/src/main/java/forge/ai/GameState.java +++ b/forge-ai/src/main/java/forge/ai/GameState.java @@ -1061,7 +1061,7 @@ public abstract class GameState { } private void applyCountersToGameEntity(GameEntity entity, String counterString) { - entity.setCounters(Maps.newEnumMap(CounterType.class)); + entity.setCounters(Maps.newEnumMap(CounterType.class)); String[] allCounterStrings = counterString.split(","); for (final String counterPair : allCounterStrings) { String[] pair = counterPair.split("=", 2); @@ -1107,7 +1107,7 @@ public abstract class GameState { Map counters = c.getCounters(); // Note: Not clearCounters() since we want to keep the counters // var as-is. - c.setCounters(Maps.newEnumMap(CounterType.class)); + c.setCounters(Maps.newEnumMap(CounterType.class)); if (c.isAura()) { // dummy "enchanting" to indicate that the card will be force-attached elsewhere // (will be overridden later, so the actual value shouldn't matter) diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 529df9a08c8..7e4923d8c9d 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -492,7 +492,7 @@ public class PlayerControllerAi extends PlayerController { Card toDiscard = Aggregates.itemWithMin(cardsOfType, CardPredicates.Accessors.fnGetCmc); return new CardCollection(toDiscard); } - return getAi().getCardsToDiscard(num, (String[])null, sa); + return getAi().getCardsToDiscard(num, null, sa); } @@ -612,7 +612,7 @@ public class PlayerControllerAi extends PlayerController { @Override public CardCollection chooseCardsToDiscardToMaximumHandSize(int numDiscard) { - return brains.getCardsToDiscard(numDiscard, (String[])null, null); + return brains.getCardsToDiscard(numDiscard, null, null); } @Override @@ -669,7 +669,7 @@ public class PlayerControllerAi extends PlayerController { throw new InvalidParameterException("SA is not api-based, this is not supported yet"); } return SpellApiToAi.Converter.get(api).chooseNumber(player, sa, min, max, params); - }; + } @Override public int chooseNumber(SpellAbility sa, String title, List options, Player relatedPlayer) { diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 1b3afb1d8c1..6124365e7f8 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -94,12 +94,8 @@ public class SpecialCardAi { int minCMC = isLowCMCDeck ? 3 : 4; // probably not worth wasting a lotus on a low-CMC spell (<4 CMC), except in low-CMC decks, where 3 CMC may be fine int paidCMC = cost.getConvertedManaCost(); if (paidCMC < minCMC) { - if (paidCMC == 3 && numManaSrcs < 3) { - // if it's a CMC 3 spell and we're more than one mana source short for it, might be worth it anyway - return true; - } - - return false; + // if it's a CMC 3 spell and we're more than one mana source short for it, might be worth it anyway + return paidCMC == 3 && numManaSrcs < 3; } return true; @@ -218,11 +214,7 @@ public class SpecialCardAi { } } - if (ai.getLife() <= sa.getHostCard().getNetPower() && !hasUsefulBlocker) { - return true; - } else { - return false; - } + return ai.getLife() <= sa.getHostCard().getNetPower() && !hasUsefulBlocker; } public static int getSacThreshold() { @@ -335,7 +327,7 @@ public class SpecialCardAi { boolean canTrample = source.hasKeyword(Keyword.TRAMPLE); if (!isBlocking && combat.getDefenderByAttacker(source) instanceof Card) { - int loyalty = ((Card)combat.getDefenderByAttacker(source)).getCounters(CounterType.LOYALTY); + int loyalty = combat.getDefenderByAttacker(source).getCounters(CounterType.LOYALTY); int totalDamageToPW = 0; for (Card atk : (combat.getAttackersOf(combat.getDefenderByAttacker(source)))) { if (combat.isUnblocked(atk)) { @@ -385,15 +377,12 @@ public class SpecialCardAi { // Already enough to kill the blockers and survive, don't overpump return false; } - if (oppCantDie && !source.hasKeyword(Keyword.TRAMPLE) && !source.hasKeyword(Keyword.WITHER) - && !source.hasKeyword(Keyword.INFECT) && predictedPT.getLeft() <= oppT) { - // Can't kill or cripple anyone, as well as can't Trample over, so don't pump - return false; - } + // Can't kill or cripple anyone, as well as can't Trample over, so don't pump + return !oppCantDie || source.hasKeyword(Keyword.TRAMPLE) || source.hasKeyword(Keyword.WITHER) + || source.hasKeyword(Keyword.INFECT) || predictedPT.getLeft() > oppT; // If we got here, it should be a favorable combat pump, resulting in at least one // opposing creature dying, and hopefully with the Pummeler surviving combat. - return true; } public static boolean predictOverwhelmingDamage(final Player ai, final SpellAbility sa) { @@ -411,11 +400,7 @@ public class SpecialCardAi { Pair predictedPT = getPumpedPT(ai, source.getNetCombatDamage(), source.getNetToughness()); int oppT = Aggregates.sum(potentialBlockers, CardPredicates.Accessors.fnGetNetToughness); - if (potentialBlockers.isEmpty() || (source.hasKeyword(Keyword.TRAMPLE) && predictedPT.getLeft() - oppT >= oppLife)) { - return true; - } - - return false; + return potentialBlockers.isEmpty() || (source.hasKeyword(Keyword.TRAMPLE) && predictedPT.getLeft() - oppT >= oppLife); } public static Pair getPumpedPT(Player ai, int power, int toughness) { @@ -486,15 +471,13 @@ public class SpecialCardAi { } if (isExileMode) { + // We probably need a low-CMC card to exile to it, exiling a higher CMC spell may be suboptimal + // since the AI does not prioritize/value cards vs. permission at the moment. if (blueCards.size() < 2) { // Need to have something else in hand that is blue in addition to Force of Will itself, // otherwise the AI will fail to play the card and the card will disappear from the pool return false; - } else if (CardLists.filter(blueCards, CardPredicates.lessCMC(3)).isEmpty()) { - // We probably need a low-CMC card to exile to it, exiling a higher CMC spell may be suboptimal - // since the AI does not prioritize/value cards vs. permission at the moment. - return false; - } + } else return !CardLists.filter(blueCards, CardPredicates.lessCMC(3)).isEmpty(); } return true; @@ -522,7 +505,7 @@ public class SpecialCardAi { best.add(sp); // these SAs are prioritized since the AI sees a reason to play them now } final List keywords = sp.hasParam("KW") ? Arrays.asList(sp.getParam("KW").split(" & ")) - : Lists.newArrayList(); + : Lists.newArrayList(); for (String kw : keywords) { if (!tgtCard.hasKeyword(kw)) { if ("Indestructible".equals(kw) && ai.getOpponents().getCreaturesInPlay().isEmpty()) { @@ -568,10 +551,7 @@ public class SpecialCardAi { @Override public boolean apply(final Card c) { // Don't enchant creatures that can survive - if (!c.canBeDestroyed() || c.getNetCombatDamage() < c.getNetToughness() || c.isEnchantedBy("Guilty Conscience")) { - return false; - } - return true; + return c.canBeDestroyed() && c.getNetCombatDamage() >= c.getNetToughness() && !c.isEnchantedBy("Guilty Conscience"); } }); chosen = ComputerUtilCard.getBestCreatureAI(creatures); @@ -912,15 +892,12 @@ public class SpecialCardAi { } else if (blackViseOTB && computerHandSize + exiledWithNecro - 1 >= 4) { // try not to overdraw in presence of Black Vise return false; - } else if (computerHandSize + exiledWithNecro - 1 >= maxHandSize) { + } else // Only activate in AI's own turn (sans the exception above) + if (computerHandSize + exiledWithNecro - 1 >= maxHandSize) { // Only draw until we reach max hand size return false; - } else if (!ph.isPlayerTurn(ai) || !ph.is(PhaseType.MAIN2)) { - // Only activate in AI's own turn (sans the exception above) - return false; - } + } else return ph.isPlayerTurn(ai) && ph.is(PhaseType.MAIN2); - return true; } } @@ -941,11 +918,7 @@ public class SpecialCardAi { } // Maybe use it for some important high-impact spells even if there are more cards in hand? - if (ai.getCardsIn(ZoneType.Hand).size() > 1 && !hasEnsnaringBridgeEffect) { - return false; - } - - return true; + return ai.getCardsIn(ZoneType.Hand).size() <= 1 || hasEnsnaringBridgeEffect; } } @@ -1310,12 +1283,8 @@ public class SpecialCardAi { } } - if (aiHandSize < HAND_SIZE_THRESHOLD || maxOppHandSize - aiHandSize > HAND_SIZE_THRESHOLD) { - // use in case we're getting low on cards or if we're significantly behind our opponent in cards in hand - return true; - } - - return false; + // use in case we're getting low on cards or if we're significantly behind our opponent in cards in hand + return aiHandSize < HAND_SIZE_THRESHOLD || maxOppHandSize - aiHandSize > HAND_SIZE_THRESHOLD; } } @@ -1342,9 +1311,7 @@ public class SpecialCardAi { if (topGY == null || !topGY.isCreature() || ComputerUtilCard.evaluateCreature(creatHand) > ComputerUtilCard.evaluateCreature(topGY) + 80) { - if (numCreatsInHand > 1 || !ComputerUtilMana.canPayManaCost(creatHand.getSpellPermanent(), ai, 0)) { - return true; - } + return numCreatsInHand > 1 || !ComputerUtilMana.canPayManaCost(creatHand.getSpellPermanent(), ai, 0); } } @@ -1459,15 +1426,12 @@ public class SpecialCardAi { } else if (blackViseOTB && computerHandSize + 1 > 4) { // try not to overdraw in presence of Black Vise return false; - } else if (computerHandSize + 1 > maxHandSize) { + } else // Only activate in AI's own turn (sans the exception above) + if (computerHandSize + 1 > maxHandSize) { // Only draw until we reach max hand size return false; - } else if (!ph.isPlayerTurn(ai)) { - // Only activate in AI's own turn (sans the exception above) - return false; - } + } else return ph.isPlayerTurn(ai); - return true; } } diff --git a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java index d86989d87a8..b2f95d717fe 100644 --- a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java @@ -133,10 +133,7 @@ public abstract class SpellAbilityAi { if (!ComputerUtilCost.checkSacrificeCost(ai, cost, source, sa)) { return false; } - if (!ComputerUtilCost.checkRemoveCounterCost(cost, source, sa)) { - return false; - } - return true; + return ComputerUtilCost.checkRemoveCounterCost(cost, source, sa); } /** diff --git a/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java b/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java index 44780ec2e94..18029dd4d7f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java @@ -56,12 +56,9 @@ public class ActivateAbilityAi extends SpellAbilityAi { } else { final List defined = AbilityUtils.getDefinedPlayers(source, sa.getParam("Defined"), sa); - if (!defined.contains(opp)) { - return false; - } + return defined.contains(opp); } - return true; } else { sa.resetTargets(); sa.getTargets().add(opp); diff --git a/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java b/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java index 243edf2c3f7..f20a3f2f7fd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java @@ -67,10 +67,8 @@ public class AddTurnAi extends SpellAbilityAi { return false; } } - if (!StringUtils.isNumeric(sa.getParam("NumTurns"))) { - // TODO: improve ai for Sage of Hours - return false; - } + // TODO: improve ai for Sage of Hours + return StringUtils.isNumeric(sa.getParam("NumTurns")); // not sure if the AI should be playing with cards that give the // Human more turns. } 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 0c98f2b65c6..7699259abd1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java @@ -23,9 +23,7 @@ public class AmassAi extends SpellAbilityAi { final Game game = ai.getGame(); if (!aiArmies.isEmpty()) { - if (CardLists.count(aiArmies, CardPredicates.canReceiveCounters(CounterType.P1P1)) <= 0) { - return false; - } + return CardLists.count(aiArmies, CardPredicates.canReceiveCounters(CounterType.P1P1)) > 0; } else { final String tokenScript = "b_0_0_zombie_army"; final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("Num", "1"), sa); @@ -57,12 +55,9 @@ public class AmassAi extends SpellAbilityAi { //reset static abilities game.getAction().checkStaticAbilities(false); - if (!result) { - return false; - } + return result; } - return true; } @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java index 0ba446e250e..5270bea95d1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java @@ -117,12 +117,9 @@ public class AnimateAi extends SpellAbilityAi { boolean activateAsPotentialBlocker = sa.hasParam("UntilYourNextTurn") && ai.getGame().getPhaseHandler().getNextTurn() != ai && source.isPermanent(); - if (ph.isPlayerTurn(ai) && ai.getLife() < 6 && opponent.getLife() > 6 - && Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES) - && !sa.hasParam("AILogic") && !sa.hasParam("Permanent") && !activateAsPotentialBlocker) { - return false; - } - return true; + return !ph.isPlayerTurn(ai) || ai.getLife() >= 6 || opponent.getLife() <= 6 + || !Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES) + || sa.hasParam("AILogic") || sa.hasParam("Permanent") || activateAsPotentialBlocker; } @Override @@ -207,21 +204,16 @@ public class AnimateAi extends SpellAbilityAi { return bFlag; // All of the defined stuff is animated, not very useful } else { sa.resetTargets(); - if (!animateTgtAI(sa)) { - return false; - } + return animateTgtAI(sa); } - return true; } @Override public boolean chkAIDrawback(SpellAbility sa, Player aiPlayer) { if (sa.usesTargeting()) { sa.resetTargets(); - if (!animateTgtAI(sa)) { - return false; - } + return animateTgtAI(sa); } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java index 8e126db8ae8..79770568fd3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java @@ -8,11 +8,7 @@ public class AnimateAllAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { - if ("Always".equals(sa.getParam("AILogic"))) { - return true; - } - - return false; + return "Always".equals(sa.getParam("AILogic")); } // end animateAllCanPlayAI() @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index ae728a26dc7..cb723ad515c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -123,9 +123,7 @@ public class AttachAi extends SpellAbilityAi { return !(c.hasProtectionFrom(source) || c.hasKeyword(Keyword.SHROUD) || c.hasKeyword(Keyword.HEXPROOF)); } }); - if (targets.isEmpty()) { - return false; - } + return !targets.isEmpty(); } return true; @@ -239,9 +237,7 @@ public class AttachAi extends SpellAbilityAi { return false; } - if (!(combat.isAttacking(attachTarget) || combat.isBlocking(attachTarget))) { - return false; - } + return combat.isAttacking(attachTarget) || combat.isBlocking(attachTarget); } return true; @@ -987,9 +983,7 @@ public class AttachAi extends SpellAbilityAi { return false; } // don't equip creatures that don't gain anything - if (card.hasSVar("NonStackingAttachEffect") && newTarget.isEquippedBy(card.getName())) { - return false; - } + return !card.hasSVar("NonStackingAttachEffect") || !newTarget.isEquippedBy(card.getName()); } } @@ -1353,7 +1347,7 @@ public class AttachAi extends SpellAbilityAi { CardCollection prefList = list; // Filter AI-specific targets if provided - prefList = ComputerUtil.filterAITgts(sa, aiPlayer, (CardCollection)list, true); + prefList = ComputerUtil.filterAITgts(sa, aiPlayer, list, true); Card c = attachGeneralAI(aiPlayer, sa, prefList, mandatory, attachSource, sa.getParam("AILogic")); @@ -1557,86 +1551,55 @@ public class AttachAi extends SpellAbilityAi { } if (evasive) { - if (card.getNetCombatDamage() + powerBonus <= 0 - || !ComputerUtilCombat.canAttackNextTurn(card) - || !canBeBlocked) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 + && ComputerUtilCombat.canAttackNextTurn(card) + && canBeBlocked; } else if (keyword.equals("Haste")) { - if (!card.hasSickness() || !ph.isPlayerTurn(sa.getActivatingPlayer()) || card.isTapped() - || card.getNetCombatDamage() + powerBonus <= 0 - || card.hasKeyword("CARDNAME can attack as though it had haste.") - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || !ComputerUtilCombat.canAttackNextTurn(card)) { - return false; - } + return card.hasSickness() && ph.isPlayerTurn(sa.getActivatingPlayer()) && !card.isTapped() + && card.getNetCombatDamage() + powerBonus > 0 + && !card.hasKeyword("CARDNAME can attack as though it had haste.") + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && ComputerUtilCombat.canAttackNextTurn(card); } else if (keyword.endsWith("Indestructible")) { return true; } else if (keyword.endsWith("Deathtouch") || keyword.endsWith("Wither")) { - if (card.getNetCombatDamage() + powerBonus <= 0 - || ((!canBeBlocked || !ComputerUtilCombat.canAttackNextTurn(card)) - && !CombatUtil.canBlock(card, true))) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 + && ((canBeBlocked && ComputerUtilCombat.canAttackNextTurn(card)) + || CombatUtil.canBlock(card, true)); } else if (keyword.equals("Double Strike") || keyword.equals("Lifelink")) { - if (card.getNetCombatDamage() + powerBonus <= 0 - || (!ComputerUtilCombat.canAttackNextTurn(card) && !CombatUtil.canBlock(card, true))) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 + && (ComputerUtilCombat.canAttackNextTurn(card) || CombatUtil.canBlock(card, true)); } else if (keyword.equals("First Strike")) { - if (card.getNetCombatDamage() + powerBonus <= 0 || card.hasKeyword(Keyword.DOUBLE_STRIKE) - || (!ComputerUtilCombat.canAttackNextTurn(card) && !CombatUtil.canBlock(card, true))) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 && !card.hasKeyword(Keyword.DOUBLE_STRIKE) + && (ComputerUtilCombat.canAttackNextTurn(card) || CombatUtil.canBlock(card, true)); } else if (keyword.startsWith("Flanking")) { - if (card.getNetCombatDamage() + powerBonus <= 0 - || !ComputerUtilCombat.canAttackNextTurn(card) - || !canBeBlocked) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 + && ComputerUtilCombat.canAttackNextTurn(card) + && canBeBlocked; } else if (keyword.startsWith("Bushido")) { - if ((!canBeBlocked || !ComputerUtilCombat.canAttackNextTurn(card)) - && !CombatUtil.canBlock(card, true)) { - return false; - } + return (canBeBlocked && ComputerUtilCombat.canAttackNextTurn(card)) + || CombatUtil.canBlock(card, true); } else if (keyword.equals("Trample")) { - if (card.getNetCombatDamage() + powerBonus <= 1 - || !canBeBlocked - || !ComputerUtilCombat.canAttackNextTurn(card)) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 1 + && canBeBlocked + && ComputerUtilCombat.canAttackNextTurn(card); } else if (keyword.equals("Infect")) { - if (card.getNetCombatDamage() + powerBonus <= 0 - || !ComputerUtilCombat.canAttackNextTurn(card)) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 + && ComputerUtilCombat.canAttackNextTurn(card); } else if (keyword.equals("Vigilance")) { - if (card.getNetCombatDamage() + powerBonus <= 0 - || !ComputerUtilCombat.canAttackNextTurn(card) - || !CombatUtil.canBlock(card, true)) { - return false; - } + return card.getNetCombatDamage() + powerBonus > 0 + && ComputerUtilCombat.canAttackNextTurn(card) + && CombatUtil.canBlock(card, true); } else if (keyword.equals("Reach")) { - if (card.hasKeyword(Keyword.FLYING) || !CombatUtil.canBlock(card, true)) { - return false; - } + return !card.hasKeyword(Keyword.FLYING) && CombatUtil.canBlock(card, true); } else if (keyword.endsWith("CARDNAME can block an additional creature each combat.")) { - if (!CombatUtil.canBlock(card, true) || card.hasKeyword("CARDNAME can block any number of creatures.") - || card.hasKeyword("CARDNAME can block an additional ninety-nine creatures each combat.")) { - return false; - } + return CombatUtil.canBlock(card, true) && !card.hasKeyword("CARDNAME can block any number of creatures.") + && !card.hasKeyword("CARDNAME can block an additional ninety-nine creatures each combat."); } else if (keyword.equals("CARDNAME can attack as though it didn't have defender.")) { - if (!card.hasKeyword(Keyword.DEFENDER) || card.getNetCombatDamage() + powerBonus <= 0) { - return false; - } + return card.hasKeyword(Keyword.DEFENDER) && card.getNetCombatDamage() + powerBonus > 0; } else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) { - if (card.hasKeyword(Keyword.SHROUD) || card.hasKeyword(Keyword.HEXPROOF)) { - return false; - } - } else if (keyword.equals("Defender")) { - return false; - } - return true; + return !card.hasKeyword(Keyword.SHROUD) && !card.hasKeyword(Keyword.HEXPROOF); + } else return !keyword.equals("Defender"); } /** @@ -1657,17 +1620,11 @@ public class AttachAi extends SpellAbilityAi { if (keyword.endsWith("CARDNAME can't attack.") || keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack or block.")) { - if (!ComputerUtilCombat.canAttackNextTurn(card) || card.getNetCombatDamage() < 1) { - return false; - } + return ComputerUtilCombat.canAttackNextTurn(card) && card.getNetCombatDamage() >= 1; } else if (keyword.endsWith("CARDNAME attacks each turn if able.") || keyword.endsWith("CARDNAME attacks each combat if able.")) { - if (!ComputerUtilCombat.canAttackNextTurn(card) || !CombatUtil.canBlock(card, true) || ai.getCreaturesInPlay().isEmpty()) { - return false; - } + return ComputerUtilCombat.canAttackNextTurn(card) && CombatUtil.canBlock(card, true) && !ai.getCreaturesInPlay().isEmpty(); } else if (keyword.endsWith("CARDNAME can't block.") || keyword.contains("CantBlock")) { - if (!CombatUtil.canBlock(card, true)) { - return false; - } + return CombatUtil.canBlock(card, true); } else if (keyword.endsWith("CARDNAME's activated abilities can't be activated.")) { for (SpellAbility ability : card.getSpellAbilities()) { if (ability.isAbility()) { @@ -1676,18 +1633,12 @@ public class AttachAi extends SpellAbilityAi { } return false; } else if (keyword.endsWith("Prevent all combat damage that would be dealt by CARDNAME.")) { - if (!ComputerUtilCombat.canAttackNextTurn(card) || card.getNetCombatDamage() < 1) { - return false; - } + return ComputerUtilCombat.canAttackNextTurn(card) && card.getNetCombatDamage() >= 1; } else if (keyword.endsWith("Prevent all combat damage that would be dealt to and dealt by CARDNAME.") || keyword.endsWith("Prevent all damage that would be dealt to and dealt by CARDNAME.")) { - if (!ComputerUtilCombat.canAttackNextTurn(card) || card.getNetCombatDamage() < 2) { - return false; - } + return ComputerUtilCombat.canAttackNextTurn(card) && card.getNetCombatDamage() >= 2; } else if (keyword.endsWith("CARDNAME doesn't untap during your untap step.")) { - if (card.isUntapped()) { - return false; - } + return !card.isUntapped(); } return true; } @@ -1711,12 +1662,8 @@ public class AttachAi extends SpellAbilityAi { return true; } - if (sa.getHostCard().isEquipment() && ComputerUtilCard.isUselessCreature(ai, c)) { - // useless to equip a creature that can't attack or block. - return false; - } - - return true; + // useless to equip a creature that can't attack or block. + return !sa.getHostCard().isEquipment() || !ComputerUtilCard.isUselessCreature(ai, c); } public static Card doPumpOrCurseAILogic(final Player ai, final SpellAbility sa, final List list, final String type) { 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 a2906c96b88..93163475b87 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -355,9 +355,7 @@ public class ChangeZoneAi extends SpellAbilityAi { @Override public boolean apply(final Card c) { if (c.getType().isLegendary()) { - if (ai.isCardInPlay(c.getName())) { - return false; - } + return !ai.isCardInPlay(c.getName()); } return true; } @@ -738,11 +736,7 @@ public class ChangeZoneAi extends SpellAbilityAi { } final AbilitySub subAb = sa.getSubAbility(); - if (subAb != null && !SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(ai, subAb)) { - return false; - } - - return true; + return subAb == null || SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(ai, subAb); } /* @@ -864,7 +858,7 @@ public class ChangeZoneAi extends SpellAbilityAi { list = CardLists.getTargetableCards(list, sa); // Filter AI-specific targets if provided - list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, true); + list = ComputerUtil.filterAITgts(sa, ai, list, true); if (sa.hasParam("AITgtsOnlyBetterThanSelf")) { list = CardLists.filter(list, new Predicate() { @Override @@ -995,11 +989,7 @@ public class ChangeZoneAi extends SpellAbilityAi { @Override public boolean apply(final Card c) { for (Card aura : c.getEnchantedBy()) { - if (aura.getController().isOpponentOf(ai)) { - return true; - } else { - return false; - } + return aura.getController().isOpponentOf(ai); } if (blink) { return c.isToken(); @@ -1471,16 +1461,12 @@ public class ChangeZoneAi extends SpellAbilityAi { if (!list.isEmpty()) { final Card attachedTo = list.get(0); // This code is for the Dragon auras - if (attachedTo.getController().isOpponentOf(ai)) { - return false; - } + return !attachedTo.getController().isOpponentOf(ai); } } } else if (isPreferredTarget(ai, sa, mandatory, true)) { // do nothing - } else if (!isUnpreferredTarget(ai, sa, mandatory)) { - return false; - } + } else return isUnpreferredTarget(ai, sa, mandatory); return true; } @@ -1532,9 +1518,7 @@ public class ChangeZoneAi extends SpellAbilityAi { @Override public boolean apply(final Card c) { if (c.getType().isLegendary()) { - if (decider.isCardInPlay(c.getName())) { - return false; - } + return !decider.isCardInPlay(c.getName()); } return true; } @@ -1543,10 +1527,7 @@ public class ChangeZoneAi extends SpellAbilityAi { fetchList = CardLists.filter(fetchList, new Predicate() { @Override public boolean apply(final Card c) { - if (ComputerUtilCard.isCardRemAIDeck(c) || ComputerUtilCard.isCardRemRandomDeck(c)) { - return false; - } - return true; + return !ComputerUtilCard.isCardRemAIDeck(c) && !ComputerUtilCard.isCardRemRandomDeck(c); } }); } @@ -1718,9 +1699,7 @@ public class ChangeZoneAi extends SpellAbilityAi { @Override public boolean apply(final Card c) { if (c.getType().isLegendary()) { - if (ai.isCardInPlay(c.getName())) { - return false; - } + return !ai.isCardInPlay(c.getName()); } return true; } @@ -1826,20 +1805,16 @@ public class ChangeZoneAi extends SpellAbilityAi { && "Battlefield".equals(causeSub.getParam("Destination"))) { // A blink effect implemented using ChangeZone API return false; - } else if (subApi == ApiType.DelayedTrigger) { + } else // This is an intrinsic effect that blinks the card (e.g. Obzedat, Ghost Council), no need to + // return the commander to the Command zone. + if (subApi == ApiType.DelayedTrigger) { SpellAbility exec = causeSub.getAdditionalAbility("Execute"); if (exec != null && exec.getApi() == ApiType.ChangeZone) { - if ("Exile".equals(exec.getParam("Origin")) && "Battlefield".equals(exec.getParam("Destination"))) { - // A blink effect implemented using a delayed trigger - return false; - } + // A blink effect implemented using a delayed trigger + return !"Exile".equals(exec.getParam("Origin")) || !"Battlefield".equals(exec.getParam("Destination")); } - } else if (causeSa.getHostCard() != null && causeSa.getHostCard().equals((Card)sa.getReplacingObject("Card")) - && causeSa.getActivatingPlayer().equals(aiPlayer)) { - // This is an intrinsic effect that blinks the card (e.g. Obzedat, Ghost Council), no need to - // return the commander to the Command zone. - return false; - } + } else return causeSa.getHostCard() == null || !causeSa.getHostCard().equals(sa.getReplacingObject("Card")) + || !causeSa.getActivatingPlayer().equals(aiPlayer); } // Normally we want the commander back in Command zone to recast him later diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java index c17506d37b2..fcf0733bf0d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java @@ -335,11 +335,8 @@ public class ChangeZoneAllAi extends SpellAbilityAi { return true; // if AI creature is better than Human Creature - if (ComputerUtilCard.evaluateCreatureList(aiCards) >= ComputerUtilCard - .evaluateCreatureList(humanCards)) { - return true; - } - return false; + return ComputerUtilCard.evaluateCreatureList(aiCards) >= ComputerUtilCard + .evaluateCreatureList(humanCards); } return true; } @@ -441,29 +438,21 @@ public class ChangeZoneAllAi extends SpellAbilityAi { if (sa.getParam("GainControl") != null) { // Check if the cards are valuable enough if ((CardLists.getNotType(humanType, "Creature").size() == 0) && (CardLists.getNotType(computerType, "Creature").size() == 0)) { - if ((ComputerUtilCard.evaluateCreatureList(computerType) + ComputerUtilCard - .evaluateCreatureList(humanType)) < 1) { - return false; - } + return (ComputerUtilCard.evaluateCreatureList(computerType) + ComputerUtilCard + .evaluateCreatureList(humanType)) >= 1; } // otherwise evaluate both lists by CMC and pass only if human // permanents are less valuable - else if ((ComputerUtilCard.evaluatePermanentList(computerType) + ComputerUtilCard - .evaluatePermanentList(humanType)) < 1) { - return false; - } + else return (ComputerUtilCard.evaluatePermanentList(computerType) + ComputerUtilCard + .evaluatePermanentList(humanType)) >= 1; } else { // don't activate if human gets more back than AI does if ((CardLists.getNotType(humanType, "Creature").isEmpty()) && (CardLists.getNotType(computerType, "Creature").isEmpty())) { - if (ComputerUtilCard.evaluateCreatureList(computerType) <= ComputerUtilCard - .evaluateCreatureList(humanType)) { - return false; - } + return ComputerUtilCard.evaluateCreatureList(computerType) > ComputerUtilCard + .evaluateCreatureList(humanType); } // otherwise evaluate both lists by CMC and pass only if human // permanents are less valuable - else if (ComputerUtilCard.evaluatePermanentList(computerType) <= ComputerUtilCard - .evaluatePermanentList(humanType)) { - return false; - } + else return ComputerUtilCard.evaluatePermanentList(computerType) > ComputerUtilCard + .evaluatePermanentList(humanType); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 6d0cee69a14..1beefd77b09 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -71,21 +71,15 @@ public class ChooseCardAi extends SpellAbilityAi { choices = CardLists.filterControlledBy(choices, ai.getOpponents()); } if (aiLogic.equals("AtLeast1") || aiLogic.equals("OppPreferred")) { - if (choices.isEmpty()) { - return false; - } + return !choices.isEmpty(); } else if (aiLogic.equals("AtLeast2") || aiLogic.equals("BestBlocker")) { - if (choices.size() < 2) { - return false; - } + return choices.size() >= 2; } else if (aiLogic.equals("Clone") || aiLogic.equals("Vesuva")) { final String filter = aiLogic.equals("Clone") ? "Permanent.YouDontCtrl,Permanent.nonLegendary" : "Permanent.YouDontCtrl+notnamedVesuva,Permanent.nonLegendary+notnamedVesuva"; choices = CardLists.getValidCards(choices, filter, host.getController(), host); - if (choices.isEmpty()) { - return false; - } + return !choices.isEmpty(); } else if (aiLogic.equals("Never")) { return false; } else if (aiLogic.equals("NeedsPrevention")) { @@ -103,9 +97,7 @@ public class ChooseCardAi extends SpellAbilityAi { return ComputerUtilCombat.damageIfUnblocked(c, ai, combat, true) > ref; } }); - if (choices.isEmpty()) { - return false; - } + return !choices.isEmpty(); } else if (aiLogic.equals("Ashiok")) { final int loyalty = host.getCounters(CounterType.LOYALTY) - 1; for (int i = loyalty; i >= 0; i--) { @@ -117,13 +109,9 @@ public class ChooseCardAi extends SpellAbilityAi { } } - if (choices.isEmpty()) { - return false; - } + return !choices.isEmpty(); } else if (aiLogic.equals("RandomNonLand")) { - if (CardLists.getValidCards(choices, "Card.nonLand", host.getController(), host).isEmpty()) { - return false; - } + return !CardLists.getValidCards(choices, "Card.nonLand", host.getController(), host).isEmpty(); } else if (aiLogic.equals("Duneblast")) { CardCollection aiCreatures = ai.getCreaturesInPlay(); CardCollection oppCreatures = ai.getWeakestOpponent().getCreaturesInPlay(); @@ -139,10 +127,8 @@ public class ChooseCardAi extends SpellAbilityAi { aiCreatures.remove(chosen); int minGain = 200; - if ((ComputerUtilCard.evaluateCreatureList(aiCreatures) + minGain) >= ComputerUtilCard - .evaluateCreatureList(oppCreatures)) { - return false; - } + return (ComputerUtilCard.evaluateCreatureList(aiCreatures) + minGain) < ComputerUtilCard + .evaluateCreatureList(oppCreatures); } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java index 8ba40274dcd..2633899924b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java @@ -52,10 +52,7 @@ public class ChooseColorAi extends SpellAbilityAi { } if ("Addle".equals(sourceName)) { - if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) || ai.getWeakestOpponent().getCardsIn(ZoneType.Hand).isEmpty()) { - return false; - } - return true; + return !ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && !ai.getWeakestOpponent().getCardsIn(ZoneType.Hand).isEmpty(); } if (logic.equals("MostExcessOpponentControls")) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java index 3480f561d70..b3ae74d5274 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java @@ -33,9 +33,7 @@ public class ChooseDirectionAi extends SpellAbilityAi { CardCollection right = CardLists.filterControlledBy(all, game.getNextPlayerAfter(ai, Direction.Right)); int leftValue = Aggregates.sum(left, CardPredicates.Accessors.fnGetCmc); int rightValue = Aggregates.sum(right, CardPredicates.Accessors.fnGetCmc); - if (aiValue > leftValue || aiValue > rightValue) { - return false; - } + return aiValue <= leftValue && aiValue <= rightValue; } } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericEffectAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericEffectAi.java index 2b608b2acbd..4ecfec696df 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericEffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericEffectAi.java @@ -385,9 +385,7 @@ public class ChooseGenericEffectAi extends SpellAbilityAi { final Player opp = player.getWeakestOpponent(); if (opp != null) { // TODO add predict Combat Damage? - if (opp.getLife() < copy.getNetPower()) { - return true; - } + return opp.getLife() < copy.getNetPower(); } // haste might not be good enough? 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 3478e74b73b..f7a694e0c67 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -97,10 +97,7 @@ public class ChooseSourceAi extends SpellAbilityAi { return false; } int dmg = AbilityUtils.calculateAmount(threatSource, topStack.getParam("NumDmg"), topStack); - if (ComputerUtilCombat.predictDamageTo(ai, dmg, threatSource, false) <= 0) { - return false; - } - return true; + return ComputerUtilCombat.predictDamageTo(ai, dmg, threatSource, false) > 0; } if (game.getPhaseHandler().getPhase() != PhaseType.COMBAT_DECLARE_BLOCKERS) { return false; @@ -119,9 +116,7 @@ public class ChooseSourceAi extends SpellAbilityAi { return ComputerUtilCombat.damageIfUnblocked(c, ai, combat, true) > 0; } }); - if (choices.isEmpty()) { - return false; - } + return !choices.isEmpty(); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java index 3f49d12fac9..3d6870d033d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java @@ -244,9 +244,6 @@ public class CloneAi extends SpellAbilityAi { } // don't activate during main2 unless this effect is permanent - if (ph.is(PhaseType.MAIN2) && !sa.hasParam("Permanent")) { - return false; - } - return true; + return !ph.is(PhaseType.MAIN2) || sa.hasParam("Permanent"); } } 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 eb6e3ed5d9b..630548b00bd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java @@ -84,9 +84,7 @@ public class ControlGainAi extends SpellAbilityAi { if (sa.hasParam("AllValid")) { CardCollectionView tgtCards = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), opponents); tgtCards = AbilityUtils.filterListByType(tgtCards, sa.getParam("AllValid"), sa); - if (tgtCards.isEmpty()) { - return false; - } + return !tgtCards.isEmpty(); } return true; } else { @@ -247,7 +245,7 @@ public class ControlGainAi extends SpellAbilityAi { break; } } - }; + } if (t != null) { sa.getTargets().add(t); @@ -296,15 +294,12 @@ public class ControlGainAi extends SpellAbilityAi { lose.addAll(Lists.newArrayList(sa.getParam("LoseControl").split(","))); } - if (lose.contains("EOT") - && game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { - return false; - } + return !lose.contains("EOT") + || !game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS); } else { return this.canPlayAI(ai, sa); } - return true; } // pumpDrawbackAI() @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java index 34827a4a273..7c973b99d45 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java @@ -90,9 +90,7 @@ public class CountersMoveAi extends SpellAbilityAi { } // for Simic Fluxmage and other - if (!ph.getNextTurn().equals(ai) || ph.getPhase().isBefore(PhaseType.END_OF_TURN)) { - return false; - } + return ph.getNextTurn().equals(ai) && !ph.getPhase().isBefore(PhaseType.END_OF_TURN); } else if (CounterType.P1P1.equals(cType) && sa.hasParam("Defined")) { // something like Cyptoplast Root-kin @@ -107,9 +105,7 @@ public class CountersMoveAi extends SpellAbilityAi { } // Make sure that removing the last counter doesn't kill the creature if ("Self".equals(sa.getParam("Source"))) { - if (host != null && host.getNetToughness() - 1 <= 0) { - return false; - } + return host == null || host.getNetToughness() - 1 > 0; } } return true; @@ -193,9 +189,7 @@ public class CountersMoveAi extends SpellAbilityAi { // check for some specific AI preferences if ("DontMoveCounterIfLethal".equals(sa.getParam("AILogic"))) { - if (cType == CounterType.P1P1 && src.getNetToughness() - src.getTempToughnessBoost() - 1 <= 0) { - return false; - } + return cType != CounterType.P1P1 || src.getNetToughness() - src.getTempToughnessBoost() - 1 > 0; } } // no target @@ -207,9 +201,7 @@ public class CountersMoveAi extends SpellAbilityAi { public boolean chkAIDrawback(SpellAbility sa, Player ai) { if (sa.usesTargeting()) { sa.resetTargets(); - if (!moveTgtAI(ai, sa)) { - return false; - } + return moveTgtAI(ai, sa); } return true; @@ -287,10 +279,7 @@ public class CountersMoveAi extends SpellAbilityAi { // do not steal a P1P1 from Undying if it would die // this way if (CounterType.P1P1.equals(cType) && srcCardCpy.getNetToughness() <= 0) { - if (srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) || card.isToken()) { - return true; - } - return false; + return srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) || card.isToken(); } return true; } @@ -338,11 +327,7 @@ public class CountersMoveAi extends SpellAbilityAi { return true; } } - if (CounterType.M1M1.equals(cType) && card.hasKeyword(Keyword.PERSIST)) { - return true; - } - - return false; + return CounterType.M1M1.equals(cType) && card.hasKeyword(Keyword.PERSIST); } }); @@ -436,11 +421,7 @@ public class CountersMoveAi extends SpellAbilityAi { } // source would leave the game - if (!card.hasSVar("EndOfTurnLeavePlay")) { - return true; - } - - return false; + return !card.hasSVar("EndOfTurnLeavePlay"); } }); diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java index 53b7c4b2619..78dec0f8c0a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java @@ -45,9 +45,7 @@ public class CountersMultiplyAi extends SpellAbilityAi { if (c.getCounters(counterType) <= 0) { return false; } - if (!c.canReceiveCounters(counterType)) { - return false; - } + return c.canReceiveCounters(counterType); } else { for (Map.Entry e : c.getCounters().entrySet()) { // has negative counter it would double @@ -87,19 +85,12 @@ public class CountersMultiplyAi extends SpellAbilityAi { } } } - if (ComputerUtil.waitForBlocking(sa)) { - return false; - } - - return true; + return !ComputerUtil.waitForBlocking(sa); } @Override protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { - if (sa.usesTargeting() && !setTargets(ai, sa) && !mandatory) { - return false; - } - return true; + return !sa.usesTargeting() || setTargets(ai, sa) || mandatory; } private CounterType getCounterType(SpellAbility sa) { @@ -135,9 +126,7 @@ public class CountersMultiplyAi extends SpellAbilityAi { if (c.getCounters(counterType) <= 0) { return false; } - if (!c.canReceiveCounters(counterType)) { - return false; - } + return c.canReceiveCounters(counterType); } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java index f108106dce3..52538a0827c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java @@ -83,12 +83,9 @@ public class CountersProliferateAi extends SpellAbilityAi { } })); } - - if (cperms.isEmpty() && hperms.isEmpty() && !opponentPoison && !allyExpOrEnergy) { - return false; - } - return true; + + return !cperms.isEmpty() || !hperms.isEmpty() || opponentPoison || allyExpOrEnergy; } @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index c636ea7b560..30e8e0f8b0f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -469,7 +469,7 @@ public class CountersPutAi extends SpellAbilityAi { int left = amount; for (Card c : list) { if (ComputerUtilCard.shouldPumpCard(ai, sa, c, i, i, - Lists.newArrayList())) { + Lists.newArrayList())) { sa.getTargets().add(c); abTgt.addDividedAllocation(c, i); left -= i; @@ -506,7 +506,7 @@ public class CountersPutAi extends SpellAbilityAi { if (type.equals("P1P1") && !SpellAbilityAi.isSorcerySpeed(sa)) { for (Card c : list) { if (ComputerUtilCard.shouldPumpCard(ai, sa, c, amount, amount, - Lists.newArrayList())) { + Lists.newArrayList())) { choice = c; break; } @@ -592,11 +592,7 @@ public class CountersPutAi extends SpellAbilityAi { } } - if (ComputerUtil.waitForBlocking(sa)) { - return false; - } - - return true; + return !ComputerUtil.waitForBlocking(sa); } @Override @@ -1071,10 +1067,8 @@ public class CountersPutAi extends SpellAbilityAi { } int totBlkPower = Aggregates.sum(combat.getBlockers(source), CardPredicates.Accessors.fnGetNetPower); - if (source.getNetToughness() <= totBlkPower - && source.getNetToughness() + amount > totBlkPower) { - return true; - } + return source.getNetToughness() <= totBlkPower + && source.getNetToughness() + amount > totBlkPower; } } else if (combat.isBlocking(source)) { for (Card blocked : combat.getAttackersBlockedBy(source)) { @@ -1085,10 +1079,8 @@ public class CountersPutAi extends SpellAbilityAi { } int totAtkPower = Aggregates.sum(combat.getAttackersBlockedBy(source), CardPredicates.Accessors.fnGetNetPower); - if (source.getNetToughness() <= totAtkPower - && source.getNetToughness() + amount > totAtkPower) { - return true; - } + return source.getNetToughness() <= totAtkPower + && source.getNetToughness() + amount > totAtkPower; } return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java index 4a2ab325af7..863e3b53c21 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java @@ -101,7 +101,7 @@ public class CountersRemoveAi extends SpellAbilityAi { } // Filter AI-specific targets if provided - list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, false); + list = ComputerUtil.filterAITgts(sa, ai, list, false); boolean noLegendary = game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule); diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageAiBase.java b/forge-ai/src/main/java/forge/ai/ability/DamageAiBase.java index d894b2f7a79..fada6ed260e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageAiBase.java @@ -37,9 +37,7 @@ public abstract class DamageAiBase extends SpellAbilityAi { } if ("SelfDamage".equals(sa.getParam("AILogic"))) { if (comp.getLife() * 0.75 < enemy.getLife()) { - if (!lifelink) { - return true; - } + return !lifelink; } } return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java index cbede1c1a11..addba35d061 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java @@ -233,12 +233,8 @@ public class DamageAllAi extends SpellAbilityAi { return true; } - if (!computerList.isEmpty() && ComputerUtilCard.evaluateCreatureList(computerList) > ComputerUtilCard - .evaluateCreatureList(humanList)) { - return false; - } - - return true; + return computerList.isEmpty() || ComputerUtilCard.evaluateCreatureList(computerList) <= ComputerUtilCard + .evaluateCreatureList(humanList); } /** @@ -320,11 +316,7 @@ public class DamageAllAi extends SpellAbilityAi { return true; } - if (!computerList.isEmpty() && ComputerUtilCard.evaluateCreatureList(computerList) + 50 >= ComputerUtilCard - .evaluateCreatureList(humanList)) { - return false; - } - - return true; + return computerList.isEmpty() || ComputerUtilCard.evaluateCreatureList(computerList) + 50 < ComputerUtilCard + .evaluateCreatureList(humanList); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index f00dffe3205..c683d8a14bf 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -80,10 +80,7 @@ public class DamageDealAi extends DamageAiBase { dmg--; // the card will be spent casting the spell, so actual damage is 1 less } } - if (!this.damageTargetAI(ai, sa, dmg, true)) { - return false; - } - return true; + return this.damageTargetAI(ai, sa, dmg, true); } @Override @@ -490,9 +487,7 @@ public class DamageDealAi extends DamageAiBase { for (final Object o : objects) { if (o instanceof Card) { final Card c = (Card) o; - if (hPlay.contains(c)) { - hPlay.remove(c); - } + hPlay.remove(c); } } hPlay = CardLists.getTargetableCards(hPlay, sa); @@ -850,10 +845,7 @@ public class DamageDealAi extends DamageAiBase { if (!positive && !(saMe instanceof AbilitySub)) { return false; } - if (!urgent && !SpellAbilityAi.playReusable(ai, saMe)) { - return false; - } - return true; + return urgent || SpellAbilityAi.playReusable(ai, saMe); } /** @@ -952,9 +944,7 @@ public class DamageDealAi extends DamageAiBase { final TargetRestrictions tgt = sa.getTargetRestrictions(); if (tgt == null) { // If it's not mandatory check a few things - if (!mandatory && !this.damageChooseNontargeted(ai, sa, dmg)) { - return false; - } + return mandatory || this.damageChooseNontargeted(ai, sa, dmg); } else { if (!this.damageChoosingTargets(ai, sa, tgt, dmg, mandatory, true) && !mandatory) { return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java index ca3fae2f3a8..6f5047d533a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java @@ -124,7 +124,7 @@ public class DebuffAi extends SpellAbilityAi { final TargetRestrictions tgt = sa.getTargetRestrictions(); sa.resetTargets(); - CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.newArrayList() : kws); + CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.newArrayList() : kws); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa); // several uses here: diff --git a/forge-ai/src/main/java/forge/ai/ability/DelayedTriggerAi.java b/forge-ai/src/main/java/forge/ai/ability/DelayedTriggerAi.java index cbe954cd663..c5b17785e61 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DelayedTriggerAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DelayedTriggerAi.java @@ -27,7 +27,7 @@ public class DelayedTriggerAi extends SpellAbilityAi { trigsa.setActivatingPlayer(ai); if (trigsa instanceof AbilitySub) { - return SpellApiToAi.Converter.get(((AbilitySub) trigsa).getApi()).chkDrawbackWithSubs(ai, (AbilitySub)trigsa); + return SpellApiToAi.Converter.get(trigsa.getApi()).chkDrawbackWithSubs(ai, (AbilitySub)trigsa); } else { return AiPlayDecision.WillPlay == ((PlayerControllerAi)ai.getController()).getAi().canPlaySa(trigsa); } diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java index cede308bfc7..b229dd1ca51 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java @@ -48,7 +48,7 @@ public class DestroyAi extends SpellAbilityAi { return false; } - hasXCost = abCost.getCostMana() != null ? abCost.getCostMana().getAmountOfX() > 0 : false; + hasXCost = abCost.getCostMana() != null && abCost.getCostMana().getAmountOfX() > 0; } if ("AtOpponentsCombatOrAfter".equals(sa.getParam("AILogic"))) { @@ -132,7 +132,7 @@ public class DestroyAi extends SpellAbilityAi { } // Filter AI-specific targets if provided - list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, true); + list = ComputerUtil.filterAITgts(sa, ai, list, true); list = CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE); if (CardLists.getNotType(list, "Creature").isEmpty()) { @@ -295,11 +295,9 @@ public class DestroyAi extends SpellAbilityAi { return false; } - if (list.isEmpty() - || !CardLists.filterControlledBy(list, ai).isEmpty() - || CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE).isEmpty()) { - return false; - } + return !list.isEmpty() + && CardLists.filterControlledBy(list, ai).isEmpty() + && !CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE).isEmpty(); } return true; } @@ -342,7 +340,7 @@ public class DestroyAi extends SpellAbilityAi { } // Filter AI-specific targets if provided - preferred = ComputerUtil.filterAITgts(sa, ai, (CardCollection)preferred, true); + preferred = ComputerUtil.filterAITgts(sa, ai, preferred, true); for (final Card c : preferred) { list.remove(c); @@ -400,16 +398,11 @@ public class DestroyAi extends SpellAbilityAi { } } - if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) { - return false; - } + return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa); } else { - if (!mandatory) { - return false; - } + return mandatory; } - return true; } public boolean doLandForLandRemovalLogic(SpellAbility sa, Player ai, Card tgtLand, String logic) { diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index 16d426c7f62..3e36251b077 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -146,10 +146,7 @@ public class DestroyAllAi extends SpellAbilityAi { AiBlockController block = new AiBlockController(ai); block.assignBlockersForCombat(combat); - if (ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) { - return true; - } - return false; + return ComputerUtilCombat.lifeInSeriousDanger(ai, combat); } // only lands involved else if (CardLists.getNotType(opplist, "Land").isEmpty() && CardLists.getNotType(ailist, "Land").isEmpty()) { if (ai.isCardInPlay("Crucible of Worlds") && !opponent.isCardInPlay("Crucible of Worlds") && !opplist.isEmpty()) { @@ -164,14 +161,9 @@ public class DestroyAllAi extends SpellAbilityAi { } } // check if the AI would lose more lands than the opponent would - if (ComputerUtilCard.evaluatePermanentList(ailist) > ComputerUtilCard.evaluatePermanentList(opplist) + 1) { - return false; - } + return ComputerUtilCard.evaluatePermanentList(ailist) <= ComputerUtilCard.evaluatePermanentList(opplist) + 1; } // otherwise evaluate both lists by CMC and pass only if human permanents are more valuable - else if ((ComputerUtilCard.evaluatePermanentList(ailist) + 3) >= ComputerUtilCard.evaluatePermanentList(opplist)) { - return false; - } + else return (ComputerUtilCard.evaluatePermanentList(ailist) + 3) < ComputerUtilCard.evaluatePermanentList(opplist); - return true; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java b/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java index f6745d73c39..fbb96a1dc91 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java @@ -51,12 +51,9 @@ public class DrainManaAi extends SpellAbilityAi { } else { final List defined = AbilityUtils.getDefinedPlayers(source, sa.getParam("Defined"), sa); - if (!defined.contains(opp)) { - return false; - } + return defined.contains(opp); } - return true; } else { sa.resetTargets(); sa.getTargets().add(opp); diff --git a/forge-ai/src/main/java/forge/ai/ability/DrawAi.java b/forge-ai/src/main/java/forge/ai/ability/DrawAi.java index 094ebe558a1..5bd958880c1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DrawAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DrawAi.java @@ -68,10 +68,7 @@ public class DrawAi extends SpellAbilityAi { return false; } - if (!canLoot(ai, sa)) { - return false; - } - return true; + return canLoot(ai, sa); } /* @@ -107,11 +104,7 @@ public class DrawAi extends SpellAbilityAi { } } - if (!ComputerUtilCost.checkRemoveCounterCost(cost, source, sa)) { - return false; - } - - return true; + return ComputerUtilCost.checkRemoveCounterCost(cost, source, sa); } /* @@ -202,9 +195,7 @@ public class DrawAi extends SpellAbilityAi { if (numHand == 0 && numDraw == numDiscard) { return false; // no looting since everything is dumped } - if (numHand + numDraw < numDiscard) { - return false; // net loss of cards - } + return numHand + numDraw >= numDiscard; // net loss of cards } return true; } @@ -486,11 +477,8 @@ public class DrawAi extends SpellAbilityAi { // ability is not targeted if (numCards >= computerLibrarySize) { - if (ai.isCardInPlay("Laboratory Maniac")) { - return true; - } + return ai.isCardInPlay("Laboratory Maniac"); // Don't deck yourself - return false; } if (numCards == 0 && !drawback) { @@ -503,9 +491,7 @@ public class DrawAi extends SpellAbilityAi { && !assumeSafeX) { // Don't draw too many cards and then risk discarding cards at // EOT - if (!drawback) { - return false; - } + return drawback; } } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index 4b83190cc6f..92e8422c41c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -283,11 +283,7 @@ public class EffectAi extends SpellAbilityAi { return false; } final SpellAbility topStack = game.getStack().peekAbility(); - if (topStack.getActivatingPlayer().isOpponentOf(ai) && topStack.getApi() == ApiType.GainLife) { - return true; - } else { - return false; - } + return topStack.getActivatingPlayer().isOpponentOf(ai) && topStack.getApi() == ApiType.GainLife; } else if (logic.equals("Fight")) { return FightAi.canFightAi(ai, sa, 0, 0); } else if (logic.equals("Burn")) { @@ -301,11 +297,9 @@ public class EffectAi extends SpellAbilityAi { return false; } if (logic.contains(":")) { - String k[] = logic.split(":"); + String[] k = logic.split(":"); Integer i = Integer.valueOf(k[1]); - if (ai.getCreaturesInPlay().size() < i) { - return false; - } + return ai.getCreaturesInPlay().size() >= i; } return true; } else if (logic.equals("CastFromGraveThisTurn")) { diff --git a/forge-ai/src/main/java/forge/ai/ability/FightAi.java b/forge-ai/src/main/java/forge/ai/ability/FightAi.java index 8486fb0ab46..94549a872b8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/FightAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/FightAi.java @@ -273,9 +273,8 @@ public class FightAi extends SpellAbilityAi { if (!canKill(opponent, fighter, -pumpDefense)) { // can survive return true; } else { - if (MyRandom.getRandom().nextInt(20)<(opponent.getCMC() - fighter.getCMC())) { // trade - return true; - } + // trade + return MyRandom.getRandom().nextInt(20) < (opponent.getCMC() - fighter.getCMC()); } } return false; @@ -289,10 +288,7 @@ public class FightAi extends SpellAbilityAi { || ComputerUtil.canRegenerate(opponent.getController(), opponent)) { return false; } - if (fighter.hasKeyword(Keyword.DEATHTOUCH) - || ComputerUtilCombat.getDamageToKill(opponent) <= fighter.getNetPower() + pumpAttack) { - return true; - } - return false; + return fighter.hasKeyword(Keyword.DEATHTOUCH) + || ComputerUtilCombat.getDamageToKill(opponent) <= fighter.getNetPower() + pumpAttack; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java b/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java index 4792fbf0c05..2afefc36f03 100644 --- a/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java @@ -20,9 +20,7 @@ public class FlipACoinAi extends SpellAbilityAi { if (AILogic.equals("Never")) { return false; } else if (AILogic.equals("PhaseOut")) { - if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(sa.getHostCard())) { - return false; - } + return ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(sa.getHostCard()); } else if (AILogic.equals("KillOrcs")) { if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN) ) { return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/GameWinAi.java b/forge-ai/src/main/java/forge/ai/ability/GameWinAi.java index f5dd9e62318..9586916f190 100644 --- a/forge-ai/src/main/java/forge/ai/ability/GameWinAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/GameWinAi.java @@ -11,9 +11,7 @@ public class GameWinAi extends SpellAbilityAi { */ @Override protected boolean canPlayAI(Player ai, SpellAbility sa) { - if (ai.cantWin()) { - return false; - } + return !ai.cantWin(); // TODO Check conditions are met on card (e.g. Coalition Victory) @@ -21,7 +19,6 @@ public class GameWinAi extends SpellAbilityAi { // In general, don't return true. // But this card wins the game, I can make an exception for that - return true; } @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java index e1432844d01..a01bcf4ce67 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java @@ -120,9 +120,7 @@ public class LifeExchangeVariantAi extends SpellAbilityAi { MagicStack stack = game.getStack(); if (!stack.isEmpty()) { SpellAbility saTop = stack.peekAbility(); - if (ComputerUtil.predictDamageFromSpell(saTop, ai) >= aiLife) { - return true; - } + return ComputerUtil.predictDamageFromSpell(saTop, ai) >= aiLife; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java index 353d84b606e..981c5f10d7b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java @@ -49,9 +49,7 @@ public class LifeGainAi extends SpellAbilityAi { return false; } - if (!ComputerUtilCost.checkRemoveCounterCost(cost, source)) { - return false; - } + return ComputerUtilCost.checkRemoveCounterCost(cost, source); } else { // don't sac possible blockers if (!ph.getPhase().equals(PhaseType.COMBAT_DECLARE_BLOCKERS) @@ -63,9 +61,7 @@ public class LifeGainAi extends SpellAbilityAi { skipCheck |= ComputerUtilCost.isSacrificeSelfCost(cost) && !source.isCreature(); if (!skipCheck) { - if (!ComputerUtilCost.checkSacrificeCost(ai, cost, source, sa,false)) { - return false; - } + return ComputerUtilCost.checkSacrificeCost(ai, cost, source, sa, false); } } } @@ -106,13 +102,9 @@ public class LifeGainAi extends SpellAbilityAi { return false; } - if (!lifeCritical && !activateForCost - && (!ph.getNextTurn().equals(ai) || ph.getPhase().isBefore(PhaseType.END_OF_TURN)) - && !sa.hasParam("PlayerTurn") && !SpellAbilityAi.isSorcerySpeed(sa)) { - return false; - } - - return true; + return lifeCritical || activateForCost + || (ph.getNextTurn().equals(ai) && !ph.getPhase().isBefore(PhaseType.END_OF_TURN)) + || sa.hasParam("PlayerTurn") || SpellAbilityAi.isSorcerySpeed(sa); } /* @@ -304,9 +296,7 @@ public class LifeGainAi extends SpellAbilityAi { hasTgt = true; } } - if (!hasTgt) { - return false; - } + return hasTgt; } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java index 96fc5d4f195..a4a6a80981f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java @@ -53,9 +53,7 @@ public class LifeLoseAi extends SpellAbilityAi { } if (sa.usesTargeting()) { - if (!doTgt(ai, sa, false)) { - return false; - } + return doTgt(ai, sa, false); } return true; @@ -148,12 +146,8 @@ public class LifeLoseAi extends SpellAbilityAi { return false; } - if (SpellAbilityAi.isSorcerySpeed(sa) || sa.hasParam("ActivationPhases") || SpellAbilityAi.playReusable(ai, sa) - || ComputerUtil.activateForCost(sa, ai)) { - return true; - } - - return false; + return SpellAbilityAi.isSorcerySpeed(sa) || sa.hasParam("ActivationPhases") || SpellAbilityAi.playReusable(ai, sa) + || ComputerUtil.activateForCost(sa, ai); } /* @@ -187,12 +181,8 @@ public class LifeLoseAi extends SpellAbilityAi { ? new FCollection(sa.getTargets().getTargetPlayers()) : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa); - if (!mandatory && tgtPlayers.contains(ai) && amount > 0 && amount + 3 > ai.getLife()) { - // For cards like Foul Imp, ETB you lose life - return false; - } - - return true; + // For cards like Foul Imp, ETB you lose life + return mandatory || !tgtPlayers.contains(ai) || amount <= 0 || amount + 3 <= ai.getLife(); } protected boolean doTgt(Player ai, SpellAbility sa, boolean mandatory) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ManaEffectAi.java b/forge-ai/src/main/java/forge/ai/ability/ManaEffectAi.java index 868f69fd185..60eaeef180f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManaEffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManaEffectAi.java @@ -80,12 +80,9 @@ public class ManaEffectAi extends SpellAbilityAi { if (sa.hasParam("AILogic")) { return true; // handled elsewhere, does not meet the standard requirements } - - if (!(sa.getPayCosts() != null && sa.getPayCosts().hasNoManaCost() && sa.getPayCosts().isReusuableResource() - && sa.getSubAbility() == null && ComputerUtil.playImmediately(ai, sa))) { - return false; - } - return true; + + return sa.getPayCosts() != null && sa.getPayCosts().hasNoManaCost() && sa.getPayCosts().isReusuableResource() + && sa.getSubAbility() == null && ComputerUtil.playImmediately(ai, sa); // return super.checkApiLogic(ai, sa); } diff --git a/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java b/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java index 7adea756b2e..947db225886 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java @@ -80,9 +80,7 @@ public class ManifestAi extends SpellAbilityAi { // Set PayX here to maximum value. int x = ComputerUtilMana.determineLeftoverMana(sa, ai); source.setSVar("PayX", Integer.toString(x)); - if (x <= 0) { - return false; - } + return x > 0; } return true; @@ -121,9 +119,7 @@ public class ManifestAi extends SpellAbilityAi { return false; // card has ETBTrigger or ETBReplacement - if (card.hasETBTrigger(false) || card.hasETBReplacement()) { - return false; - } + return !card.hasETBTrigger(false) && !card.hasETBReplacement(); } return true; } @@ -185,10 +181,7 @@ public class ManifestAi extends SpellAbilityAi { CardCollection filtered = CardLists.filter(options, new Predicate() { @Override public boolean apply(Card input) { - if (shouldManyfest(input, ai, sa)) { - return false; - } - return true; + return !shouldManyfest(input, ai, sa); } }); if (!filtered.isEmpty()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/MillAi.java b/forge-ai/src/main/java/forge/ai/ability/MillAi.java index c975d894c29..3656226ee06 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MillAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MillAi.java @@ -31,19 +31,13 @@ public class MillAi extends SpellAbilityAi { PhaseHandler ph = ai.getGame().getPhaseHandler(); if (aiLogic.equals("Main1")) { - if (ph.getPhase().isBefore(PhaseType.MAIN2) && !sa.hasParam("ActivationPhases") - && !ComputerUtil.castSpellInMain1(ai, sa)) { - return false; - } + return !ph.getPhase().isBefore(PhaseType.MAIN2) || sa.hasParam("ActivationPhases") + || ComputerUtil.castSpellInMain1(ai, sa); } else if (aiLogic.equals("EndOfOppTurn")) { - if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai))) { - return false; - } + return ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai); } else if (aiLogic.equals("LilianaMill")) { // Only mill if a "Raise Dead" target is available, in case of control decks with few creatures - if (CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES).size() < 1) { - return false; - } + return CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES).size() >= 1; } return true; } @@ -62,11 +56,9 @@ public class MillAi extends SpellAbilityAi { } } if (sa.getHostCard().isCreature() && sa.getPayCosts().hasTapCost()) { - if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai))) { - // creatures with a tap cost to mill (e.g. Doorkeeper) should be activated at the opponent's end step - // because they are also potentially useful for combat - return false; - } + // creatures with a tap cost to mill (e.g. Doorkeeper) should be activated at the opponent's end step + // because they are also potentially useful for combat + return ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai); } return true; } @@ -100,9 +92,7 @@ public class MillAi extends SpellAbilityAi { // Set PayX here to maximum value. final int cardsToDiscard = getNumToDiscard(ai, sa); source.setSVar("PayX", Integer.toString(cardsToDiscard)); - if (cardsToDiscard <= 0) { - return false; - } + return cardsToDiscard > 0; } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java b/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java index 7a7c0bdb732..008172bebcc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java @@ -24,9 +24,7 @@ public class PeekAndRevealAi extends SpellAbilityAi { return false; } if ("Main2".equals(sa.getParam("AILogic"))) { - if (aiPlayer.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) { - return false; - } + return !aiPlayer.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2); } // So far this only appears on Triggers, but will expand // once things get converted from Dig + NoMove diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index 14a3f8160c5..62012507864 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -38,10 +38,7 @@ public class PermanentAi extends SpellAbilityAi { } // Wait for Main2 if possible - if (ph.is(PhaseType.MAIN1) && ph.isPlayerTurn(ai) && !ComputerUtil.castPermanentInMain1(ai, sa) && !sa.hasParam("WithoutManaCost")) { - return false; - } - return true; + return !ph.is(PhaseType.MAIN1) || !ph.isPlayerTurn(ai) || ComputerUtil.castPermanentInMain1(ai, sa) || sa.hasParam("WithoutManaCost"); } /** @@ -259,9 +256,7 @@ public class PermanentAi extends SpellAbilityAi { } } - if (dontCast) { - return false; - } + return !dontCast; } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java index 1fa1a224098..fff79b466d4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java @@ -40,9 +40,7 @@ public class PermanentCreatureAi extends PermanentAi { ComputerUtilCard.applyStaticContPT(game, copy, null); - if (copy.getNetToughness() <= 0) { - return false; - } + return copy.getNetToughness() > 0; } return true; } @@ -225,13 +223,9 @@ public class PermanentCreatureAi extends PermanentAi { */ final Card copy = CardUtil.getLKICopy(sa.getHostCard()); ComputerUtilCard.applyStaticContPT(game, copy, null); - if (copy.getNetToughness() <= 0 && !copy.hasStartOfKeyword("etbCounter") && mana.countX() == 0 - && !copy.hasETBTrigger(false) && !copy.hasETBReplacement() && !copy.hasSVar("NoZeroToughnessAI")) { - // AiPlayDecision.WouldBecomeZeroToughnessCreature - return false; - } - - return true; + // AiPlayDecision.WouldBecomeZeroToughnessCreature + return copy.getNetToughness() > 0 || copy.hasStartOfKeyword("etbCounter") || mana.countX() != 0 + || copy.hasETBTrigger(false) || copy.hasETBReplacement() || copy.hasSVar("NoZeroToughnessAI"); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentNoncreatureAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentNoncreatureAi.java index a4569fb1c2e..bd7db42f43f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentNoncreatureAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentNoncreatureAi.java @@ -19,10 +19,7 @@ public class PermanentNoncreatureAi extends PermanentAi { @Override protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) { - if ("Never".equals(aiLogic) || "DontCast".equals(aiLogic)) { - return false; - } - return true; + return !"Never".equals(aiLogic) && !"DontCast".equals(aiLogic); } /** @@ -54,10 +51,8 @@ public class PermanentNoncreatureAi extends PermanentAi { // TODO: consider replacing the condition with host.hasSVar("OblivionRing") targets = CardLists.filterControlledBy(targets, ai.getOpponents()); } - if (targets.isEmpty()) { - // AiPlayDecision.AnotherTime - return false; - } + // AiPlayDecision.AnotherTime + return !targets.isEmpty(); } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java b/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java index dffcc09e823..ca9dcd4e57c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java @@ -33,9 +33,7 @@ public class PhasesAi extends SpellAbilityAi { if (tgtCards.contains(source)) { // Protect it from something final boolean isThreatened = ComputerUtil.predictThreatenedObjects(aiPlayer, null, true).contains(source); - if (isThreatened) { - return true; - } + return isThreatened; } else { // Card def = tgtCards.get(0); // Phase this out if it might attack me, or before it can be diff --git a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java index f023a718fb1..96c22f1d519 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java @@ -178,11 +178,7 @@ public class PlayAi extends SpellAbilityAi { // Before accepting, see if the spell has a valid number of targets (it should at this point). // Proceeding past this point if the spell is not correctly targeted will result // in "Failed to add to stack" error and the card disappearing from the game completely. - if (!spell.isTargetNumberValid()) { - return false; - } - - return true; + return spell.isTargetNumberValid(); } } return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java b/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java index a66326ac4e2..5161d672432 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java @@ -24,11 +24,8 @@ public class PoisonAi extends SpellAbilityAi { */ @Override protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, final PhaseHandler ph) { - if (ph.getPhase().isBefore(PhaseType.MAIN2) - && !sa.hasParam("ActivationPhases")) { - return false; - } - return true; + return !ph.getPhase().isBefore(PhaseType.MAIN2) + || sa.hasParam("ActivationPhases"); } /* @@ -78,13 +75,10 @@ public class PoisonAi extends SpellAbilityAi { } Player max = players.max(PlayerPredicates.compareByPoison()); - if (ai.getPoisonCounters() == max.getPoisonCounters()) { - // ai is one of the max - return false; - } + // ai is one of the max + return ai.getPoisonCounters() != max.getPoisonCounters(); } - return true; } private boolean tgtPlayer(Player ai, SpellAbility sa, boolean mandatory) { @@ -96,11 +90,8 @@ public class PoisonAi extends SpellAbilityAi { public boolean apply(Player input) { if (input.cantLose()) { return false; - } else if (!input.canReceiveCounters(CounterType.POISON)) { - return false; - } + } else return input.canReceiveCounters(CounterType.POISON); - return true; } }); @@ -132,10 +123,7 @@ public class PoisonAi extends SpellAbilityAi { if (input.cantLose()) { return true; } - if (!input.canReceiveCounters(CounterType.POISON)) { - return true; - } - return false; + return !input.canReceiveCounters(CounterType.POISON); } }); diff --git a/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java b/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java index 513b8689a0c..13ed8ff2e51 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java @@ -162,11 +162,8 @@ public class ProtectAi extends SpellAbilityAi { @Override protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, final PhaseHandler ph) { final boolean notAiMain1 = !(ph.getPlayerTurn() == ai && ph.getPhase() == PhaseType.MAIN1); - if (SpellAbilityAi.isSorcerySpeed(sa) && notAiMain1) { - // sorceries can only give protection in order to create an unblockable attacker - return false; - } - return true; + // sorceries can only give protection in order to create an unblockable attacker + return !SpellAbilityAi.isSorcerySpeed(sa) || !notAiMain1; } @Override @@ -177,9 +174,7 @@ public class ProtectAi extends SpellAbilityAi { return false; } else if (cards.size() == 1) { // Affecting single card - if ((getProtectCreatures(ai, sa)).contains(cards.get(0))) { - return true; - } + return (getProtectCreatures(ai, sa)).contains(cards.get(0)); } /* * when this happens we need to expand AI to consider if its ok diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index 3ab163edddc..d29e5c39c0d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -92,10 +92,7 @@ public class PumpAi extends PumpAiBase { return true; } - if (!ph.getNextTurn().equals(ai) || ph.getPhase().isBefore(PhaseType.END_OF_TURN)) { - return false; - } - return true; + return ph.getNextTurn().equals(ai) && !ph.getPhase().isBefore(PhaseType.END_OF_TURN); } else if (logic.equals("Aristocrat")) { final boolean isThreatened = ComputerUtil.predictThreatenedObjects(ai, null, true).contains(sa.getHostCard()); if (!ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS) && !isThreatened) { @@ -121,9 +118,7 @@ public class PumpAi extends PumpAiBase { || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS))) { // Instant-speed pumps should not be cast outside of combat when the // stack is empty - if (!sa.isCurse() && !SpellAbilityAi.isSorcerySpeed(sa) && !main1Preferred) { - return false; - } + return sa.isCurse() || SpellAbilityAi.isSorcerySpeed(sa) || main1Preferred; } return true; } @@ -134,7 +129,7 @@ public class PumpAi extends PumpAiBase { final Card source = sa.getHostCard(); final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa); final List keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) - : Lists.newArrayList(); + : Lists.newArrayList(); final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : ""; final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : ""; @@ -191,11 +186,8 @@ public class PumpAi extends PumpAiBase { srcCardCpy.setCounters(cType, srcCardCpy.getCounters(cType) - amount); if (CounterType.P1P1.equals(cType) && srcCardCpy.getNetToughness() <= 0) { - if (srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) - || card.isToken()) { - return true; - } - return false; + return srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) + || card.isToken(); } return false; } @@ -244,11 +236,8 @@ public class PumpAi extends PumpAiBase { srcCardCpy.setCounters(cType, srcCardCpy.getCounters(cType) - amount); if (CounterType.P1P1.equals(cType) && srcCardCpy.getNetToughness() <= 0) { - if (srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) - || card.isToken()) { - return true; - } - return false; + return srcCardCpy.getCounters(cType) > 0 || !card.hasKeyword(Keyword.UNDYING) + || card.isToken(); } return true; } @@ -395,9 +384,7 @@ public class PumpAi extends PumpAiBase { Card pumped = ComputerUtilCard.getPumpedCreature(ai, sa, card, 0, 0, keywords); if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS, ai) || game.getPhaseHandler().is(PhaseType.COMBAT_BEGIN, ai)) { - if (!ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, pumped)) { - return false; - } + return ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, pumped); } return true; @@ -432,7 +419,7 @@ public class PumpAi extends PumpAiBase { private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defense, final int attack, final boolean mandatory, boolean immediately) { final List keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) - : Lists.newArrayList(); + : Lists.newArrayList(); final Game game = ai.getGame(); final Card source = sa.getHostCard(); final boolean isFight = "Fight".equals(sa.getParam("AILogic")) || "PowerDmg".equals(sa.getParam("AILogic")); @@ -555,7 +542,7 @@ public class PumpAi extends PumpAiBase { } // Filter AI-specific targets if provided - list = ComputerUtil.filterAITgts(sa, ai, (CardCollection)list, true); + list = ComputerUtil.filterAITgts(sa, ai, list, true); if (list.isEmpty()) { if (ComputerUtil.activateForCost(sa, ai)) { @@ -788,15 +775,11 @@ public class PumpAi extends PumpAiBase { if (!source.hasKeyword(Keyword.INDESTRUCTIBLE) && source.getNetToughness() + defense <= source.getDamage()) { return false; } - if (source.getNetToughness() + defense <= 0) { - return false; - } + return source.getNetToughness() + defense > 0; } } else { //Targeted - if (!pumpTgtAI(ai, sa, defense, attack, false, true)) { - return false; - } + return pumpTgtAI(ai, sa, defense, attack, false, true); } return true; @@ -849,9 +832,7 @@ public class PumpAi extends PumpAiBase { } } ); - if (sacFodder.size() >= numCreatsToSac) { - return true; - } + return sacFodder.size() >= numCreatsToSac; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index 3ccc5b81605..3f178539be2 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -56,24 +56,17 @@ public abstract class PumpAiBase extends SpellAbilityAi { if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) { return false; } else if (keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack.")) { - if (!ph.isPlayerTurn(card.getController()) || !CombatUtil.canAttack(card, ai) - || (card.getNetCombatDamage() <= 0) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { - return false; - } + return ph.isPlayerTurn(card.getController()) && CombatUtil.canAttack(card, ai) + && (card.getNetCombatDamage() > 0) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS); } else if (keyword.endsWith("CARDNAME can't attack or block.")) { if (sa.hasParam("UntilYourNextTurn")) { - if (CombatUtil.canAttack(card, ai) || CombatUtil.canBlock(card, true)) { - return true; - } - return false; + return CombatUtil.canAttack(card, ai) || CombatUtil.canBlock(card, true); } if (!ph.isPlayerTurn(ai)) { - if (!CombatUtil.canAttack(card, ai) - || (card.getNetCombatDamage() <= 0) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { - return false; - } + return CombatUtil.canAttack(card, ai) + && (card.getNetCombatDamage() > 0) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS); } else { if (ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) || ph.getPhase().isBefore(PhaseType.MAIN1)) { @@ -90,9 +83,7 @@ public abstract class PumpAiBase extends SpellAbilityAi { return CombatUtil.canAttack(c, card.getController()) || (combat != null && combat.isAttacking(c)); } }); - if (!CombatUtil.canBlockAtLeastOne(card, attackers)) { - return false; - } + return CombatUtil.canBlockAtLeastOne(card, attackers); } } else if (keyword.endsWith("CARDNAME can't block.")) { if (!ph.isPlayerTurn(ai) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) @@ -112,24 +103,18 @@ public abstract class PumpAiBase extends SpellAbilityAi { && card.getController().equals(combat.getDefenderPlayerByAttacker(c))); } }); - if (!CombatUtil.canBlockAtLeastOne(card, attackers)) { - return false; - } + return CombatUtil.canBlockAtLeastOne(card, attackers); } else if (keyword.endsWith("CantBlockCardUIDSource")) { // can't block CARDNAME this turn if (!ph.isPlayerTurn(ai) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) || ph.getPhase().isBefore(PhaseType.MAIN1) || !CombatUtil.canBlock(sa.getHostCard(), card)) { return false; } // target needs to be a creature, controlled by the player which is attacked - if (sa.getHostCard().isTapped() && (combat == null || !combat.isAttacking(sa.getHostCard()) - || !card.getController().equals(combat.getDefenderPlayerByAttacker(sa.getHostCard())))) { - return false; - } + return !sa.getHostCard().isTapped() || (combat != null && combat.isAttacking(sa.getHostCard()) + && card.getController().equals(combat.getDefenderPlayerByAttacker(sa.getHostCard()))); } else if (keyword.endsWith("This card doesn't untap during your next untap step.")) { - if (ph.getPhase().isBefore(PhaseType.MAIN2) || card.isUntapped() || !ph.isPlayerTurn(ai) - || !Untap.canUntap(card)) { - return false; - } + return !ph.getPhase().isBefore(PhaseType.MAIN2) && !card.isUntapped() && ph.isPlayerTurn(ai) + && Untap.canUntap(card); } else if (keyword.endsWith("Prevent all combat damage that would be dealt by CARDNAME.") || keyword.endsWith("Prevent all damage that would be dealt by CARDNAME.")) { if (ph.isPlayerTurn(ai) && (!(CombatUtil.canBlock(card) || combat != null && combat.isBlocking(card)) @@ -139,28 +124,18 @@ public abstract class PumpAiBase extends SpellAbilityAi { || CardLists.getNotKeyword(ai.getCreaturesInPlay(), Keyword.DEFENDER).isEmpty())) { return false; } - if (!ph.isPlayerTurn(ai) && (combat == null || !combat.isAttacking(card) || card.getNetCombatDamage() <= 0)) { - return false; - } + return ph.isPlayerTurn(ai) || (combat != null && combat.isAttacking(card) && card.getNetCombatDamage() > 0); } else if (keyword.endsWith("CARDNAME attacks each turn if able.") || keyword.endsWith("CARDNAME attacks each combat if able.")) { - if (ph.isPlayerTurn(ai) || !CombatUtil.canAttack(card, ai) || !CombatUtil.canBeBlocked(card, ai) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { - return false; - } + return !ph.isPlayerTurn(ai) && CombatUtil.canAttack(card, ai) && CombatUtil.canBeBlocked(card, ai) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS); } else if (keyword.endsWith("CARDNAME can't be regenerated.")) { if (card.getShieldCount() > 0) { return true; } - if (card.hasKeyword("If CARDNAME would be destroyed, regenerate it.") && combat != null - && (combat.isBlocked(card) || combat.isBlocking(card))) { - return true; - } - return false; - } else if (keyword.endsWith("CARDNAME's activated abilities can't be activated.")) { - return false; //too complex - } - return true; + return card.hasKeyword("If CARDNAME would be destroyed, regenerate it.") && combat != null + && (combat.isBlocked(card) || combat.isBlocking(card)); + } else return !keyword.endsWith("CARDNAME's activated abilities can't be activated."); //too complex } /** @@ -187,12 +162,10 @@ public abstract class PumpAiBase extends SpellAbilityAi { final boolean evasive = (keyword.endsWith("Unblockable") || keyword.endsWith("Shadow") || keyword.startsWith("CantBeBlockedBy")); // give evasive keywords to creatures that can or do attack if (evasive) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.endsWith("Flying")) { CardCollectionView attackingFlyer = CardCollection.EMPTY; if (combat != null) { @@ -221,13 +194,11 @@ public abstract class PumpAiBase extends SpellAbilityAi { } } } - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || !Iterables.any(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), - Predicates.not(flyingOrReach))) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && Iterables.any(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), + Predicates.not(flyingOrReach)); } else if (keyword.endsWith("Horsemanship")) { if (ph.isPlayerTurn(opp) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS) @@ -236,46 +207,35 @@ public abstract class PumpAiBase extends SpellAbilityAi { && ComputerUtilCombat.lifeInDanger(ai, game.getCombat())) { return true; } - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), - Keyword.HORSEMANSHIP).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), + Keyword.HORSEMANSHIP).isEmpty(); } else if (keyword.endsWith("Intimidate")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getNotType(CardLists.filter( - opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact").isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getNotType(CardLists.filter( + opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact").isEmpty(); } else if (keyword.endsWith("Fear")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getNotColor(CardLists.getNotType(CardLists.filter( - opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact"), MagicColor.BLACK).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getNotColor(CardLists.getNotType(CardLists.filter( + opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact"), MagicColor.BLACK).isEmpty(); } else if (keyword.endsWith("Haste")) { - if (!card.hasSickness() || ph.isPlayerTurn(opp) || card.isTapped() - || newPower <= 0 - || card.hasKeyword("CARDNAME can attack as though it had haste.") - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || !ComputerUtilCombat.canAttackNextTurn(card)) { - return false; - } + return card.hasSickness() && !ph.isPlayerTurn(opp) && !card.isTapped() + && newPower > 0 + && !card.hasKeyword("CARDNAME can attack as though it had haste.") + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && ComputerUtilCombat.canAttackNextTurn(card); } else if (keyword.endsWith("Indestructible")) { // Predicting threatened objects in relevant non-combat situations happens elsewhere, // so we are only worrying about combat relevance of Indestructible at this point. - if (combat == null - || !((combat.isBlocked(card) || combat.isBlocking(card)) - && ComputerUtilCombat.combatantWouldBeDestroyed(ai, card, combat))) { - return false; - } - return true; + return combat != null + && ((combat.isBlocked(card) || combat.isBlocking(card)) + && ComputerUtilCombat.combatantWouldBeDestroyed(ai, card, combat)); } else if (keyword.endsWith("Deathtouch")) { if (ph.isPlayerTurn(opp) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) { List attackers = combat.getAttackers(); @@ -297,12 +257,10 @@ public abstract class PumpAiBase extends SpellAbilityAi { } return false; } else if (keyword.equals("Bushido")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) - || opp.getCreaturesInPlay().isEmpty() - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) + && !opp.getCreaturesInPlay().isEmpty() + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.equals("First Strike")) { if (card.hasKeyword(Keyword.DOUBLE_STRIKE)) { return false; @@ -321,40 +279,31 @@ public abstract class PumpAiBase extends SpellAbilityAi { if (!ComputerUtilCombat.canDestroyAttacker(ai, attacker, card, combat, true) && ComputerUtilCombat.canDestroyAttacker(ai, attacker, card, combat, false)) return true; - if (ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, true) - && !ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, false)) - return true; + return ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, true) + && !ComputerUtilCombat.canDestroyBlocker(ai, card, attacker, combat, false); } return false; } else if (keyword.equals("Double Strike")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || newPower <= 0 - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && newPower > 0 + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS); } else if (keyword.startsWith("Rampage")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || newPower <= 0 - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).size() < 2) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && newPower > 0 + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).size() >= 2; } else if (keyword.startsWith("Flanking")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || newPower <= 0 - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), - Keyword.FLANKING).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && newPower > 0 + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && !CardLists.getNotKeyword(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), + Keyword.FLANKING).isEmpty(); } else if (keyword.startsWith("Trample")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || !CombatUtil.canBeBlocked(card, opp) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 1 - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && CombatUtil.canBeBlocked(card, opp) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 1 + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.equals("Infect")) { if (newPower <= 0) { return false; @@ -362,11 +311,9 @@ public abstract class PumpAiBase extends SpellAbilityAi { if (combat != null && combat.isBlocking(card) && !card.hasKeyword(Keyword.WITHER)) { return true; } - if ((ph.isPlayerTurn(opp)) - || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)) { - return false; - } + return (!ph.isPlayerTurn(opp)) + && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS); } else if (keyword.endsWith("Wither")) { if (newPower <= 0 || card.hasKeyword(Keyword.INFECT)) { return false; @@ -378,20 +325,16 @@ public abstract class PumpAiBase extends SpellAbilityAi { } return combat != null && ( combat.isAttacking(card) || combat.isBlocking(card) ); } else if (keyword.equals("Vigilance")) { - if (ph.isPlayerTurn(opp) || !CombatUtil.canAttack(card, opp) - || newPower <= 0 - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || CardLists.getNotKeyword(opp.getCreaturesInPlay(), Keyword.DEFENDER).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && CombatUtil.canAttack(card, opp) + && newPower > 0 + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && !CardLists.getNotKeyword(opp.getCreaturesInPlay(), Keyword.DEFENDER).isEmpty(); } else if (keyword.equals("Reach")) { - if (ph.isPlayerTurn(ai) - || !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS) - || CardLists.getKeyword(game.getCombat().getAttackers(), Keyword.FLYING).isEmpty() - || card.hasKeyword(Keyword.FLYING) - || !CombatUtil.canBlock(card)) { - return false; - } + return !ph.isPlayerTurn(ai) + && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS) + && !CardLists.getKeyword(game.getCombat().getAttackers(), Keyword.FLYING).isEmpty() + && !card.hasKeyword(Keyword.FLYING) + && CombatUtil.canBlock(card); } else if (keyword.endsWith("CARDNAME can block an additional creature each combat.")) { if (ph.isPlayerTurn(ai) || !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) { @@ -407,63 +350,43 @@ public abstract class PumpAiBase extends SpellAbilityAi { } } } - if (possibleBlockNum <= canBlockNum) { - return false; - } + return possibleBlockNum > canBlockNum; } else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) { - if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card)) { - return false; - } + return ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card); } else if (keyword.equals("Persist")) { - if (card.getBaseToughness() <= 1 || card.hasKeyword(Keyword.UNDYING)) { - return false; - } + return card.getBaseToughness() > 1 && !card.hasKeyword(Keyword.UNDYING); } else if (keyword.equals("Islandwalk")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getType(opp.getLandsInPlay(), "Island").isEmpty() - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getType(opp.getLandsInPlay(), "Island").isEmpty() + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.equals("Swampwalk")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getType(opp.getLandsInPlay(), "Swamp").isEmpty() - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getType(opp.getLandsInPlay(), "Swamp").isEmpty() + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.equals("Mountainwalk")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getType(opp.getLandsInPlay(), "Mountain").isEmpty() - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getType(opp.getLandsInPlay(), "Mountain").isEmpty() + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.equals("Forestwalk")) { - if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) - || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) - || newPower <= 0 - || CardLists.getType(opp.getLandsInPlay(), "Forest").isEmpty() - || CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty()) { - return false; - } + return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card))) + && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) + && newPower > 0 + && !CardLists.getType(opp.getLandsInPlay(), "Forest").isEmpty() + && !CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)).isEmpty(); } else if (keyword.endsWith("CARDNAME can attack as though it didn't have defender.")) { - if (!ph.isPlayerTurn(ai) || !card.hasKeyword(Keyword.DEFENDER) - || ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) - || card.isTapped() || newPower <= 0) { - return false; - } + return ph.isPlayerTurn(ai) && card.hasKeyword(Keyword.DEFENDER) + && !ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) + && !card.isTapped() && newPower > 0; } else if (keyword.equals("Prevent all combat damage that would be dealt to CARDNAME.")) { - if (combat == null || !(combat.isBlocking(card) || combat.isBlocked(card))) { - return false; - } + return combat != null && (combat.isBlocking(card) || combat.isBlocked(card)); } else if (keyword.equals("Menace")) { - if (combat == null || !combat.isAttacking(card)) { - return false; - } + return combat != null && combat.isAttacking(card); } return true; } @@ -547,10 +470,7 @@ public abstract class PumpAiBase extends SpellAbilityAi { return true; } //Don't waste a -7/-0 spell on a 1/1 creature - if (c.getNetPower() + attack > -2 || c.getNetPower() > 3) { - return true; - } - return false; + return c.getNetPower() + attack > -2 || c.getNetPower() > 3; } }); } else { diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java index 7f03f31ddf4..9f1a6c7b159 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java @@ -141,10 +141,7 @@ public class PumpAllAi extends PumpAiBase { // evaluate both lists and pass only if human creatures are more // valuable - if ((ComputerUtilCard.evaluateCreatureList(comp) + 200) >= ComputerUtilCard.evaluateCreatureList(human)) { - return false; - } - return true; + return (ComputerUtilCard.evaluateCreatureList(comp) + 200) < ComputerUtilCard.evaluateCreatureList(human); } // end Curse return !CardLists.getValidCards(getPumpCreatures(ai, sa, defense, power, keywords, false), valid, source.getController(), source).isEmpty(); diff --git a/forge-ai/src/main/java/forge/ai/ability/RemoveFromCombatAi.java b/forge-ai/src/main/java/forge/ai/ability/RemoveFromCombatAi.java index 6c498f1e764..5d1abd1e177 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RemoveFromCombatAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RemoveFromCombatAi.java @@ -18,9 +18,7 @@ public class RemoveFromCombatAi extends SpellAbilityAi { // AI should only activate this during Human's turn if ("RemoveBestAttacker".equals(sa.getParam("AILogic"))) { - if (aiPlayer.getGame().getCombat() != null && aiPlayer.getGame().getCombat().getDefenders().contains(aiPlayer)) { - return true; - } + return aiPlayer.getGame().getCombat() != null && aiPlayer.getGame().getCombat().getDefenders().contains(aiPlayer); } // TODO - implement AI diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java index 08059c5cace..7a37733b284 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java @@ -32,9 +32,7 @@ public class RepeatAi extends SpellAbilityAi { // Set PayX here to maximum value. final int max = ComputerUtilMana.determineLeftoverMana(sa, ai); source.setSVar("PayX", Integer.toString(max)); - if (max <= 0) { - return false; - } + return max > 0; } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java index 7ef2f78aef4..8ba1494b666 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java @@ -35,9 +35,7 @@ public class RepeatEachAi extends SpellAbilityAi { List humTokenCreats = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), Presets.TOKEN); List compTokenCreats = CardLists.filter(aiPlayer.getCreaturesInPlay(), Presets.TOKEN); - if (compTokenCreats.size() <= humTokenCreats.size()) { - return false; - } + return compTokenCreats.size() > humTokenCreats.size(); } else if ("BalanceLands".equals(logic)) { if (CardLists.filter(aiPlayer.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() >= 5) { return false; @@ -111,9 +109,7 @@ public class RepeatEachAi extends SpellAbilityAi { } } // would not hit oppoent, don't do that - if (!hitOpp) { - return false; - } + return hitOpp; } // TODO Add some normal AI variability here diff --git a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java index 676d706d06b..7598d45a700 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java @@ -80,11 +80,7 @@ public class RevealAi extends RevealAiBase { } - if (!revealHandTargetAI(ai, sa/*, false, mandatory*/)) { - return false; - } - - return true; + return revealHandTargetAI(ai, sa/*, false, mandatory*/); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/RevealHandAi.java b/forge-ai/src/main/java/forge/ai/ability/RevealHandAi.java index 841a0cdedca..b2484c99f30 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RevealHandAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RevealHandAi.java @@ -30,11 +30,7 @@ public class RevealHandAi extends RevealAiBase { @Override protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { - if (!revealHandTargetAI(ai, sa/*, false, mandatory*/)) { - return false; - } - - return true; + return revealHandTargetAI(ai, sa/*, false, mandatory*/); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/RollPlanarDiceAi.java b/forge-ai/src/main/java/forge/ai/ability/RollPlanarDiceAi.java index 4dd60206601..09d3859a5c5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RollPlanarDiceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RollPlanarDiceAi.java @@ -144,7 +144,7 @@ public class RollPlanarDiceAi extends SpellAbilityAi { } } - return decideToRoll ? true : false; + return decideToRoll; } /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java b/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java index f5f1c587075..94e36b479da 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java @@ -136,9 +136,7 @@ public class SacrificeAi extends SpellAbilityAi { // Since all of the cards have AI:RemoveDeck:All, I enabled 1 for 1 // (or X for X) trades for special decks - if (humanList.size() < amount) { - return false; - } + return humanList.size() >= amount; } else if (defined.equals("You")) { List computerList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa); diff --git a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java index ea10f386b9e..cf01c1d8026 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java @@ -145,10 +145,10 @@ public class ScryAi extends SpellAbilityAi { if (maxToRemove <= 0) { return false; } - sa.setSVar("ChosenX", "Number$" + Integer.toString(maxToRemove)); + sa.setSVar("ChosenX", "Number$" + maxToRemove); } else { // no Instant or Sorceries anymore, just scry - sa.setSVar("ChosenX", "Number$" + Integer.toString(Math.min(counterNum, libsize))); + sa.setSVar("ChosenX", "Number$" + Math.min(counterNum, libsize)); } } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java index dc5c4f5e635..408fa9a62a4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java @@ -33,10 +33,7 @@ public class SetStateAi extends SpellAbilityAi { return false; } - if("Transform".equals(mode) || "Flip".equals(mode)) { - return true; - } - return false; + return "Transform".equals(mode) || "Flip".equals(mode); } @Override @@ -92,9 +89,7 @@ public class SetStateAi extends SpellAbilityAi { } } - if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) { - return false; - } + return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(source, sa); } } else if ("TurnFace".equals(mode)) { if (!sa.usesTargeting()) { @@ -123,9 +118,7 @@ public class SetStateAi extends SpellAbilityAi { } } - if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) { - return false; - } + return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(source, sa); } } return true; @@ -254,9 +247,7 @@ public class SetStateAi extends SpellAbilityAi { // for legendary KI counter creatures if (othercard.getCounters(CounterType.KI) >= source.getCounters(CounterType.KI)) { // if the other legendary is useless try to replace it - if (!ComputerUtilCard.isUselessCreature(aiPlayer, othercard)) { - return false; - } + return ComputerUtilCard.isUselessCreature(aiPlayer, othercard); } } } @@ -266,10 +257,6 @@ public class SetStateAi extends SpellAbilityAi { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { // TODO: improve the AI for when it may want to transform something that's optional to transform - if (!isSafeToTransformIntoLegendary(player, sa.getHostCard())) { - return false; - } - - return true; + return isSafeToTransformIntoLegendary(player, sa.getHostCard()); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/SkipTurnAi.java b/forge-ai/src/main/java/forge/ai/ability/SkipTurnAi.java index 23f55ec9544..14cae9165fc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SkipTurnAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SkipTurnAi.java @@ -11,10 +11,7 @@ public class SkipTurnAi extends SpellAbilityAi { */ @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { - if ("Always".equals(sa.getParam("AILogic"))) { - return true; - } - return false; + return "Always".equals(sa.getParam("AILogic")); } /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java b/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java index 23069294e94..eb2beab480b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java @@ -76,9 +76,7 @@ public class SurveilAi extends SpellAbilityAi { if ("Never".equals(aiLogic)) { return false; } else if ("Once".equals(aiLogic)) { - if (AiCardMemory.isRememberedCard(ai, source, AiCardMemory.MemorySet.ACTIVATED_THIS_TURN)) { - return false; - } + return !AiCardMemory.isRememberedCard(ai, source, AiCardMemory.MemorySet.ACTIVATED_THIS_TURN); } // TODO: add card-specific Surveil AI logic here when/if necessary diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAi.java b/forge-ai/src/main/java/forge/ai/ability/TapAi.java index 82b55dce044..a4eb933dbe4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAi.java @@ -64,9 +64,7 @@ public class TapAi extends TapAiBase { bFlag |= c.isUntapped(); } - if (!bFlag) { - return false; - } + return bFlag; } else { if ("TapForXCounters".equals(sa.getParam("AILogic"))) { // e.g. Waxmane Baku @@ -83,12 +81,9 @@ public class TapAi extends TapAiBase { } sa.resetTargets(); - if (!tapPrefTargeting(ai, source, tgt, sa, false)) { - return false; - } + return tapPrefTargeting(ai, source, tgt, sa, false); } - return true; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java index 77f83383db6..6a408821cbe 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java @@ -248,12 +248,8 @@ public abstract class TapAiBase extends SpellAbilityAi { sa.getTargets().add(choice); } - if (sa.getTargets().getNumTargeted() == 0) { - // Nothing was ever targeted, so we need to bail. - return false; - } - - return true; + // Nothing was ever targeted, so we need to bail. + return sa.getTargets().getNumTargeted() != 0; } /** @@ -307,11 +303,7 @@ public abstract class TapAiBase extends SpellAbilityAi { // just tap whatever we can tapList = list; - if (tapTargetList(ai, sa, tapList, mandatory)) { - return true; - } - - return false; + return tapTargetList(ai, sa, tapList, mandatory); } @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java index baf1842e4e0..8361e437dcd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java @@ -93,9 +93,7 @@ public class TapAllAi extends SpellAbilityAi { return CombatUtil.canAttack(c) && ComputerUtilCombat.canAttackNextTurn(c); } }); - if(!any) { - return false; - } + return any; } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index cee492ffb3c..6704b41e46b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -103,12 +103,9 @@ public class TokenAi extends SpellAbilityAi { if (actualToken == null) { final AbilitySub sub = sa.getSubAbility(); - if (pwPlus || (sub != null && SpellApiToAi.Converter.get(sub.getApi()).chkAIDrawback(sub, ai))) { - return true; // planeswalker plus ability or sub-ability is - // useful - } else { - return false; // no token created - } + // useful + // no token created + return pwPlus || (sub != null && SpellApiToAi.Converter.get(sub.getApi()).chkAIDrawback(sub, ai)); // planeswalker plus ability or sub-ability is } // X-cost spells @@ -154,10 +151,7 @@ public class TokenAi extends SpellAbilityAi { && !haste && !pwMinus) { return false; } - if ((ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) || !ph.isPlayerTurn(ai)) && oneShot) { - return false; - } - return true; + return (!ph.getPhase().isAfter(PhaseType.COMBAT_BEGIN) && ph.isPlayerTurn(ai)) || !oneShot; } @Override @@ -269,10 +263,8 @@ public class TokenAi extends SpellAbilityAi { list.add(token); list = CardLists.getValidCards(list, valid.split(","), ai.getWeakestOpponent(), topStack.getHostCard(), sa); list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack)); - if (ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0)) - && list.contains(token)) { - return true; - } + return ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0)) + && list.contains(token); } return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java b/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java index 6b7ad4eefbe..4f3292f58d4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java @@ -82,9 +82,7 @@ public class UnattachAllAi extends SpellAbilityAi { //don't equip a worse creature if (card.isEquipping()) { Card oldTarget = card.getEquipping(); - if (ComputerUtilCard.evaluateCreature(oldTarget) > ComputerUtilCard.evaluateCreature(newTarget)) { - return false; - } + return ComputerUtilCard.evaluateCreature(oldTarget) <= ComputerUtilCard.evaluateCreature(newTarget); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index 48884ee524f..5e2659fdacc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -45,11 +45,7 @@ public class UntapAi extends SpellAbilityAi { return false; } - if (!ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard())) { - return false; - } - - return true; + return ComputerUtilCost.checkDiscardCost(ai, cost, sa.getHostCard()); } @Override @@ -63,16 +59,11 @@ public class UntapAi extends SpellAbilityAi { if (tgt == null) { final List pDefined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa); - if (pDefined != null && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) { - return false; - } + return pDefined == null || !pDefined.get(0).isUntapped() || pDefined.get(0).getController() != ai; } else { - if (!untapPrefTargeting(ai, tgt, sa, false)) { - return false; - } + return untapPrefTargeting(ai, tgt, sa, false); } - return true; } @Override @@ -86,11 +77,7 @@ public class UntapAi extends SpellAbilityAi { // TODO: use Defined to determine, if this is an unfavorable result final List pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa); - if (pDefined != null && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) { - return false; - } - - return true; + return pDefined == null || !pDefined.get(0).isUntapped() || pDefined.get(0).getController() != ai; } else { if (untapPrefTargeting(ai, tgt, sa, mandatory)) { return true; @@ -271,11 +258,7 @@ public class UntapAi extends SpellAbilityAi { // just tap whatever we can tapList = list; - if (untapTargetList(source, tgt, sa, mandatory, tapList)) { - return true; - } - - return false; + return untapTargetList(source, tgt, sa, mandatory, tapList); } private boolean untapTargetList(final Card source, final TargetRestrictions tgt, final SpellAbility sa, final boolean mandatory, @@ -438,13 +421,10 @@ public class UntapAi extends SpellAbilityAi { // no harm in doing this past declare blockers during the opponent's turn and right before our turn, // maybe we'll serendipitously untap into something like a removal spell or burn spell that'll help - if (ph.getNextTurn() == ai - && (ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS))) { - return true; - } + return ph.getNextTurn() == ai + && (ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS) || ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)); // haven't found any immediate playable options - return false; } } diff --git a/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java b/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java index fcaf0ad073f..3aa48b72945 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java +++ b/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java @@ -80,7 +80,7 @@ public class PossibleTargetSelector { } private static class SimilarTargetSkipper { - private ArrayListMultimap validTargetsMap = ArrayListMultimap.create(); + private ArrayListMultimap validTargetsMap = ArrayListMultimap.create(); private HashMap cardTypeStrings = new HashMap(); private HashMap creatureScores; diff --git a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java index 75225c73cab..36fbde8d365 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java +++ b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java @@ -49,7 +49,7 @@ public class SpellAbilityChoicesIterator { // TODO: Do we need to do something special to support cards that have extra costs // when choosing more modes, like Blessed Alliance? if (!allowRepeat) { - modeIterator = CombinatoricsUtils.combinationsIterator(choices.size(), num);; + modeIterator = CombinatoricsUtils.combinationsIterator(choices.size(), num); } else { // Note: When allowRepeat is true, it does result in many possibilities being tried. // We should ideally prune some of those at a higher level. diff --git a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java index a14f2b94047..f6c9eec8dfa 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java +++ b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java @@ -308,9 +308,7 @@ public class SpellAbilityPicker { return true; } List phases = conditions.getPhases(); - if (phases.isEmpty() || phases.contains(PhaseType.MAIN1)) { - return true; - } + return phases.isEmpty() || phases.contains(PhaseType.MAIN1); } return false; diff --git a/forge-core/src/main/java/forge/CardStorageReader.java b/forge-core/src/main/java/forge/CardStorageReader.java index 92b30bce7ac..02e4d414277 100644 --- a/forge-core/src/main/java/forge/CardStorageReader.java +++ b/forge-core/src/main/java/forge/CardStorageReader.java @@ -64,7 +64,7 @@ public class CardStorageReader { void report(int current, int total); // does nothing, used when they pass null instead of an instance - public final static ProgressObserver emptyObserver = new ProgressObserver() { + ProgressObserver emptyObserver = new ProgressObserver() { @Override public void setOperationName(final String name, final boolean usePercents) {} @Override public void report(final int current, final int total) {} }; diff --git a/forge-core/src/main/java/forge/ImageKeys.java b/forge-core/src/main/java/forge/ImageKeys.java index bd2c20ed0b5..ee1bca83312 100644 --- a/forge-core/src/main/java/forge/ImageKeys.java +++ b/forge-core/src/main/java/forge/ImageKeys.java @@ -123,7 +123,7 @@ public final class ImageKeys { int index = filename.lastIndexOf('_'); if (index != -1) { String setlessFilename = filename.substring(0, index); - String setCode = filename.substring(index + 1, filename.length()); + String setCode = filename.substring(index + 1); // try with upper case set file = findFile(dir, setlessFilename + "_" + setCode.toUpperCase()); if (file != null) { return file; } @@ -133,7 +133,7 @@ public final class ImageKeys { // if there's an art variant try without it if (setlessFilename.matches(".*[0-9]*$")) { file = findFile(dir, setlessFilename.replaceAll("[0-9]*$", "")); - if (file != null) { return file; } + return file; } } } else if (filename.contains("/")) { @@ -144,7 +144,7 @@ public final class ImageKeys { // try lowering the art index to the minimum for regular cards if (setlessFilename.contains(".full")) { file = findFile(dir, setlessFilename.replaceAll("[0-9]*[.]full", "1.full")); - if (file != null) { return file; } + return file; } } diff --git a/forge-core/src/main/java/forge/LobbyPlayer.java b/forge-core/src/main/java/forge/LobbyPlayer.java index 79139ec3a75..171d4e04e96 100644 --- a/forge-core/src/main/java/forge/LobbyPlayer.java +++ b/forge-core/src/main/java/forge/LobbyPlayer.java @@ -47,13 +47,8 @@ public abstract class LobbyPlayer { } LobbyPlayer other = (LobbyPlayer) obj; if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - return true; + return other.name == null; + } else return name.equals(other.name); } public int getAvatarIndex() { diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index 0c4071e4cf4..0b157f26ac2 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -41,7 +41,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool { public final static char NameSetSeparator = '|'; // need this to obtain cardReference by name+set+artindex - private final ListMultimap allCardsByName = Multimaps.newListMultimap(new TreeMap>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); + private final ListMultimap allCardsByName = Multimaps.newListMultimap(new TreeMap>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); private final Map uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); private final Map rulesByName; private final Map facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); @@ -62,7 +62,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool { Random(false); final boolean filterSets; - private SetPreference(boolean filterIrregularSets) { + SetPreference(boolean filterIrregularSets) { filterSets = filterIrregularSets; } diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 86653eb178b..b9b88687d97 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -189,7 +189,7 @@ public final class CardEdition implements Comparable { // immutable public String getBoosterMustContain() { return boosterMustContain; } public CardInSet[] getCards() { return cards; } - public Map getTokens() { return tokenNormalized; }; + public Map getTokens() { return tokenNormalized; } public static final Function FN_GET_CODE = new Function() { @Override diff --git a/forge-core/src/main/java/forge/card/CardFace.java b/forge-core/src/main/java/forge/card/CardFace.java index 001f2eff18d..3e7afb2858b 100644 --- a/forge-core/src/main/java/forge/card/CardFace.java +++ b/forge-core/src/main/java/forge/card/CardFace.java @@ -20,7 +20,7 @@ final class CardFace implements ICardFace { public enum FaceSelectionMethod { // USE_ACTIVE_FACE, USE_PRIMARY_FACE, - COMBINE; + COMBINE } @@ -87,7 +87,7 @@ final class CardFace implements ICardFace { void setInitialLoyalty(String value) { this.initialLoyalty = value; } void setPtText(String value) { - final String k[] = value.split("/"); + final String[] k = value.split("/"); if (k.length != 2) { throw new RuntimeException("Creature '" + this.getName() + "' has bad p/t stats"); diff --git a/forge-core/src/main/java/forge/card/CardFacePredicates.java b/forge-core/src/main/java/forge/card/CardFacePredicates.java index ee83dda3787..e2b4d2a5815 100644 --- a/forge-core/src/main/java/forge/card/CardFacePredicates.java +++ b/forge-core/src/main/java/forge/card/CardFacePredicates.java @@ -85,7 +85,7 @@ public final class CardFacePredicates { @Override public boolean apply(ICardFace input) { - String k[] = valid.split("\\.", 2); + String[] k = valid.split("\\.", 2); if ("Card".equals(k[0])) { // okay @@ -110,10 +110,7 @@ public final class CardFacePredicates { static protected boolean hasProperty(ICardFace input, final String v) { if (v.startsWith("non")) { return !hasProperty(input, v.substring(3)); - } else if (!input.getType().hasStringType(v)) { - return false; - } - return true; + } else return input.getType().hasStringType(v); } } diff --git a/forge-core/src/main/java/forge/card/CardRarity.java b/forge-core/src/main/java/forge/card/CardRarity.java index 7ed13dda93c..b6f1f898067 100644 --- a/forge-core/src/main/java/forge/card/CardRarity.java +++ b/forge-core/src/main/java/forge/card/CardRarity.java @@ -35,7 +35,7 @@ public enum CardRarity { private final String shortName, longName; - private CardRarity(final String shortName0, final String longName0) { + CardRarity(final String shortName0, final String longName0) { shortName = shortName0; longName = longName0; } diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index e6b200b1a94..4748c821013 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -435,10 +435,10 @@ public final class CardRulesPredicates { return this.op(card.getManaCost().getGenericCost(), this.operand); case POWER: value = card.getIntPower(); - return value != Integer.MAX_VALUE ? this.op(value, this.operand) : false; + return value != Integer.MAX_VALUE && this.op(value, this.operand); case TOUGHNESS: value = card.getIntToughness(); - return value != Integer.MAX_VALUE ? this.op(value, this.operand) : false; + return value != Integer.MAX_VALUE && this.op(value, this.operand); default: return false; } diff --git a/forge-core/src/main/java/forge/card/CardSplitType.java b/forge-core/src/main/java/forge/card/CardSplitType.java index 38902df9db1..a949ec8b975 100644 --- a/forge-core/src/main/java/forge/card/CardSplitType.java +++ b/forge-core/src/main/java/forge/card/CardSplitType.java @@ -10,7 +10,7 @@ public enum CardSplitType Split(FaceSelectionMethod.COMBINE, CardStateName.RightSplit), Flip(FaceSelectionMethod.USE_PRIMARY_FACE, CardStateName.Flipped); - private CardSplitType(FaceSelectionMethod calcMode, CardStateName stateName) { + CardSplitType(FaceSelectionMethod calcMode, CardStateName stateName) { method = calcMode; this.changedStateName = stateName; } diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index ebc12e29266..f7c85f94bb7 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -73,7 +73,7 @@ public final class CardType implements Comparable, CardTypeView { public final boolean isPermanent; private static final ImmutableList allCoreTypeNames = EnumUtil.getNames(CoreType.class); - private CoreType(final boolean permanent) { + CoreType(final boolean permanent) { isPermanent = permanent; } } @@ -598,10 +598,7 @@ public final class CardType implements Comparable, CardTypeView { if (multiWordTypes[0].startsWith(type) && !multiWordTypes[0].equals(type)) { return true; } - if (multiWordTypes[1].startsWith(type) && !multiWordTypes[1].equals(type)) { - return true; - } - return false; + return multiWordTypes[1].startsWith(type) && !multiWordTypes[1].equals(type); } public static class Constant { diff --git a/forge-core/src/main/java/forge/card/ICardFace.java b/forge-core/src/main/java/forge/card/ICardFace.java index 4953f3ddf0e..d73578d6242 100644 --- a/forge-core/src/main/java/forge/card/ICardFace.java +++ b/forge-core/src/main/java/forge/card/ICardFace.java @@ -5,5 +5,5 @@ package forge.card; * */ public interface ICardFace extends ICardCharacteristics, ICardRawAbilites, Comparable { - public String getAltName(); + String getAltName(); } diff --git a/forge-core/src/main/java/forge/card/MagicColor.java b/forge-core/src/main/java/forge/card/MagicColor.java index bf0b4fdbb9f..c21dedeac97 100644 --- a/forge-core/src/main/java/forge/card/MagicColor.java +++ b/forge-core/src/main/java/forge/card/MagicColor.java @@ -168,7 +168,7 @@ public final class MagicColor { private final String name, symbol; private final byte colormask; - private Color(String name0, byte colormask0, String symbol0) { + Color(String name0, byte colormask0, String symbol0) { name = name0; colormask = colormask0; symbol = symbol0; diff --git a/forge-core/src/main/java/forge/card/mana/ManaAtom.java b/forge-core/src/main/java/forge/card/mana/ManaAtom.java index 5a38b3a3310..951f7fbf776 100644 --- a/forge-core/src/main/java/forge/card/mana/ManaAtom.java +++ b/forge-core/src/main/java/forge/card/mana/ManaAtom.java @@ -44,7 +44,7 @@ public abstract class ManaAtom { if (s.length() == 2) { //if name is two characters, check for combination of two colors return (byte)(fromName(s.charAt(0)) | fromName(s.charAt(1))); } else if (s.length() == 1) { - return (byte) fromName(s.charAt(0)); + return fromName(s.charAt(0)); } s = s.toLowerCase(); diff --git a/forge-core/src/main/java/forge/card/mana/ManaCost.java b/forge-core/src/main/java/forge/card/mana/ManaCost.java index a2393429897..90886018108 100644 --- a/forge-core/src/main/java/forge/card/mana/ManaCost.java +++ b/forge-core/src/main/java/forge/card/mana/ManaCost.java @@ -69,7 +69,7 @@ public final class ManaCost implements Comparable, IterablenewArrayList()); + sealClass(Lists.newArrayList()); } private ManaCost(int cmc, List shards0) { diff --git a/forge-core/src/main/java/forge/card/mana/ManaCostShard.java b/forge-core/src/main/java/forge/card/mana/ManaCostShard.java index 84d317554b7..8c97c99e5b8 100644 --- a/forge-core/src/main/java/forge/card/mana/ManaCostShard.java +++ b/forge-core/src/main/java/forge/card/mana/ManaCostShard.java @@ -86,7 +86,7 @@ public enum ManaCostShard { * @param sValue * the s value */ - private ManaCostShard(final int value, final String sValue) { + ManaCostShard(final int value, final String sValue) { this(value, sValue, sValue); } @@ -100,7 +100,7 @@ public enum ManaCostShard { * @param imgKey * the img key */ - private ManaCostShard(final int value, final String sValue, final String imgKey) { + ManaCostShard(final int value, final String sValue, final String imgKey) { this.shard = value; this.cmc = this.getCMC(); this.cmpc = this.getCmpCost(); diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index 5d9f651828b..f0515c6494b 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -85,10 +85,7 @@ public enum DeckFormat { if (otherPart != null && otherPart.getManaCost().getCMC() > 3) { return false; //only cards with CMC less than 3 are allowed } - if (bannedCards.contains(rules.getName())) { - return false; - } - return true; + return !bannedCards.contains(rules.getName()); } }) { private final Set bannedCommanders = ImmutableSet.of("Derevi, Empyrial Tactician", "Erayo, Soratami Ascendant", "Rofellos, Llanowar Emissary"); @@ -120,7 +117,7 @@ public enum DeckFormat { private final static String ADVPROCLAMATION = "Advantageous Proclamation"; private final static String SOVREALM = "Sovereign's Realm"; - private DeckFormat(Range mainRange0, Range sideRange0, int maxCardCopies0, Predicate cardPoolFilter0, Predicate paperCardPoolFilter0) { + DeckFormat(Range mainRange0, Range sideRange0, int maxCardCopies0, Predicate cardPoolFilter0, Predicate paperCardPoolFilter0) { mainRange = mainRange0; sideRange = sideRange0; maxCardCopies = maxCardCopies0; @@ -128,7 +125,7 @@ public enum DeckFormat { paperCardPoolFilter = paperCardPoolFilter0; } - private DeckFormat(Range mainRange0, Range sideRange0, int maxCardCopies0, Predicate cardPoolFilter0) { + DeckFormat(Range mainRange0, Range sideRange0, int maxCardCopies0, Predicate cardPoolFilter0) { mainRange = mainRange0; sideRange = sideRange0; maxCardCopies = maxCardCopies0; @@ -136,7 +133,7 @@ public enum DeckFormat { cardPoolFilter = cardPoolFilter0; } - private DeckFormat(Range mainRange0, Range sideRange0, int maxCardCopies0) { + DeckFormat(Range mainRange0, Range sideRange0, int maxCardCopies0) { mainRange = mainRange0; sideRange = sideRange0; maxCardCopies = maxCardCopies0; diff --git a/forge-core/src/main/java/forge/deck/DeckRecognizer.java b/forge-core/src/main/java/forge/deck/DeckRecognizer.java index 0cae2a03261..52d2005fd3f 100644 --- a/forge-core/src/main/java/forge/deck/DeckRecognizer.java +++ b/forge-core/src/main/java/forge/deck/DeckRecognizer.java @@ -216,10 +216,7 @@ public class DeckRecognizer { if (line.toLowerCase().contains("schemes")) { return true; } - if (line.toLowerCase().contains("vanguard")) { - return true; - } - return false; + return line.toLowerCase().contains("vanguard"); } public void setDateConstraint(int month, Integer year) { diff --git a/forge-core/src/main/java/forge/deck/DeckSection.java b/forge-core/src/main/java/forge/deck/DeckSection.java index 90d2b91d17e..59516041ad0 100644 --- a/forge-core/src/main/java/forge/deck/DeckSection.java +++ b/forge-core/src/main/java/forge/deck/DeckSection.java @@ -10,7 +10,7 @@ public enum DeckSection { Conspiracy(0); private final int typicalSize; // Rules enforcement is done in DeckFormat class, this is for reference only - private DeckSection(int commonSize) { + DeckSection(int commonSize) { typicalSize = commonSize; } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index d3f0a844019..050f1827e61 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -142,7 +142,7 @@ public abstract class DeckGeneratorBase { if(basicLandEdition == null){ if(setBasicLandPool(cp.getEdition())){ basicLandEdition = cp.getEdition(); - }; + } } cardCounts.put(cp.getName(), newCount); trace.append(String.format("(%d) %s [%s]%n", cp.getRules().getManaCost().getCMC(), cp.getName(), cp.getRules().getManaCost())); diff --git a/forge-core/src/main/java/forge/item/PaperCard.java b/forge-core/src/main/java/forge/item/PaperCard.java index be80957515c..f69036aa1c9 100644 --- a/forge-core/src/main/java/forge/item/PaperCard.java +++ b/forge-core/src/main/java/forge/item/PaperCard.java @@ -159,11 +159,7 @@ public final class PaperCard implements Comparable, InventoryItemFro if (!edition.equals(other.edition)) { return false; } - if ((other.foil != foil) || (other.artIndex != artIndex)) { - return false; - } - - return true; + return (other.foil == foil) && (other.artIndex == artIndex); } /* @@ -238,13 +234,11 @@ public final class PaperCard implements Comparable, InventoryItemFro // Return true if card is one of the five basic lands that can be added for free public boolean isVeryBasicLand() { - if ((this.getName().equals("Swamp")) + return (this.getName().equals("Swamp")) || (this.getName().equals("Plains")) || (this.getName().equals("Island")) || (this.getName().equals("Forest")) - || (this.getName().equals("Mountain"))) { - return true; - } else return false; + || (this.getName().equals("Mountain")); } } diff --git a/forge-core/src/main/java/forge/util/Base64Coder.java b/forge-core/src/main/java/forge/util/Base64Coder.java index c78acff79b9..2a53be0d765 100644 --- a/forge-core/src/main/java/forge/util/Base64Coder.java +++ b/forge-core/src/main/java/forge/util/Base64Coder.java @@ -36,6 +36,7 @@ import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; +import java.nio.charset.StandardCharsets; /** * A Base64 encoder/decoder. @@ -377,7 +378,7 @@ public final class Base64Coder { SecretKey key = keyFactory.generateSecret(new PBEKeySpec(PASSWORD)); Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(SALT, 20)); - return String.valueOf(encode(pbeCipher.doFinal(value.getBytes("UTF-8")))); + return String.valueOf(encode(pbeCipher.doFinal(value.getBytes(StandardCharsets.UTF_8)))); } public static String decrypt(String value) throws Exception { @@ -385,7 +386,7 @@ public final class Base64Coder { SecretKey key = keyFactory.generateSecret(new PBEKeySpec(PASSWORD)); Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(SALT, 20)); - return new String(pbeCipher.doFinal(decode(value)), "UTF-8"); + return new String(pbeCipher.doFinal(decode(value)), StandardCharsets.UTF_8); } // Dummy constructor. diff --git a/forge-core/src/main/java/forge/util/ComparableOp.java b/forge-core/src/main/java/forge/util/ComparableOp.java index ff7fb1030fb..ad295dac98e 100644 --- a/forge-core/src/main/java/forge/util/ComparableOp.java +++ b/forge-core/src/main/java/forge/util/ComparableOp.java @@ -33,7 +33,7 @@ public enum ComparableOp { private final String caption; - private ComparableOp(String caption0) { + ComparableOp(String caption0) { caption = caption0; } diff --git a/forge-core/src/main/java/forge/util/ImageUtil.java b/forge-core/src/main/java/forge/util/ImageUtil.java index fff1213d844..4b2e515f8fd 100644 --- a/forge-core/src/main/java/forge/util/ImageUtil.java +++ b/forge-core/src/main/java/forge/util/ImageUtil.java @@ -10,7 +10,7 @@ import forge.item.PaperCard; public class ImageUtil { public static float getNearestHQSize(float baseSize, float actualSize) { //get nearest power of actualSize to baseSize so that the image renders good - return (float)Math.round(actualSize) * (float)Math.pow(2, (double)Math.round(Math.log((double)(baseSize / actualSize)) / Math.log(2))); + return (float)Math.round(actualSize) * (float)Math.pow(2, (double)Math.round(Math.log(baseSize / actualSize) / Math.log(2))); } public static PaperCard getPaperCardFromImageKey(String key) { @@ -119,7 +119,6 @@ public class ImageUtil { for (int i = 0; i < in.length(); i++) { c = in.charAt(i); if ((c == '"') || (c == '/') || (c == ':') || (c == '?')) { - out.append(""); } else { out.append(c); } diff --git a/forge-core/src/main/java/forge/util/Lang.java b/forge-core/src/main/java/forge/util/Lang.java index 216bfee2664..531f7237314 100644 --- a/forge-core/src/main/java/forge/util/Lang.java +++ b/forge-core/src/main/java/forge/util/Lang.java @@ -102,7 +102,7 @@ public final class Lang { strCount = startsWithVowel(noun) ? "an " : "a "; } else { - strCount = String.valueOf(cnt) + " "; + strCount = cnt + " "; } return strCount + countedForm; } diff --git a/forge-core/src/main/java/forge/util/LocalizationChangeObserver.java b/forge-core/src/main/java/forge/util/LocalizationChangeObserver.java index 88887508309..559a2191424 100644 --- a/forge-core/src/main/java/forge/util/LocalizationChangeObserver.java +++ b/forge-core/src/main/java/forge/util/LocalizationChangeObserver.java @@ -1,5 +1,5 @@ package forge.util; public interface LocalizationChangeObserver { - public void localizationChanged(); + void localizationChanged(); } diff --git a/forge-core/src/main/java/forge/util/Localizer.java b/forge-core/src/main/java/forge/util/Localizer.java index 6569e1a2e91..73076e6b30c 100644 --- a/forge-core/src/main/java/forge/util/Localizer.java +++ b/forge-core/src/main/java/forge/util/Localizer.java @@ -1,10 +1,10 @@ package forge.util; import java.io.File; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.*; @@ -38,7 +38,7 @@ public class Localizer { try { //formatter = new MessageFormat(resourceBundle.getString(key.toLowerCase()), locale); - formatter = new MessageFormat(resourceBundle.getString(key.toString()), locale); + formatter = new MessageFormat(resourceBundle.getString(key), locale); } catch (final IllegalArgumentException | MissingResourceException e) { e.printStackTrace(); } @@ -51,14 +51,10 @@ public class Localizer { formatter.setLocale(locale); String formattedMessage = "CHAR ENCODING ERROR"; - try { - //Support non-English-standard characters - formattedMessage = new String(formatter.format(messageArguments).getBytes("ISO-8859-1"), "UTF-8"); - } catch (final UnsupportedEncodingException e) { - e.printStackTrace(); - } - - return formattedMessage; + //Support non-English-standard characters + formattedMessage = new String(formatter.format(messageArguments).getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + + return formattedMessage; } diff --git a/forge-core/src/main/java/forge/util/storage/StorageBase.java b/forge-core/src/main/java/forge/util/storage/StorageBase.java index 5a970878e8d..2c0c959fe20 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageBase.java @@ -65,7 +65,7 @@ public class StorageBase implements IStorage { @Override public boolean contains(String name) { - return name == null ? false : map.containsKey(name); + return name != null && map.containsKey(name); } @Override diff --git a/forge-game/src/main/java/forge/GameCommand.java b/forge-game/src/main/java/forge/GameCommand.java index f0d96122ffe..e67dc9560a3 100644 --- a/forge-game/src/main/java/forge/GameCommand.java +++ b/forge-game/src/main/java/forge/GameCommand.java @@ -27,7 +27,7 @@ package forge; */ public interface GameCommand extends java.io.Serializable, Runnable { /** Constant Blank. */ - public final GameCommand BLANK = new GameCommand() { + GameCommand BLANK = new GameCommand() { private static final long serialVersionUID = 2689172297036001710L; diff --git a/forge-game/src/main/java/forge/game/CardTraitBase.java b/forge-game/src/main/java/forge/game/CardTraitBase.java index aacc1d389e1..7897017b187 100644 --- a/forge-game/src/main/java/forge/game/CardTraitBase.java +++ b/forge-game/src/main/java/forge/game/CardTraitBase.java @@ -159,9 +159,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView { */ public final boolean isSecondary() { if (this.mapParams.containsKey("Secondary")) { - if (this.mapParams.get("Secondary").equals("True")) { - return true; - } + return this.mapParams.get("Secondary").equals("True"); } return false; } @@ -451,9 +449,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView { if (params.containsKey("ActivateNoLoyaltyAbilitiesCondition")) { final Player active = game.getPhaseHandler().getPlayerTurn(); - if (active.getActivateLoyaltyAbilityThisTurn()) { - return false; - } + return !active.getActivateLoyaltyAbilityThisTurn(); } return true; } diff --git a/forge-game/src/main/java/forge/game/ForgeScript.java b/forge-game/src/main/java/forge/game/ForgeScript.java index c5db86d46ad..1bf735a42d4 100644 --- a/forge-game/src/main/java/forge/game/ForgeScript.java +++ b/forge-game/src/main/java/forge/game/ForgeScript.java @@ -29,8 +29,7 @@ public class ForgeScript { int desiredColor = MagicColor.fromName(colorName); boolean hasColor = colors.hasAnyColor(desiredColor); - if (mustHave != hasColor) - return false; + return mustHave == hasColor; } else if (property.contains("Colorless")) { // ... Card is colorless boolean non = property.startsWith("non"); @@ -38,66 +37,48 @@ public class ForgeScript { if (non && withSource && isColorlessSource) { return false; } - if (non == colors.isColorless()) return false; + return non != colors.isColorless(); } else if (property.contains("MultiColor")) { // ... Card is multicolored if (property.endsWith("Source") && isColorlessSource) return false; - if (property.startsWith("non") == colors.isMulticolor()) - return false; + return property.startsWith("non") != colors.isMulticolor(); } else if (property.contains("MonoColor")) { // ... Card is monocolored if (property.endsWith("Source") && isColorlessSource) return false; - if (property.startsWith("non") == colors.isMonoColor()) - return false; + return property.startsWith("non") != colors.isMonoColor(); } else if (property.startsWith("ChosenColor")) { if (property.endsWith("Source") && isColorlessSource) return false; - if (!source.hasChosenColor() || !colors.hasAnyColor(MagicColor.fromName(source.getChosenColor()))) - return false; + return source.hasChosenColor() && colors.hasAnyColor(MagicColor.fromName(source.getChosenColor())); } else if (property.startsWith("AnyChosenColor")) { if (property.endsWith("Source") && isColorlessSource) return false; - if (!source.hasChosenColor() - || !colors.hasAnyColor(ColorSet.fromNames(source.getChosenColors()).getColor())) - return false; + return source.hasChosenColor() + && colors.hasAnyColor(ColorSet.fromNames(source.getChosenColors()).getColor()); } else if (property.startsWith("non")) { // ... Other Card types - if (cardState.getTypeWithChanges().hasStringType(property.substring(3))) { - return false; - } + return !cardState.getTypeWithChanges().hasStringType(property.substring(3)); } else if (property.equals("CostsPhyrexianMana")) { - if (!cardState.getManaCost().hasPhyrexian()) { - return false; - } + return cardState.getManaCost().hasPhyrexian(); } else if (property.startsWith("HasSVar")) { final String svar = property.substring(8); - if (!cardState.hasSVar(svar)) { - return false; - } + return cardState.hasSVar(svar); } else if (property.equals("ChosenType")) { - if (!cardState.getTypeWithChanges().hasStringType(source.getChosenType())) { - return false; - } + return cardState.getTypeWithChanges().hasStringType(source.getChosenType()); } else if (property.equals("IsNotChosenType")) { - if (cardState.getTypeWithChanges().hasStringType(source.getChosenType())) { - return false; - } + return !cardState.getTypeWithChanges().hasStringType(source.getChosenType()); } else if (property.startsWith("HasSubtype")) { final String subType = property.substring(11); - if (!cardState.getTypeWithChanges().hasSubtype(subType)) { - return false; - } + return cardState.getTypeWithChanges().hasSubtype(subType); } else if (property.startsWith("HasNoSubtype")) { final String subType = property.substring(13); - if (cardState.getTypeWithChanges().hasSubtype(subType)) { - return false; - } + return !cardState.getTypeWithChanges().hasSubtype(subType); } else if (property.equals("hasActivatedAbilityWithTapCost")) { for (final SpellAbility sa : cardState.getSpellAbilities()) { if (sa.isAbility() && (sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) { @@ -136,80 +117,47 @@ public class ForgeScript { x = AbilityUtils.calculateAmount(source, rhs, spellAbility); } - if (!Expressions.compare(y, property, x)) { - return false; - } - } else if (!cardState.getTypeWithChanges().hasStringType(property)) { - return false; - } - - return true; - + return Expressions.compare(y, property, x); + } else return cardState.getTypeWithChanges().hasStringType(property); + - } public static boolean spellAbilityHasProperty(SpellAbility sa, String property, Player sourceController, Card source, SpellAbility spellAbility) { if (property.equals("ManaAbility")) { - if (!sa.isManaAbility()) { - return false; - } + return sa.isManaAbility(); } else if (property.equals("nonManaAbility")) { - if (sa.isManaAbility()) { - return false; - } + return !sa.isManaAbility(); } else if (property.equals("Buyback")) { - if (!sa.isBuyBackAbility()) { - return false; - } + return sa.isBuyBackAbility(); } else if (property.equals("Cycling")) { - if (!sa.isCycling()) { - return false; - } + return sa.isCycling(); } else if (property.equals("Dash")) { - if (!sa.isDash()) { - return false; - } + return sa.isDash(); } else if (property.equals("Flashback")) { - if (!sa.isFlashBackAbility()) { - return false; - } + return sa.isFlashBackAbility(); } else if (property.equals("Jumpstart")) { - if (!sa.isJumpstart()) { - return false; - } + return sa.isJumpstart(); } else if (property.equals("Kicked")) { - if (!sa.isKicked()) { - return false; - } + return sa.isKicked(); } else if (property.equals("Loyalty")) { - if (!sa.isPwAbility()) { - return false; - } + return sa.isPwAbility(); } else if (property.equals("Aftermath")) { - if (!sa.isAftermath()) { - return false; - } + return sa.isAftermath(); } else if (property.equals("MorphUp")) { - if (!sa.isMorphUp()) { - return false; - } + return sa.isMorphUp(); } else if (property.equals("Equip")) { - if (!sa.hasParam("Equip")) { - return false; - } + return sa.hasParam("Equip"); } else if (property.equals("MayPlaySource")) { StaticAbility m = sa.getMayPlay(); if (m == null) { return false; } - if (!source.equals(m.getHostCard())) { - return false; - } + return source.equals(m.getHostCard()); } else if (property.startsWith("IsTargeting")) { - String k[] = property.split(" ", 2); + String[] k = property.split(" ", 2); boolean found = false; for (GameObject o : AbilityUtils.getDefinedObjects(source, k[1], spellAbility)) { if (sa.isTargeting(o)) { @@ -217,15 +165,11 @@ public class ForgeScript { break; } } - if (!found) { - return false; - } + return found; } else if (property.equals("YouCtrl")) { return sa.getActivatingPlayer().equals(sourceController); } else if (sa.getHostCard() != null) { - if (!sa.getHostCard().hasProperty(property, sourceController, source, spellAbility)) { - return false; - } + return sa.getHostCard().hasProperty(property, sourceController, source, spellAbility); } return true; diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index 4e58a1aba55..beef5eade46 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -845,7 +845,7 @@ public class Game { } } - library.removeAll((Collection)toRemove); + library.removeAll(toRemove); if (library.size() > 0) { //Make sure that matches were found. If not, use the original method to choose antes Card ante = library.get(MyRandom.getRandom().nextInt(library.size())); diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 2b95afafab1..50d3523676d 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -763,7 +763,7 @@ public class GameAction { checkStaticAbilities(true); } public final void checkStaticAbilities(final boolean runEvents) { - checkStaticAbilities(runEvents, Sets.newHashSet(), CardCollection.EMPTY); + checkStaticAbilities(runEvents, Sets.newHashSet(), CardCollection.EMPTY); } public final void checkStaticAbilities(final boolean runEvents, final Set affectedCards, final CardCollectionView preList) { if (isCheckingStaticAbilitiesOnHold()) { @@ -929,7 +929,7 @@ public class GameAction { } public final void checkStateEffects(final boolean runEvents) { - checkStateEffects(runEvents, Sets.newHashSet()); + checkStateEffects(runEvents, Sets.newHashSet()); } public final void checkStateEffects(final boolean runEvents, final Set affectedCards) { // sol(10/29) added for Phase updates, state effects shouldn't be diff --git a/forge-game/src/main/java/forge/game/GameActionUtil.java b/forge-game/src/main/java/forge/game/GameActionUtil.java index b8fa75f9f13..e425d2fff6e 100644 --- a/forge-game/src/main/java/forge/game/GameActionUtil.java +++ b/forge-game/src/main/java/forge/game/GameActionUtil.java @@ -234,7 +234,7 @@ public final class GameActionUtil { // there is a flashback cost (and not the cards cost) if (keyword.contains(":")) { - final String k[] = keyword.split(":"); + final String[] k = keyword.split(":"); flashback.setPayCosts(new Cost(k[1], false)); } alternatives.add(flashback); diff --git a/forge-game/src/main/java/forge/game/GameEntity.java b/forge-game/src/main/java/forge/game/GameEntity.java index 1e7ecd2d3f9..58ab4d02127 100644 --- a/forge-game/src/main/java/forge/game/GameEntity.java +++ b/forge-game/src/main/java/forge/game/GameEntity.java @@ -407,11 +407,7 @@ public abstract class GameEntity extends GameObject implements IIdentifiable { } // true for all - if (hasProtectionFrom(attach, checkSBA)) { - return false; - } - - return true; + return !hasProtectionFrom(attach, checkSBA); } protected boolean canBeEquippedBy(final Card aura) { diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 2790a759a64..bfa3f08efae 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -368,7 +368,7 @@ public class GameFormat implements Comparable { if ( strCars != null ) { CardRarity cr; rarities = Lists.newArrayList(); - for (String s: Arrays.asList(strCars.split(", "))) { + for (String s: strCars.split(", ")) { cr = CardRarity.smartValueOf(s); if (!cr.name().equals("Unknown")) { rarities.add(cr); diff --git a/forge-game/src/main/java/forge/game/GameLogEntryType.java b/forge-game/src/main/java/forge/game/GameLogEntryType.java index 76538fef910..8654fba1a55 100644 --- a/forge-game/src/main/java/forge/game/GameLogEntryType.java +++ b/forge-game/src/main/java/forge/game/GameLogEntryType.java @@ -20,7 +20,7 @@ public enum GameLogEntryType { PHASE("Phase"); private final String caption; - private GameLogEntryType(String name) { + GameLogEntryType(String name) { this.caption = name; } diff --git a/forge-game/src/main/java/forge/game/GameLogFormatter.java b/forge-game/src/main/java/forge/game/GameLogFormatter.java index 6ad9bd1cf8f..bed7d9a2755 100644 --- a/forge-game/src/main/java/forge/game/GameLogFormatter.java +++ b/forge-game/src/main/java/forge/game/GameLogFormatter.java @@ -182,7 +182,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base { if (event.type == DamageType.LoyaltyLoss) { additionalLog = " (Removing " + Lang.nounWithAmount(event.amount, "loyalty counter") + ")"; } - String message = event.source.toString() + " deals " + String.valueOf(event.amount) + " damage" + additionalLog + " to " + event.card.toString() + "."; + String message = event.source.toString() + " deals " + event.amount + " damage" + additionalLog + " to " + event.card.toString() + "."; return new GameLogEntry(GameLogEntryType.DAMAGE, message); } @@ -197,7 +197,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base { @Override public GameLogEntry visit(GameEventTurnBegan event) { - String message = "Turn " + String.valueOf(event.turnNumber) + " (" + event.turnOwner.toString() + ")"; + String message = "Turn " + event.turnNumber + " (" + event.turnOwner.toString() + ")"; return new GameLogEntry(GameLogEntryType.TURN, message); } @@ -205,7 +205,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base { public GameLogEntry visit(GameEventPlayerDamaged ev) { String extra = ev.infect ? " (as poison counters)" : ""; String damageType = ev.combat ? "combat" : "non-combat"; - String message = ev.source.toString() + " deals " + String.valueOf(ev.amount) + " " + damageType + " damage to " + ev.target.toString() + extra + "."; + String message = ev.source.toString() + " deals " + ev.amount + " " + damageType + " damage to " + ev.target.toString() + extra + "."; return new GameLogEntry(GameLogEntryType.DAMAGE, message); } @@ -281,7 +281,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base { @Override public GameLogEntry visit(GameEventMulligan ev) { - String message = ev.player.toString() + " has mulliganed down to " + String.valueOf(ev.player.getZone(ZoneType.Hand).size()) + " cards."; + String message = ev.player.toString() + " has mulliganed down to " + ev.player.getZone(ZoneType.Hand).size() + " cards."; return new GameLogEntry(GameLogEntryType.MULLIGAN, message); } diff --git a/forge-game/src/main/java/forge/game/GameStage.java b/forge-game/src/main/java/forge/game/GameStage.java index 9d32e7ac39f..251fc2e25ee 100644 --- a/forge-game/src/main/java/forge/game/GameStage.java +++ b/forge-game/src/main/java/forge/game/GameStage.java @@ -5,5 +5,5 @@ public enum GameStage { Mulligan, Play, RestartedByKarn, - GameOver; + GameOver } \ No newline at end of file diff --git a/forge-game/src/main/java/forge/game/GameType.java b/forge-game/src/main/java/forge/game/GameType.java index dc63a482d3f..7ef81786c26 100644 --- a/forge-game/src/main/java/forge/game/GameType.java +++ b/forge-game/src/main/java/forge/game/GameType.java @@ -71,11 +71,11 @@ public enum GameType { private final String name, description; private final Function deckAutoGenerator; - private GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0) { + GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0) { this(deckFormat0, isCardPoolLimited0, canSideboard0, addWonCardsMidgame0, name0, description0, null); } - private GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0, Function deckAutoGenerator0) { + GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0, Function deckAutoGenerator0) { final Localizer localizer = forge.util.Localizer.getInstance(); deckFormat = deckFormat0; isCardPoolLimited = isCardPoolLimited0; diff --git a/forge-game/src/main/java/forge/game/GlobalRuleChange.java b/forge-game/src/main/java/forge/game/GlobalRuleChange.java index aa2e4f1b326..2e7fc2ca2ab 100644 --- a/forge-game/src/main/java/forge/game/GlobalRuleChange.java +++ b/forge-game/src/main/java/forge/game/GlobalRuleChange.java @@ -40,7 +40,7 @@ public enum GlobalRuleChange { private final String ruleText; - private GlobalRuleChange(String text) { + GlobalRuleChange(String text) { ruleText = text; } diff --git a/forge-game/src/main/java/forge/game/IIdentifiable.java b/forge-game/src/main/java/forge/game/IIdentifiable.java index 8c3bf20272a..6b90c6826e8 100644 --- a/forge-game/src/main/java/forge/game/IIdentifiable.java +++ b/forge-game/src/main/java/forge/game/IIdentifiable.java @@ -3,8 +3,8 @@ package forge.game; import com.google.common.base.Function; public interface IIdentifiable { - public abstract int getId(); - public static final Function FN_GET_ID = new Function() { + int getId(); + Function FN_GET_ID = new Function() { @Override public Integer apply(final IIdentifiable input) { return Integer.valueOf(input.getId()); diff --git a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java index 6fd213ea43c..1e770f1fce9 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java @@ -64,7 +64,7 @@ public final class AbilityFactory { SubAbility("DB"); private final String prefix; - private AbilityRecordType(String prefix) { + AbilityRecordType(String prefix) { this.prefix = prefix; } public String getPrefix() { 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 747945ae97b..399515f6755 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -35,7 +35,6 @@ import io.sentry.event.BreadcrumbBuilder; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -1063,7 +1062,7 @@ public class AbilityUtils { } else if (defined.startsWith("OppNon")) { players.addAll(player.getOpponents()); - players.removeAll((Collection)getDefinedPlayers(card, defined.substring(6), sa)); + players.removeAll(getDefinedPlayers(card, defined.substring(6), sa)); } else if (defined.startsWith("Replaced")) { final SpellAbility root = sa.getRootAbility(); @@ -1800,7 +1799,7 @@ public class AbilityUtils { public static final String getSVar(final CardTraitBase ability, final String sVarName) { String val = null; if (ability instanceof SpellAbility) { - val = ((SpellAbility) ability).getSVar(sVarName); + val = ability.getSVar(sVarName); } if (StringUtils.isEmpty(val)) { Card host = null; @@ -1857,7 +1856,7 @@ public class AbilityUtils { public boolean apply(Card input) { for (final KeywordInterface inst : input.getKeywords(Keyword.SPLICE)) { String k = inst.getOriginal(); - final String n[] = k.split(":"); + final String[] n = k.split(":"); if (source.isValid(n[1].split(","), player, input, sa)) { return true; } @@ -1890,7 +1889,7 @@ public class AbilityUtils { // This Function thinks that Splice exist only once on the card for (final KeywordInterface inst : c.getKeywords(Keyword.SPLICE)) { final String k = inst.getOriginal(); - final String n[] = k.split(":"); + final String[] n = k.split(":"); spliceCost = new Cost(n[2], false); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ActivateAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ActivateAbilityEffect.java index 2811591354c..3114cf48501 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ActivateAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ActivateAbilityEffect.java @@ -51,7 +51,7 @@ public class ActivateAbilityEffect extends SpellAbilityEffect { continue; } SpellAbility manaAb = p.getController().chooseSingleSpellForEffect( - possibleAb, sa, "Choose a mana ability:", ImmutableMap.of()); + possibleAb, sa, "Choose a mana ability:", ImmutableMap.of()); p.getController().playChosenSpellAbility(manaAb); } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/AssignGroupEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AssignGroupEffect.java index eb53cecf76b..e3e53dc6fa0 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AssignGroupEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AssignGroupEffect.java @@ -38,7 +38,7 @@ public class AssignGroupEffect extends SpellAbilityEffect { List defined = getDefinedOrTargeted(sa, "Defined"); - final List abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices")); + final List abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices")); Player chooser = sa.getActivatingPlayer(); if (sa.hasParam("Chooser")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java b/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java index fdd3365212e..0ea798f50e9 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java @@ -54,7 +54,7 @@ public class BidLifeEffect extends SpellAbilityEffect { willBid = false; for (final Player p : bidPlayers) { final boolean result = p.getController().confirmBidAction(sa, PlayerActionConfirmMode.BidLife, - "Do you want to top bid? Current Bid =" + String.valueOf(bid), bid, winner); + "Do you want to top bid? Current Bid =" + bid, bid, winner); willBid |= result; if (result) { // a different choose number bid += p.getController().chooseNumber(sa, "Bid life:", 1, 9); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeTextEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeTextEffect.java index 91ee11bd4b8..131eecbcff7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeTextEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeTextEffect.java @@ -71,13 +71,13 @@ public class ChangeTextEffect extends SpellAbilityEffect { validTypes.addAll(CardType.Constant.CREATURE_TYPES); kindOfType = "creature"; } - changedTypeWordOriginal = sa.getActivatingPlayer().getController().chooseSomeType(kindOfType, sa, validTypes, Lists.newArrayList()); + changedTypeWordOriginal = sa.getActivatingPlayer().getController().chooseSomeType(kindOfType, sa, validTypes, Lists.newArrayList()); } else { changedTypeWordOriginal = changedTypeWordsArray[0]; } validTypes.clear(); - final List forbiddenTypes = sa.hasParam("ForbiddenNewTypes") ? Lists.newArrayList(sa.getParam("ForbiddenNewTypes").split(",")) : Lists.newArrayList(); + final List forbiddenTypes = sa.hasParam("ForbiddenNewTypes") ? Lists.newArrayList(sa.getParam("ForbiddenNewTypes").split(",")) : Lists.newArrayList(); forbiddenTypes.add(changedTypeWordOriginal); if (changedTypeWordsArray[1].startsWith("Choose")) { if (changedTypeWordsArray[1].equals("ChooseBasicLandType")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 58220d302fb..8cbf3f0ba5b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -908,7 +908,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect { } if (totalcmc != null) { if (totcmc >= 0) { - fetchList = CardLists.getValidCards(fetchList, "Card.cmcLE" + Integer.toString(totcmc), source.getController(), source); + fetchList = CardLists.getValidCards(fetchList, "Card.cmcLE" + totcmc, source.getController(), source); } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java index 5d7083bf5ab..d87d9da4b85 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java @@ -98,7 +98,7 @@ public class ChooseCardEffect extends SpellAbilityEffect { int chosenP = 0; while (!creature.isEmpty()) { Card c = p.getController().chooseSingleEntityForEffect(creature, sa, - "Select creature(s) with total power less than or equal to " + Integer.toString(totP - chosenP - negativeNum) + "Select creature(s) with total power less than or equal to " + (totP - chosenP - negativeNum) + "\r\n(Selected:" + chosenPool + ")\r\n" + "(Total Power: " + chosenP + ")", chosenP <= totP); if (c == null) { if (p.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, "Cancel Choose?")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java index 93e5b3bca09..9073e1a9342 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java @@ -30,14 +30,14 @@ public class ChooseGenericEffect extends SpellAbilityEffect { public void resolve(SpellAbility sa) { final Card host = sa.getHostCard(); - final List abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices")); + final List abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices")); final SpellAbility fallback = sa.getAdditionalAbility("FallbackAbility"); final List tgtPlayers = getDefinedPlayersOrTargeted(sa); for (final Player p : tgtPlayers) { // determine if any of the choices are not valid - List saToRemove = Lists.newArrayList(); + List saToRemove = Lists.newArrayList(); for (SpellAbility saChoice : abilities) { if (!saChoice.getRestrictions().checkOtherRestrictions(host, saChoice, sa.getActivatingPlayer()) ) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java index 19933d913e2..950643e4a9c 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java @@ -124,7 +124,7 @@ public class CloneEffect extends SpellAbilityEffect { } if (!pumpKeywords.isEmpty()) { - tgtCard.addChangedCardKeywords(pumpKeywords, Lists.newArrayList(), false, false, ts); + tgtCard.addChangedCardKeywords(pumpKeywords, Lists.newArrayList(), false, false, ts); } tgtCard.updateStateForView(); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java index 9844f1dd6a2..ec26b621f1d 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ControlGainEffect.java @@ -142,7 +142,7 @@ public class ControlGainEffect extends SpellAbilityEffect { } if (!kws.isEmpty()) { - tgtC.addChangedCardKeywords(kws, Lists.newArrayList(), false, false, tStamp); + tgtC.addChangedCardKeywords(kws, Lists.newArrayList(), false, false, tStamp); game.fireEvent(new GameEventCardStatsChanged(tgtC)); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 2ecdfcfd620..612737941e8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -192,7 +192,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect { copyInPlay.setCloneOrigin(host); if (!pumpKeywords.isEmpty()) { - copyInPlay.addChangedCardKeywords(pumpKeywords, Lists.newArrayList(), false, false, timestamp); + copyInPlay.addChangedCardKeywords(pumpKeywords, Lists.newArrayList(), false, false, timestamp); } crds.add(copyInPlay); if (sa.hasParam("RememberCopied")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java index 15a4a69bcf2..5338477cae1 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java @@ -32,7 +32,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect { int amount = 0; if (!num.equals("All") && !num.equals("Remembered")) { amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa); - }; + } sb.append("Remove "); if (sa.hasParam("UpTo")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java index d3c5ab0bc4c..33cd4a6aaf7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java @@ -30,9 +30,7 @@ public class DelayedTriggerEffect extends SpellAbilityEffect { @Override public void resolve(SpellAbility sa) { Map mapParams = Maps.newHashMap(sa.getMapParams()); - if (mapParams.containsKey("Cost")) { - mapParams.remove("Cost"); - } + mapParams.remove("Cost"); if (mapParams.containsKey("SpellDescription")) { mapParams.put("TriggerDescription", mapParams.get("SpellDescription")); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ImmediateTriggerEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ImmediateTriggerEffect.java index a96057b6c34..8fe2f8b4813 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ImmediateTriggerEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ImmediateTriggerEffect.java @@ -29,9 +29,7 @@ public class ImmediateTriggerEffect extends SpellAbilityEffect { public void resolve(SpellAbility sa) { Map mapParams = Maps.newHashMap(sa.getMapParams()); - if (mapParams.containsKey("Cost")) { - mapParams.remove("Cost"); - } + mapParams.remove("Cost"); if (mapParams.containsKey("SpellDescription")) { mapParams.put("TriggerDescription", mapParams.get("SpellDescription")); diff --git a/forge-game/src/main/java/forge/game/ability/effects/LifeLoseEffect.java b/forge-game/src/main/java/forge/game/ability/effects/LifeLoseEffect.java index d4af63d3a8e..39693308a68 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/LifeLoseEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/LifeLoseEffect.java @@ -43,12 +43,12 @@ public class LifeLoseEffect extends SpellAbilityEffect { lifeLost += p.loseLife(lifeAmount); } } - sa.getHostCard().setSVar("AFLifeLost", "Number$" + Integer.toString(lifeLost)); + sa.getHostCard().setSVar("AFLifeLost", "Number$" + lifeLost); // Exceptional case for Extort: must propagate the amount of life lost to subability, // otherwise the first Extort trigger per game won't work if (sa.getSubAbility() != null && ApiType.GainLife.equals(sa.getSubAbility().getApi())) { - sa.getSubAbility().setSVar("AFLifeLost", "Number$" + Integer.toString(lifeLost)); + sa.getSubAbility().setSVar("AFLifeLost", "Number$" + lifeLost); } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java index 2a09ba0eb5b..8929a776217 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java @@ -123,7 +123,7 @@ public class ProtectAllEffect extends SpellAbilityEffect { final List playerList = AbilityUtils.getDefinedPlayers(host, players, sa); for (final Player player : playerList) { for (final String gain : gains) { - player.addChangedKeywords(ImmutableList.of("Protection from " + gain), ImmutableList.of(), timestamp); + player.addChangedKeywords(ImmutableList.of("Protection from " + gain), ImmutableList.of(), timestamp); } if (!sa.hasParam("Permanent")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java index 3b2b1fe6445..df30dea7f34 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java @@ -27,7 +27,7 @@ public class ProtectEffect extends SpellAbilityEffect { protected String getStackDescription(SpellAbility sa) { final List gains = getProtectionList(sa); - final boolean choose = (sa.hasParam("Choices")) ? true : false; + final boolean choose = sa.hasParam("Choices"); final String joiner = choose ? "or" : "and"; final StringBuilder sb = new StringBuilder(); diff --git a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java index 591dcf525ad..c20bd2828c7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java @@ -60,7 +60,7 @@ public class PumpEffect extends SpellAbilityEffect { redrawPT = true; } - gameCard.addChangedCardKeywords(kws, Lists.newArrayList(), false, false, timestamp); + gameCard.addChangedCardKeywords(kws, Lists.newArrayList(), false, false, timestamp); if (redrawPT) { gameCard.updatePowerToughnessForView(); } @@ -106,7 +106,7 @@ public class PumpEffect extends SpellAbilityEffect { && !(host.isInPlay() || host.isInZone(ZoneType.Stack))) { return; } - p.addChangedKeywords(keywords, ImmutableList.of(), timestamp); + p.addChangedKeywords(keywords, ImmutableList.of(), timestamp); if (!sa.hasParam("Permanent")) { // If not Permanent, remove Pumped at EOT @@ -252,7 +252,7 @@ public class PumpEffect extends SpellAbilityEffect { if (defined.equals("ChosenType")) { replaced = host.getChosenType(); } else if (defined.equals("CardUIDSource")) { - replaced = "CardUID_" + String.valueOf(host.getId()); + replaced = "CardUID_" + host.getId(); } else if (defined.equals("ActivatorName")) { replaced = sa.getActivatingPlayer().getName(); } @@ -277,9 +277,7 @@ public class PumpEffect extends SpellAbilityEffect { if (sa.hasParam("NoRepetition")) { for (KeywordInterface inst : tgtCards.get(0).getKeywords()) { final String kws = inst.getOriginal(); - if (total.contains(kws)) { - total.remove(kws); - } + total.remove(kws); } } final int min = Math.min(total.size(), numkw); 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 366eb1c8680..1ee0b0f0f17 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -113,7 +113,7 @@ public class Card extends GameEntity implements Comparable { private final Map mayPlay = Maps.newHashMap(); - private final Multimap withFlash = HashMultimap.create(); + private final Multimap withFlash = HashMultimap.create(); // changes by AF animate and continuous static effects - timestamp is the key of maps private final Map changedCardTypes = Maps.newTreeMap(); @@ -1196,9 +1196,7 @@ public class Card extends GameEntity implements Comparable { if (type == CounterType.DREAM) { // need to be done extra because it is also a state based action - if (hasKeyword("CARDNAME can't have more than seven dream counters on it.") && getCounters(CounterType.DREAM) > 6) { - return false; - } + return !hasKeyword("CARDNAME can't have more than seven dream counters on it.") || getCounters(CounterType.DREAM) <= 6; } return true; } @@ -1709,7 +1707,7 @@ public class Card extends GameEntity implements Comparable { sbLong.append(sbx).append("\r\n"); } } else if (keyword.startsWith("Hexproof:")) { - final String k[] = keyword.split(":"); + final String[] k = keyword.split(":"); sbLong.append("Hexproof from ").append(k[2]) .append(" (").append(inst.getReminderText()).append(")").append("\r\n"); } else if (keyword.endsWith(".") && !keyword.startsWith("Haunt")) { @@ -1803,7 +1801,7 @@ public class Card extends GameEntity implements Comparable { } else if (keyword.equals("AllNonLegendaryCreatureNames")) { sbLong.append(getName()).append(" has all names of nonlegendary creature cards.\r\n"); } else if (keyword.startsWith("IfReach")) { - String k[] = keyword.split(":"); + String[] k = keyword.split(":"); sbLong.append(getName()).append(" can block ") .append(CardType.getPluralType(k[1])) .append(" as though it had reach.\r\n"); @@ -1813,7 +1811,7 @@ public class Card extends GameEntity implements Comparable { String desc = AbilityFactory.getMapParams(getSVar(k[1])).get("SpellDescription"); sbLong.append(desc); } else if (keyword.startsWith("Saga")) { - String k[] = keyword.split(":"); + String[] k = keyword.split(":"); String desc = "(As this Saga enters and after your draw step, " + " add a lore counter. Sacrifice after " + Strings.repeat("I", Integer.valueOf(k[1])) + ".)"; sbLong.append(desc); @@ -2201,7 +2199,7 @@ public class Card extends GameEntity implements Comparable { if (n.length > 3) { desc = n[3]; } else { - String k[] = n[1].split(","); + String[] k = n[1].split(","); for (int i = 0; i < k.length; i++) { if (CardType.isACardType(k[i])) { k[i] = k[i].toLowerCase(); @@ -3392,7 +3390,7 @@ public class Card extends GameEntity implements Comparable { } @Override public String toString() { - return TextUtil.concatWithSpace("c:"+String.valueOf(currentValue),"tb:"+String.valueOf(tempBoost),"bfc:"+String.valueOf(bonusFromCounters)); + return TextUtil.concatWithSpace("c:"+ currentValue,"tb:"+ tempBoost,"bfc:"+ bonusFromCounters); } } @@ -4785,7 +4783,7 @@ public class Card extends GameEntity implements Comparable { CardCollection newCardsInCommand = (CardCollection)getGame().getCardsIn(ZoneType.Command); newCardsInCommand.removeAll(cardsInCommand); if (!newCardsInCommand.isEmpty()) { - newCardsInCommand.get(0).setSVar("PreventedDamage", "Number$" + Integer.toString(dmgToBePrevented)); + newCardsInCommand.get(0).setSVar("PreventedDamage", "Number$" + dmgToBePrevented); } } subtractPreventNextDamageWithEffect(shieldSource, restDamage); @@ -5080,7 +5078,7 @@ public class Card extends GameEntity implements Comparable { addChangedCardTypes(new CardType(Collections.singletonList("Aura")), new CardType(Collections.singletonList("Creature")), false, false, false, false, false, false, true, bestowTimestamp, updateView); - addChangedCardKeywords(Collections.singletonList("Enchant creature"), Lists.newArrayList(), + addChangedCardKeywords(Collections.singletonList("Enchant creature"), Lists.newArrayList(), false, false, bestowTimestamp, updateView); } @@ -5384,7 +5382,7 @@ public class Card extends GameEntity implements Comparable { switch (kw.getOriginal()) { case "Shroud": StringBuilder sb = new StringBuilder(); - sb.append("Can target CardUID_").append(String.valueOf(getId())); + sb.append("Can target CardUID_").append(getId()); sb.append(" with spells and abilities as though it didn't have shroud."); if (sa.getActivatingPlayer() == null) { System.err.println("Unexpected behavior: SA activator was null when trying to determine if the activating player could target a card with Shroud. SA host card = " + source + ", SA = " + sa); @@ -5447,9 +5445,7 @@ public class Card extends GameEntity implements Comparable { } // check valid - if (!isValid(tgt.getValidTgts(), aura.getController(), aura, sa)) { - return false; - } + return isValid(tgt.getValidTgts(), aura.getController(), aura, sa); } return true; @@ -5457,18 +5453,12 @@ public class Card extends GameEntity implements Comparable { @Override protected final boolean canBeEquippedBy(final Card equip) { - if (!isCreature() || !isInPlay()) { - return false; - } - return true; + return isCreature() && isInPlay(); } @Override protected boolean canBeFortifiedBy(final Card fort) { - if (!isLand() || !isInPlay() || fort.isLand()) { - return false; - } - return true; + return isLand() && isInPlay() && !fort.isLand(); } /* (non-Javadoc) @@ -5727,11 +5717,7 @@ public class Card extends GameEntity implements Comparable { } } - if (!getController().canSacrificeBy(source)) { - return false; - } - - return true; + return getController().canSacrificeBy(source); } public CardRules getRules() { @@ -6130,10 +6116,7 @@ public class Card extends GameEntity implements Comparable { if (hasKeyword(Keyword.FLASH)) { return true; } - if (withFlash.containsValue(p)) { - return true; - } - return false; + return withFlash.containsValue(p); } public void addWithFlash(Long timestamp, Iterable players) { @@ -6170,11 +6153,7 @@ public class Card extends GameEntity implements Comparable { return false; } - if (!getOwner().canDiscardBy(sa)) { - return false; - } - - return true; + return getOwner().canDiscardBy(sa); } public void addAbilityActivated(SpellAbility ability) { diff --git a/forge-game/src/main/java/forge/game/card/CardFactory.java b/forge-game/src/main/java/forge/game/card/CardFactory.java index 2a69b3e4567..98dab46962d 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactory.java +++ b/forge-game/src/main/java/forge/game/card/CardFactory.java @@ -645,7 +645,7 @@ public class CardFactory { Trigger t = null; if (sa.isWrapper()) { // copy trigger? - t = ((WrappedAbility) sa).getTrigger(); + t = sa.getTrigger(); } else { // some keyword ability, e.g. Exalted, Annihilator return sa.copy(); } @@ -677,7 +677,7 @@ public class CardFactory { WrappedAbility wrapperAbility = new WrappedAbility(t, trig, ((WrappedAbility) sa).getDecider()); wrapperAbility.setTrigger(true); - wrapperAbility.setMandatory(((WrappedAbility) sa).isMandatory()); + wrapperAbility.setMandatory(sa.isMandatory()); wrapperAbility.setDescription(wrapperAbility.getStackDescription()); t.setTriggeredSA(wrapperAbility); return wrapperAbility; @@ -774,7 +774,7 @@ public class CardFactory { // triggers to add to clone if (sa.hasParam("AddTriggers")) { - for (final String s : Arrays.asList(sa.getParam("AddTriggers").split(","))) { + for (final String s : sa.getParam("AddTriggers").split(",")) { if (origSVars.containsKey(s)) { final String actualTrigger = origSVars.get(s); final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, out, true); @@ -786,7 +786,7 @@ public class CardFactory { // SVars to add to clone if (sa.hasParam("AddSVars") || sa.hasParam("GainTextSVars")) { final String str = sa.getParamOrDefault("GainTextSVars", sa.getParam("AddSVars")); - for (final String s : Arrays.asList(str.split(","))) { + for (final String s : str.split(",")) { if (origSVars.containsKey(s)) { final String actualsVar = origSVars.get(s); state.setSVar(s, actualsVar); @@ -797,7 +797,7 @@ public class CardFactory { // abilities to add to clone if (sa.hasParam("AddAbilities") || sa.hasParam("GainTextAbilities")) { final String str = sa.getParamOrDefault("GainTextAbilities", sa.getParam("AddAbilities")); - for (final String s : Arrays.asList(str.split(","))) { + for (final String s : str.split(",")) { if (origSVars.containsKey(s)) { final String actualAbility = origSVars.get(s); final SpellAbility grantedAbility = AbilityFactory.getAbility(actualAbility, out); diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index bf22da56bb6..3c2413b6ed6 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -147,7 +147,7 @@ public class CardFactoryUtil { sbCost.append("— "); } // get rid of the ": " at the end - sbCost.append(costDesc.substring(0, costDesc.length() - 2)); + sbCost.append(costDesc, 0, costDesc.length() - 2); StringBuilder sb = new StringBuilder(); sb.append("ST$ SetState | Cost$ ").append(costStr).append(" | CostDesc$ ").append(sbCost); @@ -292,11 +292,7 @@ public class CardFactoryUtil { * @return a boolean. */ public static boolean isCounterable(final Card c) { - if (c.hasKeyword("CARDNAME can't be countered.") || !c.getCanCounter()) { - return false; - } - - return true; + return !c.hasKeyword("CARDNAME can't be countered.") && c.getCanCounter(); } /** @@ -318,7 +314,7 @@ public class CardFactoryUtil { for (KeywordInterface k : c.getKeywords()) { final String o = k.getOriginal(); if (o.startsWith("CantBeCounteredBy")) { - final String m[] = o.split(":"); + final String[] m = o.split(":"); if (sa.isValid(m[1].split(","), c.getController(), c, null)) { return false; } @@ -2186,12 +2182,12 @@ public class CardFactoryUtil { final String abStringAfflict = "DB$ LoseLife | Defined$ TriggeredDefendingPlayer" + " | LifeAmount$ " + n; - final Trigger afflictTrigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic); + final Trigger afflictTrigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic); afflictTrigger.setOverridingAbility(AbilityFactory.getAbility(abStringAfflict, card)); inst.addTrigger(afflictTrigger); } else if (keyword.startsWith("Afterlife")) { - final String k[] = keyword.split(":"); + final String[] k = keyword.split(":"); final String name = StringUtils.join(k, " "); final StringBuilder sb = new StringBuilder(); @@ -2435,7 +2431,7 @@ public class CardFactoryUtil { final String effect = "DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | " + "CounterNum$ 1 | Evolve$ True"; - final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic); + final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic); trigger.setOverridingAbility(AbilityFactory.getAbility(effect, card)); inst.addTrigger(trigger); @@ -2731,7 +2727,7 @@ public class CardFactoryUtil { " | TriggerDescription$ Melee (" + inst.getReminderText() + ")"; final String effect = "DB$ Pump | Defined$ TriggeredAttackerLKICopy | NumAtt$ MeleeX | NumDef$ MeleeX"; - final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic); + final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic); SpellAbility sa = AbilityFactory.getAbility(effect, card); sa.setSVar("MeleeX", "TriggeredPlayersDefenders$Amount"); @@ -2746,7 +2742,7 @@ public class CardFactoryUtil { final String effect = "DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 1" + " | ValidTgts$ Creature.attacking+powerLTX" + " | TgtPrompt$ Select target attacking creature with less power"; - final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic); + final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic); SpellAbility sa = AbilityFactory.getAbility(effect, card); sa.setSVar("X", "Count$CardPower"); @@ -2854,7 +2850,7 @@ public class CardFactoryUtil { final String trigStr = "Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | Secondary$ True" + " | TriggerZones$ Battlefield | TriggerDescription$ Poisonous " + n + " (" + inst.getReminderText() + ")"; - final Trigger parsedTrigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic); + final Trigger parsedTrigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic); final String effect = "DB$ Poison | Defined$ TriggeredTarget | Num$ " + n; parsedTrigger.setOverridingAbility(AbilityFactory.getAbility(effect, card)); @@ -2902,7 +2898,7 @@ public class CardFactoryUtil { final String effect = "DB$ Pump | Defined$ TriggeredAttackerLKICopy" + " | NumAtt$ Rampage" + n + " | NumDef$ Rampage" + n; - final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic); + final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic); SpellAbility sa = AbilityFactory.getAbility(effect, card); sa.setSVar("Rampage" + n, "SVar$RampageCount/Times." + n); @@ -3070,7 +3066,7 @@ public class CardFactoryUtil { inst.addTrigger(parsedTrigger); } else if (keyword.startsWith("Suspend")) { //upkeep trigger - StringBuilder upkeepTrig = new StringBuilder();; + StringBuilder upkeepTrig = new StringBuilder(); upkeepTrig.append("Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Exile "); upkeepTrig.append(" | IsPresent$ Card.Self+suspended | PresentZone$ Exile"); @@ -3201,7 +3197,7 @@ public class CardFactoryUtil { SpellAbility saDelay = AbilityFactory.getAbility(strDelay, card); saDelay.setAdditionalAbility("Execute", (AbilitySub) AbilityFactory.getAbility(strSac, card)); - final Trigger trigger = TriggerHandler.parseTrigger(strTrig.toString(), card, intrinsic); + final Trigger trigger = TriggerHandler.parseTrigger(strTrig, card, intrinsic); trigger.setOverridingAbility(saDelay); inst.addTrigger(trigger); } @@ -3404,7 +3400,7 @@ public class CardFactoryUtil { sb.append("| ValidStackSa$ Spell.Flashback | Description$ Flashback"); if (keyword.contains(":")) { - final String k[] = keyword.split(":"); + final String[] k = keyword.split(":"); final Cost cost = new Cost(k[1], false); sb.append( cost.isOnlyManaCost() ? " " : "—"); @@ -3896,7 +3892,7 @@ public class CardFactoryUtil { // Add the Epic effect as a subAbility String dbStr = "DB$ Effect | Triggers$ EpicTrigger | SVars$ EpicCopy | StaticAbilities$ EpicCantBeCast | Duration$ Permanent | Epic$ True"; - final AbilitySub newSA = (AbilitySub) AbilityFactory.getAbility(dbStr.toString(), card); + final AbilitySub newSA = (AbilitySub) AbilityFactory.getAbility(dbStr, card); newSA.setSVar("EpicCantBeCast", "Mode$ CantBeCast | ValidCard$ Card | Caster$ You | EffectZone$ Command | Description$ For the rest of the game, you can't cast spells."); newSA.setSVar("EpicTrigger", "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ EpicCopy | TriggerDescription$ " @@ -3964,7 +3960,7 @@ public class CardFactoryUtil { // don't use SimpleString there because it does has "and" between cost i dont want that costStr = cost.toString(); // but now it has ": " at the end i want to remove - sb.append("| CostDesc$ ").append(costStr.substring(0, costStr.length() - 2)); + sb.append("| CostDesc$ ").append(costStr, 0, costStr.length() - 2); if (!cost.isOnlyManaCost()) { sb.append("."); } @@ -4542,7 +4538,7 @@ public class CardFactoryUtil { final StringBuilder sbValid = new StringBuilder(); if (!keyword.equals("Hexproof")) { - final String k[] = keyword.split(":"); + final String[] k = keyword.split(":"); sbDesc.append(" from ").append(k[2]); sbValid.append("| ValidSource$ ").append(k[1]); diff --git a/forge-game/src/main/java/forge/game/card/CardPlayOption.java b/forge-game/src/main/java/forge/game/card/CardPlayOption.java index 3c53c4d0e35..b7531dde10d 100644 --- a/forge-game/src/main/java/forge/game/card/CardPlayOption.java +++ b/forge-game/src/main/java/forge/game/card/CardPlayOption.java @@ -11,7 +11,7 @@ public final class CardPlayOption { /** Indicates the mana cost must be paid. */ YES, /** Indicates the mana cost may not be paid. */ - NO; + NO } private final Player player; diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index 5d5a415af5c..4f4d00b2010 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -214,7 +214,7 @@ public final class CardPredicates { return c.canBeSacrificedBy(sa); } }; - }; + } public static final Predicate canBeAttached(final Card aura) { return new Predicate() { @@ -223,7 +223,7 @@ public final class CardPredicates { return c.canBeAttached(aura); } }; - }; + } public static final Predicate isColor(final byte color) { return new Predicate() { 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 74112fa659e..5be3ea783c9 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -38,21 +38,13 @@ public class CardProperty { // by name can also have color names, so needs to happen before colors. if (property.startsWith("named")) { String name = TextUtil.fastReplace(property.substring(5), ";", ","); // for some legendary cards - if (!card.sharesNameWith(name)) { - return false; - } + return card.sharesNameWith(name); } else if (property.startsWith("notnamed")) { - if (card.sharesNameWith(property.substring(8))) { - return false; - } + return !card.sharesNameWith(property.substring(8)); } else if (property.startsWith("sameName")) { - if (!card.sharesNameWith(source)) { - return false; - } + return card.sharesNameWith(source); } else if (property.equals("NamedCard")) { - if (!card.sharesNameWith(source.getNamedCard())) { - return false; - } + return card.sharesNameWith(source.getNamedCard()); } else if (property.equals("NamedByRememberedPlayer")) { if (!source.hasRemembered()) { final Card newCard = game.getCardState(source); @@ -72,41 +64,23 @@ public class CardProperty { } } } else if (property.equals("Permanent")) { - if (card.isInstant() || card.isSorcery()) { - return false; - } + return !card.isInstant() && !card.isSorcery(); } else if (property.equals("Historic")) { - if (!card.isHistoric()) { - return false; - } + return card.isHistoric(); } else if (property.startsWith("CardUID_")) {// Protection with "doesn't remove effect" - if (card.getId() != Integer.parseInt(property.split("CardUID_")[1])) { - return false; - } + return card.getId() == Integer.parseInt(property.split("CardUID_")[1]); } else if (property.equals("ChosenCard")) { - if (!source.hasChosenCard(card)) { - return false; - } + return source.hasChosenCard(card); } else if (property.equals("nonChosenCard")) { - if (source.hasChosenCard(card)) { - return false; - } + return !source.hasChosenCard(card); } else if (property.equals("DoubleFaced")) { - if (!card.isDoubleFaced()) { - return false; - } + return card.isDoubleFaced(); } else if (property.equals("Flip")) { - if (!card.isFlipCard()) { - return false; - } + return card.isFlipCard(); } else if (property.equals("Split")) { - if (!card.isSplitCard()) { - return false; - } + return card.isSplitCard(); } else if (property.equals("NotSplit")) { - if (card.isSplitCard()) { - return false; - } + return !card.isSplitCard(); } else if (property.startsWith("leftcmc") || property.startsWith("rightcmc")) { int x; int y = 0; @@ -126,29 +100,17 @@ public class CardProperty { x = AbilityUtils.calculateAmount(source, rhs, spellAbility); } - if (!Expressions.compare(y, property, x)) { - return false; - } + return Expressions.compare(y, property, x); } else if (property.startsWith("YouCtrl")) { - if (!controller.equals(sourceController)) { - return false; - } + return controller.equals(sourceController); } else if (property.startsWith("YourTeamCtrl")) { - if (controller.getTeam() != sourceController.getTeam()) { - return false; - } + return controller.getTeam() == sourceController.getTeam(); } else if (property.startsWith("YouDontCtrl")) { - if (controller.equals(sourceController)) { - return false; - } + return !controller.equals(sourceController); } else if (property.startsWith("OppCtrl")) { - if (!controller.getOpponents().contains(sourceController)) { - return false; - } + return controller.getOpponents().contains(sourceController); } else if (property.startsWith("ChosenCtrl")) { - if (!controller.equals(source.getChosenPlayer())) { - return false; - } + return controller.equals(source.getChosenPlayer()); } else if (property.startsWith("DefenderCtrl")) { if (!game.getPhaseHandler().inCombat()) { return false; @@ -157,29 +119,21 @@ public class CardProperty { if (!source.hasRemembered()) { return false; } - if (combat.getDefendingPlayerRelatedTo((Card) source.getFirstRemembered()) != controller) { - return false; - } + return combat.getDefendingPlayerRelatedTo((Card) source.getFirstRemembered()) == controller; } else { - if (combat.getDefendingPlayerRelatedTo(source) != controller) { - return false; - } + return combat.getDefendingPlayerRelatedTo(source) == controller; } } else if (property.startsWith("DefendingPlayer")) { Player p = property.endsWith("Ctrl") ? controller : card.getOwner(); if (!game.getPhaseHandler().inCombat()) { return false; } - if (!combat.isPlayerAttacked(p)) { - return false; - } + return combat.isPlayerAttacked(p); } else if (property.startsWith("EnchantedPlayer")) { Player p = property.endsWith("Ctrl") ? controller : card.getOwner(); final Object o = source.getEntityAttachedTo(); if (o instanceof Player) { - if (!p.equals(o)) { - return false; - } + return p.equals(o); } else { // source not enchanting a player return false; } @@ -187,9 +141,7 @@ public class CardProperty { Player p = property.endsWith("Ctrl") ? controller : card.getOwner(); final Object o = source.getEntityAttachedTo(); if (o instanceof Card) { - if (!p.equals(((Card) o).getController())) { - return false; - } + return p.equals(((Card) o).getController()); } else { // source not enchanting a card return false; } @@ -202,9 +154,7 @@ public class CardProperty { } } - if (!source.isRemembered(p)) { - return false; - } + return source.isRemembered(p); } else if (property.startsWith("nonRememberedPlayerCtrl")) { if (!source.hasRemembered()) { final Card newCard = game.getCardState(source); @@ -213,9 +163,7 @@ public class CardProperty { } } - if (source.isRemembered(controller)) { - return false; - } + return !source.isRemembered(controller); } else if (property.equals("TargetedPlayerCtrl")) { boolean foundTargetingSA = false; for (final SpellAbility sa : source.getCurrentState().getNonManaAbilities()) { @@ -269,25 +217,15 @@ public class CardProperty { } } } else if (property.startsWith("ActivePlayerCtrl")) { - if (!game.getPhaseHandler().isPlayerTurn(controller)) { - return false; - } + return game.getPhaseHandler().isPlayerTurn(controller); } else if (property.startsWith("NonActivePlayerCtrl")) { - if (game.getPhaseHandler().isPlayerTurn(controller)) { - return false; - } + return !game.getPhaseHandler().isPlayerTurn(controller); } else if (property.startsWith("YouOwn")) { - if (!card.getOwner().equals(sourceController)) { - return false; - } + return card.getOwner().equals(sourceController); } else if (property.startsWith("YouDontOwn")) { - if (card.getOwner().equals(sourceController)) { - return false; - } + return !card.getOwner().equals(sourceController); } else if (property.startsWith("OppOwn")) { - if (!card.getOwner().getOpponents().contains(sourceController)) { - return false; - } + return card.getOwner().getOpponents().contains(sourceController); } else if (property.equals("TargetedPlayerOwn")) { boolean foundTargetingSA = false; for (final SpellAbility sa : source.getCurrentState().getNonManaAbilities()) { @@ -324,49 +262,33 @@ public class CardProperty { final String valid = property.substring(8); if (!card.getOwner().isValid(valid, sourceController, source, spellAbility)) { final List lp = AbilityUtils.getDefinedPlayers(source, valid, spellAbility); - if (!lp.contains(card.getOwner())) { - return false; - } + return lp.contains(card.getOwner()); } } else if (property.startsWith("ControlledBy")) { final String valid = property.substring(13); if (!controller.isValid(valid, sourceController, source, spellAbility)) { final List lp = AbilityUtils.getDefinedPlayers(source, valid, spellAbility); - if (!lp.contains(controller)) { - return false; - } + return lp.contains(controller); } } else if (property.startsWith("OwnerDoesntControl")) { - if (card.getOwner().equals(controller)) { - return false; - } + return !card.getOwner().equals(controller); } else if (property.startsWith("ControllerControls")) { final String type = property.substring(18); if (type.startsWith("AtLeastAsMany")) { String realType = type.split("AtLeastAsMany")[1]; CardCollectionView cards = CardLists.getType(controller.getCardsIn(ZoneType.Battlefield), realType); CardCollectionView yours = CardLists.getType(sourceController.getCardsIn(ZoneType.Battlefield), realType); - if (cards.size() < yours.size()) { - return false; - } + return cards.size() >= yours.size(); } else { final CardCollectionView cards = controller.getCardsIn(ZoneType.Battlefield); - if (CardLists.getType(cards, type).isEmpty()) { - return false; - } + return !CardLists.getType(cards, type).isEmpty(); } } else if (property.startsWith("Other")) { - if (card.equals(source)) { - return false; - } + return !card.equals(source); } else if (property.startsWith("StrictlySelf")) { - if (!card.equals(source) || card.getTimestamp() != source.getTimestamp()) { - return false; - } + return card.equals(source) && card.getTimestamp() == source.getTimestamp(); } else if (property.startsWith("Self")) { - if (!card.equals(source)) { - return false; - } + return card.equals(source); } else if (property.startsWith("ExiledWithSource")) { if (card.getExiledWith() == null) { return false; @@ -381,33 +303,21 @@ public class CardProperty { } } - if (!card.getExiledWith().equals(host)) { - return false; - } + return card.getExiledWith().equals(host); } else if (property.equals("EncodedWithSource")) { - if (!card.getEncodedCards().contains(source)) { - return false; - } + return card.getEncodedCards().contains(source); } else if (property.equals("EffectSource")) { if (!source.isEmblem() && !source.getType().hasSubtype("Effect")) { return false; } - if (!card.equals(source.getEffectSource())) { - return false; - } + return card.equals(source.getEffectSource()); } else if (property.equals("CanBeSacrificedBy")) { - if (!card.canBeSacrificedBy(spellAbility)) { - return false; - } + return card.canBeSacrificedBy(spellAbility); } else if (property.startsWith("AttachedBy")) { - if (!card.hasCardAttachment(source)) { - return false; - } + return card.hasCardAttachment(source); } else if (property.equals("Attached")) { - if (!source.hasCardAttachment(card)) { - return false; - } + return source.hasCardAttachment(card); } else if (property.startsWith("AttachedTo")) { final String restriction = property.split("AttachedTo ")[1]; if (restriction.equals("Targeted")) { @@ -433,24 +343,16 @@ public class CardProperty { return false; } } else { - if ((card.getEntityAttachedTo() == null || !card.getEntityAttachedTo().isValid(restriction, sourceController, source, spellAbility))) { - return false; - } + return (card.getEntityAttachedTo() != null && card.getEntityAttachedTo().isValid(restriction, sourceController, source, spellAbility)); } } else if (property.equals("NameNotEnchantingEnchantedPlayer")) { Player enchantedPlayer = source.getPlayerAttachedTo(); - if (enchantedPlayer == null || enchantedPlayer.isEnchantedBy(card.getName())) { - return false; - } + return enchantedPlayer != null && !enchantedPlayer.isEnchantedBy(card.getName()); } else if (property.equals("NotAttachedTo")) { - if (source.hasCardAttachment(card)) { - return false; - } + return !source.hasCardAttachment(card); } else if (property.startsWith("EnchantedBy")) { if (property.equals("EnchantedBy")) { - if (!card.isEnchantedBy(source) && !card.equals(source.getEntityAttachedTo())) { - return false; - } + return card.isEnchantedBy(source) || card.equals(source.getEntityAttachedTo()); } else { final String restriction = property.split("EnchantedBy ")[1]; switch (restriction) { @@ -495,14 +397,10 @@ public class CardProperty { } } } else { - if (card.isEnchantedBy(source)) { - return false; - } + return !card.isEnchantedBy(source); } } else if (property.startsWith("Enchanted")) { - if (!source.equals(card.getEntityAttachedTo())) { - return false; - } + return source.equals(card.getEntityAttachedTo()); } else if (property.startsWith("CanEnchant")) { final String restriction = property.substring(10); if (restriction.equals("Remembered")) { @@ -511,7 +409,7 @@ public class CardProperty { return false; } } else if (restriction.equals("Source")) { - if (!source.canBeAttached(card)) return false; + return source.canBeAttached(card); } } else if (property.startsWith("CanBeEnchantedBy")) { if (property.substring(16).equals("Targeted")) { @@ -535,9 +433,7 @@ public class CardProperty { } } } else { - if (!card.canBeAttached(source)) { - return false; - } + return card.canBeAttached(source); } } else if (property.startsWith("EquippedBy")) { if (property.substring(10).equals("Targeted")) { @@ -552,74 +448,44 @@ public class CardProperty { } } } else if (property.substring(10).equals("Enchanted")) { - if (source.getEnchantingCard() == null || - !card.hasCardAttachment(source.getEnchantingCard())) { - return false; - } + return source.getEnchantingCard() != null && + card.hasCardAttachment(source.getEnchantingCard()); } else { - if (!card.hasCardAttachment(source)) { - return false; - } + return card.hasCardAttachment(source); } } else if (property.startsWith("FortifiedBy")) { - if (!card.hasCardAttachment(source)) { - return false; - } + return card.hasCardAttachment(source); } else if (property.startsWith("CanBeAttachedBy")) { - if (!card.canBeAttached(source)) { - return false; - } + return card.canBeAttached(source); } else if (property.startsWith("Equipped")) { - if (!source.hasCardAttachment(card)) { - return false; - } + return source.hasCardAttachment(card); } else if (property.startsWith("Fortified")) { // FIXME TODO what property has this? - if (!source.hasCardAttachment(card)) { - return false; - } + return source.hasCardAttachment(card); } else if (property.startsWith("HauntedBy")) { - if (!card.isHauntedBy(source)) { - return false; - } + return card.isHauntedBy(source); } else if (property.startsWith("notTributed")) { - if (card.isTributed()) { - return false; - } + return !card.isTributed(); } else if (property.startsWith("madness")) { - if (!card.isMadness()) { - return false; - } + return card.isMadness(); } else if (property.contains("Paired")) { if (property.contains("With")) { // PairedWith - if (!card.isPaired() || card.getPairedWith() != source) { - return false; - } + return card.isPaired() && card.getPairedWith() == source; } else if (property.startsWith("Not")) { // NotPaired - if (card.isPaired()) { - return false; - } + return !card.isPaired(); } else { // Paired - if (!card.isPaired()) { - return false; - } + return card.isPaired(); } } else if (property.startsWith("Above")) { // "Are Above" Source final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Graveyard); - if (cards.indexOf(source) >= cards.indexOf(card)) { - return false; - } + return cards.indexOf(source) < cards.indexOf(card); } else if (property.startsWith("DirectlyAbove")) { // "Are Directly Above" Source final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Graveyard); - if (cards.indexOf(card) - cards.indexOf(source) != 1) { - return false; - } + return cards.indexOf(card) - cards.indexOf(source) == 1; } else if (property.startsWith("TopGraveyardCreature")) { CardCollection cards = CardLists.filter(card.getOwner().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); Collections.reverse(cards); - if (cards.isEmpty() || !card.equals(cards.get(0))) { - return false; - } + return !cards.isEmpty() && card.equals(cards.get(0)); } else if (property.startsWith("TopGraveyard")) { final CardCollection cards = new CardCollection(card.getOwner().getCardsIn(ZoneType.Graveyard)); Collections.reverse(cards); @@ -630,28 +496,18 @@ public class CardProperty { for (int i = 0; i < num; i++) { newlist.add(cards.get(i)); } - if (cards.isEmpty() || !newlist.contains(card)) { - return false; - } + return !cards.isEmpty() && newlist.contains(card); } else { - if (cards.isEmpty() || !card.equals(cards.get(0))) { - return false; - } + return !cards.isEmpty() && card.equals(cards.get(0)); } } else if (property.startsWith("BottomGraveyard")) { final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Graveyard); - if (cards.isEmpty() || !card.equals(cards.get(0))) { - return false; - } + return !cards.isEmpty() && card.equals(cards.get(0)); } else if (property.startsWith("TopLibrary")) { final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Library); - if (cards.isEmpty() || !card.equals(cards.get(0))) { - return false; - } + return !cards.isEmpty() && card.equals(cards.get(0)); } else if (property.startsWith("Cloned")) { - if ((card.getCloneOrigin() == null) || !card.getCloneOrigin().equals(source)) { - return false; - } + return (card.getCloneOrigin() != null) && card.getCloneOrigin().equals(source); } else if (property.startsWith("DamagedBy")) { if ((property.endsWith("Source") || property.equals("DamagedBy")) && !card.getReceivedDamageFromThisTurn().containsKey(source)) { @@ -664,21 +520,16 @@ public class CardProperty { } matched |= card.getReceivedDamageFromThisTurn().containsKey(obj); } - if (!matched) - return false; + return matched; } else if (property.endsWith("Equipped")) { final Card equipee = source.getEquipping(); - if (equipee == null || !card.getReceivedDamageFromThisTurn().containsKey(equipee)) - return false; + return equipee != null && card.getReceivedDamageFromThisTurn().containsKey(equipee); } else if (property.endsWith("Enchanted")) { final Card equipee = source.getEnchantingCard(); - if (equipee == null || !card.getReceivedDamageFromThisTurn().containsKey(equipee)) - return false; + return equipee != null && card.getReceivedDamageFromThisTurn().containsKey(equipee); } } else if (property.startsWith("Damaged")) { - if (!card.getDealtDamageToThisTurn().containsKey(source)) { - return false; - } + return card.getDealtDamageToThisTurn().containsKey(source); } else if (property.startsWith("IsTargetingSource")) { for (final SpellAbility sa : card.getCurrentState().getNonManaAbilities()) { final SpellAbility saTargeting = sa.getSATargetingCard(); @@ -693,9 +544,7 @@ public class CardProperty { return false; } else if (property.startsWith("SharesCMCWith")) { if (property.equals("SharesCMCWith")) { - if (!card.sharesCMCWith(source)) { - return false; - } + return card.sharesCMCWith(source); } else { final String restriction = property.split("SharesCMCWith ")[1]; CardCollection list = AbilityUtils.getDefinedCards(source, restriction, spellAbility); @@ -703,9 +552,7 @@ public class CardProperty { } } else if (property.startsWith("SharesColorWith")) { if (property.equals("SharesColorWith")) { - if (!card.sharesColorWith(source)) { - return false; - } + return card.sharesColorWith(source); } else { final String restriction = property.split("SharesColorWith ")[1]; if (restriction.startsWith("Remembered") || restriction.startsWith("Imprinted")) { @@ -766,9 +613,7 @@ public class CardProperty { return ColorSet.fromMask(mostProm).hasAnyColor(MagicColor.fromName(color)); } else if (property.startsWith("notSharesColorWith")) { if (property.equals("notSharesColorWith")) { - if (card.sharesColorWith(source)) { - return false; - } + return !card.sharesColorWith(source); } else { final String restriction = property.split("notSharesColorWith ")[1]; for (final Card c : sourceController.getCardsIn(ZoneType.Battlefield)) { @@ -779,9 +624,7 @@ public class CardProperty { } } else if (property.startsWith("sharesCreatureTypeWith")) { if (property.equals("sharesCreatureTypeWith")) { - if (!card.sharesCreatureTypeWith(source)) { - return false; - } + return card.sharesCreatureTypeWith(source); } else { final String restriction = property.split("sharesCreatureTypeWith ")[1]; switch (restriction) { @@ -814,10 +657,7 @@ public class CardProperty { } break; case "Equipped": - if (source.isEquipping() && card.sharesCreatureTypeWith(source.getEquipping())) { - return true; - } - return false; + return source.isEquipping() && card.sharesCreatureTypeWith(source.getEquipping()); case "Remembered": for (final Object rem : source.getRemembered()) { if (rem instanceof Card) { @@ -853,9 +693,7 @@ public class CardProperty { } } else if (property.startsWith("sharesCardTypeWith")) { if (property.equals("sharesCardTypeWith")) { - if (!card.sharesCardTypeWith(source)) { - return false; - } + return card.sharesCardTypeWith(source); } else { final String restriction = property.split("sharesCardTypeWith ")[1]; switch (restriction) { @@ -879,10 +717,7 @@ public class CardProperty { if (!(triggeringObject instanceof Card)) { return false; } - if (card.sharesCardTypeWith((Card) triggeringObject)) { - return true; - } - return false; + return card.sharesCardTypeWith((Card) triggeringObject); case "EachTopLibrary": final CardCollection cards = new CardCollection(); for (Player p : game.getPlayers()) { @@ -898,13 +733,9 @@ public class CardProperty { } } } else if (property.equals("sharesPermanentTypeWith")) { - if (!card.sharesPermanentTypeWith(source)) { - return false; - } + return card.sharesPermanentTypeWith(source); } else if (property.equals("canProduceSameManaTypeWith")) { - if (!card.canProduceSameManaTypeWith(source)) { - return false; - } + return card.canProduceSameManaTypeWith(source); } else if (property.startsWith("canProduceManaColor")) { final String color = property.split("canProduceManaColor ")[1]; for (SpellAbility ma : card.getManaAbilities()) { @@ -917,9 +748,7 @@ public class CardProperty { return !card.getManaAbilities().isEmpty(); } else if (property.startsWith("sharesNameWith")) { if (property.equals("sharesNameWith")) { - if (!card.sharesNameWith(source)) { - return false; - } + return card.sharesNameWith(source); } else { final String restriction = property.split("sharesNameWith ")[1]; if (restriction.equals("YourGraveyard")) { @@ -959,18 +788,14 @@ public class CardProperty { System.out.println("Looking at TriggeredCard but no SA?"); } else { Card triggeredCard = ((Card)spellAbility.getTriggeringObject("Card")); - if (triggeredCard != null && card.sharesNameWith(triggeredCard)) { - return true; - } + return triggeredCard != null && card.sharesNameWith(triggeredCard); } return false; } } } else if (property.startsWith("doesNotShareNameWith")) { if (property.equals("doesNotShareNameWith")) { - if (card.sharesNameWith(source)) { - return false; - } + return !card.sharesNameWith(source); } else { final String restriction = property.split("doesNotShareNameWith ")[1]; if (restriction.startsWith("Remembered") || restriction.startsWith("Imprinted")) { @@ -993,9 +818,7 @@ public class CardProperty { } } else if (property.startsWith("sharesControllerWith")) { if (property.equals("sharesControllerWith")) { - if (!card.sharesControllerWith(source)) { - return false; - } + return card.sharesControllerWith(source); } else { final String restriction = property.split("sharesControllerWith ")[1]; if (restriction.startsWith("Remembered") || restriction.startsWith("Imprinted")) { @@ -1005,9 +828,7 @@ public class CardProperty { } } else if (property.startsWith("sharesOwnerWith")) { if (property.equals("sharesOwnerWith")) { - if (!card.getOwner().equals(source.getOwner())) { - return false; - } + return card.getOwner().equals(source.getOwner()); } else { final String restriction = property.split("sharesOwnerWith ")[1]; if (restriction.equals("Remembered")) { @@ -1026,9 +847,7 @@ public class CardProperty { if (cards.size() < 2) { return false; } - else if (cards.get(1) != card) { - return false; - } + else return cards.get(1) == card; } else if (property.equals("ThisTurnCast")) { for (final Card c : CardUtil.getThisTurnCast("Card", source)) { if (card.equals(c)) { @@ -1046,18 +865,14 @@ public class CardProperty { } CardCollectionView cards = CardUtil.getThisTurnEntered(destination, origin, "Card", source); - if (!cards.contains(card)) { - return false; - } + return cards.contains(card); } else if (property.equals("DiscardedThisTurn")) { if (card.getTurnInZone() != game.getPhaseHandler().getTurn()) { return false; } CardCollectionView cards = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Hand, "Card", source); - if (!cards.contains(card) && !card.getMadnessWithoutCast()) { - return false; - } + return cards.contains(card) || card.getMadnessWithoutCast(); } else if (property.startsWith("ControlledByPlayerInTheDirection")) { final String restrictions = property.split("ControlledByPlayerInTheDirection_")[1]; final String[] res = restrictions.split("_"); @@ -1073,93 +888,53 @@ public class CardProperty { } else { p = sourceController; } - if (p == null || !controller.equals(game.getNextPlayerAfter(p, direction))) { - return false; - } + return p != null && controller.equals(game.getNextPlayerAfter(p, direction)); } else if (property.startsWith("hasKeyword")) { // "withFlash" would find Flashback cards, add this to fix Mystical Teachings - if (!card.hasKeyword(property.substring(10))) { - return false; - } + return card.hasKeyword(property.substring(10)); } else if (property.startsWith("withFlashback")) { boolean fb = card.hasKeyword(Keyword.FLASHBACK); - if (!fb) { - return false; - } + return fb; } else if (property.startsWith("with")) { // ... Card keywords if (property.startsWith("without") && card.hasStartOfUnHiddenKeyword(property.substring(7))) { return false; } - if (!property.startsWith("without") && !card.hasStartOfUnHiddenKeyword(property.substring(4))) { - return false; - } + return property.startsWith("without") || card.hasStartOfUnHiddenKeyword(property.substring(4)); } else if (property.startsWith("tapped")) { - if (!card.isTapped()) { - return false; - } + return card.isTapped(); } else if (property.startsWith("untapped")) { - if (!card.isUntapped()) { - return false; - } + return card.isUntapped(); } else if (property.startsWith("faceDown")) { - if (!card.isFaceDown()) { - return false; - } + return card.isFaceDown(); } else if (property.startsWith("faceUp")) { - if (card.isFaceDown()) { - return false; - } + return !card.isFaceDown(); } else if (property.startsWith("manifested")) { - if (!card.isManifested()) { - return false; - } + return card.isManifested(); } else if (property.startsWith("DrawnThisTurn")) { - if (!card.getDrawnThisTurn()) { - return false; - } + return card.getDrawnThisTurn(); } else if (property.startsWith("enteredBattlefieldThisTurn")) { - if (!(card.getTurnInZone() == game.getPhaseHandler().getTurn())) { - return false; - } + return card.getTurnInZone() == game.getPhaseHandler().getTurn(); } else if (property.startsWith("notEnteredBattlefieldThisTurn")) { - if (card.getTurnInZone() == game.getPhaseHandler().getTurn()) { - return false; - } + return card.getTurnInZone() != game.getPhaseHandler().getTurn(); } else if (property.startsWith("firstTurnControlled")) { - if (!card.isFirstTurnControlled()) { - return false; - } + return card.isFirstTurnControlled(); } else if (property.startsWith("notFirstTurnControlled")) { - if (card.isFirstTurnControlled()) { - return false; - } + return !card.isFirstTurnControlled(); } else if (property.startsWith("startedTheTurnUntapped")) { - if (!card.hasStartedTheTurnUntapped()) { - return false; - } + return card.hasStartedTheTurnUntapped(); } else if (property.startsWith("cameUnderControlSinceLastUpkeep")) { - if (!card.cameUnderControlSinceLastUpkeep()) { - return false; - } + return card.cameUnderControlSinceLastUpkeep(); } else if (property.equals("attackedOrBlockedSinceYourLastUpkeep")) { - if (!card.getDamageHistory().hasAttackedSinceLastUpkeepOf(sourceController) - && !card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController)) { - return false; - } + return card.getDamageHistory().hasAttackedSinceLastUpkeepOf(sourceController) + || card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController); } else if (property.equals("blockedOrBeenBlockedSinceYourLastUpkeep")) { - if (!card.getDamageHistory().hasBeenBlockedSinceLastUpkeepOf(sourceController) - && !card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController)) { - return false; - } + return card.getDamageHistory().hasBeenBlockedSinceLastUpkeepOf(sourceController) + || card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController); } else if (property.startsWith("dealtDamageToYouThisTurn")) { - if (!card.getDamageHistory().getThisTurnDamaged().contains(sourceController)) { - return false; - } + return card.getDamageHistory().getThisTurnDamaged().contains(sourceController); } else if (property.startsWith("dealtDamageToOppThisTurn")) { - if (!card.hasDealtDamageToOpponentThisTurn()) { - return false; - } + return card.hasDealtDamageToOpponentThisTurn(); } else if (property.startsWith("dealtCombatDamageThisTurn ") || property.startsWith("notDealtCombatDamageThisTurn ")) { final String v = property.split(" ")[1]; final List list = card.getDamageHistory().getThisTurnCombatDamaged(); @@ -1170,9 +945,7 @@ public class CardProperty { break; } } - if (found == property.startsWith("not")) { - return false; - } + return found != property.startsWith("not"); } else if (property.startsWith("dealtCombatDamageThisCombat ") || property.startsWith("notDealtCombatDamageThisCombat ")) { final String v = property.split(" ")[1]; final List list = card.getDamageHistory().getThisCombatDamaged(); @@ -1183,53 +956,31 @@ public class CardProperty { break; } } - if (found == property.startsWith("not")) { - return false; - } + return found != property.startsWith("not"); } else if (property.startsWith("controllerWasDealtCombatDamageByThisTurn")) { - if (!source.getDamageHistory().getThisTurnCombatDamaged().contains(controller)) { - return false; - } + return source.getDamageHistory().getThisTurnCombatDamaged().contains(controller); } else if (property.startsWith("controllerWasDealtDamageByThisTurn")) { - if (!source.getDamageHistory().getThisTurnDamaged().contains(controller)) { - return false; - } + return source.getDamageHistory().getThisTurnDamaged().contains(controller); } else if (property.startsWith("wasDealtDamageThisTurn")) { - if ((card.getReceivedDamageFromThisTurn().keySet()).isEmpty()) { - return false; - } + return !(card.getReceivedDamageFromThisTurn().keySet()).isEmpty(); } else if (property.startsWith("dealtDamageThisTurn")) { - if (card.getTotalDamageDoneBy() == 0) { - return false; - } + return card.getTotalDamageDoneBy() != 0; } else if (property.startsWith("attackedThisTurn")) { - if (!card.getDamageHistory().getCreatureAttackedThisTurn()) { - return false; - } + return card.getDamageHistory().getCreatureAttackedThisTurn(); } else if (property.startsWith("attackedLastTurn")) { return card.getDamageHistory().getCreatureAttackedLastTurnOf(controller); } else if (property.startsWith("blockedThisTurn")) { - if (!card.getDamageHistory().getCreatureBlockedThisTurn()) { - return false; - } + return card.getDamageHistory().getCreatureBlockedThisTurn(); } else if (property.startsWith("notExertedThisTurn")) { - if (card.getExertedThisTurn() > 0) { - return false; - } + return card.getExertedThisTurn() <= 0; } else if (property.startsWith("gotBlockedThisTurn")) { - if (!card.getDamageHistory().getCreatureGotBlockedThisTurn()) { - return false; - } + return card.getDamageHistory().getCreatureGotBlockedThisTurn(); } else if (property.startsWith("notAttackedThisTurn")) { - if (card.getDamageHistory().getCreatureAttackedThisTurn()) { - return false; - } + return !card.getDamageHistory().getCreatureAttackedThisTurn(); } else if (property.startsWith("notAttackedLastTurn")) { return !card.getDamageHistory().getCreatureAttackedLastTurnOf(controller); } else if (property.startsWith("notBlockedThisTurn")) { - if (card.getDamageHistory().getCreatureBlockedThisTurn()) { - return false; - } + return !card.getDamageHistory().getCreatureBlockedThisTurn(); } else if (property.startsWith("greatestPower")) { CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES); if (property.contains("ControlledBy")) { @@ -1280,9 +1031,7 @@ public class CardProperty { cards = CardLists.getType(cards, prop); } cards = CardLists.getCardsWithHighestCMC(cards); - if (!cards.contains(card)) { - return false; - } + return cards.contains(card); } else if (property.startsWith("greatestRememberedCMC")) { CardCollection cards = new CardCollection(); for (final Object o : source.getRemembered()) { @@ -1294,9 +1043,7 @@ public class CardProperty { return false; } cards = CardLists.getCardsWithHighestCMC(cards); - if (!cards.contains(card)) { - return false; - } + return cards.contains(card); } else if (property.startsWith("lowestRememberedCMC")) { CardCollection cards = new CardCollection(); for (final Object o : source.getRemembered()) { @@ -1308,9 +1055,7 @@ public class CardProperty { return false; } cards = CardLists.getCardsWithLowestCMC(cards); - if (!cards.contains(card)) { - return false; - } + return cards.contains(card); } else if (property.startsWith("lowestCMC")) { final CardCollectionView cards = game.getCardsIn(ZoneType.Battlefield); @@ -1323,74 +1068,40 @@ public class CardProperty { } } } else if (property.startsWith("enchanted")) { - if (!card.isEnchanted()) { - return false; - } + return card.isEnchanted(); } else if (property.startsWith("unenchanted")) { - if (card.isEnchanted()) { - return false; - } + return !card.isEnchanted(); } else if (property.startsWith("enchanting")) { - if (!card.isEnchanting()) { - return false; - } + return card.isEnchanting(); } else if (property.startsWith("equipped")) { - if (!card.isEquipped()) { - return false; - } + return card.isEquipped(); } else if (property.startsWith("unequipped")) { - if (card.isEquipped()) { - return false; - } + return !card.isEquipped(); } else if (property.startsWith("equipping")) { - if (!card.isEquipping()) { - return false; - } + return card.isEquipping(); } else if (property.startsWith("notEquipping")) { - if (card.isEquipping()) { - return false; - } + return !card.isEquipping(); } else if (property.startsWith("token")) { - if (!card.isToken()) { - return false; - } + return card.isToken(); } else if (property.startsWith("nonToken")) { - if (card.isToken()) { - return false; - } + return !card.isToken(); } else if (property.startsWith("hasXCost")) { SpellAbility sa1 = card.getFirstSpellAbility(); - if (sa1 != null && !sa1.isXCost()) { - return false; - } + return sa1 == null || sa1.isXCost(); } else if (property.startsWith("suspended")) { - if (!card.hasSuspend()) { - return false; - } + return card.hasSuspend(); } else if (property.startsWith("delved")) { - if (!source.getDelved().contains(card)) { - return false; - } + return source.getDelved().contains(card); } else if (property.startsWith("convoked")) { - if (!source.getConvoked().contains(card)) { - return false; - } + return source.getConvoked().contains(card); } else if (property.startsWith("exploited")) { - if (!source.getExploited().contains(card)) { - return false; - } + return source.getExploited().contains(card); } else if (property.startsWith("unequalPT")) { - if (card.getNetPower() == card.getNetToughness()) { - return false; - } + return card.getNetPower() != card.getNetToughness(); } else if (property.equals("powerGTtoughness")) { - if (card.getNetPower() <= card.getNetToughness()) { - return false; - } + return card.getNetPower() > card.getNetToughness(); } else if (property.equals("powerLTtoughness")) { - if (card.getNetPower() >= card.getNetToughness()) { - return false; - } + return card.getNetPower() < card.getNetToughness(); } else if (property.startsWith("power") || property.startsWith("toughness") || property.startsWith("cmc") || property.startsWith("totalPT")) { int x; @@ -1416,9 +1127,7 @@ public class CardProperty { x = AbilityUtils.calculateAmount(source, rhs, spellAbility); } - if (!Expressions.compare(y, property, x)) { - return false; - } + return Expressions.compare(y, property, x); } // syntax example: countersGE9 P1P1 or countersLT12TIME (greater number @@ -1454,9 +1163,7 @@ public class CardProperty { final int actualnumber = card.getCounters(CounterType.getType(counterType)); - if (!Expressions.compare(actualnumber, comparator, number)) { - return false; - } + return Expressions.compare(actualnumber, comparator, number); } // These predicated refer to ongoing combat. If no combat happens, they'll return false (meaning not attacking/blocking ATM) else if (property.startsWith("attacking")) { @@ -1466,26 +1173,18 @@ public class CardProperty { if (property.equals("attackingYou")) return combat.isAttacking(card, sourceController); if (property.equals("attackingYouOrYourPW")) { Player defender = combat.getDefenderPlayerByAttacker(card); - if (!sourceController.equals(defender)) { - return false; - } + return sourceController.equals(defender); } } else if (property.startsWith("notattacking")) { return null == combat || !combat.isAttacking(card); } else if (property.equals("attackedThisCombat")) { - if (null == combat || !card.getDamageHistory().getCreatureAttackedThisCombat()) { - return false; - } + return null != combat && card.getDamageHistory().getCreatureAttackedThisCombat(); } else if (property.equals("blockedThisCombat")) { - if (null == combat || !card.getDamageHistory().getCreatureBlockedThisCombat()) { - return false; - } + return null != combat && card.getDamageHistory().getCreatureBlockedThisCombat(); } else if (property.equals("attackedBySourceThisCombat")) { if (null == combat) return false; final GameEntity defender = combat.getDefenderByAttacker(source); - if (defender instanceof Card && !card.equals(defender)) { - return false; - } + return !(defender instanceof Card) || card.equals(defender); } else if (property.startsWith("blocking")) { if (null == combat) return false; String what = property.substring("blocking".length()); @@ -1512,9 +1211,7 @@ public class CardProperty { CardCollection sourceBlocking = new CardCollection(combat.getAttackersBlockedBy(source)); CardCollection thisBlocking = new CardCollection(combat.getAttackersBlockedBy(card)); - if (Collections.disjoint(sourceBlocking, thisBlocking)) { - return false; - } + return !Collections.disjoint(sourceBlocking, thisBlocking); } else if (property.startsWith("notblocking")) { return null == combat || !combat.isBlocking(card); } @@ -1585,35 +1282,27 @@ public class CardProperty { } return false; } else if (property.startsWith("unblocked")) { - if (combat == null || !combat.isUnblocked(card)) { - return false; - } + return combat != null && combat.isUnblocked(card); } else if (property.equals("attackersBandedWith")) { if (card.equals(source)) { // You don't band with yourself return false; } AttackingBand band = combat == null ? null : combat.getBandOfAttacker(source); - if (band == null || !band.getAttackers().contains(card)) { - return false; - } + return band != null && band.getAttackers().contains(card); } else if (property.startsWith("kicked")) { if (property.equals("kicked")) { - if (card.getKickerMagnitude() == 0) { - return false; - } + return card.getKickerMagnitude() != 0; } else { String s = property.split("kicked ")[1]; if ("1".equals(s) && !card.isOptionalCostPaid(OptionalCost.Kicker1)) return false; - if ("2".equals(s) && !card.isOptionalCostPaid(OptionalCost.Kicker2)) return false; + return !"2".equals(s) || card.isOptionalCostPaid(OptionalCost.Kicker2); } } else if (property.startsWith("notkicked")) { - if (card.getKickerMagnitude() > 0) { - return false; - } + return card.getKickerMagnitude() <= 0; } else if (property.startsWith("pseudokicked")) { if (property.equals("pseudokicked")) { - if (!card.isOptionalCostPaid(OptionalCost.Generic)) return false; + return card.isOptionalCostPaid(OptionalCost.Generic); } } else if (property.startsWith("surged")) { if (card.getCastSA() == null) { @@ -1641,33 +1330,19 @@ public class CardProperty { } return card.getCastSA().isSpectacle(); } else if (property.equals("HasDevoured")) { - if (card.getDevouredCards().isEmpty()) { - return false; - } + return !card.getDevouredCards().isEmpty(); } else if (property.equals("HasNotDevoured")) { - if (!card.getDevouredCards().isEmpty()) { - return false; - } + return card.getDevouredCards().isEmpty(); } else if (property.equals("IsMonstrous")) { - if (!card.isMonstrous()) { - return false; - } + return card.isMonstrous(); } else if (property.equals("IsNotMonstrous")) { - if (card.isMonstrous()) { - return false; - } + return !card.isMonstrous(); } else if (property.equals("IsUnearthed")) { - if (!card.isUnearthed()) { - return false; - } + return card.isUnearthed(); } else if (property.equals("IsRenowned")) { - if (!card.isRenowned()) { - return false; - } + return card.isRenowned(); } else if (property.equals("IsNotRenowned")) { - if (card.isRenowned()) { - return false; - } + return !card.isRenowned(); } else if (property.startsWith("RememberMap")) { System.out.println(source.getRememberMap()); for (SpellAbility sa : source.getSpellAbilities()) { @@ -1682,93 +1357,59 @@ public class CardProperty { } return false; } else if (property.equals("IsRemembered")) { - if (!source.isRemembered(card)) { - return false; - } + return source.isRemembered(card); } else if (property.equals("IsNotRemembered")) { - if (source.isRemembered(card)) { - return false; - } + return !source.isRemembered(card); } else if (property.equals("IsImprinted")) { - if (!source.hasImprintedCard(card)) { - return false; - } + return source.hasImprintedCard(card); } else if (property.equals("IsNotImprinted")) { - if (source.hasImprintedCard(card)) { - return false; - } + return !source.hasImprintedCard(card); } else if (property.equals("NoAbilities")) { - if (!((card.getAbilityText().trim().equals("") || card.isFaceDown()) && (card.getUnhiddenKeywords().isEmpty()))) { - return false; - } + return (card.getAbilityText().trim().equals("") || card.isFaceDown()) && (card.getUnhiddenKeywords().isEmpty()); } else if (property.equals("HasCounters")) { - if (!card.hasCounters()) { - return false; - } + return card.hasCounters(); } else if (property.equals("NoCounters")) { - if (card.hasCounters()) { - return false; - } + return !card.hasCounters(); } else if (property.startsWith("CastSa")) { SpellAbility castSA = card.getCastSA(); if (castSA == null) { return false; } String v = property.substring(7); - if (!castSA.isValid(v, sourceController, source, spellAbility)) { - return false; - } + return castSA.isValid(v, sourceController, source, spellAbility); } else if (property.equals("wasCast")) { - if (null == card.getCastFrom()) { - return false; - } + return null != card.getCastFrom(); } else if (property.equals("wasNotCast")) { - if (null != card.getCastFrom()) { - return false; - } + return null == card.getCastFrom(); } else if (property.startsWith("wasCastFrom")) { // How are we getting in here with a comma? final String strZone = property.split(",")[0].substring(11); final ZoneType realZone = ZoneType.smartValueOf(strZone); - if (realZone != card.getCastFrom()) { - return false; - } + return realZone == card.getCastFrom(); } else if (property.startsWith("wasNotCastFrom")) { final String strZone = property.substring(14); final ZoneType realZone = ZoneType.smartValueOf(strZone); - if (realZone == card.getCastFrom()) { - return false; - } + return realZone != card.getCastFrom(); } else if (property.startsWith("set")) { final String setCode = property.substring(3, 6); - if (!card.getSetCode().equals(setCode)) { - return false; - } + return card.getSetCode().equals(setCode); } else if (property.startsWith("inZone")) { final String strZone = property.substring(6); final ZoneType realZone = ZoneType.smartValueOf(strZone); // lki last zone does fall back to this zone final Zone lkiZone = lki.getLastKnownZone(); - - if (lkiZone == null || !lkiZone.is(realZone)) { - return false; - } + + return lkiZone != null && lkiZone.is(realZone); } else if (property.startsWith("inRealZone")) { final String strZone = property.substring(10); final ZoneType realZone = ZoneType.smartValueOf(strZone); - if (!card.isInZone(realZone)) { - return false; - } + return card.isInZone(realZone); } else if (property.equals("IsCommander")) { - if (!card.isCommander()) { - return false; - } + return card.isCommander(); } else { // StringType done in CardState - if (!card.getCurrentState().hasProperty(property, sourceController, source, spellAbility)) { - return false; - } + return card.getCurrentState().hasProperty(property, sourceController, source, spellAbility); } return true; } diff --git a/forge-game/src/main/java/forge/game/card/CardState.java b/forge-game/src/main/java/forge/game/card/CardState.java index dbe4ca1546b..b2b4d60e72a 100644 --- a/forge-game/src/main/java/forge/game/card/CardState.java +++ b/forge-game/src/main/java/forge/game/card/CardState.java @@ -471,9 +471,7 @@ public class CardState extends GameObject { view.updateFoilIndex(card.getState(CardStateName.Original)); } public final void removeSVar(final String var) { - if (sVars.containsKey(var)) { - sVars.remove(var); - } + sVars.remove(var); } public final int getFoil() { diff --git a/forge-game/src/main/java/forge/game/card/CardUtil.java b/forge-game/src/main/java/forge/game/card/CardUtil.java index 014515eb063..8d0c2000fff 100644 --- a/forge-game/src/main/java/forge/game/card/CardUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardUtil.java @@ -80,7 +80,7 @@ public final class CardUtil { } public static boolean isStackingKeyword(final String keyword) { - String kw = new String(keyword); + String kw = keyword; if (kw.startsWith("HIDDEN")) { kw = kw.substring(7); } @@ -345,7 +345,7 @@ public final class CardUtil { // a nice entry point with minimum parameters public static Set getReflectableManaColors(final SpellAbility sa) { - return getReflectableManaColors(sa, sa, Sets.newHashSet(), new CardCollection()); + return getReflectableManaColors(sa, sa, Sets.newHashSet(), new CardCollection()); } private static Set getReflectableManaColors(final SpellAbility abMana, final SpellAbility sa, @@ -390,9 +390,7 @@ public final class CardUtil { // remove anything cards that is already in parents for (final Card p : parents) { - if (cards.contains(p)) { - cards.remove(p); - } + cards.remove(p); } if ((cards.size() == 0) && !reflectProperty.equals("Produced")) { @@ -506,9 +504,7 @@ public final class CardUtil { // Remove cards already targeted final List targeted = Lists.newArrayList(ability.getTargets().getTargetCards()); for (final Card c : targeted) { - if (choices.contains(c)) { - choices.remove(c); - } + choices.remove(c); } // Remove cards exceeding total CMC diff --git a/forge-game/src/main/java/forge/game/card/CardView.java b/forge-game/src/main/java/forge/game/card/CardView.java index 5afd53b06ca..8762d2816d2 100644 --- a/forge-game/src/main/java/forge/game/card/CardView.java +++ b/forge-game/src/main/java/forge/game/card/CardView.java @@ -345,10 +345,7 @@ public class CardView extends GameEntityView { return true; } col = get(TrackableProperty.PlayerMayLookTemp); - if (col != null && col.contains(pv)) { - return true; - } - return false; + return col != null && col.contains(pv); } void setPlayerMayLook(Player p, boolean mayLook, boolean temp) { TrackableProperty prop = temp ? TrackableProperty.PlayerMayLookTemp : TrackableProperty.PlayerMayLook; @@ -380,7 +377,7 @@ public class CardView extends GameEntityView { return Iterables.any(viewers, new Predicate() { public final boolean apply(final PlayerView input) { return canBeShownTo(input); - }; + } }); } @@ -462,10 +459,7 @@ public class CardView extends GameEntityView { if (mindSlaveMaster != null && canFaceDownBeShownTo(mindSlaveMaster)) { return true; } - if (isInZone(EnumSet.of(ZoneType.Battlefield, ZoneType.Stack, ZoneType.Sideboard)) && getController().equals(viewer)) { - return true; - } - return false; + return isInZone(EnumSet.of(ZoneType.Battlefield, ZoneType.Stack, ZoneType.Sideboard)) && getController().equals(viewer); } public FCollectionView getEncodedCards() { @@ -1067,7 +1061,7 @@ public class CardView extends GameEntityView { TrackableCollection views = get(key); if (views == null) { views = new TrackableCollection(); - views.add(cardToAdd.getView());; + views.add(cardToAdd.getView()); set(key, views); } else if (views.add(cardToAdd.getView())) { diff --git a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java index 5d4ff3b79aa..4abd4a7447e 100644 --- a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java +++ b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java @@ -320,7 +320,7 @@ public class TokenInfo { if (!CardUtil.isKeywordModifiable(o)) { continue; } - String r = new String(o); + String r = o; // replace types for (final Map.Entry e : typeMap.entrySet()) { final String key = e.getKey(); diff --git a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java index c3420217e83..f7b59f9413f 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -94,7 +94,7 @@ public class AttackConstraints { final int globalMax = globalRestrictions.getMax(); final int myMax = Ints.min(globalMax == -1 ? Integer.MAX_VALUE : globalMax, possibleAttackers.size()); if (myMax == 0) { - return Pair.of(Collections.emptyMap(), Integer.valueOf(0)); + return Pair.of(Collections.emptyMap(), Integer.valueOf(0)); } final MapToAmount> possible = new LinkedHashMapToAmount>(); @@ -163,8 +163,8 @@ public class AttackConstraints { // Now try all others (plus empty attack) and count their violations final FCollection> legalAttackers = collectLegalAttackers(reqs, myMax); possible.putAll(Maps.asMap(legalAttackers.asSet(), FN_COUNT_VIOLATIONS)); - if (countViolations(Collections.emptyMap()) != -1) { - possible.put(Collections.emptyMap(), countViolations(Collections.emptyMap())); + if (countViolations(Collections.emptyMap()) != -1) { + possible.put(Collections.emptyMap(), countViolations(Collections.emptyMap())); } // take the case with the fewest violations @@ -173,7 +173,7 @@ public class AttackConstraints { private final FCollection> collectLegalAttackers(final List reqs, final int maximum) { return new FCollection> - (collectLegalAttackers(Collections.emptyMap(), deepClone(reqs), new CardCollection(), maximum)); + (collectLegalAttackers(Collections.emptyMap(), deepClone(reqs), new CardCollection(), maximum)); } private final List> collectLegalAttackers(final Map attackers, final List reqs, final CardCollection reserved, final int maximum) { diff --git a/forge-game/src/main/java/forge/game/combat/AttackRequirement.java b/forge-game/src/main/java/forge/game/combat/AttackRequirement.java index c02701595d3..8c40d44d7e6 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRequirement.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRequirement.java @@ -80,7 +80,7 @@ public class AttackRequirement { for (Card pw : CardLists.filter(c.getController().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANESWALKERS)) { // Add the attack alternatives that suffice (planeswalkers that can be attacked instead of the player) if (!defenderSpecificAlternatives.containsKey(c.getController())) { - defenderSpecificAlternatives.put(c.getController(), Lists.newArrayList()); + defenderSpecificAlternatives.put(c.getController(), Lists.newArrayList()); } defenderSpecificAlternatives.get(c.getController()).add(pw); } @@ -147,7 +147,7 @@ public class AttackRequirement { int violations = 0; // first. check to see if "must attack X or Y with at least one creature" requirements are satisfied - List toRemoveFromDefSpecific = Lists.newArrayList(); + List toRemoveFromDefSpecific = Lists.newArrayList(); if (!defenderOrPWSpecific.isEmpty()) { for (GameEntity def : defenderOrPWSpecific.keySet()) { if (defenderSpecificAlternatives.containsKey(def)) { diff --git a/forge-game/src/main/java/forge/game/combat/Combat.java b/forge-game/src/main/java/forge/game/combat/Combat.java index bc5441689ea..4299ce1eede 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -54,8 +54,8 @@ public class Combat { private final FCollection attackableEntries = new FCollection(); // Keyed by attackable defender (player or planeswalker) - private final Multimap attackedByBands = Multimaps.synchronizedMultimap(ArrayListMultimap.create()); - private final Multimap blockedBands = Multimaps.synchronizedMultimap(ArrayListMultimap.create()); + private final Multimap attackedByBands = Multimaps.synchronizedMultimap(ArrayListMultimap.create()); + private final Multimap blockedBands = Multimaps.synchronizedMultimap(ArrayListMultimap.create()); private final Map defendingDamageMap = Maps.newHashMap(); @@ -353,7 +353,7 @@ public class Combat { public final boolean isBlocked(final Card attacker) { AttackingBand band = getBandOfAttacker(attacker); - return band == null ? false : Boolean.TRUE.equals(band.isBlocked()); + return band != null && Boolean.TRUE.equals(band.isBlocked()); } // Some cards in Alpha may UNBLOCK an attacker, so second parameter is not always-true @@ -804,7 +804,7 @@ public class Combat { for (final Entry entry : defendingDamageMap.entrySet()) { GameEntity defender = getDefenderByAttacker(entry.getKey()); if (defender instanceof Player) { // player - ((Player) defender).addCombatDamage(entry.getValue(), entry.getKey(), dealtDamageTo, preventMap, counterTable); + defender.addCombatDamage(entry.getValue(), entry.getKey(), dealtDamageTo, preventMap, counterTable); } else if (defender instanceof Card) { // planeswalker ((Card) defender).getController().addCombatDamage(entry.getValue(), entry.getKey(), dealtDamageTo, preventMap, counterTable); @@ -843,7 +843,7 @@ public class Combat { public final boolean isUnblocked(final Card att) { AttackingBand band = getBandOfAttacker(att); - return band == null ? false : Boolean.FALSE.equals(band.isBlocked()); + return band != null && Boolean.FALSE.equals(band.isBlocked()); } public final CardCollection getUnblockedAttackers() { @@ -875,7 +875,7 @@ public class Combat { public boolean isBlocking(Card blocker) { if (blockedBands.containsValue(blocker)) { return true; // is blocking something at the moment - }; + } CombatLki lki = lkiCache.get(blocker); return null != lki && !lki.isAttacker; // was blocking something anyway diff --git a/forge-game/src/main/java/forge/game/combat/CombatLki.java b/forge-game/src/main/java/forge/game/combat/CombatLki.java index 128718a3d25..682265f0a18 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatLki.java +++ b/forge-game/src/main/java/forge/game/combat/CombatLki.java @@ -14,7 +14,7 @@ public class CombatLki { public CombatLki(boolean isAttacker, FCollectionView relatedBands) { this.isAttacker = isAttacker; - this.relatedBands = new FCollection(relatedBands);; + this.relatedBands = new FCollection(relatedBands); } public AttackingBand getFirstBand() { diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index 1b88c16440f..0273d3a03cb 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -426,11 +426,7 @@ public class CombatUtil { } final List list = blocker.getController().getCreaturesInPlay(); - if (list.size() < 2 && blocker.hasKeyword("CARDNAME can't attack or block alone.")) { - return false; - } - - return true; + return list.size() >= 2 || !blocker.hasKeyword("CARDNAME can't attack or block alone."); } public static boolean canBlockMoreCreatures(final Card blocker, final CardCollectionView blockedBy) { @@ -500,8 +496,7 @@ public class CombatUtil { // Landwalk if (isUnblockableFromLandwalk(attacker, defender)) { - if (CardLists.getAmountOfKeyword(defender.getCreaturesInPlay(), "CARDNAME can block creatures with landwalk abilities as though they didn't have those abilities.") == 0) - return false; + return CardLists.getAmountOfKeyword(defender.getCreaturesInPlay(), "CARDNAME can block creatures with landwalk abilities as though they didn't have those abilities.") != 0; } return true; @@ -518,7 +513,7 @@ public class CombatUtil { IGNORE_LANDWALK_KEYWORDS = new String[size]; for (int i = 0; i < size; i++) { final String basic = MagicColor.Constant.BASIC_LANDS.get(i); - final String landwalk = basic + "walk";; + final String landwalk = basic + "walk"; LANDWALK_KEYWORDS[i] = landwalk; SNOW_LANDWALK_KEYWORDS[i] = "Snow " + landwalk.toLowerCase(); IGNORE_LANDWALK_KEYWORDS[i] = "May be blocked as though it doesn't have " + landwalk + "."; @@ -1053,7 +1048,7 @@ public class CombatUtil { for (KeywordInterface inst : blocker.getKeywords()) { String k = inst.getOriginal(); if (k.startsWith("IfReach")) { - String n[] = k.split(":"); + String[] n = k.split(":"); if (attacker.getType().hasCreatureType(n[1])) { stillblock = true; break; @@ -1074,11 +1069,7 @@ public class CombatUtil { return false; } - if (attacker.hasKeyword(Keyword.INTIMIDATE) && !blocker.isArtifact() && !blocker.sharesColorWith(attacker)) { - return false; - } - - return true; + return !attacker.hasKeyword(Keyword.INTIMIDATE) || blocker.isArtifact() || blocker.sharesColorWith(attacker); } // canBlock() public static boolean canAttackerBeBlockedWithAmount(Card attacker, int amount, Combat combat) { @@ -1114,9 +1105,7 @@ public class CombatUtil { System.out.println("Warning: it was impossible to deduce the defending player in CombatUtil#canAttackerBeBlockedWithAmount, returning 'true' (safest default)."); return true; } - if (amount < defender.getCreaturesInPlay().size()) { - return false; - } + return amount >= defender.getCreaturesInPlay().size(); } return true; diff --git a/forge-game/src/main/java/forge/game/combat/GlobalAttackRestrictions.java b/forge-game/src/main/java/forge/game/combat/GlobalAttackRestrictions.java index cde3c921347..9c5f3b810bf 100644 --- a/forge-game/src/main/java/forge/game/combat/GlobalAttackRestrictions.java +++ b/forge-game/src/main/java/forge/game/combat/GlobalAttackRestrictions.java @@ -45,7 +45,7 @@ public class GlobalAttackRestrictions { private GlobalAttackRestrictionViolations getViolations(final Map attackers, final CardCollection possibleAttackers, final boolean returnQuickly) { final int nTooMany = max < 0 ? 0 : attackers.size() - max; if (returnQuickly && nTooMany > 0) { - return new GlobalAttackRestrictionViolations(nTooMany, MapToAmountUtil.emptyMap(), MapToAmountUtil.emptyMap()); + return new GlobalAttackRestrictionViolations(nTooMany, MapToAmountUtil.emptyMap(), MapToAmountUtil.emptyMap()); } final MapToAmount defenderTooMany = new LinkedHashMapToAmount(defenderMax.size()); diff --git a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java index 5f40f259d76..75d87c49e64 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java +++ b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java @@ -13,7 +13,6 @@ import forge.game.keyword.KeywordInterface; import forge.game.mana.ManaCostBeingPaid; import forge.game.player.Player; import forge.game.spellability.AbilityActivated; -import forge.game.spellability.Spell; import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetChoices; import forge.game.staticability.StaticAbility; @@ -40,7 +39,7 @@ public class CostAdjustment { Cost result = cost.copy(); boolean isStateChangeToFaceDown = false; - if (sa.isSpell() && ((Spell) sa).isCastFaceDown()) { + if (sa.isSpell() && sa.isCastFaceDown()) { // Turn face down to apply cost modifiers correctly host.turnFaceDownNoUpdate(); isStateChangeToFaceDown = true; @@ -159,7 +158,7 @@ public class CostAdjustment { boolean isStateChangeToFaceDown = false; if (sa.isSpell()) { - if (((Spell) sa).isCastFaceDown()) { + if (sa.isCastFaceDown()) { // Turn face down to apply cost modifiers correctly originalCard.turnFaceDownNoUpdate(); isStateChangeToFaceDown = true; @@ -490,7 +489,7 @@ public class CostAdjustment { return false; } } else if (type.equals("MorphDown")) { - if (!sa.isSpell() || !((Spell) sa).isCastFaceDown()) { + if (!sa.isSpell() || !sa.isCastFaceDown()) { return false; } } @@ -546,9 +545,7 @@ public class CostAdjustment { } curSa = curSa.getSubAbility(); } - if (!targetValid) { - return false; - } + return targetValid; } return true; } diff --git a/forge-game/src/main/java/forge/game/cost/CostDiscard.java b/forge-game/src/main/java/forge/game/cost/CostDiscard.java index d788b0287f4..b8073001756 100644 --- a/forge-game/src/main/java/forge/game/cost/CostDiscard.java +++ b/forge-game/src/main/java/forge/game/cost/CostDiscard.java @@ -112,15 +112,11 @@ public class CostDiscard extends CostPartWithList { final Integer amount = this.convertAmount(); if (this.payCostFromSource()) { - if (!source.canBeDiscardedBy(ability)) { - return false; - } + return source.canBeDiscardedBy(ability); } else { if (type.equals("Hand")) { - if (!payer.canDiscardBy(ability)) { - return false; - } + return payer.canDiscardBy(ability); // this will always work } else if (type.equals("LastDrawn")) { @@ -153,14 +149,11 @@ public class CostDiscard extends CostPartWithList { } } - if ((amount != null) && (amount > handList.size() - adjustment)) { - // not enough cards in hand to pay - return false; - } + // not enough cards in hand to pay + return (amount == null) || (amount <= handList.size() - adjustment); } } - return true; } /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/cost/CostExert.java b/forge-game/src/main/java/forge/game/cost/CostExert.java index 60160d0d5f3..c9dc957a715 100644 --- a/forge-game/src/main/java/forge/game/cost/CostExert.java +++ b/forge-game/src/main/java/forge/game/cost/CostExert.java @@ -93,9 +93,7 @@ public class CostExert extends CostPartWithList { final Integer amount = this.convertAmount(); - if (!needsAnnoucement && (amount != null) && (typeList.size() < amount)) { - return false; - } + return needsAnnoucement || (amount == null) || (typeList.size() >= amount); } diff --git a/forge-game/src/main/java/forge/game/cost/CostExile.java b/forge-game/src/main/java/forge/game/cost/CostExile.java index 4e4f3dc8003..61a189b8731 100644 --- a/forge-game/src/main/java/forge/game/cost/CostExile.java +++ b/forge-game/src/main/java/forge/game/cost/CostExile.java @@ -146,9 +146,7 @@ public class CostExile extends CostPartWithList { break; } } - if (!foundPayable) { - return false; - } + return foundPayable; } return true; } diff --git a/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java b/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java index cf66f777abd..d04501e37f3 100644 --- a/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java +++ b/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java @@ -94,11 +94,7 @@ public class CostExileFromStack extends CostPart { list = CardLists.getValidCards(list, type.split(";"), payer, source, ability); final Integer amount = this.convertAmount(); - if ((amount != null) && (list.size() < amount)) { - return false; - } - - return true; + return (amount == null) || (list.size() >= amount); } diff --git a/forge-game/src/main/java/forge/game/cost/CostGainControl.java b/forge-game/src/main/java/forge/game/cost/CostGainControl.java index b77f91075ac..28940a73060 100644 --- a/forge-game/src/main/java/forge/game/cost/CostGainControl.java +++ b/forge-game/src/main/java/forge/game/cost/CostGainControl.java @@ -83,10 +83,7 @@ public class CostGainControl extends CostPartWithList { if (amount == null) { amount = AbilityUtils.calculateAmount(source, this.getAmount(), ability); } - if (typeList.size() < amount) { - return false; - } - return true; + return typeList.size() >= amount; } /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/cost/CostPartWithList.java b/forge-game/src/main/java/forge/game/cost/CostPartWithList.java index 495457493be..b934d3d0be7 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPartWithList.java +++ b/forge-game/src/main/java/forge/game/cost/CostPartWithList.java @@ -144,7 +144,7 @@ public abstract class CostPartWithList extends CostPart { protected abstract Card doPayment(SpellAbility ability, Card targetCard); // Overload these two only together, set to true and perform payment on list protected boolean canPayListAtOnce() { return false; } - protected CardCollectionView doListPayment(SpellAbility ability, CardCollectionView targetCards) { return CardCollection.EMPTY; }; + protected CardCollectionView doListPayment(SpellAbility ability, CardCollectionView targetCards) { return CardCollection.EMPTY; } /** * TODO: Write javadoc for this method. diff --git a/forge-game/src/main/java/forge/game/cost/CostPayLife.java b/forge-game/src/main/java/forge/game/cost/CostPayLife.java index c0394e31bc4..39f59048685 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPayLife.java +++ b/forge-game/src/main/java/forge/game/cost/CostPayLife.java @@ -78,11 +78,7 @@ public class CostPayLife extends CostPart { return false; } - if (payer.hasKeyword("You can't pay life to cast spells or activate abilities.")) { - return false; - } - - return true; + return !payer.hasKeyword("You can't pay life to cast spells or activate abilities."); } @Override diff --git a/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java b/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java index f70b1c8d188..5c55cea15e1 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java +++ b/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java @@ -160,9 +160,7 @@ public class CostPutCardToLib extends CostPartWithList { break; } } - if (!foundPayable) { - return false; - } + return foundPayable; } return true; } diff --git a/forge-game/src/main/java/forge/game/cost/CostPutCounter.java b/forge-game/src/main/java/forge/game/cost/CostPutCounter.java index 3738d839398..63c64457ea2 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPutCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostPutCounter.java @@ -140,9 +140,7 @@ public class CostPutCounter extends CostPartWithList { public final boolean canPay(final SpellAbility ability, final Player payer) { final Card source = ability.getHostCard(); if (this.payCostFromSource()) { - if (!source.canReceiveCounters(this.counter)) { - return false; - } + return source.canReceiveCounters(this.counter); } else { // 3 Cards have Put a -1/-1 Counter on a Creature you control. List typeList = CardLists.getValidCards(source.getGame().getCardsIn(ZoneType.Battlefield), @@ -150,12 +148,9 @@ public class CostPutCounter extends CostPartWithList { typeList = CardLists.filter(typeList, CardPredicates.canReceiveCounters(this.counter)); - if (typeList.isEmpty()) { - return false; - } + return !typeList.isEmpty(); } - return true; } /* diff --git a/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java b/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java index f74a892516d..7434d7add6f 100644 --- a/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java @@ -133,9 +133,7 @@ public class CostRemoveCounter extends CostPartWithList { final Integer amount = this.convertAmount(); if (this.payCostFromSource()) { - if ((amount != null) && ((source.getCounters(cntrs) - amount) < 0)) { - return false; - } + return (amount == null) || ((source.getCounters(cntrs) - amount) >= 0); } else { List typeList; @@ -152,9 +150,7 @@ public class CostRemoveCounter extends CostPartWithList { for (Card c : typeList) { totalCounters += c.getCounters(cntrs); } - if (totalCounters >= amount) { - return true; - } + return totalCounters >= amount; } else { // (default logic) remove X counters from a single permanent diff --git a/forge-game/src/main/java/forge/game/cost/CostReturn.java b/forge-game/src/main/java/forge/game/cost/CostReturn.java index 11b9e8b236a..2a9d6603701 100644 --- a/forge-game/src/main/java/forge/game/cost/CostReturn.java +++ b/forge-game/src/main/java/forge/game/cost/CostReturn.java @@ -102,14 +102,9 @@ public class CostReturn extends CostPartWithList { typeList = CardLists.getValidCards(typeList, this.getType().split(";"), payer, source, ability); final Integer amount = this.convertAmount(); - if (!needsAnnoucement && amount != null && typeList.size() < amount) { - return false; - } - } else if (!source.isInPlay()) { - return false; - } + return needsAnnoucement || amount == null || typeList.size() >= amount; + } else return source.isInPlay(); - return true; } /* (non-Javadoc) 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 0252203d1e6..b7d08ff1807 100644 --- a/forge-game/src/main/java/forge/game/cost/CostReveal.java +++ b/forge-game/src/main/java/forge/game/cost/CostReveal.java @@ -57,9 +57,7 @@ public class CostReveal extends CostPartWithList { final Integer amount = this.convertAmount(); if (this.payCostFromSource()) { - if (!source.isInZone(ZoneType.Hand)) { - return false; - } + return source.isInZone(ZoneType.Hand); } else if (this.getType().equals("Hand")) { return true; } else if (this.getType().equals("SameColor")) { @@ -85,14 +83,11 @@ public class CostReveal extends CostPartWithList { handList = modifiedHand; } handList = CardLists.getValidCards(handList, type.split(";"), payer, source, ability); - if ((amount != null) && (amount > handList.size())) { - // not enough cards in hand to pay - return false; - } + // not enough cards in hand to pay + return (amount == null) || (amount <= handList.size()); //System.out.println("revealcost - " + amount + type + handList); } - return true; } @Override diff --git a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java index 46f121a07a2..0ac0cb3248a 100644 --- a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java +++ b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java @@ -103,19 +103,14 @@ public class CostSacrifice extends CostPartWithList { typeList = CardLists.filter(typeList, CardPredicates.canBeSacrificedBy(ability)); - if (!needsAnnoucement && (amount != null) && (typeList.size() < amount)) { - return false; - } + return needsAnnoucement || (amount == null) || (typeList.size() >= amount); // If amount is null, it's either "ALL" or "X" // if X is defined, it needs to be calculated and checked, if X is // choice, it can be Paid even if it's 0 } - else if (!source.canBeSacrificedBy(ability)) { - return false; - } + else return source.canBeSacrificedBy(ability); - return true; } @Override diff --git a/forge-game/src/main/java/forge/game/cost/CostTapType.java b/forge-game/src/main/java/forge/game/cost/CostTapType.java index e0e9b345f4e..4a400a3a4dc 100644 --- a/forge-game/src/main/java/forge/game/cost/CostTapType.java +++ b/forge-game/src/main/java/forge/game/cost/CostTapType.java @@ -150,11 +150,7 @@ public class CostTapType extends CostPartWithList { } final Integer amount = this.convertAmount(); - if ((typeList.size() == 0) || ((amount != null) && (typeList.size() < amount))) { - return false; - } - - return true; + return (typeList.size() != 0) && ((amount == null) || (typeList.size() >= amount)); } /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/cost/CostUnattach.java b/forge-game/src/main/java/forge/game/cost/CostUnattach.java index fb33a53ebf3..d4ab4bd8b76 100644 --- a/forge-game/src/main/java/forge/game/cost/CostUnattach.java +++ b/forge-game/src/main/java/forge/game/cost/CostUnattach.java @@ -74,21 +74,14 @@ public class CostUnattach extends CostPartWithList { final String type = this.getType(); if (type.equals("CARDNAME")) { - if (source.isEquipping()) { - return true; - } + return source.isEquipping(); } else if (type.equals("OriginalHost")) { Card originalEquipment = ability.getOriginalHost(); - if (originalEquipment.isEquipping()) { - return true; - } + return originalEquipment.isEquipping(); } else { - if (CardLists.getValidCards(source.getEquippedBy(), type, payer, source).size() > 0) { - return true; - } + return CardLists.getValidCards(source.getEquippedBy(), type, payer, source).size() > 0; } - return false; } public Card findCardToUnattach(final Card source, Player activator, SpellAbility ability) { diff --git a/forge-game/src/main/java/forge/game/cost/CostUntapType.java b/forge-game/src/main/java/forge/game/cost/CostUntapType.java index 7db801bc88f..b52634e00f8 100644 --- a/forge-game/src/main/java/forge/game/cost/CostUntapType.java +++ b/forge-game/src/main/java/forge/game/cost/CostUntapType.java @@ -89,10 +89,7 @@ public class CostUntapType extends CostPartWithList { typeList = CardLists.filter(typeList, Presets.TAPPED); final Integer amount = convertAmount(); - if ((typeList.size() == 0) || ((amount != null) && (typeList.size() < amount))) { - return false; - } - return true; + return (typeList.size() != 0) && ((amount == null) || (typeList.size() >= amount)); } @Override diff --git a/forge-game/src/main/java/forge/game/cost/ICostVisitor.java b/forge-game/src/main/java/forge/game/cost/ICostVisitor.java index 5112124012e..9ca192502b3 100644 --- a/forge-game/src/main/java/forge/game/cost/ICostVisitor.java +++ b/forge-game/src/main/java/forge/game/cost/ICostVisitor.java @@ -2,36 +2,36 @@ package forge.game.cost; public interface ICostVisitor { - public T visit(CostGainControl cost); - public T visit(CostChooseCreatureType cost); - public T visit(CostDiscard cost); - public T visit(CostDamage cost); - public T visit(CostDraw cost); - public T visit(CostExile cost); - public T visit(CostExileFromStack cost); - public T visit(CostExiledMoveToGrave cost); - public T visit(CostExert cost); - public T visit(CostFlipCoin cost); - public T visit(CostMill cost); - public T visit(CostAddMana cost); - public T visit(CostPayLife cost); - public T visit(CostPayEnergy cost); - public T visit(CostGainLife cost); - public T visit(CostPartMana cost); - public T visit(CostPutCardToLib cost); - public T visit(CostTap cost); - public T visit(CostSacrifice cost); - public T visit(CostReturn cost); - public T visit(CostReveal cost); - public T visit(CostRemoveAnyCounter cost); - public T visit(CostRemoveCounter cost); - public T visit(CostPutCounter cost); - public T visit(CostUntapType cost); - public T visit(CostUntap cost); - public T visit(CostUnattach cost); - public T visit(CostTapType cost); + T visit(CostGainControl cost); + T visit(CostChooseCreatureType cost); + T visit(CostDiscard cost); + T visit(CostDamage cost); + T visit(CostDraw cost); + T visit(CostExile cost); + T visit(CostExileFromStack cost); + T visit(CostExiledMoveToGrave cost); + T visit(CostExert cost); + T visit(CostFlipCoin cost); + T visit(CostMill cost); + T visit(CostAddMana cost); + T visit(CostPayLife cost); + T visit(CostPayEnergy cost); + T visit(CostGainLife cost); + T visit(CostPartMana cost); + T visit(CostPutCardToLib cost); + T visit(CostTap cost); + T visit(CostSacrifice cost); + T visit(CostReturn cost); + T visit(CostReveal cost); + T visit(CostRemoveAnyCounter cost); + T visit(CostRemoveCounter cost); + T visit(CostPutCounter cost); + T visit(CostUntapType cost); + T visit(CostUntap cost); + T visit(CostUnattach cost); + T visit(CostTapType cost); - public static class Base implements ICostVisitor { + class Base implements ICostVisitor { @Override public T visit(CostGainControl cost) { diff --git a/forge-game/src/main/java/forge/game/event/GameEventCardDamaged.java b/forge-game/src/main/java/forge/game/event/GameEventCardDamaged.java index e809ad41743..149cf8e3ea9 100644 --- a/forge-game/src/main/java/forge/game/event/GameEventCardDamaged.java +++ b/forge-game/src/main/java/forge/game/event/GameEventCardDamaged.java @@ -8,7 +8,7 @@ public class GameEventCardDamaged extends GameEvent { Normal, M1M1Counters, Deathtouch, - LoyaltyLoss; + LoyaltyLoss } public final Card card; diff --git a/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java b/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java index 1eb9149788f..e1bb2138ffe 100644 --- a/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java +++ b/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java @@ -43,7 +43,7 @@ public class GameEventCardStatsChanged extends GameEvent { return "Card state changes: " + card.getName() + " (" + StringUtils.join(card.getType(), ' ') + ") " + card.getNetPower() + "/" + card.getNetToughness() + - " and " + String.valueOf(cards.size() - 1) + " more"; + " and " + (cards.size() - 1) + " more"; } } diff --git a/forge-game/src/main/java/forge/game/event/IGameEventVisitor.java b/forge-game/src/main/java/forge/game/event/IGameEventVisitor.java index 7e038506226..8dd56af94d4 100644 --- a/forge-game/src/main/java/forge/game/event/IGameEventVisitor.java +++ b/forge-game/src/main/java/forge/game/event/IGameEventVisitor.java @@ -51,7 +51,7 @@ public interface IGameEventVisitor { // This is base class for all visitors. - public static class Base implements IGameEventVisitor{ + class Base implements IGameEventVisitor{ public T visit(GameEventAnteCardsSelected event) { return null; } public T visit(GameEventAttackersDeclared event) { return null; } public T visit(GameEventBlockersDeclared event) { return null; } diff --git a/forge-game/src/main/java/forge/game/keyword/Keyword.java b/forge-game/src/main/java/forge/game/keyword/Keyword.java index ead951daf98..101dc0a4a90 100644 --- a/forge-game/src/main/java/forge/game/keyword/Keyword.java +++ b/forge-game/src/main/java/forge/game/keyword/Keyword.java @@ -164,7 +164,7 @@ public enum Keyword { protected final boolean isMultipleRedundant; protected final String reminderText, displayName; - private Keyword(Class> type0, boolean isMultipleRedundant0, String reminderText0) { + Keyword(Class> type0, boolean isMultipleRedundant0, String reminderText0) { type = type0; isMultipleRedundant = isMultipleRedundant0; reminderText = reminderText0; @@ -176,7 +176,7 @@ public enum Keyword { String details = k; // try to get real part if (k.contains(":")) { - final String x[] = k.split(":", 2); + final String[] x = k.split(":", 2); keyword = smartValueOf(x[0]); details = x[1]; } else if (k.contains(" ")) { @@ -186,7 +186,7 @@ public enum Keyword { // other keywords that contains other stuff like Enchant if (keyword == Keyword.UNDEFINED) { - final String x[] = k.split(" ", 2); + final String[] x = k.split(" ", 2); final Keyword k2 = smartValueOf(x[0]); // Keywords that needs to be undefined diff --git a/forge-game/src/main/java/forge/game/keyword/KeywordInstance.java b/forge-game/src/main/java/forge/game/keyword/KeywordInstance.java index 33bfe77dd56..50b99b5e66a 100644 --- a/forge-game/src/main/java/forge/game/keyword/KeywordInstance.java +++ b/forge-game/src/main/java/forge/game/keyword/KeywordInstance.java @@ -24,10 +24,10 @@ public abstract class KeywordInstance> implements K private boolean hidden; - private List triggers = Lists.newArrayList(); - private List replacements = Lists.newArrayList(); - private List abilities = Lists.newArrayList(); - private List staticAbilities = Lists.newArrayList(); + private List triggers = Lists.newArrayList(); + private List replacements = Lists.newArrayList(); + private List abilities = Lists.newArrayList(); + private List staticAbilities = Lists.newArrayList(); /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/keyword/KeywordInterface.java b/forge-game/src/main/java/forge/game/keyword/KeywordInterface.java index 83ad9b87aa8..d8b5f152605 100644 --- a/forge-game/src/main/java/forge/game/keyword/KeywordInterface.java +++ b/forge-game/src/main/java/forge/game/keyword/KeywordInterface.java @@ -21,36 +21,36 @@ public interface KeywordInterface extends Cloneable { boolean getHidden(); void setHidden(boolean val); - public void createTraits(final Card host, final boolean intrinsic); + void createTraits(final Card host, final boolean intrinsic); void createTraits(final Card host, final boolean intrinsic, final boolean clear); - public void addTrigger(final Trigger trg); + void addTrigger(final Trigger trg); - public void addReplacement(final ReplacementEffect trg); + void addReplacement(final ReplacementEffect trg); - public void addSpellAbility(final SpellAbility s); - public void addStaticAbility(final StaticAbility st); + void addSpellAbility(final SpellAbility s); + void addStaticAbility(final StaticAbility st); - public void setHostCard(final Card host); + void setHostCard(final Card host); /** * @return the triggers */ - public Collection getTriggers(); + Collection getTriggers(); /** * @return the replacements */ - public Collection getReplacements(); + Collection getReplacements(); /** * @return the abilities */ - public Collection getAbilities(); + Collection getAbilities(); /** * @return the staticAbilities */ - public Collection getStaticAbilities(); + Collection getStaticAbilities(); - public KeywordInterface copy(final Card host, final boolean lki); + KeywordInterface copy(final Card host, final boolean lki); - public boolean redundant(final Collection list); + boolean redundant(final Collection list); } \ No newline at end of file diff --git a/forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndType.java b/forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndType.java index b1e988e5bdb..167cc20dce5 100644 --- a/forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndType.java +++ b/forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndType.java @@ -18,7 +18,7 @@ public class KeywordWithCostAndType extends KeywordInstance 2) { strType = k[2]; } else { - String n[] = type.split(","); + String[] n = type.split(","); for (int i = 0; i < n.length; i++) { if (CardType.isACardType(n[i])) { n[i] = n[i].toLowerCase(); diff --git a/forge-game/src/main/java/forge/game/keyword/Ninjutsu.java b/forge-game/src/main/java/forge/game/keyword/Ninjutsu.java index 2159f8ea430..50b5d8b2006 100644 --- a/forge-game/src/main/java/forge/game/keyword/Ninjutsu.java +++ b/forge-game/src/main/java/forge/game/keyword/Ninjutsu.java @@ -10,7 +10,7 @@ public class Ninjutsu extends KeywordWithCost { @Override protected void parse(String details) { if (details.contains(":")) { - String k[] = details.split(":"); + String[] k = details.split(":"); details = k[0]; if (k[1].equals("Commander")) { commander = true; diff --git a/forge-game/src/main/java/forge/game/mana/ManaPool.java b/forge-game/src/main/java/forge/game/mana/ManaPool.java index de59a57ef21..bf68649ae12 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -95,10 +95,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable { } } - if (totalMana() == safeMana) { - return false; //won't lose floating mana if all mana is of colors that aren't going to be emptied - } - return true; + return totalMana() != safeMana; //won't lose floating mana if all mana is of colors that aren't going to be emptied } public final List clearPool(boolean isEndOfPhase) { @@ -370,7 +367,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable { } // TODO The following may not be needed anymore? - if (((color & (byte) ManaAtom.COLORLESS) != 0) && shard.canBePaidWithManaOfColor((byte) (byte)ManaAtom.COLORLESS)) { + if (((color & (byte) ManaAtom.COLORLESS) != 0) && shard.canBePaidWithManaOfColor((byte)ManaAtom.COLORLESS)) { return true; } diff --git a/forge-game/src/main/java/forge/game/mulligan/MulliganService.java b/forge-game/src/main/java/forge/game/mulligan/MulliganService.java index 2fed6777cc5..0d787327ff1 100644 --- a/forge-game/src/main/java/forge/game/mulligan/MulliganService.java +++ b/forge-game/src/main/java/forge/game/mulligan/MulliganService.java @@ -68,7 +68,7 @@ public class MulliganService { continue; } Player p = mulligan.getPlayer(); - boolean keep = mulligan.canMulligan() ? p.getController().mulliganKeepHand(firstPlayer, mulligan.tuckCardsAfterKeepHand()) : true; + boolean keep = !mulligan.canMulligan() || p.getController().mulliganKeepHand(firstPlayer, mulligan.tuckCardsAfterKeepHand()); if (game.isGameOver()) { // conceded on mulligan prompt return; diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index fd75bb5e2b8..00ca310ff9e 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -663,7 +663,7 @@ public class PhaseHandler implements java.io.Serializable { // map: defender => (many) attacker => (many) blocker Map> blockers = Maps.newHashMap(); for (GameEntity ge : combat.getDefendersControlledBy(p)) { - MapOfLists protectThisDefender = new HashMapOfLists(CollectionSuppliers.arrayLists()); + MapOfLists protectThisDefender = new HashMapOfLists(CollectionSuppliers.arrayLists()); for (Card att : combat.getAttackersOf(ge)) { protectThisDefender.addAll(att, combat.getBlockers(att)); } diff --git a/forge-game/src/main/java/forge/game/phase/PhaseType.java b/forge-game/src/main/java/forge/game/phase/PhaseType.java index 8022b483c39..eda13a747f7 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseType.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseType.java @@ -36,10 +36,10 @@ public enum PhaseType { public final String nameForUi; public final String nameForScripts; - private PhaseType(String name) { + PhaseType(String name) { this(name, name); } - private PhaseType(String name, String name_for_scripts) { + PhaseType(String name, String name_for_scripts) { nameForUi = name; nameForScripts = name_for_scripts; } diff --git a/forge-game/src/main/java/forge/game/phase/Untap.java b/forge-game/src/main/java/forge/game/phase/Untap.java index 7835a67cdaf..688a295ce79 100644 --- a/forge-game/src/main/java/forge/game/phase/Untap.java +++ b/forge-game/src/main/java/forge/game/phase/Untap.java @@ -35,7 +35,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -93,11 +92,8 @@ public class Untap extends Phase { } //exerted need current player turn final Player playerTurn = c.getGame().getPhaseHandler().getPlayerTurn(); - - if (c.isExertedBy(playerTurn)) { - return false; - } - return true; + + return !c.isExertedBy(playerTurn); } public static final Predicate CANUNTAP = new Predicate() { @@ -125,7 +121,7 @@ public class Untap extends Phase { for (final Card c : bounceList) { game.getAction().moveToHand(c, null); } - list.removeAll((Collection)bounceList); + list.removeAll(bounceList); final Map restrictUntap = Maps.newHashMap(); boolean hasChosen = false; @@ -154,10 +150,7 @@ public class Untap extends Phase { if (!Untap.canUntap(c)) { return false; } - if (c.isValid(restrict, player, null, null)) { - return false; - } - return true; + return !c.isValid(restrict, player, null, null); } }); @@ -187,7 +180,7 @@ public class Untap extends Phase { Map remaining = Maps.newHashMap(restrictUntap); for (Entry entry : remaining.entrySet()) { if (entry.getValue() == 0) { - cardList.removeAll((Collection)CardLists.getValidCards(cardList, entry.getKey(), player, null)); + cardList.removeAll(CardLists.getValidCards(cardList, entry.getKey(), player, null)); restrictUntap.remove(entry.getKey()); } } 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 2607b412d75..9e42220c143 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -461,10 +461,7 @@ public class Player extends GameEntity implements Comparable { } public final boolean canGainLife() { - if (hasKeyword("You can't gain life.") || hasKeyword("Your life total can't change.")) { - return false; - } - return true; + return !hasKeyword("You can't gain life.") && !hasKeyword("Your life total can't change."); } public final int loseLife(final int toLose) { @@ -513,20 +510,14 @@ public class Player extends GameEntity implements Comparable { } public final boolean canLoseLife() { - if (hasKeyword("Your life total can't change.")) { - return false; - } - return true; + return !hasKeyword("Your life total can't change."); } public final boolean canPayLife(final int lifePayment) { if (life < lifePayment) { return false; } - if ((lifePayment > 0) && hasKeyword("Your life total can't change.")) { - return false; - } - return true; + return (lifePayment <= 0) || !hasKeyword("Your life total can't change."); } public final boolean payLife(final int lifePayment, final Card source) { @@ -826,7 +817,7 @@ public class Player extends GameEntity implements Comparable { CardCollection newCardsInCommand = new CardCollection(getGame().getCardsIn(ZoneType.Command)); newCardsInCommand.removeAll(cardsInCommand); if (!newCardsInCommand.isEmpty()) { - newCardsInCommand.get(0).setSVar("PreventedDamage", "Number$" + Integer.toString(dmgToBePrevented)); + newCardsInCommand.get(0).setSVar("PreventedDamage", "Number$" + dmgToBePrevented); } } subtractPreventNextDamageWithEffect(shieldSource, restDamage); @@ -1067,7 +1058,7 @@ public class Player extends GameEntity implements Comparable { * @param keyword the keyword to add. */ public final void addKeyword(final String keyword) { - addChangedKeywords(ImmutableList.of(keyword), ImmutableList.of(), getGame().getNextTimestamp()); + addChangedKeywords(ImmutableList.of(keyword), ImmutableList.of(), getGame().getNextTimestamp()); } /** @@ -1185,7 +1176,7 @@ public class Player extends GameEntity implements Comparable { PlayerZone com = getZone(ZoneType.Command); for (DetachedCardEffect eff : staticAbilities.values()) { com.remove(eff); - eff.setStaticAbilities(Lists.newArrayList()); + eff.setStaticAbilities(Lists.newArrayList()); } this.updateZoneForView(com); } @@ -1201,7 +1192,7 @@ public class Player extends GameEntity implements Comparable { boolean cancelHexproof = false; for (String k : a.getKeywords()) { if (k.startsWith("IgnoreHexproof")) { - String m[] = k.split(":"); + String[] m = k.split(":"); if (isValid(m[1].split(","), a, sa.getHostCard(), sa)) { cancelHexproof = true; break; @@ -1218,10 +1209,7 @@ public class Player extends GameEntity implements Comparable { return false; } - if ((hasKeyword("You can't be the targets of spells or activated abilities") && (sa.isSpell() || (sa instanceof AbilityActivated)))) { - return false; - } - return true; + return (!hasKeyword("You can't be the targets of spells or activated abilities") || (!sa.isSpell() && (!(sa instanceof AbilityActivated)))); } @@ -1783,10 +1771,7 @@ public class Player extends GameEntity implements Comparable { adjMax += Integer.valueOf(k[1]); } } - if (landsPlayedThisTurn < adjMax) { - return true; - } - return false; + return landsPlayedThisTurn < adjMax; } public final ManaPool getManaPool() { @@ -2491,10 +2476,7 @@ public class Player extends GameEntity implements Comparable { "Skip all combat phases of this turn."); return true; } - if (hasKeyword("Skip all combat phases of this turn.")) { - return true; - } - return false; + return hasKeyword("Skip all combat phases of this turn."); } public boolean isSkippingMain() { @@ -2614,10 +2596,7 @@ public class Player extends GameEntity implements Comparable { removeKeyword("Skip your next draw step."); return true; } - if (hasKeyword("Skip your draw step.")) { - return true; - } - return false; + return hasKeyword("Skip your draw step."); } public CardCollectionView getInboundTokens() { @@ -2957,11 +2936,7 @@ public class Player extends GameEntity implements Comparable { return true; } - if (isOpponentOf(sa.getActivatingPlayer()) && hasKeyword("Spells and abilities your opponents control can't cause you to discard cards.")) { - return false; - } - - return true; + return !isOpponentOf(sa.getActivatingPlayer()) || !hasKeyword("Spells and abilities your opponents control can't cause you to discard cards."); } public boolean canSacrificeBy(SpellAbility sa) { @@ -2969,11 +2944,7 @@ public class Player extends GameEntity implements Comparable { return true; } - if (isOpponentOf(sa.getActivatingPlayer()) && hasKeyword("Spells and abilities your opponents control can't cause you to sacrifice permanents.")) { - return false; - } - - return true; + return !isOpponentOf(sa.getActivatingPlayer()) || !hasKeyword("Spells and abilities your opponents control can't cause you to sacrifice permanents."); } public boolean canSearchLibraryWith(SpellAbility sa, Player targetPlayer) { @@ -2983,11 +2954,8 @@ public class Player extends GameEntity implements Comparable { if (this.hasKeyword("CantSearchLibrary")) { return false; - } else if (targetPlayer != null && targetPlayer.equals(sa.getActivatingPlayer()) - && hasKeyword("Spells and abilities you control can't cause you to search your library.")) { - 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 true; } } diff --git a/forge-game/src/main/java/forge/game/player/PlayerController.java b/forge-game/src/main/java/forge/game/player/PlayerController.java index 96f146e564f..ecea26174d9 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerController.java +++ b/forge-game/src/main/java/forge/game/player/PlayerController.java @@ -43,7 +43,7 @@ import java.util.Map; */ public abstract class PlayerController { - public static enum ManaPaymentPurpose { + public enum ManaPaymentPurpose { DeclareAttacker, DeclareBlocker, Echo, @@ -51,7 +51,7 @@ public abstract class PlayerController { CumulativeUpkeep, } - public static enum BinaryChoiceType { + public enum BinaryChoiceType { HeadsOrTails, // coin TapOrUntap, PlayOrDraw, diff --git a/forge-game/src/main/java/forge/game/player/PlayerProperty.java b/forge-game/src/main/java/forge/game/player/PlayerProperty.java index 08238470931..73aebdbd1c0 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerProperty.java +++ b/forge-game/src/main/java/forge/game/player/PlayerProperty.java @@ -23,13 +23,9 @@ public class PlayerProperty { Game game = player.getGame(); if (property.equals("You")) { - if (!player.equals(sourceController)) { - return false; - } + return player.equals(sourceController); } else if (property.equals("Opponent")) { - if (player.equals(sourceController) || !player.isOpponentOf(sourceController)) { - return false; - } + return !player.equals(sourceController) && player.isOpponentOf(sourceController); } else if (property.startsWith("OpponentOf ")) { final String v = property.split(" ")[1]; final List players = AbilityUtils.getDefinedPlayers(source, v, spellAbility); @@ -39,42 +35,24 @@ public class PlayerProperty { } } } else if (property.equals("YourTeam")) { - if (!player.sameTeam(sourceController)) { - return false; - } + return player.sameTeam(sourceController); } else if (property.equals("Allies")) { - if (player.equals(sourceController) || player.isOpponentOf(sourceController)) { - return false; - } + return !player.equals(sourceController) && !player.isOpponentOf(sourceController); } else if (property.equals("Active")) { - if (!player.equals(game.getPhaseHandler().getPlayerTurn())) { - return false; - } + return player.equals(game.getPhaseHandler().getPlayerTurn()); } else if (property.equals("NonActive")) { - if (player.equals(game.getPhaseHandler().getPlayerTurn())) { - return false; - } + return !player.equals(game.getPhaseHandler().getPlayerTurn()); } else if (property.equals("OpponentToActive")) { final Player active = game.getPhaseHandler().getPlayerTurn(); - if (player.equals(active) || !player.isOpponentOf(active)) { - return false; - } + return !player.equals(active) && player.isOpponentOf(active); } else if (property.equals("Other")) { - if (player.equals(sourceController)) { - return false; - } + return !player.equals(sourceController); } else if (property.equals("OtherThanSourceOwner")) { - if (player.equals(source.getOwner())) { - return false; - } + return !player.equals(source.getOwner()); } else if (property.equals("isMonarch")) { - if (!player.equals(game.getMonarch())) { - return false; - } + return player.equals(game.getMonarch()); } else if (property.equals("hasBlessing")) { - if (!player.hasBlessing()) { - return false; - } + return player.hasBlessing(); } else if (property.startsWith("wasDealtCombatDamageThisCombatBy ")) { String v = property.split(" ")[1]; @@ -91,9 +69,7 @@ public class PlayerProperty { found++; } } - if (found < count) { - return false; - } + return found >= count; } else if (property.startsWith("wasDealtDamageThisGameBy ")) { String v = property.split(" ")[1]; @@ -110,9 +86,7 @@ public class PlayerProperty { found++; } } - if (found < count) { - return false; - } + return found >= count; } else if (property.startsWith("wasDealtDamageThisTurnBy ")) { String v = property.split(" ")[1]; int count = 1; @@ -129,9 +103,7 @@ public class PlayerProperty { found++; } } - if (found < count) { - return false; - } + return found >= count; } else if (property.startsWith("wasDealtCombatDamageThisTurnBy ")) { String v = property.split(" ")[1]; @@ -149,90 +121,54 @@ public class PlayerProperty { found++; } } - if (found < count) { - return false; - } + return found >= count; } else if (property.equals("attackedBySourceThisCombat")) { - if (game.getCombat() == null || !player.equals(game.getCombat().getDefenderPlayerByAttacker(source))) { - return false; - } + return game.getCombat() != null && player.equals(game.getCombat().getDefenderPlayerByAttacker(source)); } else if (property.equals("wasDealtDamageThisTurn")) { - if (player.getAssignedDamage() == 0) { - return false; - } + return player.getAssignedDamage() != 0; } else if (property.equals("wasDealtCombatDamageThisTurn")) { - if (player.getAssignedCombatDamage() == 0) { - return false; - } + return player.getAssignedCombatDamage() != 0; } else if (property.equals("LostLifeThisTurn")) { - if (player.getLifeLostThisTurn() <= 0) { - return false; - } + return player.getLifeLostThisTurn() > 0; } else if (property.equals("DeclaredAttackerThisTurn")) { - if (player.getAttackersDeclaredThisTurn() <= 0) { - return false; - } + return player.getAttackersDeclaredThisTurn() > 0; } else if (property.equals("TappedLandForManaThisTurn")) { - if (!player.hasTappedLandForManaThisTurn()) { - return false; - } + return player.hasTappedLandForManaThisTurn(); } else if (property.equals("NoCardsInHandAtBeginningOfTurn")) { - if (player.getNumCardsInHandStartedThisTurnWith() > 0) { - return false; - } + return player.getNumCardsInHandStartedThisTurnWith() <= 0; } else if (property.equals("CardsInHandAtBeginningOfTurn")) { - if (player.getNumCardsInHandStartedThisTurnWith() <= 0) { - return false; - } + return player.getNumCardsInHandStartedThisTurnWith() > 0; } else if (property.startsWith("WithCardsInHand")) { if (property.contains("AtLeast")) { int amount = Integer.parseInt(property.split("AtLeast")[1]); - if (player.getCardsIn(ZoneType.Hand).size() < amount) { - return false; - } + return player.getCardsIn(ZoneType.Hand).size() >= amount; } } else if (property.equals("IsRemembered")) { - if (!source.isRemembered(player)) { - return false; - } + return source.isRemembered(player); } else if (property.equals("IsNotRemembered")) { - if (source.isRemembered(player)) { - return false; - } + return !source.isRemembered(player); } else if (property.equals("EnchantedBy")) { - if (!player.isEnchantedBy(source)) { - return false; - } + return player.isEnchantedBy(source); } else if (property.equals("Chosen")) { - if (source.getChosenPlayer() == null || !source.getChosenPlayer().equals(player)) { - return false; - } + return source.getChosenPlayer() != null && source.getChosenPlayer().equals(player); } else if (property.startsWith("LifeEquals_")) { int life = AbilityUtils.calculateAmount(source, property.substring(11), null); - if (player.getLife() != life) { - return false; - } + return player.getLife() == life; } else if (property.equals("IsPoisoned")) { - if (player.getPoisonCounters() <= 0) { - return false; - } + return player.getPoisonCounters() > 0; } else if (property.startsWith("controls")) { final String[] type = property.substring(8).split("_"); final CardCollectionView list = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type[0], sourceController, source); String comparator = type[1]; String compareTo = comparator.substring(2); int y = StringUtils.isNumeric(compareTo) ? Integer.parseInt(compareTo) : 0; - if (!Expressions.compare(list.size(), comparator, y)) { - return false; - } + return Expressions.compare(list.size(), comparator, y); } else if (property.startsWith("withMore")) { final String cardType = property.split("sThan")[0].substring(8); final Player controller = "Active".equals(property.split("sThan")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController; final CardCollectionView oppList = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); final CardCollectionView yourList = CardLists.filter(controller.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); - if (oppList.size() <= yourList.size()) { - return false; - } + return oppList.size() > yourList.size(); } else if (property.startsWith("withAtLeast")) { final String cardType = property.split("More")[1].split("sThan")[0]; final int amount = Integer.parseInt(property.substring(11, 12)); @@ -240,25 +176,19 @@ public class PlayerProperty { final CardCollectionView oppList = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); final CardCollectionView yourList = CardLists.filter(controller.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); System.out.println(yourList.size()); - if (oppList.size() < yourList.size() + amount) { - return false; - } + return oppList.size() >= yourList.size() + amount; } else if (property.startsWith("hasMore")) { final Player controller = property.contains("Than") && "Active".equals(property.split("Than")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController; if (property.substring(7).startsWith("Life") && player.getLife() <= controller.getLife()) { return false; - } else if (property.substring(7).startsWith("CardsInHand") - && player.getCardsIn(ZoneType.Hand).size() <= controller.getCardsIn(ZoneType.Hand).size()) { - return false; - } + } else return !property.substring(7).startsWith("CardsInHand") + || player.getCardsIn(ZoneType.Hand).size() > controller.getCardsIn(ZoneType.Hand).size(); } else if (property.startsWith("hasFewer")) { final Player controller = "Active".equals(property.split("Than")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController; final ZoneType zt = property.substring(8).startsWith("CreaturesInYard") ? ZoneType.Graveyard : ZoneType.Battlefield; final CardCollectionView oppList = CardLists.filter(player.getCardsIn(zt), Presets.CREATURES); final CardCollectionView yourList = CardLists.filter(controller.getCardsIn(zt), Presets.CREATURES); - if (oppList.size() >= yourList.size()) { - return false; - } + return oppList.size() < yourList.size(); } else if (property.startsWith("withMost")) { final String kind = property.substring(8); if (kind.equals("Life")) { @@ -268,9 +198,7 @@ public class PlayerProperty { highestLife = p.getLife(); } } - if (player.getLife() != highestLife) { - return false; - } + return player.getLife() == highestLife; } else if (kind.equals("PermanentInPlay")) { int typeNum = 0; @@ -286,9 +214,7 @@ public class PlayerProperty { } } - if (controlmost.size() != 1 || !controlmost.contains(player)) { - return false; - } + return controlmost.size() == 1 && controlmost.contains(player); } else if (kind.equals("CardsInHand")) { int largestHand = 0; @@ -299,9 +225,7 @@ public class PlayerProperty { withLargestHand = p; } } - if (!player.equals(withLargestHand)) { - return false; - } + return player.equals(withLargestHand); } else if (kind.startsWith("Type")) { String type = property.split("Type")[1]; @@ -325,9 +249,7 @@ public class PlayerProperty { if (checkOnly && controlmost.size() != 1) { return false; } - if (!controlmost.contains(player)) { - return false; - } + return controlmost.contains(player); } } else if (property.startsWith("withLowest")) { if (property.substring(10).equals("Life")) { @@ -342,18 +264,12 @@ public class PlayerProperty { lowestlifep.add(p); } } - if (!lowestlifep.contains(player)) { - return false; - } + return lowestlifep.contains(player); } } else if (property.startsWith("LessThanHalfStartingLifeTotal")) { - if (player.getLife() >= (int) Math.ceil(player.getStartingLife() / 2.0)) { - return false; - } + return player.getLife() < (int) Math.ceil(player.getStartingLife() / 2.0); } else if (property.startsWith("Triggered")) { - if (!AbilityUtils.getDefinedPlayers(source, property, spellAbility).contains(player)) { - return false; - } + return AbilityUtils.getDefinedPlayers(source, property, spellAbility).contains(player); } return true; } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java b/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java index 05bf6c1627d..882dd783bcc 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java @@ -59,9 +59,7 @@ public class ReplaceAddCounter extends ReplacementEffect { if (mapParams.containsKey("ValidCounterType")) { String type = this.getMapParams().get("ValidCounterType"); - if (CounterType.getType(type) != runParams.get("CounterType")) { - return false; - } + return CounterType.getType(type) == runParams.get("CounterType"); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java b/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java index 6708d29b7ed..e1e92a84ae0 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java @@ -59,9 +59,7 @@ public class ReplaceCounter extends ReplacementEffect { } if (this.getMapParams().containsKey("ValidType")) { String type = this.getMapParams().get("ValidType"); - if (type.equals("Spell") && !spellAbility.isSpell()) { - return false; - } + return !type.equals("Spell") || spellAbility.isSpell(); } return true; } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java index fa61c0e1123..5aa9da41132 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java @@ -74,9 +74,7 @@ public class ReplaceDestroy extends ReplacementEffect { } } if (hasParam("ValidSource")) { - if (!matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), getHostCard())) { - return false; - } + return matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java index 20499fc1de2..8354cf6418b 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java @@ -62,9 +62,7 @@ public class ReplaceDiscard extends ReplacementEffect { } } if (this.getMapParams().containsKey("DiscardFromEffect")) { - if (null == runParams.get("Source")) { - return false; - } + return null != runParams.get("Source"); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java index 4b7b2d80f38..a6547e66d49 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java @@ -55,11 +55,9 @@ public class ReplaceDraw extends ReplacementEffect { } if (this.getMapParams().containsKey("NotFirstCardInDrawStep")) { final Player p = (Player)runParams.get("Affected"); - if (p.numDrawnThisDrawStep() == 0 - && this.getHostCard().getGame().getPhaseHandler().is(PhaseType.DRAW) - && this.getHostCard().getGame().getPhaseHandler().isPlayerTurn(p)) { - return false; - } + return p.numDrawnThisDrawStep() != 0 + || !this.getHostCard().getGame().getPhaseHandler().is(PhaseType.DRAW) + || !this.getHostCard().getGame().getPhaseHandler().isPlayerTurn(p); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java index 30f56eceb9d..fffc08855ed 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java @@ -57,9 +57,7 @@ public class ReplaceDrawCards extends ReplacementEffect { String comparator = this.getMapParams().get("Number"); final String operator = comparator.substring(0, 2); final int operandValue = Integer.parseInt(comparator.substring(2)); - if (!Expressions.compare(n, operator, operandValue)) { - return false; - } + return Expressions.compare(n, operator, operandValue); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java b/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java index d269f9c044f..aa95a7a8862 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java @@ -57,9 +57,7 @@ public class ReplaceGainLife extends ReplacementEffect { } } if ("True".equals(this.getMapParams().get("SourceController"))) { - if (runParams.get("Source") == null || !runParams.get("Affected").equals(((Card)runParams.get("Source")).getController())) { - return false; - } + return runParams.get("Source") != null && runParams.get("Affected").equals(((Card) runParams.get("Source")).getController()); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java b/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java index 298f6cf470b..d6cc1b84cf2 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java @@ -29,9 +29,7 @@ public class ReplaceGameLoss extends ReplacementEffect { return false; } if (this.getMapParams().containsKey("ValidPlayer")) { - if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) { - return false; - } + return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java b/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java index 162d87bca99..a7af2db3f2e 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java @@ -105,9 +105,7 @@ public class ReplaceMoved extends ReplacementEffect { if (runParams.containsKey("Cause")) { SpellAbility cause = (SpellAbility) runParams.get("Cause"); if (cause != null) { - if (cause.isValid(getParam("NotCause").split(","), controller, getHostCard(), null)) { - return false; - } + return !cause.isValid(getParam("NotCause").split(","), controller, getHostCard(), null); } } } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java b/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java index 90abfa87fd6..dc7c218e750 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java @@ -58,9 +58,7 @@ public class ReplaceProduceMana extends ReplacementEffect { } if (this.getMapParams().containsKey("ValidCard")) { - if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) { - return false; - } + return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java b/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java index d4c2c7a2c1f..7cfb4413ce8 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java @@ -46,9 +46,7 @@ public class ReplaceSetInMotion extends ReplacementEffect { return false; } if (this.getMapParams().containsKey("ValidPlayer")) { - if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) { - return false; - } + return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java b/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java index c2121b2e0d7..809dd8a00a8 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java @@ -31,9 +31,7 @@ public class ReplaceSurveil extends ReplacementEffect { } if (hasParam("ValidPlayer")) { - if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), getHostCard())) { - return false; - } + return matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java b/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java index d58cd697b4a..f8b5d4ebe78 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java @@ -45,9 +45,7 @@ public class ReplaceToken extends ReplacementEffect { if (hasParam("ValidToken")) { if (runParams.containsKey("Token")) { - if (!matchesValid(runParams.get("Token"), getParam("ValidToken").split(","), getHostCard())) { - return false; - } + return matchesValid(runParams.get("Token"), getParam("ValidToken").split(","), getHostCard()); } else { // in case RE is not updated yet return false; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java b/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java index d1d4bbe2845..67feac6bdbd 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java @@ -30,9 +30,7 @@ public class ReplaceTurnFaceUp extends ReplacementEffect { return false; } if (this.getMapParams().containsKey("ValidCard")) { - if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) { - return false; - } + return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java b/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java index d336af27279..898ec36bfea 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java @@ -63,9 +63,7 @@ public class ReplaceUntap extends ReplacementEffect { final Card card = (Card) o; // all replace untap with untapStep does have "your untap step" final Player player = card.getController(); - if (!player.getGame().getPhaseHandler().is(PhaseType.UNTAP, player)) { - return false; - } + return player.getGame().getPhaseHandler().is(PhaseType.UNTAP, player); } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplacementResult.java b/forge-game/src/main/java/forge/game/replacement/ReplacementResult.java index bdbf0705124..a60f85d12ce 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplacementResult.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplacementResult.java @@ -8,5 +8,5 @@ public enum ReplacementResult { Replaced, NotReplaced, Prevented, - Updated; + Updated } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplacementType.java b/forge-game/src/main/java/forge/game/replacement/ReplacementType.java index 9d420ef7199..0f10844b665 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplacementType.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplacementType.java @@ -29,7 +29,7 @@ public enum ReplacementType { Untap(ReplaceUntap.class); Class clasz; - private ReplacementType(Class cls) { + ReplacementType(Class cls) { clasz = cls; } diff --git a/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java b/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java index 9d2d71e1f38..b3b9040bf61 100644 --- a/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java +++ b/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java @@ -97,8 +97,7 @@ public class AbilityManaPart implements java.io.Serializable { this.addsKeywordsUntil = params.get("AddsKeywordsUntil"); this.addsCounters = params.get("AddsCounters"); this.triggersWhenSpent = params.get("TriggersWhenSpent"); - this.persistentMana = (null == params.get("PersistentMana")) ? false : - "True".equalsIgnoreCase(params.get("PersistentMana")); + this.persistentMana = (null != params.get("PersistentMana")) && "True".equalsIgnoreCase(params.get("PersistentMana")); this.manaReplaceType = params.containsKey("ManaReplaceType") ? params.get("ManaReplaceType") : ""; } @@ -489,12 +488,8 @@ public class AbilityManaPart implements java.io.Serializable { * @return a boolean. */ public final boolean isBasic() { - if (this.getOrigProduced().length() != 1 && !this.getOrigProduced().contains("Any") - && !this.getOrigProduced().contains("Chosen")) { - return false; - } - - return true; + return this.getOrigProduced().length() == 1 || this.getOrigProduced().contains("Any") + || this.getOrigProduced().contains("Chosen"); } /** {@inheritDoc} */ diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index fb8389a1af7..2ec5dac8bc2 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -118,7 +118,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit private boolean basicLandAbility = false; private SplitSide splitSide = null; - enum SplitSide { LEFT, RIGHT }; + enum SplitSide { LEFT, RIGHT } + private int totalManaSpent = 0; /** The pay costs. */ @@ -209,7 +210,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit @Override public boolean equals(final Object obj) { return obj instanceof SpellAbility && this.id == ((SpellAbility) obj).id; - }; + } @Override public void setHostCard(final Card c) { @@ -271,7 +272,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit if (isPwAbility()) { return false; //Loyalty ability, not a mana ability. } - if (isWrapper() && ((WrappedAbility) this).getTrigger().getMode() != TriggerType.TapsForMana) { + if (isWrapper() && this.getTrigger().getMode() != TriggerType.TapsForMana) { return false; } @@ -1428,10 +1429,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit maxTargets = Integer.parseInt(this.getHostCard().getSVar("CostCountersRemoved")); } - if (minTargets > numTargets || maxTargets < numTargets) { - return false; - } - return true; + return minTargets <= numTargets && maxTargets >= numTargets; } /** *

@@ -1722,10 +1720,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit if (isSpell() && text.contains("was spent to cast")) { return true; } - if (isAbility() && text.contains("mana spent to pay")) { - return true; - } - return false; + return isAbility() && text.contains("mana spent to pay"); } public void checkActivationResloveSubs() { 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 c53c34bd3ce..80fe9bedd26 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -444,9 +444,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables { final int svarValue = AbilityUtils.calculateAmount(host, this.getsVarToCheck(), sa); final int operandValue = AbilityUtils.calculateAmount(host, this.getsVarOperand(), sa); - if (!Expressions.compare(svarValue, this.getsVarOperator(), operandValue)) { - return false; - } + return Expressions.compare(svarValue, this.getsVarOperator(), operandValue); } diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index bc3e6649da4..01c1b2ea326 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -270,11 +270,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } // TODO: this is an exception for Aftermath. Needs to be somehow generalized. - if (this.getZone() != ZoneType.Graveyard && sa.isAftermath() && sa.isRightSplit()) { - return false; - } - - return true; + return this.getZone() == ZoneType.Graveyard || !sa.isAftermath() || !sa.isRightSplit(); } } return false; @@ -315,9 +311,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } } - if (!isPhase) { - return false; - } + return isPhase; } return true; } @@ -356,9 +350,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { if (sa.isSpell()) { final CardPlayOption o = c.mayPlay(sa.getMayPlay()); - if (o != null && o.getPlayer() == activator) { - return true; - } + return o != null && o.getPlayer() == activator; } return false; @@ -515,9 +507,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { final int svarValue = AbilityUtils.calculateAmount(sa.getHostCard(), this.getsVarToCheck(), sa); final int operandValue = AbilityUtils.calculateAmount(sa.getHostCard(), this.getsVarOperand(), sa); - if (!Expressions.compare(svarValue, this.getsVarOperator(), operandValue)) { - return false; - } + return Expressions.compare(svarValue, this.getsVarOperator(), operandValue); } return true; } @@ -582,9 +572,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { int gameActivationLimit = AbilityUtils.calculateAmount(c, limit, sa); this.setGameActivationLimit(gameActivationLimit); - if ((this.getGameActivationLimit() != -1) && (sa.getActivationsThisGame() >= this.getGameActivationLimit())) { - return false; - } + return (this.getGameActivationLimit() == -1) || (sa.getActivationsThisGame() < this.getGameActivationLimit()); } return true; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityStackInstance.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityStackInstance.java index bf6a8e8a045..048014c7684 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityStackInstance.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityStackInstance.java @@ -314,7 +314,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView { // try to deduce which target has been replaced // (this may be imprecise, updateTarget should specify old target if possible) for (Object obj : map.keySet()) { - if (!target.getTargets().contains((GameObject)obj)) { + if (!target.getTargets().contains(obj)) { toRemove = obj; break; } diff --git a/forge-game/src/main/java/forge/game/spellability/SpellPermanent.java b/forge-game/src/main/java/forge/game/spellability/SpellPermanent.java index 8b04a632bb3..4d0a734746a 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellPermanent.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellPermanent.java @@ -48,7 +48,7 @@ public class SpellPermanent extends SpellApiBased { */ public SpellPermanent(final Card sourceCard) { super(sourceCard.isCreature() ? ApiType.PermanentCreature : ApiType.PermanentNoncreature, sourceCard, - new Cost(sourceCard.getManaCost(), false), null, Maps.newHashMap()); + new Cost(sourceCard.getManaCost(), false), null, Maps.newHashMap()); // reset StackDescription for something with Text this.setStackDescription(""); 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 305b77f6950..270e57585b2 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetRestrictions.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetRestrictions.java @@ -773,9 +773,7 @@ public class TargetRestrictions { * @param portionAllocated the divided portion allocated */ public final void addDividedAllocation(final Object tgt, final Integer portionAllocated) { - if (this.dividedMap.containsKey(tgt)) { - this.dividedMap.remove(tgt); - } + this.dividedMap.remove(tgt); this.dividedMap.put(tgt, portionAllocated); } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java index 0c01ab230e9..bb4a0f6e37b 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java @@ -516,12 +516,8 @@ public class StaticAbility extends CardTraitBase implements Comparable thisTurnCast = CardUtil.getThisTurnCast(valid, card); - if (CardLists.filterControlledBy(thisTurnCast, activator).size() < limit) { - return false; - } + return CardLists.filterControlledBy(thisTurnCast, activator).size() >= limit; } return true; @@ -138,12 +136,8 @@ public class StaticAbilityCantBeCast { return false; } - if (params.containsKey("NonActivatorTurn") && (activator != null) - && activator.getGame().getPhaseHandler().isPlayerTurn(activator)) { - return false; - } - - return true; + return !params.containsKey("NonActivatorTurn") || (activator == null) + || !activator.getGame().getPhaseHandler().isPlayerTurn(activator); } /** @@ -174,12 +168,8 @@ public class StaticAbilityCantBeCast { } } - if (params.containsKey("Player") && (player != null) - && !player.isValid(params.get("Player"), hostCard.getController(), hostCard, null)) { - return false; - } - - return true; + return !params.containsKey("Player") || (player == null) + || player.isValid(params.get("Player"), hostCard.getController(), hostCard, null); } } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java index 72331cbb9af..e43f48cb517 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java @@ -17,16 +17,11 @@ public class StaticAbilityCantPutCounter { } } + // for the other part if (staticAbility.hasParam("ValidCard")) { - if (!card.isValid(staticAbility.getParam("ValidCard").split(","), hostCard.getController(), hostCard, null)) { - return false; - } - } else if (staticAbility.hasParam("ValidPlayer")) { - // for the other part - return false; - } + return card.isValid(staticAbility.getParam("ValidCard").split(","), hostCard.getController(), hostCard, null); + } else return !staticAbility.hasParam("ValidPlayer"); - return true; } public static boolean applyCantPutCounter(final StaticAbility staticAbility, final Player player, @@ -40,15 +35,10 @@ public class StaticAbilityCantPutCounter { } } + // for the other part if (staticAbility.hasParam("ValidPlayer")) { - if (!player.isValid(staticAbility.getParam("ValidPlayer").split(","), hostCard.getController(), hostCard, null)) { - return false; - } - } else if (staticAbility.hasParam("ValidCard")) { - // for the other part - return false; - } + return player.isValid(staticAbility.getParam("ValidPlayer").split(","), hostCard.getController(), hostCard, null); + } else return !staticAbility.hasParam("ValidCard"); - return true; } } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantTarget.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantTarget.java index 1667633ef1e..91ab7dc10bd 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantTarget.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantTarget.java @@ -99,7 +99,7 @@ public class StaticAbilityCantTarget { if (params.containsKey("Hexproof") && (activator != null)) { for (String k : activator.getKeywords()) { if (k.startsWith("IgnoreHexproof")) { - String m[] = k.split(":"); + String[] m = k.split(":"); if (card.isValid(m[1].split(","), activator, source, spellAbility)) { return false; } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 4126ddca865..3e6b6e3fb86 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -627,7 +627,7 @@ public final class StaticAbilityContinuous { for (String rep : addReplacements) { final ReplacementEffect actualRep = ReplacementHandler.parseReplacement(rep, affectedCard, false); actualRep.setIntrinsic(false); - affectedCard.addReplacementEffect(actualRep).setTemporary(true);; + affectedCard.addReplacementEffect(actualRep).setTemporary(true); } } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityETBTapped.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityETBTapped.java index db69215e01e..43dd0cb64df 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityETBTapped.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityETBTapped.java @@ -39,12 +39,8 @@ public class StaticAbilityETBTapped { final Map params = stAb.getMapParams(); final Card hostCard = stAb.getHostCard(); - if (params.containsKey("ValidCard") - && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null)) { - return false; - } - - return true; + return !params.containsKey("ValidCard") + || card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard, null); } } diff --git a/forge-game/src/main/java/forge/game/trigger/Trigger.java b/forge-game/src/main/java/forge/game/trigger/Trigger.java index e901efcb665..1ff3deaf234 100644 --- a/forge-game/src/main/java/forge/game/trigger/Trigger.java +++ b/forge-game/src/main/java/forge/game/trigger/Trigger.java @@ -284,9 +284,7 @@ public abstract class Trigger extends TriggerReplacementBase { if (this.mapParams.containsKey("TurnCount")) { int turn = Integer.parseInt(this.mapParams.get("TurnCount")); - if (phaseHandler.getTurn() != turn) { - return false; - } + return phaseHandler.getTurn() == turn; } return true; @@ -356,10 +354,7 @@ public abstract class Trigger extends TriggerReplacementBase { } } - if ( !meetsCommonRequirements(this.mapParams)) - return false; - - return true; + return meetsCommonRequirements(this.mapParams); } @@ -382,8 +377,7 @@ public abstract class Trigger extends TriggerReplacementBase { String condition = this.mapParams.get("Condition"); if ("AltCost".equals(condition)) { final Card moved = (Card) runParams.get("Card"); - if( null != moved && !moved.isOptionalCostPaid(OptionalCost.AltCost)) - return false; + return null == moved || moved.isOptionalCostPaid(OptionalCost.AltCost); } else if ("AttackedPlayerWithMostLife".equals(condition)) { GameEntity attacked = (GameEntity) runParams.get("Attacked"); if (attacked == null) { @@ -391,10 +385,8 @@ public abstract class Trigger extends TriggerReplacementBase { // ends up being in Defender at that point. attacked = (GameEntity) runParams.get("Defender"); } - if (attacked == null || !attacked.isValid("Player.withMostLife", - this.getHostCard().getController(), this.getHostCard(), null)) { - return false; - } + return attacked != null && attacked.isValid("Player.withMostLife", + this.getHostCard().getController(), this.getHostCard(), null); } else if ("AttackedPlayerWhoAttackedYouLastTurn".equals(condition)) { GameEntity attacked = (GameEntity) runParams.get("Attacked"); if (attacked == null) { @@ -411,9 +403,7 @@ public abstract class Trigger extends TriggerReplacementBase { } } - if (attacked == null || !valid) { - return false; - } + return attacked != null && valid; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java b/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java index a07aff661d8..4aba396ab93 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java @@ -49,10 +49,8 @@ public class TriggerAbandoned extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Scheme"), this.mapParams.get("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Scheme"), this.mapParams.get("ValidCard").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java b/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java index 5a603b715c8..efd19c6340c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java @@ -52,10 +52,8 @@ public class TriggerAdapt extends Trigger { public final boolean performTest(final Map runParams2) { final Card sac = (Card) runParams2.get("Card"); if (hasParam("ValidCard")) { - if (!sac.isValid(getParam("ValidCard").split(","), getHostCard().getController(), - getHostCard(), null)) { - return false; - } + return sac.isValid(getParam("ValidCard").split(","), getHostCard().getController(), + getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java index f185d57a441..a4051152221 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java @@ -60,9 +60,7 @@ public class TriggerAttached extends Trigger { } if (this.mapParams.containsKey("ValidTarget")) { - if (!matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard())) { - return false; - } + return matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java index 89136658f35..d8a57921a46 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java @@ -73,9 +73,7 @@ public class TriggerAttackerBlocked extends Trigger { getHostCard().getController(), getHostCard() ); - if ( count == 0 ) { - return false; - } + return count != 0; } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java index 4f4ae302f7a..8edc3ad202c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java @@ -73,12 +73,8 @@ public class TriggerAttackerBlockedByCreature extends Trigger { if (this.mapParams.containsKey("ValidBlocker")) { final String validBlocker = this.mapParams.get("ValidBlocker"); if (validBlocker.equals("LessPowerThanAttacker")) { - if (blocker.getNetPower() >= attacker.getNetPower()) { - return false; - } - } else if (!matchesValid(blocker, validBlocker.split(","), this.getHostCard())) { - return false; - } + return blocker.getNetPower() < attacker.getNetPower(); + } else return matchesValid(blocker, validBlocker.split(","), this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java index c9ac21fc4bd..ec0bfa5c95b 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java @@ -58,10 +58,8 @@ public class TriggerAttackerUnblocked extends Trigger { } } if (this.mapParams.containsKey("ValidDefender")) { - if (!matchesValid(runParams2.get("Defender"), this.mapParams.get("ValidDefender").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Defender"), this.mapParams.get("ValidDefender").split(","), + this.getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java index 66ed8f5c01b..06f7e06590f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java @@ -73,10 +73,8 @@ public class TriggerAttackerUnblockedOnce extends Trigger { */ } if (hasParam("ValidAttackingPlayer")) { - if (!matchesValid(runParams2.get("AttackingPlayer"), - this.mapParams.get("ValidAttackingPlayer").split(","), this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("AttackingPlayer"), + this.mapParams.get("ValidAttackingPlayer").split(","), this.getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java index 72f9649bba1..8f00fbf3d33 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java @@ -76,9 +76,7 @@ public class TriggerAttackersDeclared extends Trigger { valid = true; } } - if (!valid) { - return false; - } + return valid; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java index 0f28b513ce6..971d4299bd7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java @@ -113,9 +113,7 @@ public class TriggerAttacks extends Trigger { } } } - if (!found) { - return false; - } + return found; } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java index 17d9840f804..26a0deae9ef 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java @@ -24,10 +24,8 @@ public class TriggerBecomeMonarch extends Trigger { } if (this.mapParams.containsKey("BeginTurn")) { - if (!matchesValid(game.getMonarchBeginTurn(), this.mapParams.get("BeginTurn").split(","), - host)) { - return false; - } + return matchesValid(game.getMonarchBeginTurn(), this.mapParams.get("BeginTurn").split(","), + host); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java index 5a70ce99648..9b914392737 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java @@ -52,10 +52,8 @@ public class TriggerBecomeMonstrous extends Trigger { @Override public final boolean performTest(Map runParams2) { if (hasParam("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java index ab84910d4cf..f0da7bc86b9 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java @@ -50,10 +50,8 @@ public class TriggerBecomeRenowned extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java index 097262f0c51..3bdfa10004f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java @@ -77,9 +77,7 @@ public class TriggerBecomesTarget extends Trigger { } } if (this.mapParams.containsKey("FirstTime")) { - if (!runParams2.containsKey("FirstTime")) { - return false; - } + return runParams2.containsKey("FirstTime"); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java index bd8a2868c51..6707812b470 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java @@ -70,9 +70,7 @@ public class TriggerBecomesTargetOnce extends Trigger { break; } } - if (!valid) { - return false; - } + return valid; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java b/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java index 1f351c52813..06f7e300693 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java @@ -76,10 +76,8 @@ public class TriggerBlocks extends Trigger { break; } } - - if (!foundMatch) { - return false; - } + + return foundMatch; } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java b/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java index 2604e2d55c7..1611f9c7595 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java @@ -60,10 +60,8 @@ public class TriggerChampioned extends Trigger { } } if (this.mapParams.containsKey("ValidSource")) { - if (!source.isValid(this.mapParams.get("ValidSource").split(","), - this.getHostCard().getController(), this.getHostCard(), null)) { - return false; - } + return source.isValid(this.mapParams.get("ValidSource").split(","), + this.getHostCard().getController(), this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java index 31a073b8508..b394980a87d 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java @@ -58,10 +58,8 @@ public class TriggerChangesController extends Trigger { } } if (this.mapParams.containsKey("ValidOriginalController")) { - if (!matchesValid(runParams2.get("OriginalController"), this.mapParams.get("ValidOriginalController").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("OriginalController"), this.mapParams.get("ValidOriginalController").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java index 0993e8dae29..f49005ac74a 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java @@ -17,11 +17,7 @@ public class TriggerChangesZoneAll extends Trigger { public boolean performTest(Map runParams2) { final CardZoneTable table = (CardZoneTable) runParams2.get("Cards"); - if (filterCards(table).isEmpty()) { - return false; - } - - return true; + return !filterCards(table).isEmpty(); } @Override diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java b/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java index 8caaf85c7ef..a2eec1db4d7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java @@ -59,9 +59,7 @@ public class TriggerClashed extends Trigger { } if (this.mapParams.containsKey("Won")) { - if (!this.mapParams.get("Won").equals(runParams2.get("Won"))) { - return false; - } + return this.mapParams.get("Won").equals(runParams2.get("Won")); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java index 26f64523bdc..9e8e0b4d288 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java @@ -109,9 +109,7 @@ public class TriggerCounterAdded extends Trigger { final int operand = Integer.parseInt(fullParam.substring(2)); final int actualAmount = (Integer) runParams2.get("CounterAmount"); - if (!Expressions.compare(actualAmount, operator, operand)) { - return false; - } + return Expressions.compare(actualAmount, operator, operand); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedAll.java index 8becd1a4ded..94b49909f02 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedAll.java @@ -19,11 +19,7 @@ public class TriggerCounterAddedAll extends Trigger { public boolean performTest(Map runParams2) { final GameEntityCounterTable table = (GameEntityCounterTable) runParams2.get("Objects"); - if (filterTable(table).isEmpty()) { - return false; - } - - return true; + return !filterTable(table).isEmpty(); } @Override diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java index 549a3d81670..65ea6cc7e18 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java @@ -93,10 +93,8 @@ public class TriggerCounterAddedOnce extends Trigger { return false; } - if (!source.isValid(getParam("ValidSource").split(","), getHostCard().getController(), - getHostCard(), null)) { - return false; - } + return source.isValid(getParam("ValidSource").split(","), getHostCard().getController(), + getHostCard(), null); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java index 46e0bc5fa41..eec54b27f2f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java @@ -71,9 +71,7 @@ public class TriggerCounterRemoved extends Trigger { if (hasParam("NewCounterAmount")) { final String amtString = getParam("NewCounterAmount"); int amt = Integer.parseInt(amtString); - if(amt != addedNewCounterAmount.intValue()) { - return false; - } + return amt == addedNewCounterAmount.intValue(); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java index 4e02b6d8df4..888ab7027dc 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java @@ -62,9 +62,7 @@ public class TriggerCounterRemovedOnce extends Trigger { if (hasParam("CounterType")) { final String type = getParam("CounterType"); - if (!type.equals(removedType.toString())) { - return false; - } + return type.equals(removedType.toString()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java b/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java index 0b11585be24..a31fab2f15e 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java @@ -80,9 +80,7 @@ public class TriggerCountered extends Trigger { if (ctrdSA != null) { if (validType.equals("Spell") && !ctrdSA.isSpell()) { return false; - } else if (validType.equals("Ability") && !ctrdSA.isAbility()) { - return false; - } + } else return !validType.equals("Ability") || ctrdSA.isAbility(); } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCycled.java b/forge-game/src/main/java/forge/game/trigger/TriggerCycled.java index a13e8664d9e..d62f0f8f58c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCycled.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCycled.java @@ -63,10 +63,8 @@ public class TriggerCycled extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), + this.getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java index 7b4331ddb06..88e9ea45135 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java @@ -94,9 +94,7 @@ public class TriggerDamageDealtOnce extends Trigger { final int operand = Integer.parseInt(fullParam.substring(2)); final int actualAmount = (Integer) runParams2.get("DamageAmount"); - if (!Expressions.compare(actualAmount, operator, operand)) { - return false; - } + return Expressions.compare(actualAmount, operator, operand); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java index d5a9634cc39..bed6d6bc1a3 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java @@ -45,9 +45,7 @@ public class TriggerDamageDoneOnce extends Trigger { } if (this.mapParams.containsKey("ValidTarget")) { - if (!matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard())) { - return false; - } + return matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard()); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java b/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java index cd533694d4f..9686ea9fd29 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java @@ -57,9 +57,7 @@ public class TriggerDestroyed extends Trigger { } } if (hasParam("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDevoured.java b/forge-game/src/main/java/forge/game/trigger/TriggerDevoured.java index f067b7a179a..ac8002f5682 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDevoured.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDevoured.java @@ -51,10 +51,8 @@ public class TriggerDevoured extends Trigger { public final boolean performTest(final java.util.Map runParams2) { final Card sac = (Card) runParams2.get("Devoured"); if (this.mapParams.containsKey("ValidDevoured")) { - if (!sac.isValid(this.mapParams.get("ValidDevoured").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return sac.isValid(this.mapParams.get("ValidDevoured").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java b/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java index 0c60b064149..f8a5f7d8d7a 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java @@ -74,9 +74,7 @@ public class TriggerDiscarded extends Trigger { } if (this.mapParams.containsKey("IsMadness")) { Boolean madness = (Boolean) runParams2.get("IsMadness"); - if (this.mapParams.get("IsMadness").equals("True") ^ madness) { - return false; - } + return !(this.mapParams.get("IsMadness").equals("True") ^ madness); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java b/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java index 7e236166d20..c9a761ac3ec 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java @@ -70,11 +70,7 @@ public class TriggerDrawn extends Trigger { } // trigger should not happen while Mulligan - if (game.getAge() == GameStage.Mulligan) { - return false; - } - - return true; + return game.getAge() != GameStage.Mulligan; } /** {@inheritDoc} */ diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerEvolved.java b/forge-game/src/main/java/forge/game/trigger/TriggerEvolved.java index a85c4479cb3..71c0af1aac8 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerEvolved.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerEvolved.java @@ -52,10 +52,8 @@ public class TriggerEvolved extends Trigger { public final boolean performTest(final Map runParams2) { final Card sac = (Card) runParams2.get("Card"); if (hasParam("ValidCard")) { - if (!sac.isValid(getParam("ValidCard").split(","), getHostCard().getController(), - getHostCard(), null)) { - return false; - } + return sac.isValid(getParam("ValidCard").split(","), getHostCard().getController(), + getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerExerted.java b/forge-game/src/main/java/forge/game/trigger/TriggerExerted.java index 2005d7fdc40..d4006d908e5 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerExerted.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerExerted.java @@ -24,10 +24,8 @@ public class TriggerExerted extends Trigger { public boolean performTest(Map runParams2) { final Card exerter = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - if (!exerter.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return exerter.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java b/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java index 3592a8d0adf..e12e4320903 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java @@ -84,10 +84,8 @@ public class TriggerExiled extends Trigger { if (cause == null) { return false; } - if (!cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(), - getHostCard(), null)) { - return false; - } + return cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(), + getHostCard(), null); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java b/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java index dd566071c3c..2a4093ff1b2 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java @@ -60,10 +60,8 @@ public class TriggerExploited extends Trigger { } } if (this.mapParams.containsKey("ValidSource")) { - if (!source.isValid(this.mapParams.get("ValidSource").split(","), - this.getHostCard().getController(), this.getHostCard(), null)) { - return false; - } + return source.isValid(this.mapParams.get("ValidSource").split(","), + this.getHostCard().getController(), this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerExplores.java b/forge-game/src/main/java/forge/game/trigger/TriggerExplores.java index 5b15c7db8da..69e458136a9 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerExplores.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerExplores.java @@ -51,10 +51,8 @@ public class TriggerExplores extends Trigger { @Override public final boolean performTest(final Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerFight.java b/forge-game/src/main/java/forge/game/trigger/TriggerFight.java index 65ee54f09f4..e45b2eeda7e 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerFight.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerFight.java @@ -53,10 +53,8 @@ public class TriggerFight extends Trigger { final Card fighter = (Card) runParams2.get("Fighter"); if (this.mapParams.containsKey("ValidCard")) { - if (!fighter.isValid(this.mapParams.get("ValidCard").split(","), - this.getHostCard().getController(), this.getHostCard(), null)) { - return false; - } + return fighter.isValid(this.mapParams.get("ValidCard").split(","), + this.getHostCard().getController(), this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java b/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java index 3d4795f9be7..3137c5cd83f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java @@ -58,9 +58,7 @@ public class TriggerFlippedCoin extends Trigger { if (this.mapParams.containsKey("ValidResult")) { final boolean result = (Boolean) runParams2.get("Result"); final boolean valid = "Win".equals(this.mapParams.get("ValidResult")); - if (result ^ valid) { - return false; - } + return !(result ^ valid); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index 0197f253336..bd43d722a0d 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -57,7 +57,7 @@ public class TriggerHandler { private final List delayedTriggers = Collections.synchronizedList(new ArrayList()); private final List thisTurnDelayedTriggers = Collections.synchronizedList(new ArrayList()); - private final ListMultimap playerDefinedDelayedTriggers = Multimaps.synchronizedListMultimap(ArrayListMultimap.create()); + private final ListMultimap playerDefinedDelayedTriggers = Multimaps.synchronizedListMultimap(ArrayListMultimap.create()); private final List waitingTriggers = Collections.synchronizedList(new ArrayList()); private final Game game; @@ -536,9 +536,7 @@ public class TriggerHandler { final String dest = (String) runParams.get("Destination"); if (dest.equals("Battlefield") && runParams.get("Card") instanceof Card) { final Card card = (Card) runParams.get("Card"); - if (card.isCreature()) { - return false; - } + return !card.isCreature(); } } } // Torpor Orb check diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java b/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java index 89f3a10341d..cb82452b8a5 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java @@ -73,9 +73,7 @@ public class TriggerInvestigated extends Trigger { } if (this.mapParams.containsKey("OnlyFirst")) { - if ((int) runParams2.get("Num") != 1) { - return false; - } + return (int) runParams2.get("Num") == 1; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java b/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java index 0622263bdce..2498fb1d58f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java @@ -72,9 +72,7 @@ public class TriggerLandPlayed extends Trigger { } if (this.mapParams.containsKey("NotFirstLand")) { - if (land.getController().getLandsPlayedThisTurn() < 1) { - return false; - } + return land.getController().getLandsPlayedThisTurn() >= 1; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java b/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java index 599594075a5..8c44cee9063 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java @@ -62,9 +62,7 @@ public class TriggerLifeGained extends Trigger { } if (hasParam("Spell")) { final SpellAbility spellAbility = (SpellAbility) runParams2.get("SourceSA"); - if (spellAbility == null || !spellAbility.getRootAbility().isSpell()) { - return false; - } + return spellAbility != null && spellAbility.getRootAbility().isSpell(); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java b/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java index d905e1c8b07..60998db1fdb 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java @@ -59,9 +59,7 @@ public class TriggerLifeLost extends Trigger { } if (this.mapParams.containsKey("FirstTime")) { - if (!(boolean)runParams2.get("FirstTime")) { - return false; - } + return (boolean) runParams2.get("FirstTime"); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLosesGame.java b/forge-game/src/main/java/forge/game/trigger/TriggerLosesGame.java index b9aa5c4028e..931ef32c740 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLosesGame.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLosesGame.java @@ -28,10 +28,8 @@ public class TriggerLosesGame extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java b/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java index bf13399f36e..365aecf8b92 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java @@ -57,10 +57,8 @@ public class TriggerPayCumulativeUpkeep extends Trigger { } final Card card = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - if (!card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java b/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java index f9e7ecabf45..c6a9c567f8e 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java @@ -57,10 +57,8 @@ public class TriggerPayEcho extends Trigger { } final Card card = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - if (!card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPayLife.java b/forge-game/src/main/java/forge/game/trigger/TriggerPayLife.java index 0dcdb617893..4616f0db3a9 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPayLife.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPayLife.java @@ -51,9 +51,7 @@ public class TriggerPayLife extends Trigger { @Override public final boolean performTest(final Map runParams2) { if (hasParam("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), getParam("ValidPlayer").split(","), getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Player"), getParam("ValidPlayer").split(","), getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPhase.java b/forge-game/src/main/java/forge/game/trigger/TriggerPhase.java index 843368ac05d..3fbe945effc 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPhase.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPhase.java @@ -50,10 +50,8 @@ public class TriggerPhase extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), + this.getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseIn.java b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseIn.java index a9cac8b0db5..c3b4aa6e789 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseIn.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseIn.java @@ -17,10 +17,8 @@ public class TriggerPhaseIn extends Trigger { final Card phaser = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - if (!phaser.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return phaser.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java index d0abe3e4747..530544ea3c4 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java @@ -20,13 +20,9 @@ public class TriggerPhaseOut extends Trigger { if (this.mapParams.get("ValidCard").equals("Card.Self")) { // Since Phased out cards aren't visible in .isValid, use a special check here. // NOTE: All Phase Out Triggers should use ValidCard$ Card.Self - if (phaser != this.getHostCard()) { - return false; - } - } else if (!phaser.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return phaser == this.getHostCard(); + } else return phaser.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java b/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java index f8d1d6c18e4..87ed5e4666e 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java @@ -42,9 +42,7 @@ public class TriggerPlanarDice extends Trigger { if (this.mapParams.containsKey("Result")) { PlanarDice cond = PlanarDice.smartValueOf(this.mapParams.get("Result")); - if (cond != ((PlanarDice) runParams2.get("Result"))) { - return false; - } + return cond == runParams2.get("Result"); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java b/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java index cd9f836c466..42483ab6abc 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java @@ -57,9 +57,7 @@ public class TriggerRegenerated extends Trigger { } } if (hasParam("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java b/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java index 59d8d29d926..e75ff3c88c0 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java @@ -22,9 +22,7 @@ public class TriggerRevealed extends Trigger { } if (this.mapParams.containsKey("Miracle")) { Boolean madness = (Boolean) runParams2.get("Miracle"); - if (this.mapParams.get("Miracle").equals("True") ^ madness) { - return false; - } + return !(this.mapParams.get("Miracle").equals("True") ^ madness); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java b/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java index 64e545483fb..4ece31285c7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java @@ -114,8 +114,7 @@ public class TriggerSacrificed extends Trigger { } } - if (!withKeyword) - return false; + return withKeyword; } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerScry.java b/forge-game/src/main/java/forge/game/trigger/TriggerScry.java index 209f3bd5571..70be461dde3 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerScry.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerScry.java @@ -50,10 +50,8 @@ public class TriggerScry extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java b/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java index 538b82670ff..52dc26d35bb 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java @@ -61,9 +61,7 @@ public class TriggerSearchedLibrary extends Trigger { if (this.mapParams.containsKey("SearchOwnLibrary")) { @SuppressWarnings("unchecked") List targets = (List) runParams2.get("Target"); - if (!targets.contains(runParams2.get("Player"))) { - return false; - } + return targets.contains(runParams2.get("Player")); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java b/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java index bdc94181666..6b3bd7fa926 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java @@ -59,13 +59,9 @@ public class TriggerSetInMotion extends Trigger { if (this.mapParams.containsKey("SchemeType")) { if (this.mapParams.get("SchemeType").equals("NonOngoing")) { - if (((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing)) { - return false; - } + return !((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing); } else if (this.mapParams.get("SchemeType").equals("Ongoing")) { - if (!((Card)runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing)) { - return false; - } + return ((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing); } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java b/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java index e8abae4f522..a351e9b31b6 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java @@ -62,9 +62,7 @@ public class TriggerShuffled extends Trigger { } if (this.mapParams.containsKey("ShuffleBySelfControlled")) { SpellAbility source = (SpellAbility) runParams2.get("Source"); - if (!source.getActivatingPlayer().equals(runParams2.get("Player"))) { - return false; - } + return source.getActivatingPlayer().equals(runParams2.get("Player")); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java index 0dc88c7c789..14312a228a3 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java @@ -252,9 +252,7 @@ public class TriggerSpellAbilityCast extends Trigger { break; } } - if (!sameNameFound) { - return false; - } + return sameNameFound; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java index 26bb022c137..cd0ee3d47f4 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java @@ -78,10 +78,8 @@ public class TriggerSpellAbilityCopy extends Trigger { } } if (hasParam("ValidActivatingPlayer")) { - if (si == null || !matchesValid(si.getSpellAbility(true).getActivatingPlayer(), getParam("ValidActivatingPlayer") - .split(","), getHostCard())) { - return false; - } + return si != null && matchesValid(si.getSpellAbility(true).getActivatingPlayer(), getParam("ValidActivatingPlayer") + .split(","), getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java b/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java index 2d3ee1dbb19..a0d16afa570 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java @@ -69,9 +69,7 @@ public class TriggerSurveil extends Trigger { } if (hasParam("OnlyFirst")) { - if ((int) runParams2.get("NumThisTurn") != 1) { - return false; - } + return (int) runParams2.get("NumThisTurn") == 1; } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java b/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java index 44185a79ef7..70ec3905557 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java @@ -60,13 +60,9 @@ public class TriggerTaps extends Trigger { } if (hasParam("Attacker")) { if ("True".equalsIgnoreCase(getParam("Attacker"))) { - if (!(Boolean)runParams2.get("Attacker")) { - return false; - } + return (Boolean) runParams2.get("Attacker"); } else if ("False".equalsIgnoreCase(getParam("Attacker"))) { - if ((Boolean)runParams2.get("Attacker")) { - return false; - } + return !((Boolean) runParams2.get("Attacker")); } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java b/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java index 348492cb775..293f2abbdaa 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java @@ -91,9 +91,7 @@ public class TriggerTapsForMana extends Trigger { } String produced = (String) prod; if ("ChosenColor".equals(mapParams.get("Produced"))) { - if (!this.getHostCard().hasChosenColor() || !produced.contains(MagicColor.toShortString(this.getHostCard().getChosenColor()))) { - return false; - } + return this.getHostCard().hasChosenColor() && produced.contains(MagicColor.toShortString(this.getHostCard().getChosenColor())); } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTransformed.java b/forge-game/src/main/java/forge/game/trigger/TriggerTransformed.java index 49bedc53cea..b1237117a44 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTransformed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTransformed.java @@ -45,10 +45,8 @@ public class TriggerTransformed extends Trigger { @Override public boolean performTest(Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Transformer"), this.mapParams.get("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Transformer"), this.mapParams.get("ValidCard").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTurnBegin.java b/forge-game/src/main/java/forge/game/trigger/TriggerTurnBegin.java index 032a6733081..aa0ac8a718d 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTurnBegin.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTurnBegin.java @@ -12,10 +12,8 @@ public class TriggerTurnBegin extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Player"), this.mapParams.get("ValidPlayer").split(","), + this.getHostCard()); } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTurnFaceUp.java b/forge-game/src/main/java/forge/game/trigger/TriggerTurnFaceUp.java index 1136077e14b..41d27376928 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTurnFaceUp.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTurnFaceUp.java @@ -50,10 +50,8 @@ public class TriggerTurnFaceUp extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), - this.getHostCard())) { - return false; - } + return matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), + this.getHostCard()); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerType.java b/forge-game/src/main/java/forge/game/trigger/TriggerType.java index 1c62481089e..952a21bb6f9 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerType.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerType.java @@ -98,7 +98,7 @@ public enum TriggerType { private final Constructor constructor; - private TriggerType(Class clasz) { + TriggerType(Class clasz) { constructor = findConstructor(clasz); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java b/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java index 8b96b06fd3f..51b07e3c862 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java @@ -60,10 +60,8 @@ public class TriggerUnattach extends Trigger { } if (hasParam("ValidAttachment")) { - if (!attach.isValid(getParam("ValidAttachment").split(","), getHostCard() - .getController(), getHostCard(), null)) { - return false; - } + return attach.isValid(getParam("ValidAttachment").split(","), getHostCard() + .getController(), getHostCard(), null); } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java b/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java index 7c583f1467d..3029fa3177f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java @@ -54,10 +54,8 @@ public class TriggerUntaps extends Trigger { final Card untapper = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - if (!untapper.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null)) { - return false; - } + return untapper.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null); } return true; 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 2fb39bf9915..bdaf3207197 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -618,7 +618,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable() { @Override public boolean apply(final Card c) { - if (!c.mayPlay(who).isEmpty() || c.mayPlayerLook(who)) { - return true; - } - return false; + return !c.mayPlay(who).isEmpty() || c.mayPlayerLook(who); } }; } diff --git a/forge-game/src/main/java/forge/game/zone/Zone.java b/forge-game/src/main/java/forge/game/zone/Zone.java index 7800e400519..000da073c7c 100644 --- a/forge-game/src/main/java/forge/game/zone/Zone.java +++ b/forge-game/src/main/java/forge/game/zone/Zone.java @@ -51,10 +51,10 @@ public class Zone implements java.io.Serializable, Iterable { protected final ZoneType zoneType; protected final Game game; - protected final transient MapOfLists cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); - protected final transient MapOfLists cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); - protected final transient MapOfLists latestStateCardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); - protected final transient MapOfLists latestStateCardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); + protected final transient MapOfLists cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); + protected final transient MapOfLists cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); + protected final transient MapOfLists latestStateCardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); + protected final transient MapOfLists latestStateCardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); public Zone(final ZoneType zone0, Game game0) { zoneType = zone0; diff --git a/forge-game/src/main/java/forge/game/zone/ZoneType.java b/forge-game/src/main/java/forge/game/zone/ZoneType.java index 283c309df0e..9f358f902de 100644 --- a/forge-game/src/main/java/forge/game/zone/ZoneType.java +++ b/forge-game/src/main/java/forge/game/zone/ZoneType.java @@ -22,10 +22,10 @@ public enum ZoneType { PlanarDeck(true), None(true); - public static final List STATIC_ABILITIES_SOURCE_ZONES = Arrays.asList(new ZoneType[]{Battlefield, Graveyard, Exile, Command/*, Hand*/}); + public static final List STATIC_ABILITIES_SOURCE_ZONES = Arrays.asList(Battlefield, Graveyard, Exile, Command/*, Hand*/); private final boolean holdsHiddenInfo; - private ZoneType(boolean holdsHidden) { + ZoneType(boolean holdsHidden) { holdsHiddenInfo = holdsHidden; } diff --git a/forge-game/src/main/java/forge/trackable/TrackableProperty.java b/forge-game/src/main/java/forge/trackable/TrackableProperty.java index bae4622580e..232788992bd 100644 --- a/forge-game/src/main/java/forge/trackable/TrackableProperty.java +++ b/forge-game/src/main/java/forge/trackable/TrackableProperty.java @@ -172,10 +172,10 @@ public enum TrackableProperty { private final TrackableType type; private final FreezeMode freezeMode; - private TrackableProperty(TrackableType type0) { + TrackableProperty(TrackableType type0) { this(type0, FreezeMode.RespectsFreeze); } - private TrackableProperty(TrackableType type0, FreezeMode freezeMode0) { + TrackableProperty(TrackableType type0, FreezeMode freezeMode0) { type = type0; freezeMode = freezeMode0; } diff --git a/forge-game/src/main/java/forge/util/MessageUtil.java b/forge-game/src/main/java/forge/util/MessageUtil.java index efdbc0c040f..ea46eeb77e3 100644 --- a/forge-game/src/main/java/forge/util/MessageUtil.java +++ b/forge-game/src/main/java/forge/util/MessageUtil.java @@ -9,7 +9,7 @@ import forge.game.spellability.SpellAbility; public class MessageUtil { - private MessageUtil() { }; + private MessageUtil() { } public static String formatMessage(String message, Player player, Object related) { if (related instanceof Player && message.indexOf("{player") >= 0) { diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index 4bafc436d96..e502263eee2 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -221,7 +221,7 @@ public final class CEditorQuest extends CDeckEditor { if (n == 0) { s = "Remove custom rating"; } else { - s = "Rate this card as " + Integer.toString(n) + " stars"; + s = "Rate this card as " + n + " stars"; } GuiUtils.addMenuItem(cmb.getMenu(), s, KeyStroke.getKeyStroke(48 + n, 0), diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestCardShop.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestCardShop.java index c9f8f5c0fb2..11e1c512e83 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestCardShop.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestCardShop.java @@ -83,10 +83,10 @@ public final class CEditorQuestCardShop extends ACEditorBase { private List fullCatalogCards; // remember changed gui elements - private String CCTabLabel = new String(); - private String CCAddLabel = new String(); - private String CDTabLabel = new String(); - private String CDRemLabel = new String(); + private String CCTabLabel = ""; + private String CCAddLabel = ""; + private String CDTabLabel = ""; + private String CDRemLabel = ""; private String prevRem4Label = null; private String prevRem4Tooltip = null; private Runnable prevRem4Cmd = null; diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/ContestGauntletLister.java b/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/ContestGauntletLister.java index f465232242b..588cf960802 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/ContestGauntletLister.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/ContestGauntletLister.java @@ -79,8 +79,8 @@ public class ContestGauntletLister extends JPanel { name = gd.getName(); name = name.substring(GauntletIO.PREFIX_LOCKED.length()); - progress = String.valueOf(Math.round( - ((double) gd.getCompleted() / (double) gd.getDecks().size()) * 100)) + " %"; + progress = Math.round( + ((double) gd.getCompleted() / (double) gd.getDecks().size()) * 100) + " %"; if (gd.getUserDeck() == null) { progress = "---"; 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 1938459912c..b0e9d04cfdb 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 @@ -110,8 +110,8 @@ public class QuickGauntletLister extends JPanel { row.add(new FLabel.Builder().text(String.valueOf(gd.getDecks().size())) .fontAlign(SwingConstants.RIGHT).build(), "w 90px!, h 20px!, gap 0 0 5px 0"); - row.add(new FLabel.Builder().text(String.valueOf(Math.round( - ((double) gd.getCompleted() / (double) gd.getDecks().size()) * 100)) + "%") + row.add(new FLabel.Builder().text(Math.round( + ((double) gd.getCompleted() / (double) gd.getDecks().size()) * 100) + "%") .fontAlign(SwingConstants.RIGHT).build(), "w 90px!, h 20px!, gap 0 0 5px 0"); this.add(row, "w 98%!, h 30px!, gap 1% 0 0 0"); diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java b/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java index 3813522c759..65454ac06ce 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java @@ -49,7 +49,7 @@ public enum VSubmenuQuestData implements IVSubmenu { private final FLabel lblTitleNew = new FLabel.Builder().text(localizer.getMessage("lblStartanewQuest")).opaque(true).fontSize(16).build(); - String str=new String( ForgeConstants.QUEST_SAVE_DIR.replace('\\', '/')); + String str= ForgeConstants.QUEST_SAVE_DIR.replace('\\', '/'); private final FLabel lblOldQuests = new FLabel.Builder().text(localizer.getMessage("lblOldQuestData").replace("%s",str)).fontAlign(SwingConstants.CENTER).fontSize(12).build(); private final QuestFileLister lstQuests = new QuestFileLister(); private final FScrollPane scrQuests = new FScrollPane(lstQuests, false); diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/quest/ViewItem.java b/forge-gui-desktop/src/main/java/forge/screens/home/quest/ViewItem.java index 002165d9255..31b8aa1a43b 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/quest/ViewItem.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/quest/ViewItem.java @@ -89,7 +89,7 @@ public class ViewItem extends FPanel { ViewItem.this.lblIcon.setIcon(i); ViewItem.this.lblName.setText(bazaarItem.getPurchaseName()); - ViewItem.this.lblPrice.setText("Cost: " + String.valueOf(bazaarItem.getBuyingPrice(qA)) + " credits"); + ViewItem.this.lblPrice.setText("Cost: " + bazaarItem.getBuyingPrice(qA) + " credits"); String desc = bazaarItem.getPurchaseDescription(qA); ViewItem.this.tarDesc.setText(FSkin.encodeSymbols(desc, false)); //encode in case there are mana symbols in description 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 1d6b5532257..dc80e578182 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 @@ -101,7 +101,6 @@ import forge.util.gui.SOptionPane; import forge.view.FView; import forge.view.arcane.CardPanel; import forge.view.arcane.FloatingZone; -import forge.match.input.*; /** * Constructs instance of match UI controller, used as a single point of diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/VAssignDamage.java b/forge-gui-desktop/src/main/java/forge/screens/match/VAssignDamage.java index 9e9fcb0df1d..8b4717a3929 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/VAssignDamage.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/VAssignDamage.java @@ -174,7 +174,7 @@ public class VAssignDamage { final JPanel pnlDefenders = new JPanel(); pnlDefenders.setOpaque(false); int cols = attackerHasTrample ? blockers.size() + 1 : blockers.size(); - final String wrap = "wrap " + Integer.toString(cols); + final String wrap = "wrap " + cols; pnlDefenders.setLayout(new MigLayout("insets 0, gap 0, ax center, " + wrap)); final FScrollPane scrDefenders = new FScrollPane(pnlDefenders, false); diff --git a/forge-gui-desktop/src/main/java/forge/toolbox/imaging/FImagePanel.java b/forge-gui-desktop/src/main/java/forge/toolbox/imaging/FImagePanel.java index 1bfcdd2b460..9c53990d84d 100644 --- a/forge-gui-desktop/src/main/java/forge/toolbox/imaging/FImagePanel.java +++ b/forge-gui-desktop/src/main/java/forge/toolbox/imaging/FImagePanel.java @@ -282,7 +282,7 @@ public class FImagePanel extends JPanel { at.translate(this.getWidth() / 2, this.getHeight() / 2); // 3. rotate around (0,0). - at.rotate(Math.toRadians((double) degreesOfRotation)); + at.rotate(Math.toRadians(degreesOfRotation)); // 2. scale image. if (createScaleTransform) { diff --git a/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java b/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java index 79fa196ba8f..79c32a486cc 100644 --- a/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java +++ b/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java @@ -213,7 +213,7 @@ public class PlayerDetailsPanel extends JPanel { } public void setToolTip(final String... args) { - super.setToolTipText(String.format(tooltip, (Object[]) args)); + super.setToolTipText(String.format(tooltip, args)); } @Override diff --git a/forge-gui-desktop/src/main/java/forge/view/arcane/CardPanel.java b/forge-gui-desktop/src/main/java/forge/view/arcane/CardPanel.java index 0ae68b24e79..e3d2270d7dd 100644 --- a/forge-gui-desktop/src/main/java/forge/view/arcane/CardPanel.java +++ b/forge-gui-desktop/src/main/java/forge/view/arcane/CardPanel.java @@ -693,7 +693,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl titleText.setText(card.getCurrentState().getName()); final int damage = card.getDamage(); - damageText.setText(damage > 0 ? "\u00BB " + String.valueOf(damage) + " \u00AB" : ""); + damageText.setText(damage > 0 ? "\u00BB " + damage + " \u00AB" : ""); // Card Id overlay cardIdText.setText(card.getCurrentState().getDisplayId()); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index 3eedba838c6..d74ac25ac6d 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -109,7 +109,7 @@ public class PlanarConquestCommanderGeneraterGA extends PlanarConquestGeneraterG @Override protected Deck mutateObject(Deck parent1) { PaperCard allele = parent1.getCommanders().get(0); - if(!standardMap.keySet().contains(allele.getName())){ + if(!standardMap.containsKey(allele.getName())){ return null; } return getDeckForCard(allele); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java index 1ff8140c537..5d352e0d51a 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java @@ -174,7 +174,7 @@ public class PlanarConquestGeneraterGA extends AbstractGeneticAlgorithm { @Override protected Deck mutateObject(Deck parent1) { PaperCard allele = parent1.getMain().get(MyRandom.getRandom().nextInt(8)); - if(!standardMap.keySet().contains(allele.getName())){ + if(!standardMap.containsKey(allele.getName())){ return null; } return getDeckForCard(allele); @@ -184,8 +184,8 @@ public class PlanarConquestGeneraterGA extends AbstractGeneticAlgorithm { protected Deck createChild(Deck parent1, Deck parent2) { PaperCard allele = parent1.getMain().get(MyRandom.getRandom().nextInt(8)); PaperCard allele2 = parent2.getMain().get(MyRandom.getRandom().nextInt(8)); - if(!standardMap.keySet().contains(allele.getName()) - ||!standardMap.keySet().contains(allele2.getName()) + if(!standardMap.containsKey(allele.getName()) + ||!standardMap.containsKey(allele2.getName()) ||allele.getName().equals(allele2.getName())){ return null; } diff --git a/forge-gui-mobile-dev/src/forge/app/Main.java b/forge-gui-mobile-dev/src/forge/app/Main.java index d5a932cefda..d80bc49cdae 100644 --- a/forge-gui-mobile-dev/src/forge/app/Main.java +++ b/forge-gui-mobile-dev/src/forge/app/Main.java @@ -77,7 +77,7 @@ public class Main { boolean fullscreenFlag = true; if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) { res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x"); - fullscreenFlag = res.length == 3 ? Integer.parseInt(res[2].trim()) > 0 : true; + fullscreenFlag = res.length != 3 || Integer.parseInt(res[2].trim()) > 0; if (res.length >= 2) { desktopScreenWidth = Integer.parseInt(res[0].trim()); desktopScreenHeight = Integer.parseInt(res[1].trim()); diff --git a/forge-gui-mobile/src/forge/animation/AbilityEffect.java b/forge-gui-mobile/src/forge/animation/AbilityEffect.java index 868d527863b..755aa68d16a 100644 --- a/forge-gui-mobile/src/forge/animation/AbilityEffect.java +++ b/forge-gui-mobile/src/forge/animation/AbilityEffect.java @@ -11,7 +11,7 @@ public enum AbilityEffect { private GifAnimation animation; private AudioClip soundClip; - private AbilityEffect(String gif0, String wav0) { + AbilityEffect(String gif0, String wav0) { gif = gif0; wav = wav0; } diff --git a/forge-gui-mobile/src/forge/animation/GifDecoder.java b/forge-gui-mobile/src/forge/animation/GifDecoder.java index a0aa82ad767..301bec02894 100644 --- a/forge-gui-mobile/src/forge/animation/GifDecoder.java +++ b/forge-gui-mobile/src/forge/animation/GifDecoder.java @@ -254,7 +254,7 @@ public class GifDecoder { if (frameCount <= 0) return null; n = n % frameCount; - return ((GifFrame) frames.elementAt(n)).image; + return frames.elementAt(n).image; } /** @@ -692,7 +692,7 @@ public class GifDecoder { Pixmap frame = getFrame(0); int width = frame.getWidth(); int height = frame.getHeight(); - int vzones = (int)Math.sqrt((double)nrFrames); + int vzones = (int)Math.sqrt(nrFrames); int hzones = vzones; while(vzones * hzones < nrFrames) vzones++; diff --git a/forge-gui-mobile/src/forge/assets/BitmapFontWriter.java b/forge-gui-mobile/src/forge/assets/BitmapFontWriter.java index 457a337d2ec..768eb1e4efe 100644 --- a/forge-gui-mobile/src/forge/assets/BitmapFontWriter.java +++ b/forge-gui-mobile/src/forge/assets/BitmapFontWriter.java @@ -40,12 +40,12 @@ import com.badlogic.gdx.utils.Array; public class BitmapFontWriter { /** The output format. */ - public static enum OutputFormat { + public enum OutputFormat { /** AngelCodeFont text format */ Text, /** AngelCodeFont XML format */ - XML; + XML } /** The output format */ diff --git a/forge-gui-mobile/src/forge/card/CardZoom.java b/forge-gui-mobile/src/forge/card/CardZoom.java index cbc10b877c3..72536fe686b 100644 --- a/forge-gui-mobile/src/forge/card/CardZoom.java +++ b/forge-gui-mobile/src/forge/card/CardZoom.java @@ -291,7 +291,7 @@ public class CardZoom extends FOverlay { protected void doLayout(float width, float height) { } - public static interface ActivateHandler { + public interface ActivateHandler { String getActivateAction(int index); void setSelectedIndex(int index); void activate(int index); diff --git a/forge-gui-mobile/src/forge/deck/FDeckEditor.java b/forge-gui-mobile/src/forge/deck/FDeckEditor.java index 56cbcaf5288..c3cb2a257b2 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckEditor.java +++ b/forge-gui-mobile/src/forge/deck/FDeckEditor.java @@ -135,7 +135,7 @@ public class FDeckEditor extends TabPageScreen { return controller; } - private EditorType(DeckController controller0, Predicate cardFilter0) { + EditorType(DeckController controller0, Predicate cardFilter0) { controller = controller0; cardFilter = cardFilter0; } diff --git a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java index bfdcf634a56..4daa745c651 100644 --- a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java @@ -901,10 +901,7 @@ public abstract class ItemManager extends FContainer im @Override protected boolean hideBackdropOnPress(float x, float y) { Rectangle bounds = currentView.getSelectionBounds(); - if (bounds == null || bounds.contains(x, y)) { - return false; //don't hide on press if within selection bounds - } - return true; + return bounds != null && !bounds.contains(x, y); //don't hide on press if within selection bounds } @Override diff --git a/forge-gui-mobile/src/forge/menu/FDropDown.java b/forge-gui-mobile/src/forge/menu/FDropDown.java index f308b38578e..0f2f67bd893 100644 --- a/forge-gui-mobile/src/forge/menu/FDropDown.java +++ b/forge-gui-mobile/src/forge/menu/FDropDown.java @@ -187,10 +187,7 @@ public abstract class FDropDown extends FScrollPane { protected boolean hideBackdropOnPress(float x, float y) { FDisplayObject owner = getDropDownOwner(); - if (owner == null || !owner.screenPos.contains(x, y)) { - return true; //auto-hide when backdrop pressed unless over owner - } - return false; + return owner == null || !owner.screenPos.contains(x, y); //auto-hide when backdrop pressed unless over owner } protected boolean preventOwnerHandlingBackupTap(float x, float y, int count) { diff --git a/forge-gui-mobile/src/forge/menu/FDropDownMenu.java b/forge-gui-mobile/src/forge/menu/FDropDownMenu.java index 6636a51f257..7385252fb5d 100644 --- a/forge-gui-mobile/src/forge/menu/FDropDownMenu.java +++ b/forge-gui-mobile/src/forge/menu/FDropDownMenu.java @@ -71,9 +71,6 @@ public abstract class FDropDownMenu extends FDropDown { @Override public boolean tap(float x, float y, int count) { super.tap(x, y, count); - if (getDropDownOwner() instanceof FSubMenu) { - return false; //return false so owning sub menu can be hidden - } - return true; + return !(getDropDownOwner() instanceof FSubMenu); //return false so owning sub menu can be hidden } } diff --git a/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java b/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java index 146de6b6217..b1f2c67e1e9 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java +++ b/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java @@ -719,7 +719,7 @@ public class PlayerPanel extends FContainer { public Set getAiOptions() { return isSimulatedAi() ? ImmutableSet.of(AIOption.USE_SIMULATION) - : Collections.emptySet(); + : Collections.emptySet(); } private boolean isSimulatedAi() { return isAi() && useAiSimulation; diff --git a/forge-gui-mobile/src/forge/screens/gauntlet/NewGauntletScreen.java b/forge-gui-mobile/src/forge/screens/gauntlet/NewGauntletScreen.java index 869730c6237..58b5b19c993 100644 --- a/forge-gui-mobile/src/forge/screens/gauntlet/NewGauntletScreen.java +++ b/forge-gui-mobile/src/forge/screens/gauntlet/NewGauntletScreen.java @@ -82,8 +82,7 @@ public class NewGauntletScreen extends LaunchScreen { if (numOpponents == null) { return; } ListChooser chooser = new ListChooser( - "Choose allowed deck types for opponents", 0, 11, Arrays.asList(new DeckType[] { - DeckType.CUSTOM_DECK, + "Choose allowed deck types for opponents", 0, 11, Arrays.asList(DeckType.CUSTOM_DECK, DeckType.PRECONSTRUCTED_DECK, DeckType.QUEST_OPPONENT_DECK, DeckType.COLOR_DECK, @@ -93,8 +92,7 @@ public class NewGauntletScreen extends LaunchScreen { DeckType.MODERN_CARDGEN_DECK, DeckType.LEGACY_CARDGEN_DECK, DeckType.VINTAGE_CARDGEN_DECK, - DeckType.THEME_DECK - }), null, new Callback>() { + DeckType.THEME_DECK), null, new Callback>() { @Override public void run(final List allowedDeckTypes) { if (allowedDeckTypes == null || allowedDeckTypes.isEmpty()) { return; } diff --git a/forge-gui-mobile/src/forge/screens/home/LoadGameMenu.java b/forge-gui-mobile/src/forge/screens/home/LoadGameMenu.java index 1ff05bc4dfd..c38c3f6c48b 100644 --- a/forge-gui-mobile/src/forge/screens/home/LoadGameMenu.java +++ b/forge-gui-mobile/src/forge/screens/home/LoadGameMenu.java @@ -32,7 +32,7 @@ public class LoadGameMenu extends FPopupMenu { private final Class screenClass; private FScreen screen; - private LoadGameScreen(final String caption0, final FImage icon0, final Class screenClass0) { + LoadGameScreen(final String caption0, final FImage icon0, final Class screenClass0) { screenClass = screenClass0; item = new FMenuItem(caption0, icon0, new FEventHandler() { @Override diff --git a/forge-gui-mobile/src/forge/screens/home/NewGameMenu.java b/forge-gui-mobile/src/forge/screens/home/NewGameMenu.java index e1756cf2434..0bd6829888b 100644 --- a/forge-gui-mobile/src/forge/screens/home/NewGameMenu.java +++ b/forge-gui-mobile/src/forge/screens/home/NewGameMenu.java @@ -36,7 +36,7 @@ public class NewGameMenu extends FPopupMenu { private final Class screenClass; private FScreen screen; - private NewGameScreen(final String caption0, final FImage icon0, final Class screenClass0) { + NewGameScreen(final String caption0, final FImage icon0, final Class screenClass0) { screenClass = screenClass0; item = new FMenuItem(caption0, icon0, new FEventHandler() { @Override diff --git a/forge-gui-mobile/src/forge/screens/match/views/VStack.java b/forge-gui-mobile/src/forge/screens/match/views/VStack.java index c72bcf226e3..563d8d3c765 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VStack.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VStack.java @@ -325,7 +325,7 @@ public class VStack extends FDropDown { CardZoom.show(stackInstance.getSourceCard()); } })); - }; + } }; menu.show(this, x, y); diff --git a/forge-gui-mobile/src/forge/screens/online/OnlineMenu.java b/forge-gui-mobile/src/forge/screens/online/OnlineMenu.java index 7b7dcf882cb..f796b3d55d3 100644 --- a/forge-gui-mobile/src/forge/screens/online/OnlineMenu.java +++ b/forge-gui-mobile/src/forge/screens/online/OnlineMenu.java @@ -21,7 +21,7 @@ public class OnlineMenu extends FPopupMenu { private final Class screenClass; private FScreen screen; - private OnlineScreen(final String caption0, final FImage icon0, final Class screenClass0) { + OnlineScreen(final String caption0, final FImage icon0, final Class screenClass0) { screenClass = screenClass0; item = new FMenuItem(caption0, icon0, new FEventHandler() { @Override diff --git a/forge-gui-mobile/src/forge/sound/AudioClip.java b/forge-gui-mobile/src/forge/sound/AudioClip.java index e7ec8c305f0..792125836d5 100644 --- a/forge-gui-mobile/src/forge/sound/AudioClip.java +++ b/forge-gui-mobile/src/forge/sound/AudioClip.java @@ -74,9 +74,6 @@ public class AudioClip implements IAudioClip { } public final boolean isDone() { - if (clip == null) { - return false; - } - return true; //TODO: Make this smarter if Sound supports marking as done + return clip != null;//TODO: Make this smarter if Sound supports marking as done } } diff --git a/forge-gui-mobile/src/forge/toolbox/FDialog.java b/forge-gui-mobile/src/forge/toolbox/FDialog.java index a935e0d72a3..19b8c8aec42 100644 --- a/forge-gui-mobile/src/forge/toolbox/FDialog.java +++ b/forge-gui-mobile/src/forge/toolbox/FDialog.java @@ -145,7 +145,7 @@ public abstract class FDialog extends FOverlay { public boolean isButtonEnabled(int index) { FButton button = getButton(index); - return button != null ? button.isEnabled() : false; + return button != null && button.isEnabled(); } public void setButtonEnabled(int index, boolean enabled) { @@ -283,9 +283,7 @@ public abstract class FDialog extends FOverlay { if (revealPercent != newRevealPercent) { revealPercent = newRevealPercent; updateDisplayTop(); - if (physicsObj.isMoving()) { - return true; - } + return physicsObj.isMoving(); } } diff --git a/forge-gui-mobile/src/forge/toolbox/FEvent.java b/forge-gui-mobile/src/forge/toolbox/FEvent.java index fd6d83ba6bc..7fc207b66d2 100644 --- a/forge-gui-mobile/src/forge/toolbox/FEvent.java +++ b/forge-gui-mobile/src/forge/toolbox/FEvent.java @@ -36,7 +36,7 @@ public class FEvent { return args; } - public static interface FEventHandler { + public interface FEventHandler { void handleEvent(FEvent e); } } diff --git a/forge-gui-mobile/src/forge/toolbox/FScrollPane.java b/forge-gui-mobile/src/forge/toolbox/FScrollPane.java index 809b715c8ad..0534860961e 100644 --- a/forge-gui-mobile/src/forge/toolbox/FScrollPane.java +++ b/forge-gui-mobile/src/forge/toolbox/FScrollPane.java @@ -232,9 +232,7 @@ public abstract class FScrollPane extends FContainer { if (physicsObj.isMoving()) { //avoid storing last fling stop time if scroll manually stopped physicsObj.advance(dt); Vector2 pos = physicsObj.getPosition(); - if (setScrollPositions(pos.x, pos.y) && physicsObj.isMoving()) { - return true; - } + return setScrollPositions(pos.x, pos.y) && physicsObj.isMoving(); } //end fling animation if can't scroll anymore or physics object is no longer moving diff --git a/forge-gui/src/main/java/forge/achievement/AchievementCollection.java b/forge-gui/src/main/java/forge/achievement/AchievementCollection.java index b52029fbb89..178cab2932c 100644 --- a/forge-gui/src/main/java/forge/achievement/AchievementCollection.java +++ b/forge-gui/src/main/java/forge/achievement/AchievementCollection.java @@ -81,7 +81,7 @@ public abstract class AchievementCollection implements Iterable { } protected AchievementCollection(String name0, String filename0, boolean isLimitedFormat0) { - this(name0, filename0, isLimitedFormat0, (String) null); + this(name0, filename0, isLimitedFormat0, null); } protected AchievementCollection(String name0, String filename0, boolean isLimitedFormat0, String path0) { @@ -125,7 +125,7 @@ public abstract class AchievementCollection implements Iterable { final List achievementListFile = FileUtil.readFile(path); for (final String s : achievementListFile) { if (!s.isEmpty()) { - String k[] = StringUtils.split(s, "|"); + String[] k = StringUtils.split(s, "|"); add(k[0],k[1],k[2]); } } diff --git a/forge-gui/src/main/java/forge/achievement/ChallengeAchievements.java b/forge-gui/src/main/java/forge/achievement/ChallengeAchievements.java index 4765d8c9c1f..f159ad97243 100644 --- a/forge-gui/src/main/java/forge/achievement/ChallengeAchievements.java +++ b/forge-gui/src/main/java/forge/achievement/ChallengeAchievements.java @@ -72,11 +72,8 @@ public class ChallengeAchievements extends AchievementCollection { } public static boolean checkValidGameMode(final Game game) { - if (game.getRules().hasAppliedVariant(GameType.MomirBasic) || game.getRules().hasAppliedVariant(GameType.MoJhoSto) - || game.getRules().hasAppliedVariant(GameType.Puzzle)) { - // these modes use a fixed pre-defined deck format, so challenge achievements don't apply in them - return false; - } - return true; + // these modes use a fixed pre-defined deck format, so challenge achievements don't apply in them + return !game.getRules().hasAppliedVariant(GameType.MomirBasic) && !game.getRules().hasAppliedVariant(GameType.MoJhoSto) + && !game.getRules().hasAppliedVariant(GameType.Puzzle); } } diff --git a/forge-gui/src/main/java/forge/achievement/MatchWinStreak.java b/forge-gui/src/main/java/forge/achievement/MatchWinStreak.java index 47bb95c6b56..a876029d2e5 100644 --- a/forge-gui/src/main/java/forge/achievement/MatchWinStreak.java +++ b/forge-gui/src/main/java/forge/achievement/MatchWinStreak.java @@ -15,10 +15,7 @@ public class MatchWinStreak extends StreakAchievement { @Override protected Boolean eval(Player player, Game game) { if (game.getMatch().isMatchOver()) { - if (game.getMatch().isWonBy(player.getLobbyPlayer())) { - return true; - } - return false; + return game.getMatch().isWonBy(player.getLobbyPlayer()); } return null; } diff --git a/forge-gui/src/main/java/forge/achievement/VariantWins.java b/forge-gui/src/main/java/forge/achievement/VariantWins.java index 9e1630dc810..a1124b95e17 100644 --- a/forge-gui/src/main/java/forge/achievement/VariantWins.java +++ b/forge-gui/src/main/java/forge/achievement/VariantWins.java @@ -23,9 +23,7 @@ public class VariantWins extends ProgressiveAchievement { if (game.getRules().hasAppliedVariant(variant)) { return true; } - if (variant == GameType.Archenemy && game.getRules().hasAppliedVariant(GameType.ArchenemyRumble)) { - return true; //lump Archenemy Rumble into same achievement as Archenemy - } + return variant == GameType.Archenemy && game.getRules().hasAppliedVariant(GameType.ArchenemyRumble); //lump Archenemy Rumble into same achievement as Archenemy } return false; } diff --git a/forge-gui/src/main/java/forge/assets/FSkinProp.java b/forge-gui/src/main/java/forge/assets/FSkinProp.java index 2a3fd620fd6..91ac4331eed 100644 --- a/forge-gui/src/main/java/forge/assets/FSkinProp.java +++ b/forge-gui/src/main/java/forge/assets/FSkinProp.java @@ -297,7 +297,7 @@ public enum FSkinProp { private int[] coords; private PropType type; - private FSkinProp(final int[] coords0, final PropType type0) { + FSkinProp(final int[] coords0, final PropType type0) { coords = coords0; type = type0; } diff --git a/forge-gui/src/main/java/forge/card/CardDetailUtil.java b/forge-gui/src/main/java/forge/card/CardDetailUtil.java index 54e92455c8d..e86d433f44e 100644 --- a/forge-gui/src/main/java/forge/card/CardDetailUtil.java +++ b/forge-gui/src/main/java/forge/card/CardDetailUtil.java @@ -46,7 +46,7 @@ public class CardDetailUtil { public final int r, g, b; - private DetailColors(final int r0, final int g0, final int b0) { + DetailColors(final int r0, final int g0, final int b0) { r = r0; g = g0; b = b0; diff --git a/forge-gui/src/main/java/forge/card/CardReaderExperiments.java b/forge-gui/src/main/java/forge/card/CardReaderExperiments.java index 91159243231..88caacc8442 100644 --- a/forge-gui/src/main/java/forge/card/CardReaderExperiments.java +++ b/forge-gui/src/main/java/forge/card/CardReaderExperiments.java @@ -162,7 +162,7 @@ public class CardReaderExperiments { Matcher m = p.matcher(line); if (m.matches()) { StringBuilder newLineBuilder = new StringBuilder(); - newLineBuilder.append(line.substring(0, m.start(1))); + newLineBuilder.append(line, 0, m.start(1)); for (String sym : m.group(1).split(" ")) { newLineBuilder.append("{" + sym + "}"); } diff --git a/forge-gui/src/main/java/forge/card/CardScriptParser.java b/forge-gui/src/main/java/forge/card/CardScriptParser.java index a62037712cc..c171329f248 100644 --- a/forge-gui/src/main/java/forge/card/CardScriptParser.java +++ b/forge-gui/src/main/java/forge/card/CardScriptParser.java @@ -119,10 +119,7 @@ public final class CardScriptParser { if (!(part.startsWith("P") || part.startsWith("2") || isManaSymbol(part.charAt(0)))) { return false; } - if ((!isManaSymbol(part.charAt(1))) || part.charAt(0) == part.charAt(1)) { - return false; - } - return true; + return (isManaSymbol(part.charAt(1))) && part.charAt(0) != part.charAt(1); } return false; } @@ -344,10 +341,7 @@ public final class CardScriptParser { if (DEFINED_CARDS.contains(defined)) { return true; } - if (Iterables.any(DEFINED_CARDS_STARTSWITH, startsWith(defined))) { - return true; - } - return false; + return Iterables.any(DEFINED_CARDS_STARTSWITH, startsWith(defined)); } private static boolean isDefinedPlayerLegal(final String defined) { final boolean non = defined.startsWith("Non"), flipped = defined.startsWith("Flipped"); @@ -363,10 +357,7 @@ public final class CardScriptParser { if (DEFINED_PLAYERS.contains(defined)) { return true; } - if (Iterables.any(DEFINED_PLAYERS_STARTSWITH, startsWith(defined))) { - return true; - } - return false; + return Iterables.any(DEFINED_PLAYERS_STARTSWITH, startsWith(defined)); } private static final Set VALID_INCLUSIVE = ImmutableSortedSet.of( @@ -472,10 +463,7 @@ public final class CardScriptParser { if (VALID_EXCLUSIVE.contains(valid)) { return true; } - if (Iterables.any(VALID_EXCLUSIVE_STARTSWITH, startsWith(valid))) { - return true; - } - return false; + return Iterables.any(VALID_EXCLUSIVE_STARTSWITH, startsWith(valid)); } private static final class KeyValuePair { diff --git a/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java b/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java index 1d38d76c8ac..2cbab5ab4d1 100644 --- a/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java @@ -80,7 +80,7 @@ public final class CardArchetypeLDAGenerator { System.out.print("t" + t + ": "); int i = 0; while (topic.size()<=40&&i=0.005d) { topicCards.add(cardName); diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index c8ef0a89a58..9227ae62637 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -100,7 +100,7 @@ public final class CardRelationMatrixGenerator { for (PaperCard card:cardList){ int col=cardIntegerMap.get(card.getName()); int[] distances = matrix[col]; - int max = (Integer) Collections.max(Arrays.asList(ArrayUtils.toObject(distances))); + int max = Collections.max(Arrays.asList(ArrayUtils.toObject(distances))); if (max>0) { ArrayIndexComparator comparator = new ArrayIndexComparator(ArrayUtils.toObject(distances)); Integer[] indices = comparator.createIndexArray(); @@ -118,7 +118,7 @@ public final class CardRelationMatrixGenerator { ++j; } deckPool.add(new AbstractMap.SimpleEntry(cardToAdd,distances[indices[cardList.size()-1-k]])); - }; + } if(excludeThisCard){ continue; } @@ -181,7 +181,7 @@ public final class CardRelationMatrixGenerator { for (PaperCard card:legends){ int col=legendIntegerMap.get(card.getName()); int[] distances = matrix[col]; - int max = (Integer) Collections.max(Arrays.asList(ArrayUtils.toObject(distances))); + int max = Collections.max(Arrays.asList(ArrayUtils.toObject(distances))); if (max>0) { List> deckPool=new ArrayList<>(); for(int k=0;k evaluator; - private FilterOption(String name0, Class type0, FilterOperator[] operatorOptions0, FilterEvaluator evaluator0) { + FilterOption(String name0, Class type0, FilterOperator[] operatorOptions0, FilterEvaluator evaluator0) { name = name0; type = type0; operatorOptions = operatorOptions0; @@ -680,7 +680,7 @@ public class AdvancedSearch { private final FilterValueCount valueCount; private final OperatorEvaluator evaluator; - private FilterOperator(String caption0, String formatStr0, FilterValueCount valueCount0, OperatorEvaluator evaluator0) { + FilterOperator(String caption0, String formatStr0, FilterValueCount valueCount0, OperatorEvaluator evaluator0) { caption = caption0; formatStr = formatStr0; valueCount = valueCount0; @@ -1302,7 +1302,7 @@ public class AdvancedSearch { private final String token; - private Operator(String token0) { + Operator(String token0) { token = token0; } diff --git a/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java b/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java index e6e202bba64..c4c8c550464 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java +++ b/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java @@ -7,7 +7,7 @@ import com.google.common.base.Function; import forge.item.InventoryItem; public class ItemColumnConfig { - public static enum SortState { + public enum SortState { NONE, ASC, DESC diff --git a/forge-gui/src/main/java/forge/itemmanager/ItemManagerConfig.java b/forge-gui/src/main/java/forge/itemmanager/ItemManagerConfig.java index 0280c8ab604..b08cb5247f2 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ItemManagerConfig.java +++ b/forge-gui/src/main/java/forge/itemmanager/ItemManagerConfig.java @@ -114,7 +114,7 @@ public enum ItemManagerConfig { private Prop imageColumnCount; private Prop viewIndex; - private ItemManagerConfig(final Map cols0, boolean showUniqueCardsOption0, boolean uniqueCardsOnly0, boolean hideFilters0, GroupDef groupBy0, ColumnDef pileBy0, int imageColumnCount0, int viewIndex0) { + ItemManagerConfig(final Map cols0, boolean showUniqueCardsOption0, boolean uniqueCardsOnly0, boolean hideFilters0, GroupDef groupBy0, ColumnDef pileBy0, int imageColumnCount0, int viewIndex0) { cols = cols0; for (ItemColumnConfig colConfig : cols.values()) { colConfig.establishDefaults(); diff --git a/forge-gui/src/main/java/forge/itemmanager/ItemManagerModel.java b/forge-gui/src/main/java/forge/itemmanager/ItemManagerModel.java index a55282600a2..4969909ac9d 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ItemManagerModel.java +++ b/forge-gui/src/main/java/forge/itemmanager/ItemManagerModel.java @@ -190,7 +190,7 @@ public final class ItemManagerModel { for (final ItemColumn col : colsToSort) { oneColSorters.add(new ItemPoolSorter( col.getFnSort(), - col.getConfig().getSortState().equals(SortState.ASC) ? true : false)); + col.getConfig().getSortState().equals(SortState.ASC))); } return new Sorter(oneColSorters); diff --git a/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java b/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java index b880cf717b6..78a6a894b06 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java @@ -28,7 +28,7 @@ import java.util.Map.Entry; */ public final class SItemManagerUtil { /** An enum to encapsulate metadata for the stats/filter objects. */ - public static enum StatTypes implements IHasSkinProp { + public enum StatTypes implements IHasSkinProp { WHITE (FSkinProp.IMG_MANA_W, CardRulesPredicates.Presets.IS_WHITE, "lblWhitecards"), BLUE (FSkinProp.IMG_MANA_U, CardRulesPredicates.Presets.IS_BLUE, "lblBluecards"), BLACK (FSkinProp.IMG_MANA_B, CardRulesPredicates.Presets.IS_BLACK, "lblBlackcards"), @@ -78,7 +78,7 @@ public final class SItemManagerUtil { public final Predicate predicate; public final String label; - private StatTypes(final FSkinProp skinProp0, final Predicate predicate0, final String label0) { + StatTypes(final FSkinProp skinProp0, final Predicate predicate0, final String label0) { skinProp = skinProp0; predicate = predicate0; final Localizer localizer = Localizer.getInstance(); diff --git a/forge-gui/src/main/java/forge/limited/BoosterDraft.java b/forge-gui/src/main/java/forge/limited/BoosterDraft.java index ef22d7b8e76..09d22dca69e 100644 --- a/forge-gui/src/main/java/forge/limited/BoosterDraft.java +++ b/forge-gui/src/main/java/forge/limited/BoosterDraft.java @@ -346,7 +346,7 @@ public class BoosterDraft implements IBoosterDraft { @Override public Deck[] getDecks() { - Deck decks[] = new Deck[7]; + Deck[] decks = new Deck[7]; for (int i = 1; i < N_PLAYERS; i++) { decks[i - 1] = ((LimitedPlayerAI) this.players.get(i)).buildDeck(); } diff --git a/forge-gui/src/main/java/forge/limited/CardThemedConquestDeckBuilder.java b/forge-gui/src/main/java/forge/limited/CardThemedConquestDeckBuilder.java index b618dd63c6b..b126ef47b27 100644 --- a/forge-gui/src/main/java/forge/limited/CardThemedConquestDeckBuilder.java +++ b/forge-gui/src/main/java/forge/limited/CardThemedConquestDeckBuilder.java @@ -44,7 +44,7 @@ public class CardThemedConquestDeckBuilder extends CardThemedDeckBuilder { } numSpellsNeeded = ((Double)Math.floor(targetSize*(getCreaturePercentage()+getSpellPercentage()))).intValue(); numCreaturesToStart = ((Double)Math.ceil(targetSize*(getCreaturePercentage()))).intValue(); - landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue();; + landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue(); if (logColorsToConsole) { System.out.println(keyCard.getName()); System.out.println("Pre Colors: " + colors.toEnumSet().toString()); diff --git a/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java index 769e7a34801..1188f0e943b 100644 --- a/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/limited/CardThemedDeckBuilder.java @@ -132,7 +132,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase { } numSpellsNeeded = ((Double)Math.floor(targetSize*(getCreaturePercentage()+getSpellPercentage()))).intValue(); numCreaturesToStart = ((Double)Math.ceil(targetSize*(getCreaturePercentage()))).intValue(); - landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue();; + landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue(); if (logColorsToConsole) { System.out.println(keyCard.getName()); System.out.println("Pre Colors: " + colors.toEnumSet().toString()); diff --git a/forge-gui/src/main/java/forge/limited/LimitedPoolType.java b/forge-gui/src/main/java/forge/limited/LimitedPoolType.java index 2f52015e1e8..7ce7fbd8828 100644 --- a/forge-gui/src/main/java/forge/limited/LimitedPoolType.java +++ b/forge-gui/src/main/java/forge/limited/LimitedPoolType.java @@ -8,7 +8,7 @@ public enum LimitedPoolType { Chaos("Chaos Draft"); private final String displayName; - private LimitedPoolType(String name) { + LimitedPoolType(String name) { displayName = name; } diff --git a/forge-gui/src/main/java/forge/match/GameLobby.java b/forge-gui/src/main/java/forge/match/GameLobby.java index 9951217dcb3..797ecec2a73 100644 --- a/forge-gui/src/main/java/forge/match/GameLobby.java +++ b/forge-gui/src/main/java/forge/match/GameLobby.java @@ -158,7 +158,7 @@ public abstract class GameLobby implements IHasGameType { public void addSlot() { final int newIndex = getNumberOfSlots(); final LobbySlotType type = allowNetworking ? LobbySlotType.OPEN : LobbySlotType.AI; - addSlot(new LobbySlot(type, null, newIndex, newIndex, false, !allowNetworking, Collections.emptySet())); + addSlot(new LobbySlot(type, null, newIndex, newIndex, false, !allowNetworking, Collections.emptySet())); } protected final void addSlot(final LobbySlot slot) { if (slot == null) { @@ -485,7 +485,7 @@ public abstract class GameLobby implements IHasGameType { return null; } } - schemes = schemePool == null ? Collections.emptyList() : schemePool.toFlatList(); + schemes = schemePool == null ? Collections.emptyList() : schemePool.toFlatList(); } //Planechase @@ -498,7 +498,7 @@ public abstract class GameLobby implements IHasGameType { return null; } } - planes = planePool == null ? Collections.emptyList() : planePool.toFlatList(); + planes = planePool == null ? Collections.emptyList() : planePool.toFlatList(); } //Vanguard diff --git a/forge-gui/src/main/java/forge/match/HostedMatch.java b/forge-gui/src/main/java/forge/match/HostedMatch.java index 7535a28d20f..34919b479c2 100644 --- a/forge-gui/src/main/java/forge/match/HostedMatch.java +++ b/forge-gui/src/main/java/forge/match/HostedMatch.java @@ -98,7 +98,7 @@ public class HostedMatch { throw new IllegalArgumentException(); } - this.guis = guis == null ? ImmutableMap.of() : guis; + this.guis = guis == null ? ImmutableMap.of() : guis; final boolean useRandomFoil = FModel.getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL); for (final RegisteredPlayer rp : players) { rp.setRandomFoil(useRandomFoil); @@ -160,7 +160,7 @@ public class HostedMatch { final GameView gameView = getGameView(); humanCount = 0; - final MapOfLists playersPerGui = new HashMapOfLists(CollectionSuppliers.arrayLists()); + final MapOfLists playersPerGui = new HashMapOfLists(CollectionSuppliers.arrayLists()); for (int iPlayer = 0; iPlayer < players.size(); iPlayer++) { final RegisteredPlayer rp = match.getPlayers().get(iPlayer); final Player p = players.get(iPlayer); diff --git a/forge-gui/src/main/java/forge/match/LobbySlot.java b/forge-gui/src/main/java/forge/match/LobbySlot.java index 9deb226fe04..bd33cff83e9 100644 --- a/forge-gui/src/main/java/forge/match/LobbySlot.java +++ b/forge-gui/src/main/java/forge/match/LobbySlot.java @@ -137,7 +137,7 @@ public final class LobbySlot implements Serializable { } public void setAiOptions(final Set aiOptions) { - this.aiOptions = aiOptions == null ? ImmutableSet.of() : ImmutableSet.copyOf(aiOptions); + this.aiOptions = aiOptions == null ? ImmutableSet.of() : ImmutableSet.copyOf(aiOptions); } } \ No newline at end of file diff --git a/forge-gui/src/main/java/forge/match/LobbySlotType.java b/forge-gui/src/main/java/forge/match/LobbySlotType.java index 8e764b232b4..2c8e6bce624 100644 --- a/forge-gui/src/main/java/forge/match/LobbySlotType.java +++ b/forge-gui/src/main/java/forge/match/LobbySlotType.java @@ -4,5 +4,5 @@ public enum LobbySlotType { LOCAL, AI, OPEN, - REMOTE; + REMOTE } \ No newline at end of file diff --git a/forge-gui/src/main/java/forge/match/LocalLobby.java b/forge-gui/src/main/java/forge/match/LocalLobby.java index ca7b66724ad..f8fa6f7a8e7 100644 --- a/forge-gui/src/main/java/forge/match/LocalLobby.java +++ b/forge-gui/src/main/java/forge/match/LocalLobby.java @@ -3,7 +3,6 @@ package forge.match; import java.util.Collections; import forge.GuiBase; -import forge.ai.AIOption; import forge.interfaces.IGuiGame; public final class LocalLobby extends GameLobby { @@ -15,10 +14,10 @@ public final class LocalLobby extends GameLobby { final String humanName = localName(); final int[] avatarIndices = localAvatarIndices(); - final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, true, Collections.emptySet()); + final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, true, Collections.emptySet()); addSlot(slot0); - final LobbySlot slot1 = new LobbySlot(LobbySlotType.AI, null, avatarIndices[1], 1, false, true, Collections.emptySet()); + final LobbySlot slot1 = new LobbySlot(LobbySlotType.AI, null, avatarIndices[1], 1, false, true, Collections.emptySet()); addSlot(slot1); } diff --git a/forge-gui/src/main/java/forge/match/NextGameDecision.java b/forge-gui/src/main/java/forge/match/NextGameDecision.java index 88e11189c41..52cf84d9b0d 100644 --- a/forge-gui/src/main/java/forge/match/NextGameDecision.java +++ b/forge-gui/src/main/java/forge/match/NextGameDecision.java @@ -3,5 +3,5 @@ package forge.match; public enum NextGameDecision { NEW, CONTINUE, - QUIT; + QUIT } diff --git a/forge-gui/src/main/java/forge/match/input/InputLockUI.java b/forge-gui/src/main/java/forge/match/input/InputLockUI.java index 5b525ee7c69..657f77ec96f 100644 --- a/forge-gui/src/main/java/forge/match/input/InputLockUI.java +++ b/forge-gui/src/main/java/forge/match/input/InputLockUI.java @@ -55,7 +55,7 @@ public class InputLockUI implements Input { } FThreads.invokeInEdtLater(showMessageFromEdt); } - }; + } private final Runnable showMessageFromEdt = new Runnable() { @Override diff --git a/forge-gui/src/main/java/forge/model/CardBlock.java b/forge-gui/src/main/java/forge/model/CardBlock.java index a3893102354..ba8d16b08d9 100644 --- a/forge-gui/src/main/java/forge/model/CardBlock.java +++ b/forge-gui/src/main/java/forge/model/CardBlock.java @@ -181,10 +181,7 @@ public final class CardBlock implements Comparable { if (!this.landSet.equals(other.landSet)) { return false; } - if (!this.name.equals(other.name)) { - return false; - } - return true; + return this.name.equals(other.name); } /* diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index edbe8779551..2e2f04ba571 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -276,7 +276,7 @@ public final class FModel { } else if (s.length() > 1) { if (tList != null) { if (s.contains(":")) { - String k[] = s.split(":"); + String[] k = s.split(":"); tList.add(k[0]); CardType.Constant.pluralTypes.put(k[0], k[1]); } else { diff --git a/forge-gui/src/main/java/forge/model/MetaSet.java b/forge-gui/src/main/java/forge/model/MetaSet.java index 9da30c7dbf7..ee881f7e512 100644 --- a/forge-gui/src/main/java/forge/model/MetaSet.java +++ b/forge-gui/src/main/java/forge/model/MetaSet.java @@ -108,7 +108,7 @@ public class MetaSet { private final String shortHand; public final String descriptiveName; - private MetaSetType(String shortname, String descName) { + MetaSetType(String shortname, String descName) { shortHand = shortname; descriptiveName = descName; } diff --git a/forge-gui/src/main/java/forge/net/OfflineLobby.java b/forge-gui/src/main/java/forge/net/OfflineLobby.java index 18827184027..e8827558e1a 100644 --- a/forge-gui/src/main/java/forge/net/OfflineLobby.java +++ b/forge-gui/src/main/java/forge/net/OfflineLobby.java @@ -2,7 +2,6 @@ package forge.net; import java.util.Collections; -import forge.ai.AIOption; import forge.interfaces.IGuiGame; import forge.match.GameLobby; import forge.match.LobbySlot; @@ -16,10 +15,10 @@ public final class OfflineLobby extends GameLobby { final String humanName = localName(); final int[] avatarIndices = localAvatarIndices(); - final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, false, Collections.emptySet()); + final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, false, Collections.emptySet()); addSlot(slot0); - final LobbySlot slot1 = new LobbySlot(LobbySlotType.OPEN, null, -1, -1, false, false, Collections.emptySet()); + final LobbySlot slot1 = new LobbySlot(LobbySlotType.OPEN, null, -1, -1, false, false, Collections.emptySet()); addSlot(slot1); } diff --git a/forge-gui/src/main/java/forge/net/ProtocolMethod.java b/forge-gui/src/main/java/forge/net/ProtocolMethod.java index b75acdce1cf..e220668832f 100644 --- a/forge-gui/src/main/java/forge/net/ProtocolMethod.java +++ b/forge-gui/src/main/java/forge/net/ProtocolMethod.java @@ -101,23 +101,23 @@ public enum ProtocolMethod { CLIENT(IGameController.class); private final Class toInvoke; - private Mode(final Class toInvoke) { + Mode(final Class toInvoke) { this.toInvoke = toInvoke; } - }; + } private final ProtocolMethod.Mode mode; private final Class returnType; private final Class[] args; - private ProtocolMethod(final ProtocolMethod.Mode mode) { + ProtocolMethod(final ProtocolMethod.Mode mode) { this(mode, Void.TYPE); } - private ProtocolMethod(final ProtocolMethod.Mode mode, final Class returnType) { + ProtocolMethod(final ProtocolMethod.Mode mode, final Class returnType) { this(mode, returnType, (Class[]) null); } @SafeVarargs - private ProtocolMethod(final ProtocolMethod.Mode mode, final Class returnType, final Class ... args) { + ProtocolMethod(final ProtocolMethod.Mode mode, final Class returnType, final Class... args) { this.mode = mode; this.returnType = returnType; this.args = args == null ? new Class[] {} : args; diff --git a/forge-gui/src/main/java/forge/net/client/GameClientHandler.java b/forge-gui/src/main/java/forge/net/client/GameClientHandler.java index 93f11d7be96..30d977378a1 100644 --- a/forge-gui/src/main/java/forge/net/client/GameClientHandler.java +++ b/forge-gui/src/main/java/forge/net/client/GameClientHandler.java @@ -231,7 +231,7 @@ final class GameClientHandler extends GameProtocolHandler { if (trackableObject.getTracker() == null) { trackableObject.setTracker(this.tracker); // walk the props - EnumMap props = (EnumMap) trackableObject.getProps(); + EnumMap props = trackableObject.getProps(); if (!(props == null)) { for (Object propObj : props.values()) { updateTrackers(new Object[]{propObj}); diff --git a/forge-gui/src/main/java/forge/net/server/FServerManager.java b/forge-gui/src/main/java/forge/net/server/FServerManager.java index 826dd0ea895..4a17201fd69 100644 --- a/forge-gui/src/main/java/forge/net/server/FServerManager.java +++ b/forge-gui/src/main/java/forge/net/server/FServerManager.java @@ -223,7 +223,7 @@ public final class FServerManager { NetworkInterface n = NetworkInterface.getByInetAddress(s.getLocalAddress()); Enumeration en = n.getInetAddresses(); while (en.hasMoreElements()) { - InetAddress addr = (InetAddress) en.nextElement(); + InetAddress addr = en.nextElement(); if (addr instanceof Inet4Address) { if (preferIPv6) { continue; diff --git a/forge-gui/src/main/java/forge/net/server/ServerGameLobby.java b/forge-gui/src/main/java/forge/net/server/ServerGameLobby.java index 84c489c40c5..9fd87b8b132 100644 --- a/forge-gui/src/main/java/forge/net/server/ServerGameLobby.java +++ b/forge-gui/src/main/java/forge/net/server/ServerGameLobby.java @@ -4,7 +4,6 @@ import java.util.Collections; import org.apache.commons.lang3.StringUtils; -import forge.ai.AIOption; import forge.interfaces.IGuiGame; import forge.match.GameLobby; import forge.match.LobbySlot; @@ -14,8 +13,8 @@ public final class ServerGameLobby extends GameLobby { public ServerGameLobby() { super(true); - addSlot(new LobbySlot(LobbySlotType.LOCAL, localName(), localAvatarIndices()[0], 0, true, false, Collections.emptySet())); - addSlot(new LobbySlot(LobbySlotType.OPEN, null, -1, 1, false, false, Collections.emptySet())); + addSlot(new LobbySlot(LobbySlotType.LOCAL, localName(), localAvatarIndices()[0], 0, true, false, Collections.emptySet())); + addSlot(new LobbySlot(LobbySlotType.OPEN, null, -1, 1, false, false, Collections.emptySet())); } public int connectPlayer(final String name, final int avatarIndex) { diff --git a/forge-gui/src/main/java/forge/planarconquest/ConquestCommander.java b/forge-gui/src/main/java/forge/planarconquest/ConquestCommander.java index 74048caf5b2..6bff8b41e60 100644 --- a/forge-gui/src/main/java/forge/planarconquest/ConquestCommander.java +++ b/forge-gui/src/main/java/forge/planarconquest/ConquestCommander.java @@ -29,10 +29,7 @@ public class ConquestCommander implements InventoryItem, IXmlWritable { @Override public boolean apply(PaperCard pc) { CardRules rules = pc.getRules(); - if (rules.canBeCommander() || rules.getType().isPlaneswalker()) { - return false; //prevent including additional commanders or planeswalkers in starting deck - } - return true; + return !rules.canBeCommander() && !rules.getType().isPlaneswalker(); //prevent including additional commanders or planeswalkers in starting deck } })), false), null); } diff --git a/forge-gui/src/main/java/forge/planarconquest/ConquestPreferences.java b/forge-gui/src/main/java/forge/planarconquest/ConquestPreferences.java index 8e7bec55fe3..e5878551219 100644 --- a/forge-gui/src/main/java/forge/planarconquest/ConquestPreferences.java +++ b/forge-gui/src/main/java/forge/planarconquest/ConquestPreferences.java @@ -27,7 +27,7 @@ public class ConquestPreferences extends PreferencesStore predicate; private String caption; - private AEtherFilter(final FSkinProp skinProp0, final Predicate predicate0, final String caption0) { + AEtherFilter(final FSkinProp skinProp0, final Predicate predicate0, final String caption0) { skinProp = skinProp0; predicate = predicate0; caption = caption0; @@ -509,8 +509,7 @@ public class ConquestUtil { public boolean apply(PaperCard card) { int cardCmc = card.getRules().getManaCost().getCMC(); if (cardCmc < cmcMin) { return false; } - if (cmcMax != -1 && cardCmc > cmcMax) { return false; } - return true; + return cmcMax == -1 || cardCmc <= cmcMax; } } } diff --git a/forge-gui/src/main/java/forge/player/GamePlayerUtil.java b/forge-gui/src/main/java/forge/player/GamePlayerUtil.java index 448670a30ce..a7a93d85006 100644 --- a/forge-gui/src/main/java/forge/player/GamePlayerUtil.java +++ b/forge-gui/src/main/java/forge/player/GamePlayerUtil.java @@ -17,7 +17,7 @@ import forge.util.MyRandom; import forge.util.gui.SOptionPane; public final class GamePlayerUtil { - private GamePlayerUtil() { }; + private GamePlayerUtil() { } private static final LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human"); public static final LobbyPlayer getGuiPlayer() { diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index 02e4ec6c80b..c283bf771e5 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -159,7 +159,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { return PaymentDecision.card(discarded); } - final String type = new String(discardType); + final String type = discardType; final String[] validType = type.split(";"); hand = CardLists.getValidCards(hand, validType, player, source, ability); @@ -860,7 +860,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { } if (num == 0) { return PaymentDecision.number(0); - }; + } inp = new InputSelectCardsFromList(controller, num, num, hand, ability); inp.setMessage("Select %d more " + cost.getDescriptiveType() + " card(s) to reveal."); diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index c1e1325af7d..93b4b31678a 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -514,7 +514,7 @@ public class HumanPlay { } } else if (part instanceof CostPutCardToLib) { - int amount = Integer.parseInt(((CostPutCardToLib) part).getAmount()); + int amount = Integer.parseInt(part.getAmount()); final ZoneType from = ((CostPutCardToLib) part).getFrom(); final boolean sameZone = ((CostPutCardToLib) part).isSameZone(); CardCollectionView listView; @@ -562,9 +562,7 @@ public class HumanPlay { } else { // Tainted Specter, Gurzigost, etc. boolean hasPaid = payCostPart(controller, sourceAbility, (CostPartWithList)part, amount, list, "put into library." + orString); - if (!hasPaid) { - return false; - } + return hasPaid; } return true; } @@ -576,7 +574,7 @@ public class HumanPlay { part.payAsDecided(p, pd, sourceAbility); } else if (part instanceof CostGainControl) { - int amount = Integer.parseInt(((CostGainControl)part).getAmount()); + int amount = Integer.parseInt(part.getAmount()); CardCollectionView list = CardLists.getValidCards(p.getGame().getCardsIn(ZoneType.Battlefield), part.getType(), p, source); boolean hasPaid = payCostPart(controller, sourceAbility, (CostPartWithList)part, amount, list, "gain control." + orString); if (!hasPaid) { return false; } diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index d02362f46cc..84c5bd0555d 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -335,7 +335,7 @@ public class HumanPlaySpellAbility { for (final String aVar : announce.split(",")) { final String varName = aVar.trim(); if ("CreatureType".equals(varName)) { - final String choice = pc.chooseSomeType("Creature", ability, CardType.Constant.CREATURE_TYPES, Collections.emptyList()); + final String choice = pc.chooseSomeType("Creature", ability, CardType.Constant.CREATURE_TYPES, Collections.emptyList()); ability.getHostCard().setChosenType(choice); } if ("ChooseNumber".equals(varName)) { diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index c7fefdc1b5d..16bf87f71b2 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -776,7 +776,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont } else { toBottom = game.getCardList(getGui().many("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, CardView.getCollection(topN), null)); - topN.removeAll((Collection) toBottom); + topN.removeAll(toBottom); if (topN.isEmpty()) { toTop = null; } else if (topN.size() == 1) { @@ -814,7 +814,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont } else { toGrave = game.getCardList(getGui().many("Select cards to be put into the graveyard", "Cards to put in the graveyard", -1, CardView.getCollection(topN), null)); - topN.removeAll((Collection) toGrave); + topN.removeAll(toGrave); if (topN.isEmpty()) { toTop = null; } else if (topN.size() == 1) { @@ -1404,7 +1404,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont final boolean call) { final String[] labelsSrc = call ? new String[] { "heads", "tails" } : new String[] { "win the flip", "lose the flip" }; - final ImmutableList.Builder strResults = ImmutableList.builder(); + final ImmutableList.Builder strResults = ImmutableList.builder(); for (int i = 0; i < results.length; i++) { strResults.add(labelsSrc[results[i] ? 0 : 1]); } @@ -1665,8 +1665,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont boolean preselect = FModel.getPreferences() .getPrefBoolean(FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER); orderedSAVs = getGui().order("Reorder simultaneous abilities", "Resolve first", 0, 0, - preselect ? Lists.newArrayList() : orderedSAVs, - preselect ? orderedSAVs : Lists.newArrayList(), null, false); + preselect ? Lists.newArrayList() : orderedSAVs, + preselect ? orderedSAVs : Lists.newArrayList(), null, false); } else { orderedSAVs = getGui().order("Select order for simultaneous abilities", "Resolve first", orderedSAVs, null); @@ -1829,10 +1829,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont return false; } final Player priorityPlayer = game.getPhaseHandler().getPriorityPlayer(); - if (priorityPlayer == null || priorityPlayer != player) { - return false; - } - return true; + return priorityPlayer != null && priorityPlayer == player; } @Override @@ -2741,7 +2738,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont for (final Player player : game.getPlayers()) { if (player.getId() == entity.getKey()) { found = true; - rememberedActions.add(Pair.of((GameEntityView) player.getView(), true)); + rememberedActions.add(Pair.of(player.getView(), true)); break; } } @@ -2749,7 +2746,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont for (final Card card : cards) { if (card.getId() == entity.getKey()) { found = true; - rememberedActions.add(Pair.of((GameEntityView) card.getView(), false)); + rememberedActions.add(Pair.of(card.getView(), false)); break; } } diff --git a/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java b/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java index 7d48de0651f..17f71d1e6e2 100644 --- a/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java +++ b/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java @@ -12,7 +12,7 @@ import forge.game.player.PlayerView; public class PlayerZoneUpdates implements Iterable, Serializable { private static final long serialVersionUID = 7023549243041119023L; - private final Map updates = Collections.synchronizedMap(Maps.newHashMap()); + private final Map updates = Collections.synchronizedMap(Maps.newHashMap()); public PlayerZoneUpdates() { } diff --git a/forge-gui/src/main/java/forge/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/properties/ForgeConstants.java index 342d2184991..7ff4316eb99 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/properties/ForgeConstants.java @@ -306,7 +306,7 @@ public final class ForgeConstants { public static final String GRAVEYARD_ORDERING_ALWAYS = "Always"; // Set boolean constant for landscape mode for gdx port - public static final boolean isGdxPortLandscape = FileUtil.doesFileExist(ASSETS_DIR + "switch_orientation.ini") ? true : false; + public static final boolean isGdxPortLandscape = FileUtil.doesFileExist(ASSETS_DIR + "switch_orientation.ini"); public enum CounterDisplayLocation { diff --git a/forge-gui/src/main/java/forge/properties/ForgePreferences.java b/forge-gui/src/main/java/forge/properties/ForgePreferences.java index d4a35b4db97..9aa8e691bd0 100644 --- a/forge-gui/src/main/java/forge/properties/ForgePreferences.java +++ b/forge-gui/src/main/java/forge/properties/ForgePreferences.java @@ -240,7 +240,7 @@ public class ForgePreferences extends PreferencesStore { private final String strDefaultVal; - private FPref(final String s0) { + FPref(final String s0) { this.strDefaultVal = s0; } diff --git a/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java b/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java index 25a8dbce4dd..17711e08509 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java +++ b/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java @@ -74,7 +74,7 @@ public class ForgeProfileProperties { cardPicsDir = getDir(props, CARD_PICS_DIR_KEY, cacheDir + "pics" + File.separator + "cards" + File.separator); cardPicsSubDirs = getMap(props, CARD_PICS_SUB_DIRS_KEY); decksDir = getDir(props, DECKS_DIR_KEY, userDir + "decks" + File.separator); - decksConstructedDir = getDir(props, DECKS_CONSTRUCTED_DIR_KEY, decksDir + "constructed" + File.separator);; + decksConstructedDir = getDir(props, DECKS_CONSTRUCTED_DIR_KEY, decksDir + "constructed" + File.separator); serverPort = getInt(props, SERVER_PORT_KEY, 36743); // "Forge" using phone keypad //ensure directories exist diff --git a/forge-gui/src/main/java/forge/puzzle/Puzzle.java b/forge-gui/src/main/java/forge/puzzle/Puzzle.java index b513fc0732a..39904881b7e 100644 --- a/forge-gui/src/main/java/forge/puzzle/Puzzle.java +++ b/forge-gui/src/main/java/forge/puzzle/Puzzle.java @@ -222,6 +222,6 @@ public class Puzzle extends GameState implements InventoryItem, Comparable sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); + private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); private final IStorage allDuels; /** diff --git a/forge-gui/src/main/java/forge/quest/QuestEventLDADuelManager.java b/forge-gui/src/main/java/forge/quest/QuestEventLDADuelManager.java index 0fdc9660461..eadd2ed28d4 100644 --- a/forge-gui/src/main/java/forge/quest/QuestEventLDADuelManager.java +++ b/forge-gui/src/main/java/forge/quest/QuestEventLDADuelManager.java @@ -42,7 +42,7 @@ import java.util.List; public class QuestEventLDADuelManager implements QuestEventDuelManagerInterface { private List archetypes; - private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); + private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); private GameFormat baseFormat; public QuestEventLDADuelManager(GameFormat baseFormat){ diff --git a/forge-gui/src/main/java/forge/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/quest/QuestRewardCard.java index 024fd3c56bc..91b008abbd4 100644 --- a/forge-gui/src/main/java/forge/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/quest/QuestRewardCard.java @@ -25,9 +25,9 @@ public abstract class QuestRewardCard implements IQuestRewardCard { if (s.startsWith("desc:") || s.startsWith("Desc:")) { final String[] tmp = s.split(":"); if (tmp.length > 1) { - buildDesc = new String(tmp[1]); + buildDesc = tmp[1]; } else { - buildDesc = new String(); + buildDesc = ""; } } else if (buildDesc != null) { if (s.contains(":")) { diff --git a/forge-gui/src/main/java/forge/quest/QuestUtil.java b/forge-gui/src/main/java/forge/quest/QuestUtil.java index 46ab8eda6fa..63be897d389 100644 --- a/forge-gui/src/main/java/forge/quest/QuestUtil.java +++ b/forge-gui/src/main/java/forge/quest/QuestUtil.java @@ -677,7 +677,7 @@ public class QuestUtil { } public static String getDeckConformanceProblems(Deck deck){ - String errorMessage = GameType.Quest.getDeckFormat().getDeckConformanceProblem(deck);; + String errorMessage = GameType.Quest.getDeckFormat().getDeckConformanceProblem(deck); if(errorMessage != null) return errorMessage; //return immediately if the deck does not conform to quest requirements diff --git a/forge-gui/src/main/java/forge/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/quest/QuestUtilUnlockSets.java index d7881334f57..3e6a5d0fe29 100644 --- a/forge-gui/src/main/java/forge/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/quest/QuestUtilUnlockSets.java @@ -130,7 +130,7 @@ public class QuestUtilUnlockSets { * * @return unmodifiable list, assorted sets that are not currently in the format. */ - private static final List emptyEditions = ImmutableList.of(); + private static final List emptyEditions = ImmutableList.of(); private static final EnumSet unlockableSetTypes = EnumSet.of(CardEdition.Type.CORE, CardEdition.Type.EXPANSION, CardEdition.Type.REPRINT, CardEdition.Type.STARTER); diff --git a/forge-gui/src/main/java/forge/quest/SellRules.java b/forge-gui/src/main/java/forge/quest/SellRules.java index 8d8ca9e8d45..36de28da65f 100644 --- a/forge-gui/src/main/java/forge/quest/SellRules.java +++ b/forge-gui/src/main/java/forge/quest/SellRules.java @@ -60,11 +60,7 @@ public class SellRules { if (quest.getWin() < minWins) { return false; } - if (quest.getDifficulty() < minDifficulty || quest.getDifficulty() > maxDifficulty) { - return false; - } - - return true; + return quest.getDifficulty() >= minDifficulty && quest.getDifficulty() <= maxDifficulty; } /** diff --git a/forge-gui/src/main/java/forge/quest/StartingPoolType.java b/forge-gui/src/main/java/forge/quest/StartingPoolType.java index 513a49f1da0..dc1bd6dbe3c 100644 --- a/forge-gui/src/main/java/forge/quest/StartingPoolType.java +++ b/forge-gui/src/main/java/forge/quest/StartingPoolType.java @@ -12,7 +12,7 @@ public enum StartingPoolType { private final String caption; - private StartingPoolType(String caption0) { + StartingPoolType(String caption0) { caption = caption0; } diff --git a/forge-gui/src/main/java/forge/quest/bazaar/QuestItemType.java b/forge-gui/src/main/java/forge/quest/bazaar/QuestItemType.java index 86ac871228b..07cb6165f9e 100644 --- a/forge-gui/src/main/java/forge/quest/bazaar/QuestItemType.java +++ b/forge-gui/src/main/java/forge/quest/bazaar/QuestItemType.java @@ -53,8 +53,8 @@ public enum QuestItemType { private final Class bazaarControllerClass; private final Class modelClass; - private QuestItemType(final String key, final Class controllerClass0, - final Class modelClass0) { + QuestItemType(final String key, final Class controllerClass0, + final Class modelClass0) { this.saveFileKey = key; this.bazaarControllerClass = controllerClass0; this.modelClass = modelClass0; diff --git a/forge-gui/src/main/java/forge/quest/data/StarRating.java b/forge-gui/src/main/java/forge/quest/data/StarRating.java index 37f5f30213b..1c91b4ed4d7 100644 --- a/forge-gui/src/main/java/forge/quest/data/StarRating.java +++ b/forge-gui/src/main/java/forge/quest/data/StarRating.java @@ -44,10 +44,6 @@ public class StarRating { return false; } - if (rating != other.rating) { - return false; - } - - return true; + return rating == other.rating; } } diff --git a/forge-gui/src/main/java/forge/sound/EventVisualizer.java b/forge-gui/src/main/java/forge/sound/EventVisualizer.java index 057293b7e60..0f2cc2c71fd 100644 --- a/forge-gui/src/main/java/forge/sound/EventVisualizer.java +++ b/forge-gui/src/main/java/forge/sound/EventVisualizer.java @@ -301,7 +301,7 @@ public class EventVisualizer extends IGameEventVisitor.Base imp if (null != c) { effect = c.getSVar("SoundEffect"); } - return effect.isEmpty() ? false : true; + return !effect.isEmpty(); } diff --git a/forge-gui/src/main/java/forge/sound/IAudioClip.java b/forge-gui/src/main/java/forge/sound/IAudioClip.java index 1fc08bb123c..479eccc4da3 100644 --- a/forge-gui/src/main/java/forge/sound/IAudioClip.java +++ b/forge-gui/src/main/java/forge/sound/IAudioClip.java @@ -1,8 +1,8 @@ package forge.sound; public interface IAudioClip { - public void play(); - public boolean isDone(); - public void stop(); - public void loop(); + void play(); + boolean isDone(); + void stop(); + void loop(); } diff --git a/forge-gui/src/main/java/forge/sound/MusicPlaylist.java b/forge-gui/src/main/java/forge/sound/MusicPlaylist.java index c5cbbb3d1ea..d5acc57718d 100644 --- a/forge-gui/src/main/java/forge/sound/MusicPlaylist.java +++ b/forge-gui/src/main/java/forge/sound/MusicPlaylist.java @@ -14,7 +14,7 @@ public enum MusicPlaylist { private int mostRecentTrackIdx = -1; private String[] filenames; - private MusicPlaylist(String subDir0) { + MusicPlaylist(String subDir0) { subDir = subDir0; } diff --git a/forge-gui/src/main/java/forge/tournament/TournamentData.java b/forge-gui/src/main/java/forge/tournament/TournamentData.java index 66c76ffd74e..c045179161f 100644 --- a/forge-gui/src/main/java/forge/tournament/TournamentData.java +++ b/forge-gui/src/main/java/forge/tournament/TournamentData.java @@ -57,7 +57,7 @@ public class TournamentData { public void stamp() { final DateFormat dateFormat = new SimpleDateFormat("MM-dd-yy, H:m"); - timestamp = dateFormat.format(new Date()).toString(); + timestamp = dateFormat.format(new Date()); } /** Resets a Tournament data to an unplayed state, then stamps and saves. */ diff --git a/forge-gui/src/main/java/forge/tournament/system/TournamentSwiss.java b/forge-gui/src/main/java/forge/tournament/system/TournamentSwiss.java index a49c54fae00..31c9ae300ff 100644 --- a/forge-gui/src/main/java/forge/tournament/system/TournamentSwiss.java +++ b/forge-gui/src/main/java/forge/tournament/system/TournamentSwiss.java @@ -57,7 +57,7 @@ public class TournamentSwiss extends AbstractTournament { if (byePlayer != null) { groupPlayers.remove(byePlayer); - TournamentPairing byePair = new TournamentPairing(activeRound, Lists.newArrayList(byePlayer)); + TournamentPairing byePair = new TournamentPairing(activeRound, Lists.newArrayList(byePlayer)); byePair.setBye(true); activePairings.add(byePair); } diff --git a/forge-gui/src/main/java/forge/util/ImageFetcher.java b/forge-gui/src/main/java/forge/util/ImageFetcher.java index fa08293340f..cf219331dc8 100644 --- a/forge-gui/src/main/java/forge/util/ImageFetcher.java +++ b/forge-gui/src/main/java/forge/util/ImageFetcher.java @@ -118,7 +118,7 @@ public abstract class ImageFetcher { protected abstract Runnable getDownloadTask(String[] toArray, String destPath, Runnable notifyObservers); - public static interface Callback { - public void onImageFetched(); + public interface Callback { + void onImageFetched(); } } \ No newline at end of file From a4d34bb85894199fbbc7112a4ba3b0882cfd6238 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 3 Sep 2019 11:20:10 +0800 Subject: [PATCH 2/5] Retained some schemas --- .../java/forge/ai/AiAttackController.java | 12 +- .../src/main/java/forge/ai/AiController.java | 18 +- .../src/main/java/forge/ai/ComputerUtil.java | 46 +++-- .../main/java/forge/ai/ComputerUtilCard.java | 10 +- .../java/forge/ai/ComputerUtilCombat.java | 31 ++-- .../main/java/forge/ai/ComputerUtilMana.java | 16 +- .../src/main/java/forge/ai/SpecialCardAi.java | 39 ++-- .../main/java/forge/ai/SpellAbilityAi.java | 5 +- .../main/java/forge/ai/ability/AnimateAi.java | 9 +- .../java/forge/ai/ability/CountersMoveAi.java | 12 +- .../forge/ai/ability/CountersMultiplyAi.java | 15 +- .../java/forge/ai/ability/CountersPutAi.java | 18 +- .../java/forge/ai/ability/DamageAllAi.java | 16 +- .../java/forge/ai/ability/DamageDealAi.java | 5 +- .../main/java/forge/ai/ability/DestroyAi.java | 8 +- .../java/forge/ai/ability/DestroyAllAi.java | 15 +- .../main/java/forge/ai/ability/DrawAi.java | 24 ++- .../main/java/forge/ai/ability/FightAi.java | 14 +- .../java/forge/ai/ability/FlipACoinAi.java | 4 +- .../ai/ability/LifeExchangeVariantAi.java | 4 +- .../java/forge/ai/ability/LifeGainAi.java | 8 +- .../java/forge/ai/ability/LifeLoseAi.java | 8 +- .../java/forge/ai/ability/ManifestAi.java | 8 +- .../forge/ai/ability/PeekAndRevealAi.java | 6 +- .../main/java/forge/ai/ability/PoisonAi.java | 14 +- .../main/java/forge/ai/ability/RevealAi.java | 6 +- .../java/forge/ai/ability/SetStateAi.java | 5 +- forge-core/src/main/java/forge/ImageKeys.java | 4 +- .../src/main/java/forge/LobbyPlayer.java | 9 +- .../src/main/java/forge/card/CardType.java | 5 +- .../main/java/forge/deck/DeckRecognizer.java | 5 +- .../src/main/java/forge/item/PaperCard.java | 6 +- .../java/forge/game/combat/CombatUtil.java | 6 +- .../java/forge/game/cost/CostDiscard.java | 8 +- .../java/forge/game/cost/CostPayLife.java | 6 +- .../main/java/forge/game/player/Player.java | 10 +- .../forge/game/player/PlayerProperty.java | 172 +++++++++++++----- .../game/replacement/ReplaceAddCounter.java | 4 +- .../game/replacement/ReplaceCounter.java | 4 +- .../game/replacement/ReplaceDestroy.java | 4 +- .../game/replacement/ReplaceDiscard.java | 4 +- .../forge/game/replacement/ReplaceDraw.java | 8 +- .../game/replacement/ReplaceDrawCards.java | 4 +- .../game/replacement/ReplaceGainLife.java | 4 +- .../game/replacement/ReplaceGameLoss.java | 4 +- .../forge/game/replacement/ReplaceMoved.java | 4 +- .../game/replacement/ReplaceProduceMana.java | 4 +- .../game/replacement/ReplaceSetInMotion.java | 4 +- .../game/replacement/ReplaceSurveil.java | 4 +- .../forge/game/replacement/ReplaceToken.java | 4 +- .../game/replacement/ReplaceTurnFaceUp.java | 4 +- .../forge/game/replacement/ReplaceUntap.java | 4 +- .../forge/game/spellability/SpellAbility.java | 5 +- .../spellability/SpellAbilityCondition.java | 4 +- .../spellability/SpellAbilityRestriction.java | 22 ++- .../game/staticability/StaticAbility.java | 12 +- .../StaticAbilityCantAttach.java | 4 +- .../StaticAbilityCantAttackBlock.java | 4 +- .../StaticAbilityCantBeCast.java | 20 +- .../StaticAbilityCantPutCounter.java | 22 ++- .../main/java/forge/game/trigger/Trigger.java | 22 ++- .../forge/game/trigger/TriggerAbandoned.java | 6 +- .../java/forge/game/trigger/TriggerAdapt.java | 6 +- .../forge/game/trigger/TriggerAttached.java | 4 +- .../game/trigger/TriggerAttackerBlocked.java | 4 +- .../TriggerAttackerBlockedByCreature.java | 8 +- .../trigger/TriggerAttackerUnblocked.java | 6 +- .../trigger/TriggerAttackerUnblockedOnce.java | 6 +- .../trigger/TriggerAttackersDeclared.java | 4 +- .../forge/game/trigger/TriggerAttacks.java | 4 +- .../game/trigger/TriggerBecomeMonarch.java | 6 +- .../game/trigger/TriggerBecomeMonstrous.java | 6 +- .../game/trigger/TriggerBecomeRenowned.java | 6 +- .../game/trigger/TriggerBecomesTarget.java | 4 +- .../trigger/TriggerBecomesTargetOnce.java | 4 +- .../forge/game/trigger/TriggerBlocks.java | 4 +- .../forge/game/trigger/TriggerChampioned.java | 6 +- .../trigger/TriggerChangesController.java | 6 +- .../forge/game/trigger/TriggerClashed.java | 4 +- .../game/trigger/TriggerCounterAdded.java | 4 +- .../game/trigger/TriggerCounterAddedOnce.java | 6 +- .../game/trigger/TriggerCounterRemoved.java | 4 +- .../trigger/TriggerCounterRemovedOnce.java | 4 +- .../forge/game/trigger/TriggerCountered.java | 4 +- .../game/trigger/TriggerDamageDealtOnce.java | 4 +- .../game/trigger/TriggerDamageDoneOnce.java | 4 +- .../forge/game/trigger/TriggerDestroyed.java | 4 +- .../forge/game/trigger/TriggerDiscarded.java | 4 +- .../java/forge/game/trigger/TriggerDrawn.java | 6 +- .../forge/game/trigger/TriggerExiled.java | 6 +- .../forge/game/trigger/TriggerExploited.java | 6 +- .../game/trigger/TriggerFlippedCoin.java | 4 +- .../forge/game/trigger/TriggerHandler.java | 4 +- .../game/trigger/TriggerInvestigated.java | 4 +- .../forge/game/trigger/TriggerLandPlayed.java | 4 +- .../forge/game/trigger/TriggerLifeGained.java | 4 +- .../forge/game/trigger/TriggerLifeLost.java | 4 +- .../trigger/TriggerPayCumulativeUpkeep.java | 6 +- .../forge/game/trigger/TriggerPayEcho.java | 6 +- .../forge/game/trigger/TriggerPhaseOut.java | 10 +- .../forge/game/trigger/TriggerPlanarDice.java | 4 +- .../game/trigger/TriggerRegenerated.java | 4 +- .../forge/game/trigger/TriggerRevealed.java | 4 +- .../forge/game/trigger/TriggerSacrificed.java | 3 +- .../game/trigger/TriggerSearchedLibrary.java | 4 +- .../game/trigger/TriggerSetInMotion.java | 8 +- .../forge/game/trigger/TriggerShuffled.java | 4 +- .../game/trigger/TriggerSpellAbilityCast.java | 4 +- .../game/trigger/TriggerSpellAbilityCopy.java | 6 +- .../forge/game/trigger/TriggerSurveil.java | 4 +- .../java/forge/game/trigger/TriggerTaps.java | 8 +- .../game/trigger/TriggerTapsForMana.java | 4 +- .../forge/game/trigger/TriggerUnattach.java | 6 +- .../forge/game/trigger/TriggerUntaps.java | 6 +- .../java/forge/achievement/VariantWins.java | 4 +- .../java/forge/card/CardScriptParser.java | 5 +- .../src/main/java/forge/model/CardBlock.java | 5 +- .../src/main/java/forge/player/HumanPlay.java | 4 +- .../java/forge/quest/data/StarRating.java | 6 +- 119 files changed, 783 insertions(+), 292 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 35b2d140432..fa658e72bbe 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -602,7 +602,12 @@ public class AiAttackController { return true; } - return totalPoisonDamage >= 10 - opp.getPoisonCounters(); + if (totalPoisonDamage >= 10 - opp.getPoisonCounters()) { + return true; + } + + return false; + } private final GameEntity chooseDefender(final Combat c, final boolean bAssault) { @@ -1450,7 +1455,10 @@ public class AiAttackController { if (color != null) { return color; } - return artifact;//should never get here + if (artifact != null) { + return artifact; + } + return null;//should never get here } private void doLightmineFieldAttackLogic(List attackersLeft, int numForcedAttackers, boolean playAggro) { diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 3a10b030309..f9a6de01010 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1516,9 +1516,13 @@ public class AiController { // Hopefully there's not much to do with the extra mana immediately, can wait for Main 2 return true; } - // Might need an extra land to cast something, or for some kind of an ETB ability with a cost or an - // alternative cost (if we cast it in Main 1), or to use an activated ability on the battlefield - return (predictedMana > totalCMCInHand || !canCastWithLandDrop) && (!hasRelevantAbsOTB || isTapLand) && !hasLandBasedEffect; + if ((predictedMana <= totalCMCInHand && canCastWithLandDrop) || (hasRelevantAbsOTB && !isTapLand) || hasLandBasedEffect) { + // Might need an extra land to cast something, or for some kind of an ETB ability with a cost or an + // alternative cost (if we cast it in Main 1), or to use an activated ability on the battlefield + return false; + } + + return true; } private final SpellAbility getSpellAbilityToPlay() { @@ -1637,8 +1641,12 @@ public class AiController { return SpellApiToAi.Converter.get(spell.getApi()).doTriggerAI(player, spell, mandatory); if (spell instanceof WrappedAbility) return doTrigger(((WrappedAbility)spell).getWrappedAbility(), mandatory); - // For non-converted triggers (such as Cumulative Upkeep) that don't have costs or targets to worry about - return spell.getPayCosts() == Cost.Zero && spell.getTargetRestrictions() == null; + if (spell.getPayCosts() == Cost.Zero && spell.getTargetRestrictions() == null) { + // For non-converted triggers (such as Cumulative Upkeep) that don't have costs or targets to worry about + return true; + } + + return false; } /** diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index ffc4d8815dd..b21cc4435e4 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -795,7 +795,11 @@ public class ComputerUtil { return true; } - return ComputerUtilCard.hasActiveUndyingOrPersist(c); + if (ComputerUtilCard.hasActiveUndyingOrPersist(c)) { + return true; + } + + return false; } }); } @@ -1155,25 +1159,30 @@ public class ComputerUtil { final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, CardPredicates.Accessors.fnGetCmc)); final int discardCMC = discard.getCMC(); if (discard.isLand()) { - // Don't need more land. - return landsInPlay.size() >= highestCMC + if (landsInPlay.size() >= highestCMC || (landsInPlay.size() + landsInHand.size() > 6 && landsInHand.size() > 1) - || (landsInPlay.size() > 3 && nonLandsInHand.size() == 0); + || (landsInPlay.size() > 3 && nonLandsInHand.size() == 0)) { + // Don't need more land. + return true; + } } else { //non-land if (discardCMC > landsInPlay.size() + landsInHand.size() + 2) { // not castable for some time. return true; - } else // Probably don't need small stuff now. - if (!game.getPhaseHandler().isPlayerTurn(ai) + } else if (!game.getPhaseHandler().isPlayerTurn(ai) && game.getPhaseHandler().getPhase().isAfter(PhaseType.MAIN2) && discardCMC > landsInPlay.size() + landsInHand.size() && discardCMC > landsInPlay.size() + 1 && nonLandsInHand.size() > 1) { // not castable for at least one other turn. return true; - } else return landsInPlay.size() > 5 && discard.getCMC() <= 1 - && !discard.hasProperty("hasXCost", ai, null, null); + } else if (landsInPlay.size() > 5 && discard.getCMC() <= 1 + && !discard.hasProperty("hasXCost", ai, null, null)) { + // Probably don't need small stuff now. + return true; + } } + return false; } // returns true if it's better to wait until blockers are declared @@ -1914,12 +1923,16 @@ public class ComputerUtil { if (predictThreatenedObjects(ai, null).contains(source)) { return true; } - return game.getPhaseHandler().inCombat() && - ComputerUtilCombat.combatantWouldBeDestroyed(ai, source, game.getCombat()); + if (game.getPhaseHandler().inCombat() && + ComputerUtilCombat.combatantWouldBeDestroyed(ai, source, game.getCombat())) { + return true; + } } else if (zone.getZoneType() == ZoneType.Exile && sa.getMayPlay() != null) { // play cards in exile that can only be played that turn if (game.getPhaseHandler().getPhase() == PhaseType.MAIN2) { - return source.mayPlay(sa.getMayPlay()) != null; + if (source.mayPlay(sa.getMayPlay()) != null) { + return true; + } } } return false; @@ -2847,8 +2860,10 @@ public class ComputerUtil { return false; } else if (Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LoseLife"))) { return false; - } else return !Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LichDraw")); - + } else if (Iterables.any(list, CardTraitPredicates.hasParam("AiLogic", "LichDraw"))) { + return false; + } + return true; } public static boolean lifegainNegative(final Player player, final Card source) { @@ -3046,7 +3061,10 @@ public class ComputerUtil { if ((serious) && (ComputerUtilCombat.lifeInSeriousDanger(ai, combat, payment))) { return true; } - return (!serious) && (ComputerUtilCombat.lifeInDanger(ai, combat, payment)); + if ((!serious) && (ComputerUtilCombat.lifeInDanger(ai, combat, payment))) { + return true; + } + return false; } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index b00dccd66b5..21197757d99 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -1742,14 +1742,20 @@ public class ComputerUtilCard { if (!c.isCreature()) { return false; } - return c.hasKeyword("CARDNAME can't attack or block.") || (c.hasKeyword("CARDNAME doesn't untap during your untap step.") && c.isTapped()) || (c.getOwner() == ai && ai.getOpponents().contains(c.getController())); + if (c.hasKeyword("CARDNAME can't attack or block.") || (c.hasKeyword("CARDNAME doesn't untap during your untap step.") && c.isTapped()) || (c.getOwner() == ai && ai.getOpponents().contains(c.getController()))) { + return true; + } + return false; } public static boolean hasActiveUndyingOrPersist(final Card c) { if (c.hasKeyword(Keyword.UNDYING) && c.getCounters(CounterType.P1P1) == 0) { return true; } - return c.hasKeyword(Keyword.PERSIST) && c.getCounters(CounterType.M1M1) == 0; + if (c.hasKeyword(Keyword.PERSIST) && c.getCounters(CounterType.M1M1) == 0) { + return true; + } + return false; } public static boolean isPresentOnBattlefield(final Game game, final String cardName) { diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java index 5c56a8f84a6..9c030f3a2d4 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java @@ -879,18 +879,19 @@ public class ComputerUtilCombat { } else if (mode == TriggerType.DamageDone) { willTrigger = true; if (trigParams.containsKey("ValidSource")) { - if (CardTraitBase.matchesValid(defender, trigParams.get("ValidSource").split(","), source) + if (!(CardTraitBase.matchesValid(defender, trigParams.get("ValidSource").split(","), source) && defender.getNetCombatDamage() > 0 && (!trigParams.containsKey("ValidTarget") - || CardTraitBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source))) { - return true; + || CardTraitBase.matchesValid(attacker, trigParams.get("ValidTarget").split(","), source)))) { + return false; } - return CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source) + if (!(CardTraitBase.matchesValid(attacker, trigParams.get("ValidSource").split(","), source) && attacker.getNetCombatDamage() > 0 && (!trigParams.containsKey("ValidTarget") - || CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source)); + || CardTraitBase.matchesValid(defender, trigParams.get("ValidTarget").split(","), source)))) { + return false; + } } - return false; } return willTrigger; @@ -1789,7 +1790,11 @@ public class ComputerUtilCombat { } // all damage will be prevented - return attacker.hasKeyword("PreventAllDamageBy Creature.blockingSource"); + if (attacker.hasKeyword("PreventAllDamageBy Creature.blockingSource")) { + return true; + } + + return false; } // can the blocker destroy the attacker? @@ -1912,7 +1917,9 @@ public class ComputerUtilCombat { return false; } } - return attackerLife <= 2 * defenderDamage; + if (attackerLife <= 2 * defenderDamage) { + return true; + } } // defender double strike else { // no double strike for defender @@ -1936,7 +1943,7 @@ public class ComputerUtilCombat { return defenderDamage >= attackerLife; } // defender no double strike - // should never arrive here + return false;// should never arrive here } // canDestroyAttacker // For AI safety measures like Regeneration @@ -2157,7 +2164,9 @@ public class ComputerUtilCombat { return false; } } - return defenderLife <= 2 * attackerDamage; + if (defenderLife <= 2 * attackerDamage) { + return true; + } } // attacker double strike else { // no double strike for attacker @@ -2181,7 +2190,7 @@ public class ComputerUtilCombat { return attackerDamage >= defenderLife; } // attacker no double strike - // should never arrive here + return false;// should never arrive here } // canDestroyBlocker diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 5ac65671de7..8e9c0f84e2d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -880,10 +880,12 @@ public class ComputerUtilMana { // For combat tricks, always obey mana reservation if (curPhase == PhaseType.COMBAT_DECLARE_BLOCKERS || curPhase == PhaseType.CLEANUP) { - AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK); - } else if (!(ai.getGame().getPhaseHandler().isPlayerTurn(ai)) && (curPhase == PhaseType.COMBAT_DECLARE_BLOCKERS || curPhase == PhaseType.CLEANUP)) { - AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK); - AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT); + if (!(ai.getGame().getPhaseHandler().isPlayerTurn(ai))) { + AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK); + AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT); + } + else + AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK); } else { if ((AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK)) || (AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK))) { @@ -905,8 +907,10 @@ public class ComputerUtilMana { AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2); } else { - // This mana source is held elsewhere for a Main Phase 2 spell. - return AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2); + if (AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2)) { + // This mana source is held elsewhere for a Main Phase 2 spell. + return true; + } } return false; diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 6124365e7f8..27700e2455b 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -377,12 +377,15 @@ public class SpecialCardAi { // Already enough to kill the blockers and survive, don't overpump return false; } - // Can't kill or cripple anyone, as well as can't Trample over, so don't pump - return !oppCantDie || source.hasKeyword(Keyword.TRAMPLE) || source.hasKeyword(Keyword.WITHER) - || source.hasKeyword(Keyword.INFECT) || predictedPT.getLeft() > oppT; + if (oppCantDie && !source.hasKeyword(Keyword.TRAMPLE) && !source.hasKeyword(Keyword.WITHER) + && !source.hasKeyword(Keyword.INFECT) && predictedPT.getLeft() <= oppT) { + // Can't kill or cripple anyone, as well as can't Trample over, so don't pump + return false; + } // If we got here, it should be a favorable combat pump, resulting in at least one // opposing creature dying, and hopefully with the Pummeler surviving combat. + return true; } public static boolean predictOverwhelmingDamage(final Player ai, final SpellAbility sa) { @@ -471,13 +474,15 @@ public class SpecialCardAi { } if (isExileMode) { - // We probably need a low-CMC card to exile to it, exiling a higher CMC spell may be suboptimal - // since the AI does not prioritize/value cards vs. permission at the moment. if (blueCards.size() < 2) { // Need to have something else in hand that is blue in addition to Force of Will itself, // otherwise the AI will fail to play the card and the card will disappear from the pool return false; - } else return !CardLists.filter(blueCards, CardPredicates.lessCMC(3)).isEmpty(); + } else if (CardLists.filter(blueCards, CardPredicates.lessCMC(3)).isEmpty()) { + // We probably need a low-CMC card to exile to it, exiling a higher CMC spell may be suboptimal + // since the AI does not prioritize/value cards vs. permission at the moment. + return false; + } } return true; @@ -891,13 +896,15 @@ public class SpecialCardAi { } } else if (blackViseOTB && computerHandSize + exiledWithNecro - 1 >= 4) { // try not to overdraw in presence of Black Vise - return false; - } else // Only activate in AI's own turn (sans the exception above) - if (computerHandSize + exiledWithNecro - 1 >= maxHandSize) { + return false; + } else if (computerHandSize + exiledWithNecro - 1 >= maxHandSize) { // Only draw until we reach max hand size return false; - } else return ph.isPlayerTurn(ai) && ph.is(PhaseType.MAIN2); - + } else if (!ph.isPlayerTurn(ai) || !ph.is(PhaseType.MAIN2)) { + // Only activate in AI's own turn (sans the exception above) + return false; + } + return true; } } @@ -1426,12 +1433,14 @@ public class SpecialCardAi { } else if (blackViseOTB && computerHandSize + 1 > 4) { // try not to overdraw in presence of Black Vise return false; - } else // Only activate in AI's own turn (sans the exception above) - if (computerHandSize + 1 > maxHandSize) { + } else if (computerHandSize + 1 > maxHandSize) { // Only draw until we reach max hand size return false; - } else return ph.isPlayerTurn(ai); - + } else if (!ph.isPlayerTurn(ai)) { + // Only activate in AI's own turn (sans the exception above) + return false; + } + return true; } } diff --git a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java index b2f95d717fe..d86989d87a8 100644 --- a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java @@ -133,7 +133,10 @@ public abstract class SpellAbilityAi { if (!ComputerUtilCost.checkSacrificeCost(ai, cost, source, sa)) { return false; } - return ComputerUtilCost.checkRemoveCounterCost(cost, source, sa); + if (!ComputerUtilCost.checkRemoveCounterCost(cost, source, sa)) { + return false; + } + return true; } /** diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java index 5270bea95d1..17748584c9f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java @@ -117,9 +117,12 @@ public class AnimateAi extends SpellAbilityAi { boolean activateAsPotentialBlocker = sa.hasParam("UntilYourNextTurn") && ai.getGame().getPhaseHandler().getNextTurn() != ai && source.isPermanent(); - return !ph.isPlayerTurn(ai) || ai.getLife() >= 6 || opponent.getLife() <= 6 - || !Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES) - || sa.hasParam("AILogic") || sa.hasParam("Permanent") || activateAsPotentialBlocker; + if (ph.isPlayerTurn(ai) && ai.getLife() < 6 && opponent.getLife() > 6 + && Iterables.any(opponent.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES) + && !sa.hasParam("AILogic") && !sa.hasParam("Permanent") && !activateAsPotentialBlocker) { + return false; + } + return true; } @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java index 7c973b99d45..bf142184a33 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java @@ -327,7 +327,11 @@ public class CountersMoveAi extends SpellAbilityAi { return true; } } - return CounterType.M1M1.equals(cType) && card.hasKeyword(Keyword.PERSIST); + if (CounterType.M1M1.equals(cType) && card.hasKeyword(Keyword.PERSIST)) { + return true; + } + + return false; } }); @@ -421,7 +425,11 @@ public class CountersMoveAi extends SpellAbilityAi { } // source would leave the game - return !card.hasSVar("EndOfTurnLeavePlay"); + if (!card.hasSVar("EndOfTurnLeavePlay")) { + return true; + } + + return false; } }); diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java index 78dec0f8c0a..b20e99ace3b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java @@ -45,7 +45,10 @@ public class CountersMultiplyAi extends SpellAbilityAi { if (c.getCounters(counterType) <= 0) { return false; } - return c.canReceiveCounters(counterType); + if (!c.canReceiveCounters(counterType)) { + return false; + } + } else { for (Map.Entry e : c.getCounters().entrySet()) { // has negative counter it would double @@ -85,7 +88,11 @@ public class CountersMultiplyAi extends SpellAbilityAi { } } } - return !ComputerUtil.waitForBlocking(sa); + if (ComputerUtil.waitForBlocking(sa)) { + return false; + } + + return true; } @Override @@ -126,7 +133,9 @@ public class CountersMultiplyAi extends SpellAbilityAi { if (c.getCounters(counterType) <= 0) { return false; } - return c.canReceiveCounters(counterType); + if (!c.canReceiveCounters(counterType)) { + return false; + } } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 30e8e0f8b0f..d139920d0a4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -592,7 +592,11 @@ public class CountersPutAi extends SpellAbilityAi { } } - return !ComputerUtil.waitForBlocking(sa); + if (ComputerUtil.waitForBlocking(sa)) { + return false; + } + + return true; } @Override @@ -1067,8 +1071,10 @@ public class CountersPutAi extends SpellAbilityAi { } int totBlkPower = Aggregates.sum(combat.getBlockers(source), CardPredicates.Accessors.fnGetNetPower); - return source.getNetToughness() <= totBlkPower - && source.getNetToughness() + amount > totBlkPower; + if (source.getNetToughness() <= totBlkPower + && source.getNetToughness() + amount > totBlkPower) { + return true; + } } } else if (combat.isBlocking(source)) { for (Card blocked : combat.getAttackersBlockedBy(source)) { @@ -1079,8 +1085,10 @@ public class CountersPutAi extends SpellAbilityAi { } int totAtkPower = Aggregates.sum(combat.getAttackersBlockedBy(source), CardPredicates.Accessors.fnGetNetPower); - return source.getNetToughness() <= totAtkPower - && source.getNetToughness() + amount > totAtkPower; + if (source.getNetToughness() <= totAtkPower + && source.getNetToughness() + amount > totAtkPower) { + return true; + } } return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java index addba35d061..cbede1c1a11 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java @@ -233,8 +233,12 @@ public class DamageAllAi extends SpellAbilityAi { return true; } - return computerList.isEmpty() || ComputerUtilCard.evaluateCreatureList(computerList) <= ComputerUtilCard - .evaluateCreatureList(humanList); + if (!computerList.isEmpty() && ComputerUtilCard.evaluateCreatureList(computerList) > ComputerUtilCard + .evaluateCreatureList(humanList)) { + return false; + } + + return true; } /** @@ -316,7 +320,11 @@ public class DamageAllAi extends SpellAbilityAi { return true; } - return computerList.isEmpty() || ComputerUtilCard.evaluateCreatureList(computerList) + 50 < ComputerUtilCard - .evaluateCreatureList(humanList); + if (!computerList.isEmpty() && ComputerUtilCard.evaluateCreatureList(computerList) + 50 >= ComputerUtilCard + .evaluateCreatureList(humanList)) { + return false; + } + + return true; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index c683d8a14bf..f4af5ec56dc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -845,7 +845,10 @@ public class DamageDealAi extends DamageAiBase { if (!positive && !(saMe instanceof AbilitySub)) { return false; } - return urgent || SpellAbilityAi.playReusable(ai, saMe); + if (!urgent && !SpellAbilityAi.playReusable(ai, saMe)) { + return false; + } + return true; } /** diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java index b229dd1ca51..69c5bf22fc0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java @@ -295,9 +295,11 @@ public class DestroyAi extends SpellAbilityAi { return false; } - return !list.isEmpty() - && CardLists.filterControlledBy(list, ai).isEmpty() - && !CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE).isEmpty(); + if (list.isEmpty() + || !CardLists.filterControlledBy(list, ai).isEmpty() + || CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE).isEmpty()) { + return false; + } } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index 3e36251b077..a84aa9d8643 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -146,7 +146,10 @@ public class DestroyAllAi extends SpellAbilityAi { AiBlockController block = new AiBlockController(ai); block.assignBlockersForCombat(combat); - return ComputerUtilCombat.lifeInSeriousDanger(ai, combat); + if (ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) { + return true; + } + return false; } // only lands involved else if (CardLists.getNotType(opplist, "Land").isEmpty() && CardLists.getNotType(ailist, "Land").isEmpty()) { if (ai.isCardInPlay("Crucible of Worlds") && !opponent.isCardInPlay("Crucible of Worlds") && !opplist.isEmpty()) { @@ -161,9 +164,13 @@ public class DestroyAllAi extends SpellAbilityAi { } } // check if the AI would lose more lands than the opponent would - return ComputerUtilCard.evaluatePermanentList(ailist) <= ComputerUtilCard.evaluatePermanentList(opplist) + 1; + if (ComputerUtilCard.evaluatePermanentList(ailist) > ComputerUtilCard.evaluatePermanentList(opplist) + 1) { + return false; + } } // otherwise evaluate both lists by CMC and pass only if human permanents are more valuable - else return (ComputerUtilCard.evaluatePermanentList(ailist) + 3) < ComputerUtilCard.evaluatePermanentList(opplist); - + else if ((ComputerUtilCard.evaluatePermanentList(ailist) + 3) >= ComputerUtilCard.evaluatePermanentList(opplist)) { + return false; + } + return true; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/DrawAi.java b/forge-ai/src/main/java/forge/ai/ability/DrawAi.java index 5bd958880c1..212f0bbdab6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DrawAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DrawAi.java @@ -68,7 +68,10 @@ public class DrawAi extends SpellAbilityAi { return false; } - return canLoot(ai, sa); + if (!canLoot(ai, sa)) { + return false; + } + return true; } /* @@ -104,7 +107,11 @@ public class DrawAi extends SpellAbilityAi { } } - return ComputerUtilCost.checkRemoveCounterCost(cost, source, sa); + if (!ComputerUtilCost.checkRemoveCounterCost(cost, source, sa)) { + return false; + } + + return true; } /* @@ -195,7 +202,9 @@ public class DrawAi extends SpellAbilityAi { if (numHand == 0 && numDraw == numDiscard) { return false; // no looting since everything is dumped } - return numHand + numDraw >= numDiscard; // net loss of cards + if (numHand + numDraw < numDiscard) { + return false; // net loss of cards + } } return true; } @@ -477,8 +486,11 @@ public class DrawAi extends SpellAbilityAi { // ability is not targeted if (numCards >= computerLibrarySize) { - return ai.isCardInPlay("Laboratory Maniac"); + if (ai.isCardInPlay("Laboratory Maniac")) { + return true; + } // Don't deck yourself + return false; } if (numCards == 0 && !drawback) { @@ -491,7 +503,9 @@ public class DrawAi extends SpellAbilityAi { && !assumeSafeX) { // Don't draw too many cards and then risk discarding cards at // EOT - return drawback; + if (!drawback) { + return false; + } } } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/FightAi.java b/forge-ai/src/main/java/forge/ai/ability/FightAi.java index 94549a872b8..9a3b0965c42 100644 --- a/forge-ai/src/main/java/forge/ai/ability/FightAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/FightAi.java @@ -273,9 +273,10 @@ public class FightAi extends SpellAbilityAi { if (!canKill(opponent, fighter, -pumpDefense)) { // can survive return true; } else { - // trade - return MyRandom.getRandom().nextInt(20) < (opponent.getCMC() - fighter.getCMC()); - } + if (MyRandom.getRandom().nextInt(20)<(opponent.getCMC() - fighter.getCMC())) { // trade + return true; + } + } } return false; } @@ -288,7 +289,10 @@ public class FightAi extends SpellAbilityAi { || ComputerUtil.canRegenerate(opponent.getController(), opponent)) { return false; } - return fighter.hasKeyword(Keyword.DEATHTOUCH) - || ComputerUtilCombat.getDamageToKill(opponent) <= fighter.getNetPower() + pumpAttack; + if (fighter.hasKeyword(Keyword.DEATHTOUCH) + || ComputerUtilCombat.getDamageToKill(opponent) <= fighter.getNetPower() + pumpAttack) { + return true; + } + return false; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java b/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java index 2afefc36f03..7d61025c40d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/FlipACoinAi.java @@ -20,7 +20,9 @@ public class FlipACoinAi extends SpellAbilityAi { if (AILogic.equals("Never")) { return false; } else if (AILogic.equals("PhaseOut")) { - return ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(sa.getHostCard()); + if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(sa.getHostCard())) { + return false; + } } else if (AILogic.equals("KillOrcs")) { if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.END_OF_TURN) ) { return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java index a01bcf4ce67..e1432844d01 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java @@ -120,7 +120,9 @@ public class LifeExchangeVariantAi extends SpellAbilityAi { MagicStack stack = game.getStack(); if (!stack.isEmpty()) { SpellAbility saTop = stack.peekAbility(); - return ComputerUtil.predictDamageFromSpell(saTop, ai) >= aiLife; + if (ComputerUtil.predictDamageFromSpell(saTop, ai) >= aiLife) { + return true; + } } } diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java index 981c5f10d7b..41751f85882 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java @@ -49,7 +49,9 @@ public class LifeGainAi extends SpellAbilityAi { return false; } - return ComputerUtilCost.checkRemoveCounterCost(cost, source); + if (!ComputerUtilCost.checkRemoveCounterCost(cost, source)) { + return false; + } } else { // don't sac possible blockers if (!ph.getPhase().equals(PhaseType.COMBAT_DECLARE_BLOCKERS) @@ -61,7 +63,9 @@ public class LifeGainAi extends SpellAbilityAi { skipCheck |= ComputerUtilCost.isSacrificeSelfCost(cost) && !source.isCreature(); if (!skipCheck) { - return ComputerUtilCost.checkSacrificeCost(ai, cost, source, sa, false); + if (!ComputerUtilCost.checkSacrificeCost(ai, cost, source, sa,false)) { + return false; + } } } } diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java index a4a6a80981f..087261271c2 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java @@ -146,8 +146,12 @@ public class LifeLoseAi extends SpellAbilityAi { return false; } - return SpellAbilityAi.isSorcerySpeed(sa) || sa.hasParam("ActivationPhases") || SpellAbilityAi.playReusable(ai, sa) - || ComputerUtil.activateForCost(sa, ai); + if (SpellAbilityAi.isSorcerySpeed(sa) || sa.hasParam("ActivationPhases") || SpellAbilityAi.playReusable(ai, sa) + || ComputerUtil.activateForCost(sa, ai)) { + return true; + } + + return false; } /* diff --git a/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java b/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java index 947db225886..57e70f7fe58 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManifestAi.java @@ -80,7 +80,9 @@ public class ManifestAi extends SpellAbilityAi { // Set PayX here to maximum value. int x = ComputerUtilMana.determineLeftoverMana(sa, ai); source.setSVar("PayX", Integer.toString(x)); - return x > 0; + if (x <= 0) { + return false; + } } return true; @@ -119,7 +121,9 @@ public class ManifestAi extends SpellAbilityAi { return false; // card has ETBTrigger or ETBReplacement - return !card.hasETBTrigger(false) && !card.hasETBReplacement(); + if (card.hasETBTrigger(false) || card.hasETBReplacement()) { + return false; + } } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java b/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java index 008172bebcc..bd6dedc12ec 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PeekAndRevealAi.java @@ -24,8 +24,10 @@ public class PeekAndRevealAi extends SpellAbilityAi { return false; } if ("Main2".equals(sa.getParam("AILogic"))) { - return !aiPlayer.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2); - } + if (aiPlayer.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) { + return false; + } + } // So far this only appears on Triggers, but will expand // once things get converted from Dig + NoMove return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java b/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java index 5161d672432..0eba3082f50 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PoisonAi.java @@ -75,10 +75,12 @@ public class PoisonAi extends SpellAbilityAi { } Player max = players.max(PlayerPredicates.compareByPoison()); - // ai is one of the max - return ai.getPoisonCounters() != max.getPoisonCounters(); + if (ai.getPoisonCounters() == max.getPoisonCounters()) { + // ai is one of the max + return false; + } } - + return true; } private boolean tgtPlayer(Player ai, SpellAbility sa, boolean mandatory) { @@ -90,8 +92,10 @@ public class PoisonAi extends SpellAbilityAi { public boolean apply(Player input) { if (input.cantLose()) { return false; - } else return input.canReceiveCounters(CounterType.POISON); - + } else if (!input.canReceiveCounters(CounterType.POISON)) { + return false; + } + return true; } }); diff --git a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java index 7598d45a700..676d706d06b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java @@ -80,7 +80,11 @@ public class RevealAi extends RevealAiBase { } - return revealHandTargetAI(ai, sa/*, false, mandatory*/); + if (!revealHandTargetAI(ai, sa/*, false, mandatory*/)) { + return false; + } + + return true; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java index 408fa9a62a4..79104d062a6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java @@ -33,7 +33,10 @@ public class SetStateAi extends SpellAbilityAi { return false; } - return "Transform".equals(mode) || "Flip".equals(mode); + if("Transform".equals(mode) || "Flip".equals(mode)) { + return true; + } + return false; } @Override diff --git a/forge-core/src/main/java/forge/ImageKeys.java b/forge-core/src/main/java/forge/ImageKeys.java index ee1bca83312..3e5192ba642 100644 --- a/forge-core/src/main/java/forge/ImageKeys.java +++ b/forge-core/src/main/java/forge/ImageKeys.java @@ -133,7 +133,7 @@ public final class ImageKeys { // if there's an art variant try without it if (setlessFilename.matches(".*[0-9]*$")) { file = findFile(dir, setlessFilename.replaceAll("[0-9]*$", "")); - return file; + if (file != null) { return file; } } } } else if (filename.contains("/")) { @@ -144,7 +144,7 @@ public final class ImageKeys { // try lowering the art index to the minimum for regular cards if (setlessFilename.contains(".full")) { file = findFile(dir, setlessFilename.replaceAll("[0-9]*[.]full", "1.full")); - return file; + if (file != null) { return file; } } } diff --git a/forge-core/src/main/java/forge/LobbyPlayer.java b/forge-core/src/main/java/forge/LobbyPlayer.java index 171d4e04e96..79139ec3a75 100644 --- a/forge-core/src/main/java/forge/LobbyPlayer.java +++ b/forge-core/src/main/java/forge/LobbyPlayer.java @@ -47,8 +47,13 @@ public abstract class LobbyPlayer { } LobbyPlayer other = (LobbyPlayer) obj; if (name == null) { - return other.name == null; - } else return name.equals(other.name); + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; } public int getAvatarIndex() { diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index f7c85f94bb7..21cd142f63a 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -598,7 +598,10 @@ public final class CardType implements Comparable, CardTypeView { if (multiWordTypes[0].startsWith(type) && !multiWordTypes[0].equals(type)) { return true; } - return multiWordTypes[1].startsWith(type) && !multiWordTypes[1].equals(type); + if (multiWordTypes[1].startsWith(type) && !multiWordTypes[1].equals(type)) { + return true; + } + return false; } public static class Constant { diff --git a/forge-core/src/main/java/forge/deck/DeckRecognizer.java b/forge-core/src/main/java/forge/deck/DeckRecognizer.java index 52d2005fd3f..0cae2a03261 100644 --- a/forge-core/src/main/java/forge/deck/DeckRecognizer.java +++ b/forge-core/src/main/java/forge/deck/DeckRecognizer.java @@ -216,7 +216,10 @@ public class DeckRecognizer { if (line.toLowerCase().contains("schemes")) { return true; } - return line.toLowerCase().contains("vanguard"); + if (line.toLowerCase().contains("vanguard")) { + return true; + } + return false; } public void setDateConstraint(int month, Integer year) { diff --git a/forge-core/src/main/java/forge/item/PaperCard.java b/forge-core/src/main/java/forge/item/PaperCard.java index f69036aa1c9..4200b240e4d 100644 --- a/forge-core/src/main/java/forge/item/PaperCard.java +++ b/forge-core/src/main/java/forge/item/PaperCard.java @@ -159,7 +159,11 @@ public final class PaperCard implements Comparable, InventoryItemFro if (!edition.equals(other.edition)) { return false; } - return (other.foil == foil) && (other.artIndex == artIndex); + if ((other.foil != foil) || (other.artIndex != artIndex)) { + return false; + } + + return true; } /* diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index 0273d3a03cb..5f020665993 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -1069,7 +1069,11 @@ public class CombatUtil { return false; } - return !attacker.hasKeyword(Keyword.INTIMIDATE) || blocker.isArtifact() || blocker.sharesColorWith(attacker); + if (attacker.hasKeyword(Keyword.INTIMIDATE) && !blocker.isArtifact() && !blocker.sharesColorWith(attacker)) { + return false; + } + + return true; } // canBlock() public static boolean canAttackerBeBlockedWithAmount(Card attacker, int amount, Combat combat) { diff --git a/forge-game/src/main/java/forge/game/cost/CostDiscard.java b/forge-game/src/main/java/forge/game/cost/CostDiscard.java index b8073001756..517b374b6b8 100644 --- a/forge-game/src/main/java/forge/game/cost/CostDiscard.java +++ b/forge-game/src/main/java/forge/game/cost/CostDiscard.java @@ -149,11 +149,13 @@ public class CostDiscard extends CostPartWithList { } } - // not enough cards in hand to pay - return (amount == null) || (amount <= handList.size() - adjustment); + if ((amount != null) && (amount > handList.size() - adjustment)) { + // not enough cards in hand to pay + return false; + } } } - + return true; } /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/cost/CostPayLife.java b/forge-game/src/main/java/forge/game/cost/CostPayLife.java index 39f59048685..c0394e31bc4 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPayLife.java +++ b/forge-game/src/main/java/forge/game/cost/CostPayLife.java @@ -78,7 +78,11 @@ public class CostPayLife extends CostPart { return false; } - return !payer.hasKeyword("You can't pay life to cast spells or activate abilities."); + if (payer.hasKeyword("You can't pay life to cast spells or activate abilities.")) { + return false; + } + + return true; } @Override 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 9e42220c143..d4214940983 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -2476,7 +2476,10 @@ public class Player extends GameEntity implements Comparable { "Skip all combat phases of this turn."); return true; } - return hasKeyword("Skip all combat phases of this turn."); + if (hasKeyword("Skip all combat phases of this turn.")) { + return true; + } + return false; } public boolean isSkippingMain() { @@ -2596,7 +2599,10 @@ public class Player extends GameEntity implements Comparable { removeKeyword("Skip your next draw step."); return true; } - return hasKeyword("Skip your draw step."); + if (hasKeyword("Skip your draw step.")) { + return true; + } + return false; } public CardCollectionView getInboundTokens() { diff --git a/forge-game/src/main/java/forge/game/player/PlayerProperty.java b/forge-game/src/main/java/forge/game/player/PlayerProperty.java index 73aebdbd1c0..f1c17abdf59 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerProperty.java +++ b/forge-game/src/main/java/forge/game/player/PlayerProperty.java @@ -23,9 +23,13 @@ public class PlayerProperty { Game game = player.getGame(); if (property.equals("You")) { - return player.equals(sourceController); + if (!player.equals(sourceController)) { + return false; + } } else if (property.equals("Opponent")) { - return !player.equals(sourceController) && player.isOpponentOf(sourceController); + if (player.equals(sourceController) || !player.isOpponentOf(sourceController)) { + return false; + } } else if (property.startsWith("OpponentOf ")) { final String v = property.split(" ")[1]; final List players = AbilityUtils.getDefinedPlayers(source, v, spellAbility); @@ -35,24 +39,42 @@ public class PlayerProperty { } } } else if (property.equals("YourTeam")) { - return player.sameTeam(sourceController); + if (!player.sameTeam(sourceController)) { + return false; + } } else if (property.equals("Allies")) { - return !player.equals(sourceController) && !player.isOpponentOf(sourceController); + if (player.equals(sourceController) || player.isOpponentOf(sourceController)) { + return false; + } } else if (property.equals("Active")) { - return player.equals(game.getPhaseHandler().getPlayerTurn()); + if (!player.equals(game.getPhaseHandler().getPlayerTurn())) { + return false; + } } else if (property.equals("NonActive")) { - return !player.equals(game.getPhaseHandler().getPlayerTurn()); + if (player.equals(game.getPhaseHandler().getPlayerTurn())) { + return false; + } } else if (property.equals("OpponentToActive")) { final Player active = game.getPhaseHandler().getPlayerTurn(); - return !player.equals(active) && player.isOpponentOf(active); + if (player.equals(active) || !player.isOpponentOf(active)) { + return false; + } } else if (property.equals("Other")) { - return !player.equals(sourceController); + if (player.equals(sourceController)) { + return false; + } } else if (property.equals("OtherThanSourceOwner")) { - return !player.equals(source.getOwner()); + if (player.equals(source.getOwner())) { + return false; + } } else if (property.equals("isMonarch")) { - return player.equals(game.getMonarch()); + if (!player.equals(game.getMonarch())) { + return false; + } } else if (property.equals("hasBlessing")) { - return player.hasBlessing(); + if (!player.hasBlessing()) { + return false; + } } else if (property.startsWith("wasDealtCombatDamageThisCombatBy ")) { String v = property.split(" ")[1]; @@ -69,7 +91,9 @@ public class PlayerProperty { found++; } } - return found >= count; + if (found < count) { + return false; + } } else if (property.startsWith("wasDealtDamageThisGameBy ")) { String v = property.split(" ")[1]; @@ -86,7 +110,9 @@ public class PlayerProperty { found++; } } - return found >= count; + if (found < count) { + return false; + } } else if (property.startsWith("wasDealtDamageThisTurnBy ")) { String v = property.split(" ")[1]; int count = 1; @@ -103,7 +129,9 @@ public class PlayerProperty { found++; } } - return found >= count; + if (found < count) { + return false; + } } else if (property.startsWith("wasDealtCombatDamageThisTurnBy ")) { String v = property.split(" ")[1]; @@ -121,54 +149,90 @@ public class PlayerProperty { found++; } } - return found >= count; + if (found < count) { + return false; + } } else if (property.equals("attackedBySourceThisCombat")) { - return game.getCombat() != null && player.equals(game.getCombat().getDefenderPlayerByAttacker(source)); + if (game.getCombat() == null || !player.equals(game.getCombat().getDefenderPlayerByAttacker(source))) { + return false; + } } else if (property.equals("wasDealtDamageThisTurn")) { - return player.getAssignedDamage() != 0; + if (player.getAssignedDamage() == 0) { + return false; + } } else if (property.equals("wasDealtCombatDamageThisTurn")) { - return player.getAssignedCombatDamage() != 0; + if (player.getAssignedCombatDamage() == 0) { + return false; + } } else if (property.equals("LostLifeThisTurn")) { - return player.getLifeLostThisTurn() > 0; + if (player.getLifeLostThisTurn() <= 0) { + return false; + } } else if (property.equals("DeclaredAttackerThisTurn")) { - return player.getAttackersDeclaredThisTurn() > 0; + if (player.getAttackersDeclaredThisTurn() <= 0) { + return false; + } } else if (property.equals("TappedLandForManaThisTurn")) { - return player.hasTappedLandForManaThisTurn(); + if (!player.hasTappedLandForManaThisTurn()) { + return false; + } } else if (property.equals("NoCardsInHandAtBeginningOfTurn")) { - return player.getNumCardsInHandStartedThisTurnWith() <= 0; + if (player.getNumCardsInHandStartedThisTurnWith() > 0) { + return false; + } } else if (property.equals("CardsInHandAtBeginningOfTurn")) { - return player.getNumCardsInHandStartedThisTurnWith() > 0; + if (player.getNumCardsInHandStartedThisTurnWith() <= 0) { + return false; + } } else if (property.startsWith("WithCardsInHand")) { if (property.contains("AtLeast")) { int amount = Integer.parseInt(property.split("AtLeast")[1]); - return player.getCardsIn(ZoneType.Hand).size() >= amount; + if (player.getCardsIn(ZoneType.Hand).size() < amount) { + return false; + } } } else if (property.equals("IsRemembered")) { - return source.isRemembered(player); + if (!source.isRemembered(player)) { + return false; + } } else if (property.equals("IsNotRemembered")) { - return !source.isRemembered(player); + if (source.isRemembered(player)) { + return false; + } } else if (property.equals("EnchantedBy")) { - return player.isEnchantedBy(source); + if (!player.isEnchantedBy(source)) { + return false; + } } else if (property.equals("Chosen")) { - return source.getChosenPlayer() != null && source.getChosenPlayer().equals(player); + if (source.getChosenPlayer() == null || !source.getChosenPlayer().equals(player)) { + return false; + } } else if (property.startsWith("LifeEquals_")) { int life = AbilityUtils.calculateAmount(source, property.substring(11), null); - return player.getLife() == life; + if (player.getLife() != life) { + return false; + } } else if (property.equals("IsPoisoned")) { - return player.getPoisonCounters() > 0; + if (player.getPoisonCounters() <= 0) { + return false; + } } else if (property.startsWith("controls")) { final String[] type = property.substring(8).split("_"); final CardCollectionView list = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type[0], sourceController, source); String comparator = type[1]; String compareTo = comparator.substring(2); int y = StringUtils.isNumeric(compareTo) ? Integer.parseInt(compareTo) : 0; - return Expressions.compare(list.size(), comparator, y); + if (!Expressions.compare(list.size(), comparator, y)) { + return false; + } } else if (property.startsWith("withMore")) { final String cardType = property.split("sThan")[0].substring(8); final Player controller = "Active".equals(property.split("sThan")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController; final CardCollectionView oppList = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); final CardCollectionView yourList = CardLists.filter(controller.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); - return oppList.size() > yourList.size(); + if (oppList.size() <= yourList.size()) { + return false; + } } else if (property.startsWith("withAtLeast")) { final String cardType = property.split("More")[1].split("sThan")[0]; final int amount = Integer.parseInt(property.substring(11, 12)); @@ -176,19 +240,25 @@ public class PlayerProperty { final CardCollectionView oppList = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); final CardCollectionView yourList = CardLists.filter(controller.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(cardType)); System.out.println(yourList.size()); - return oppList.size() >= yourList.size() + amount; + if (oppList.size() < yourList.size() + amount) { + return false; + } } else if (property.startsWith("hasMore")) { final Player controller = property.contains("Than") && "Active".equals(property.split("Than")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController; if (property.substring(7).startsWith("Life") && player.getLife() <= controller.getLife()) { return false; - } else return !property.substring(7).startsWith("CardsInHand") - || player.getCardsIn(ZoneType.Hand).size() > controller.getCardsIn(ZoneType.Hand).size(); + } else if (property.substring(7).startsWith("CardsInHand") + && player.getCardsIn(ZoneType.Hand).size() <= controller.getCardsIn(ZoneType.Hand).size()) { + return false; + } } else if (property.startsWith("hasFewer")) { final Player controller = "Active".equals(property.split("Than")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController; final ZoneType zt = property.substring(8).startsWith("CreaturesInYard") ? ZoneType.Graveyard : ZoneType.Battlefield; final CardCollectionView oppList = CardLists.filter(player.getCardsIn(zt), Presets.CREATURES); final CardCollectionView yourList = CardLists.filter(controller.getCardsIn(zt), Presets.CREATURES); - return oppList.size() < yourList.size(); + if (oppList.size() >= yourList.size()) { + return false; + } } else if (property.startsWith("withMost")) { final String kind = property.substring(8); if (kind.equals("Life")) { @@ -198,7 +268,9 @@ public class PlayerProperty { highestLife = p.getLife(); } } - return player.getLife() == highestLife; + if (player.getLife() != highestLife) { + return false; + } } else if (kind.equals("PermanentInPlay")) { int typeNum = 0; @@ -214,7 +286,9 @@ public class PlayerProperty { } } - return controlmost.size() == 1 && controlmost.contains(player); + if (controlmost.size() != 1 || !controlmost.contains(player)) { + return false; + } } else if (kind.equals("CardsInHand")) { int largestHand = 0; @@ -225,7 +299,9 @@ public class PlayerProperty { withLargestHand = p; } } - return player.equals(withLargestHand); + if (!player.equals(withLargestHand)) { + return false; + } } else if (kind.startsWith("Type")) { String type = property.split("Type")[1]; @@ -249,7 +325,9 @@ public class PlayerProperty { if (checkOnly && controlmost.size() != 1) { return false; } - return controlmost.contains(player); + if (!controlmost.contains(player)) { + return false; + } } } else if (property.startsWith("withLowest")) { if (property.substring(10).equals("Life")) { @@ -264,14 +342,20 @@ public class PlayerProperty { lowestlifep.add(p); } } - return lowestlifep.contains(player); + if (!lowestlifep.contains(player)) { + return false; + } } } else if (property.startsWith("LessThanHalfStartingLifeTotal")) { - return player.getLife() < (int) Math.ceil(player.getStartingLife() / 2.0); + if (player.getLife() >= (int) Math.ceil(player.getStartingLife() / 2.0)) { + return false; + } } else if (property.startsWith("Triggered")) { - return AbilityUtils.getDefinedPlayers(source, property, spellAbility).contains(player); + if (!AbilityUtils.getDefinedPlayers(source, property, spellAbility).contains(player)) { + return false; + } } return true; } -} +} \ No newline at end of file diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java b/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java index 882dd783bcc..05bf6c1627d 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java @@ -59,7 +59,9 @@ public class ReplaceAddCounter extends ReplacementEffect { if (mapParams.containsKey("ValidCounterType")) { String type = this.getMapParams().get("ValidCounterType"); - return CounterType.getType(type) == runParams.get("CounterType"); + if (CounterType.getType(type) != runParams.get("CounterType")) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java b/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java index e1e92a84ae0..6708d29b7ed 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceCounter.java @@ -59,7 +59,9 @@ public class ReplaceCounter extends ReplacementEffect { } if (this.getMapParams().containsKey("ValidType")) { String type = this.getMapParams().get("ValidType"); - return !type.equals("Spell") || spellAbility.isSpell(); + if (type.equals("Spell") && !spellAbility.isSpell()) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java index 5aa9da41132..fa61c0e1123 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDestroy.java @@ -74,7 +74,9 @@ public class ReplaceDestroy extends ReplacementEffect { } } if (hasParam("ValidSource")) { - return matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), getHostCard()); + if (!matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java index 8354cf6418b..20499fc1de2 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDiscard.java @@ -62,7 +62,9 @@ public class ReplaceDiscard extends ReplacementEffect { } } if (this.getMapParams().containsKey("DiscardFromEffect")) { - return null != runParams.get("Source"); + if (null == runParams.get("Source")) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java index a6547e66d49..4b7b2d80f38 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java @@ -55,9 +55,11 @@ public class ReplaceDraw extends ReplacementEffect { } if (this.getMapParams().containsKey("NotFirstCardInDrawStep")) { final Player p = (Player)runParams.get("Affected"); - return p.numDrawnThisDrawStep() != 0 - || !this.getHostCard().getGame().getPhaseHandler().is(PhaseType.DRAW) - || !this.getHostCard().getGame().getPhaseHandler().isPlayerTurn(p); + if (p.numDrawnThisDrawStep() == 0 + && this.getHostCard().getGame().getPhaseHandler().is(PhaseType.DRAW) + && this.getHostCard().getGame().getPhaseHandler().isPlayerTurn(p)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java index fffc08855ed..30f56eceb9d 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDrawCards.java @@ -57,7 +57,9 @@ public class ReplaceDrawCards extends ReplacementEffect { String comparator = this.getMapParams().get("Number"); final String operator = comparator.substring(0, 2); final int operandValue = Integer.parseInt(comparator.substring(2)); - return Expressions.compare(n, operator, operandValue); + if (!Expressions.compare(n, operator, operandValue)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java b/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java index aa95a7a8862..d269f9c044f 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceGainLife.java @@ -57,7 +57,9 @@ public class ReplaceGainLife extends ReplacementEffect { } } if ("True".equals(this.getMapParams().get("SourceController"))) { - return runParams.get("Source") != null && runParams.get("Affected").equals(((Card) runParams.get("Source")).getController()); + if (runParams.get("Source") == null || !runParams.get("Affected").equals(((Card)runParams.get("Source")).getController())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java b/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java index d6cc1b84cf2..298f6cf470b 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceGameLoss.java @@ -29,7 +29,9 @@ public class ReplaceGameLoss extends ReplacementEffect { return false; } if (this.getMapParams().containsKey("ValidPlayer")) { - return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard()); + if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java b/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java index a7af2db3f2e..162d87bca99 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceMoved.java @@ -105,7 +105,9 @@ public class ReplaceMoved extends ReplacementEffect { if (runParams.containsKey("Cause")) { SpellAbility cause = (SpellAbility) runParams.get("Cause"); if (cause != null) { - return !cause.isValid(getParam("NotCause").split(","), controller, getHostCard(), null); + if (cause.isValid(getParam("NotCause").split(","), controller, getHostCard(), null)) { + return false; + } } } } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java b/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java index dc7c218e750..90abfa87fd6 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceProduceMana.java @@ -58,7 +58,9 @@ public class ReplaceProduceMana extends ReplacementEffect { } if (this.getMapParams().containsKey("ValidCard")) { - return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard()); + if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java b/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java index 7cfb4413ce8..d4c2c7a2c1f 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceSetInMotion.java @@ -46,7 +46,9 @@ public class ReplaceSetInMotion extends ReplacementEffect { return false; } if (this.getMapParams().containsKey("ValidPlayer")) { - return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard()); + if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java b/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java index 809dd8a00a8..ad6a9478245 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java @@ -31,7 +31,9 @@ public class ReplaceSurveil extends ReplacementEffect { } if (hasParam("ValidPlayer")) { - return matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), getHostCard()); + if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java b/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java index f8b5d4ebe78..d58cd697b4a 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceToken.java @@ -45,7 +45,9 @@ public class ReplaceToken extends ReplacementEffect { if (hasParam("ValidToken")) { if (runParams.containsKey("Token")) { - return matchesValid(runParams.get("Token"), getParam("ValidToken").split(","), getHostCard()); + if (!matchesValid(runParams.get("Token"), getParam("ValidToken").split(","), getHostCard())) { + return false; + } } else { // in case RE is not updated yet return false; diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java b/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java index 67feac6bdbd..d1d4bbe2845 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceTurnFaceUp.java @@ -30,7 +30,9 @@ public class ReplaceTurnFaceUp extends ReplacementEffect { return false; } if (this.getMapParams().containsKey("ValidCard")) { - return matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard()); + if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java b/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java index 898ec36bfea..d336af27279 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceUntap.java @@ -63,7 +63,9 @@ public class ReplaceUntap extends ReplacementEffect { final Card card = (Card) o; // all replace untap with untapStep does have "your untap step" final Player player = card.getController(); - return player.getGame().getPhaseHandler().is(PhaseType.UNTAP, player); + if (!player.getGame().getPhaseHandler().is(PhaseType.UNTAP, player)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index 2ec5dac8bc2..cfa028365c6 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -1720,7 +1720,10 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit if (isSpell() && text.contains("was spent to cast")) { return true; } - return isAbility() && text.contains("mana spent to pay"); + if (isAbility() && text.contains("mana spent to pay")) { + return true; + } + return false; } public void checkActivationResloveSubs() { 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 80fe9bedd26..c53c34bd3ce 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -444,7 +444,9 @@ public class SpellAbilityCondition extends SpellAbilityVariables { final int svarValue = AbilityUtils.calculateAmount(host, this.getsVarToCheck(), sa); final int operandValue = AbilityUtils.calculateAmount(host, this.getsVarOperand(), sa); - return Expressions.compare(svarValue, this.getsVarOperator(), operandValue); + if (!Expressions.compare(svarValue, this.getsVarOperator(), operandValue)) { + return false; + } } diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index 01c1b2ea326..bc3e6649da4 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -270,7 +270,11 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } // TODO: this is an exception for Aftermath. Needs to be somehow generalized. - return this.getZone() == ZoneType.Graveyard || !sa.isAftermath() || !sa.isRightSplit(); + if (this.getZone() != ZoneType.Graveyard && sa.isAftermath() && sa.isRightSplit()) { + return false; + } + + return true; } } return false; @@ -311,7 +315,9 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } } - return isPhase; + if (!isPhase) { + return false; + } } return true; } @@ -350,7 +356,9 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { if (sa.isSpell()) { final CardPlayOption o = c.mayPlay(sa.getMayPlay()); - return o != null && o.getPlayer() == activator; + if (o != null && o.getPlayer() == activator) { + return true; + } } return false; @@ -507,7 +515,9 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { final int svarValue = AbilityUtils.calculateAmount(sa.getHostCard(), this.getsVarToCheck(), sa); final int operandValue = AbilityUtils.calculateAmount(sa.getHostCard(), this.getsVarOperand(), sa); - return Expressions.compare(svarValue, this.getsVarOperator(), operandValue); + if (!Expressions.compare(svarValue, this.getsVarOperator(), operandValue)) { + return false; + } } return true; } @@ -572,7 +582,9 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { int gameActivationLimit = AbilityUtils.calculateAmount(c, limit, sa); this.setGameActivationLimit(gameActivationLimit); - return (this.getGameActivationLimit() == -1) || (sa.getActivationsThisGame() < this.getGameActivationLimit()); + if ((this.getGameActivationLimit() != -1) && (sa.getActivationsThisGame() >= this.getGameActivationLimit())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java index bb4a0f6e37b..d429b7e3d70 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java @@ -516,8 +516,12 @@ public class StaticAbility extends CardTraitBase implements Comparable thisTurnCast = CardUtil.getThisTurnCast(valid, card); - return CardLists.filterControlledBy(thisTurnCast, activator).size() >= limit; + if (CardLists.filterControlledBy(thisTurnCast, activator).size() < limit) { + return false; + } } return true; @@ -136,8 +138,12 @@ public class StaticAbilityCantBeCast { return false; } - return !params.containsKey("NonActivatorTurn") || (activator == null) - || !activator.getGame().getPhaseHandler().isPlayerTurn(activator); + if (params.containsKey("NonActivatorTurn") && (activator != null) + && activator.getGame().getPhaseHandler().isPlayerTurn(activator)) { + return false; + } + + return true; } /** @@ -168,8 +174,12 @@ public class StaticAbilityCantBeCast { } } - return !params.containsKey("Player") || (player == null) - || player.isValid(params.get("Player"), hostCard.getController(), hostCard, null); + if (params.containsKey("Player") && (player != null) + && !player.isValid(params.get("Player"), hostCard.getController(), hostCard, null)) { + return false; + } + + return true; } } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java index e43f48cb517..c66923a5168 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantPutCounter.java @@ -19,9 +19,14 @@ public class StaticAbilityCantPutCounter { // for the other part if (staticAbility.hasParam("ValidCard")) { - return card.isValid(staticAbility.getParam("ValidCard").split(","), hostCard.getController(), hostCard, null); - } else return !staticAbility.hasParam("ValidPlayer"); - + if (!card.isValid(staticAbility.getParam("ValidCard").split(","), hostCard.getController(), hostCard, null)) { + return false; + } + } else if (staticAbility.hasParam("ValidPlayer")) { + // for the other part + return false; + } + return true; } public static boolean applyCantPutCounter(final StaticAbility staticAbility, final Player player, @@ -37,8 +42,13 @@ public class StaticAbilityCantPutCounter { // for the other part if (staticAbility.hasParam("ValidPlayer")) { - return player.isValid(staticAbility.getParam("ValidPlayer").split(","), hostCard.getController(), hostCard, null); - } else return !staticAbility.hasParam("ValidCard"); - + if (!player.isValid(staticAbility.getParam("ValidPlayer").split(","), hostCard.getController(), hostCard, null)) { + return false; + } + } else if (staticAbility.hasParam("ValidCard")) { + // for the other part + return false; + } + return true; } } diff --git a/forge-game/src/main/java/forge/game/trigger/Trigger.java b/forge-game/src/main/java/forge/game/trigger/Trigger.java index 1ff3deaf234..e901efcb665 100644 --- a/forge-game/src/main/java/forge/game/trigger/Trigger.java +++ b/forge-game/src/main/java/forge/game/trigger/Trigger.java @@ -284,7 +284,9 @@ public abstract class Trigger extends TriggerReplacementBase { if (this.mapParams.containsKey("TurnCount")) { int turn = Integer.parseInt(this.mapParams.get("TurnCount")); - return phaseHandler.getTurn() == turn; + if (phaseHandler.getTurn() != turn) { + return false; + } } return true; @@ -354,7 +356,10 @@ public abstract class Trigger extends TriggerReplacementBase { } } - return meetsCommonRequirements(this.mapParams); + if ( !meetsCommonRequirements(this.mapParams)) + return false; + + return true; } @@ -377,7 +382,8 @@ public abstract class Trigger extends TriggerReplacementBase { String condition = this.mapParams.get("Condition"); if ("AltCost".equals(condition)) { final Card moved = (Card) runParams.get("Card"); - return null == moved || moved.isOptionalCostPaid(OptionalCost.AltCost); + if( null != moved && !moved.isOptionalCostPaid(OptionalCost.AltCost)) + return false; } else if ("AttackedPlayerWithMostLife".equals(condition)) { GameEntity attacked = (GameEntity) runParams.get("Attacked"); if (attacked == null) { @@ -385,8 +391,10 @@ public abstract class Trigger extends TriggerReplacementBase { // ends up being in Defender at that point. attacked = (GameEntity) runParams.get("Defender"); } - return attacked != null && attacked.isValid("Player.withMostLife", - this.getHostCard().getController(), this.getHostCard(), null); + if (attacked == null || !attacked.isValid("Player.withMostLife", + this.getHostCard().getController(), this.getHostCard(), null)) { + return false; + } } else if ("AttackedPlayerWhoAttackedYouLastTurn".equals(condition)) { GameEntity attacked = (GameEntity) runParams.get("Attacked"); if (attacked == null) { @@ -403,7 +411,9 @@ public abstract class Trigger extends TriggerReplacementBase { } } - return attacked != null && valid; + if (attacked == null || !valid) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java b/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java index 4aba396ab93..a07aff661d8 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAbandoned.java @@ -49,8 +49,10 @@ public class TriggerAbandoned extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - return matchesValid(runParams2.get("Scheme"), this.mapParams.get("ValidCard").split(","), - this.getHostCard()); + if (!matchesValid(runParams2.get("Scheme"), this.mapParams.get("ValidCard").split(","), + this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java b/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java index efd19c6340c..5a603b715c8 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAdapt.java @@ -52,8 +52,10 @@ public class TriggerAdapt extends Trigger { public final boolean performTest(final Map runParams2) { final Card sac = (Card) runParams2.get("Card"); if (hasParam("ValidCard")) { - return sac.isValid(getParam("ValidCard").split(","), getHostCard().getController(), - getHostCard(), null); + if (!sac.isValid(getParam("ValidCard").split(","), getHostCard().getController(), + getHostCard(), null)) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java index a4051152221..f185d57a441 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttached.java @@ -60,7 +60,9 @@ public class TriggerAttached extends Trigger { } if (this.mapParams.containsKey("ValidTarget")) { - return matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard()); + if (!matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java index d8a57921a46..89136658f35 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java @@ -73,7 +73,9 @@ public class TriggerAttackerBlocked extends Trigger { getHostCard().getController(), getHostCard() ); - return count != 0; + if ( count == 0 ) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java index 8edc3ad202c..be66cc09438 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java @@ -73,8 +73,12 @@ public class TriggerAttackerBlockedByCreature extends Trigger { if (this.mapParams.containsKey("ValidBlocker")) { final String validBlocker = this.mapParams.get("ValidBlocker"); if (validBlocker.equals("LessPowerThanAttacker")) { - return blocker.getNetPower() < attacker.getNetPower(); - } else return matchesValid(blocker, validBlocker.split(","), this.getHostCard()); + if (blocker.getNetPower() >= attacker.getNetPower()) { + return false; + } + } else if (!matchesValid(blocker, validBlocker.split(","), this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java index ec0bfa5c95b..c9ac21fc4bd 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java @@ -58,8 +58,10 @@ public class TriggerAttackerUnblocked extends Trigger { } } if (this.mapParams.containsKey("ValidDefender")) { - return matchesValid(runParams2.get("Defender"), this.mapParams.get("ValidDefender").split(","), - this.getHostCard()); + if (!matchesValid(runParams2.get("Defender"), this.mapParams.get("ValidDefender").split(","), + this.getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java index 06f7e06590f..66ed8f5c01b 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblockedOnce.java @@ -73,8 +73,10 @@ public class TriggerAttackerUnblockedOnce extends Trigger { */ } if (hasParam("ValidAttackingPlayer")) { - return matchesValid(runParams2.get("AttackingPlayer"), - this.mapParams.get("ValidAttackingPlayer").split(","), this.getHostCard()); + if (!matchesValid(runParams2.get("AttackingPlayer"), + this.mapParams.get("ValidAttackingPlayer").split(","), this.getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java index 8f00fbf3d33..72f9649bba1 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java @@ -76,7 +76,9 @@ public class TriggerAttackersDeclared extends Trigger { valid = true; } } - return valid; + if (!valid) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java index 971d4299bd7..0f28b513ce6 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java @@ -113,7 +113,9 @@ public class TriggerAttacks extends Trigger { } } } - return found; + if (!found) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java index 26a0deae9ef..17d9840f804 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonarch.java @@ -24,8 +24,10 @@ public class TriggerBecomeMonarch extends Trigger { } if (this.mapParams.containsKey("BeginTurn")) { - return matchesValid(game.getMonarchBeginTurn(), this.mapParams.get("BeginTurn").split(","), - host); + if (!matchesValid(game.getMonarchBeginTurn(), this.mapParams.get("BeginTurn").split(","), + host)) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java index 9b914392737..5a70ce99648 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeMonstrous.java @@ -52,8 +52,10 @@ public class TriggerBecomeMonstrous extends Trigger { @Override public final boolean performTest(Map runParams2) { if (hasParam("ValidCard")) { - return matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), - this.getHostCard()); + if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), + this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java index f0da7bc86b9..ab84910d4cf 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomeRenowned.java @@ -50,8 +50,10 @@ public class TriggerBecomeRenowned extends Trigger { @Override public final boolean performTest(final java.util.Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - return matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), - this.getHostCard()); + if (!matchesValid(runParams2.get("Card"), this.mapParams.get("ValidCard").split(","), + this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java index 3bdfa10004f..097262f0c51 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTarget.java @@ -77,7 +77,9 @@ public class TriggerBecomesTarget extends Trigger { } } if (this.mapParams.containsKey("FirstTime")) { - return runParams2.containsKey("FirstTime"); + if (!runParams2.containsKey("FirstTime")) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java index 6707812b470..bd8a2868c51 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBecomesTargetOnce.java @@ -70,7 +70,9 @@ public class TriggerBecomesTargetOnce extends Trigger { break; } } - return valid; + if (!valid) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java b/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java index 06f7e300693..441348ace95 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerBlocks.java @@ -77,7 +77,9 @@ public class TriggerBlocks extends Trigger { } } - return foundMatch; + if (!foundMatch) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java b/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java index 1611f9c7595..2604e2d55c7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChampioned.java @@ -60,8 +60,10 @@ public class TriggerChampioned extends Trigger { } } if (this.mapParams.containsKey("ValidSource")) { - return source.isValid(this.mapParams.get("ValidSource").split(","), - this.getHostCard().getController(), this.getHostCard(), null); + if (!source.isValid(this.mapParams.get("ValidSource").split(","), + this.getHostCard().getController(), this.getHostCard(), null)) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java index b394980a87d..31a073b8508 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesController.java @@ -58,8 +58,10 @@ public class TriggerChangesController extends Trigger { } } if (this.mapParams.containsKey("ValidOriginalController")) { - return matchesValid(runParams2.get("OriginalController"), this.mapParams.get("ValidOriginalController").split(","), - this.getHostCard()); + if (!matchesValid(runParams2.get("OriginalController"), this.mapParams.get("ValidOriginalController").split(","), + this.getHostCard())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java b/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java index a2eec1db4d7..8caaf85c7ef 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerClashed.java @@ -59,7 +59,9 @@ public class TriggerClashed extends Trigger { } if (this.mapParams.containsKey("Won")) { - return this.mapParams.get("Won").equals(runParams2.get("Won")); + if (!this.mapParams.get("Won").equals(runParams2.get("Won"))) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java index 9e8e0b4d288..26f64523bdc 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAdded.java @@ -109,7 +109,9 @@ public class TriggerCounterAdded extends Trigger { final int operand = Integer.parseInt(fullParam.substring(2)); final int actualAmount = (Integer) runParams2.get("CounterAmount"); - return Expressions.compare(actualAmount, operator, operand); + if (!Expressions.compare(actualAmount, operator, operand)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java index 65ea6cc7e18..549a3d81670 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterAddedOnce.java @@ -93,8 +93,10 @@ public class TriggerCounterAddedOnce extends Trigger { return false; } - return source.isValid(getParam("ValidSource").split(","), getHostCard().getController(), - getHostCard(), null); + if (!source.isValid(getParam("ValidSource").split(","), getHostCard().getController(), + getHostCard(), null)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java index eec54b27f2f..46e0bc5fa41 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemoved.java @@ -71,7 +71,9 @@ public class TriggerCounterRemoved extends Trigger { if (hasParam("NewCounterAmount")) { final String amtString = getParam("NewCounterAmount"); int amt = Integer.parseInt(amtString); - return amt == addedNewCounterAmount.intValue(); + if(amt != addedNewCounterAmount.intValue()) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java index 888ab7027dc..4e02b6d8df4 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterRemovedOnce.java @@ -62,7 +62,9 @@ public class TriggerCounterRemovedOnce extends Trigger { if (hasParam("CounterType")) { final String type = getParam("CounterType"); - return type.equals(removedType.toString()); + if (!type.equals(removedType.toString())) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java b/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java index a31fab2f15e..0b11585be24 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCountered.java @@ -80,7 +80,9 @@ public class TriggerCountered extends Trigger { if (ctrdSA != null) { if (validType.equals("Spell") && !ctrdSA.isSpell()) { return false; - } else return !validType.equals("Ability") || ctrdSA.isAbility(); + } else if (validType.equals("Ability") && !ctrdSA.isAbility()) { + return false; + } } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java index 88e9ea45135..7b4331ddb06 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDealtOnce.java @@ -94,7 +94,9 @@ public class TriggerDamageDealtOnce extends Trigger { final int operand = Integer.parseInt(fullParam.substring(2)); final int actualAmount = (Integer) runParams2.get("DamageAmount"); - return Expressions.compare(actualAmount, operator, operand); + if (!Expressions.compare(actualAmount, operator, operand)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java index bed6d6bc1a3..d5a9634cc39 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDamageDoneOnce.java @@ -45,7 +45,9 @@ public class TriggerDamageDoneOnce extends Trigger { } if (this.mapParams.containsKey("ValidTarget")) { - return matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard()); + if (!matchesValid(tgt, this.mapParams.get("ValidTarget").split(","), this.getHostCard())) { + return false; + } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java b/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java index 9686ea9fd29..cd533694d4f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDestroyed.java @@ -57,7 +57,9 @@ public class TriggerDestroyed extends Trigger { } } if (hasParam("ValidCard")) { - return matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard()); + if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java b/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java index f8a5f7d8d7a..0c60b064149 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDiscarded.java @@ -74,7 +74,9 @@ public class TriggerDiscarded extends Trigger { } if (this.mapParams.containsKey("IsMadness")) { Boolean madness = (Boolean) runParams2.get("IsMadness"); - return !(this.mapParams.get("IsMadness").equals("True") ^ madness); + if (this.mapParams.get("IsMadness").equals("True") ^ madness) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java b/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java index c9a761ac3ec..7e236166d20 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerDrawn.java @@ -70,7 +70,11 @@ public class TriggerDrawn extends Trigger { } // trigger should not happen while Mulligan - return game.getAge() != GameStage.Mulligan; + if (game.getAge() == GameStage.Mulligan) { + return false; + } + + return true; } /** {@inheritDoc} */ diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java b/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java index e12e4320903..3592a8d0adf 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerExiled.java @@ -84,8 +84,10 @@ public class TriggerExiled extends Trigger { if (cause == null) { return false; } - return cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(), - getHostCard(), null); + if (!cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(), + getHostCard(), null)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java b/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java index 2a4093ff1b2..dd566071c3c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerExploited.java @@ -60,8 +60,10 @@ public class TriggerExploited extends Trigger { } } if (this.mapParams.containsKey("ValidSource")) { - return source.isValid(this.mapParams.get("ValidSource").split(","), - this.getHostCard().getController(), this.getHostCard(), null); + if (!source.isValid(this.mapParams.get("ValidSource").split(","), + this.getHostCard().getController(), this.getHostCard(), null)) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java b/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java index 3137c5cd83f..3d4795f9be7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerFlippedCoin.java @@ -58,7 +58,9 @@ public class TriggerFlippedCoin extends Trigger { if (this.mapParams.containsKey("ValidResult")) { final boolean result = (Boolean) runParams2.get("Result"); final boolean valid = "Win".equals(this.mapParams.get("ValidResult")); - return !(result ^ valid); + if (result ^ valid) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index bd43d722a0d..85a7d8a1d6c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -536,7 +536,9 @@ public class TriggerHandler { final String dest = (String) runParams.get("Destination"); if (dest.equals("Battlefield") && runParams.get("Card") instanceof Card) { final Card card = (Card) runParams.get("Card"); - return !card.isCreature(); + if (card.isCreature()) { + return false; + } } } } // Torpor Orb check diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java b/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java index cb82452b8a5..89f3a10341d 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerInvestigated.java @@ -73,7 +73,9 @@ public class TriggerInvestigated extends Trigger { } if (this.mapParams.containsKey("OnlyFirst")) { - return (int) runParams2.get("Num") == 1; + if ((int) runParams2.get("Num") != 1) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java b/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java index 2498fb1d58f..0622263bdce 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java @@ -72,7 +72,9 @@ public class TriggerLandPlayed extends Trigger { } if (this.mapParams.containsKey("NotFirstLand")) { - return land.getController().getLandsPlayedThisTurn() >= 1; + if (land.getController().getLandsPlayedThisTurn() < 1) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java b/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java index 8c44cee9063..599594075a5 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLifeGained.java @@ -62,7 +62,9 @@ public class TriggerLifeGained extends Trigger { } if (hasParam("Spell")) { final SpellAbility spellAbility = (SpellAbility) runParams2.get("SourceSA"); - return spellAbility != null && spellAbility.getRootAbility().isSpell(); + if (spellAbility == null || !spellAbility.getRootAbility().isSpell()) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java b/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java index 60998db1fdb..d905e1c8b07 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLifeLost.java @@ -59,7 +59,9 @@ public class TriggerLifeLost extends Trigger { } if (this.mapParams.containsKey("FirstTime")) { - return (boolean) runParams2.get("FirstTime"); + if (!(boolean)runParams2.get("FirstTime")) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java b/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java index 365aecf8b92..bf13399f36e 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPayCumulativeUpkeep.java @@ -57,8 +57,10 @@ public class TriggerPayCumulativeUpkeep extends Trigger { } final Card card = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - return card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null); + if (!card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null)) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java b/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java index c6a9c567f8e..f9e7ecabf45 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPayEcho.java @@ -57,8 +57,10 @@ public class TriggerPayEcho extends Trigger { } final Card card = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - return card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null); + if (!card.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null)) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java index 530544ea3c4..d0abe3e4747 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOut.java @@ -20,9 +20,13 @@ public class TriggerPhaseOut extends Trigger { if (this.mapParams.get("ValidCard").equals("Card.Self")) { // Since Phased out cards aren't visible in .isValid, use a special check here. // NOTE: All Phase Out Triggers should use ValidCard$ Card.Self - return phaser == this.getHostCard(); - } else return phaser.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null); + if (phaser != this.getHostCard()) { + return false; + } + } else if (!phaser.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java b/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java index 87ed5e4666e..55bbcbd4b5c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPlanarDice.java @@ -42,7 +42,9 @@ public class TriggerPlanarDice extends Trigger { if (this.mapParams.containsKey("Result")) { PlanarDice cond = PlanarDice.smartValueOf(this.mapParams.get("Result")); - return cond == runParams2.get("Result"); + if (cond != runParams2.get("Result")) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java b/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java index 42483ab6abc..cd9f836c466 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerRegenerated.java @@ -57,7 +57,9 @@ public class TriggerRegenerated extends Trigger { } } if (hasParam("ValidCard")) { - return matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard()); + if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java b/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java index e75ff3c88c0..c7614ca9d95 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerRevealed.java @@ -22,7 +22,9 @@ public class TriggerRevealed extends Trigger { } if (this.mapParams.containsKey("Miracle")) { Boolean madness = (Boolean) runParams2.get("Miracle"); - return !(this.mapParams.get("Miracle").equals("True") ^ madness); + if (!matchesValid(runParams2.get("Card"), getParam("ValidCard").split(","), getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java b/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java index 4ece31285c7..64e545483fb 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java @@ -114,7 +114,8 @@ public class TriggerSacrificed extends Trigger { } } - return withKeyword; + if (!withKeyword) + return false; } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java b/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java index 52dc26d35bb..538b82670ff 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSearchedLibrary.java @@ -61,7 +61,9 @@ public class TriggerSearchedLibrary extends Trigger { if (this.mapParams.containsKey("SearchOwnLibrary")) { @SuppressWarnings("unchecked") List targets = (List) runParams2.get("Target"); - return targets.contains(runParams2.get("Player")); + if (!targets.contains(runParams2.get("Player"))) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java b/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java index 6b3bd7fa926..0cebd807951 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSetInMotion.java @@ -59,9 +59,13 @@ public class TriggerSetInMotion extends Trigger { if (this.mapParams.containsKey("SchemeType")) { if (this.mapParams.get("SchemeType").equals("NonOngoing")) { - return !((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing); + if (((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing)) { + return false; + } } else if (this.mapParams.get("SchemeType").equals("Ongoing")) { - return ((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing); + if (((Card) runParams2.get("Scheme")).getType().hasSupertype(CardType.Supertype.Ongoing)) { + return false; + } } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java b/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java index a351e9b31b6..e8abae4f522 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerShuffled.java @@ -62,7 +62,9 @@ public class TriggerShuffled extends Trigger { } if (this.mapParams.containsKey("ShuffleBySelfControlled")) { SpellAbility source = (SpellAbility) runParams2.get("Source"); - return source.getActivatingPlayer().equals(runParams2.get("Player")); + if (!source.getActivatingPlayer().equals(runParams2.get("Player"))) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java index 14312a228a3..43fde3f60c0 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCast.java @@ -252,7 +252,9 @@ public class TriggerSpellAbilityCast extends Trigger { break; } } - return sameNameFound; + if (!sameNameFound) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java index cd0ee3d47f4..26bb022c137 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSpellAbilityCopy.java @@ -78,8 +78,10 @@ public class TriggerSpellAbilityCopy extends Trigger { } } if (hasParam("ValidActivatingPlayer")) { - return si != null && matchesValid(si.getSpellAbility(true).getActivatingPlayer(), getParam("ValidActivatingPlayer") - .split(","), getHostCard()); + if (si == null || !matchesValid(si.getSpellAbility(true).getActivatingPlayer(), getParam("ValidActivatingPlayer") + .split(","), getHostCard())) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java b/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java index a0d16afa570..2d3ee1dbb19 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSurveil.java @@ -69,7 +69,9 @@ public class TriggerSurveil extends Trigger { } if (hasParam("OnlyFirst")) { - return (int) runParams2.get("NumThisTurn") == 1; + if ((int) runParams2.get("NumThisTurn") != 1) { + return false; + } } return true; } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java b/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java index 70ec3905557..44185a79ef7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTaps.java @@ -60,9 +60,13 @@ public class TriggerTaps extends Trigger { } if (hasParam("Attacker")) { if ("True".equalsIgnoreCase(getParam("Attacker"))) { - return (Boolean) runParams2.get("Attacker"); + if (!(Boolean)runParams2.get("Attacker")) { + return false; + } } else if ("False".equalsIgnoreCase(getParam("Attacker"))) { - return !((Boolean) runParams2.get("Attacker")); + if ((Boolean)runParams2.get("Attacker")) { + return false; + } } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java b/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java index 293f2abbdaa..348492cb775 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTapsForMana.java @@ -91,7 +91,9 @@ public class TriggerTapsForMana extends Trigger { } String produced = (String) prod; if ("ChosenColor".equals(mapParams.get("Produced"))) { - return this.getHostCard().hasChosenColor() && produced.contains(MagicColor.toShortString(this.getHostCard().getChosenColor())); + if (!this.getHostCard().hasChosenColor() || !produced.contains(MagicColor.toShortString(this.getHostCard().getChosenColor()))) { + return false; + } } } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java b/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java index 51b07e3c862..8b96b06fd3f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerUnattach.java @@ -60,8 +60,10 @@ public class TriggerUnattach extends Trigger { } if (hasParam("ValidAttachment")) { - return attach.isValid(getParam("ValidAttachment").split(","), getHostCard() - .getController(), getHostCard(), null); + if (!attach.isValid(getParam("ValidAttachment").split(","), getHostCard() + .getController(), getHostCard(), null)) { + return false; + } } return true; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java b/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java index 3029fa3177f..7c583f1467d 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerUntaps.java @@ -54,8 +54,10 @@ public class TriggerUntaps extends Trigger { final Card untapper = (Card) runParams2.get("Card"); if (this.mapParams.containsKey("ValidCard")) { - return untapper.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard(), null); + if (!untapper.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard(), null)) { + return false; + } } return true; diff --git a/forge-gui/src/main/java/forge/achievement/VariantWins.java b/forge-gui/src/main/java/forge/achievement/VariantWins.java index a1124b95e17..77a7e38f71d 100644 --- a/forge-gui/src/main/java/forge/achievement/VariantWins.java +++ b/forge-gui/src/main/java/forge/achievement/VariantWins.java @@ -23,7 +23,9 @@ public class VariantWins extends ProgressiveAchievement { if (game.getRules().hasAppliedVariant(variant)) { return true; } - return variant == GameType.Archenemy && game.getRules().hasAppliedVariant(GameType.ArchenemyRumble); //lump Archenemy Rumble into same achievement as Archenemy + if (variant == GameType.Archenemy && game.getRules().hasAppliedVariant(GameType.ArchenemyRumble)) { + return true; //lump Archenemy Rumble into same achievement as Archenemy + } } return false; } diff --git a/forge-gui/src/main/java/forge/card/CardScriptParser.java b/forge-gui/src/main/java/forge/card/CardScriptParser.java index c171329f248..55947f13095 100644 --- a/forge-gui/src/main/java/forge/card/CardScriptParser.java +++ b/forge-gui/src/main/java/forge/card/CardScriptParser.java @@ -119,7 +119,10 @@ public final class CardScriptParser { if (!(part.startsWith("P") || part.startsWith("2") || isManaSymbol(part.charAt(0)))) { return false; } - return (isManaSymbol(part.charAt(1))) && part.charAt(0) != part.charAt(1); + if ((!isManaSymbol(part.charAt(1))) || part.charAt(0) == part.charAt(1)) { + return false; + } + return true; } return false; } diff --git a/forge-gui/src/main/java/forge/model/CardBlock.java b/forge-gui/src/main/java/forge/model/CardBlock.java index ba8d16b08d9..a3893102354 100644 --- a/forge-gui/src/main/java/forge/model/CardBlock.java +++ b/forge-gui/src/main/java/forge/model/CardBlock.java @@ -181,7 +181,10 @@ public final class CardBlock implements Comparable { if (!this.landSet.equals(other.landSet)) { return false; } - return this.name.equals(other.name); + if (!this.name.equals(other.name)) { + return false; + } + return true; } /* diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index 93b4b31678a..fec7ac0844a 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -562,7 +562,9 @@ public class HumanPlay { } else { // Tainted Specter, Gurzigost, etc. boolean hasPaid = payCostPart(controller, sourceAbility, (CostPartWithList)part, amount, list, "put into library." + orString); - return hasPaid; + if (!hasPaid) { + return false; + } } return true; } diff --git a/forge-gui/src/main/java/forge/quest/data/StarRating.java b/forge-gui/src/main/java/forge/quest/data/StarRating.java index 1c91b4ed4d7..37f5f30213b 100644 --- a/forge-gui/src/main/java/forge/quest/data/StarRating.java +++ b/forge-gui/src/main/java/forge/quest/data/StarRating.java @@ -44,6 +44,10 @@ public class StarRating { return false; } - return rating == other.rating; + if (rating != other.rating) { + return false; + } + + return true; } } From efa606783c07a15d210e55d9c103da6bf41dcde1 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 3 Sep 2019 22:13:35 +0800 Subject: [PATCH 3/5] Cleanup --- .../java/forge/ai/AiAttackController.java | 1 - .../src/main/java/forge/ai/AiController.java | 1 - .../src/main/java/forge/ai/ComputerUtil.java | 6 +- .../java/forge/game/card/CardProperty.java | 736 +++++++++++++----- forge-gui-mobile/src/forge/Forge.java | 5 +- .../forge/download/GuiDownloadService.java | 6 +- 6 files changed, 558 insertions(+), 197 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index fa658e72bbe..c309b41ac01 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -607,7 +607,6 @@ public class AiAttackController { } return false; - } private final GameEntity chooseDefender(final Combat c, final boolean bAssault) { diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index f9a6de01010..a027cc9ea1c 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1645,7 +1645,6 @@ public class AiController { // For non-converted triggers (such as Cumulative Upkeep) that don't have costs or targets to worry about return true; } - return false; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index b21cc4435e4..f3172be4a43 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -1107,8 +1107,10 @@ public class ComputerUtil { creatures2.add(creatures.get(i)); } } - return ((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0)).size()) > 1) - && card.isCreature() && card.getManaCost().getCMC() <= 3; + if (((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0)).size()) > 1) + && card.isCreature() && card.getManaCost().getCMC() <= 3) { + return true; + } } return false; } 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 5be3ea783c9..1411664dd18 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -27,8 +27,7 @@ import java.util.List; public class CardProperty { - public static boolean cardHasProperty(Card card, String property, Player sourceController, Card source, - SpellAbility spellAbility) { + public static boolean cardHasProperty(Card card, String property, Player sourceController, Card source, SpellAbility spellAbility) { final Game game = card.getGame(); final Combat combat = game.getCombat(); // lki can't be null but it does return this @@ -38,13 +37,21 @@ public class CardProperty { // by name can also have color names, so needs to happen before colors. if (property.startsWith("named")) { String name = TextUtil.fastReplace(property.substring(5), ";", ","); // for some legendary cards - return card.sharesNameWith(name); + if (!card.sharesNameWith(name)) { + return false; + } } else if (property.startsWith("notnamed")) { - return !card.sharesNameWith(property.substring(8)); + if (card.sharesNameWith(property.substring(8))) { + return false; + } } else if (property.startsWith("sameName")) { - return card.sharesNameWith(source); + if (!card.sharesNameWith(source)) { + return false; + } } else if (property.equals("NamedCard")) { - return card.sharesNameWith(source.getNamedCard()); + if (!card.sharesNameWith(source.getNamedCard())) { + return false; + } } else if (property.equals("NamedByRememberedPlayer")) { if (!source.hasRemembered()) { final Card newCard = game.getCardState(source); @@ -64,23 +71,41 @@ public class CardProperty { } } } else if (property.equals("Permanent")) { - return !card.isInstant() && !card.isSorcery(); + if (card.isInstant() || card.isSorcery()) { + return false; + } } else if (property.equals("Historic")) { - return card.isHistoric(); + if (!card.isHistoric()) { + return false; + } } else if (property.startsWith("CardUID_")) {// Protection with "doesn't remove effect" - return card.getId() == Integer.parseInt(property.split("CardUID_")[1]); + if (card.getId() != Integer.parseInt(property.split("CardUID_")[1])) { + return false; + } } else if (property.equals("ChosenCard")) { - return source.hasChosenCard(card); + if (!source.hasChosenCard(card)) { + return false; + } } else if (property.equals("nonChosenCard")) { - return !source.hasChosenCard(card); + if (source.hasChosenCard(card)) { + return false; + } } else if (property.equals("DoubleFaced")) { - return card.isDoubleFaced(); + if (!card.isDoubleFaced()) { + return false; + } } else if (property.equals("Flip")) { - return card.isFlipCard(); + if (!card.isFlipCard()) { + return false; + } } else if (property.equals("Split")) { - return card.isSplitCard(); + if (!card.isSplitCard()) { + return false; + } } else if (property.equals("NotSplit")) { - return !card.isSplitCard(); + if (card.isSplitCard()) { + return false; + } } else if (property.startsWith("leftcmc") || property.startsWith("rightcmc")) { int x; int y = 0; @@ -100,17 +125,29 @@ public class CardProperty { x = AbilityUtils.calculateAmount(source, rhs, spellAbility); } - return Expressions.compare(y, property, x); + if (!Expressions.compare(y, property, x)) { + return false; + } } else if (property.startsWith("YouCtrl")) { - return controller.equals(sourceController); + if (!controller.equals(sourceController)) { + return false; + } } else if (property.startsWith("YourTeamCtrl")) { - return controller.getTeam() == sourceController.getTeam(); + if (controller.getTeam() != sourceController.getTeam()) { + return false; + } } else if (property.startsWith("YouDontCtrl")) { - return !controller.equals(sourceController); + if (controller.equals(sourceController)) { + return false; + } } else if (property.startsWith("OppCtrl")) { - return controller.getOpponents().contains(sourceController); + if (!controller.getOpponents().contains(sourceController)) { + return false; + } } else if (property.startsWith("ChosenCtrl")) { - return controller.equals(source.getChosenPlayer()); + if (!controller.equals(source.getChosenPlayer())) { + return false; + } } else if (property.startsWith("DefenderCtrl")) { if (!game.getPhaseHandler().inCombat()) { return false; @@ -119,21 +156,29 @@ public class CardProperty { if (!source.hasRemembered()) { return false; } - return combat.getDefendingPlayerRelatedTo((Card) source.getFirstRemembered()) == controller; + if (combat.getDefendingPlayerRelatedTo((Card) source.getFirstRemembered()) != controller) { + return false; + } } else { - return combat.getDefendingPlayerRelatedTo(source) == controller; + if (combat.getDefendingPlayerRelatedTo(source) != controller) { + return false; + } } } else if (property.startsWith("DefendingPlayer")) { Player p = property.endsWith("Ctrl") ? controller : card.getOwner(); if (!game.getPhaseHandler().inCombat()) { return false; } - return combat.isPlayerAttacked(p); + if (!combat.isPlayerAttacked(p)) { + return false; + } } else if (property.startsWith("EnchantedPlayer")) { Player p = property.endsWith("Ctrl") ? controller : card.getOwner(); final Object o = source.getEntityAttachedTo(); if (o instanceof Player) { - return p.equals(o); + if (!p.equals(o)) { + return false; + } } else { // source not enchanting a player return false; } @@ -141,7 +186,9 @@ public class CardProperty { Player p = property.endsWith("Ctrl") ? controller : card.getOwner(); final Object o = source.getEntityAttachedTo(); if (o instanceof Card) { - return p.equals(((Card) o).getController()); + if (!p.equals(((Card) o).getController())) { + return false; + } } else { // source not enchanting a card return false; } @@ -154,7 +201,9 @@ public class CardProperty { } } - return source.isRemembered(p); + if (!source.isRemembered(p)) { + return false; + } } else if (property.startsWith("nonRememberedPlayerCtrl")) { if (!source.hasRemembered()) { final Card newCard = game.getCardState(source); @@ -163,7 +212,9 @@ public class CardProperty { } } - return !source.isRemembered(controller); + if (source.isRemembered(controller)) { + return false; + } } else if (property.equals("TargetedPlayerCtrl")) { boolean foundTargetingSA = false; for (final SpellAbility sa : source.getCurrentState().getNonManaAbilities()) { @@ -217,15 +268,25 @@ public class CardProperty { } } } else if (property.startsWith("ActivePlayerCtrl")) { - return game.getPhaseHandler().isPlayerTurn(controller); + if (!game.getPhaseHandler().isPlayerTurn(controller)) { + return false; + } } else if (property.startsWith("NonActivePlayerCtrl")) { - return !game.getPhaseHandler().isPlayerTurn(controller); + if (game.getPhaseHandler().isPlayerTurn(controller)) { + return false; + } } else if (property.startsWith("YouOwn")) { - return card.getOwner().equals(sourceController); + if (!card.getOwner().equals(sourceController)) { + return false; + } } else if (property.startsWith("YouDontOwn")) { - return !card.getOwner().equals(sourceController); + if (card.getOwner().equals(sourceController)) { + return false; + } } else if (property.startsWith("OppOwn")) { - return card.getOwner().getOpponents().contains(sourceController); + if (!card.getOwner().getOpponents().contains(sourceController)) { + return false; + } } else if (property.equals("TargetedPlayerOwn")) { boolean foundTargetingSA = false; for (final SpellAbility sa : source.getCurrentState().getNonManaAbilities()) { @@ -262,33 +323,49 @@ public class CardProperty { final String valid = property.substring(8); if (!card.getOwner().isValid(valid, sourceController, source, spellAbility)) { final List lp = AbilityUtils.getDefinedPlayers(source, valid, spellAbility); - return lp.contains(card.getOwner()); + if (!lp.contains(card.getOwner())) { + return false; + } } } else if (property.startsWith("ControlledBy")) { final String valid = property.substring(13); if (!controller.isValid(valid, sourceController, source, spellAbility)) { final List lp = AbilityUtils.getDefinedPlayers(source, valid, spellAbility); - return lp.contains(controller); + if (!lp.contains(controller)) { + return false; + } } } else if (property.startsWith("OwnerDoesntControl")) { - return !card.getOwner().equals(controller); + if (card.getOwner().equals(controller)) { + return false; + } } else if (property.startsWith("ControllerControls")) { final String type = property.substring(18); if (type.startsWith("AtLeastAsMany")) { String realType = type.split("AtLeastAsMany")[1]; CardCollectionView cards = CardLists.getType(controller.getCardsIn(ZoneType.Battlefield), realType); CardCollectionView yours = CardLists.getType(sourceController.getCardsIn(ZoneType.Battlefield), realType); - return cards.size() >= yours.size(); + if (cards.size() < yours.size()) { + return false; + } } else { final CardCollectionView cards = controller.getCardsIn(ZoneType.Battlefield); - return !CardLists.getType(cards, type).isEmpty(); + if (CardLists.getType(cards, type).isEmpty()) { + return false; + } } } else if (property.startsWith("Other")) { - return !card.equals(source); + if (card.equals(source)) { + return false; + } } else if (property.startsWith("StrictlySelf")) { - return card.equals(source) && card.getTimestamp() == source.getTimestamp(); + if (!card.equals(source) || card.getTimestamp() != source.getTimestamp()) { + return false; + } } else if (property.startsWith("Self")) { - return card.equals(source); + if (!card.equals(source)) { + return false; + } } else if (property.startsWith("ExiledWithSource")) { if (card.getExiledWith() == null) { return false; @@ -303,21 +380,33 @@ public class CardProperty { } } - return card.getExiledWith().equals(host); + if (!card.getExiledWith().equals(host)) { + return false; + } } else if (property.equals("EncodedWithSource")) { - return card.getEncodedCards().contains(source); + if (!card.getEncodedCards().contains(source)) { + return false; + } } else if (property.equals("EffectSource")) { if (!source.isEmblem() && !source.getType().hasSubtype("Effect")) { return false; } - return card.equals(source.getEffectSource()); + if (!card.equals(source.getEffectSource())) { + return false; + } } else if (property.equals("CanBeSacrificedBy")) { - return card.canBeSacrificedBy(spellAbility); + if (!card.canBeSacrificedBy(spellAbility)) { + return false; + } } else if (property.startsWith("AttachedBy")) { - return card.hasCardAttachment(source); + if (!card.hasCardAttachment(source)) { + return false; + } } else if (property.equals("Attached")) { - return source.hasCardAttachment(card); + if (!source.hasCardAttachment(card)) { + return false; + } } else if (property.startsWith("AttachedTo")) { final String restriction = property.split("AttachedTo ")[1]; if (restriction.equals("Targeted")) { @@ -343,16 +432,24 @@ public class CardProperty { return false; } } else { - return (card.getEntityAttachedTo() != null && card.getEntityAttachedTo().isValid(restriction, sourceController, source, spellAbility)); + if ((card.getEntityAttachedTo() == null || !card.getEntityAttachedTo().isValid(restriction, sourceController, source, spellAbility))) { + return false; + } } } else if (property.equals("NameNotEnchantingEnchantedPlayer")) { Player enchantedPlayer = source.getPlayerAttachedTo(); - return enchantedPlayer != null && !enchantedPlayer.isEnchantedBy(card.getName()); + if (enchantedPlayer == null || enchantedPlayer.isEnchantedBy(card.getName())) { + return false; + } } else if (property.equals("NotAttachedTo")) { - return !source.hasCardAttachment(card); + if (source.hasCardAttachment(card)) { + return false; + } } else if (property.startsWith("EnchantedBy")) { if (property.equals("EnchantedBy")) { - return card.isEnchantedBy(source) || card.equals(source.getEntityAttachedTo()); + if (!card.isEnchantedBy(source) && !card.equals(source.getEntityAttachedTo())) { + return false; + } } else { final String restriction = property.split("EnchantedBy ")[1]; switch (restriction) { @@ -397,10 +494,14 @@ public class CardProperty { } } } else { - return !card.isEnchantedBy(source); + if (card.isEnchantedBy(source)) { + return false; + } } } else if (property.startsWith("Enchanted")) { - return source.equals(card.getEntityAttachedTo()); + if (!source.equals(card.getEntityAttachedTo())) { + return false; + } } else if (property.startsWith("CanEnchant")) { final String restriction = property.substring(10); if (restriction.equals("Remembered")) { @@ -409,7 +510,7 @@ public class CardProperty { return false; } } else if (restriction.equals("Source")) { - return source.canBeAttached(card); + if (!source.canBeAttached(card)) return false; } } else if (property.startsWith("CanBeEnchantedBy")) { if (property.substring(16).equals("Targeted")) { @@ -433,7 +534,9 @@ public class CardProperty { } } } else { - return card.canBeAttached(source); + if (!card.canBeAttached(source)) { + return false; + } } } else if (property.startsWith("EquippedBy")) { if (property.substring(10).equals("Targeted")) { @@ -448,44 +551,74 @@ public class CardProperty { } } } else if (property.substring(10).equals("Enchanted")) { - return source.getEnchantingCard() != null && - card.hasCardAttachment(source.getEnchantingCard()); + if (source.getEnchantingCard() == null || + !card.hasCardAttachment(source.getEnchantingCard())) { + return false; + } } else { - return card.hasCardAttachment(source); + if (!card.hasCardAttachment(source)) { + return false; + } } } else if (property.startsWith("FortifiedBy")) { - return card.hasCardAttachment(source); + if (!card.hasCardAttachment(source)) { + return false; + } } else if (property.startsWith("CanBeAttachedBy")) { - return card.canBeAttached(source); + if (!card.canBeAttached(source)) { + return false; + } } else if (property.startsWith("Equipped")) { - return source.hasCardAttachment(card); + if (!source.hasCardAttachment(card)) { + return false; + } } else if (property.startsWith("Fortified")) { // FIXME TODO what property has this? - return source.hasCardAttachment(card); + if (!source.hasCardAttachment(card)) { + return false; + } } else if (property.startsWith("HauntedBy")) { - return card.isHauntedBy(source); + if (!card.isHauntedBy(source)) { + return false; + } } else if (property.startsWith("notTributed")) { - return !card.isTributed(); + if (card.isTributed()) { + return false; + } } else if (property.startsWith("madness")) { - return card.isMadness(); + if (!card.isMadness()) { + return false; + } } else if (property.contains("Paired")) { if (property.contains("With")) { // PairedWith - return card.isPaired() && card.getPairedWith() == source; + if (!card.isPaired() || card.getPairedWith() != source) { + return false; + } } else if (property.startsWith("Not")) { // NotPaired - return !card.isPaired(); + if (card.isPaired()) { + return false; + } } else { // Paired - return card.isPaired(); + if (!card.isPaired()) { + return false; + } } } else if (property.startsWith("Above")) { // "Are Above" Source final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Graveyard); - return cards.indexOf(source) < cards.indexOf(card); + if (cards.indexOf(source) >= cards.indexOf(card)) { + return false; + } } else if (property.startsWith("DirectlyAbove")) { // "Are Directly Above" Source final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Graveyard); - return cards.indexOf(card) - cards.indexOf(source) == 1; + if (cards.indexOf(card) - cards.indexOf(source) != 1) { + return false; + } } else if (property.startsWith("TopGraveyardCreature")) { CardCollection cards = CardLists.filter(card.getOwner().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); Collections.reverse(cards); - return !cards.isEmpty() && card.equals(cards.get(0)); + if (cards.isEmpty() || !card.equals(cards.get(0))) { + return false; + } } else if (property.startsWith("TopGraveyard")) { final CardCollection cards = new CardCollection(card.getOwner().getCardsIn(ZoneType.Graveyard)); Collections.reverse(cards); @@ -496,18 +629,28 @@ public class CardProperty { for (int i = 0; i < num; i++) { newlist.add(cards.get(i)); } - return !cards.isEmpty() && newlist.contains(card); + if (cards.isEmpty() || !newlist.contains(card)) { + return false; + } } else { - return !cards.isEmpty() && card.equals(cards.get(0)); + if (cards.isEmpty() || !card.equals(cards.get(0))) { + return false; + } } } else if (property.startsWith("BottomGraveyard")) { final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Graveyard); - return !cards.isEmpty() && card.equals(cards.get(0)); + if (cards.isEmpty() || !card.equals(cards.get(0))) { + return false; + } } else if (property.startsWith("TopLibrary")) { final CardCollectionView cards = card.getOwner().getCardsIn(ZoneType.Library); - return !cards.isEmpty() && card.equals(cards.get(0)); + if (cards.isEmpty() || !card.equals(cards.get(0))) { + return false; + } } else if (property.startsWith("Cloned")) { - return (card.getCloneOrigin() != null) && card.getCloneOrigin().equals(source); + if ((card.getCloneOrigin() == null) || !card.getCloneOrigin().equals(source)) { + return false; + } } else if (property.startsWith("DamagedBy")) { if ((property.endsWith("Source") || property.equals("DamagedBy")) && !card.getReceivedDamageFromThisTurn().containsKey(source)) { @@ -520,16 +663,21 @@ public class CardProperty { } matched |= card.getReceivedDamageFromThisTurn().containsKey(obj); } - return matched; + if (!matched) + return false; } else if (property.endsWith("Equipped")) { final Card equipee = source.getEquipping(); - return equipee != null && card.getReceivedDamageFromThisTurn().containsKey(equipee); + if (equipee == null || !card.getReceivedDamageFromThisTurn().containsKey(equipee)) + return false; } else if (property.endsWith("Enchanted")) { final Card equipee = source.getEnchantingCard(); - return equipee != null && card.getReceivedDamageFromThisTurn().containsKey(equipee); + if (equipee == null || !card.getReceivedDamageFromThisTurn().containsKey(equipee)) + return false; } } else if (property.startsWith("Damaged")) { - return card.getDealtDamageToThisTurn().containsKey(source); + if (!card.getDealtDamageToThisTurn().containsKey(source)) { + return false; + } } else if (property.startsWith("IsTargetingSource")) { for (final SpellAbility sa : card.getCurrentState().getNonManaAbilities()) { final SpellAbility saTargeting = sa.getSATargetingCard(); @@ -544,7 +692,9 @@ public class CardProperty { return false; } else if (property.startsWith("SharesCMCWith")) { if (property.equals("SharesCMCWith")) { - return card.sharesCMCWith(source); + if (!card.sharesCMCWith(source)) { + return false; + } } else { final String restriction = property.split("SharesCMCWith ")[1]; CardCollection list = AbilityUtils.getDefinedCards(source, restriction, spellAbility); @@ -552,7 +702,9 @@ public class CardProperty { } } else if (property.startsWith("SharesColorWith")) { if (property.equals("SharesColorWith")) { - return card.sharesColorWith(source); + if (!card.sharesColorWith(source)) { + return false; + } } else { final String restriction = property.split("SharesColorWith ")[1]; if (restriction.startsWith("Remembered") || restriction.startsWith("Imprinted")) { @@ -613,7 +765,9 @@ public class CardProperty { return ColorSet.fromMask(mostProm).hasAnyColor(MagicColor.fromName(color)); } else if (property.startsWith("notSharesColorWith")) { if (property.equals("notSharesColorWith")) { - return !card.sharesColorWith(source); + if (card.sharesColorWith(source)) { + return false; + } } else { final String restriction = property.split("notSharesColorWith ")[1]; for (final Card c : sourceController.getCardsIn(ZoneType.Battlefield)) { @@ -624,7 +778,9 @@ public class CardProperty { } } else if (property.startsWith("sharesCreatureTypeWith")) { if (property.equals("sharesCreatureTypeWith")) { - return card.sharesCreatureTypeWith(source); + if (!card.sharesCreatureTypeWith(source)) { + return false; + } } else { final String restriction = property.split("sharesCreatureTypeWith ")[1]; switch (restriction) { @@ -657,7 +813,10 @@ public class CardProperty { } break; case "Equipped": - return source.isEquipping() && card.sharesCreatureTypeWith(source.getEquipping()); + if (source.isEquipping() && card.sharesCreatureTypeWith(source.getEquipping())) { + return true; + } + return false; case "Remembered": for (final Object rem : source.getRemembered()) { if (rem instanceof Card) { @@ -693,7 +852,9 @@ public class CardProperty { } } else if (property.startsWith("sharesCardTypeWith")) { if (property.equals("sharesCardTypeWith")) { - return card.sharesCardTypeWith(source); + if (!card.sharesCardTypeWith(source)) { + return false; + } } else { final String restriction = property.split("sharesCardTypeWith ")[1]; switch (restriction) { @@ -717,7 +878,10 @@ public class CardProperty { if (!(triggeringObject instanceof Card)) { return false; } - return card.sharesCardTypeWith((Card) triggeringObject); + if (card.sharesCardTypeWith((Card) triggeringObject)) { + return true; + } + return false; case "EachTopLibrary": final CardCollection cards = new CardCollection(); for (Player p : game.getPlayers()) { @@ -733,9 +897,13 @@ public class CardProperty { } } } else if (property.equals("sharesPermanentTypeWith")) { - return card.sharesPermanentTypeWith(source); + if (!card.sharesPermanentTypeWith(source)) { + return false; + } } else if (property.equals("canProduceSameManaTypeWith")) { - return card.canProduceSameManaTypeWith(source); + if (!card.canProduceSameManaTypeWith(source)) { + return false; + } } else if (property.startsWith("canProduceManaColor")) { final String color = property.split("canProduceManaColor ")[1]; for (SpellAbility ma : card.getManaAbilities()) { @@ -748,7 +916,9 @@ public class CardProperty { return !card.getManaAbilities().isEmpty(); } else if (property.startsWith("sharesNameWith")) { if (property.equals("sharesNameWith")) { - return card.sharesNameWith(source); + if (!card.sharesNameWith(source)) { + return false; + } } else { final String restriction = property.split("sharesNameWith ")[1]; if (restriction.equals("YourGraveyard")) { @@ -788,14 +958,18 @@ public class CardProperty { System.out.println("Looking at TriggeredCard but no SA?"); } else { Card triggeredCard = ((Card)spellAbility.getTriggeringObject("Card")); - return triggeredCard != null && card.sharesNameWith(triggeredCard); + if (triggeredCard != null && card.sharesNameWith(triggeredCard)) { + return true; + } } return false; } } } else if (property.startsWith("doesNotShareNameWith")) { if (property.equals("doesNotShareNameWith")) { - return !card.sharesNameWith(source); + if (card.sharesNameWith(source)) { + return false; + } } else { final String restriction = property.split("doesNotShareNameWith ")[1]; if (restriction.startsWith("Remembered") || restriction.startsWith("Imprinted")) { @@ -818,7 +992,9 @@ public class CardProperty { } } else if (property.startsWith("sharesControllerWith")) { if (property.equals("sharesControllerWith")) { - return card.sharesControllerWith(source); + if (!card.sharesControllerWith(source)) { + return false; + } } else { final String restriction = property.split("sharesControllerWith ")[1]; if (restriction.startsWith("Remembered") || restriction.startsWith("Imprinted")) { @@ -828,7 +1004,9 @@ public class CardProperty { } } else if (property.startsWith("sharesOwnerWith")) { if (property.equals("sharesOwnerWith")) { - return card.getOwner().equals(source.getOwner()); + if (!card.getOwner().equals(source.getOwner())) { + return false; + } } else { final String restriction = property.split("sharesOwnerWith ")[1]; if (restriction.equals("Remembered")) { @@ -847,7 +1025,9 @@ public class CardProperty { if (cards.size() < 2) { return false; } - else return cards.get(1) == card; + else if (cards.get(1) != card) { + return false; + } } else if (property.equals("ThisTurnCast")) { for (final Card c : CardUtil.getThisTurnCast("Card", source)) { if (card.equals(c)) { @@ -865,14 +1045,18 @@ public class CardProperty { } CardCollectionView cards = CardUtil.getThisTurnEntered(destination, origin, "Card", source); - return cards.contains(card); + if (!cards.contains(card)) { + return false; + } } else if (property.equals("DiscardedThisTurn")) { if (card.getTurnInZone() != game.getPhaseHandler().getTurn()) { return false; } CardCollectionView cards = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Hand, "Card", source); - return cards.contains(card) || card.getMadnessWithoutCast(); + if (!cards.contains(card) && !card.getMadnessWithoutCast()) { + return false; + } } else if (property.startsWith("ControlledByPlayerInTheDirection")) { final String restrictions = property.split("ControlledByPlayerInTheDirection_")[1]; final String[] res = restrictions.split("_"); @@ -888,53 +1072,93 @@ public class CardProperty { } else { p = sourceController; } - return p != null && controller.equals(game.getNextPlayerAfter(p, direction)); + if (p == null || !controller.equals(game.getNextPlayerAfter(p, direction))) { + return false; + } } else if (property.startsWith("hasKeyword")) { // "withFlash" would find Flashback cards, add this to fix Mystical Teachings - return card.hasKeyword(property.substring(10)); + if (!card.hasKeyword(property.substring(10))) { + return false; + } } else if (property.startsWith("withFlashback")) { boolean fb = card.hasKeyword(Keyword.FLASHBACK); - return fb; + if (!fb) { + return false; + } } else if (property.startsWith("with")) { // ... Card keywords if (property.startsWith("without") && card.hasStartOfUnHiddenKeyword(property.substring(7))) { return false; } - return property.startsWith("without") || card.hasStartOfUnHiddenKeyword(property.substring(4)); + if (!property.startsWith("without") && !card.hasStartOfUnHiddenKeyword(property.substring(4))) { + return false; + } } else if (property.startsWith("tapped")) { - return card.isTapped(); + if (!card.isTapped()) { + return false; + } } else if (property.startsWith("untapped")) { - return card.isUntapped(); + if (!card.isUntapped()) { + return false; + } } else if (property.startsWith("faceDown")) { - return card.isFaceDown(); + if (!card.isFaceDown()) { + return false; + } } else if (property.startsWith("faceUp")) { - return !card.isFaceDown(); + if (card.isFaceDown()) { + return false; + } } else if (property.startsWith("manifested")) { - return card.isManifested(); + if (!card.isManifested()) { + return false; + } } else if (property.startsWith("DrawnThisTurn")) { - return card.getDrawnThisTurn(); + if (!card.getDrawnThisTurn()) { + return false; + } } else if (property.startsWith("enteredBattlefieldThisTurn")) { - return card.getTurnInZone() == game.getPhaseHandler().getTurn(); + if (!(card.getTurnInZone() == game.getPhaseHandler().getTurn())) { + return false; + } } else if (property.startsWith("notEnteredBattlefieldThisTurn")) { - return card.getTurnInZone() != game.getPhaseHandler().getTurn(); + if (card.getTurnInZone() == game.getPhaseHandler().getTurn()) { + return false; + } } else if (property.startsWith("firstTurnControlled")) { - return card.isFirstTurnControlled(); + if (!card.isFirstTurnControlled()) { + return false; + } } else if (property.startsWith("notFirstTurnControlled")) { - return !card.isFirstTurnControlled(); + if (card.isFirstTurnControlled()) { + return false; + } } else if (property.startsWith("startedTheTurnUntapped")) { - return card.hasStartedTheTurnUntapped(); + if (!card.hasStartedTheTurnUntapped()) { + return false; + } } else if (property.startsWith("cameUnderControlSinceLastUpkeep")) { - return card.cameUnderControlSinceLastUpkeep(); + if (!card.cameUnderControlSinceLastUpkeep()) { + return false; + } } else if (property.equals("attackedOrBlockedSinceYourLastUpkeep")) { - return card.getDamageHistory().hasAttackedSinceLastUpkeepOf(sourceController) - || card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController); + if (!card.getDamageHistory().hasAttackedSinceLastUpkeepOf(sourceController) + && !card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController)) { + return false; + } } else if (property.equals("blockedOrBeenBlockedSinceYourLastUpkeep")) { - return card.getDamageHistory().hasBeenBlockedSinceLastUpkeepOf(sourceController) - || card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController); + if (!card.getDamageHistory().hasBeenBlockedSinceLastUpkeepOf(sourceController) + && !card.getDamageHistory().hasBlockedSinceLastUpkeepOf(sourceController)) { + return false; + } } else if (property.startsWith("dealtDamageToYouThisTurn")) { - return card.getDamageHistory().getThisTurnDamaged().contains(sourceController); + if (!card.getDamageHistory().getThisTurnDamaged().contains(sourceController)) { + return false; + } } else if (property.startsWith("dealtDamageToOppThisTurn")) { - return card.hasDealtDamageToOpponentThisTurn(); + if (!card.hasDealtDamageToOpponentThisTurn()) { + return false; + } } else if (property.startsWith("dealtCombatDamageThisTurn ") || property.startsWith("notDealtCombatDamageThisTurn ")) { final String v = property.split(" ")[1]; final List list = card.getDamageHistory().getThisTurnCombatDamaged(); @@ -945,7 +1169,9 @@ public class CardProperty { break; } } - return found != property.startsWith("not"); + if (found == property.startsWith("not")) { + return false; + } } else if (property.startsWith("dealtCombatDamageThisCombat ") || property.startsWith("notDealtCombatDamageThisCombat ")) { final String v = property.split(" ")[1]; final List list = card.getDamageHistory().getThisCombatDamaged(); @@ -956,31 +1182,53 @@ public class CardProperty { break; } } - return found != property.startsWith("not"); + if (found == property.startsWith("not")) { + return false; + } } else if (property.startsWith("controllerWasDealtCombatDamageByThisTurn")) { - return source.getDamageHistory().getThisTurnCombatDamaged().contains(controller); + if (!source.getDamageHistory().getThisTurnCombatDamaged().contains(controller)) { + return false; + } } else if (property.startsWith("controllerWasDealtDamageByThisTurn")) { - return source.getDamageHistory().getThisTurnDamaged().contains(controller); + if (!source.getDamageHistory().getThisTurnDamaged().contains(controller)) { + return false; + } } else if (property.startsWith("wasDealtDamageThisTurn")) { - return !(card.getReceivedDamageFromThisTurn().keySet()).isEmpty(); + if ((card.getReceivedDamageFromThisTurn().keySet()).isEmpty()) { + return false; + } } else if (property.startsWith("dealtDamageThisTurn")) { - return card.getTotalDamageDoneBy() != 0; + if (card.getTotalDamageDoneBy() == 0) { + return false; + } } else if (property.startsWith("attackedThisTurn")) { - return card.getDamageHistory().getCreatureAttackedThisTurn(); + if (!card.getDamageHistory().getCreatureAttackedThisTurn()) { + return false; + } } else if (property.startsWith("attackedLastTurn")) { return card.getDamageHistory().getCreatureAttackedLastTurnOf(controller); } else if (property.startsWith("blockedThisTurn")) { - return card.getDamageHistory().getCreatureBlockedThisTurn(); + if (!card.getDamageHistory().getCreatureBlockedThisTurn()) { + return false; + } } else if (property.startsWith("notExertedThisTurn")) { - return card.getExertedThisTurn() <= 0; + if (card.getExertedThisTurn() > 0) { + return false; + } } else if (property.startsWith("gotBlockedThisTurn")) { - return card.getDamageHistory().getCreatureGotBlockedThisTurn(); + if (!card.getDamageHistory().getCreatureGotBlockedThisTurn()) { + return false; + } } else if (property.startsWith("notAttackedThisTurn")) { - return !card.getDamageHistory().getCreatureAttackedThisTurn(); + if (card.getDamageHistory().getCreatureAttackedThisTurn()) { + return false; + } } else if (property.startsWith("notAttackedLastTurn")) { return !card.getDamageHistory().getCreatureAttackedLastTurnOf(controller); } else if (property.startsWith("notBlockedThisTurn")) { - return !card.getDamageHistory().getCreatureBlockedThisTurn(); + if (card.getDamageHistory().getCreatureBlockedThisTurn()) { + return false; + } } else if (property.startsWith("greatestPower")) { CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES); if (property.contains("ControlledBy")) { @@ -1031,7 +1279,9 @@ public class CardProperty { cards = CardLists.getType(cards, prop); } cards = CardLists.getCardsWithHighestCMC(cards); - return cards.contains(card); + if (!cards.contains(card)) { + return false; + } } else if (property.startsWith("greatestRememberedCMC")) { CardCollection cards = new CardCollection(); for (final Object o : source.getRemembered()) { @@ -1043,7 +1293,9 @@ public class CardProperty { return false; } cards = CardLists.getCardsWithHighestCMC(cards); - return cards.contains(card); + if (!cards.contains(card)) { + return false; + } } else if (property.startsWith("lowestRememberedCMC")) { CardCollection cards = new CardCollection(); for (final Object o : source.getRemembered()) { @@ -1055,7 +1307,9 @@ public class CardProperty { return false; } cards = CardLists.getCardsWithLowestCMC(cards); - return cards.contains(card); + if (!cards.contains(card)) { + return false; + } } else if (property.startsWith("lowestCMC")) { final CardCollectionView cards = game.getCardsIn(ZoneType.Battlefield); @@ -1068,40 +1322,74 @@ public class CardProperty { } } } else if (property.startsWith("enchanted")) { - return card.isEnchanted(); + if (!card.isEnchanted()) { + return false; + } } else if (property.startsWith("unenchanted")) { - return !card.isEnchanted(); + if (card.isEnchanted()) { + return false; + } } else if (property.startsWith("enchanting")) { - return card.isEnchanting(); + if (!card.isEnchanting()) { + return false; + } } else if (property.startsWith("equipped")) { - return card.isEquipped(); + if (!card.isEquipped()) { + return false; + } } else if (property.startsWith("unequipped")) { - return !card.isEquipped(); + if (card.isEquipped()) { + return false; + } } else if (property.startsWith("equipping")) { - return card.isEquipping(); + if (!card.isEquipping()) { + return false; + } } else if (property.startsWith("notEquipping")) { - return !card.isEquipping(); + if (card.isEquipping()) { + return false; + } } else if (property.startsWith("token")) { - return card.isToken(); + if (!card.isToken()) { + return false; + } } else if (property.startsWith("nonToken")) { - return !card.isToken(); + if (card.isToken()) { + return false; + } } else if (property.startsWith("hasXCost")) { SpellAbility sa1 = card.getFirstSpellAbility(); - return sa1 == null || sa1.isXCost(); + if (sa1 != null && !sa1.isXCost()) { + return false; + } } else if (property.startsWith("suspended")) { - return card.hasSuspend(); + if (!card.hasSuspend()) { + return false; + } } else if (property.startsWith("delved")) { - return source.getDelved().contains(card); + if (!source.getDelved().contains(card)) { + return false; + } } else if (property.startsWith("convoked")) { - return source.getConvoked().contains(card); + if (!source.getConvoked().contains(card)) { + return false; + } } else if (property.startsWith("exploited")) { - return source.getExploited().contains(card); + if (!source.getExploited().contains(card)) { + return false; + } } else if (property.startsWith("unequalPT")) { - return card.getNetPower() != card.getNetToughness(); + if (card.getNetPower() == card.getNetToughness()) { + return false; + } } else if (property.equals("powerGTtoughness")) { - return card.getNetPower() > card.getNetToughness(); + if (card.getNetPower() <= card.getNetToughness()) { + return false; + } } else if (property.equals("powerLTtoughness")) { - return card.getNetPower() < card.getNetToughness(); + if (card.getNetPower() >= card.getNetToughness()) { + return false; + } } else if (property.startsWith("power") || property.startsWith("toughness") || property.startsWith("cmc") || property.startsWith("totalPT")) { int x; @@ -1127,7 +1415,9 @@ public class CardProperty { x = AbilityUtils.calculateAmount(source, rhs, spellAbility); } - return Expressions.compare(y, property, x); + if (!Expressions.compare(y, property, x)) { + return false; + } } // syntax example: countersGE9 P1P1 or countersLT12TIME (greater number @@ -1163,7 +1453,9 @@ public class CardProperty { final int actualnumber = card.getCounters(CounterType.getType(counterType)); - return Expressions.compare(actualnumber, comparator, number); + if (!Expressions.compare(actualnumber, comparator, number)) { + return false; + } } // These predicated refer to ongoing combat. If no combat happens, they'll return false (meaning not attacking/blocking ATM) else if (property.startsWith("attacking")) { @@ -1173,18 +1465,26 @@ public class CardProperty { if (property.equals("attackingYou")) return combat.isAttacking(card, sourceController); if (property.equals("attackingYouOrYourPW")) { Player defender = combat.getDefenderPlayerByAttacker(card); - return sourceController.equals(defender); + if (!sourceController.equals(defender)) { + return false; + } } } else if (property.startsWith("notattacking")) { return null == combat || !combat.isAttacking(card); } else if (property.equals("attackedThisCombat")) { - return null != combat && card.getDamageHistory().getCreatureAttackedThisCombat(); + if (null == combat || !card.getDamageHistory().getCreatureAttackedThisCombat()) { + return false; + } } else if (property.equals("blockedThisCombat")) { - return null != combat && card.getDamageHistory().getCreatureBlockedThisCombat(); + if (null == combat || !card.getDamageHistory().getCreatureBlockedThisCombat()) { + return false; + } } else if (property.equals("attackedBySourceThisCombat")) { if (null == combat) return false; final GameEntity defender = combat.getDefenderByAttacker(source); - return !(defender instanceof Card) || card.equals(defender); + if (defender instanceof Card && !card.equals(defender)) { + return false; + } } else if (property.startsWith("blocking")) { if (null == combat) return false; String what = property.substring("blocking".length()); @@ -1211,7 +1511,9 @@ public class CardProperty { CardCollection sourceBlocking = new CardCollection(combat.getAttackersBlockedBy(source)); CardCollection thisBlocking = new CardCollection(combat.getAttackersBlockedBy(card)); - return !Collections.disjoint(sourceBlocking, thisBlocking); + if (Collections.disjoint(sourceBlocking, thisBlocking)) { + return false; + } } else if (property.startsWith("notblocking")) { return null == combat || !combat.isBlocking(card); } @@ -1282,27 +1584,35 @@ public class CardProperty { } return false; } else if (property.startsWith("unblocked")) { - return combat != null && combat.isUnblocked(card); + if (combat == null || !combat.isUnblocked(card)) { + return false; + } } else if (property.equals("attackersBandedWith")) { if (card.equals(source)) { // You don't band with yourself return false; } AttackingBand band = combat == null ? null : combat.getBandOfAttacker(source); - return band != null && band.getAttackers().contains(card); + if (band == null || !band.getAttackers().contains(card)) { + return false; + } } else if (property.startsWith("kicked")) { if (property.equals("kicked")) { - return card.getKickerMagnitude() != 0; + if (card.getKickerMagnitude() == 0) { + return false; + } } else { String s = property.split("kicked ")[1]; if ("1".equals(s) && !card.isOptionalCostPaid(OptionalCost.Kicker1)) return false; - return !"2".equals(s) || card.isOptionalCostPaid(OptionalCost.Kicker2); + if ("2".equals(s) && !card.isOptionalCostPaid(OptionalCost.Kicker2)) return false; } } else if (property.startsWith("notkicked")) { - return card.getKickerMagnitude() <= 0; + if (card.getKickerMagnitude() > 0) { + return false; + } } else if (property.startsWith("pseudokicked")) { if (property.equals("pseudokicked")) { - return card.isOptionalCostPaid(OptionalCost.Generic); + if (!card.isOptionalCostPaid(OptionalCost.Generic)) return false; } } else if (property.startsWith("surged")) { if (card.getCastSA() == null) { @@ -1330,19 +1640,33 @@ public class CardProperty { } return card.getCastSA().isSpectacle(); } else if (property.equals("HasDevoured")) { - return !card.getDevouredCards().isEmpty(); + if (card.getDevouredCards().isEmpty()) { + return false; + } } else if (property.equals("HasNotDevoured")) { - return card.getDevouredCards().isEmpty(); + if (!card.getDevouredCards().isEmpty()) { + return false; + } } else if (property.equals("IsMonstrous")) { - return card.isMonstrous(); + if (!card.isMonstrous()) { + return false; + } } else if (property.equals("IsNotMonstrous")) { - return !card.isMonstrous(); + if (card.isMonstrous()) { + return false; + } } else if (property.equals("IsUnearthed")) { - return card.isUnearthed(); + if (!card.isUnearthed()) { + return false; + } } else if (property.equals("IsRenowned")) { - return card.isRenowned(); + if (!card.isRenowned()) { + return false; + } } else if (property.equals("IsNotRenowned")) { - return !card.isRenowned(); + if (card.isRenowned()) { + return false; + } } else if (property.startsWith("RememberMap")) { System.out.println(source.getRememberMap()); for (SpellAbility sa : source.getSpellAbilities()) { @@ -1357,61 +1681,95 @@ public class CardProperty { } return false; } else if (property.equals("IsRemembered")) { - return source.isRemembered(card); + if (!source.isRemembered(card)) { + return false; + } } else if (property.equals("IsNotRemembered")) { - return !source.isRemembered(card); + if (source.isRemembered(card)) { + return false; + } } else if (property.equals("IsImprinted")) { - return source.hasImprintedCard(card); + if (!source.hasImprintedCard(card)) { + return false; + } } else if (property.equals("IsNotImprinted")) { - return !source.hasImprintedCard(card); + if (source.hasImprintedCard(card)) { + return false; + } } else if (property.equals("NoAbilities")) { - return (card.getAbilityText().trim().equals("") || card.isFaceDown()) && (card.getUnhiddenKeywords().isEmpty()); + if (!((card.getAbilityText().trim().equals("") || card.isFaceDown()) && (card.getUnhiddenKeywords().isEmpty()))) { + return false; + } } else if (property.equals("HasCounters")) { - return card.hasCounters(); + if (!card.hasCounters()) { + return false; + } } else if (property.equals("NoCounters")) { - return !card.hasCounters(); + if (card.hasCounters()) { + return false; + } } else if (property.startsWith("CastSa")) { SpellAbility castSA = card.getCastSA(); if (castSA == null) { return false; } String v = property.substring(7); - return castSA.isValid(v, sourceController, source, spellAbility); + if (!castSA.isValid(v, sourceController, source, spellAbility)) { + return false; + } } else if (property.equals("wasCast")) { - return null != card.getCastFrom(); + if (null == card.getCastFrom()) { + return false; + } } else if (property.equals("wasNotCast")) { - return null == card.getCastFrom(); + if (null != card.getCastFrom()) { + return false; + } } else if (property.startsWith("wasCastFrom")) { // How are we getting in here with a comma? final String strZone = property.split(",")[0].substring(11); final ZoneType realZone = ZoneType.smartValueOf(strZone); - return realZone == card.getCastFrom(); + if (realZone != card.getCastFrom()) { + return false; + } } else if (property.startsWith("wasNotCastFrom")) { final String strZone = property.substring(14); final ZoneType realZone = ZoneType.smartValueOf(strZone); - return realZone != card.getCastFrom(); + if (realZone == card.getCastFrom()) { + return false; + } } else if (property.startsWith("set")) { final String setCode = property.substring(3, 6); - return card.getSetCode().equals(setCode); + if (!card.getSetCode().equals(setCode)) { + return false; + } } else if (property.startsWith("inZone")) { final String strZone = property.substring(6); final ZoneType realZone = ZoneType.smartValueOf(strZone); // lki last zone does fall back to this zone final Zone lkiZone = lki.getLastKnownZone(); - return lkiZone != null && lkiZone.is(realZone); + if (lkiZone == null || !lkiZone.is(realZone)) { + return false; + } } else if (property.startsWith("inRealZone")) { final String strZone = property.substring(10); final ZoneType realZone = ZoneType.smartValueOf(strZone); - return card.isInZone(realZone); + if (!card.isInZone(realZone)) { + return false; + } } else if (property.equals("IsCommander")) { - return card.isCommander(); + if (!card.isCommander()) { + return false; + } } else { // StringType done in CardState - return card.getCurrentState().hasProperty(property, sourceController, source, spellAbility); + if (!card.getCurrentState().hasProperty(property, sourceController, source, spellAbility)) { + return false; + } } return true; } -} +} \ No newline at end of file diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 2be333bc7c5..6afce5fb824 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -79,7 +79,7 @@ public class Forge implements ApplicationListener { to prevent rendering issue when you try to restart the app again (seems it doesnt dispose correctly...?!?) */ - Gdx.input.setCatchBackKey(true); + Gdx.input.setCatchKey(Keys.BACK, true); destroyThis = true; //Prevent back() ForgePreferences prefs = new ForgePreferences(); @@ -126,8 +126,7 @@ public class Forge implements ApplicationListener { SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music destroyThis = false; //Allow back() - Gdx.input.setCatchBackKey(true); - Gdx.input.setCatchMenuKey(true); + Gdx.input.setCatchKey(Keys.MENU, true); openScreen(HomeScreen.instance); splashScreen = null; diff --git a/forge-gui/src/main/java/forge/download/GuiDownloadService.java b/forge-gui/src/main/java/forge/download/GuiDownloadService.java index 88f39d77b95..8b7187332a0 100644 --- a/forge-gui/src/main/java/forge/download/GuiDownloadService.java +++ b/forge-gui/src/main/java/forge/download/GuiDownloadService.java @@ -22,6 +22,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.InetSocketAddress; @@ -29,6 +30,7 @@ import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; @@ -265,7 +267,9 @@ public abstract class GuiDownloadService implements Runnable { cardSkipped = true; //assume skipped unless saved successfully String url = kv.getValue(); //decode URL Key - String decodedKey = URLDecoder.decode(kv.getKey()); + String decodedKey = ""; + try { decodedKey = URLDecoder.decode(kv.getKey(), StandardCharsets.UTF_8.toString()); } + catch (UnsupportedEncodingException e) { Log.error("UTF-8 is unknown", e); } final File fileDest = new File(decodedKey); final String filePath = fileDest.getPath(); final String subLastIndex = filePath.contains("pics") ? "\\pics\\" : "\\db\\"; From 51ea20b1dfe5b3092994b391b716c3c01c785575 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 4 Sep 2019 02:15:13 +0800 Subject: [PATCH 4/5] Refactor Dynamic Planechase BG --- .../src/forge/assets/FSkinTexture.java | 175 ++-- .../src/forge/screens/match/MatchScreen.java | 814 +----------------- 2 files changed, 120 insertions(+), 869 deletions(-) diff --git a/forge-gui-mobile/src/forge/assets/FSkinTexture.java b/forge-gui-mobile/src/forge/assets/FSkinTexture.java index 1e5689ea45d..772d897cb24 100644 --- a/forge-gui-mobile/src/forge/assets/FSkinTexture.java +++ b/forge-gui-mobile/src/forge/assets/FSkinTexture.java @@ -7,94 +7,99 @@ import com.badlogic.gdx.graphics.Texture.TextureWrap; import forge.Graphics; import forge.properties.ForgeConstants; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public enum FSkinTexture implements FImage { BG_TEXTURE(ForgeConstants.TEXTURE_BG_FILE, true, false), BG_MATCH(ForgeConstants.MATCH_BG_FILE, false, false), BG_SPACE(ForgeConstants.SPACE_BG_FILE, false, false), BG_CHAOS_WHEEL(ForgeConstants.CHAOS_WHEEL_IMG_FILE, false, false), - BG_PLANE1(ForgeConstants.BG_1, false, true), - BG_PLANE2(ForgeConstants.BG_2, false, true), - BG_PLANE3(ForgeConstants.BG_3, false, true), - BG_PLANE4(ForgeConstants.BG_4, false, true), - BG_PLANE5(ForgeConstants.BG_5, false, true), - BG_PLANE6(ForgeConstants.BG_6, false, true), - BG_PLANE7(ForgeConstants.BG_7, false, true), - BG_PLANE8(ForgeConstants.BG_8, false, true), - BG_PLANE9(ForgeConstants.BG_9, false, true), - BG_PLANE10(ForgeConstants.BG_10, false, true), - BG_PLANE11(ForgeConstants.BG_11, false, true), - BG_PLANE12(ForgeConstants.BG_12, false, true), - BG_PLANE13(ForgeConstants.BG_13, false, true), - BG_PLANE14(ForgeConstants.BG_14, false, true), - BG_PLANE15(ForgeConstants.BG_15, false, true), - BG_PLANE16(ForgeConstants.BG_16, false, true), - BG_PLANE17(ForgeConstants.BG_17, false, true), - BG_PLANE18(ForgeConstants.BG_18, false, true), - BG_PLANE19(ForgeConstants.BG_19, false, true), - BG_PLANE20(ForgeConstants.BG_20, false, true), - BG_PLANE21(ForgeConstants.BG_21, false, true), - BG_PLANE22(ForgeConstants.BG_22, false, true), - BG_PLANE23(ForgeConstants.BG_23, false, true), - BG_PLANE24(ForgeConstants.BG_24, false, true), - BG_PLANE25(ForgeConstants.BG_25, false, true), - BG_PLANE26(ForgeConstants.BG_26, false, true), - BG_PLANE27(ForgeConstants.BG_27, false, true), - BG_PLANE28(ForgeConstants.BG_28, false, true), - BG_PLANE29(ForgeConstants.BG_29, false, true), - BG_PLANE30(ForgeConstants.BG_30, false, true), - BG_PLANE31(ForgeConstants.BG_31, false, true), - BG_PLANE32(ForgeConstants.BG_32, false, true), - BG_PLANE33(ForgeConstants.BG_33, false, true), - BG_PLANE34(ForgeConstants.BG_34, false, true), - BG_PLANE35(ForgeConstants.BG_35, false, true), - BG_PLANE36(ForgeConstants.BG_36, false, true), - BG_PLANE37(ForgeConstants.BG_37, false, true), - BG_PLANE38(ForgeConstants.BG_38, false, true), - BG_PLANE39(ForgeConstants.BG_39, false, true), - BG_PLANE40(ForgeConstants.BG_40, false, true), - BG_PLANE41(ForgeConstants.BG_41, false, true), - BG_PLANE42(ForgeConstants.BG_42, false, true), - BG_PLANE43(ForgeConstants.BG_43, false, true), - BG_PLANE44(ForgeConstants.BG_44, false, true), - BG_PLANE45(ForgeConstants.BG_45, false, true), - BG_PLANE46(ForgeConstants.BG_46, false, true), - BG_PLANE47(ForgeConstants.BG_47, false, true), - BG_PLANE48(ForgeConstants.BG_48, false, true), - BG_PLANE49(ForgeConstants.BG_49, false, true), - BG_PLANE50(ForgeConstants.BG_50, false, true), - BG_PLANE51(ForgeConstants.BG_51, false, true), - BG_PLANE52(ForgeConstants.BG_52, false, true), - BG_PLANE53(ForgeConstants.BG_53, false, true), - BG_PLANE54(ForgeConstants.BG_54, false, true), - BG_PLANE55(ForgeConstants.BG_55, false, true), - BG_PLANE56(ForgeConstants.BG_56, false, true), - BG_PLANE57(ForgeConstants.BG_57, false, true), - BG_PLANE58(ForgeConstants.BG_58, false, true), - BG_PLANE59(ForgeConstants.BG_59, false, true), - BG_PLANE60(ForgeConstants.BG_60, false, true), - BG_PLANE61(ForgeConstants.BG_61, false, true), - BG_PLANE62(ForgeConstants.BG_62, false, true), - BG_PLANE63(ForgeConstants.BG_63, false, true), - BG_PLANE64(ForgeConstants.BG_64, false, true), - BG_PLANE65(ForgeConstants.BG_65, false, true), - BG_PLANE66(ForgeConstants.BG_66, false, true), - BG_PLANE67(ForgeConstants.BG_67, false, true), - BG_PLANE68(ForgeConstants.BG_68, false, true), - BG_PLANE69(ForgeConstants.BG_69, false, true), - BG_PLANE70(ForgeConstants.BG_70, false, true), - BG_PLANE71(ForgeConstants.BG_71, false, true), - BG_PLANE72(ForgeConstants.BG_72, false, true), - BG_PLANE73(ForgeConstants.BG_73, false, true), - BG_PLANE74(ForgeConstants.BG_74, false, true), - BG_PLANE75(ForgeConstants.BG_75, false, true), - BG_PLANE76(ForgeConstants.BG_76, false, true), - BG_PLANE77(ForgeConstants.BG_77, false, true), - BG_PLANE78(ForgeConstants.BG_78, false, true); + Academy_at_Tolaria_West(ForgeConstants.BG_1, false, true), + Agyrem(ForgeConstants.BG_2, false, true), + Akoum(ForgeConstants.BG_3, false, true), + Aretopolis(ForgeConstants.BG_4, false, true), + Astral_Arena(ForgeConstants.BG_5, false, true), + Bant(ForgeConstants.BG_6, false, true), + Bloodhill_Bastion(ForgeConstants.BG_7, false, true), + Cliffside_Market(ForgeConstants.BG_8, false, true), + Edge_of_Malacol(ForgeConstants.BG_9, false, true), + Eloren_Wilds(ForgeConstants.BG_10, false, true), + Feeding_Grounds(ForgeConstants.BG_11, false, true), + Fields_of_Summer(ForgeConstants.BG_12, false, true), + Furnace_Layer(ForgeConstants.BG_13, false, true), + Gavony(ForgeConstants.BG_14, false, true), + Glen_Elendra(ForgeConstants.BG_15, false, true), + Glimmervoid_Basin(ForgeConstants.BG_16, false, true), + Goldmeadow(ForgeConstants.BG_17, false, true), + Grand_Ossuary(ForgeConstants.BG_18, false, true), + Grixis(ForgeConstants.BG_19, false, true), + Grove_of_the_Dreampods(ForgeConstants.BG_20, false, true), + Hedron_Fields_of_Agadeem(ForgeConstants.BG_21, false, true), + Immersturm(ForgeConstants.BG_22, false, true), + Isle_of_Vesuva(ForgeConstants.BG_23, false, true), + Izzet_Steam_Maze(ForgeConstants.BG_24, false, true), + Jund(ForgeConstants.BG_25, false, true), + Kessig(ForgeConstants.BG_26, false, true), + Kharasha_Foothills(ForgeConstants.BG_27, false, true), + Kilnspire_District(ForgeConstants.BG_28, false, true), + Krosa(ForgeConstants.BG_29, false, true), + Lair_of_the_Ashen_Idol(ForgeConstants.BG_30, false, true), + Lethe_Lake(ForgeConstants.BG_31, false, true), + Llanowar(ForgeConstants.BG_32, false, true), + Minamo(ForgeConstants.BG_33, false, true), + Mount_Keralia(ForgeConstants.BG_34, false, true), + Murasa(ForgeConstants.BG_35, false, true), + Naar_Isle(ForgeConstants.BG_36, false, true), + Naya(ForgeConstants.BG_37, false, true), + Nephalia(ForgeConstants.BG_38, false, true), + Norns_Dominion(ForgeConstants.BG_39, false, true), + Onakke_Catacomb(ForgeConstants.BG_40, false, true), + Orochi_Colony(ForgeConstants.BG_41, false, true), + Orzhova(ForgeConstants.BG_42, false, true), + Otaria(ForgeConstants.BG_43, false, true), + Panopticon(ForgeConstants.BG_44, false, true), + Pools_of_Becoming(ForgeConstants.BG_45, false, true), + Prahv(ForgeConstants.BG_46, false, true), + Quicksilver_Sea(ForgeConstants.BG_47, false, true), + Ravens_Run(ForgeConstants.BG_48, false, true), + Sanctum_of_Serra(ForgeConstants.BG_49, false, true), + Sea_of_Sand(ForgeConstants.BG_50, false, true), + Selesnya_Loft_Gardens(ForgeConstants.BG_51, false, true), + Shiv(ForgeConstants.BG_52, false, true), + Skybreen(ForgeConstants.BG_53, false, true), + Sokenzan(ForgeConstants.BG_54, false, true), + Stairs_to_Infinity(ForgeConstants.BG_55, false, true), + Stensia(ForgeConstants.BG_56, false, true), + Stronghold_Furnace(ForgeConstants.BG_57, false, true), + Takenuma(ForgeConstants.BG_58, false, true), + Tazeem(ForgeConstants.BG_59, false, true), + The_Aether_Flues(ForgeConstants.BG_60, false, true), + The_Dark_Barony(ForgeConstants.BG_61, false, true), + The_Eon_Fog(ForgeConstants.BG_62, false, true), + The_Fourth_Sphere(ForgeConstants.BG_63, false, true), + The_Great_Forest(ForgeConstants.BG_64, false, true), + The_Hippodrome(ForgeConstants.BG_65, false, true), + The_Maelstrom(ForgeConstants.BG_66, false, true), + The_Zephyr_Maze(ForgeConstants.BG_67, false, true), + Trail_of_the_MageRings(ForgeConstants.BG_68, false, true), + Truga_Jungle(ForgeConstants.BG_69, false, true), + Turri_Island(ForgeConstants.BG_70, false, true), + Undercity_Reaches(ForgeConstants.BG_71, false, true), + Velis_Vel(ForgeConstants.BG_72, false, true), + Windriddle_Palaces(ForgeConstants.BG_73, false, true), + Tember_City(ForgeConstants.BG_74, false, true), + Celestine_Reef(ForgeConstants.BG_75, false, true), + Horizon_Boughs(ForgeConstants.BG_76, false, true), + Mirrored_Depths(ForgeConstants.BG_77, false, true), + Talon_Gates(ForgeConstants.BG_78, false, true); private final String filename; private final boolean repeat; private Texture texture; private final boolean isPlane; + private static List PlanesValue; FSkinTexture(String filename0, boolean repeat0, boolean isPlane0) { filename = filename0; @@ -102,6 +107,20 @@ public enum FSkinTexture implements FImage { isPlane = isPlane0; } + static { + PlanesValue = new ArrayList<>(); + for (FSkinTexture PlanesEnum : FSkinTexture.values()) { + PlanesValue.add(PlanesEnum.filename + .replace(".jpg", "") + .replace("'", "") + .replace("-", "")); + } + } + + public static List getValues() { + return Collections.unmodifiableList(PlanesValue); + } + public void load() { FileHandle preferredFile = isPlane ? FSkin.getCachePlanechaseFile(filename) : FSkin.getSkinFile(filename); if (preferredFile.exists()) { diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index 20c46b0c33a..3b86b71cda6 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -661,797 +661,29 @@ public class MatchScreen extends FScreen { float planeFullWidth; float scaledPlaneHeight; float planeHeight = midField + bottomPlayerPanel.getField().getHeight() - y; - switch (planeName) { - case "Academy at Tolaria West": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE1.getWidth() / FSkinTexture.BG_PLANE1.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE1, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Agyrem": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE2.getWidth() / FSkinTexture.BG_PLANE2.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE2, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Akoum": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE3.getWidth() / FSkinTexture.BG_PLANE3.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE3, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Aretopolis": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE4.getWidth() / FSkinTexture.BG_PLANE4.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE4, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Astral Arena": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE5.getWidth() / FSkinTexture.BG_PLANE5.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE5, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Bant": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE6.getWidth() / FSkinTexture.BG_PLANE6.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE6, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Bloodhill Bastion": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE7.getWidth() / FSkinTexture.BG_PLANE7.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE7, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Cliffside Market": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE8.getWidth() / FSkinTexture.BG_PLANE8.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE8, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Edge of Malacol": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE9.getWidth() / FSkinTexture.BG_PLANE9.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE9, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Eloren Wilds": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE10.getWidth() / FSkinTexture.BG_PLANE10.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE10, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Feeding Grounds": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE11.getWidth() / FSkinTexture.BG_PLANE11.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE11, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Fields of Summer": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE12.getWidth() / FSkinTexture.BG_PLANE12.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE12, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Furnace Layer": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE13.getWidth() / FSkinTexture.BG_PLANE13.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE13, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Gavony": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE14.getWidth() / FSkinTexture.BG_PLANE14.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE14, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Glen Elendra": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE15.getWidth() / FSkinTexture.BG_PLANE15.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE15, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Glimmervoid Basin": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE16.getWidth() / FSkinTexture.BG_PLANE16.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE16, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Goldmeadow": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE17.getWidth() / FSkinTexture.BG_PLANE17.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE17, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Grand Ossuary": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE18.getWidth() / FSkinTexture.BG_PLANE18.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE18, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Grixis": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE19.getWidth() / FSkinTexture.BG_PLANE19.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE19, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Grove of the Dreampods": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE20.getWidth() / FSkinTexture.BG_PLANE20.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE20, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Hedron Fields of Agadeem": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE21.getWidth() / FSkinTexture.BG_PLANE21.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE21, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Immersturm": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE22.getWidth() / FSkinTexture.BG_PLANE22.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE22, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Isle of Vesuva": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE23.getWidth() / FSkinTexture.BG_PLANE23.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE23, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Izzet Steam Maze": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE24.getWidth() / FSkinTexture.BG_PLANE24.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE24, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Jund": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE25.getWidth() / FSkinTexture.BG_PLANE25.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE25, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Kessig": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE26.getWidth() / FSkinTexture.BG_PLANE26.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE26, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Kharasha Foothills": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE27.getWidth() / FSkinTexture.BG_PLANE27.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE27, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Kilnspire District": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE28.getWidth() / FSkinTexture.BG_PLANE28.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE28, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Krosa": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE29.getWidth() / FSkinTexture.BG_PLANE29.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE29, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Lair of the Ashen Idol": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE30.getWidth() / FSkinTexture.BG_PLANE30.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE30, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Lethe Lake": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE31.getWidth() / FSkinTexture.BG_PLANE31.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE31, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Llanowar": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE32.getWidth() / FSkinTexture.BG_PLANE32.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE32, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Minamo": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE33.getWidth() / FSkinTexture.BG_PLANE33.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE33, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Mount Keralia": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE34.getWidth() / FSkinTexture.BG_PLANE34.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE34, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Murasa": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE35.getWidth() / FSkinTexture.BG_PLANE35.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE35, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Naar Isle": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE36.getWidth() / FSkinTexture.BG_PLANE36.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE36, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Naya": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE37.getWidth() / FSkinTexture.BG_PLANE37.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE37, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Nephalia": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE38.getWidth() / FSkinTexture.BG_PLANE38.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE38, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Norn's Dominion": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE39.getWidth() / FSkinTexture.BG_PLANE39.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE39, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Onakke Catacomb": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE40.getWidth() / FSkinTexture.BG_PLANE40.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE40, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Orochi Colony": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE41.getWidth() / FSkinTexture.BG_PLANE41.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE41, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Orzhova": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE42.getWidth() / FSkinTexture.BG_PLANE42.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE42, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Otaria": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE43.getWidth() / FSkinTexture.BG_PLANE43.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE43, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Panopticon": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE44.getWidth() / FSkinTexture.BG_PLANE44.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE44, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Pools of Becoming": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE45.getWidth() / FSkinTexture.BG_PLANE45.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE45, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Prahv": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE46.getWidth() / FSkinTexture.BG_PLANE46.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE46, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Quicksilver Sea": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE47.getWidth() / FSkinTexture.BG_PLANE47.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE47, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Raven's Run": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE48.getWidth() / FSkinTexture.BG_PLANE48.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE48, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Sanctum of Serra": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE49.getWidth() / FSkinTexture.BG_PLANE49.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE49, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Sea of Sand": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE50.getWidth() / FSkinTexture.BG_PLANE50.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE50, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Selesnya Loft Gardens": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE51.getWidth() / FSkinTexture.BG_PLANE51.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE51, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Shiv": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE52.getWidth() / FSkinTexture.BG_PLANE52.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE52, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Skybreen": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE53.getWidth() / FSkinTexture.BG_PLANE53.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE53, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Sokenzan": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE54.getWidth() / FSkinTexture.BG_PLANE54.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE54, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Stairs to Infinity": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE55.getWidth() / FSkinTexture.BG_PLANE55.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE55, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Stensia": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE56.getWidth() / FSkinTexture.BG_PLANE56.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE56, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Stronghold Furnace": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE57.getWidth() / FSkinTexture.BG_PLANE57.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE57, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Takenuma": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE58.getWidth() / FSkinTexture.BG_PLANE58.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE58, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Tazeem": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE59.getWidth() / FSkinTexture.BG_PLANE59.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE59, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Aether Flues": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE60.getWidth() / FSkinTexture.BG_PLANE60.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE60, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Dark Barony": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE61.getWidth() / FSkinTexture.BG_PLANE61.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE61, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Eon Fog": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE62.getWidth() / FSkinTexture.BG_PLANE62.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE62, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Fourth Sphere": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE63.getWidth() / FSkinTexture.BG_PLANE63.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE63, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Great Forest": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE64.getWidth() / FSkinTexture.BG_PLANE64.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE64, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Hippodrome": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE65.getWidth() / FSkinTexture.BG_PLANE65.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE65, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Maelstrom": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE66.getWidth() / FSkinTexture.BG_PLANE66.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE66, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "The Zephyr Maze": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE67.getWidth() / FSkinTexture.BG_PLANE67.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE67, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Trail of the Mage-Rings": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE68.getWidth() / FSkinTexture.BG_PLANE68.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE68, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Truga Jungle": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE69.getWidth() / FSkinTexture.BG_PLANE69.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE69, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Turri Island": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE70.getWidth() / FSkinTexture.BG_PLANE70.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE70, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Undercity Reaches": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE71.getWidth() / FSkinTexture.BG_PLANE71.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE71, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Velis Vel": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE72.getWidth() / FSkinTexture.BG_PLANE72.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE72, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Windriddle Palaces": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE73.getWidth() / FSkinTexture.BG_PLANE73.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE73, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Tember City": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE74.getWidth() / FSkinTexture.BG_PLANE74.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE74, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Celestine Reef": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE75.getWidth() / FSkinTexture.BG_PLANE75.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE75, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Horizon Boughs": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE76.getWidth() / FSkinTexture.BG_PLANE76.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE76, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Mirrored Depths": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE77.getWidth() / FSkinTexture.BG_PLANE77.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE77, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - case "Talon Gates": { - planeFullWidth = planeHeight * FSkinTexture.BG_PLANE78.getWidth() / FSkinTexture.BG_PLANE78.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_PLANE78, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - break; - - default: { - planeFullWidth = planeHeight * FSkinTexture.BG_MATCH.getWidth() / FSkinTexture.BG_MATCH.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_MATCH, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight); - } + String imageName = planeName + .replace(" ", "_") + .replace("'", "") + .replace("-", ""); + if (FSkinTexture.getValues().contains(imageName)) + { + planeFullWidth = planeHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight(); + if (planeFullWidth < w) { + scaledPlaneHeight = w * (planeHeight / planeFullWidth); + planeFullWidth = w; + planeHeight = scaledPlaneHeight; + } + g.drawImage(FSkinTexture.valueOf(imageName), x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); + } + else + { + planeFullWidth = planeHeight * FSkinTexture.BG_MATCH.getWidth() / FSkinTexture.BG_MATCH.getHeight(); + if (planeFullWidth < w) { + scaledPlaneHeight = w * (planeHeight / planeFullWidth); + planeFullWidth = w; + planeHeight = scaledPlaneHeight; + } + g.drawImage(FSkinTexture.BG_MATCH, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight); } } } From 5876ee822066bcd6f0f383b54b419cf80b39181b Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 4 Sep 2019 12:23:36 +0800 Subject: [PATCH 5/5] Removed redundant code --- .../src/forge/screens/match/MatchScreen.java | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index 3b86b71cda6..c0fdfdc67ec 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -505,14 +505,25 @@ public class MatchScreen extends FScreen { float x = topPlayerPanel.getField().getLeft(); float y = midField - topPlayerPanel.getField().getHeight(); float w = getWidth() - x; - + float bgFullWidth, scaledbgHeight; + float bgHeight = midField + bottomPlayerPanel.getField().getHeight() - y; if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG) - && hasActivePlane()) - setPlanarBG(g, getPlaneName(), x, y, w, midField); + && hasActivePlane()) { + String imageName = getPlaneName() + .replace(" ", "_") + .replace("'", "") + .replace("-", ""); + if (FSkinTexture.getValues().contains(imageName)) { + bgFullWidth = bgHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight(); + if (bgFullWidth < w) { + scaledbgHeight = w * (bgHeight / bgFullWidth); + bgFullWidth = w; + bgHeight = scaledbgHeight; + } + g.drawImage(FSkinTexture.valueOf(imageName), x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, true); + } + } else { - float bgFullWidth; - float scaledbgHeight; - float bgHeight = midField + bottomPlayerPanel.getField().getHeight() - y; bgFullWidth = bgHeight * FSkinTexture.BG_MATCH.getWidth() / FSkinTexture.BG_MATCH.getHeight(); if (bgFullWidth < w) { scaledbgHeight = w * (bgHeight / bgFullWidth); @@ -657,34 +668,5 @@ public class MatchScreen extends FScreen { } return false; } - private void setPlanarBG(Graphics g, String planeName, float x, float y, float w, float midField ){ - float planeFullWidth; - float scaledPlaneHeight; - float planeHeight = midField + bottomPlayerPanel.getField().getHeight() - y; - String imageName = planeName - .replace(" ", "_") - .replace("'", "") - .replace("-", ""); - if (FSkinTexture.getValues().contains(imageName)) - { - planeFullWidth = planeHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.valueOf(imageName), x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true); - } - else - { - planeFullWidth = planeHeight * FSkinTexture.BG_MATCH.getWidth() / FSkinTexture.BG_MATCH.getHeight(); - if (planeFullWidth < w) { - scaledPlaneHeight = w * (planeHeight / planeFullWidth); - planeFullWidth = w; - planeHeight = scaledPlaneHeight; - } - g.drawImage(FSkinTexture.BG_MATCH, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight); - } - } } }