From c16fb756683fcbdee1cc562bb6f81051e9cfe924 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 22 Aug 2020 12:52:49 +0200 Subject: [PATCH] * replaces all [source} by {this}. ATTENTION !!!: Only supporting [this} from now on in rule text. --- .../components/ability/AbilityPicker.java | 2 +- .../org/mage/card/arcane/ManaSymbols.java | 67 +++++++--------- .../src/mage/player/human/HumanPlayer.java | 80 ++++++++++--------- Mage.Sets/src/mage/cards/a/AbyssalHunter.java | 2 +- .../mage/cards/a/AccumulatedKnowledge.java | 2 +- Mage.Sets/src/mage/cards/a/ArcTrail.java | 2 +- Mage.Sets/src/mage/cards/a/ArmedResponse.java | 2 +- Mage.Sets/src/mage/cards/b/BookBurning.java | 2 +- Mage.Sets/src/mage/cards/b/BrainGorgers.java | 2 +- Mage.Sets/src/mage/cards/b/Browbeat.java | 2 +- .../src/mage/cards/c/ChandrasPyreling.java | 2 +- Mage.Sets/src/mage/cards/c/Clickslither.java | 2 +- .../src/mage/cards/c/CloakAndDagger.java | 2 +- Mage.Sets/src/mage/cards/c/ConeOfFlame.java | 2 +- Mage.Sets/src/mage/cards/d/DashHopes.java | 2 +- .../src/mage/cards/d/DiseasedVermin.java | 2 +- Mage.Sets/src/mage/cards/d/DivinersWand.java | 2 +- .../src/mage/cards/d/DoorOfDestinies.java | 2 +- Mage.Sets/src/mage/cards/e/Electrolyze.java | 2 +- .../src/mage/cards/e/EtherealChampion.java | 2 +- Mage.Sets/src/mage/cards/f/Fastbond.java | 2 +- Mage.Sets/src/mage/cards/f/FeastOfFlesh.java | 2 +- .../src/mage/cards/f/FelhideSpiritbinder.java | 2 +- .../src/mage/cards/g/GalvanicBombardment.java | 2 +- .../src/mage/cards/g/GhastlyRemains.java | 2 +- Mage.Sets/src/mage/cards/g/GiantOyster.java | 2 +- Mage.Sets/src/mage/cards/g/Gigapede.java | 2 +- Mage.Sets/src/mage/cards/h/HerosBlade.java | 2 +- .../src/mage/cards/h/HuatliWarriorPoet.java | 2 +- Mage.Sets/src/mage/cards/i/Ichorid.java | 2 +- Mage.Sets/src/mage/cards/k/Kindle.java | 2 +- .../src/mage/cards/k/KjeldoranRoyalGuard.java | 2 +- .../src/mage/cards/k/KjeldoranWarCry.java | 2 +- Mage.Sets/src/mage/cards/l/LifeBurst.java | 2 +- .../mage/cards/l/LyzoldaTheBloodWitch.java | 2 +- Mage.Sets/src/mage/cards/m/Mindreaver.java | 2 +- Mage.Sets/src/mage/cards/n/NetherShadow.java | 2 +- .../src/mage/cards/o/ObsidianBattleAxe.java | 2 +- .../mage/cards/o/OdricMasterTactician.java | 3 + .../src/mage/cards/o/OldManOfTheSea.java | 2 +- .../src/mage/cards/o/OranRiefInvoker.java | 2 +- .../src/mage/cards/p/Phantasmagorian.java | 2 +- .../mage/cards/r/RinAndSeriInseparable.java | 2 +- .../src/mage/cards/s/SaiOfTheShinobi.java | 2 +- .../src/mage/cards/s/ShieldedByFaith.java | 2 +- Mage.Sets/src/mage/cards/s/Skullcage.java | 2 +- Mage.Sets/src/mage/cards/s/Skullscorch.java | 2 +- Mage.Sets/src/mage/cards/s/StormriderRig.java | 2 +- Mage.Sets/src/mage/cards/t/TakeInventory.java | 2 +- .../src/mage/cards/t/TemporalExtortion.java | 2 +- .../src/mage/cards/t/ThornbiteStaff.java | 2 +- Mage.Sets/src/mage/cards/t/Tornado.java | 4 +- .../src/mage/cards/v/VeteranBodyguard.java | 2 +- .../src/mage/cards/v/VeteransArmaments.java | 2 +- Mage.Sets/src/mage/cards/v/Viseling.java | 2 +- Mage.Sets/src/mage/cards/w/WickedAkuba.java | 2 +- .../abilities/equipped/HeavyArbalestTest.java | 4 +- .../abilities/keywords/ChampionTest.java | 2 +- .../oneshot/damage/SatyrFiredancerTest.java | 2 +- .../test/cards/planeswalker/UginTest.java | 2 +- .../cards/single/dka/HavengulLichTest.java | 6 +- .../single/lrw/BurrentonForgeTenderTest.java | 6 +- .../cards/single/m21/ChandrasMagmuttTest.java | 4 +- .../triggers/damage/SyrCarahTheBoldTest.java | 4 +- .../cards/triggers/dies/BloodCultistTest.java | 14 ++-- .../test/cards/watchers/DiesExiledTest.java | 6 +- .../watchers/KiraGreatGlassSpinnerTest.java | 8 +- .../watchers/UnscytheKillerOfKingsTest.java | 4 +- .../mage/test/game/ends/GameIsADrawTest.java | 2 +- .../org/mage/test/testapi/TestAliases.java | 8 +- .../java/mage/verify/VerifyCardDataTest.java | 41 +++++----- .../main/java/mage/abilities/AbilityImpl.java | 16 ++-- Mage/src/main/java/mage/abilities/Modes.java | 8 +- .../common/ProwlCostWasPaidCondition.java | 2 +- .../common/SourcePermanentPowerCount.java | 2 +- .../common/SourcePermanentToughnessValue.java | 2 +- .../effects/common/DamageAllEffect.java | 2 +- .../effects/common/DamageAttachedEffect.java | 2 +- .../common/DamageControllerEffect.java | 2 +- .../common/DamageEverythingEffect.java | 2 +- .../effects/common/DamageMultiEffect.java | 2 +- .../effects/common/DamagePlayersEffect.java | 2 +- .../effects/common/DamageSelfEffect.java | 2 +- .../effects/common/DamageTargetEffect.java | 2 +- .../effects/common/DoIfCostPaid.java | 6 +- .../DontUntapAsLongAsSourceTappedEffect.java | 2 +- .../common/PreventDamageToSourceEffect.java | 2 +- .../ProtectionChosenColorAttachedEffect.java | 2 +- .../ProtectionChosenColorSourceEffect.java | 2 +- .../main/java/mage/constants/Duration.java | 2 +- Mage/src/main/java/mage/util/CardUtil.java | 32 ++++---- 91 files changed, 229 insertions(+), 236 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java b/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java index df03dc72fc..91227cc94b 100644 --- a/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java +++ b/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java @@ -391,7 +391,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener { List objectList = new ArrayList<>(); objectList.add("T: add {R}. 111111111111111111111111111"); - objectList.add("T: add {B}. {source} deals 1 damage to you."); + objectList.add("T: add {B}. {this} deals 1 damage to you."); objectList.add("{T}: add {B}"); objectList.add("T: add {B}"); objectList.add("T: add {B}"); diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java b/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java index 09abb216b5..5dc9ca187a 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java @@ -1,5 +1,23 @@ package org.mage.card.arcane; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.awt.image.FilteredImageSource; +import java.awt.image.ImageProducer; +import java.awt.image.RGBImageFilter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Pattern; +import java.util.stream.IntStream; +import javax.imageio.ImageIO; +import javax.swing.*; import mage.abilities.hint.HintUtils; import mage.cards.repository.CardInfo; import mage.cards.repository.ExpansionRepository; @@ -22,27 +40,6 @@ import org.apache.batik.transcoder.image.ImageTranscoder; import org.apache.batik.util.SVGConstants; import org.apache.log4j.Logger; import org.mage.plugins.card.utils.CardImageUtils; - -import javax.imageio.ImageIO; -import javax.swing.*; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.awt.image.FilteredImageSource; -import java.awt.image.ImageProducer; -import java.awt.image.RGBImageFilter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.file.*; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.List; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.regex.Pattern; -import java.util.stream.IntStream; - import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir; public final class ManaSymbols { @@ -77,22 +74,22 @@ public final class ManaSymbols { withoutSymbols.add("P09"); withoutSymbols.add("P10"); withoutSymbols.add("P11"); - + } private static final Map setImagesExist = new HashMap<>(); private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}"); private static final String[] symbols = new String[]{ - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", - "B", "BG", "BR", "BP", "2B", - "G", "GU", "GW", "GP", "2G", - "R", "RG", "RW", "RP", "2R", - "S", "T", "Q", - "U", "UB", "UR", "UP", "2U", - "W", "WB", "WU", "WP", "2W", - "X", "C", "E"}; + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", + "B", "BG", "BR", "BP", "2B", + "G", "GU", "GW", "GP", "2G", + "R", "RG", "RW", "RP", "2R", + "S", "T", "Q", + "U", "UB", "UR", "UP", "2U", + "W", "WB", "WU", "WP", "2W", + "X", "C", "E"}; private static final JLabel labelRender = new JLabel(); // render mana text @@ -173,7 +170,7 @@ public final class ManaSymbols { } // preload set images - List setCodes = ExpansionRepository.instance.getSetCodes(); + java.util.List setCodes = ExpansionRepository.instance.getSetCodes(); if (setCodes == null) { // the cards db file is probaly not included in the client. It will be created after the first connect to a server. LOGGER.warn("No db information for sets found. Connect to a server to create database file on client side. Then try to restart the client."); @@ -713,7 +710,7 @@ public final class ManaSymbols { } - public static String getStringManaCost(List manaCost) { + public static String getStringManaCost(java.util.List manaCost) { StringBuilder sb = new StringBuilder(); for (String s : manaCost) { sb.append(s); @@ -778,7 +775,6 @@ public final class ManaSymbols { // replace every {symbol} to link // ignore data backup String replaced = value - .replace("{source}", "|source|") .replace("{this}", "|this|"); // not need to add different images (width and height do the work) @@ -790,7 +786,7 @@ public final class ManaSymbols { replaced = replaced.replace(CardInfo.SPLIT_MANA_SEPARATOR_FULL, CardInfo.SPLIT_MANA_SEPARATOR_RENDER); replaced = REPLACE_SYMBOLS_PATTERN.matcher(replaced).replaceAll( "$1$2 chosen = target.getTargets(); + java.util.List chosen = target.getTargets(); options.put("chosen", (Serializable) chosen); updateGameStatePriority("choose(5)", game); @@ -656,9 +660,9 @@ public class HumanPlayer extends PlayerImpl { } Map options = getOptions(target, null); - List chosen = target.getTargets(); + java.util.List chosen = target.getTargets(); options.put("chosen", (Serializable) chosen); - List choosable = new ArrayList<>(); + java.util.List choosable = new ArrayList<>(); for (UUID cardId : cards) { if (target.canTarget(abilityControllerId, cardId, null, cards, game)) { choosable.add(cardId); @@ -730,9 +734,9 @@ public class HumanPlayer extends PlayerImpl { } Map options = getOptions(target, null); - List chosen = target.getTargets(); + java.util.List chosen = target.getTargets(); options.put("chosen", (Serializable) chosen); - List choosable = new ArrayList<>(); + java.util.List choosable = new ArrayList<>(); for (UUID cardId : cards) { if (target.canTarget(abilityControllerId, cardId, source, cards, game)) { choosable.add(cardId); @@ -801,9 +805,9 @@ public class HumanPlayer extends PlayerImpl { if (!isExecutingMacro()) { String selectedNames = target.getTargetedName(game); game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage() - + "
Amount remaining: " + target.getAmountRemaining() - + (selectedNames.isEmpty() ? "" : ", selected: " + selectedNames), - getRelatedObjectName(source, game)), + + "
Amount remaining: " + target.getAmountRemaining() + + (selectedNames.isEmpty() ? "" : ", selected: " + selectedNames), + getRelatedObjectName(source, game)), possibleTargets, required, getOptions(target, null)); @@ -817,7 +821,7 @@ public class HumanPlayer extends PlayerImpl { boolean removeMode = target.getTargets().contains(targetId) && chooseUse(outcome, "What do you want to do with " + (targetObject != null ? targetObject.getLogName() : " target") + "?", "", - "Remove from selected", "Add extra amount (remaining " + target.getAmountRemaining() + ")", source, game); + "Remove from selected", "Add extra amount (remaining " + target.getAmountRemaining() + ")", source, game); if (removeMode) { target.remove(targetId); @@ -959,9 +963,9 @@ public class HumanPlayer extends PlayerImpl { if (!skippedAtLeastOnce || (playerId.equals(game.getActivePlayerId()) && !controllingPlayer - .getUserData() - .getUserSkipPrioritySteps() - .isStopOnAllEndPhases())) { + .getUserData() + .getUserSkipPrioritySteps() + .isStopOnAllEndPhases())) { skippedAtLeastOnce = true; if (passWithManaPoolCheck(game)) { return false; @@ -993,9 +997,9 @@ public class HumanPlayer extends PlayerImpl { if (haveNewObjectsOnStack && (playerId.equals(game.getActivePlayerId()) && controllingPlayer - .getUserData() - .getUserSkipPrioritySteps() - .isStopOnStackNewObjects())) { + .getUserData() + .getUserSkipPrioritySteps() + .isStopOnStackNewObjects())) { // new objects on stack -- disable "pass until stack resolved" passedUntilStackResolved = false; } else { @@ -1131,7 +1135,7 @@ public class HumanPlayer extends PlayerImpl { } @Override - public TriggeredAbility chooseTriggeredAbility(List abilities, Game game) { + public TriggeredAbility chooseTriggeredAbility(java.util.List abilities, Game game) { // choose triggered abilitity from list if (gameInCheckPlayableState(game)) { return null; @@ -1141,7 +1145,7 @@ public class HumanPlayer extends PlayerImpl { boolean autoOrderUse = getControllingPlayersUserData(game).isAutoOrderTrigger(); while (canRespond()) { // try to set trigger auto order - List abilitiesWithNoOrderSet = new ArrayList<>(); + java.util.List abilitiesWithNoOrderSet = new ArrayList<>(); TriggeredAbility abilityOrderLast = null; for (TriggeredAbility ability : abilities) { if (triggerAutoOrderAbilityFirst.contains(ability.getOriginalId())) { @@ -1399,7 +1403,7 @@ public class HumanPlayer extends PlayerImpl { filter.add(new ControllerIdPredicate(attackingPlayerId)); while (canRespond()) { - List possibleAttackers = new ArrayList<>(); + java.util.List possibleAttackers = new ArrayList<>(); for (Permanent possibleAttacker : game.getBattlefield().getActivePermanents(filter, attackingPlayerId, game)) { if (possibleAttacker.canAttack(null, game)) { possibleAttackers.add(possibleAttacker.getId()); @@ -1413,8 +1417,8 @@ public class HumanPlayer extends PlayerImpl { if (passedAllTurns || passedUntilEndStepBeforeMyTurn || (!getControllingPlayersUserData(game) - .getUserSkipPrioritySteps() - .isStopOnDeclareAttackers() + .getUserSkipPrioritySteps() + .isStopOnDeclareAttackers() && (passedTurn || passedTurnSkipStack || passedUntilEndOfTurn @@ -1682,7 +1686,7 @@ public class HumanPlayer extends PlayerImpl { prepareForResponse(game); if (!isExecutingMacro()) { Map options = new HashMap<>(); - List possibleBlockers = game.getBattlefield().getActivePermanents(filter, playerId, game).stream() + java.util.List possibleBlockers = game.getBattlefield().getActivePermanents(filter, playerId, game).stream() .map(p -> p.getId()) .collect(Collectors.toList()); options.put(Constants.Option.POSSIBLE_BLOCKERS, (Serializable) possibleBlockers); @@ -1715,7 +1719,7 @@ public class HumanPlayer extends PlayerImpl { } @Override - public UUID chooseAttackerOrder(List attackers, Game game) { + public UUID chooseAttackerOrder(java.util.List attackers, Game game) { if (gameInCheckPlayableState(game)) { return null; } @@ -1740,7 +1744,7 @@ public class HumanPlayer extends PlayerImpl { } @Override - public UUID chooseBlockerOrder(List blockers, CombatGroup combatGroup, List blockerOrder, Game game) { + public UUID chooseBlockerOrder(java.util.List blockers, CombatGroup combatGroup, java.util.List blockerOrder, Game game) { if (gameInCheckPlayableState(game)) { return null; } @@ -1809,7 +1813,7 @@ public class HumanPlayer extends PlayerImpl { } @Override - public void assignDamage(int damage, List targets, String singleTargetName, UUID sourceId, Game game) { + public void assignDamage(int damage, java.util.List targets, String singleTargetName, UUID sourceId, Game game) { updateGameStatePriority("assignDamage", game); int remainingDamage = damage; while (remainingDamage > 0 && canRespond()) { @@ -1873,7 +1877,7 @@ public class HumanPlayer extends PlayerImpl { } @Override - public void pickCard(List cards, Deck deck, Draft draft) { + public void pickCard(java.util.List cards, Deck deck, Draft draft) { draft.firePickCardEvent(playerId); } @@ -2056,7 +2060,7 @@ public class HumanPlayer extends PlayerImpl { if (mode.getTargets().canChoose(source.getSourceId(), source.getControllerId(), game)) { // and needed targets have to be available String modeText = mode.getEffects().getText(mode); if (obj != null) { - modeText = modeText.replace("{source}", obj.getName()).replace("{this}", obj.getName()); + modeText = modeText.replace("{this}", obj.getName()); } if (modes.isEachModeMoreThanOnce()) { if (timesSelected > 0) { @@ -2131,7 +2135,7 @@ public class HumanPlayer extends PlayerImpl { } @Override - public boolean choosePile(Outcome outcome, String message, List pile1, List pile2, Game game) { + public boolean choosePile(Outcome outcome, String message, java.util.List pile1, java.util.List pile2, Game game) { if (gameInCheckPlayableState(game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/a/AbyssalHunter.java b/Mage.Sets/src/mage/cards/a/AbyssalHunter.java index 8f55d8d1c8..a1acd7e151 100644 --- a/Mage.Sets/src/mage/cards/a/AbyssalHunter.java +++ b/Mage.Sets/src/mage/cards/a/AbyssalHunter.java @@ -35,7 +35,7 @@ public final class AbyssalHunter extends CardImpl { // {B}, {tap}: Tap target creature. Abyssal Hunter deals damage equal to Abyssal Hunter's power to that creature. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TapTargetEffect(), new ManaCostsImpl("{B}")); Effect effect = new DamageTargetEffect(new SourcePermanentPowerCount()); - effect.setText("{source} deals damage equal to {source}'s power to that creature."); + effect.setText("{this} deals damage equal to {this}'s power to that creature."); ability.addEffect(effect); ability.addCost(new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); diff --git a/Mage.Sets/src/mage/cards/a/AccumulatedKnowledge.java b/Mage.Sets/src/mage/cards/a/AccumulatedKnowledge.java index 10a6f8e2b9..55c362995c 100644 --- a/Mage.Sets/src/mage/cards/a/AccumulatedKnowledge.java +++ b/Mage.Sets/src/mage/cards/a/AccumulatedKnowledge.java @@ -30,7 +30,7 @@ public final class AccumulatedKnowledge extends CardImpl { // Draw a card, then draw cards equal to the number of cards named Accumulated Knowledge in all graveyards. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); Effect effect = new DrawCardSourceControllerEffect(new CardsInAllGraveyardsCount(filter)); - effect.setText(", then draw cards equal to the number of cards named {source} in all graveyards"); + effect.setText(", then draw cards equal to the number of cards named {this} in all graveyards"); this.getSpellAbility().addEffect(effect); } diff --git a/Mage.Sets/src/mage/cards/a/ArcTrail.java b/Mage.Sets/src/mage/cards/a/ArcTrail.java index ba385941f7..8c75688fea 100644 --- a/Mage.Sets/src/mage/cards/a/ArcTrail.java +++ b/Mage.Sets/src/mage/cards/a/ArcTrail.java @@ -68,7 +68,7 @@ class ArcTrailEffect extends OneShotEffect { private ArcTrailEffect() { super(Outcome.Damage); - staticText = "{source} deals 2 damage to any target and 1 damage to another target"; + staticText = "{this} deals 2 damage to any target and 1 damage to another target"; } @Override diff --git a/Mage.Sets/src/mage/cards/a/ArmedResponse.java b/Mage.Sets/src/mage/cards/a/ArmedResponse.java index e57346f044..af04450c6c 100644 --- a/Mage.Sets/src/mage/cards/a/ArmedResponse.java +++ b/Mage.Sets/src/mage/cards/a/ArmedResponse.java @@ -30,7 +30,7 @@ public final class ArmedResponse extends CardImpl { // Armed Response deals damage to target attacking creature equal to the number of Equipment you control. Effect effect = new DamageTargetEffect(new PermanentsOnBattlefieldCount(filter)); - effect.setText("{source} deals damage to target attacking creature equal to the number of Equipment you control"); + effect.setText("{this} deals damage to target attacking creature equal to the number of Equipment you control"); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetAttackingCreature()); } diff --git a/Mage.Sets/src/mage/cards/b/BookBurning.java b/Mage.Sets/src/mage/cards/b/BookBurning.java index 6678b6520f..b084527e3f 100644 --- a/Mage.Sets/src/mage/cards/b/BookBurning.java +++ b/Mage.Sets/src/mage/cards/b/BookBurning.java @@ -41,7 +41,7 @@ class BookBurningMillEffect extends OneShotEffect { public BookBurningMillEffect() { super(Outcome.Detriment); - staticText = "Any player may have {source} deal 6 damage to them. If no one does, target player mills six cards"; + staticText = "Any player may have {this} deal 6 damage to them. If no one does, target player mills six cards"; } public BookBurningMillEffect(final BookBurningMillEffect effect) { diff --git a/Mage.Sets/src/mage/cards/b/BrainGorgers.java b/Mage.Sets/src/mage/cards/b/BrainGorgers.java index 056e52aa17..df85017892 100644 --- a/Mage.Sets/src/mage/cards/b/BrainGorgers.java +++ b/Mage.Sets/src/mage/cards/b/BrainGorgers.java @@ -54,7 +54,7 @@ class BrainGorgersCounterSourceEffect extends OneShotEffect { public BrainGorgersCounterSourceEffect() { super(Outcome.AIDontUseIt); - staticText = "any player may sacrifice a creature. If a player does, counter {source}"; + staticText = "any player may sacrifice a creature. If a player does, counter {this}"; } public BrainGorgersCounterSourceEffect(final BrainGorgersCounterSourceEffect effect) { diff --git a/Mage.Sets/src/mage/cards/b/Browbeat.java b/Mage.Sets/src/mage/cards/b/Browbeat.java index e96f9ae7bb..b2bf79ddfe 100644 --- a/Mage.Sets/src/mage/cards/b/Browbeat.java +++ b/Mage.Sets/src/mage/cards/b/Browbeat.java @@ -41,7 +41,7 @@ class BrowbeatDrawEffect extends OneShotEffect { public BrowbeatDrawEffect() { super(Outcome.DrawCard); - staticText = "Any player may have {source} deal 5 damage to them. If no one does, target player draws three cards."; + staticText = "Any player may have {this} deal 5 damage to them. If no one does, target player draws three cards."; } public BrowbeatDrawEffect(final BrowbeatDrawEffect effect) { diff --git a/Mage.Sets/src/mage/cards/c/ChandrasPyreling.java b/Mage.Sets/src/mage/cards/c/ChandrasPyreling.java index bca970e2a6..833a3d6475 100644 --- a/Mage.Sets/src/mage/cards/c/ChandrasPyreling.java +++ b/Mage.Sets/src/mage/cards/c/ChandrasPyreling.java @@ -77,6 +77,6 @@ class ChandrasPyrelingAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Whenever a source you control deals noncombat damage to an opponent, {source} gets +1/+0 and gains double strike until end of turn."; + return "Whenever a source you control deals noncombat damage to an opponent, {this} gets +1/+0 and gains double strike until end of turn."; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/c/Clickslither.java b/Mage.Sets/src/mage/cards/c/Clickslither.java index 55317c1f64..0ab8d046cc 100644 --- a/Mage.Sets/src/mage/cards/c/Clickslither.java +++ b/Mage.Sets/src/mage/cards/c/Clickslither.java @@ -43,7 +43,7 @@ public final class Clickslither extends CardImpl { this.addAbility(HasteAbility.getInstance()); // Sacrifice a Goblin: Clickslither gets +2/+2 and gains trample until end of turn. Effect effect = new BoostSourceEffect(2,2,Duration.EndOfTurn); - effect.setText("{source} gets +2/+2"); + effect.setText("{this} gets +2/+2"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,filter,true))); effect = new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); diff --git a/Mage.Sets/src/mage/cards/c/CloakAndDagger.java b/Mage.Sets/src/mage/cards/c/CloakAndDagger.java index 11a8d9f1bd..406697b2e5 100644 --- a/Mage.Sets/src/mage/cards/c/CloakAndDagger.java +++ b/Mage.Sets/src/mage/cards/c/CloakAndDagger.java @@ -40,7 +40,7 @@ public final class CloakAndDagger extends CardImpl { this.addAbility(ability); // Whenever a Rogue creature enters the battlefield, you may attach Cloak and Dagger to it. this.addAbility(new EntersBattlefieldAllTriggeredAbility( - Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {source} to it"), + Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {this} to it"), filter, true, SetTargetPointer.PERMANENT, null)); // Equip {3} this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3))); diff --git a/Mage.Sets/src/mage/cards/c/ConeOfFlame.java b/Mage.Sets/src/mage/cards/c/ConeOfFlame.java index cc1c9e7950..c64de5418d 100644 --- a/Mage.Sets/src/mage/cards/c/ConeOfFlame.java +++ b/Mage.Sets/src/mage/cards/c/ConeOfFlame.java @@ -63,7 +63,7 @@ class ConeOfFlameEffect extends OneShotEffect { public ConeOfFlameEffect() { super(Outcome.Damage); - this.staticText = "{source} deals 1 damage to any target, " + this.staticText = "{this} deals 1 damage to any target, " + "2 damage to another target, " + "and 3 damage to a third target"; } diff --git a/Mage.Sets/src/mage/cards/d/DashHopes.java b/Mage.Sets/src/mage/cards/d/DashHopes.java index a8edaeace7..c6eac88e19 100644 --- a/Mage.Sets/src/mage/cards/d/DashHopes.java +++ b/Mage.Sets/src/mage/cards/d/DashHopes.java @@ -48,7 +48,7 @@ class DashHopesCounterSourceEffect extends OneShotEffect { public DashHopesCounterSourceEffect() { super(Outcome.AIDontUseIt); - staticText = "any player may pay 5 life. If a player does, counter {source}"; + staticText = "any player may pay 5 life. If a player does, counter {this}"; } public DashHopesCounterSourceEffect(final DashHopesCounterSourceEffect effect) { diff --git a/Mage.Sets/src/mage/cards/d/DiseasedVermin.java b/Mage.Sets/src/mage/cards/d/DiseasedVermin.java index b9d61ec3ff..e40712175c 100644 --- a/Mage.Sets/src/mage/cards/d/DiseasedVermin.java +++ b/Mage.Sets/src/mage/cards/d/DiseasedVermin.java @@ -127,7 +127,7 @@ class DiseasedVerminPredicate implements ObjectSourcePlayerPredicateInspired — Whenever Felhide Spiritbinder becomes untapped, you may pay {1}{R}. If you do, create a token that's a copy of another target creature except it's an enchantment in addition to its other types. It gains haste. Exile it at the beginning of the next end step. - Ability ability = new InspiredAbility(new DoIfCostPaid(new FelhideSpiritbinderEffect(), new ManaCostsImpl("{1}{R}"), "Use effect of {source}?")); + Ability ability = new InspiredAbility(new DoIfCostPaid(new FelhideSpiritbinderEffect(), new ManaCostsImpl("{1}{R}"), "Use effect of {this}?")); ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java b/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java index 723b3a7f36..4d44c642c4 100644 --- a/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java +++ b/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java @@ -32,7 +32,7 @@ public final class GalvanicBombardment extends CardImpl { // Galvanic Bombardment deals X damage to target creature, where X is 2 plus the number of cards named Galvanic Bombardment in your graveyard. Effect effect = new DamageTargetEffect(new GalvanicBombardmentCardsInControllerGraveyardCount(filter)); - effect.setText("{this} deals X damage to target creature, where X is 2 plus the number of cards named {source} in your graveyard"); + effect.setText("{this} deals X damage to target creature, where X is 2 plus the number of cards named {this} in your graveyard"); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } diff --git a/Mage.Sets/src/mage/cards/g/GhastlyRemains.java b/Mage.Sets/src/mage/cards/g/GhastlyRemains.java index 07ce776d13..4ef20b240d 100644 --- a/Mage.Sets/src/mage/cards/g/GhastlyRemains.java +++ b/Mage.Sets/src/mage/cards/g/GhastlyRemains.java @@ -75,7 +75,7 @@ class GhastlyRemainsTriggeredAbility extends BeginningOfUpkeepTriggeredAbility { @Override public String getRule() { - return "At the beginning of your upkeep, if {source} is in your graveyard, you may pay {B}{B}{B}. If you do, return {source} to your hand"; + return "At the beginning of your upkeep, if {this} is in your graveyard, you may pay {B}{B}{B}. If you do, return {this} to your hand"; } } diff --git a/Mage.Sets/src/mage/cards/g/GiantOyster.java b/Mage.Sets/src/mage/cards/g/GiantOyster.java index 6b4dacd028..3749dd7b04 100644 --- a/Mage.Sets/src/mage/cards/g/GiantOyster.java +++ b/Mage.Sets/src/mage/cards/g/GiantOyster.java @@ -71,7 +71,7 @@ class GiantOysterDontUntapAsLongAsSourceTappedEffect extends DontUntapAsLongAsSo public GiantOysterDontUntapAsLongAsSourceTappedEffect() { super(); - staticText = "For as long as {source} remains tapped, target tapped creature doesn't untap during its controller's untap step"; + staticText = "For as long as {this} remains tapped, target tapped creature doesn't untap during its controller's untap step"; } public GiantOysterDontUntapAsLongAsSourceTappedEffect(final GiantOysterDontUntapAsLongAsSourceTappedEffect effect) { diff --git a/Mage.Sets/src/mage/cards/g/Gigapede.java b/Mage.Sets/src/mage/cards/g/Gigapede.java index 7de6e73bbf..8fc780e34f 100644 --- a/Mage.Sets/src/mage/cards/g/Gigapede.java +++ b/Mage.Sets/src/mage/cards/g/Gigapede.java @@ -74,7 +74,7 @@ class GigapedeTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ @Override public String getRule() { - return "At the beginning of your upkeep, if {source} is in your graveyard, you may discard a card. If you do, return {source} to your hand"; + return "At the beginning of your upkeep, if {this} is in your graveyard, you may discard a card. If you do, return {this} to your hand"; } } diff --git a/Mage.Sets/src/mage/cards/h/HerosBlade.java b/Mage.Sets/src/mage/cards/h/HerosBlade.java index 5ff21c3c65..7c255142e8 100644 --- a/Mage.Sets/src/mage/cards/h/HerosBlade.java +++ b/Mage.Sets/src/mage/cards/h/HerosBlade.java @@ -36,7 +36,7 @@ public final class HerosBlade extends CardImpl { // Whenever a legendary creature enters the battlefield under your control, you may attach Hero's Blade to it. this.addAbility(new EntersBattlefieldAllTriggeredAbility( - Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {source} to it"), + Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {this} to it"), filter, true, SetTargetPointer.PERMANENT, null, true)); // Equip {4} diff --git a/Mage.Sets/src/mage/cards/h/HuatliWarriorPoet.java b/Mage.Sets/src/mage/cards/h/HuatliWarriorPoet.java index 7d3ec36556..d5d6da9f1e 100644 --- a/Mage.Sets/src/mage/cards/h/HuatliWarriorPoet.java +++ b/Mage.Sets/src/mage/cards/h/HuatliWarriorPoet.java @@ -137,7 +137,7 @@ class HuatliWarriorPoetDamageEffect extends OneShotEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } - return "{source} deals " + return "{this} deals " + amount.toString() + " damage divided as you choose among any number of target " + mode.getTargets().get(0).getTargetName() diff --git a/Mage.Sets/src/mage/cards/i/Ichorid.java b/Mage.Sets/src/mage/cards/i/Ichorid.java index 3fbd71701d..2942f1ba9d 100644 --- a/Mage.Sets/src/mage/cards/i/Ichorid.java +++ b/Mage.Sets/src/mage/cards/i/Ichorid.java @@ -95,7 +95,7 @@ class IchoridTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ @Override public String getRule() { - return "At the beginning of your upkeep, if {source} is in your graveyard, you may exile a black creature card other than {source} from your graveyard. If you do, return {source} to the battlefield."; + return "At the beginning of your upkeep, if {this} is in your graveyard, you may exile a black creature card other than {this} from your graveyard. If you do, return {this} to the battlefield."; } } diff --git a/Mage.Sets/src/mage/cards/k/Kindle.java b/Mage.Sets/src/mage/cards/k/Kindle.java index ac8d7a38ca..dbebb67667 100644 --- a/Mage.Sets/src/mage/cards/k/Kindle.java +++ b/Mage.Sets/src/mage/cards/k/Kindle.java @@ -33,7 +33,7 @@ public final class Kindle extends CardImpl { // Kindle deals X damage to any target, where X is 2 plus the number of cards named Kindle in all graveyards. Effect effect = new DamageTargetEffect(new KindleCardsInAllGraveyardsCount(filter)); - effect.setText("{this} deals X damage to any target, where X is 2 plus the number of cards named {source} in all graveyards"); + effect.setText("{this} deals X damage to any target, where X is 2 plus the number of cards named {this} in all graveyards"); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetAnyTarget()); } diff --git a/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java b/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java index 36c340c81c..420a53422f 100644 --- a/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java +++ b/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java @@ -60,7 +60,7 @@ class KjeldoranRoyalGuardEffect extends ReplacementEffectImpl { KjeldoranRoyalGuardEffect() { super(Duration.EndOfTurn, Outcome.RedirectDamage); - staticText = "All combat damage that would be dealt to you by unblocked creatures this turn is dealt to {source} instead"; + staticText = "All combat damage that would be dealt to you by unblocked creatures this turn is dealt to {this} instead"; } KjeldoranRoyalGuardEffect(final KjeldoranRoyalGuardEffect effect) { diff --git a/Mage.Sets/src/mage/cards/k/KjeldoranWarCry.java b/Mage.Sets/src/mage/cards/k/KjeldoranWarCry.java index deb04f68eb..82b8852482 100644 --- a/Mage.Sets/src/mage/cards/k/KjeldoranWarCry.java +++ b/Mage.Sets/src/mage/cards/k/KjeldoranWarCry.java @@ -32,7 +32,7 @@ public final class KjeldoranWarCry extends CardImpl { // Creatures you control get +X/+X until end of turn, where X is 1 plus the number of cards named Kjeldoran War Cry in all graveyards. IntPlusDynamicValue value = new IntPlusDynamicValue(1, new CardsInAllGraveyardsCount(filter)); Effect effect = new BoostControlledEffect(value, value, Duration.EndOfTurn, new FilterCreaturePermanent("creatures"), false, true); - effect.setText("Creatures you control get +X/+X until end of turn, where X is 1 plus the number of cards named {source} in all graveyards"); + effect.setText("Creatures you control get +X/+X until end of turn, where X is 1 plus the number of cards named {this} in all graveyards"); this.getSpellAbility().addEffect(effect); } diff --git a/Mage.Sets/src/mage/cards/l/LifeBurst.java b/Mage.Sets/src/mage/cards/l/LifeBurst.java index 38ba25ae65..9c92672884 100644 --- a/Mage.Sets/src/mage/cards/l/LifeBurst.java +++ b/Mage.Sets/src/mage/cards/l/LifeBurst.java @@ -31,7 +31,7 @@ public final class LifeBurst extends CardImpl { // Target player gains 4 life, then gains 4 life for each card named Life Burst in each graveyard. this.getSpellAbility().addEffect(new GainLifeTargetEffect(4)); Effect effect = new GainLifeTargetEffect(new MultipliedValue(new CardsInAllGraveyardsCount(filter), 4)); - effect.setText(", then gains 4 life for each card named {source} in each graveyard"); + effect.setText(", then gains 4 life for each card named {this} in each graveyard"); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetPlayer()); } diff --git a/Mage.Sets/src/mage/cards/l/LyzoldaTheBloodWitch.java b/Mage.Sets/src/mage/cards/l/LyzoldaTheBloodWitch.java index 8f89e0feab..2b575b6f2b 100644 --- a/Mage.Sets/src/mage/cards/l/LyzoldaTheBloodWitch.java +++ b/Mage.Sets/src/mage/cards/l/LyzoldaTheBloodWitch.java @@ -55,7 +55,7 @@ public final class LyzoldaTheBloodWitch extends CardImpl { Effect effect = new ConditionalOneShotEffect( new DamageTargetEffect(2), new SacrificedWasCondition(redFilter), - "{source} deals 2 damage to any target if the sacrificed creature was red"); + "{this} deals 2 damage to any target if the sacrificed creature was red"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{2}")); effect = new ConditionalOneShotEffect( new DrawCardSourceControllerEffect(1), diff --git a/Mage.Sets/src/mage/cards/m/Mindreaver.java b/Mage.Sets/src/mage/cards/m/Mindreaver.java index a07333170f..83def79c22 100644 --- a/Mage.Sets/src/mage/cards/m/Mindreaver.java +++ b/Mage.Sets/src/mage/cards/m/Mindreaver.java @@ -135,6 +135,6 @@ class MindreaverNamePredicate implements Predicate { @Override public String toString() { - return "spell with the same name as a card exiled with {source}"; + return "spell with the same name as a card exiled with {this}"; } } diff --git a/Mage.Sets/src/mage/cards/n/NetherShadow.java b/Mage.Sets/src/mage/cards/n/NetherShadow.java index cfb9ac130e..47f659de1a 100644 --- a/Mage.Sets/src/mage/cards/n/NetherShadow.java +++ b/Mage.Sets/src/mage/cards/n/NetherShadow.java @@ -87,7 +87,7 @@ class NetherShadowTriggerdAbility extends BeginningOfUpkeepTriggeredAbility{ @Override public String getRule() { - return "At the beginning of your upkeep, if {source} is in your graveyard with three or more creature cards above it, you may put {source} onto the battlefield."; + return "At the beginning of your upkeep, if {this} is in your graveyard with three or more creature cards above it, you may put {this} onto the battlefield."; } diff --git a/Mage.Sets/src/mage/cards/o/ObsidianBattleAxe.java b/Mage.Sets/src/mage/cards/o/ObsidianBattleAxe.java index b8546e621a..f5cf3e9419 100644 --- a/Mage.Sets/src/mage/cards/o/ObsidianBattleAxe.java +++ b/Mage.Sets/src/mage/cards/o/ObsidianBattleAxe.java @@ -39,7 +39,7 @@ public final class ObsidianBattleAxe extends CardImpl { this.addAbility(ability); // Whenever a Warrior creature enters the battlefield, you may attach Obsidian Battle-Axe to it. this.addAbility(new EntersBattlefieldAllTriggeredAbility( - Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {source} to it"), + Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "attach {this} to it"), filter, true, SetTargetPointer.PERMANENT, null)); // Equip {3} this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3))); diff --git a/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java b/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java index f80c1331a7..237074dde0 100644 --- a/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java +++ b/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java @@ -128,6 +128,9 @@ class OdricMasterTacticianChooseBlockersEffect extends ContinuousRuleModifyingEf @Override public boolean applies(GameEvent event, Ability source, Game game) { + if (source.isControlledBy(event.getPlayerId())) { + return false; // Don't replace the own call to selectBlockers + } ChooseBlockersRedundancyWatcher watcher = game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if (watcher == null) { return false; diff --git a/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java b/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java index 94b55ca253..5a5f9bf87b 100644 --- a/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java +++ b/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java @@ -170,6 +170,6 @@ class PowerLowerEqualSourcePredicate implements ObjectPlayerPredicate> planesClassesList = reflections.getSubTypesOf(Plane.class); - // 1. correct class name for (Class planeClass : planesClassesList) { if (!planeClass.getName().endsWith("Plane")) { @@ -1086,7 +1085,7 @@ public class VerifyCardDataTest { // fix names (e.g. Urza’s to Urza's) if (expected != null && expected.contains("Urza’s")) { expected = new ArrayList<>(expected); - for (ListIterator it = ((List) expected).listIterator(); it.hasNext(); ) { + for (ListIterator it = ((List) expected).listIterator(); it.hasNext();) { if (it.next().equals("Urza’s")) { it.set("Urza's"); } @@ -1145,9 +1144,9 @@ public class VerifyCardDataTest { // ability/effect must have description or not boolean mustCheck = card.getAbilities().containsClass(objectClass) || card.getAbilities().stream() - .map(Ability::getAllEffects) - .flatMap(Collection::stream) - .anyMatch(effect -> effect.getClass().isAssignableFrom(objectClass)); + .map(Ability::getAllEffects) + .flatMap(Collection::stream) + .anyMatch(effect -> effect.getClass().isAssignableFrom(objectClass)); mustCheck = false; // TODO: enable and fix all problems with effect and ability hints if (mustCheck) { boolean needHint = ref.text.contains(objectHint); @@ -1205,7 +1204,6 @@ public class VerifyCardDataTest { // replace special text and symbols newRule = newRule .replace("{this}", cardName) - .replace("{source}", cardName) .replace("−", "-") .replace("—", "-") .replace("—", "-"); @@ -1248,7 +1246,7 @@ public class VerifyCardDataTest { } - /* + /* for(String rule : card.getRules()) { rule = rule.replaceAll("(?i).+", ""); // Ignoring reminder text in italic // TODO: add Equip {3} checks @@ -1302,7 +1300,6 @@ public class VerifyCardDataTest { } }*/ - private void checkWrongAbilitiesText(Card card, MtgJsonCard ref, int cardIndex) { // checks missing or wrong text if (!card.getExpansionSetCode().equals(FULL_ABILITIES_CHECK_SET_CODE)) { diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index 29a18df91c..36567af94b 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -1,5 +1,10 @@ package mage.abilities; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import mage.MageIdentifier; import mage.MageObject; import mage.abilities.costs.*; import mage.abilities.costs.common.PayLifeCost; @@ -31,12 +36,6 @@ import mage.util.ThreadLocalStringBuilder; import mage.watchers.Watcher; import org.apache.log4j.Logger; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import mage.MageIdentifier; - /** * @author BetaSteward_at_googlemail.com */ @@ -74,7 +73,7 @@ public abstract class AbilityImpl implements Ability { protected List hints = new ArrayList<>(); protected Outcome customOutcome = null; // uses for AI decisions instead effects protected MageIdentifier identifier; // used to identify specific ability (e.g. to match with corresponding watcher) - + public AbilityImpl(AbilityType abilityType, Zone zone) { this.id = UUID.randomUUID(); this.originalId = id; @@ -801,7 +800,6 @@ public abstract class AbilityImpl implements Ability { String replace = rule; if (rule != null && source != null && !source.isEmpty()) { replace = rule.replace("{this}", source); - replace = replace.replace("{source}", source); } return replace; } @@ -1318,5 +1316,5 @@ public abstract class AbilityImpl implements Ability { public AbilityImpl setIdentifier(MageIdentifier identifier) { this.identifier = identifier; return this; - } + } } diff --git a/Mage/src/main/java/mage/abilities/Modes.java b/Mage/src/main/java/mage/abilities/Modes.java index b06707d34c..1d43c9b3a2 100644 --- a/Mage/src/main/java/mage/abilities/Modes.java +++ b/Mage/src/main/java/mage/abilities/Modes.java @@ -1,5 +1,6 @@ package mage.abilities; +import java.util.*; import mage.abilities.costs.OptionalAdditionalModeSourceCosts; import mage.cards.Card; import mage.constants.Outcome; @@ -11,8 +12,6 @@ import mage.players.Player; import mage.target.common.TargetOpponent; import mage.util.RandomUtil; -import java.util.*; - /** * @author BetaSteward_at_googlemail.com */ @@ -446,10 +445,7 @@ public class Modes extends LinkedHashMap { } public String getText(String sourceName) { - String text = getText(); - text = text.replace("{this}", sourceName); - text = text.replace("{source}", sourceName); - return text; + return getText().replace("{this}", sourceName); } public boolean isEachModeOnlyOnce() { diff --git a/Mage/src/main/java/mage/abilities/condition/common/ProwlCostWasPaidCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ProwlCostWasPaidCondition.java index 5b6879fcbf..a3f28c19f3 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ProwlCostWasPaidCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ProwlCostWasPaidCondition.java @@ -32,7 +32,7 @@ public enum ProwlCostWasPaidCondition implements Condition { @Override public String toString() { - return "{source}'s prowl cost was paid"; + return "{this}'s prowl cost was paid"; } } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentPowerCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentPowerCount.java index e48bfa0451..c347fbc2c0 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentPowerCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentPowerCount.java @@ -55,6 +55,6 @@ public class SourcePermanentPowerCount implements DynamicValue { @Override public String getMessage() { - return "{source}'s power"; + return "{this}'s power"; } } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentToughnessValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentToughnessValue.java index 14a21180aa..4b13eee1f6 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentToughnessValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SourcePermanentToughnessValue.java @@ -52,6 +52,6 @@ public class SourcePermanentToughnessValue implements DynamicValue { @Override public String getMessage() { - return "{source}'s toughness"; + return "{this}'s toughness"; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageAllEffect.java index 8dffba358d..d489a9ba25 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageAllEffect.java @@ -19,7 +19,7 @@ public class DamageAllEffect extends OneShotEffect { private FilterPermanent filter; private DynamicValue amount; - private String sourceName = "{source}"; + private String sourceName = "{this}"; public DamageAllEffect(int amount, FilterPermanent filter) { this(StaticValue.get(amount), filter); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java index e302c240ca..43cb13ca72 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java @@ -19,7 +19,7 @@ import mage.game.permanent.Permanent; public class DamageAttachedEffect extends OneShotEffect { protected DynamicValue amount; - private String sourceName = "{source}"; + private String sourceName = "{this}"; public DamageAttachedEffect(int amount) { super(Outcome.Damage); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageControllerEffect.java index 1977287239..56d5c4fe87 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageControllerEffect.java @@ -19,7 +19,7 @@ public class DamageControllerEffect extends OneShotEffect { protected DynamicValue amount; protected boolean preventable; - private String sourceName = "{source}"; + private String sourceName = "{this}"; public DamageControllerEffect(int amount, String whoDealDamageName) { this(amount, true, whoDealDamageName); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java index 54db753781..0329202422 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java @@ -22,7 +22,7 @@ public class DamageEverythingEffect extends OneShotEffect { private DynamicValue amount; private FilterPermanent filter; private UUID damageSource; - private String sourceName = "{source}"; + private String sourceName = "{this}"; public DamageEverythingEffect(int amount) { this(StaticValue.get(amount), new FilterCreaturePermanent()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageMultiEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageMultiEffect.java index 9dc0f94e17..a2cf55be8b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageMultiEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageMultiEffect.java @@ -22,7 +22,7 @@ import java.util.UUID; public class DamageMultiEffect extends OneShotEffect { protected DynamicValue amount; - private String sourceName = "{source}"; + private String sourceName = "{this}"; private final Set damagedSet = new HashSet<>(); public DamageMultiEffect(int amount) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java index 01d581c38e..ef45ec725a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java @@ -17,7 +17,7 @@ import java.util.UUID; public class DamagePlayersEffect extends OneShotEffect { private DynamicValue amount; private TargetController controller; - private String sourceName = "{source}"; + private String sourceName = "{this}"; public DamagePlayersEffect(int amount) { this(Outcome.Damage, StaticValue.get(amount)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageSelfEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageSelfEffect.java index 31e471ad78..a819b385d4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageSelfEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageSelfEffect.java @@ -47,7 +47,7 @@ public class DamageSelfEffect extends OneShotEffect { return staticText; } StringBuilder sb = new StringBuilder(); - sb.append("{source} deals ").append(amount).append(" damage to itself"); + sb.append("{this} deals ").append(amount).append(" damage to itself"); return sb.toString(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageTargetEffect.java index ea60a6e866..dff5f88bb3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageTargetEffect.java @@ -24,7 +24,7 @@ public class DamageTargetEffect extends OneShotEffect { protected boolean preventable; protected String targetDescription; protected boolean useOnlyTargetPointer; - protected String sourceName = "{source}"; + protected String sourceName = "{this}"; public DamageTargetEffect(int amount) { this(StaticValue.get(amount), true); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java index 437059c0a6..59d6234ef1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java @@ -1,5 +1,6 @@ package mage.abilities.effects.common; +import java.util.Locale; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.Mode; @@ -13,8 +14,6 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; -import java.util.Locale; - public class DoIfCostPaid extends OneShotEffect { protected Effects executingEffects = new Effects(); @@ -85,11 +84,10 @@ public class DoIfCostPaid extends OneShotEffect { } message = getCostText() + (effectText.isEmpty() ? "" : " and " + effectText) + "?"; message = Character.toUpperCase(message.charAt(0)) + message.substring(1); - CardUtil.replaceSourceName(message, mageObject.getName()); } else { message = chooseUseText; } - message = CardUtil.replaceSourceName(message, mageObject.getLogName()); + message = CardUtil.replaceSourceName(message, mageObject.getName()); boolean result = true; Outcome payOutcome = executingEffects.getOutcome(source, this.outcome); if (cost.canPay(source, source.getSourceId(), player.getId(), game) diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapAsLongAsSourceTappedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapAsLongAsSourceTappedEffect.java index 866f2350bf..1bee239488 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapAsLongAsSourceTappedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapAsLongAsSourceTappedEffect.java @@ -18,7 +18,7 @@ public class DontUntapAsLongAsSourceTappedEffect extends ConditionalContinuousRu public DontUntapAsLongAsSourceTappedEffect() { super(new DontUntapInControllersUntapStepTargetEffect(Duration.Custom), SourceTappedCondition.instance); - staticText = "It doesn't untap during its controller's untap step for as long as {source} remains tapped."; + staticText = "It doesn't untap during its controller's untap step for as long as {this} remains tapped."; } public DontUntapAsLongAsSourceTappedEffect(final DontUntapAsLongAsSourceTappedEffect effect) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToSourceEffect.java index 7038040e8f..5fa7cba4ce 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToSourceEffect.java @@ -60,7 +60,7 @@ public class PreventDamageToSourceEffect extends PreventionEffectImpl { } else { sb.append("Prevent the next ").append(amountToPrevent).append(" damage that would be dealt to "); } - sb.append("{source} "); + sb.append("{this} "); if (duration == EndOfTurn) { sb.append("this turn"); } else { diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java index 2bcf56fc87..0779d8c9ff 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java @@ -27,7 +27,7 @@ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl { public ProtectionChosenColorAttachedEffect(boolean notRemoveItself) { super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); this.notRemoveItself = notRemoveItself; - staticText = "{source} has protection from the chosen color" + (notRemoveItself ? ". This effect doesn't remove {this}" : ""); + staticText = "{this} has protection from the chosen color" + (notRemoveItself ? ". This effect doesn't remove {this}" : ""); } public ProtectionChosenColorAttachedEffect(final ProtectionChosenColorAttachedEffect effect) { diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorSourceEffect.java index 0f441be904..1ef28aae06 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorSourceEffect.java @@ -25,7 +25,7 @@ public class ProtectionChosenColorSourceEffect extends ContinuousEffectImpl { public ProtectionChosenColorSourceEffect() { super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); - staticText = "{source} has protection from the chosen color"; + staticText = "{this} has protection from the chosen color"; } public ProtectionChosenColorSourceEffect(final ProtectionChosenColorSourceEffect effect) { diff --git a/Mage/src/main/java/mage/constants/Duration.java b/Mage/src/main/java/mage/constants/Duration.java index 1b857000ae..7e9e43b5df 100644 --- a/Mage/src/main/java/mage/constants/Duration.java +++ b/Mage/src/main/java/mage/constants/Duration.java @@ -12,7 +12,7 @@ public enum Duration { EndOfTurn("until end of turn", true, true), UntilYourNextTurn("until your next turn", true, true), UntilEndOfYourNextTurn("until the end of your next turn", true, true), - UntilSourceLeavesBattlefield("until {source} leaves the battlefield", true, false), // supported for continuous layered effects + UntilSourceLeavesBattlefield("until {this} leaves the battlefield", true, false), // supported for continuous layered effects EndOfCombat("until end of combat", true, true), EndOfStep("until end of phase step", true, true), Custom("", true, true); diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 47680901cf..ae1289cee1 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -1,5 +1,11 @@ package mage.util; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; import mage.MageObject; import mage.Mana; import mage.abilities.Abilities; @@ -25,13 +31,6 @@ import mage.players.Player; import mage.target.Target; import mage.util.functions.CopyTokenFunction; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.stream.Collectors; - /** * @author nantuko */ @@ -40,10 +39,10 @@ public final class CardUtil { private static final String SOURCE_EXILE_ZONE_TEXT = "SourceExileZone"; static final String[] numberStrings = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", - "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"}; + "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"}; static final String[] ordinalStrings = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eightth", "ninth", - "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth"}; + "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth"}; public static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS"); @@ -242,7 +241,8 @@ public final class CardUtil { * @param spellAbility * @param manaCostsToReduce costs to reduce * @param convertToGeneric colored mana does reduce generic mana if no - * appropriate colored mana is in the costs included + * appropriate colored mana is in the costs + * included */ public static void adjustCost(SpellAbility spellAbility, ManaCosts manaCostsToReduce, boolean convertToGeneric) { ManaCosts previousCost = spellAbility.getManaCostsToPay(); @@ -462,9 +462,7 @@ public final class CardUtil { } public static String replaceSourceName(String message, String sourceName) { - message = message.replace("{this}", sourceName); - message = message.replace("{source}", sourceName); - return message; + return message.replace("{this}", sourceName); } public static String booleanToFlipName(boolean flip) { @@ -767,8 +765,12 @@ public final class CardUtil { // +0/-1 must be -0/-1 String signedP = String.format("%1$+d", power); String signedT = String.format("%1$+d", toughness); - if (signedP.equals("+0") && signedT.startsWith("-")) signedP = "-0"; - if (signedT.equals("+0") && signedP.startsWith("-")) signedT = "-0"; + if (signedP.equals("+0") && signedT.startsWith("-")) { + signedP = "-0"; + } + if (signedT.equals("+0") && signedP.startsWith("-")) { + signedT = "-0"; + } return signedP + "/" + signedT; }