diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java index 5b347cb2a92..770d3b0aaec 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java @@ -396,7 +396,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ { && stackObject.getControllerId().equals(playerId)) { Target target = effect.getTarget(); if (!target.doneChosing()) { - for (UUID targetId : target.possibleTargets(stackObject.getSourceId(), stackObject.getControllerId(), game)) { + for (UUID targetId : target.possibleTargets(stackObject.getControllerId(), stackObject.getStackAbility(), game)) { Game sim = game.copy(); StackAbility newAbility = (StackAbility) stackObject.copy(); SearchEffect newEffect = getSearchEffect(newAbility); diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 6fd185ad7b5..d8cda7dc4f4 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -122,12 +122,12 @@ public class ComputerPlayer extends PlayerImpl implements Player { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { - return choose(outcome, target, sourceId, game, null); + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { + return choose(outcome, target, source, game, null); } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { if (log.isDebugEnabled()) { log.debug("choose: " + outcome.toString() + ':' + target.toString()); @@ -143,9 +143,10 @@ public class ComputerPlayer extends PlayerImpl implements Player { && target.getAbilityController() != null) { abilityControllerId = target.getAbilityController(); } + UUID sourceId = source != null ? source.getSourceId() : null; boolean required = target.isRequired(sourceId, game); - Set possibleTargets = target.possibleTargets(sourceId, abilityControllerId, game); + Set possibleTargets = target.possibleTargets(abilityControllerId, source, game); if (possibleTargets.isEmpty() || target.getTargets().size() >= target.getNumberOfTargets()) { required = false; } @@ -160,7 +161,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } if (target.getOriginalTarget() instanceof TargetPlayer) { - return setTargetPlayer(outcome, target, null, sourceId, abilityControllerId, randomOpponentId, game, required); + return setTargetPlayer(outcome, target, null, abilityControllerId, randomOpponentId, game, required); } if (target.getOriginalTarget() instanceof TargetDiscard) { @@ -191,12 +192,12 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (target.getOriginalTarget() instanceof TargetControlledPermanent) { List targets; TargetControlledPermanent origTarget = (TargetControlledPermanent) target.getOriginalTarget(); - targets = threats(abilityControllerId, sourceId, origTarget.getFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, origTarget.getFilter(), game, target.getTargets()); if (!outcome.isGood()) { Collections.reverse(targets); } for (Permanent permanent : targets) { - if (origTarget.canTarget(abilityControllerId, permanent.getId(), sourceId, game, false) && !target.getTargets().contains(permanent.getId())) { + if (origTarget.canTarget(abilityControllerId, permanent.getId(), source, game, false) && !target.getTargets().contains(permanent.getId())) { target.add(permanent.getId(), game); return true; } @@ -217,18 +218,18 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; if (outcome.isCanTargetAll()) { - targets = threats(null, sourceId, filter, game, target.getTargets()); + targets = threats(null, source, filter, game, target.getTargets()); } else { if (outcome.isGood()) { - targets = threats(abilityControllerId, sourceId, filter, game, target.getTargets()); + targets = threats(abilityControllerId, source, filter, game, target.getTargets()); } else { - targets = threats(randomOpponentId, sourceId, filter, game, target.getTargets()); + targets = threats(randomOpponentId, source, filter, game, target.getTargets()); } if (targets.isEmpty() && target.isRequired()) { if (!outcome.isGood()) { - targets = threats(abilityControllerId, sourceId, filter, game, target.getTargets()); + targets = threats(abilityControllerId, source, filter, game, target.getTargets()); } else { - targets = threats(randomOpponentId, sourceId, filter, game, target.getTargets()); + targets = threats(randomOpponentId, source, filter, game, target.getTargets()); } } } @@ -257,7 +258,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (target.getOriginalTarget() instanceof TargetCardInHand || (target.getZone() == Zone.HAND && (target.getOriginalTarget() instanceof TargetCard))) { List cards = new ArrayList<>(); - for (UUID cardId : target.possibleTargets(sourceId, this.getId(), game)) { + for (UUID cardId : target.possibleTargets(this.getId(), source, game)) { Card card = game.getCard(cardId); if (card != null) { cards.add(card); @@ -278,9 +279,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; TargetAnyTarget origTarget = (TargetAnyTarget) target.getOriginalTarget(); if (outcome.isGood()) { - targets = threats(abilityControllerId, sourceId, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, sourceId, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); } for (Permanent permanent : targets) { List alreadyTargetted = target.getTargets(); @@ -309,9 +310,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; TargetCreatureOrPlayer origTarget = (TargetCreatureOrPlayer) target.getOriginalTarget(); if (outcome.isGood()) { - targets = threats(abilityControllerId, sourceId, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, sourceId, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); } for (Permanent permanent : targets) { List alreadyTargeted = target.getTargets(); @@ -339,8 +340,8 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (target.getOriginalTarget() instanceof TargetPermanentOrPlayer) { List targets; TargetPermanentOrPlayer origTarget = (TargetPermanentOrPlayer) target.getOriginalTarget(); - List ownedTargets = threats(abilityControllerId, sourceId, ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); - List opponentTargets = threats(randomOpponentId, sourceId, ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + List ownedTargets = threats(abilityControllerId, source, ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + List opponentTargets = threats(randomOpponentId, source, ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); if (outcome.isGood()) { targets = ownedTargets; } else { @@ -463,7 +464,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (target.getOriginalTarget() instanceof TargetSource) { Set targets; - targets = target.possibleTargets(sourceId, abilityControllerId, game); + targets = target.possibleTargets(abilityControllerId, source, game); for (UUID targetId : targets) { MageObject targetObject = game.getObject(targetId); if (targetObject != null) { @@ -517,7 +518,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } boolean required = target.isRequired(sourceId, game); - Set possibleTargets = target.possibleTargets(sourceId, abilityControllerId, game); + Set possibleTargets = target.possibleTargets(abilityControllerId, source, game); if (possibleTargets.isEmpty() || target.getTargets().size() >= target.getNumberOfTargets()) { required = false; } @@ -537,7 +538,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } if (target.getOriginalTarget() instanceof TargetPlayer) { - return setTargetPlayer(outcome, target, source, sourceId, abilityControllerId, randomOpponentId, game, required); + return setTargetPlayer(outcome, target, source, abilityControllerId, randomOpponentId, game, required); } // Angel of Serenity trigger @@ -642,7 +643,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (target.getOriginalTarget() instanceof TargetControlledPermanent) { TargetControlledPermanent origTarget = (TargetControlledPermanent) target.getOriginalTarget(); List targets; - targets = threats(abilityControllerId, sourceId, origTarget.getFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, origTarget.getFilter(), game, target.getTargets()); if (!outcome.isGood()) { Collections.reverse(targets); } @@ -671,7 +672,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { + target.getOriginalTarget().getClass().getCanonicalName()); } - findBestPermanentTargets(outcome, abilityControllerId, sourceId, filter, + findBestPermanentTargets(outcome, abilityControllerId, sourceId, source, filter, game, target, goodList, badList, allList); // use good list all the time and add maximum targets @@ -700,9 +701,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; TargetCreatureOrPlayer origTarget = ((TargetCreatureOrPlayer) target.getOriginalTarget()); if (outcome.isGood()) { - targets = threats(abilityControllerId, sourceId, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, sourceId, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, ((FilterCreatureOrPlayer) origTarget.getFilter()).getCreatureFilter(), game, target.getTargets()); } if (targets.isEmpty()) { @@ -742,9 +743,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; TargetAnyTarget origTarget = ((TargetAnyTarget) target.getOriginalTarget()); if (outcome.isGood()) { - targets = threats(abilityControllerId, sourceId, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, sourceId, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, ((FilterCreaturePlayerOrPlaneswalker) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); } if (targets.isEmpty()) { @@ -785,9 +786,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; TargetPermanentOrPlayer origTarget = ((TargetPermanentOrPlayer) target.getOriginalTarget()); if (outcome.isGood()) { - targets = threats(abilityControllerId, source.getSourceId(), ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, source.getSourceId(), ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, ((FilterPermanentOrPlayer) origTarget.getFilter()).getPermanentFilter(), game, target.getTargets()); } if (targets.isEmpty()) { @@ -823,9 +824,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { // normal cycle (good for you, bad for opponents) // possible good/bad permanents if (outcome.isGood()) { - targets = threats(abilityControllerId, source.getSourceId(), ((FilterPermanentOrPlayer) target.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, ((FilterPermanentOrPlayer) target.getFilter()).getPermanentFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, source.getSourceId(), ((FilterPermanentOrPlayer) target.getFilter()).getPermanentFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, ((FilterPermanentOrPlayer) target.getFilter()).getPermanentFilter(), game, target.getTargets()); } // possible good/bad players @@ -930,12 +931,12 @@ public class ComputerPlayer extends PlayerImpl implements Player { List targets; boolean outcomeTargets = true; if (outcome.isGood()) { - targets = threats(abilityControllerId, source == null ? null : source.getSourceId(), origTarget.getPermanentFilter(), game, target.getTargets()); + targets = threats(abilityControllerId, source, origTarget.getPermanentFilter(), game, target.getTargets()); } else { - targets = threats(randomOpponentId, source == null ? null : source.getSourceId(), origTarget.getPermanentFilter(), game, target.getTargets()); + targets = threats(randomOpponentId, source, origTarget.getPermanentFilter(), game, target.getTargets()); } if (targets.isEmpty() && required) { - targets = threats(null, source == null ? null : source.getSourceId(), origTarget.getPermanentFilter(), game, target.getTargets()); + targets = threats(null, source, origTarget.getPermanentFilter(), game, target.getTargets()); Collections.reverse(targets); outcomeTargets = false; } @@ -1008,7 +1009,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } List cards = new ArrayList<>(); - for (UUID uuid : target.possibleTargets(source.getSourceId(), source.getControllerId(), game)) { + for (UUID uuid : target.possibleTargets(source.getControllerId(), source, game)) { Card card = game.getCard(uuid); if (card != null && game.getState().getZone(card.getId()) == Zone.EXILED) { cards.add(card); @@ -1026,7 +1027,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (target.getOriginalTarget() instanceof TargetActivatedAbility) { List stackObjects = new ArrayList<>(); - for (UUID uuid : target.possibleTargets(source.getSourceId(), source.getControllerId(), game)) { + for (UUID uuid : target.possibleTargets(source.getControllerId(), source, game)) { StackObject stackObject = game.getStack().getStackObject(uuid); if (stackObject != null) { stackObjects.add(stackObject); @@ -1129,7 +1130,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { // permanents kill for (UUID opponentId : opponents) { - targets = threats(opponentId, sourceId, StaticFilters.FILTER_PERMANENT_CREATURE_OR_PLANESWALKER_A, game, target.getTargets()); + targets = threats(opponentId, source, StaticFilters.FILTER_PERMANENT_CREATURE_OR_PLANESWALKER_A, game, target.getTargets()); // planeswalker kill for (Permanent permanent : targets) { @@ -1156,9 +1157,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { // own permanents will be checked multiple times... that's ok for (UUID opponentId : opponents) { if (outcome.isGood()) { - targets = threats(getId(), sourceId, StaticFilters.FILTER_PERMANENT, game, target.getTargets()); + targets = threats(getId(), source, StaticFilters.FILTER_PERMANENT, game, target.getTargets()); } else { - targets = threats(opponentId, sourceId, StaticFilters.FILTER_PERMANENT, game, target.getTargets()); + targets = threats(opponentId, source, StaticFilters.FILTER_PERMANENT, game, target.getTargets()); } // planeswalkers @@ -1192,9 +1193,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { for (UUID opponentId : opponents) { if (!outcome.isGood()) { // bad on yourself, uses weakest targets - targets = threats(getId(), sourceId, StaticFilters.FILTER_PERMANENT, game, target.getTargets(), false); + targets = threats(getId(), source, StaticFilters.FILTER_PERMANENT, game, target.getTargets(), false); } else { - targets = threats(opponentId, sourceId, StaticFilters.FILTER_PERMANENT, game, target.getTargets(), false); + targets = threats(opponentId, source, StaticFilters.FILTER_PERMANENT, game, target.getTargets(), false); } // creatures - non killable (TODO: add extra skill checks like undestructeable) @@ -1989,7 +1990,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } // we still use playerId when getting cards even if they don't control the search - List cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), source != null ? source.getSourceId() : null, playerId, game)); + List cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), playerId, source, game)); while (!target.doneChosing()) { Card card = pickTarget(abilityControllerId, cardChoices, outcome, target, source, game); if (card != null) { @@ -2109,7 +2110,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { continue AvailableMode; } } - if (mode.getTargets().canChoose(source.getSourceId(), source.getControllerId(), game)) { // and where targets are available + if (mode.getTargets().canChoose(source.getControllerId(), source, game)) { // and where targets are available return mode; } } @@ -2694,7 +2695,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { return worst; } - protected void findBestPermanentTargets(Outcome outcome, UUID abilityControllerId, UUID sourceId, FilterPermanent filter, Game game, Target target, + protected void findBestPermanentTargets(Outcome outcome, UUID abilityControllerId, UUID sourceId, Ability source, FilterPermanent filter, Game game, Target target, List goodList, List badList, List allList) { // searching for most valuable/powerfull permanents goodList.clear(); @@ -2703,7 +2704,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { List usedTargets = target.getTargets(); // search all - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, abilityControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, abilityControllerId, source, game)) { if (usedTargets.contains(permanent.getId())) { continue; } @@ -2751,19 +2752,19 @@ public class ComputerPlayer extends PlayerImpl implements Player { } } - protected List threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List targets) { - return threats(playerId, sourceId, filter, game, targets, true); + protected List threats(UUID playerId, Ability source, FilterPermanent filter, Game game, List targets) { + return threats(playerId, source, filter, game, targets, true); } - protected List threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List targets, boolean mostValueableGoFirst) { + protected List threats(UUID playerId, Ability source, FilterPermanent filter, Game game, List targets, boolean mostValueableGoFirst) { // most valuable/powerfull permanents goes at first List threats; if (playerId == null) { - threats = game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game); // all permanents within the range of the player + threats = game.getBattlefield().getActivePermanents(filter, this.getId(), source, game); // all permanents within the range of the player } else { FilterPermanent filterCopy = filter.copy(); filterCopy.add(new ControllerIdPredicate(playerId)); - threats = game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game); + threats = game.getBattlefield().getActivePermanents(filter, this.getId(), source, game); } Iterator it = threats.iterator(); while (it.hasNext()) { // remove permanents already targeted @@ -2881,7 +2882,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { * * @param source null on choose and non-null on chooseTarget */ - private boolean setTargetPlayer(Outcome outcome, Target target, Ability source, UUID sourceId, UUID abilityControllerId, UUID randomOpponentId, Game game, boolean required) { + private boolean setTargetPlayer(Outcome outcome, Target target, Ability source, UUID abilityControllerId, UUID randomOpponentId, Game game, boolean required) { Outcome affectedOutcome; if (abilityControllerId == this.playerId) { // selects for itself @@ -2915,6 +2916,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { return false; } + UUID sourceId = source != null ? source.getSourceId() : null; if (target.getOriginalTarget() instanceof TargetPlayer) { if (affectedOutcome.isGood()) { if (source == null) { diff --git a/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java b/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java index f887ca55c93..4eb502940c3 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java +++ b/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/SimulatedPlayerMCTS.java @@ -221,7 +221,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer { } protected boolean chooseRandomTarget(Target target, Ability source, Game game) { - Set possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game); + Set possibleTargets = target.possibleTargets(playerId, source, game); if (possibleTargets.isEmpty()) { return false; } @@ -245,19 +245,19 @@ public class SimulatedPlayerMCTS extends MCTSPlayer { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { if (this.isHuman()) { return chooseRandom(target, game); } - return super.choose(outcome, target, sourceId, game); + return super.choose(outcome, target, source, game); } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { if (this.isHuman()) { return chooseRandom(target, game); } - return super.choose(outcome, target, sourceId, game, options); + return super.choose(outcome, target, source, game, options); } @Override @@ -302,7 +302,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer { @Override public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) { - Set possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game); + Set possibleTargets = target.possibleTargets(playerId, source, game); if (possibleTargets.isEmpty()) { return !target.isRequired(source); } diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java index 097c08ef3b7..18c518cbd21 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java @@ -235,7 +235,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player { if (effect != null && ability.getControllerId().equals(playerId)) { Target target = effect.getTarget(); if (!target.doneChosing()) { - for (UUID targetId: target.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) { + for (UUID targetId: target.possibleTargets(ability.getControllerId(), ability.getStackAbility(), game)) { Game sim = game.copy(); StackAbility newAbility = (StackAbility) ability.copy(); SearchEffect newEffect = getSearchEffect((StackAbility) newAbility); diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index e1898cbe152..65aef6c1d05 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -498,12 +498,12 @@ public class HumanPlayer extends PlayerImpl { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { - return choose(outcome, target, sourceId, game, null); + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { + return choose(outcome, target, source, game, null); } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { if (gameInCheckPlayableState(game)) { return true; } @@ -519,12 +519,12 @@ public class HumanPlayer extends PlayerImpl { } while (canRespond()) { - Set targetIds = target.possibleTargets(sourceId, abilityControllerId, game); + Set targetIds = target.possibleTargets(abilityControllerId, source, game); if (targetIds == null || targetIds.isEmpty()) { return target.getTargets().size() >= target.getNumberOfTargets(); } - boolean required = target.isRequired(sourceId, game); + boolean required = target.isRequired(source != null ? source.getSourceId() : null, game); if (target.getTargets().size() >= target.getNumberOfTargets()) { required = false; } @@ -535,7 +535,7 @@ public class HumanPlayer extends PlayerImpl { updateGameStatePriority("choose(5)", game); prepareForResponse(game); if (!isExecutingMacro()) { - game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(sourceId, game)), targetIds, required, getOptions(target, options)); + game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source.getSourceId(), game)), targetIds, required, getOptions(target, options)); } waitForResponse(game); @@ -554,14 +554,14 @@ public class HumanPlayer extends PlayerImpl { } if (target instanceof TargetPermanent) { - if (((TargetPermanent) target).canTarget(abilityControllerId, responseId, sourceId, game, false)) { + if (((TargetPermanent) target).canTarget(abilityControllerId, responseId, source, game, false)) { target.add(responseId, game); if (target.doneChosing()) { return true; } } } else { - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); if (object instanceof Ability) { if (target.canTarget(responseId, (Ability) object, game)) { if (target.getTargets().contains(responseId)) { // if already included remove it with @@ -617,7 +617,7 @@ public class HumanPlayer extends PlayerImpl { Map options = new HashMap<>(); while (canRespond()) { - Set possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), abilityControllerId, game); + Set possibleTargets = target.possibleTargets(abilityControllerId, source, game); boolean required = target.isRequired(source != null ? source.getSourceId() : null, game); if (possibleTargets.isEmpty() || target.getTargets().size() >= target.getNumberOfTargets()) { @@ -845,7 +845,7 @@ public class HumanPlayer extends PlayerImpl { // 1. Select targets while (canRespond()) { - Set possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), abilityControllerId, game); + Set possibleTargets = target.possibleTargets(abilityControllerId, source, game); boolean required = target.isRequired(source != null ? source.getSourceId() : null, game); if (possibleTargets.isEmpty() || target.getSize() >= target.getNumberOfTargets()) { @@ -979,7 +979,7 @@ public class HumanPlayer extends PlayerImpl { FilterCreatureForCombatBlock filter = filterCreatureForCombatBlock.copy(); filter.add(new ControllerIdPredicate(playerId)); // stop skip on any/zero permanents available - int possibleBlockersCount = game.getBattlefield().count(filter, null, playerId, game); + int possibleBlockersCount = game.getBattlefield().count(filter, playerId, null, game); boolean canStopOnAny = possibleBlockersCount != 0 && getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockersWithAnyPermanents(); boolean canStopOnZero = possibleBlockersCount == 0 && getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockersWithZeroPermanents(); quickStop = canStopOnAny || canStopOnZero; @@ -1605,9 +1605,9 @@ public class HumanPlayer extends PlayerImpl { } else if (responseId != null) { Permanent attacker = game.getPermanent(responseId); if (attacker != null) { - if (filterCreatureForCombat.match(attacker, null, playerId, game)) { + if (filterCreatureForCombat.match(attacker, playerId, null, game)) { selectDefender(game.getCombat().getDefenders(), attacker.getId(), game); - } else if (filterAttack.match(attacker, null, playerId, game) && game.getStack().isEmpty()) { + } else if (filterAttack.match(attacker, playerId, null, game) && game.getStack().isEmpty()) { removeAttackerIfPossible(game, attacker); } } @@ -1772,7 +1772,7 @@ public class HumanPlayer extends PlayerImpl { filter.add(new ControllerIdPredicate(defendingPlayerId)); // stop skip on any/zero permanents available - int possibleBlockersCount = game.getBattlefield().count(filter, null, playerId, game); + int possibleBlockersCount = game.getBattlefield().count(filter, playerId, source, game); boolean canStopOnAny = possibleBlockersCount != 0 && getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockersWithAnyPermanents(); boolean canStopOnZero = possibleBlockersCount == 0 && getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockersWithZeroPermanents(); @@ -1810,9 +1810,9 @@ public class HumanPlayer extends PlayerImpl { if (blocker != null) { boolean removeBlocker = false; // does not block yet and can block or can block more attackers - if (filter.match(blocker, null, playerId, game)) { + if (filter.match(blocker, playerId, source, game)) { selectCombatGroup(defendingPlayerId, blocker.getId(), game); - } else if (filterBlock.match(blocker, null, playerId, game) + } else if (filterBlock.match(blocker, playerId, source, game) && game.getStack().isEmpty()) { removeBlocker = true; } @@ -1892,7 +1892,7 @@ public class HumanPlayer extends PlayerImpl { prepareForResponse(game); if (!isExecutingMacro()) { // possible attackers to block - Set attackers = target.possibleTargets(null, playerId, game); + Set attackers = target.possibleTargets(playerId, null, game); Permanent blocker = game.getPermanent(blockerId); Set possibleTargets = new HashSet<>(); for (UUID attackerId : attackers) { @@ -1932,7 +1932,7 @@ public class HumanPlayer extends PlayerImpl { if (singleTargetName != null) { target.setTargetName(singleTargetName); } - choose(Outcome.Damage, target, source.getSourceId(), game); + choose(Outcome.Damage, target, source, game); if (targets.isEmpty() || targets.contains(target.getFirstTarget())) { int damageAmount = getAmount(0, remainingDamage, "Select amount", game); Permanent permanent = game.getPermanent(target.getFirstTarget()); @@ -2222,7 +2222,7 @@ public class HumanPlayer extends PlayerImpl { if (modes.size() > 1) { // done option for up to choices boolean canEndChoice = modes.getSelectedModes().size() >= modes.getMinModes() || modes.isMayChooseNone(); - MageObject obj = game.getObject(source.getSourceId()); + MageObject obj = game.getObject(source); Map modeMap = new LinkedHashMap<>(); int modeIndex = 0; AvailableModes: @@ -2242,7 +2242,7 @@ public class HumanPlayer extends PlayerImpl { } } - if (mode.getTargets().canChoose(source.getSourceId(), source.getControllerId(), game)) { // and needed targets have to be available + if (mode.getTargets().canChoose(source.getControllerId(), source, game)) { // and needed targets have to be available String modeText = mode.getEffects().getText(mode); if (obj != null) { modeText = modeText.replace("{this}", obj.getName()); diff --git a/Mage.Sets/src/mage/cards/a/Abeyance.java b/Mage.Sets/src/mage/cards/a/Abeyance.java index 5281148c49f..3f6e49e7cc2 100644 --- a/Mage.Sets/src/mage/cards/a/Abeyance.java +++ b/Mage.Sets/src/mage/cards/a/Abeyance.java @@ -68,7 +68,7 @@ class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast instant or sorcery spells or activate abilities " + "that aren't mana abilities this turn (" + mageObject.getIdName() + ")."; diff --git a/Mage.Sets/src/mage/cards/a/AbuJafar.java b/Mage.Sets/src/mage/cards/a/AbuJafar.java index 15d9931ddfa..0747eb9c3e8 100644 --- a/Mage.Sets/src/mage/cards/a/AbuJafar.java +++ b/Mage.Sets/src/mage/cards/a/AbuJafar.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.effects.common.DestroyAllEffect; @@ -9,28 +7,31 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; + +import java.util.UUID; /** - * * @author MarcoMarin */ public final class AbuJafar extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creatures blocking or blocked by it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public AbuJafar(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}"); this.subtype.add(SubType.HUMAN); this.power = new MageInt(0); this.toughness = new MageInt(1); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures blocking or blocked by it"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); - - // When Abu Ja'far dies, destroy all creatures blocking or blocked by it. They can't be regenerated. + // When Abu Ja'far dies, destroy all creatures blocking or blocked by it. They can't be regenerated. this.addAbility(new DiesSourceTriggeredAbility(new DestroyAllEffect(filter, true), false)); } diff --git a/Mage.Sets/src/mage/cards/a/Abundance.java b/Mage.Sets/src/mage/cards/a/Abundance.java index 2e4522f30d4..a7a1f9fed52 100644 --- a/Mage.Sets/src/mage/cards/a/Abundance.java +++ b/Mage.Sets/src/mage/cards/a/Abundance.java @@ -64,7 +64,7 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(event.getPlayerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { FilterCard filter = new FilterCard(); if (controller.chooseUse(Outcome.Detriment, "Choose card type:", @@ -79,7 +79,7 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl { Card selectedCard = null; for (Card card : controller.getLibrary().getCards(game)) { toReveal.add(card); - if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) { + if (filter.match(card, source.getControllerId(), source, game)) { selectedCard = card; break; } diff --git a/Mage.Sets/src/mage/cards/a/AcademyResearchers.java b/Mage.Sets/src/mage/cards/a/AcademyResearchers.java index b6646bf014e..0aaa9bbba05 100644 --- a/Mage.Sets/src/mage/cards/a/AcademyResearchers.java +++ b/Mage.Sets/src/mage/cards/a/AcademyResearchers.java @@ -73,7 +73,7 @@ class AcademyResearchersEffect extends OneShotEffect { if (controller != null && academyResearchers != null) { filterCardInHand.add(new AuraCardCanAttachToPermanentId(academyResearchers.getId())); TargetCardInHand target = new TargetCardInHand(0, 1, filterCardInHand); - if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source, game)) { Card auraInHand = game.getCard(target.getFirstTarget()); if (auraInHand != null) { game.getState().setValue("attachTo:" + auraInHand.getId(), academyResearchers); diff --git a/Mage.Sets/src/mage/cards/a/AcererakTheArchlich.java b/Mage.Sets/src/mage/cards/a/AcererakTheArchlich.java index 6ea9dee4c1e..19f34cfbf69 100644 --- a/Mage.Sets/src/mage/cards/a/AcererakTheArchlich.java +++ b/Mage.Sets/src/mage/cards/a/AcererakTheArchlich.java @@ -103,7 +103,7 @@ class AcererakTheArchlichEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(0, 1); target.setNotTarget(true); - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && permanent.sacrifice(source, game)) { tokens--; diff --git a/Mage.Sets/src/mage/cards/a/AcidicSoil.java b/Mage.Sets/src/mage/cards/a/AcidicSoil.java index ea0ac39142d..be950588e28 100644 --- a/Mage.Sets/src/mage/cards/a/AcidicSoil.java +++ b/Mage.Sets/src/mage/cards/a/AcidicSoil.java @@ -50,7 +50,7 @@ class AcidicSoilEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source, game); for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java b/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java index 58791c6deb2..b206f0338b7 100644 --- a/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java +++ b/Mage.Sets/src/mage/cards/a/AcolyteOfAffliction.java @@ -73,7 +73,7 @@ class AcolyteOfAfflictionEffect extends OneShotEffect { } player.moveCards(player.getLibrary().getTopCards(game, 2), Zone.GRAVEYARD, source, game); TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true); - if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + if (!player.choose(Outcome.ReturnToHand, target, source, game)) { return true; } Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java b/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java index d998ff65bd6..b6542288891 100644 --- a/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java +++ b/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java @@ -63,7 +63,7 @@ class AdviceFromTheFaeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && mageObject != null) { Set topCards = controller.getLibrary().getTopCards(game, 5); Cards cardsFromLibrary = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/a/AerialSurveyor.java b/Mage.Sets/src/mage/cards/a/AerialSurveyor.java index 34b53bc3182..b96d633b7e6 100644 --- a/Mage.Sets/src/mage/cards/a/AerialSurveyor.java +++ b/Mage.Sets/src/mage/cards/a/AerialSurveyor.java @@ -79,10 +79,10 @@ enum AerialSurveyorCondition implements Condition { @Override public boolean apply(Game game, Ability source) { return game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ) > game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); } } @@ -96,7 +96,7 @@ enum AerialSurveyorHint implements Hint { .getActivePermanents( StaticFilters.FILTER_LAND, ability.getControllerId(), - ability.getSourceId(), game + ability, game ).stream() .map(Controllable::getControllerId) .filter(game.getOpponents(ability.getControllerId())::contains) diff --git a/Mage.Sets/src/mage/cards/a/AetherVial.java b/Mage.Sets/src/mage/cards/a/AetherVial.java index b5a9f24d614..10866abda9a 100644 --- a/Mage.Sets/src/mage/cards/a/AetherVial.java +++ b/Mage.Sets/src/mage/cards/a/AetherVial.java @@ -90,7 +90,7 @@ class AetherVialEffect extends OneShotEffect { } TargetCardInHand target = new TargetCardInHand(filter); - if (controller.choose(this.outcome, target, source.getSourceId(), game)) { + if (controller.choose(this.outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { return controller.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java b/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java index b2925e58532..6f252704e5e 100644 --- a/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java +++ b/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java @@ -78,12 +78,12 @@ class AetherbornMarauderEffect extends OneShotEffect { filter.add(AnotherPredicate.instance); filter.add(CounterType.P1P1.getPredicate()); boolean firstRun = true; - while (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + while (game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0) { if (controller.chooseUse(outcome, "Move " + (firstRun ? "any" : "more") + " +1/+1 counters from other permanents you control to " + sourceObject.getLogName() + '?', source, game)) { firstRun = false; TargetControlledPermanent target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game)) { Permanent fromPermanent = game.getPermanent(target.getFirstTarget()); if (fromPermanent != null) { int numberOfCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1); diff --git a/Mage.Sets/src/mage/cards/a/AethermagesTouch.java b/Mage.Sets/src/mage/cards/a/AethermagesTouch.java index 027b033d4c0..ad47780bb23 100644 --- a/Mage.Sets/src/mage/cards/a/AethermagesTouch.java +++ b/Mage.Sets/src/mage/cards/a/AethermagesTouch.java @@ -60,7 +60,7 @@ class AethermagesTouchEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); if (!cards.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/a/Aetherplasm.java b/Mage.Sets/src/mage/cards/a/Aetherplasm.java index 9636bde5c7f..4b935217590 100644 --- a/Mage.Sets/src/mage/cards/a/Aetherplasm.java +++ b/Mage.Sets/src/mage/cards/a/Aetherplasm.java @@ -67,7 +67,7 @@ class AetherplasmEffect extends OneShotEffect { } if (player.chooseUse(Outcome.PutCardInPlay, "Put a creature card from your hand onto the battlefield?", source, game)) { TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE_A); - if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (player.choose(Outcome.PutCardInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { Permanent blockedCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/a/Aetherspouts.java b/Mage.Sets/src/mage/cards/a/Aetherspouts.java index db3a7e1120b..1cb48164069 100644 --- a/Mage.Sets/src/mage/cards/a/Aetherspouts.java +++ b/Mage.Sets/src/mage/cards/a/Aetherspouts.java @@ -81,7 +81,7 @@ class AetherspoutsEffect extends OneShotEffect { do { List permanentsToTop = new ArrayList<>(); List permanentsToBottom = new ArrayList<>(); - for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source, game)) { if (permanent.isOwnedBy(player.getId())) { if (player.chooseUse(outcome, "Put " + permanent.getLogName() + " to the top? (else it goes to bottom)", source, game)) { permanentsToTop.add(permanent); diff --git a/Mage.Sets/src/mage/cards/a/AgadeemOccultist.java b/Mage.Sets/src/mage/cards/a/AgadeemOccultist.java index 99b3654a0e5..f96262b5a87 100644 --- a/Mage.Sets/src/mage/cards/a/AgadeemOccultist.java +++ b/Mage.Sets/src/mage/cards/a/AgadeemOccultist.java @@ -81,8 +81,8 @@ class AgadeemOccultistEffect extends OneShotEffect { TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(1, 1, filter); if (controller != null) { - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.GainControl, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.GainControl, target, source, game)) { if (!target.getTargets().isEmpty()) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/a/AgadeemsAwakening.java b/Mage.Sets/src/mage/cards/a/AgadeemsAwakening.java index eb16de9bef9..75944abd326 100644 --- a/Mage.Sets/src/mage/cards/a/AgadeemsAwakening.java +++ b/Mage.Sets/src/mage/cards/a/AgadeemsAwakening.java @@ -100,8 +100,8 @@ class AgadeemsAwakeningTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Set cmcs = this.getTargets() .stream() .map(game::getCard) diff --git a/Mage.Sets/src/mage/cards/a/AgitatorAnt.java b/Mage.Sets/src/mage/cards/a/AgitatorAnt.java index 71d914889e0..02541574c22 100644 --- a/Mage.Sets/src/mage/cards/a/AgitatorAnt.java +++ b/Mage.Sets/src/mage/cards/a/AgitatorAnt.java @@ -86,7 +86,7 @@ class AgitatorAntEffect extends OneShotEffect { } TargetPermanent targetPermanent = new TargetControlledCreaturePermanent(0, 1); targetPermanent.setNotTarget(true); - player.choose(Outcome.BoostCreature, targetPermanent, source.getSourceId(), game); + player.choose(Outcome.BoostCreature, targetPermanent, source, game); Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget()); if (permanent == null || !permanent.addCounters(CounterType.P1P1.createInstance(2), player.getId(), source, game)) { continue; diff --git a/Mage.Sets/src/mage/cards/a/AidFromTheCowl.java b/Mage.Sets/src/mage/cards/a/AidFromTheCowl.java index 5794ef89141..82d0f16613f 100644 --- a/Mage.Sets/src/mage/cards/a/AidFromTheCowl.java +++ b/Mage.Sets/src/mage/cards/a/AidFromTheCowl.java @@ -65,7 +65,7 @@ class AidFromTheCowlEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/AkiriFearlessVoyager.java b/Mage.Sets/src/mage/cards/a/AkiriFearlessVoyager.java index a7583635ab4..c9dbd3ca820 100644 --- a/Mage.Sets/src/mage/cards/a/AkiriFearlessVoyager.java +++ b/Mage.Sets/src/mage/cards/a/AkiriFearlessVoyager.java @@ -142,11 +142,11 @@ class AkiriFearlessVoyagerEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(1, 1, filter, true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (!target.canChoose(source.getControllerId(), source, game) || !player.chooseUse(outcome, "Unnattach an equipment from a creature you control?", source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent equipment = game.getPermanent(target.getFirstTarget()); if (equipment == null) { return false; diff --git a/Mage.Sets/src/mage/cards/a/AkromaVisionOfIxidor.java b/Mage.Sets/src/mage/cards/a/AkromaVisionOfIxidor.java index d61412fa395..0e86ee06aa8 100644 --- a/Mage.Sets/src/mage/cards/a/AkromaVisionOfIxidor.java +++ b/Mage.Sets/src/mage/cards/a/AkromaVisionOfIxidor.java @@ -104,7 +104,7 @@ class AkromaVisionOfIxidorEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { Abilities abilities = permanent.getAbilities(game); int count = classes diff --git a/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java b/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java index 165adfccda2..f49af6d9d42 100644 --- a/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java +++ b/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java @@ -138,7 +138,7 @@ class AlhammarretHighArbiterCantCastEffect extends ContinuousRuleModifyingEffect @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You may not cast a card named " + cardName + " (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/a/AlibouAncientWitness.java b/Mage.Sets/src/mage/cards/a/AlibouAncientWitness.java index 3fc6f9f0f98..c640759be20 100644 --- a/Mage.Sets/src/mage/cards/a/AlibouAncientWitness.java +++ b/Mage.Sets/src/mage/cards/a/AlibouAncientWitness.java @@ -91,7 +91,7 @@ class AlibouAncientWitnessEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int xValue = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int xValue = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (xValue < 1) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/AlignedHedronNetwork.java b/Mage.Sets/src/mage/cards/a/AlignedHedronNetwork.java index 08a0cbe0a92..6658b9c9e5e 100644 --- a/Mage.Sets/src/mage/cards/a/AlignedHedronNetwork.java +++ b/Mage.Sets/src/mage/cards/a/AlignedHedronNetwork.java @@ -77,7 +77,7 @@ class AlignedHedronNetworkExileEffect extends OneShotEffect { // If Whale leaves the battlefield before its triggered ability resolves, // the target creature won't be exiled. - Set toExile = new LinkedHashSet<>(game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)); + Set toExile = new LinkedHashSet<>(game.getBattlefield().getActivePermanents(filter, controller.getId(), source, game)); if (toExile.isEmpty()) { return false; } controller.moveCardsToExile(toExile, source, game, true, CardUtil.getCardExileZoneId(game, source), permanent.getIdName()); diff --git a/Mage.Sets/src/mage/cards/a/AliveWell.java b/Mage.Sets/src/mage/cards/a/AliveWell.java index d2b9468f9ed..5c10da767e4 100644 --- a/Mage.Sets/src/mage/cards/a/AliveWell.java +++ b/Mage.Sets/src/mage/cards/a/AliveWell.java @@ -66,7 +66,7 @@ class WellEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int life = 2 * game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int life = 2 * game.getBattlefield().count(filter, source.getControllerId(), source, game); player.gainLife(life, game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/AllureOfTheUnknown.java b/Mage.Sets/src/mage/cards/a/AllureOfTheUnknown.java index b48c1b930a2..662e298721f 100644 --- a/Mage.Sets/src/mage/cards/a/AllureOfTheUnknown.java +++ b/Mage.Sets/src/mage/cards/a/AllureOfTheUnknown.java @@ -69,7 +69,7 @@ class AllureOfTheUnknownEffect extends OneShotEffect { return player.moveCards(cards, Zone.HAND, source, game); } TargetOpponent targetOpponent = new TargetOpponent(true); - if (!player.choose(outcome, targetOpponent, source.getSourceId(), game)) { + if (!player.choose(outcome, targetOpponent, source, game)) { return false; } Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java b/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java index 6ef5a39ee3c..6d346dc5f56 100644 --- a/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java +++ b/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java @@ -105,7 +105,7 @@ class AminatouPlusEffect extends OneShotEffect { private boolean putOnLibrary(Player player, Ability source, Game game) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/a/AmuletOfSafekeeping.java b/Mage.Sets/src/mage/cards/a/AmuletOfSafekeeping.java index 00e7a996f11..92ff67533d3 100644 --- a/Mage.Sets/src/mage/cards/a/AmuletOfSafekeeping.java +++ b/Mage.Sets/src/mage/cards/a/AmuletOfSafekeeping.java @@ -82,7 +82,7 @@ class AmuletOfSafekeepingTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { StackObject stackObject = game.getStack().getStackObject(event.getSourceId()); if (event.getTargetId().equals(getControllerId()) - && filter.match(stackObject, getSourceId(), getControllerId(), game)) { + && filter.match(stackObject, getControllerId(), this, game)) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(stackObject.getId(), game)); } diff --git a/Mage.Sets/src/mage/cards/a/AnHavvaConstable.java b/Mage.Sets/src/mage/cards/a/AnHavvaConstable.java index 515be187f3d..98d3da2f8a6 100644 --- a/Mage.Sets/src/mage/cards/a/AnHavvaConstable.java +++ b/Mage.Sets/src/mage/cards/a/AnHavvaConstable.java @@ -68,7 +68,7 @@ class AnHavvaConstableEffect extends ContinuousEffectImpl { FilterCreaturePermanent filter = new FilterCreaturePermanent("green creatures"); filter.add(new ColorPredicate(ObjectColor.GREEN)); - int numberOfGreenCreatures = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int numberOfGreenCreatures = game.getBattlefield().count(filter, source.getSourceId(), source, game); mageObject.getToughness().setValue(1 + numberOfGreenCreatures); diff --git a/Mage.Sets/src/mage/cards/a/AnHavvaInn.java b/Mage.Sets/src/mage/cards/a/AnHavvaInn.java index 0d81cc7e55a..ffab9055d57 100644 --- a/Mage.Sets/src/mage/cards/a/AnHavvaInn.java +++ b/Mage.Sets/src/mage/cards/a/AnHavvaInn.java @@ -59,7 +59,7 @@ class AnHavvaInnEffect extends OneShotEffect { if (player != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent("green creatures"); filter.add(new ColorPredicate(ObjectColor.GREEN)); - int greenCreatures = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int greenCreatures = game.getBattlefield().count(filter, source.getControllerId(), source, game); player.gainLife(greenCreatures+1, game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/Anathemancer.java b/Mage.Sets/src/mage/cards/a/Anathemancer.java index 30aa0af2ec2..5785ab161bc 100644 --- a/Mage.Sets/src/mage/cards/a/Anathemancer.java +++ b/Mage.Sets/src/mage/cards/a/Anathemancer.java @@ -63,8 +63,8 @@ enum AnathemancerCount implements DynamicValue { } return game.getBattlefield().count( StaticFilters.FILTER_LANDS_NONBASIC, - sourceAbility.getFirstTarget(), - sourceAbility.getControllerId(), game + sourceAbility.getControllerId(), + sourceAbility, game ); } diff --git a/Mage.Sets/src/mage/cards/a/AngelOfGlorysRise.java b/Mage.Sets/src/mage/cards/a/AngelOfGlorysRise.java index c8df87128b5..0b663bb191c 100644 --- a/Mage.Sets/src/mage/cards/a/AngelOfGlorysRise.java +++ b/Mage.Sets/src/mage/cards/a/AngelOfGlorysRise.java @@ -72,7 +72,7 @@ class AngelOfGlorysRiseEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Set toExile = new HashSet<>(game.getBattlefield() - .getActivePermanents(new FilterCreaturePermanent(SubType.ZOMBIE, "Zombie"), source.getControllerId(), source.getSourceId(), game)); + .getActivePermanents(new FilterCreaturePermanent(SubType.ZOMBIE, "Zombie"), source.getControllerId(), source, game)); controller.moveCards(toExile, Zone.EXILED, source, game); FilterCreatureCard filterHuman = new FilterCreatureCard(); filterHuman.add(SubType.HUMAN.getPredicate()); diff --git a/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java b/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java index 87bb6c250f6..8fba5e3f25f 100644 --- a/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java +++ b/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java @@ -57,7 +57,7 @@ class AnimalMagnetismEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); if (!cards.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/a/AnimistsAwakening.java b/Mage.Sets/src/mage/cards/a/AnimistsAwakening.java index 840b92bf263..911a2f264d6 100644 --- a/Mage.Sets/src/mage/cards/a/AnimistsAwakening.java +++ b/Mage.Sets/src/mage/cards/a/AnimistsAwakening.java @@ -56,7 +56,7 @@ class AnimistsAwakeningEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } @@ -66,7 +66,7 @@ class AnimistsAwakeningEffect extends OneShotEffect { if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); Set toBattlefield = new LinkedHashSet<>(); - for (Card card : cards.getCards(new FilterLandCard(), source.getSourceId(), source.getControllerId(), game)) { + for (Card card : cards.getCards(new FilterLandCard(), source.getControllerId(), source, game)) { cards.remove(card); toBattlefield.add(card); } diff --git a/Mage.Sets/src/mage/cards/a/AnuridScavenger.java b/Mage.Sets/src/mage/cards/a/AnuridScavenger.java index e72f7b67e57..5f4c455c57d 100644 --- a/Mage.Sets/src/mage/cards/a/AnuridScavenger.java +++ b/Mage.Sets/src/mage/cards/a/AnuridScavenger.java @@ -69,7 +69,7 @@ class AnuridScavengerCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), source, game)) { for (UUID targetId: targets.get(0).getTargets()) { Card card = game.getCard(targetId); if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) { @@ -85,7 +85,7 @@ class AnuridScavengerCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java b/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java index e4b1b4f351c..21fe3683bf5 100644 --- a/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java +++ b/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java @@ -82,7 +82,7 @@ class ArashinWarBeastTriggeredAbility extends TriggeredAbilityImpl { ((DamagedEvent) event).isCombatDamage() && !usedForCombatDamageStep) { Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) { + if (creature == null || !filter.match(creature, getControllerId(), this, game)) { return false; } // trigger only once per combat damage step diff --git a/Mage.Sets/src/mage/cards/a/AraumiOfTheDeadTide.java b/Mage.Sets/src/mage/cards/a/AraumiOfTheDeadTide.java index 2a54189e348..3bdd5b9c706 100644 --- a/Mage.Sets/src/mage/cards/a/AraumiOfTheDeadTide.java +++ b/Mage.Sets/src/mage/cards/a/AraumiOfTheDeadTide.java @@ -96,7 +96,7 @@ class AraumiOfTheDeadTideCost extends CostImpl { int oppCount = game.getOpponents(controllerId).size(); TargetCard target = new TargetCardInYourGraveyard(oppCount, StaticFilters.FILTER_CARD); target.setNotTarget(true); - player.choose(Outcome.Exile, target, source.getSourceId(), game); + player.choose(Outcome.Exile, target, source, game); Cards cards = new CardsImpl(target.getTargets()); if (cards.size() < oppCount) { return paid; diff --git a/Mage.Sets/src/mage/cards/a/Arcbond.java b/Mage.Sets/src/mage/cards/a/Arcbond.java index 8e3f19ea1bf..06ae06950e5 100644 --- a/Mage.Sets/src/mage/cards/a/Arcbond.java +++ b/Mage.Sets/src/mage/cards/a/Arcbond.java @@ -130,7 +130,7 @@ class ArcbondEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int damage = (Integer) this.getValue("damage"); UUID sourceId = (UUID) this.getValue("sourceId"); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && damage > 0 && sourceId != null) { Permanent targetObject = game.getPermanentOrLKIBattlefield(sourceId); if (targetObject != null) { diff --git a/Mage.Sets/src/mage/cards/a/ArchaeomancersMap.java b/Mage.Sets/src/mage/cards/a/ArchaeomancersMap.java index 39918d13917..9f97adf0fab 100644 --- a/Mage.Sets/src/mage/cards/a/ArchaeomancersMap.java +++ b/Mage.Sets/src/mage/cards/a/ArchaeomancersMap.java @@ -72,10 +72,10 @@ enum ArchaeomancersMapCondition implements Condition { UUID playerId = (UUID) source.getEffects().get(0).getValue("permanentEnteringControllerId"); return playerId != null && game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), playerId, game + playerId, source, game ) > game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); } } diff --git a/Mage.Sets/src/mage/cards/a/ArchdemonOfGreed.java b/Mage.Sets/src/mage/cards/a/ArchdemonOfGreed.java index b8127b27631..6fcb910e12a 100644 --- a/Mage.Sets/src/mage/cards/a/ArchdemonOfGreed.java +++ b/Mage.Sets/src/mage/cards/a/ArchdemonOfGreed.java @@ -84,8 +84,8 @@ public final class ArchdemonOfGreed extends CardImpl { if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); // if they can pay the cost, then they must pay - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); Permanent humanSacrifice = game.getPermanent(target.getFirstTarget()); if (humanSacrifice != null) { // sacrifice the chosen card diff --git a/Mage.Sets/src/mage/cards/a/ArchfiendOfDepravity.java b/Mage.Sets/src/mage/cards/a/ArchfiendOfDepravity.java index 76864cb6176..52b712d9714 100644 --- a/Mage.Sets/src/mage/cards/a/ArchfiendOfDepravity.java +++ b/Mage.Sets/src/mage/cards/a/ArchfiendOfDepravity.java @@ -73,7 +73,7 @@ class ArchfiendOfDepravityEffect extends OneShotEffect { List creaturesToSacrifice = new ArrayList<>(); TargetControlledPermanent target = new TargetControlledPermanent(0, 2, new FilterControlledCreaturePermanent("creatures to keep"), true); if (opponent.chooseTarget(outcome, target, source, game)) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), opponent.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), opponent.getId(), source, game)) { if (permanent != null && !target.getTargets().contains(permanent.getId())) { creaturesToSacrifice.add(permanent); } diff --git a/Mage.Sets/src/mage/cards/a/ArcticFoxes.java b/Mage.Sets/src/mage/cards/a/ArcticFoxes.java index d6b86a7d425..c75d0b58019 100644 --- a/Mage.Sets/src/mage/cards/a/ArcticFoxes.java +++ b/Mage.Sets/src/mage/cards/a/ArcticFoxes.java @@ -68,6 +68,6 @@ enum ArcticFoxesCondition implements Condition { if (defenderId == null) { return false; } - return game.getBattlefield().contains(filter, source.getSourceId(), defenderId, game, 1); + return game.getBattlefield().contains(filter, source.getSourceId(), defenderId, source, game, 1); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/a/ArdennIntrepidArchaeologist.java b/Mage.Sets/src/mage/cards/a/ArdennIntrepidArchaeologist.java index fbd5b292ad1..4f8f9e25d32 100644 --- a/Mage.Sets/src/mage/cards/a/ArdennIntrepidArchaeologist.java +++ b/Mage.Sets/src/mage/cards/a/ArdennIntrepidArchaeologist.java @@ -88,7 +88,7 @@ class ArdennIntrepidArchaeologistEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); for (UUID targetId : target.getTargets()) { if (player != null) { player.addAttachment(targetId, source, game); diff --git a/Mage.Sets/src/mage/cards/a/ArdentDustspeaker.java b/Mage.Sets/src/mage/cards/a/ArdentDustspeaker.java index 1d8f14d44ba..a5317238953 100644 --- a/Mage.Sets/src/mage/cards/a/ArdentDustspeaker.java +++ b/Mage.Sets/src/mage/cards/a/ArdentDustspeaker.java @@ -79,7 +79,7 @@ class ArdentDustspeakerCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/a/ArmedAndArmored.java b/Mage.Sets/src/mage/cards/a/ArmedAndArmored.java index 29e95ca5bef..d101a746b06 100644 --- a/Mage.Sets/src/mage/cards/a/ArmedAndArmored.java +++ b/Mage.Sets/src/mage/cards/a/ArmedAndArmored.java @@ -108,12 +108,12 @@ class ArmedAndArmoredEquipEffect extends OneShotEffect { if (!dwarves.isEmpty() && !equipment.isEmpty()) { TargetPermanent target = new TargetPermanent(0, 1, dwarfFilter, true); target.withChooseHint("dwarf to be equipped"); - controller.choose(outcome, target, source.getId(), game); + controller.choose(outcome, target, source, game); Permanent dwarf = game.getPermanent(target.getFirstTarget()); if (dwarf != null) { target = new TargetPermanent(0, Integer.MAX_VALUE, equipmentFilter, true); target.withChooseHint("equip to " + dwarf.getLogName()); - controller.choose(outcome, target, source.getId(), game); + controller.choose(outcome, target, source, game); for (UUID targetId : target.getTargets()) { dwarf.addAttachment(targetId, source, game); game.informPlayers(game.getPermanent(targetId).getLogName() + " was attached to " + dwarf.getLogName()); diff --git a/Mage.Sets/src/mage/cards/a/ArmoredSkyhunter.java b/Mage.Sets/src/mage/cards/a/ArmoredSkyhunter.java index a4d57dfa177..9c20073645b 100644 --- a/Mage.Sets/src/mage/cards/a/ArmoredSkyhunter.java +++ b/Mage.Sets/src/mage/cards/a/ArmoredSkyhunter.java @@ -100,7 +100,7 @@ class ArmoredSkyhunterEffect extends OneShotEffect { } TargetPermanent targetPermanent = new TargetControlledCreaturePermanent(0, 1); targetCard.setNotTarget(true); - player.choose(outcome, targetPermanent, source.getSourceId(), game); + player.choose(outcome, targetPermanent, source, game); Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget()); if (permanent != null) { permanent.addAttachment(equipment.getId(), source, game); diff --git a/Mage.Sets/src/mage/cards/a/ArmoryAutomaton.java b/Mage.Sets/src/mage/cards/a/ArmoryAutomaton.java index db3852831e7..8ea11d805a0 100644 --- a/Mage.Sets/src/mage/cards/a/ArmoryAutomaton.java +++ b/Mage.Sets/src/mage/cards/a/ArmoryAutomaton.java @@ -88,7 +88,7 @@ class ArmoryAutomatonEffect extends OneShotEffect { while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.Benefit, "Select and attach a target Equipment?", source, game)) { Target targetEquipment = new TargetPermanent(currentFilter); targetEquipment.setRequired(false); - if (player.choose(Outcome.Benefit, targetEquipment, source.getSourceId(), game) && targetEquipment.getFirstTarget() != null) { + if (player.choose(Outcome.Benefit, targetEquipment, source, game) && targetEquipment.getFirstTarget() != null) { currentFilter.add(Predicates.not(new PermanentIdPredicate(targetEquipment.getFirstTarget()))); // exclude selected for next time Permanent aura = game.getPermanent(targetEquipment.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/a/ArniBrokenbrow.java b/Mage.Sets/src/mage/cards/a/ArniBrokenbrow.java index b7531af26b7..c930da96a01 100644 --- a/Mage.Sets/src/mage/cards/a/ArniBrokenbrow.java +++ b/Mage.Sets/src/mage/cards/a/ArniBrokenbrow.java @@ -69,7 +69,7 @@ class ArniBrokenbrowEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller == null || mageObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/ArsenalThresher.java b/Mage.Sets/src/mage/cards/a/ArsenalThresher.java index 168f8b8e264..a9d3f5eb3ae 100644 --- a/Mage.Sets/src/mage/cards/a/ArsenalThresher.java +++ b/Mage.Sets/src/mage/cards/a/ArsenalThresher.java @@ -14,7 +14,7 @@ import mage.constants.Outcome; import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.common.FilterArtifactCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -75,12 +75,12 @@ class ArsenalThresherEffect extends OneShotEffect { } Permanent arsenalThresher = game.getPermanentEntering(source.getSourceId()); FilterArtifactCard filter = new FilterArtifactCard(); - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); if (controller.chooseUse(Outcome.Benefit, "Reveal other artifacts in your hand?", source, game)) { Cards cards = new CardsImpl(); - if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + if (controller.getHand().count(filter, source.getControllerId(), source, game) > 0) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter); - if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Benefit, target, source, game)) { for (UUID uuid : target.getTargets()) { cards.add(controller.getHand().get(uuid, game)); } diff --git a/Mage.Sets/src/mage/cards/a/ArterialAlchemy.java b/Mage.Sets/src/mage/cards/a/ArterialAlchemy.java index 9fc51df6f9d..0750354b54e 100644 --- a/Mage.Sets/src/mage/cards/a/ArterialAlchemy.java +++ b/Mage.Sets/src/mage/cards/a/ArterialAlchemy.java @@ -74,7 +74,7 @@ class ArterialAlchemyEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { switch (layer) { case TypeChangingEffects_4: diff --git a/Mage.Sets/src/mage/cards/a/AryelKnightOfWindgrace.java b/Mage.Sets/src/mage/cards/a/AryelKnightOfWindgrace.java index 5c493e33179..59d17c42819 100644 --- a/Mage.Sets/src/mage/cards/a/AryelKnightOfWindgrace.java +++ b/Mage.Sets/src/mage/cards/a/AryelKnightOfWindgrace.java @@ -95,7 +95,7 @@ class AryelTapXTargetCost extends VariableCostImpl { @Override public int getMaxValue(Ability source, Game game) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + return game.getBattlefield().count(filter, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/a/AsForetold.java b/Mage.Sets/src/mage/cards/a/AsForetold.java index d80d0d64748..e4b281fa86d 100644 --- a/Mage.Sets/src/mage/cards/a/AsForetold.java +++ b/Mage.Sets/src/mage/cards/a/AsForetold.java @@ -69,7 +69,7 @@ class SpellWithManaCostLessThanOrEqualToCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && !object.isLand(game) && object.getManaValue() <= counters; diff --git a/Mage.Sets/src/mage/cards/a/AscendantAcolyte.java b/Mage.Sets/src/mage/cards/a/AscendantAcolyte.java index dfeafe2aa0c..464c364c675 100644 --- a/Mage.Sets/src/mage/cards/a/AscendantAcolyte.java +++ b/Mage.Sets/src/mage/cards/a/AscendantAcolyte.java @@ -71,7 +71,7 @@ enum AscendantAcolyteValue implements DynamicValue { .getActivePermanents( StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, sourceAbility.getControllerId(), - sourceAbility.getSourceId(), game + sourceAbility, game ).stream() .mapToInt(permanent -> permanent.getCounters(game).getCount(CounterType.P1P1)) .sum(); diff --git a/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java b/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java index c8c9b689e43..60d61305991 100644 --- a/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java +++ b/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java @@ -87,10 +87,10 @@ class AscentOfTheWorthyEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } - player.choose(outcome, target, source.getControllerId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/a/AshayaSoulOfTheWild.java b/Mage.Sets/src/mage/cards/a/AshayaSoulOfTheWild.java index 010985ee806..64bf0edd602 100644 --- a/Mage.Sets/src/mage/cards/a/AshayaSoulOfTheWild.java +++ b/Mage.Sets/src/mage/cards/a/AshayaSoulOfTheWild.java @@ -77,7 +77,7 @@ class AshayaSoulOfTheWildEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { if (!permanent.isLand(game)) { permanent.addCardType(game, CardType.LAND); diff --git a/Mage.Sets/src/mage/cards/a/AshiokDreamRender.java b/Mage.Sets/src/mage/cards/a/AshiokDreamRender.java index cd5f208f858..abfd27ec50e 100644 --- a/Mage.Sets/src/mage/cards/a/AshiokDreamRender.java +++ b/Mage.Sets/src/mage/cards/a/AshiokDreamRender.java @@ -73,7 +73,7 @@ class AshiokDreamRenderEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't search libraries (" + mageObject.getLogName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java b/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java index e44f88853b7..eb4fd3b2afd 100644 --- a/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java +++ b/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java @@ -120,7 +120,7 @@ class AshiokNightmareWeaverPutIntoPlayEffect extends OneShotEffect { Target target = new TargetCardInExile(filter, CardUtil.getExileZoneId(game, source)); - if (!target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (!target.canChoose(controller.getId(), source, game)) { return false; } controller.chooseTarget(Outcome.PutCreatureInPlay, target, source, game); diff --git a/Mage.Sets/src/mage/cards/a/AspectOfWolf.java b/Mage.Sets/src/mage/cards/a/AspectOfWolf.java index 8eb1359d2d1..3c1326272b9 100644 --- a/Mage.Sets/src/mage/cards/a/AspectOfWolf.java +++ b/Mage.Sets/src/mage/cards/a/AspectOfWolf.java @@ -66,7 +66,7 @@ enum AspectOfWolfValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int forestCount = game.getBattlefield().count( - filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + filter, sourceAbility.getControllerId(), sourceAbility, game ); return forestCount / 2 + (up ? forestCount % 2 : 0); } diff --git a/Mage.Sets/src/mage/cards/a/AssemblyHall.java b/Mage.Sets/src/mage/cards/a/AssemblyHall.java index 83960e895e8..b9a5055a3a3 100644 --- a/Mage.Sets/src/mage/cards/a/AssemblyHall.java +++ b/Mage.Sets/src/mage/cards/a/AssemblyHall.java @@ -70,7 +70,7 @@ class AssemblyHallEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || controller.getHand().isEmpty() || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java b/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java index 4eb29bcf77f..219303f4980 100644 --- a/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java +++ b/Mage.Sets/src/mage/cards/a/AtarkaWorldRender.java @@ -82,7 +82,7 @@ class AtarkaWorldRenderEffect extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent attacker = game.getPermanent(event.getSourceId()); if (attacker != null - && filter.match(attacker, sourceId, controllerId, game)) { + && filter.match(attacker, controllerId, this, game)) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(attacker.getId(), game)); } diff --git a/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java b/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java index d7fc7e9a137..10764d4ef63 100644 --- a/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java +++ b/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java @@ -144,7 +144,7 @@ class AthreosDiesCreatureTriggeredAbility extends TriggeredAbilityImpl { if (!zEvent.isDiesEvent()) { return false; } - if (zEvent.getTarget() == null || !filter.match(zEvent.getTarget(), sourceId, controllerId, game)) { + if (zEvent.getTarget() == null || !filter.match(zEvent.getTarget(), controllerId, this, game)) { return false; } for (Effect effect : this.getEffects()) { diff --git a/Mage.Sets/src/mage/cards/a/AugurOfBolas.java b/Mage.Sets/src/mage/cards/a/AugurOfBolas.java index ded15a1cb91..7093d3ca9d2 100644 --- a/Mage.Sets/src/mage/cards/a/AugurOfBolas.java +++ b/Mage.Sets/src/mage/cards/a/AugurOfBolas.java @@ -72,18 +72,18 @@ class AugurOfBolasEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards topCards = new CardsImpl(); topCards.addAll(controller.getLibrary().getTopCards(game, 3)); if (!topCards.isEmpty()) { controller.lookAtCards(sourceObject.getIdName(), topCards, game); - int number = topCards.count(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game); + int number = topCards.count(new FilterInstantOrSorceryCard(), source.getControllerId(), source, game); if (number > 0) { if (controller.chooseUse(outcome, "Reveal an instant or sorcery card from the looked at cards and put it into your hand?", source, game)) { Card card = null; if (number == 1) { - Set cards = topCards.getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game); + Set cards = topCards.getCards(new FilterInstantOrSorceryCard(), source.getControllerId(), source, game); if (!cards.isEmpty()) { card = cards.iterator().next(); } diff --git a/Mage.Sets/src/mage/cards/a/AuntiesSnitch.java b/Mage.Sets/src/mage/cards/a/AuntiesSnitch.java index 7432bd05b7c..a57287ace22 100644 --- a/Mage.Sets/src/mage/cards/a/AuntiesSnitch.java +++ b/Mage.Sets/src/mage/cards/a/AuntiesSnitch.java @@ -18,7 +18,6 @@ import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -83,7 +82,7 @@ class AuntiesSnitchTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event; Permanent p = game.getPermanent(event.getSourceId()); - return damageEvent.isCombatDamage() && filter.match(p, getSourceId(), getControllerId(), game); + return damageEvent.isCombatDamage() && filter.match(p, getControllerId(), this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/a/AuraBarbs.java b/Mage.Sets/src/mage/cards/a/AuraBarbs.java index 9fc5d9157e6..175efc7aad2 100644 --- a/Mage.Sets/src/mage/cards/a/AuraBarbs.java +++ b/Mage.Sets/src/mage/cards/a/AuraBarbs.java @@ -54,7 +54,7 @@ public final class AuraBarbs extends CardImpl { FilterPermanent filterEnchantments = new FilterPermanent(); filterEnchantments.add(CardType.ENCHANTMENT.getPredicate()); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source, game)) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null) { controller.damage(2, permanent.getId(), source, game); @@ -63,7 +63,7 @@ public final class AuraBarbs extends CardImpl { } filterEnchantments.add(SubType.AURA.getPredicate()); - for (Permanent auraEnchantment : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent auraEnchantment : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source, game)) { if (auraEnchantment.getAttachedTo() != null) { Permanent attachedToCreature = game.getPermanent(auraEnchantment.getAttachedTo()); if (attachedToCreature != null && attachedToCreature.isCreature(game)) { diff --git a/Mage.Sets/src/mage/cards/a/AuraGraft.java b/Mage.Sets/src/mage/cards/a/AuraGraft.java index 27fad23790d..82397b57a6e 100644 --- a/Mage.Sets/src/mage/cards/a/AuraGraft.java +++ b/Mage.Sets/src/mage/cards/a/AuraGraft.java @@ -123,8 +123,8 @@ class MoveTargetAuraEffect extends OneShotEffect { filter.add(new PermanentCanBeAttachedToPredicate(enchantment)); Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(oldAttachment.getId(), controller.getId(), game) - && controller.choose(outcome, target, oldAttachment.getId(), game)) { + if (target.canChoose(controller.getId(), source, game) + && controller.choose(outcome, target, source, game)) { Permanent newAttachment = game.getPermanent(target.getFirstTarget()); if (newAttachment != null && oldAttachment.removeAttachment(enchantment.getId(), source, game)) { diff --git a/Mage.Sets/src/mage/cards/a/AuraThief.java b/Mage.Sets/src/mage/cards/a/AuraThief.java index 792ea8b9874..90026e5f609 100644 --- a/Mage.Sets/src/mage/cards/a/AuraThief.java +++ b/Mage.Sets/src/mage/cards/a/AuraThief.java @@ -71,7 +71,7 @@ class AuraThiefDiesTriggeredEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { boolean ret = false; - for(Permanent enchantment : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source.getControllerId(), game)) { + for(Permanent enchantment : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) { ContinuousEffect gainControl = new GainControlTargetEffect(Duration.EndOfGame); gainControl.setTargetPointer(new FixedTarget(enchantment.getId(), game)); game.addEffect(gainControl, source); diff --git a/Mage.Sets/src/mage/cards/a/AureliasFury.java b/Mage.Sets/src/mage/cards/a/AureliasFury.java index 5d5e32a7c5d..3ce2d3b5357 100644 --- a/Mage.Sets/src/mage/cards/a/AureliasFury.java +++ b/Mage.Sets/src/mage/cards/a/AureliasFury.java @@ -140,7 +140,7 @@ class AureliasFuryCantCastEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast noncreature spells this turn (you were dealt damage by " + mageObject.getLogName() + ')'; } diff --git a/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java b/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java index ff4648cf3e4..3aeda316adf 100644 --- a/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java +++ b/Mage.Sets/src/mage/cards/a/AurraSingBaneOfJedi.java @@ -111,7 +111,7 @@ class SacrificeAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getId(), game); + List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game); for (Permanent p : permanents) { p.sacrifice(source, game); } diff --git a/Mage.Sets/src/mage/cards/a/AvenShrine.java b/Mage.Sets/src/mage/cards/a/AvenShrine.java index 43bd4c8b79a..fa652eef316 100644 --- a/Mage.Sets/src/mage/cards/a/AvenShrine.java +++ b/Mage.Sets/src/mage/cards/a/AvenShrine.java @@ -90,7 +90,7 @@ class AvenShrineEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int count = 0; - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if(mageObject != null) { Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject); if (spell != null) { diff --git a/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java b/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java index 1fae3a76be9..647c2d9c61c 100644 --- a/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java +++ b/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java @@ -81,7 +81,7 @@ class AvenSoulgazerLookFaceDownEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (player == null || mageObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/AzorTheLawbringer.java b/Mage.Sets/src/mage/cards/a/AzorTheLawbringer.java index 49c90ae4d72..4a1b428af29 100644 --- a/Mage.Sets/src/mage/cards/a/AzorTheLawbringer.java +++ b/Mage.Sets/src/mage/cards/a/AzorTheLawbringer.java @@ -113,7 +113,7 @@ class AzorTheLawbringerCantCastEffect extends ContinuousRuleModifyingEffectImpl @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast instant or sorcery spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/a/AzoriusAethermage.java b/Mage.Sets/src/mage/cards/a/AzoriusAethermage.java index 75c3de932e4..10a0b598ab1 100644 --- a/Mage.Sets/src/mage/cards/a/AzoriusAethermage.java +++ b/Mage.Sets/src/mage/cards/a/AzoriusAethermage.java @@ -80,7 +80,7 @@ class AzoriusAEthermageAbility extends TriggeredAbilityImpl { return false; } - return StaticFilters.FILTER_PERMANENT_CREATURE.match(permanentThatMoved, sourceId, controllerId, game); + return StaticFilters.FILTER_PERMANENT_CREATURE.match(permanentThatMoved, controllerId, this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/a/AzorsGateway.java b/Mage.Sets/src/mage/cards/a/AzorsGateway.java index c43cb154c98..18e42b3e952 100644 --- a/Mage.Sets/src/mage/cards/a/AzorsGateway.java +++ b/Mage.Sets/src/mage/cards/a/AzorsGateway.java @@ -87,7 +87,7 @@ class AzorsGatewayEffect extends OneShotEffect { controller.drawCards(1, source, game); TargetCardInHand target = new TargetCardInHand(); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card cardToExile = game.getCard(target.getFirstTarget()); if (cardToExile != null) { controller.moveCardsToExile(cardToExile, source, game, true, exileId, sourceObject.getIdName()); diff --git a/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java b/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java index 4a73bdf6af4..46ec46c4431 100644 --- a/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java +++ b/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java @@ -75,7 +75,7 @@ class AzraBladeseekerEffect extends OneShotEffect { continue; } Target target = new TargetDiscard(playerId); - if (target.choose(Outcome.DrawCard, playerId, source.getSourceId(), game)) { + if (target.choose(Outcome.DrawCard, playerId, source.getSourceId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { playerCardList.add(new PlayerCard(player, card)); diff --git a/Mage.Sets/src/mage/cards/a/AzraOddsmaker.java b/Mage.Sets/src/mage/cards/a/AzraOddsmaker.java index c119b222b78..28f4dc7f6b7 100644 --- a/Mage.Sets/src/mage/cards/a/AzraOddsmaker.java +++ b/Mage.Sets/src/mage/cards/a/AzraOddsmaker.java @@ -82,7 +82,7 @@ class AzraOddsmakerEffect extends OneShotEffect { Permanent permanent = null; TargetCreaturePermanent target = new TargetCreaturePermanent(); target.setNotTarget(true); - if (player.choose(Outcome.DrawCard, target, source.getSourceId(), game)) { + if (player.choose(Outcome.DrawCard, target, source, game)) { permanent = game.getPermanent(target.getFirstTarget()); } if (permanent == null) { diff --git a/Mage.Sets/src/mage/cards/b/BINGO.java b/Mage.Sets/src/mage/cards/b/BINGO.java index c02556c1903..979e459faa3 100644 --- a/Mage.Sets/src/mage/cards/b/BINGO.java +++ b/Mage.Sets/src/mage/cards/b/BINGO.java @@ -83,7 +83,7 @@ class BingoEffect extends OneShotEffect { if (spell.getManaValue() > 9) { return true; } - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { Map chipCounters = new HashMap<>(); // Map if (game.getState().getValue(mageObject.getId() + "_chip") != null) { diff --git a/Mage.Sets/src/mage/cards/b/BackFromTheBrink.java b/Mage.Sets/src/mage/cards/b/BackFromTheBrink.java index 54c0b94a254..7f326f2d9b3 100644 --- a/Mage.Sets/src/mage/cards/b/BackFromTheBrink.java +++ b/Mage.Sets/src/mage/cards/b/BackFromTheBrink.java @@ -67,12 +67,12 @@ class BackFromTheBrinkCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { Player controller = game.getPlayer(controllerId); if (controller != null) { Card card = controller.getGraveyard().get(targets.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/b/BagOfDevouring.java b/Mage.Sets/src/mage/cards/b/BagOfDevouring.java index b223aa83345..c0a57fc5eb0 100644 --- a/Mage.Sets/src/mage/cards/b/BagOfDevouring.java +++ b/Mage.Sets/src/mage/cards/b/BagOfDevouring.java @@ -113,7 +113,7 @@ class BagOfDevouringEffect extends OneShotEffect { CardUtil.getExileZoneId(game, source) ); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/b/BakisCurse.java b/Mage.Sets/src/mage/cards/b/BakisCurse.java index 0afce6934a4..78b4627151d 100644 --- a/Mage.Sets/src/mage/cards/b/BakisCurse.java +++ b/Mage.Sets/src/mage/cards/b/BakisCurse.java @@ -55,7 +55,7 @@ class BakisCurseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source, game)) { int count = 0; List attachments = creature.getAttachments(); for (UUID attachmentId : attachments) { diff --git a/Mage.Sets/src/mage/cards/b/BalancingAct.java b/Mage.Sets/src/mage/cards/b/BalancingAct.java index 45403e59038..d0c157143b9 100644 --- a/Mage.Sets/src/mage/cards/b/BalancingAct.java +++ b/Mage.Sets/src/mage/cards/b/BalancingAct.java @@ -64,7 +64,7 @@ class BalancingActEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getSourceId(), game).size(); + int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source, game).size(); if (count < minPermanent) { minPermanent = count; } @@ -75,8 +75,8 @@ class BalancingActEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(minPermanent, minPermanent, new FilterControlledPermanent(), true); - if (target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), game)) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source, game)) { if (permanent != null && !target.getTargets().contains(permanent.getId())) { permanent.sacrifice(source, game); } @@ -101,7 +101,7 @@ class BalancingActEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard()); - if (target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game)) { Cards cards = player.getHand().copy(); cards.removeIf(target.getTargets()::contains); player.discard(cards, false, source, game); diff --git a/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java b/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java index 6bb41553fa1..51276efd26e 100644 --- a/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java +++ b/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java @@ -115,8 +115,8 @@ class BalduvianWarlordUnblockEffect extends OneShotEffect { FilterAttackingCreature filter = new FilterAttackingCreature("creature attacking " + targetsController.getLogName()); filter.add(new PermanentInListPredicate(list)); TargetAttackingCreature target = new TargetAttackingCreature(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } else { diff --git a/Mage.Sets/src/mage/cards/b/BalthorTheDefiled.java b/Mage.Sets/src/mage/cards/b/BalthorTheDefiled.java index 2328627e1b5..46bb525f73f 100644 --- a/Mage.Sets/src/mage/cards/b/BalthorTheDefiled.java +++ b/Mage.Sets/src/mage/cards/b/BalthorTheDefiled.java @@ -89,7 +89,7 @@ class BalthorTheDefiledEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - cardsToReturn.addAll(player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)); + cardsToReturn.addAll(player.getGraveyard().getCards(filter, source.getControllerId(), source, game)); } } controller.moveCards(cardsToReturn.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); diff --git a/Mage.Sets/src/mage/cards/b/BaneOfProgress.java b/Mage.Sets/src/mage/cards/b/BaneOfProgress.java index 609daa3db66..b452f1339f6 100644 --- a/Mage.Sets/src/mage/cards/b/BaneOfProgress.java +++ b/Mage.Sets/src/mage/cards/b/BaneOfProgress.java @@ -70,7 +70,7 @@ class BaneOfProgressEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int destroyedPermanents = 0; - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent.destroy(source, game, false)) { destroyedPermanents++; } diff --git a/Mage.Sets/src/mage/cards/b/BaneclawMarauder.java b/Mage.Sets/src/mage/cards/b/BaneclawMarauder.java index 2a2394c962e..e158a3c738f 100644 --- a/Mage.Sets/src/mage/cards/b/BaneclawMarauder.java +++ b/Mage.Sets/src/mage/cards/b/BaneclawMarauder.java @@ -1,7 +1,6 @@ package mage.cards.b; import mage.MageInt; -import mage.MageObjectReference; import mage.abilities.common.BecomesBlockedSourceTriggeredAbility; import mage.abilities.common.DiesCreatureTriggeredAbility; import mage.abilities.effects.common.LoseLifeTargetControllerEffect; @@ -12,18 +11,10 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.SubType; -import mage.constants.WatcherScope; -import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.ObjectSourcePlayer; -import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.watchers.Watcher; -import java.util.*; +import java.util.UUID; /** * @author TheElk801 @@ -31,11 +22,9 @@ import java.util.*; public final class BaneclawMarauder extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); - private static final FilterPermanent filter2 = new FilterCreaturePermanent("a creature blocking {this}"); static { filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); - filter2.add(BaneclawMarauderPredicate.instance); } public BaneclawMarauder(UUID ownerId, CardSetInfo setInfo) { @@ -56,8 +45,8 @@ public final class BaneclawMarauder extends CardImpl { this.addAbility(new DiesCreatureTriggeredAbility( new LoseLifeTargetControllerEffect(1) .setText("that creature's controller loses 1 life"), - false, filter2, true - ), new BaneclawMarauderWatcher()); + false, filter, true + )); // Nightbound this.addAbility(new NightboundAbility()); @@ -72,55 +61,3 @@ public final class BaneclawMarauder extends CardImpl { return new BaneclawMarauder(this); } } - -enum BaneclawMarauderPredicate implements ObjectSourcePlayerPredicate { - instance; - - @Override - public boolean apply(ObjectSourcePlayer input, Game game) { - return BaneclawMarauderWatcher.check(input.getSourceId(), input.getObject(), game); - } -} - -class BaneclawMarauderWatcher extends Watcher { - - private final Map> blockerMap = new HashMap<>(); - - BaneclawMarauderWatcher() { - super(WatcherScope.GAME); - } - - @Override - public void watch(GameEvent event, Game game) { - switch (event.getType()) { - case BLOCKER_DECLARED: - blockerMap - .computeIfAbsent(new MageObjectReference(event.getTargetId(), game), x -> new HashSet<>()) - .add(new MageObjectReference(event.getSourceId(), game)); - return; - case END_COMBAT_STEP_POST: - blockerMap.clear(); - return; - case REMOVED_FROM_COMBAT: - blockerMap - .values() - .stream() - .forEach(set -> set.removeIf(mor -> mor.refersTo(event.getTargetId(), game))); - } - } - - @Override - public void reset() { - super.reset(); - blockerMap.clear(); - } - - static boolean check(UUID sourceId, Permanent blocker, Game game) { - return game.getState() - .getWatcher(BaneclawMarauderWatcher.class) - .blockerMap - .getOrDefault(new MageObjectReference(sourceId, game), Collections.emptySet()) - .stream() - .anyMatch(mor -> mor.refersTo(blocker, game)); - } -} diff --git a/Mage.Sets/src/mage/cards/b/BarbedBackWurm.java b/Mage.Sets/src/mage/cards/b/BarbedBackWurm.java index a3d937a91d5..5941c3d1831 100644 --- a/Mage.Sets/src/mage/cards/b/BarbedBackWurm.java +++ b/Mage.Sets/src/mage/cards/b/BarbedBackWurm.java @@ -1,7 +1,5 @@ - package mage.cards.b; -import java.util.UUID; import mage.MageInt; import mage.ObjectColor; import mage.abilities.Ability; @@ -13,30 +11,37 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author LoneFox */ public final class BarbedBackWurm extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("green creature blocking {this}"); + + static { + filter.add(new ColorPredicate(ObjectColor.GREEN)); + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public BarbedBackWurm(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}"); this.subtype.add(SubType.WURM); this.power = new MageInt(4); this.toughness = new MageInt(3); // {B}: Target green creature blocking Barbed-Back Wurm gets -1/-1 until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(-1, -1, Duration.EndOfTurn), new ManaCostsImpl("{B}")); - FilterCreaturePermanent filter = new FilterCreaturePermanent("green creature blocking {this}"); - filter.add(new ColorPredicate(ObjectColor.GREEN)); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new BoostTargetEffect( + -1, -1, Duration.EndOfTurn + ), new ManaCostsImpl<>("{B}")); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/b/BaronVonCount.java b/Mage.Sets/src/mage/cards/b/BaronVonCount.java index cd15e61d273..063be647844 100644 --- a/Mage.Sets/src/mage/cards/b/BaronVonCount.java +++ b/Mage.Sets/src/mage/cards/b/BaronVonCount.java @@ -76,7 +76,7 @@ class BaronVonCountPutCounterEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { Integer doomNumber = 5; @@ -172,7 +172,7 @@ class BaronVonCountMoveDoomCounterEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && sourcePermanent != null && mageObject != null) { if (game.getState().getValue(mageObject.getId() + "_doom") == null) { return false; @@ -249,7 +249,7 @@ class BaronVonCountDestroyPlayerEffect extends OneShotEffect { targetPlayer.lost(game); // double checks canLose, but seems more future-proof than lostForced } Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (sourcePermanent != null && mageObject != null) { if (game.getState().getValue(mageObject.getId() + "_doom") == null) { return false; diff --git a/Mage.Sets/src/mage/cards/b/BaseCamp.java b/Mage.Sets/src/mage/cards/b/BaseCamp.java index d5c97d41156..79de773fff5 100644 --- a/Mage.Sets/src/mage/cards/b/BaseCamp.java +++ b/Mage.Sets/src/mage/cards/b/BaseCamp.java @@ -75,7 +75,7 @@ enum BaseCampCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && ( object.hasSubtype(SubType.CLERIC, game) || object.hasSubtype(SubType.ROGUE, game) diff --git a/Mage.Sets/src/mage/cards/b/BatheInLight.java b/Mage.Sets/src/mage/cards/b/BatheInLight.java index 32050ff30a7..932559944e3 100644 --- a/Mage.Sets/src/mage/cards/b/BatheInLight.java +++ b/Mage.Sets/src/mage/cards/b/BatheInLight.java @@ -87,7 +87,7 @@ class BatheInLightEffect extends OneShotEffect { ContinuousEffect effect = new ProtectionChosenColorTargetEffect(); game.addEffect(effect, source); ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) { game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor()); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/b/BattleForBretagard.java b/Mage.Sets/src/mage/cards/b/BattleForBretagard.java index ed2e3c190a5..ac11200470e 100644 --- a/Mage.Sets/src/mage/cards/b/BattleForBretagard.java +++ b/Mage.Sets/src/mage/cards/b/BattleForBretagard.java @@ -89,7 +89,7 @@ class BattleForBretagardEffect extends OneShotEffect { return false; } TargetPermanent target = new BattleForBretagardTarget(); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); for (UUID targetId : target.getTargets()) { new CreateTokenCopyTargetEffect() .setTargetPointer(new FixedTarget(targetId, game)) @@ -145,8 +145,8 @@ class BattleForBretagardTarget extends TargetPermanent { @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Set names = this.getTargets() .stream() .map(game::getPermanent) diff --git a/Mage.Sets/src/mage/cards/b/BattlefieldScrounger.java b/Mage.Sets/src/mage/cards/b/BattlefieldScrounger.java index 04ad2419f8e..ceb6de8a6b7 100644 --- a/Mage.Sets/src/mage/cards/b/BattlefieldScrounger.java +++ b/Mage.Sets/src/mage/cards/b/BattlefieldScrounger.java @@ -68,7 +68,7 @@ class BattlefieldScroungerCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), source, game)) { for (UUID targetId: targets.get(0).getTargets()) { Card card = game.getCard(targetId); if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) { @@ -84,7 +84,7 @@ class BattlefieldScroungerCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BattlefieldThaumaturge.java b/Mage.Sets/src/mage/cards/b/BattlefieldThaumaturge.java index 9f6b3fdca89..20694150ff0 100644 --- a/Mage.Sets/src/mage/cards/b/BattlefieldThaumaturge.java +++ b/Mage.Sets/src/mage/cards/b/BattlefieldThaumaturge.java @@ -99,7 +99,7 @@ class BattlefieldThaumaturgeSpellsCostReductionEffect extends CostModificationEf if (target.isNotTarget()) { continue; } - Set possibleList = target.possibleTargets(ability.getSourceId(), ability.getControllerId(), game); + Set possibleList = target.possibleTargets(ability.getControllerId(), ability, game); possibleList.removeIf(id -> { Permanent permanent = game.getPermanent(id); return permanent == null || !permanent.isCreature(game); diff --git a/Mage.Sets/src/mage/cards/b/BeaconOfDestiny.java b/Mage.Sets/src/mage/cards/b/BeaconOfDestiny.java index 80b6b4c4aff..f390f76d8bb 100644 --- a/Mage.Sets/src/mage/cards/b/BeaconOfDestiny.java +++ b/Mage.Sets/src/mage/cards/b/BeaconOfDestiny.java @@ -71,7 +71,7 @@ class BeaconOfDestinyEffect extends RedirectionEffect { @Override public void init(Ability source, Game game) { - this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java b/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java index 1163654b047..04b192dc2c6 100644 --- a/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java +++ b/Mage.Sets/src/mage/cards/b/BeamsplitterMage.java @@ -112,7 +112,7 @@ class BeamsplitterMageTriggeredAbility extends TriggeredAbilityImpl { } return game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - getControllerId(), getSourceId(), game + getControllerId(), this, game ).stream() .filter(Objects::nonNull) .filter(permanent -> permanent.isCreature(game)) @@ -165,7 +165,7 @@ class BeamsplitterMageEffect extends OneShotEffect { filter.add(new BeamsplitterMagePredicate(spell)); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/b/BeckCall.java b/Mage.Sets/src/mage/cards/b/BeckCall.java index 5a5932f6956..0a63bff7c77 100644 --- a/Mage.Sets/src/mage/cards/b/BeckCall.java +++ b/Mage.Sets/src/mage/cards/b/BeckCall.java @@ -14,7 +14,6 @@ import mage.constants.SpellAbilityType; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.permanent.token.BirdToken; @@ -65,7 +64,7 @@ class BeckTriggeredAbility extends DelayedTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanent(targetId); - return filter.match(permanent, getSourceId(), getControllerId(), game); + return filter.match(permanent, getControllerId(), this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BendOrBreak.java b/Mage.Sets/src/mage/cards/b/BendOrBreak.java index 43026084beb..fc347eb89d2 100644 --- a/Mage.Sets/src/mage/cards/b/BendOrBreak.java +++ b/Mage.Sets/src/mage/cards/b/BendOrBreak.java @@ -96,7 +96,7 @@ class BendOrBreakEffect extends OneShotEffect { List secondPile = new ArrayList<>(); FilterControlledLandPermanent filter = new FilterControlledLandPermanent("lands you control to assign to the first pile (lands not chosen will be assigned to the second pile)"); TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true); - if (!target.canChoose(source.getSourceId(), currentPlayer.getId(), game)) { continue; } + if (!target.canChoose(currentPlayer.getId(), source, game)) { continue; } // TODO: add support for AI (50/50), need AI hints mechanic here currentPlayer.chooseTarget(Outcome.Neutral, target, source, game); diff --git a/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java b/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java index cccf8353357..b391ad05407 100644 --- a/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java +++ b/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java @@ -61,7 +61,7 @@ class BenefactionOfRhonasEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); boolean creatureCardFound = false; diff --git a/Mage.Sets/src/mage/cards/b/BenevolentOffering.java b/Mage.Sets/src/mage/cards/b/BenevolentOffering.java index 6a33bef478a..f3365b3f2be 100644 --- a/Mage.Sets/src/mage/cards/b/BenevolentOffering.java +++ b/Mage.Sets/src/mage/cards/b/BenevolentOffering.java @@ -66,7 +66,7 @@ class BenevolentOfferingEffect1 extends OneShotEffect { if (controller == null) { return false; } Target target = new TargetOpponent(true); - target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent == null) { return false; } @@ -100,7 +100,7 @@ class BenevolentOfferingEffect2 extends OneShotEffect { if (controller == null) { return false; } Target target = new TargetOpponent(true); - target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/b/BenthicExplorers.java b/Mage.Sets/src/mage/cards/b/BenthicExplorers.java index bb7a1355e02..661e60a3040 100644 --- a/Mage.Sets/src/mage/cards/b/BenthicExplorers.java +++ b/Mage.Sets/src/mage/cards/b/BenthicExplorers.java @@ -81,7 +81,7 @@ class BenthicExplorersCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (target.choose(Outcome.Untap, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Untap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { @@ -98,7 +98,7 @@ class BenthicExplorersCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BerserkersFrenzy.java b/Mage.Sets/src/mage/cards/b/BerserkersFrenzy.java index 2dc7617417e..744b5503e4e 100644 --- a/Mage.Sets/src/mage/cards/b/BerserkersFrenzy.java +++ b/Mage.Sets/src/mage/cards/b/BerserkersFrenzy.java @@ -99,7 +99,7 @@ class BerserkersFrenzyEffect extends OneShotEffect { } TargetPermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); game.addEffect(new BlocksIfAbleTargetEffect(Duration.EndOfTurn) .setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source); return true; diff --git a/Mage.Sets/src/mage/cards/b/BirchloreRangers.java b/Mage.Sets/src/mage/cards/b/BirchloreRangers.java index 29f0351e04e..329056818d7 100644 --- a/Mage.Sets/src/mage/cards/b/BirchloreRangers.java +++ b/Mage.Sets/src/mage/cards/b/BirchloreRangers.java @@ -80,7 +80,7 @@ class BirchloreRangersManaEffect extends AddManaOfAnyColorEffect { @Override public List getNetMana(Game game, Ability source) { if (game != null && game.inCheckPlayableState()) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 2; + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game) / 2; List netMana = new ArrayList<>(); if (count > 0) { netMana.add(Mana.AnyMana(count * 2)); diff --git a/Mage.Sets/src/mage/cards/b/BlasphemousAct.java b/Mage.Sets/src/mage/cards/b/BlasphemousAct.java index defbca5e4a3..f17a9d0f425 100644 --- a/Mage.Sets/src/mage/cards/b/BlasphemousAct.java +++ b/Mage.Sets/src/mage/cards/b/BlasphemousAct.java @@ -59,7 +59,7 @@ class BlasphemousCostReductionEffect extends CostModificationEffectImpl { Player player = game.getPlayer(source.getControllerId()); if (player == null) { return false; } - int reductionAmount = game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), source.getControllerId(), game); + int reductionAmount = game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), source, game); CardUtil.reduceCost(abilityToModify, reductionAmount); return true; diff --git a/Mage.Sets/src/mage/cards/b/BlastOfGenius.java b/Mage.Sets/src/mage/cards/b/BlastOfGenius.java index 3bdc32a0641..4aea551192e 100644 --- a/Mage.Sets/src/mage/cards/b/BlastOfGenius.java +++ b/Mage.Sets/src/mage/cards/b/BlastOfGenius.java @@ -60,8 +60,8 @@ class BlastOfGeniusEffect extends OneShotEffect { if (player != null) { player.drawCards(3, source, game); TargetDiscard target = new TargetDiscard(player.getId()); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Discard, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Discard, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { player.discard(card, false, source, game); diff --git a/Mage.Sets/src/mage/cards/b/BlatantThievery.java b/Mage.Sets/src/mage/cards/b/BlatantThievery.java index 9a754b68068..c619988e8f5 100644 --- a/Mage.Sets/src/mage/cards/b/BlatantThievery.java +++ b/Mage.Sets/src/mage/cards/b/BlatantThievery.java @@ -52,7 +52,7 @@ enum BlatantThieveryAdjuster implements TargetAdjuster { Player opponent = game.getPlayer(opponentId); if (opponent == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT, - ability.getSourceId(), opponentId, game + opponentId, ability, game ) < 1) { continue; } diff --git a/Mage.Sets/src/mage/cards/b/BlazingHope.java b/Mage.Sets/src/mage/cards/b/BlazingHope.java index 319e1ed3437..f85d5a86ef6 100644 --- a/Mage.Sets/src/mage/cards/b/BlazingHope.java +++ b/Mage.Sets/src/mage/cards/b/BlazingHope.java @@ -54,29 +54,29 @@ class BlazingHopeTarget extends TargetCreaturePermanent { if (permanent != null) { if (!isNotTarget()) { if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) - || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) { + || !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) { return false; } } Player controller = game.getPlayer(source.getControllerId()); if (controller != null && permanent.getPower().getValue() >= controller.getLife()) { - return filter.match(permanent, source.getSourceId(), controllerId, game); + return filter.match(permanent, controllerId, source, game); } } return false; } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int remainingTargets = this.minNumberOfTargets - targets.size(); if (remainingTargets <= 0) { return true; } int count = 0; Player controller = game.getPlayer(sourceControllerId); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId())) { if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (controller != null && permanent.getPower().getValue() >= controller.getLife()) { diff --git a/Mage.Sets/src/mage/cards/b/BlessingOfFrost.java b/Mage.Sets/src/mage/cards/b/BlessingOfFrost.java index 1deee6907f5..a90524a964c 100644 --- a/Mage.Sets/src/mage/cards/b/BlessingOfFrost.java +++ b/Mage.Sets/src/mage/cards/b/BlessingOfFrost.java @@ -91,7 +91,7 @@ class BlessingOfFrostEffect extends OneShotEffect { } game.getState().processAction(game); player.drawCards(game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ), source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/b/BlightHerder.java b/Mage.Sets/src/mage/cards/b/BlightHerder.java index 82c0a5afaac..a33c25b6563 100644 --- a/Mage.Sets/src/mage/cards/b/BlightHerder.java +++ b/Mage.Sets/src/mage/cards/b/BlightHerder.java @@ -72,7 +72,7 @@ class BlightHerderEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetCardInExile(2, 2, filter, null); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { if (controller.chooseTarget(outcome, target, source, game)) { Cards cardsToGraveyard = new CardsImpl(target.getTargets()); controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game); diff --git a/Mage.Sets/src/mage/cards/b/BlimComedicGenius.java b/Mage.Sets/src/mage/cards/b/BlimComedicGenius.java index 5b1782303c2..0664c90748c 100644 --- a/Mage.Sets/src/mage/cards/b/BlimComedicGenius.java +++ b/Mage.Sets/src/mage/cards/b/BlimComedicGenius.java @@ -93,13 +93,13 @@ class BlimComedicGeniusEffect extends OneShotEffect { if (player == null) { continue; } - int count = game.getBattlefield().count(filter, source.getSourceId(), playerId, game); + int count = game.getBattlefield().count(filter, playerId, source, game); if (count < 1) { continue; } player.loseLife(count, game, source, true); TargetDiscard target = new TargetDiscard(StaticFilters.FILTER_CARD, playerId); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); cardsMap.put(playerId, new CardsImpl(target.getTargets())); } for (Map.Entry entry : cardsMap.entrySet()) { diff --git a/Mage.Sets/src/mage/cards/b/BlinkmothUrn.java b/Mage.Sets/src/mage/cards/b/BlinkmothUrn.java index 23a6f1b7157..cf3cf34b851 100644 --- a/Mage.Sets/src/mage/cards/b/BlinkmothUrn.java +++ b/Mage.Sets/src/mage/cards/b/BlinkmothUrn.java @@ -66,7 +66,7 @@ class BlinkmothUrnEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null && !sourcePermanent.isTapped()) { player.getManaPool().addMana(Mana.ColorlessMana( - game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game). + game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game). size()), game, source, false); return true; } diff --git a/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java b/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java index 50eacff9f7c..44e37d37f76 100644 --- a/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java +++ b/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java @@ -81,7 +81,7 @@ class BlizzardBrawlEffect extends OneShotEffect { if (creature1 == null) { return false; } - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) >= 3) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) >= 3) { game.addEffect(new BoostTargetEffect( 1, 0, Duration.EndOfTurn ).setTargetPointer(new FixedTarget(creature1.getId(), game)), source); diff --git a/Mage.Sets/src/mage/cards/b/BlizzardSpecter.java b/Mage.Sets/src/mage/cards/b/BlizzardSpecter.java index a2df581949d..6067663d03b 100644 --- a/Mage.Sets/src/mage/cards/b/BlizzardSpecter.java +++ b/Mage.Sets/src/mage/cards/b/BlizzardSpecter.java @@ -79,7 +79,7 @@ class ReturnToHandEffect extends OneShotEffect { return false; } Target target = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true); - if (target.canChoose(source.getSourceId(), targetPlayer.getId(), game)) { + if (target.canChoose(targetPlayer.getId(), source, game)) { targetPlayer.chooseTarget(Outcome.ReturnToHand, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/b/BloodClock.java b/Mage.Sets/src/mage/cards/b/BloodClock.java index 90739872eff..f17f9752d49 100644 --- a/Mage.Sets/src/mage/cards/b/BloodClock.java +++ b/Mage.Sets/src/mage/cards/b/BloodClock.java @@ -73,7 +73,7 @@ class BloodClockEffect extends OneShotEffect { } Target target = new TargetControlledPermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), player.getId(), game) + if (!target.canChoose(player.getId(), source, game) || !player.chooseTarget(outcome, target, source, game)) { return false; } diff --git a/Mage.Sets/src/mage/cards/b/BloodCurdle.java b/Mage.Sets/src/mage/cards/b/BloodCurdle.java index 9a75ba77a1e..df33509b6b5 100644 --- a/Mage.Sets/src/mage/cards/b/BloodCurdle.java +++ b/Mage.Sets/src/mage/cards/b/BloodCurdle.java @@ -66,7 +66,7 @@ class BloodCurdleEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/b/BloodLust.java b/Mage.Sets/src/mage/cards/b/BloodLust.java index e0ae6a2e613..941c4dc4f72 100644 --- a/Mage.Sets/src/mage/cards/b/BloodLust.java +++ b/Mage.Sets/src/mage/cards/b/BloodLust.java @@ -68,7 +68,7 @@ class TargetMatchesFilterCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent target = game.getBattlefield().getPermanent(source.getFirstTarget()); if (target != null) { - if (filter.match(target, source.getSourceId(), source.getControllerId(), game)) { + if (filter.match(target, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/b/BloodOath.java b/Mage.Sets/src/mage/cards/b/BloodOath.java index 0893ebbd5dd..1a4756c3cf7 100644 --- a/Mage.Sets/src/mage/cards/b/BloodOath.java +++ b/Mage.Sets/src/mage/cards/b/BloodOath.java @@ -73,7 +73,7 @@ class BloodOathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player player = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(source.getFirstTarget()); if (player != null && opponent != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/b/BloodSun.java b/Mage.Sets/src/mage/cards/b/BloodSun.java index 0a9e2dd853a..55bfd19f9da 100644 --- a/Mage.Sets/src/mage/cards/b/BloodSun.java +++ b/Mage.Sets/src/mage/cards/b/BloodSun.java @@ -69,7 +69,7 @@ class BloodSunEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source, game)) { switch (layer) { case AbilityAddingRemovingEffects_6: List toRemove = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/b/Bloodletter.java b/Mage.Sets/src/mage/cards/b/Bloodletter.java index 39e5867931d..ace3e39ce06 100644 --- a/Mage.Sets/src/mage/cards/b/Bloodletter.java +++ b/Mage.Sets/src/mage/cards/b/Bloodletter.java @@ -64,7 +64,7 @@ class BloodletterStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { Map initialCount = new HashMap<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), getControllerId(), getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), getControllerId(), this, game)) { Character initial = permanent.getName().charAt(0); initialCount.putIfAbsent(initial, 0); initialCount.put(initial, initialCount.get(initial) + 1); diff --git a/Mage.Sets/src/mage/cards/b/Blustersquall.java b/Mage.Sets/src/mage/cards/b/Blustersquall.java index f81550cbb79..7d316f63a5a 100644 --- a/Mage.Sets/src/mage/cards/b/Blustersquall.java +++ b/Mage.Sets/src/mage/cards/b/Blustersquall.java @@ -56,7 +56,7 @@ class BlustersqallTapAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source, game)) { creature.tap(source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/b/BoardedWindow.java b/Mage.Sets/src/mage/cards/b/BoardedWindow.java index a762fc91c62..141d2dc8920 100644 --- a/Mage.Sets/src/mage/cards/b/BoardedWindow.java +++ b/Mage.Sets/src/mage/cards/b/BoardedWindow.java @@ -66,8 +66,8 @@ class BoardedWindowFilter extends FilterAttackingCreature { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (!super.match(permanent, sourceId, playerId, game)) { + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (!super.match(permanent, playerId, source, game)) { return false; } diff --git a/Mage.Sets/src/mage/cards/b/BodyDouble.java b/Mage.Sets/src/mage/cards/b/BodyDouble.java index 77684c2a4f5..0aeb944e0fe 100644 --- a/Mage.Sets/src/mage/cards/b/BodyDouble.java +++ b/Mage.Sets/src/mage/cards/b/BodyDouble.java @@ -65,8 +65,8 @@ class BodyDoubleCopyEffect extends OneShotEffect { if (player != null) { Target target = new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - player.choose(outcome, target, source.getSourceId(), game); + if (target.canChoose(source.getControllerId(), source, game)) { + player.choose(outcome, target, source, game); Card copyFromCard = game.getCard(target.getFirstTarget()); if (copyFromCard != null) { CopyEffect copyEffect = new CopyEffect(Duration.Custom, copyFromCard, source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/b/BondOfInsight.java b/Mage.Sets/src/mage/cards/b/BondOfInsight.java index 960fe72b091..e36f25f79c2 100644 --- a/Mage.Sets/src/mage/cards/b/BondOfInsight.java +++ b/Mage.Sets/src/mage/cards/b/BondOfInsight.java @@ -73,7 +73,7 @@ class BondOfInsightEffect extends OneShotEffect { TargetCard target = new TargetCardInYourGraveyard( 0, 2, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, true ); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Cards cards = new CardsImpl(target.getTargets()); diff --git a/Mage.Sets/src/mage/cards/b/BoneDragon.java b/Mage.Sets/src/mage/cards/b/BoneDragon.java index b5a67d9c643..f356a27c55e 100644 --- a/Mage.Sets/src/mage/cards/b/BoneDragon.java +++ b/Mage.Sets/src/mage/cards/b/BoneDragon.java @@ -1,24 +1,24 @@ package mage.cards.b; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.ExileFromGraveCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect; -import mage.constants.SubType; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class BoneDragon extends CardImpl { @@ -26,7 +26,7 @@ public final class BoneDragon extends CardImpl { private static final FilterCard filter = new FilterCard("other cards"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public BoneDragon(UUID ownerId, CardSetInfo setInfo) { @@ -44,7 +44,7 @@ public final class BoneDragon extends CardImpl { Ability ability = new SimpleActivatedAbility( Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(true), - new ManaCostsImpl("{3}{B}{B}") + new ManaCostsImpl<>("{3}{B}{B}") ); ability.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(7, filter))); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/b/BoneyardParley.java b/Mage.Sets/src/mage/cards/b/BoneyardParley.java index b72c702aa0b..24ae9d6aec0 100644 --- a/Mage.Sets/src/mage/cards/b/BoneyardParley.java +++ b/Mage.Sets/src/mage/cards/b/BoneyardParley.java @@ -79,7 +79,7 @@ class BoneyardParleyEffect extends OneShotEffect { } if (!cards.isEmpty() && player.moveCards(cards, Zone.EXILED, source, game)) { TargetOpponent targetOpponent = new TargetOpponent(true); - if (player.choose(Outcome.Neutral, targetOpponent, source.getSourceId(), game)) { + if (player.choose(Outcome.Neutral, targetOpponent, source, game)) { Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent != null) { TargetCard targetCards = new TargetCard(0, cards.size(), Zone.EXILED, new FilterCard("cards to put in the first pile")); diff --git a/Mage.Sets/src/mage/cards/b/BoneyardScourge.java b/Mage.Sets/src/mage/cards/b/BoneyardScourge.java index f992ca337d5..453c598235d 100644 --- a/Mage.Sets/src/mage/cards/b/BoneyardScourge.java +++ b/Mage.Sets/src/mage/cards/b/BoneyardScourge.java @@ -97,7 +97,7 @@ class DiesWhileInGraveyardTriggeredAbility extends TriggeredAbilityImpl { } } - return filter.match(zEvent.getTarget(), sourceId, controllerId, game); + return filter.match(zEvent.getTarget(), controllerId,this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BoonOfBoseiju.java b/Mage.Sets/src/mage/cards/b/BoonOfBoseiju.java index 868f4ecc395..a7a896e7549 100644 --- a/Mage.Sets/src/mage/cards/b/BoonOfBoseiju.java +++ b/Mage.Sets/src/mage/cards/b/BoonOfBoseiju.java @@ -53,7 +53,7 @@ enum BoonOfBoseijuValue implements DynamicValue { public int calculate(Game game, Ability sourceAbility, Effect effect) { return game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT, - sourceAbility.getControllerId(), sourceAbility.getSourceId(), game + sourceAbility.getControllerId(), sourceAbility, game ).stream().mapToInt(MageObject::getManaValue).sum(); } diff --git a/Mage.Sets/src/mage/cards/b/BoreasCharger.java b/Mage.Sets/src/mage/cards/b/BoreasCharger.java index 7169a5d1240..b84fa7fddae 100644 --- a/Mage.Sets/src/mage/cards/b/BoreasCharger.java +++ b/Mage.Sets/src/mage/cards/b/BoreasCharger.java @@ -92,7 +92,7 @@ class BoreasChargerEffect extends OneShotEffect { return false; } TargetPlayer target = new TargetPlayer(1, 1, true, filter); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent == null) { controller.shuffleLibrary(source, game); diff --git a/Mage.Sets/src/mage/cards/b/Borrowing100000Arrows.java b/Mage.Sets/src/mage/cards/b/Borrowing100000Arrows.java index 815623ebc9d..d2f033af6d8 100644 --- a/Mage.Sets/src/mage/cards/b/Borrowing100000Arrows.java +++ b/Mage.Sets/src/mage/cards/b/Borrowing100000Arrows.java @@ -64,7 +64,7 @@ class Borrowing100000ArrowsEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(TappedPredicate.TAPPED); filter.add(new ControllerIdPredicate(opponent.getId())); - return new DrawCardSourceControllerEffect(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game)).apply(game, source); + return new DrawCardSourceControllerEffect(game.getBattlefield().count(filter, source.getControllerId(), source, game)).apply(game, source); } return false; } diff --git a/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java b/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java index 54d3d5ab997..d3e5160a38c 100644 --- a/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java +++ b/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java @@ -112,7 +112,7 @@ class BoseijuWhoSheltersAllCantCounterEffect extends ContinuousRuleModifyingEffe @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This spell can't be countered because mana from " + sourceObject.getName() + " was spent to cast it."; } diff --git a/Mage.Sets/src/mage/cards/b/Bossk.java b/Mage.Sets/src/mage/cards/b/Bossk.java index f4f07f8928b..cb63516b910 100644 --- a/Mage.Sets/src/mage/cards/b/Bossk.java +++ b/Mage.Sets/src/mage/cards/b/Bossk.java @@ -70,7 +70,7 @@ class BosskTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - return game.getBattlefield().count(new FilterControlledLandPermanent(), getSourceId(), getControllerId(), game) > 4; + return game.getBattlefield().count(new FilterControlledLandPermanent(), getControllerId(), this, game) > 4; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BoundDetermined.java b/Mage.Sets/src/mage/cards/b/BoundDetermined.java index 09c349f5d76..f218090357f 100644 --- a/Mage.Sets/src/mage/cards/b/BoundDetermined.java +++ b/Mage.Sets/src/mage/cards/b/BoundDetermined.java @@ -81,7 +81,7 @@ class BoundEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent("a creature (to sacrifice)"), true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { if (controller.chooseTarget(outcome, target, source, game)) { Permanent toSacrifice = game.getPermanent(target.getFirstTarget()); if (toSacrifice != null) { @@ -126,7 +126,7 @@ class DeterminedEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This spell can't be countered (" + sourceObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/b/BrainPry.java b/Mage.Sets/src/mage/cards/b/BrainPry.java index cc8eb1e4bdd..1d1e4475fa8 100644 --- a/Mage.Sets/src/mage/cards/b/BrainPry.java +++ b/Mage.Sets/src/mage/cards/b/BrainPry.java @@ -55,7 +55,7 @@ class BrainPryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (targetPlayer != null && controller != null && sourceObject != null && cardName != null) { boolean hasDiscarded = false; diff --git a/Mage.Sets/src/mage/cards/b/BrandOfIllOmen.java b/Mage.Sets/src/mage/cards/b/BrandOfIllOmen.java index 7cfb2e6c03e..a676d10bcce 100644 --- a/Mage.Sets/src/mage/cards/b/BrandOfIllOmen.java +++ b/Mage.Sets/src/mage/cards/b/BrandOfIllOmen.java @@ -78,7 +78,7 @@ class BrandOfIllOmenEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast creature spells (" + mageObject.getLogName() + " on the battlefield)."; } diff --git a/Mage.Sets/src/mage/cards/b/Bravado.java b/Mage.Sets/src/mage/cards/b/Bravado.java index 60493c8cce2..0f96ef39fe5 100644 --- a/Mage.Sets/src/mage/cards/b/Bravado.java +++ b/Mage.Sets/src/mage/cards/b/Bravado.java @@ -68,7 +68,7 @@ class BravadoBoostEnchantedEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1; + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game) - 1; if (count > 0) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { diff --git a/Mage.Sets/src/mage/cards/b/BreachingLeviathan.java b/Mage.Sets/src/mage/cards/b/BreachingLeviathan.java index 771bcb9febc..9a42d85e5de 100644 --- a/Mage.Sets/src/mage/cards/b/BreachingLeviathan.java +++ b/Mage.Sets/src/mage/cards/b/BreachingLeviathan.java @@ -82,7 +82,7 @@ class BreachingLeviathanEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List doNotUntapNextUntapStep = new ArrayList<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { creature.tap(source, game); doNotUntapNextUntapStep.add(creature); } diff --git a/Mage.Sets/src/mage/cards/b/BreakingEntering.java b/Mage.Sets/src/mage/cards/b/BreakingEntering.java index 6911b38c1d1..2cca2af2e2f 100644 --- a/Mage.Sets/src/mage/cards/b/BreakingEntering.java +++ b/Mage.Sets/src/mage/cards/b/BreakingEntering.java @@ -71,7 +71,7 @@ class EnteringReturnFromGraveyardToBattlefieldEffect extends OneShotEffect { if (controller != null) { Target target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/b/BreakingPoint.java b/Mage.Sets/src/mage/cards/b/BreakingPoint.java index 717cd509807..29efe1f3e33 100644 --- a/Mage.Sets/src/mage/cards/b/BreakingPoint.java +++ b/Mage.Sets/src/mage/cards/b/BreakingPoint.java @@ -78,7 +78,7 @@ class BreakingPointDestroyEffect extends OneShotEffect { } } if (destroyCreatures) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(FILTER_PERMANENT_CREATURES, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(FILTER_PERMANENT_CREATURES, source.getControllerId(), source, game)) { permanent.destroy(source, game, true); } } diff --git a/Mage.Sets/src/mage/cards/b/BreakingWave.java b/Mage.Sets/src/mage/cards/b/BreakingWave.java index f66663ea5b1..bb1e3aaae88 100644 --- a/Mage.Sets/src/mage/cards/b/BreakingWave.java +++ b/Mage.Sets/src/mage/cards/b/BreakingWave.java @@ -64,7 +64,7 @@ class BreakingWaveEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List creatures = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, - source.getControllerId(), source.getSourceId(), game); + source.getControllerId(), source, game); for (Permanent creature : creatures) { if (creature.isTapped()) { creature.untap(game); diff --git a/Mage.Sets/src/mage/cards/b/Breakthrough.java b/Mage.Sets/src/mage/cards/b/Breakthrough.java index 09806be9f12..62bc8b18ae6 100644 --- a/Mage.Sets/src/mage/cards/b/Breakthrough.java +++ b/Mage.Sets/src/mage/cards/b/Breakthrough.java @@ -68,7 +68,7 @@ class BreakthroughEffect extends OneShotEffect { } else if (amountToKeep < player.getHand().size()) { TargetCardInHand target = new TargetCardInHand(amountToKeep, new FilterCard()); target.setTargetName("cards to keep"); - target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), game); + target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game); Cards cards = player.getHand().copy(); cards.removeIf(target.getTargets()::contains); player.discard(cards, false, source, game); diff --git a/Mage.Sets/src/mage/cards/b/BreathOfFury.java b/Mage.Sets/src/mage/cards/b/BreathOfFury.java index cf437b32809..061eb9e8382 100644 --- a/Mage.Sets/src/mage/cards/b/BreathOfFury.java +++ b/Mage.Sets/src/mage/cards/b/BreathOfFury.java @@ -16,7 +16,6 @@ import mage.filter.predicate.permanent.CanBeEnchantedByPredicate; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.turn.TurnMod; import mage.players.Player; @@ -130,8 +129,8 @@ class BreathOfFuryEffect extends OneShotEffect { // Commanders going to the command zone and Rest in Peace style replacement effects don't make Permanent.sacrifice return false. if (enchantedCreature != null && controller != null && enchantedCreature.sacrifice(source, game) - && target.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(outcome, target, source.getSourceId(), game); + && target.canChoose(controller.getId(), source, game)) { + controller.choose(outcome, target, source, game); Permanent newCreature = game.getPermanent(target.getFirstTarget()); boolean success = false; if (newCreature != null) { diff --git a/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java b/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java index 6f3192bfd0c..5849e71eafd 100644 --- a/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java +++ b/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java @@ -125,13 +125,13 @@ class BreenaTheDemagogueEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ) < 1) { return false; } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); return permanent != null && permanent.addCounters( CounterType.P1P1.createInstance(2), diff --git a/Mage.Sets/src/mage/cards/b/BreyasApprentice.java b/Mage.Sets/src/mage/cards/b/BreyasApprentice.java index 9110c2b6648..bc062ac069f 100644 --- a/Mage.Sets/src/mage/cards/b/BreyasApprentice.java +++ b/Mage.Sets/src/mage/cards/b/BreyasApprentice.java @@ -85,7 +85,7 @@ class BreyasApprenticeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/b/BridgeFromBelow.java b/Mage.Sets/src/mage/cards/b/BridgeFromBelow.java index da663d202f1..aa737a43cc6 100644 --- a/Mage.Sets/src/mage/cards/b/BridgeFromBelow.java +++ b/Mage.Sets/src/mage/cards/b/BridgeFromBelow.java @@ -87,7 +87,7 @@ class BridgeFromBelowAbility extends TriggeredAbilityImpl { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (permanent == null) { return false; } - return filter.match(permanent, sourceId, controllerId, game); + return filter.match(permanent, controllerId, this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BrilliantUltimatum.java b/Mage.Sets/src/mage/cards/b/BrilliantUltimatum.java index 158bfc6d391..21308bfd4c0 100644 --- a/Mage.Sets/src/mage/cards/b/BrilliantUltimatum.java +++ b/Mage.Sets/src/mage/cards/b/BrilliantUltimatum.java @@ -59,7 +59,7 @@ class BrilliantUltimatumEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } @@ -69,7 +69,7 @@ class BrilliantUltimatumEffect extends OneShotEffect { controller.moveCardsToExile(pile2.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName()); TargetOpponent targetOpponent = new TargetOpponent(true); - targetOpponent.choose(outcome, source.getControllerId(), source.getSourceId(), game); + targetOpponent.choose(outcome, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent != null) { TargetCard target = new TargetCard(0, pile2.size(), Zone.EXILED, new FilterCard("cards to put in the first pile")); diff --git a/Mage.Sets/src/mage/cards/b/BriselaVoiceOfNightmares.java b/Mage.Sets/src/mage/cards/b/BriselaVoiceOfNightmares.java index 981bbaffdd1..e6cce7f8790 100644 --- a/Mage.Sets/src/mage/cards/b/BriselaVoiceOfNightmares.java +++ b/Mage.Sets/src/mage/cards/b/BriselaVoiceOfNightmares.java @@ -82,7 +82,7 @@ class BriselaVoiceOfNightmaresCantCastEffect extends ContinuousRuleModifyingEffe @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast spells with mana value 3 or less (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/b/BronzehideLion.java b/Mage.Sets/src/mage/cards/b/BronzehideLion.java index da5b0187de9..fbd92ad8a99 100644 --- a/Mage.Sets/src/mage/cards/b/BronzehideLion.java +++ b/Mage.Sets/src/mage/cards/b/BronzehideLion.java @@ -88,7 +88,7 @@ class BronzehideLionReturnEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (controller.choose(outcome, target, source.getSourceId(), game) + if (controller.choose(outcome, target, source, game) && game.getPermanent(target.getFirstTarget()) != null) { game.getState().setValue("attachTo:" + source.getSourceId(), target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/b/BrothersYamazaki.java b/Mage.Sets/src/mage/cards/b/BrothersYamazaki.java index eb339a13ba0..ee936a0012f 100644 --- a/Mage.Sets/src/mage/cards/b/BrothersYamazaki.java +++ b/Mage.Sets/src/mage/cards/b/BrothersYamazaki.java @@ -99,7 +99,7 @@ class BrothersYamazakiIgnoreLegendRuleEffectEffect extends ContinuousRuleModifyi public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.getName().equals("Brothers Yamazaki")) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 2; + return game.getBattlefield().count(filter, source.getControllerId(), source, game) == 2; } return false; } diff --git a/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java b/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java index 32540571ce7..863c43269ab 100644 --- a/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java +++ b/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java @@ -94,7 +94,7 @@ class BrudicladTelchorEngineerEffect extends OneShotEffect { TargetControlledPermanent target = new TargetControlledPermanent(0, 1, filter, true); target.setNotTarget(true); if (controller.chooseUse(outcome, "Select a token to copy?", source, game) - && controller.choose(Outcome.Neutral, target, source.getSourceId(), game)) { + && controller.choose(Outcome.Neutral, target, source, game)) { Permanent toCopyFromPermanent = game.getPermanent(target.getFirstTarget()); if (toCopyFromPermanent != null) { diff --git a/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java b/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java index c70f83bd04b..17d6ecbaa5e 100644 --- a/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java +++ b/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java @@ -72,7 +72,7 @@ class BruenorBattlehammerBoostEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { int equipped = permanent .getAttachments() diff --git a/Mage.Sets/src/mage/cards/b/BrunaLightOfAlabaster.java b/Mage.Sets/src/mage/cards/b/BrunaLightOfAlabaster.java index f7055c74893..9a6da1ee603 100644 --- a/Mage.Sets/src/mage/cards/b/BrunaLightOfAlabaster.java +++ b/Mage.Sets/src/mage/cards/b/BrunaLightOfAlabaster.java @@ -102,7 +102,7 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect { && controller.chooseUse(Outcome.Benefit, "Attach an Aura from the battlefield?", source, game)) { Target targetAura = new TargetPermanent(filterAura); targetAura.setNotTarget(true); - if (!controller.choose(Outcome.Benefit, targetAura, source.getSourceId(), game)) { continue; } + if (!controller.choose(Outcome.Benefit, targetAura, source, game)) { continue; } Permanent aura = game.getPermanent(targetAura.getFirstTarget()); if (aura == null) { continue; } diff --git a/Mage.Sets/src/mage/cards/b/BudokaGardener.java b/Mage.Sets/src/mage/cards/b/BudokaGardener.java index a149b51f6c3..68fc7a99d10 100644 --- a/Mage.Sets/src/mage/cards/b/BudokaGardener.java +++ b/Mage.Sets/src/mage/cards/b/BudokaGardener.java @@ -71,7 +71,7 @@ class BudokaGardenerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return false; } - if (game.getBattlefield().count(filterLands, source.getSourceId(), source.getControllerId(), game) < 10) { + if (game.getBattlefield().count(filterLands, source.getControllerId(), source, game) < 10) { return false; } diff --git a/Mage.Sets/src/mage/cards/b/BurdenOfGreed.java b/Mage.Sets/src/mage/cards/b/BurdenOfGreed.java index f824f61baf9..6b49922a8a8 100644 --- a/Mage.Sets/src/mage/cards/b/BurdenOfGreed.java +++ b/Mage.Sets/src/mage/cards/b/BurdenOfGreed.java @@ -50,7 +50,7 @@ class BurdenOfGreedCount implements DynamicValue { FilterArtifactPermanent filter = new FilterArtifactPermanent(); filter.add(TappedPredicate.TAPPED); filter.add(new ControllerIdPredicate(sourceAbility.getFirstTarget())); - return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BurningOfXinye.java b/Mage.Sets/src/mage/cards/b/BurningOfXinye.java index 95ffc4d62e5..cc81dfbf8d5 100644 --- a/Mage.Sets/src/mage/cards/b/BurningOfXinye.java +++ b/Mage.Sets/src/mage/cards/b/BurningOfXinye.java @@ -82,9 +82,9 @@ class BurningOfXinyeEffect extends OneShotEffect{ int amount = Math.min(4, realCount); Target target = new TargetControlledPermanent(amount, amount, filter, true); - if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (amount > 0 && target.canChoose(player.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(player.getId(), source, game) && player.canRespond()) { + player.choose(Outcome.Sacrifice, target, source, game); } for (UUID targetId : target.getTargets()) { diff --git a/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java b/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java index e45a74da89a..79b81c565e8 100644 --- a/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java +++ b/Mage.Sets/src/mage/cards/b/ButcherOfTheHorde.java @@ -71,7 +71,7 @@ class ButcherOfTheHordeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Choice abilityChoice = new ChoiceImpl(); abilityChoice.setMessage("Choose an ability to add"); diff --git a/Mage.Sets/src/mage/cards/c/CabalShrine.java b/Mage.Sets/src/mage/cards/c/CabalShrine.java index 319eb43c873..6ba7d6f0adc 100644 --- a/Mage.Sets/src/mage/cards/c/CabalShrine.java +++ b/Mage.Sets/src/mage/cards/c/CabalShrine.java @@ -90,7 +90,7 @@ class CabalShrineEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int count = 0; - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if(mageObject != null) { Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject); if (spell != null) { diff --git a/Mage.Sets/src/mage/cards/c/CabalTherapist.java b/Mage.Sets/src/mage/cards/c/CabalTherapist.java index 53997fd42a9..6f4395e7281 100644 --- a/Mage.Sets/src/mage/cards/c/CabalTherapist.java +++ b/Mage.Sets/src/mage/cards/c/CabalTherapist.java @@ -81,7 +81,7 @@ class CabalTherapistDiscardEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (targetPlayer == null || controller == null || sourceObject == null || cardName == null) { return false; diff --git a/Mage.Sets/src/mage/cards/c/CabalTherapy.java b/Mage.Sets/src/mage/cards/c/CabalTherapy.java index 59cd97eef5f..73ec5c75673 100644 --- a/Mage.Sets/src/mage/cards/c/CabalTherapy.java +++ b/Mage.Sets/src/mage/cards/c/CabalTherapy.java @@ -65,7 +65,7 @@ class CabalTherapyEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (targetPlayer == null || controller == null || sourceObject == null || cardName == null) { return false; diff --git a/Mage.Sets/src/mage/cards/c/CallOfTheDeathDweller.java b/Mage.Sets/src/mage/cards/c/CallOfTheDeathDweller.java index 583d2ad7fa5..37d72138912 100644 --- a/Mage.Sets/src/mage/cards/c/CallOfTheDeathDweller.java +++ b/Mage.Sets/src/mage/cards/c/CallOfTheDeathDweller.java @@ -96,7 +96,7 @@ class CallOfTheDeathDwellerEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent("creature to put a deathtouch counter on"); filter.add(Predicates.or(predicates)); Target target = new TargetPermanent(0, 1, filter, true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.DEATHTOUCH.createInstance(), source.getControllerId(), source, game); @@ -104,7 +104,7 @@ class CallOfTheDeathDwellerEffect extends OneShotEffect { } filter.setMessage("creature to put a menace counter on"); target = new TargetPermanent(0, 1, filter, true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.MENACE.createInstance(), source.getControllerId(), source, game); diff --git a/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java b/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java index 6a10b85f2b3..4787e7c7c98 100644 --- a/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java +++ b/Mage.Sets/src/mage/cards/c/CallerOfTheHunt.java @@ -138,7 +138,7 @@ class ChooseCreatureTypeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); Choice typeChoice = new ChoiceCreatureType(mageObject); if (controller != null && mageObject != null diff --git a/Mage.Sets/src/mage/cards/c/CallousOppressor.java b/Mage.Sets/src/mage/cards/c/CallousOppressor.java index 35cdfca8e54..49d13865bd9 100644 --- a/Mage.Sets/src/mage/cards/c/CallousOppressor.java +++ b/Mage.Sets/src/mage/cards/c/CallousOppressor.java @@ -84,9 +84,9 @@ class CallousOppressorFilter extends FilterCreaturePermanent { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (super.match(permanent, sourceId, playerId, game)) { - SubType subtype = (SubType) game.getState().getValue(sourceId + "_type"); + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (super.match(permanent, playerId, source, game)) { + SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type"); if (subtype != null && permanent.hasSubtype(subtype, game)) { return false; } @@ -113,12 +113,12 @@ class CallousOppressorChooseCreatureTypeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null) { TargetOpponent target = new TargetOpponent(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } else { diff --git a/Mage.Sets/src/mage/cards/c/CalmingVerse.java b/Mage.Sets/src/mage/cards/c/CalmingVerse.java index 04653e31979..e00451c3fb4 100644 --- a/Mage.Sets/src/mage/cards/c/CalmingVerse.java +++ b/Mage.Sets/src/mage/cards/c/CalmingVerse.java @@ -75,7 +75,7 @@ class CalmingVerseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { // Destroy all other enchantments - for (Permanent permanent : game.getBattlefield().getActivePermanents(opponentEnchantmentsFilter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(opponentEnchantmentsFilter, source.getControllerId(), source, game)) { permanent.destroy(source, game, false); } @@ -84,7 +84,7 @@ class CalmingVerseEffect extends OneShotEffect { if (controller != null) { if (game.getState().getBattlefield().countAll(untappedLandFilter, controller.getId(), game) > 0) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(controlledEnchantmentsFilter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(controlledEnchantmentsFilter, source.getControllerId(), source, game)) { permanent.destroy(source, game, false); } } diff --git a/Mage.Sets/src/mage/cards/c/Camaraderie.java b/Mage.Sets/src/mage/cards/c/Camaraderie.java index f5a43597849..8eea5f8f722 100644 --- a/Mage.Sets/src/mage/cards/c/Camaraderie.java +++ b/Mage.Sets/src/mage/cards/c/Camaraderie.java @@ -64,7 +64,7 @@ class CamaraderieEffect extends OneShotEffect { } int xValue = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); player.gainLife(xValue, game, source); player.drawCards(xValue, source, game); diff --git a/Mage.Sets/src/mage/cards/c/Camouflage.java b/Mage.Sets/src/mage/cards/c/Camouflage.java index 0d21c27c13b..d9728714b12 100644 --- a/Mage.Sets/src/mage/cards/c/Camouflage.java +++ b/Mage.Sets/src/mage/cards/c/Camouflage.java @@ -117,7 +117,7 @@ class CamouflageEffect extends ContinuousRuleModifyingEffectImpl { } if (defender.chooseUse(Outcome.Neutral, "Make a new blocker pile? If not, all remaining piles stay empty. (remaining piles: " + (attackerCount - masterList.size()) + ')', source, game)) { Target target = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), defenderId, game)) { + if (target.canChoose(defenderId, source, game)) { if (defender.chooseTarget(Outcome.Neutral, target, source, game)) { for (UUID creatureId : target.getTargets()) { Permanent creature = game.getPermanent(creatureId); diff --git a/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java b/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java index 45739de5709..449abacaec9 100644 --- a/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java +++ b/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java @@ -62,7 +62,7 @@ class CandlesOfLengEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if(controller == null || sourceObject == null){ return false; } diff --git a/Mage.Sets/src/mage/cards/c/CankerAbomination.java b/Mage.Sets/src/mage/cards/c/CankerAbomination.java index 5129e0b0273..7b2fdce35e8 100644 --- a/Mage.Sets/src/mage/cards/c/CankerAbomination.java +++ b/Mage.Sets/src/mage/cards/c/CankerAbomination.java @@ -72,7 +72,7 @@ class CankerAbominationEffect extends OneShotEffect { if (controller != null && cankerAbomination != null) { Target target = new TargetOpponent(); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { game.informPlayers(cankerAbomination.getName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName()); diff --git a/Mage.Sets/src/mage/cards/c/Capricopian.java b/Mage.Sets/src/mage/cards/c/Capricopian.java index 521a3696a6f..92c0fb04b2b 100644 --- a/Mage.Sets/src/mage/cards/c/Capricopian.java +++ b/Mage.Sets/src/mage/cards/c/Capricopian.java @@ -117,7 +117,7 @@ class CapricopianEffect extends OneShotEffect { filterPlayer.add(Predicates.not(new PlayerIdPredicate(permanent.getControllerId()))); filterPlayer.add(Predicates.not(new PlayerIdPredicate(game.getCombat().getDefenderId(permanent.getId())))); TargetPlayer targetPlayer = new TargetPlayer(0, 1, true, filterPlayer); - player.choose(outcome, targetPlayer, source.getSourceId(), game); + player.choose(outcome, targetPlayer, source, game); Player newPlayer = game.getPlayer(targetPlayer.getFirstTarget()); if (newPlayer == null) { return false; diff --git a/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java b/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java index 782d533d055..c66f8e7cd87 100644 --- a/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java +++ b/Mage.Sets/src/mage/cards/c/CarpetOfFlowers.java @@ -14,7 +14,6 @@ import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.common.TargetOpponent; @@ -131,7 +130,7 @@ class CarpetOfFlowersEffect extends ManaEffect { public List getNetMana(Game game, Ability source) { List netMana = new ArrayList<>(); if (game != null) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game); + int count = game.getBattlefield().count(filter, source.getTargets().getFirstTarget(), source, game); if (count > 0) { netMana.add(Mana.AnyMana(count)); } @@ -148,7 +147,7 @@ class CarpetOfFlowersEffect extends ManaEffect { Player controller = game.getPlayer(source.getControllerId()); ChoiceColor choice = new ChoiceColor(); if (controller != null && controller.choose(Outcome.Benefit, choice, game)) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game); + int count = game.getBattlefield().count(filter, source.getTargets().getFirstTarget(), source, game); if (count > 0) { switch (choice.getChoice()) { case "Black": diff --git a/Mage.Sets/src/mage/cards/c/CarrionThrash.java b/Mage.Sets/src/mage/cards/c/CarrionThrash.java index 9b671db3adf..b030aabaced 100644 --- a/Mage.Sets/src/mage/cards/c/CarrionThrash.java +++ b/Mage.Sets/src/mage/cards/c/CarrionThrash.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.costs.mana.GenericManaCost; @@ -13,11 +11,12 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterCreatureCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; +import java.util.UUID; + /** - * * @author North */ public final class CarrionThrash extends CardImpl { @@ -25,7 +24,7 @@ public final class CarrionThrash extends CardImpl { private static final FilterCreatureCard filter = new FilterCreatureCard("another target creature card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public CarrionThrash(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/c/CastleGarenbrig.java b/Mage.Sets/src/mage/cards/c/CastleGarenbrig.java index b97b7bd31fa..e2ebf923851 100644 --- a/Mage.Sets/src/mage/cards/c/CastleGarenbrig.java +++ b/Mage.Sets/src/mage/cards/c/CastleGarenbrig.java @@ -90,7 +90,7 @@ enum CastleGarenbrigManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.isCreature(game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/Cataclysm.java b/Mage.Sets/src/mage/cards/c/Cataclysm.java index df46dd71517..e307076e49d 100644 --- a/Mage.Sets/src/mage/cards/c/Cataclysm.java +++ b/Mage.Sets/src/mage/cards/c/Cataclysm.java @@ -67,8 +67,8 @@ class CataclysmEffect extends OneShotEffect { Target target3 = new TargetControlledPermanent(1, 1, new FilterControlledEnchantmentPermanent(), true); Target target4 = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true); - if (target1.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target1.isChosen() && target1.canChoose(source.getSourceId(), player.getId(), game)) { + if (target1.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target1.isChosen() && target1.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target1, source, game); } Permanent artifact = game.getPermanent(target1.getFirstTarget()); @@ -78,8 +78,8 @@ class CataclysmEffect extends OneShotEffect { target1.clearChosen(); } - if (target2.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target2.isChosen() && target2.canChoose(source.getSourceId(), player.getId(), game)) { + if (target2.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target2.isChosen() && target2.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target2, source, game); } Permanent creature = game.getPermanent(target2.getFirstTarget()); @@ -89,8 +89,8 @@ class CataclysmEffect extends OneShotEffect { target2.clearChosen(); } - if (target3.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target3.isChosen() && target3.canChoose(source.getSourceId(), player.getId(), game)) { + if (target3.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target3.isChosen() && target3.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target3, source, game); } Permanent enchantment = game.getPermanent(target3.getFirstTarget()); @@ -100,8 +100,8 @@ class CataclysmEffect extends OneShotEffect { target3.clearChosen(); } - if (target4.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target4.isChosen() && target4.canChoose(source.getSourceId(), player.getId(), game)) { + if (target4.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target4.isChosen() && target4.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target4, source, game); } Permanent land = game.getPermanent(target4.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/CataclysmicGearhulk.java b/Mage.Sets/src/mage/cards/c/CataclysmicGearhulk.java index f86a5525c8c..57e82bd582b 100644 --- a/Mage.Sets/src/mage/cards/c/CataclysmicGearhulk.java +++ b/Mage.Sets/src/mage/cards/c/CataclysmicGearhulk.java @@ -100,8 +100,8 @@ class CataclysmicGearhulkEffect extends OneShotEffect { Target target3 = new TargetControlledPermanent(1, 1, filterEnchantment, true); Target target4 = new TargetControlledPermanent(1, 1, filterPlaneswalker, true); - if (target1.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target1.isChosen() && target1.canChoose(source.getSourceId(), player.getId(), game)) { + if (target1.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target1.isChosen() && target1.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target1, source, game); } Permanent artifact = game.getPermanent(target1.getFirstTarget()); @@ -111,8 +111,8 @@ class CataclysmicGearhulkEffect extends OneShotEffect { target1.clearChosen(); } - if (target2.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target2.isChosen() && target2.canChoose(source.getSourceId(), player.getId(), game)) { + if (target2.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target2.isChosen() && target2.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target2, source, game); } Permanent creature = game.getPermanent(target2.getFirstTarget()); @@ -122,8 +122,8 @@ class CataclysmicGearhulkEffect extends OneShotEffect { target2.clearChosen(); } - if (target3.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target3.isChosen() && target3.canChoose(source.getSourceId(), player.getId(), game)) { + if (target3.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target3.isChosen() && target3.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target3, source, game); } Permanent enchantment = game.getPermanent(target3.getFirstTarget()); @@ -133,8 +133,8 @@ class CataclysmicGearhulkEffect extends OneShotEffect { target3.clearChosen(); } - if (target4.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target4.isChosen() && target4.canChoose(source.getSourceId(), player.getId(), game)) { + if (target4.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target4.isChosen() && target4.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target4, source, game); } Permanent planeswalker = game.getPermanent(target4.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/Catastrophe.java b/Mage.Sets/src/mage/cards/c/Catastrophe.java index fb8ae17279d..74ef2af9065 100644 --- a/Mage.Sets/src/mage/cards/c/Catastrophe.java +++ b/Mage.Sets/src/mage/cards/c/Catastrophe.java @@ -58,11 +58,11 @@ class CatastropheEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (controller.chooseUse(outcome, "Destroy all lands? (otherwise all creatures are destroyed)", source, game)) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterLandPermanent(), controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterLandPermanent(), controller.getId(), source, game)) { permanent.destroy(source, game, permanent.isCreature(game)); } } else { - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source, game)) { permanent.destroy(source, game, true); } } diff --git a/Mage.Sets/src/mage/cards/c/CatchRelease.java b/Mage.Sets/src/mage/cards/c/CatchRelease.java index 93024ebc137..a281c668697 100644 --- a/Mage.Sets/src/mage/cards/c/CatchRelease.java +++ b/Mage.Sets/src/mage/cards/c/CatchRelease.java @@ -86,8 +86,8 @@ class ReleaseSacrificeEffect extends OneShotEffect { Target target4 = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true); Target target5 = new TargetControlledPermanent(1, 1, new FilterControlledPlaneswalkerPermanent(), true); - if (target1.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target1.isChosen() && target1.canChoose(source.getSourceId(), player.getId(), game)) { + if (target1.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target1.isChosen() && target1.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target1, source, game); } Permanent artifact = game.getPermanent(target1.getFirstTarget()); @@ -97,8 +97,8 @@ class ReleaseSacrificeEffect extends OneShotEffect { target1.clearChosen(); } - if (target2.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target2.isChosen() && target2.canChoose(source.getSourceId(), player.getId(), game)) { + if (target2.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target2.isChosen() && target2.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target2, source, game); } Permanent creature = game.getPermanent(target2.getFirstTarget()); @@ -108,8 +108,8 @@ class ReleaseSacrificeEffect extends OneShotEffect { target2.clearChosen(); } - if (target3.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target3.isChosen() && target3.canChoose(source.getSourceId(), player.getId(), game)) { + if (target3.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target3.isChosen() && target3.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target3, source, game); } Permanent enchantment = game.getPermanent(target3.getFirstTarget()); @@ -119,8 +119,8 @@ class ReleaseSacrificeEffect extends OneShotEffect { target3.clearChosen(); } - if (target4.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target4.isChosen() && target4.canChoose(source.getSourceId(), player.getId(), game)) { + if (target4.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target4.isChosen() && target4.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target4, source, game); } Permanent land = game.getPermanent(target4.getFirstTarget()); @@ -130,8 +130,8 @@ class ReleaseSacrificeEffect extends OneShotEffect { target4.clearChosen(); } - if (target5.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target5.isChosen() && target5.canChoose(source.getSourceId(), player.getId(), game)) { + if (target5.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target5.isChosen() && target5.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target5, source, game); } Permanent planeswalker = game.getPermanent(target5.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/CauldronDance.java b/Mage.Sets/src/mage/cards/c/CauldronDance.java index 035584db826..88c38e6fda9 100644 --- a/Mage.Sets/src/mage/cards/c/CauldronDance.java +++ b/Mage.Sets/src/mage/cards/c/CauldronDance.java @@ -119,7 +119,7 @@ class CauldronDancePutCreatureFromHandOntoBattlefieldEffect extends OneShotEffec if (controller != null) { if (controller.chooseUse(Outcome.PutCreatureInPlay, CHOICE_TEXT, source, game)) { TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { diff --git a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java index ea0ac58c26a..3acd3b26d27 100644 --- a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java +++ b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java @@ -67,7 +67,7 @@ class CavernOfSoulsManaBuilder extends ConditionalManaBuilder { creatureType = subType; } Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && mana.getAny() == 0) { game.informPlayers(controller.getLogName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() + " (can only be spend to cast for creatures of type " + creatureType + " and that spell can't be countered)"); @@ -108,7 +108,7 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition { // check: ... to cast a creature spell if (super.apply(game, source)) { // check: ... of the chosen type - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) { return true; } @@ -170,7 +170,7 @@ class CavernOfSoulsCantCounterEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This spell can't be countered because a colored mana from " + sourceObject.getName() + " was spent to cast it."; } diff --git a/Mage.Sets/src/mage/cards/c/CeaseFire.java b/Mage.Sets/src/mage/cards/c/CeaseFire.java index dc559d1afe9..3683fe6f949 100644 --- a/Mage.Sets/src/mage/cards/c/CeaseFire.java +++ b/Mage.Sets/src/mage/cards/c/CeaseFire.java @@ -64,7 +64,7 @@ class CeaseFireEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast creature spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java b/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java index 47fcbcb28f7..4bf241f98c4 100644 --- a/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java +++ b/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java @@ -70,7 +70,7 @@ class CelebrateTheHarvestEffect extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ) .stream() .filter(Objects::nonNull) diff --git a/Mage.Sets/src/mage/cards/c/CelestialJudgment.java b/Mage.Sets/src/mage/cards/c/CelestialJudgment.java index 5ac6057ad24..b62c88ea32d 100644 --- a/Mage.Sets/src/mage/cards/c/CelestialJudgment.java +++ b/Mage.Sets/src/mage/cards/c/CelestialJudgment.java @@ -68,7 +68,7 @@ class CelestialJudgmentEffect extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_PERMANENT_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ); Map> powerMap = permanents .stream() @@ -89,7 +89,7 @@ class CelestialJudgmentEffect extends OneShotEffect { filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, entry.getKey())); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); toKeep.add(target.getFirstTarget()); } for (Permanent permanent : permanents) { diff --git a/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java b/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java index 60b72184552..439ea276999 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryDesecrator.java @@ -88,7 +88,7 @@ class CemeteryDesecratorEffect extends OneShotEffect { if (controller != null) { TargetCardInGraveyard target = new TargetCardInGraveyard(filter); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { int manaValue = card.getManaValue(); diff --git a/Mage.Sets/src/mage/cards/c/CemeteryGatekeeper.java b/Mage.Sets/src/mage/cards/c/CemeteryGatekeeper.java index 4bdcc579128..26b3af039da 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryGatekeeper.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryGatekeeper.java @@ -83,7 +83,7 @@ class CemeteryGatekeeperEffect extends OneShotEffect { if (controller != null) { TargetCardInGraveyard target = new TargetCardInGraveyard(); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); diff --git a/Mage.Sets/src/mage/cards/c/CemeteryIlluminator.java b/Mage.Sets/src/mage/cards/c/CemeteryIlluminator.java index 20d51cabb6a..160d30bba59 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryIlluminator.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryIlluminator.java @@ -88,7 +88,7 @@ class CemeteryIlluminatorExileEffect extends OneShotEffect { if (controller != null) { TargetCardInGraveyard target = new TargetCardInGraveyard(); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); diff --git a/Mage.Sets/src/mage/cards/c/CemeteryProtector.java b/Mage.Sets/src/mage/cards/c/CemeteryProtector.java index 79cfa40752a..f3eed733466 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryProtector.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryProtector.java @@ -84,7 +84,7 @@ class CemeteryProtectorEffect extends OneShotEffect { if (controller != null) { TargetCardInGraveyard target = new TargetCardInGraveyard(); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); diff --git a/Mage.Sets/src/mage/cards/c/CemeteryProwler.java b/Mage.Sets/src/mage/cards/c/CemeteryProwler.java index d70f7aafbe4..2c841a7d97d 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryProwler.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryProwler.java @@ -76,7 +76,7 @@ class CemeteryProwlerExileEffect extends OneShotEffect { if (controller != null) { TargetCardInGraveyard target = new TargetCardInGraveyard(); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); diff --git a/Mage.Sets/src/mage/cards/c/CephalidShrine.java b/Mage.Sets/src/mage/cards/c/CephalidShrine.java index 32d77b5d345..66e6072566f 100644 --- a/Mage.Sets/src/mage/cards/c/CephalidShrine.java +++ b/Mage.Sets/src/mage/cards/c/CephalidShrine.java @@ -95,7 +95,7 @@ class CephalidShrineEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int count = 0; - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject); if (spell != null) { diff --git a/Mage.Sets/src/mage/cards/c/CerebralEruption.java b/Mage.Sets/src/mage/cards/c/CerebralEruption.java index d72297536a3..1200f337456 100644 --- a/Mage.Sets/src/mage/cards/c/CerebralEruption.java +++ b/Mage.Sets/src/mage/cards/c/CerebralEruption.java @@ -53,7 +53,7 @@ class CerebralEruptionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null && player.getLibrary().hasCards()) { Card card = player.getLibrary().getFromTop(game); Cards cards = new CardsImpl(card); diff --git a/Mage.Sets/src/mage/cards/c/ChandraAblaze.java b/Mage.Sets/src/mage/cards/c/ChandraAblaze.java index 0b607a83a26..9806fd544c3 100644 --- a/Mage.Sets/src/mage/cards/c/ChandraAblaze.java +++ b/Mage.Sets/src/mage/cards/c/ChandraAblaze.java @@ -11,7 +11,10 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.cards.CardsImpl; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; import mage.filter.FilterCard; import mage.filter.StaticFilters; import mage.filter.common.FilterInstantOrSorceryCard; @@ -84,7 +87,7 @@ class ChandraAblazeEffect1 extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { TargetDiscard target = new TargetDiscard(player.getId()); - player.choose(Outcome.Discard, target, source.getSourceId(), game); + player.choose(Outcome.Discard, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { player.discard(card, false, source, game); diff --git a/Mage.Sets/src/mage/cards/c/ChandraHeartOfFire.java b/Mage.Sets/src/mage/cards/c/ChandraHeartOfFire.java index 1a0f5432850..fbf1ddfd3bb 100644 --- a/Mage.Sets/src/mage/cards/c/ChandraHeartOfFire.java +++ b/Mage.Sets/src/mage/cards/c/ChandraHeartOfFire.java @@ -101,16 +101,16 @@ class ChandraHeartOfFireUltimateEffect extends OneShotEffect { // from graveyard Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter, true).withChooseHint("from graveyard"); - if (target.canChoose(source.getSourceId(), controller.getId(), game) - && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game) + && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), source, game)) { Set cards = new CardsImpl(target.getTargets()).getCards(game); exiledCards.addAll(cards); } // from library target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter).withChooseHint("from library"); - if (target.canChoose(source.getSourceId(), controller.getId(), game) - && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game) + && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), source, game)) { Set cards = new CardsImpl(target.getTargets()).getCards(game); exiledCards.addAll(cards); } diff --git a/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java b/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java index 3eb7d4bcc1c..e267aa4e980 100644 --- a/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java +++ b/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java @@ -126,16 +126,16 @@ class ChandraPyromasterTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); for (StackObject item : game.getState().getStack()) { - if (item.getId().equals(sourceId)) { + if (item.getId().equals(source.getSourceId())) { object = item; } - if (item.getSourceId().equals(sourceId)) { + if (item.getSourceId().equals(source.getSourceId())) { object = item; } } diff --git a/Mage.Sets/src/mage/cards/c/ChandrasEmbercat.java b/Mage.Sets/src/mage/cards/c/ChandrasEmbercat.java index e5f9e25542d..cfad9feed45 100644 --- a/Mage.Sets/src/mage/cards/c/ChandrasEmbercat.java +++ b/Mage.Sets/src/mage/cards/c/ChandrasEmbercat.java @@ -69,7 +69,7 @@ class ChandrasEmbercatElementalManaCondition extends CreatureCastManaCondition { if (!super.apply(game, source)) { return false; } - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object == null) { return false; } @@ -84,7 +84,7 @@ class ChandrasEmbercatPlaneswalkerManaCondition extends PlaneswalkerCastManaCond if (!super.apply(game, source)) { return false; } - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/ChandrasIgnition.java b/Mage.Sets/src/mage/cards/c/ChandrasIgnition.java index 28393821c59..9398409ceb1 100644 --- a/Mage.Sets/src/mage/cards/c/ChandrasIgnition.java +++ b/Mage.Sets/src/mage/cards/c/ChandrasIgnition.java @@ -57,7 +57,7 @@ class ChandrasIgnitionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null && targetCreature.getPower().getValue() > 0) { - for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!creature.getId().equals(targetCreature.getId())) { creature.damage(targetCreature.getPower().getValue(), targetCreature.getId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/c/ChandrasTriumph.java b/Mage.Sets/src/mage/cards/c/ChandrasTriumph.java index 356df7abe44..6fe22ed35fd 100644 --- a/Mage.Sets/src/mage/cards/c/ChandrasTriumph.java +++ b/Mage.Sets/src/mage/cards/c/ChandrasTriumph.java @@ -75,7 +75,7 @@ class ChandrasTriumphEffect extends OneShotEffect { return false; } int damage = 3; - if (!game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).isEmpty()) { + if (!game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).isEmpty()) { damage = 5; } return permanent.damage(damage, source.getSourceId(), source, game) > 0; diff --git a/Mage.Sets/src/mage/cards/c/ChaosMoon.java b/Mage.Sets/src/mage/cards/c/ChaosMoon.java index 6741496ba70..b389e080d3f 100644 --- a/Mage.Sets/src/mage/cards/c/ChaosMoon.java +++ b/Mage.Sets/src/mage/cards/c/ChaosMoon.java @@ -81,7 +81,7 @@ class ChaosMoonEffect extends OneShotEffect { return false; } int permanentsInPlay = game.getBattlefield().count( - StaticFilters.FILTER_PERMANENT, source.getSourceId(), source.getControllerId(), game + StaticFilters.FILTER_PERMANENT, source.getControllerId(), source, game ); // Odd if (permanentsInPlay % 2 == 1) { diff --git a/Mage.Sets/src/mage/cards/c/ChaosWarp.java b/Mage.Sets/src/mage/cards/c/ChaosWarp.java index 3d24bfa2ec7..06308ce2694 100644 --- a/Mage.Sets/src/mage/cards/c/ChaosWarp.java +++ b/Mage.Sets/src/mage/cards/c/ChaosWarp.java @@ -98,7 +98,7 @@ class ChaosWarpRevealEffect extends OneShotEffect { return false; } Player owner = game.getPlayer(permanent.getOwnerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (owner == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/Chaosphere.java b/Mage.Sets/src/mage/cards/c/Chaosphere.java index 166e589e985..ae385300615 100644 --- a/Mage.Sets/src/mage/cards/c/Chaosphere.java +++ b/Mage.Sets/src/mage/cards/c/Chaosphere.java @@ -74,7 +74,7 @@ class ChaosphereEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/c/CharmedGriffin.java b/Mage.Sets/src/mage/cards/c/CharmedGriffin.java index b751cbf3692..d5ab22e938d 100644 --- a/Mage.Sets/src/mage/cards/c/CharmedGriffin.java +++ b/Mage.Sets/src/mage/cards/c/CharmedGriffin.java @@ -76,9 +76,9 @@ class CharmedGriffinEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { TargetCardInHand target = new TargetCardInHand(new FilterArtifactOrEnchantmentCard()); - if (target.canChoose(source.getSourceId(), playerId, game) + if (target.canChoose(playerId, source, game) && player.chooseUse(Outcome.Neutral, "Put an artifact or enchantment card from your hand onto the battlefield?", source, game) - && player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + && player.choose(Outcome.PutCardInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { toBattlefield.add(card); diff --git a/Mage.Sets/src/mage/cards/c/CharmingPrince.java b/Mage.Sets/src/mage/cards/c/CharmingPrince.java index 8dbcf612dc3..16623a0ebca 100644 --- a/Mage.Sets/src/mage/cards/c/CharmingPrince.java +++ b/Mage.Sets/src/mage/cards/c/CharmingPrince.java @@ -90,7 +90,7 @@ class CharmingPrinceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/ChecksAndBalances.java b/Mage.Sets/src/mage/cards/c/ChecksAndBalances.java index f6fb669a3a3..2e44f6c2c66 100644 --- a/Mage.Sets/src/mage/cards/c/ChecksAndBalances.java +++ b/Mage.Sets/src/mage/cards/c/ChecksAndBalances.java @@ -11,7 +11,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SetTargetPointer; -import mage.filter.FilterSpell; import mage.filter.StaticFilters; import mage.game.Game; import mage.game.stack.Spell; @@ -103,7 +102,7 @@ class ChecksAndBalancesEffect extends OneShotEffect { Player player = game.getPlayer(uuid); if (player != null && !player.getHand().isEmpty()) { TargetCardInHand target = new TargetCardInHand(); - if (player.choose(Outcome.Discard, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Discard, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); player.discard(card, false, source, game); } diff --git a/Mage.Sets/src/mage/cards/c/ChemistersTrick.java b/Mage.Sets/src/mage/cards/c/ChemistersTrick.java index 812b25bfdac..a8d4b4527b4 100644 --- a/Mage.Sets/src/mage/cards/c/ChemistersTrick.java +++ b/Mage.Sets/src/mage/cards/c/ChemistersTrick.java @@ -64,7 +64,7 @@ class ChemistersTrickEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source, game)) { AttacksIfAbleTargetEffect effect = new AttacksIfAbleTargetEffect(Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(creature.getId(), game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/c/ChimneyImp.java b/Mage.Sets/src/mage/cards/c/ChimneyImp.java index 8c50b7c30f7..f817a846733 100644 --- a/Mage.Sets/src/mage/cards/c/ChimneyImp.java +++ b/Mage.Sets/src/mage/cards/c/ChimneyImp.java @@ -75,7 +75,7 @@ class ChimneyImpEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand(); target.setNotTarget(true); target.setTargetName("a card from your hand to put on top of your library"); - targetOpponent.choose(Outcome.Detriment, target, source.getSourceId(), game); + targetOpponent.choose(Outcome.Detriment, target, source, game); Card card = targetOpponent.getHand().get(target.getFirstTarget(), game); if (card != null) { targetOpponent.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false); diff --git a/Mage.Sets/src/mage/cards/c/ChitteringRats.java b/Mage.Sets/src/mage/cards/c/ChitteringRats.java index 6e9a871b659..a9ff004eda8 100644 --- a/Mage.Sets/src/mage/cards/c/ChitteringRats.java +++ b/Mage.Sets/src/mage/cards/c/ChitteringRats.java @@ -72,7 +72,7 @@ class ChitteringRatsEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand(); target.setNotTarget(true); target.setTargetName("a card from your hand to put on top of your library"); - targetOpponent.choose(Outcome.Detriment, target, source.getSourceId(), game); + targetOpponent.choose(Outcome.Detriment, target, source, game); Card card = targetOpponent.getHand().get(target.getFirstTarget(), game); if (card != null) { targetOpponent.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false); diff --git a/Mage.Sets/src/mage/cards/c/ChoArrimAlchemist.java b/Mage.Sets/src/mage/cards/c/ChoArrimAlchemist.java index d4ce9c681e4..867c5d4b3a3 100644 --- a/Mage.Sets/src/mage/cards/c/ChoArrimAlchemist.java +++ b/Mage.Sets/src/mage/cards/c/ChoArrimAlchemist.java @@ -79,7 +79,7 @@ class ChoArrimAlchemistEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/c/ChromeMox.java b/Mage.Sets/src/mage/cards/c/ChromeMox.java index 0b7ccdc18c4..0c5f47e9c4f 100644 --- a/Mage.Sets/src/mage/cards/c/ChromeMox.java +++ b/Mage.Sets/src/mage/cards/c/ChromeMox.java @@ -81,7 +81,7 @@ class ChromeMoxEffect extends OneShotEffect { target.setNotTarget(true); Card cardToImprint = null; Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (!controller.getHand().isEmpty() && controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (!controller.getHand().isEmpty() && controller.choose(Outcome.Benefit, target, source, game)) { cardToImprint = controller.getHand().get(target.getFirstTarget(), game); } if (sourcePermanent != null) { diff --git a/Mage.Sets/src/mage/cards/c/ChromeReplicator.java b/Mage.Sets/src/mage/cards/c/ChromeReplicator.java index 3bfecae7b0c..ea8e2c44bb2 100644 --- a/Mage.Sets/src/mage/cards/c/ChromeReplicator.java +++ b/Mage.Sets/src/mage/cards/c/ChromeReplicator.java @@ -70,7 +70,7 @@ enum ChromeReplicatorCondition implements Condition { return game .getBattlefield() .getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ).stream() .filter(Objects::nonNull) .map(MageObject::getName) diff --git a/Mage.Sets/src/mage/cards/c/CinderheartGiant.java b/Mage.Sets/src/mage/cards/c/CinderheartGiant.java index 4dc474cf9fe..41edce72e3b 100644 --- a/Mage.Sets/src/mage/cards/c/CinderheartGiant.java +++ b/Mage.Sets/src/mage/cards/c/CinderheartGiant.java @@ -70,7 +70,7 @@ class CinderheartGiantEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ) < 1) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CityInABottle.java b/Mage.Sets/src/mage/cards/c/CityInABottle.java index 30d668281d3..2177c78905e 100644 --- a/Mage.Sets/src/mage/cards/c/CityInABottle.java +++ b/Mage.Sets/src/mage/cards/c/CityInABottle.java @@ -158,7 +158,7 @@ class CityInABottleStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().contains(filter, this.getSourceId(), this.getControllerId(), game, 1); + return game.getBattlefield().contains(filter, this.getSourceId(), this.getControllerId(), this, game, 1); } @Override @@ -192,7 +192,7 @@ class CityInABottleSacrificeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.sacrifice(source, game); } return true; @@ -239,6 +239,6 @@ class CityInABottleCantPlayEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getSourceId()); - return filter.match(card, source.getSourceId(), source.getControllerId(), game); + return filter.match(card, source.getControllerId(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/c/CityOfSolitude.java b/Mage.Sets/src/mage/cards/c/CityOfSolitude.java index fdb24401c75..409048a05e4 100644 --- a/Mage.Sets/src/mage/cards/c/CityOfSolitude.java +++ b/Mage.Sets/src/mage/cards/c/CityOfSolitude.java @@ -57,7 +57,7 @@ class CityOfSolitudeEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); MageObject eventObject = game.getObject(event.getSourceId()); if (sourceObject != null && eventObject != null) { return "You can cast or activate anability of " + eventObject.getIdName() + " only during your own turns (" + sourceObject.getIdName() + "). "; diff --git a/Mage.Sets/src/mage/cards/c/ClackbridgeTroll.java b/Mage.Sets/src/mage/cards/c/ClackbridgeTroll.java index 0388d41c922..12609ef38c0 100644 --- a/Mage.Sets/src/mage/cards/c/ClackbridgeTroll.java +++ b/Mage.Sets/src/mage/cards/c/ClackbridgeTroll.java @@ -94,9 +94,9 @@ class ClackbridgeTrollEffect extends OneShotEffect { } TargetControlledPermanent target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), opponent.getId(), game) + if (!target.canChoose(opponent.getId(), source, game) || !opponent.chooseUse(Outcome.AIDontUseIt, "Sacrifice a creature?", source, game) - || !opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + || !opponent.choose(Outcome.Sacrifice, target, source, game)) { continue; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/Clambassadors.java b/Mage.Sets/src/mage/cards/c/Clambassadors.java index f1a37fd465b..ddf3f37cc3e 100644 --- a/Mage.Sets/src/mage/cards/c/Clambassadors.java +++ b/Mage.Sets/src/mage/cards/c/Clambassadors.java @@ -81,8 +81,8 @@ class ClambassadorsEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } diff --git a/Mage.Sets/src/mage/cards/c/ClarionUltimatum.java b/Mage.Sets/src/mage/cards/c/ClarionUltimatum.java index 53c5deacce1..2835ac886e3 100644 --- a/Mage.Sets/src/mage/cards/c/ClarionUltimatum.java +++ b/Mage.Sets/src/mage/cards/c/ClarionUltimatum.java @@ -69,11 +69,11 @@ class ClarionUltimatumEffect extends OneShotEffect { } int permCount = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); TargetPermanent targetPermanent = new TargetControlledPermanent(Math.max(permCount, 5)); targetPermanent.setNotTarget(true); - player.choose(outcome, targetPermanent, source.getSourceId(), game); + player.choose(outcome, targetPermanent, source, game); Set names = targetPermanent .getTargets() .stream() diff --git a/Mage.Sets/src/mage/cards/c/CleansingMeditation.java b/Mage.Sets/src/mage/cards/c/CleansingMeditation.java index 31adc723dc5..b3716a38538 100644 --- a/Mage.Sets/src/mage/cards/c/CleansingMeditation.java +++ b/Mage.Sets/src/mage/cards/c/CleansingMeditation.java @@ -73,7 +73,7 @@ class CleansingMeditationEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) { if (permanent != null && permanent.destroy(source, game, false)) { if (threshold && controller != null && permanent.isOwnedBy(controller.getId())) { cardsToBattlefield.add(permanent); diff --git a/Mage.Sets/src/mage/cards/c/ClingingMists.java b/Mage.Sets/src/mage/cards/c/ClingingMists.java index 7506823282f..bed1c919805 100644 --- a/Mage.Sets/src/mage/cards/c/ClingingMists.java +++ b/Mage.Sets/src/mage/cards/c/ClingingMists.java @@ -63,7 +63,7 @@ class ClingingMistsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List doNotUntapNextUntapStep = new ArrayList<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_ATTACKING_CREATURES, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_ATTACKING_CREATURES, source.getControllerId(), source, game)) { creature.tap(source, game); doNotUntapNextUntapStep.add(creature); } diff --git a/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java b/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java index 1f092551139..0c60bfbff9b 100644 --- a/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java +++ b/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java @@ -82,7 +82,7 @@ class CloudstoneCurioEffect extends OneShotEffect { )); TargetPermanent target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) { + if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { Permanent returningCreature = game.getPermanent(target.getFirstTarget()); if (returningCreature != null) { controller.moveCards(returningCreature, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/c/CoalitionVictory.java b/Mage.Sets/src/mage/cards/c/CoalitionVictory.java index a39235a3e78..ff12aa73d88 100644 --- a/Mage.Sets/src/mage/cards/c/CoalitionVictory.java +++ b/Mage.Sets/src/mage/cards/c/CoalitionVictory.java @@ -68,33 +68,33 @@ class CoalitionVictoryCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - if (game.getBattlefield().count(CoalitionVictory.filterPlains, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterPlains, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterIsland, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterIsland, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterSwamp, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterSwamp, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterMountain, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterMountain, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterForest, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterForest, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterWhite, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterWhite, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterBlue, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterBlue, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterBlack, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterBlack, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(CoalitionVictory.filterRed, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(CoalitionVictory.filterRed, source.getControllerId(), source, game) < 1) { return false; } - return game.getBattlefield().count(CoalitionVictory.filterGreen, source.getSourceId(), source.getControllerId(), game) >= 1; + return game.getBattlefield().count(CoalitionVictory.filterGreen, source.getControllerId(), source, game) >= 1; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java b/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java index ec9e1197732..8c461e68ae1 100644 --- a/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java +++ b/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java @@ -150,7 +150,7 @@ class ColfenorsPlansLookAtCardEffect extends AsThoughEffectImpl { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java b/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java index 46df2f9f3f9..da26d1ad12f 100644 --- a/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java +++ b/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java @@ -95,7 +95,7 @@ class ColfenorsUrnCondition implements Condition { @Override public final boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { UUID exileId = CardUtil.getCardExileZoneId(game, source); ExileZone exile = game.getExile().getExileZone(exileId); diff --git a/Mage.Sets/src/mage/cards/c/CommuneWithTheGods.java b/Mage.Sets/src/mage/cards/c/CommuneWithTheGods.java index f9f80f6b0ed..bad93618d42 100644 --- a/Mage.Sets/src/mage/cards/c/CommuneWithTheGods.java +++ b/Mage.Sets/src/mage/cards/c/CommuneWithTheGods.java @@ -63,7 +63,7 @@ class CommuneWithTheGodsEffect extends OneShotEffect { FilterCard filterPutInHand = new FilterCard("creature or enchantment card to put in hand"); filterPutInHand.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate())); controller.revealCards(source, cards, game); - if (cards.count(filterPutInHand, source.getSourceId(), source.getControllerId(), game) > 0) { + if (cards.count(filterPutInHand, source.getControllerId(), source, game) > 0) { TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, filterPutInHand); if (controller.choose(Outcome.DrawCard, cards, target, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/CompulsiveResearch.java b/Mage.Sets/src/mage/cards/c/CompulsiveResearch.java index 840f57400ec..e7eaa81f986 100644 --- a/Mage.Sets/src/mage/cards/c/CompulsiveResearch.java +++ b/Mage.Sets/src/mage/cards/c/CompulsiveResearch.java @@ -67,7 +67,7 @@ class CompulsiveResearchDiscardEffect extends OneShotEffect { return !targetPlayer.discard(2, false, false, source, game).isEmpty(); } TargetDiscard target = new TargetDiscard(StaticFilters.FILTER_CARD_LAND_A, targetPlayer.getId()); - targetPlayer.choose(Outcome.Discard, target, source.getSourceId(), game); + targetPlayer.choose(Outcome.Discard, target, source, game); Card card = targetPlayer.getHand().get(target.getFirstTarget(), game); if (card != null && targetPlayer.discard(card, false, source, game)) { return true; diff --git a/Mage.Sets/src/mage/cards/c/ConchHorn.java b/Mage.Sets/src/mage/cards/c/ConchHorn.java index 1fd78493047..a73e76cc1a7 100644 --- a/Mage.Sets/src/mage/cards/c/ConchHorn.java +++ b/Mage.Sets/src/mage/cards/c/ConchHorn.java @@ -73,7 +73,7 @@ class ConchHornEffect extends OneShotEffect { private boolean putOnLibrary(Player player, Ability source, Game game) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/c/ConfoundingConundrum.java b/Mage.Sets/src/mage/cards/c/ConfoundingConundrum.java index f393c1e6cd6..e8ceb3d5a4a 100644 --- a/Mage.Sets/src/mage/cards/c/ConfoundingConundrum.java +++ b/Mage.Sets/src/mage/cards/c/ConfoundingConundrum.java @@ -106,10 +106,10 @@ class ConfoundingConundrumEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(1, StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + if (!target.canChoose(player.getId(), source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/c/CongregationAtDawn.java b/Mage.Sets/src/mage/cards/c/CongregationAtDawn.java index 9d48fa444ea..d1d604e46f5 100644 --- a/Mage.Sets/src/mage/cards/c/CongregationAtDawn.java +++ b/Mage.Sets/src/mage/cards/c/CongregationAtDawn.java @@ -61,7 +61,7 @@ class CongregationAtDawnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCreatureCard("creature cards")); if (controller.searchLibrary(target, source, game)) { diff --git a/Mage.Sets/src/mage/cards/c/ConniveConcoct.java b/Mage.Sets/src/mage/cards/c/ConniveConcoct.java index d6144105e87..5cd00455179 100644 --- a/Mage.Sets/src/mage/cards/c/ConniveConcoct.java +++ b/Mage.Sets/src/mage/cards/c/ConniveConcoct.java @@ -93,7 +93,7 @@ class ConcoctEffect extends OneShotEffect { player.surveil(3, source, game); Target target = new TargetCardInYourGraveyard(filter); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game)); effect.apply(game, source); diff --git a/Mage.Sets/src/mage/cards/c/ConsumingTide.java b/Mage.Sets/src/mage/cards/c/ConsumingTide.java index 3e71ee8ec1c..01834bd2d68 100644 --- a/Mage.Sets/src/mage/cards/c/ConsumingTide.java +++ b/Mage.Sets/src/mage/cards/c/ConsumingTide.java @@ -70,7 +70,7 @@ class ConsumingTideEffect extends OneShotEffect { if (player != null) { TargetNonlandPermanent target = new TargetNonlandPermanent(); target.setNotTarget(true); - player.choose(Outcome.Benefit, target, source.getSourceId(), game); + player.choose(Outcome.Benefit, target, source, game); UUID permId = target.getFirstTarget(); if (permId != null) { chosenPermanents.add(permId); @@ -78,7 +78,7 @@ class ConsumingTideEffect extends OneShotEffect { } } HashSet permanentsToHand = new HashSet<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, controller.getId(), source, game)) { if (!chosenPermanents.contains(permanent.getId())) { permanentsToHand.add(permanent); } diff --git a/Mage.Sets/src/mage/cards/c/ConsumingVapors.java b/Mage.Sets/src/mage/cards/c/ConsumingVapors.java index f78dfbe7333..487f6ebb6c5 100644 --- a/Mage.Sets/src/mage/cards/c/ConsumingVapors.java +++ b/Mage.Sets/src/mage/cards/c/ConsumingVapors.java @@ -64,8 +64,8 @@ class ConsumingVaporsEffect extends OneShotEffect { filter.add(TargetController.YOU.getControllerPredicate()); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - if (player != null && target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (player != null && target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java b/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java index 91cdb882c24..592ff34873f 100644 --- a/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java +++ b/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java @@ -60,12 +60,12 @@ class CoordinatedBarrageEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice choice = new ChoiceCreatureType(game.getObject(source)); if (controller.choose(Outcome.Damage, choice, game)) { String chosenType = choice.getChoice(); FilterControlledPermanent filter = new FilterControlledPermanent(); filter.add(SubType.byDescription(chosenType).getPredicate()); - int damageDealt = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int damageDealt = game.getBattlefield().count(filter, source.getControllerId(), source, game); Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { permanent.damage(damageDealt, source.getSourceId(), source, game, false, true); diff --git a/Mage.Sets/src/mage/cards/c/CopperhornScout.java b/Mage.Sets/src/mage/cards/c/CopperhornScout.java index 7be18f955d6..2887e93527c 100644 --- a/Mage.Sets/src/mage/cards/c/CopperhornScout.java +++ b/Mage.Sets/src/mage/cards/c/CopperhornScout.java @@ -16,7 +16,6 @@ import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -91,7 +90,7 @@ class CopperhornScoutUntapEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for ( Permanent creature : creatures ) { if ( !creature.getId().equals(source.getSourceId()) ) { diff --git a/Mage.Sets/src/mage/cards/c/CorpseChurn.java b/Mage.Sets/src/mage/cards/c/CorpseChurn.java index e27a3ade3a0..dd337e59ea5 100644 --- a/Mage.Sets/src/mage/cards/c/CorpseChurn.java +++ b/Mage.Sets/src/mage/cards/c/CorpseChurn.java @@ -64,9 +64,9 @@ class CorpseChurnEffect extends OneShotEffect { } TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseUse(outcome, "Return a creature card from your graveyard to hand?", source, game) - && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + && controller.choose(Outcome.ReturnToHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/c/CorpseHauler.java b/Mage.Sets/src/mage/cards/c/CorpseHauler.java index 443a0974058..7f98451e9ed 100644 --- a/Mage.Sets/src/mage/cards/c/CorpseHauler.java +++ b/Mage.Sets/src/mage/cards/c/CorpseHauler.java @@ -14,7 +14,7 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -26,7 +26,7 @@ public final class CorpseHauler extends CardImpl { private static final FilterCard filter = new FilterCard("another target creature card from your graveyard"); static { filter.add(CardType.CREATURE.getPredicate()); - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public CorpseHauler(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/c/Corrosion.java b/Mage.Sets/src/mage/cards/c/Corrosion.java index 309a29fadd2..665c49792f5 100644 --- a/Mage.Sets/src/mage/cards/c/Corrosion.java +++ b/Mage.Sets/src/mage/cards/c/Corrosion.java @@ -82,7 +82,7 @@ class CorrosionUpkeepEffect extends OneShotEffect { } } // destroy each artifact with converted mana cost less than or equal to the number of rust counters on it - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent.getManaValue() <= permanent.getCounters(game).getCount(CounterType.RUST)) { permanent.destroy(source, game, true); } diff --git a/Mage.Sets/src/mage/cards/c/Corrupt.java b/Mage.Sets/src/mage/cards/c/Corrupt.java index 6931d7489f4..09efcf60797 100644 --- a/Mage.Sets/src/mage/cards/c/Corrupt.java +++ b/Mage.Sets/src/mage/cards/c/Corrupt.java @@ -60,7 +60,7 @@ class CorruptEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int amount = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (amount > 0) { int damageDealt = amount; Permanent permanent = game.getPermanent(source.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/CorruptedCrossroads.java b/Mage.Sets/src/mage/cards/c/CorruptedCrossroads.java index b8d17d2578c..e915c4aeeb1 100644 --- a/Mage.Sets/src/mage/cards/c/CorruptedCrossroads.java +++ b/Mage.Sets/src/mage/cards/c/CorruptedCrossroads.java @@ -69,7 +69,7 @@ class BlightedCrossroadsConditionalMana extends ConditionalMana { class BlightedCrossroadsManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null) { for (Ability ability: object.getAbilities()) { if (ability instanceof DevoidAbility) { diff --git a/Mage.Sets/src/mage/cards/c/CouncilOfTheAbsolute.java b/Mage.Sets/src/mage/cards/c/CouncilOfTheAbsolute.java index 54da84be391..69990b3afc8 100644 --- a/Mage.Sets/src/mage/cards/c/CouncilOfTheAbsolute.java +++ b/Mage.Sets/src/mage/cards/c/CouncilOfTheAbsolute.java @@ -76,7 +76,7 @@ class CouncilOfTheAbsoluteReplacementEffect extends ContinuousRuleModifyingEffec @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast a spell with that name (" + mageObject.getName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/c/CouncilsJudgment.java b/Mage.Sets/src/mage/cards/c/CouncilsJudgment.java index 1c722445761..bc6f5f584e0 100644 --- a/Mage.Sets/src/mage/cards/c/CouncilsJudgment.java +++ b/Mage.Sets/src/mage/cards/c/CouncilsJudgment.java @@ -17,7 +17,6 @@ import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.Target; import mage.target.TargetPermanent; import java.util.LinkedHashSet; @@ -95,13 +94,13 @@ class CouncilsJudgmentVote extends VoteHandler { @Override public Permanent playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) { - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) < 1) { return null; } TargetPermanent target = new TargetPermanent(1, filter); target.withChooseHint(voteInfo + " (to exile)"); target.setNotTarget(true); - decidingPlayer.choose(Outcome.Exile, target, source.getSourceId(), game); + decidingPlayer.choose(Outcome.Exile, target, source, game); return game.getPermanent(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/c/CourtHomunculus.java b/Mage.Sets/src/mage/cards/c/CourtHomunculus.java index f1c52d18e70..6d02aa9b1e3 100644 --- a/Mage.Sets/src/mage/cards/c/CourtHomunculus.java +++ b/Mage.Sets/src/mage/cards/c/CourtHomunculus.java @@ -54,7 +54,7 @@ class ControlsAnotherArtifactCondition implements Condition { public boolean apply(Game game, Ability source) { List controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game); for (Permanent permanent : controlledArtifacts) { - if (!permanent.getId().equals(game.getObject(source.getSourceId()).getId())) { + if (!permanent.getId().equals(game.getObject(source).getId())) { return true; } } diff --git a/Mage.Sets/src/mage/cards/c/CourtOfAmbition.java b/Mage.Sets/src/mage/cards/c/CourtOfAmbition.java index 453c0f88b8f..9cf70bf1ce5 100644 --- a/Mage.Sets/src/mage/cards/c/CourtOfAmbition.java +++ b/Mage.Sets/src/mage/cards/c/CourtOfAmbition.java @@ -82,7 +82,7 @@ class CourtOfAmbitionEffect extends OneShotEffect { continue; } TargetDiscard target = new TargetDiscard(discardCount, StaticFilters.FILTER_CARD, playerId); - player.choose(Outcome.Discard, target, source.getSourceId(), game); + player.choose(Outcome.Discard, target, source, game); discardMap.put(playerId, new CardsImpl(target.getTargets())); } for (Map.Entry entry : discardMap.entrySet()) { diff --git a/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java b/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java index c3b97c757dc..e525d953b48 100644 --- a/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java +++ b/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java @@ -1,7 +1,7 @@ package mage.cards.c; -import java.util.UUID; +import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.ChooseCreatureTypeEffect; @@ -14,8 +14,9 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class CoverOfDarkness extends CardImpl { @@ -58,10 +59,10 @@ class FilterCoverOfDarkness extends FilterCreaturePermanent { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (super.match(permanent, sourceId, playerId, game)) { + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (super.match(permanent, playerId, source, game)) { if (subType == null) { - subType = ChooseCreatureTypeEffect.getChosenCreatureType(sourceId, game); + subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game); if (subType == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CracklingDoom.java b/Mage.Sets/src/mage/cards/c/CracklingDoom.java index e7a57c37b0f..e3d85a853be 100644 --- a/Mage.Sets/src/mage/cards/c/CracklingDoom.java +++ b/Mage.Sets/src/mage/cards/c/CracklingDoom.java @@ -93,7 +93,7 @@ class CracklingDoomEffect extends OneShotEffect { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature to sacrifice with power equal to " + greatestPower); filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, greatestPower)); Target target = new TargetControlledCreaturePermanent(filter); - if (opponent.choose(outcome, target, playerId, game)) { + if (opponent.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { toSacrifice.add(permanent); diff --git a/Mage.Sets/src/mage/cards/c/CrashingBoars.java b/Mage.Sets/src/mage/cards/c/CrashingBoars.java index b9e66a2c13f..d2c5a1e4c71 100644 --- a/Mage.Sets/src/mage/cards/c/CrashingBoars.java +++ b/Mage.Sets/src/mage/cards/c/CrashingBoars.java @@ -74,7 +74,7 @@ class CrashingBoarsEffect extends OneShotEffect { Player defendingPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (defendingPlayer != null) { Target target = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (target.choose(Outcome.Neutral, defendingPlayer.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Neutral, defendingPlayer.getId(), source.getSourceId(), source, game)) { RequirementEffect effect = new MustBeBlockedByTargetSourceEffect(); effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/c/CreditVoucher.java b/Mage.Sets/src/mage/cards/c/CreditVoucher.java index 2fdc5e4bc6a..5b7a871fa5e 100644 --- a/Mage.Sets/src/mage/cards/c/CreditVoucher.java +++ b/Mage.Sets/src/mage/cards/c/CreditVoucher.java @@ -65,13 +65,13 @@ class CreditVoucherEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { FilterCard filter = new FilterCard("card in your hand to shuffle away"); TargetCardInHand target = new TargetCardInHand(0, controller.getHand().size(), filter); target.setRequired(false); int amountShuffled = 0; - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { amountShuffled = target.getTargets().size(); controller.moveCards(new CardsImpl(target.getTargets()), Zone.LIBRARY, source, game); diff --git a/Mage.Sets/src/mage/cards/c/CreepingInn.java b/Mage.Sets/src/mage/cards/c/CreepingInn.java index 5ba7b0aa98c..81125611374 100644 --- a/Mage.Sets/src/mage/cards/c/CreepingInn.java +++ b/Mage.Sets/src/mage/cards/c/CreepingInn.java @@ -84,8 +84,8 @@ class CreepingInnEffect extends OneShotEffect { UUID exileId = CardUtil.getExileZoneId(game, source); TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - if (player.choose(Outcome.Exile, target, source.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { + if (player.choose(Outcome.Exile, target, source, game)) { Card cardChosen = game.getCard(target.getFirstTarget()); if (cardChosen != null) { int lifeAmount = 0; diff --git a/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java b/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java index 10f09e1f1d3..23cbf17c3ae 100644 --- a/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java +++ b/Mage.Sets/src/mage/cards/c/CreepingRenaissance.java @@ -10,7 +10,6 @@ import mage.choices.Choice; import mage.choices.ChoiceCardType; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.TimingRule; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; @@ -76,7 +75,7 @@ class CreepingRenaissanceEffect extends OneShotEffect { } FilterCard filter = new FilterCard(chosenType.toString().toLowerCase(Locale.ENGLISH) + " card"); filter.add(chosenType.getPredicate()); - return controller.moveCards(controller.getGraveyard().getCards(filter, source.getSourceId(), controller.getId(), game), Zone.HAND, source, game); + return controller.moveCards(controller.getGraveyard().getCards(filter, controller.getId(), source, game), Zone.HAND, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/c/Cromat.java b/Mage.Sets/src/mage/cards/c/Cromat.java index ce52d89df43..dc49bb0e3e4 100644 --- a/Mage.Sets/src/mage/cards/c/Cromat.java +++ b/Mage.Sets/src/mage/cards/c/Cromat.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -15,24 +13,30 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; +import mage.constants.SubType; import mage.constants.SuperType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class Cromat extends CardImpl { - + + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public Cromat(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}{U}{B}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{U}{B}{R}{G}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.ILLUSION); @@ -40,20 +44,31 @@ public final class Cromat extends CardImpl { this.toughness = new MageInt(5); // {W}{B}: Destroy target creature blocking or blocked by Cromat. - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by Cromat"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{W}{B}")); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility( + new DestroyTargetEffect(), new ManaCostsImpl<>("{W}{B}") + ); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); + // {U}{R}: Cromat gains flying until end of turn. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{U}{R}"))); + this.addAbility(new SimpleActivatedAbility(new GainAbilitySourceEffect( + FlyingAbility.getInstance(), Duration.EndOfTurn + ), new ManaCostsImpl<>("{U}{R}"))); + // {B}{G}: Regenerate Cromat. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{B}{G}"))); + this.addAbility(new SimpleActivatedAbility( + new RegenerateSourceEffect(), new ManaCostsImpl<>("{B}{G}") + )); + // {R}{W}: Cromat gets +1/+1 until end of turn. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1,1, Duration.EndOfTurn), new ManaCostsImpl("{R}{W}"))); + this.addAbility(new SimpleActivatedAbility(new BoostSourceEffect( + 1, 1, Duration.EndOfTurn + ), new ManaCostsImpl<>("{R}{W}"))); + // {G}{U}: Put Cromat on top of its owner's library. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutOnLibrarySourceEffect(true), new ManaCostsImpl("{G}{U}"))); + this.addAbility(new SimpleActivatedAbility( + new PutOnLibrarySourceEffect(true), new ManaCostsImpl<>("{G}{U}") + )); } private Cromat(final Cromat card) { diff --git a/Mage.Sets/src/mage/cards/c/CrownOfConvergence.java b/Mage.Sets/src/mage/cards/c/CrownOfConvergence.java index c23faefedb9..d344968c4b6 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfConvergence.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfConvergence.java @@ -75,7 +75,7 @@ class CrownOfConvergenceColorBoostEffect extends BoostAllEffect { if (you != null) { Card topCard = you.getLibrary().getFromTop(game); if (topCard != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source, game)) { if (permanent.getColor(game).shares(topCard.getColor(game)) && !permanent.getColor(game).isColorless()) { permanent.addPower(power.calculate(game, source, this)); permanent.addToughness(toughness.calculate(game, source, this)); diff --git a/Mage.Sets/src/mage/cards/c/CrownOfDoom.java b/Mage.Sets/src/mage/cards/c/CrownOfDoom.java index 5fcb5a82d9c..0d05fa45b1d 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfDoom.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfDoom.java @@ -78,7 +78,7 @@ enum CrownOfDoomPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { Player targetPlayer = input.getObject(); - Permanent sourceObject = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourceObject = input.getSource().getSourcePermanentOrLKI(game); if (targetPlayer == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CrownOfTheAges.java b/Mage.Sets/src/mage/cards/c/CrownOfTheAges.java index 2dfd51581aa..2201e4b4702 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfTheAges.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfTheAges.java @@ -91,8 +91,8 @@ class CrownOfTheAgesEffect extends OneShotEffect { Target chosenCreatureToAttachAura = new TargetPermanent(filterChoice); chosenCreatureToAttachAura.setNotTarget(true); - if (chosenCreatureToAttachAura.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.Neutral, chosenCreatureToAttachAura, source.getSourceId(), game)) { + if (chosenCreatureToAttachAura.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.Neutral, chosenCreatureToAttachAura, source, game)) { Permanent creatureToAttachAura = game.getPermanent(chosenCreatureToAttachAura.getFirstTarget()); if (creatureToAttachAura != null) { if (passed) { diff --git a/Mage.Sets/src/mage/cards/c/CrucibleOfTheSpiritDragon.java b/Mage.Sets/src/mage/cards/c/CrucibleOfTheSpiritDragon.java index ea8181859f4..9d089af6268 100644 --- a/Mage.Sets/src/mage/cards/c/CrucibleOfTheSpiritDragon.java +++ b/Mage.Sets/src/mage/cards/c/CrucibleOfTheSpiritDragon.java @@ -89,7 +89,7 @@ class CrucibleOfTheSpiritDragonManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.hasSubtype(SubType.DRAGON, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/CruelReality.java b/Mage.Sets/src/mage/cards/c/CruelReality.java index e3249e40188..b80779dbeaf 100644 --- a/Mage.Sets/src/mage/cards/c/CruelReality.java +++ b/Mage.Sets/src/mage/cards/c/CruelReality.java @@ -86,8 +86,8 @@ class CruelRealityEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), cursedPlayer.getId(), game) - && cursedPlayer.choose(Outcome.Sacrifice, target, source.getId(), game)) { + if (target.canChoose(cursedPlayer.getId(), source, game) + && cursedPlayer.choose(Outcome.Sacrifice, target, source, game)) { Permanent objectToBeSacrificed = game.getPermanent(target.getFirstTarget()); if (objectToBeSacrificed != null) { if (objectToBeSacrificed.sacrifice(source, game)) { diff --git a/Mage.Sets/src/mage/cards/c/CruelUltimatum.java b/Mage.Sets/src/mage/cards/c/CruelUltimatum.java index a1eae80d39f..6abad936cb2 100644 --- a/Mage.Sets/src/mage/cards/c/CruelUltimatum.java +++ b/Mage.Sets/src/mage/cards/c/CruelUltimatum.java @@ -73,7 +73,7 @@ class CruelUltimatumEffect extends OneShotEffect { return false; } TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); - controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game); + controller.choose(Outcome.ReturnToHand, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { return controller.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/c/CrushUnderfoot.java b/Mage.Sets/src/mage/cards/c/CrushUnderfoot.java index 0b2ceda2144..6ddb8c5ce71 100644 --- a/Mage.Sets/src/mage/cards/c/CrushUnderfoot.java +++ b/Mage.Sets/src/mage/cards/c/CrushUnderfoot.java @@ -72,7 +72,7 @@ class CrushUnderfootEffect extends OneShotEffect { if (controller != null) { // Choose a Giant creature you control (not targeted, happens during effect resolving ) Target target = new TargetControlledCreaturePermanent(1,1, filter,false); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { Permanent giant = game.getPermanent(target.getFirstTarget()); if (giant != null) { diff --git a/Mage.Sets/src/mage/cards/c/CryptChampion.java b/Mage.Sets/src/mage/cards/c/CryptChampion.java index fbf59417c09..1b30f26a4c2 100644 --- a/Mage.Sets/src/mage/cards/c/CryptChampion.java +++ b/Mage.Sets/src/mage/cards/c/CryptChampion.java @@ -89,7 +89,7 @@ class CryptChampionEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(playerId)); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4)); Target target = new TargetCardInGraveyard(filter); - if (target.canChoose(source.getSourceId(), playerId, game) + if (target.canChoose(playerId, source, game) && player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/c/CrypticCommand.java b/Mage.Sets/src/mage/cards/c/CrypticCommand.java index e158fd11e71..9fa79b8c413 100644 --- a/Mage.Sets/src/mage/cards/c/CrypticCommand.java +++ b/Mage.Sets/src/mage/cards/c/CrypticCommand.java @@ -79,7 +79,7 @@ class CrypticCommandEffect extends OneShotEffect { if (player == null) { return false; } - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, player.getId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, player.getId(), source, game)) { creature.tap(source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/c/CrypticGateway.java b/Mage.Sets/src/mage/cards/c/CrypticGateway.java index 28396688e11..252f348067f 100644 --- a/Mage.Sets/src/mage/cards/c/CrypticGateway.java +++ b/Mage.Sets/src/mage/cards/c/CrypticGateway.java @@ -70,7 +70,7 @@ class CrypticGatewayCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { int numTargets = 0; Set permanents = new HashSet<>(); - while (numTargets < 2 && target.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) { + while (numTargets < 2 && target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { @@ -92,7 +92,7 @@ class CrypticGatewayCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } public CrypticGatewayPredicate getPredicate() { diff --git a/Mage.Sets/src/mage/cards/c/CrystalChimes.java b/Mage.Sets/src/mage/cards/c/CrystalChimes.java index 4e55d14de5d..9e7fc9141fd 100644 --- a/Mage.Sets/src/mage/cards/c/CrystalChimes.java +++ b/Mage.Sets/src/mage/cards/c/CrystalChimes.java @@ -63,8 +63,8 @@ class CrystalChimesEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - return controller.moveCards(controller.getGraveyard().getCards(new FilterEnchantmentCard(), source.getSourceId(), - source.getControllerId(), game), Zone.HAND, source, game); + return controller.moveCards(controller.getGraveyard().getCards(new FilterEnchantmentCard(), + source.getControllerId(), source, game), Zone.HAND, source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/c/CullingRitual.java b/Mage.Sets/src/mage/cards/c/CullingRitual.java index 4d1f414ecfb..d6bf290d208 100644 --- a/Mage.Sets/src/mage/cards/c/CullingRitual.java +++ b/Mage.Sets/src/mage/cards/c/CullingRitual.java @@ -71,7 +71,7 @@ class CullingRitualEffect extends OneShotEffect { } int counter = 0; for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { counter += permanent.destroy(source, game, false) ? 1 : 0; } diff --git a/Mage.Sets/src/mage/cards/c/CullingScales.java b/Mage.Sets/src/mage/cards/c/CullingScales.java index 9bddf1d536c..eb804a02a8b 100644 --- a/Mage.Sets/src/mage/cards/c/CullingScales.java +++ b/Mage.Sets/src/mage/cards/c/CullingScales.java @@ -58,7 +58,7 @@ class HasLowestCMCAmongstNonlandPermanentsPredicate implements ObjectSourcePlaye public boolean apply(ObjectSourcePlayer input, Game game) { FilterPermanent filter = new FilterNonlandPermanent(); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, input.getObject().getManaValue())); - return !game.getBattlefield().contains(filter, input.getSourceId(), input.getPlayerId(), game, 1); + return !game.getBattlefield().contains(filter, input.getSourceId(), input.getPlayerId(), input.getSource(), game, 1); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/c/CultOfTheWaxingMoon.java b/Mage.Sets/src/mage/cards/c/CultOfTheWaxingMoon.java index dad7df6f206..aac52d5533b 100644 --- a/Mage.Sets/src/mage/cards/c/CultOfTheWaxingMoon.java +++ b/Mage.Sets/src/mage/cards/c/CultOfTheWaxingMoon.java @@ -73,7 +73,7 @@ class CultOfTheWaxingMoonAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); - return filter.match(permanent, getSourceId(), getControllerId(), game); + return filter.match(permanent, getControllerId(), this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/c/Cultivate.java b/Mage.Sets/src/mage/cards/c/Cultivate.java index 579ebda3c3d..48fe88af542 100644 --- a/Mage.Sets/src/mage/cards/c/Cultivate.java +++ b/Mage.Sets/src/mage/cards/c/Cultivate.java @@ -63,7 +63,7 @@ class CultivateEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CultivatorColossus.java b/Mage.Sets/src/mage/cards/c/CultivatorColossus.java index 1e30399f6eb..8689cf4afc9 100644 --- a/Mage.Sets/src/mage/cards/c/CultivatorColossus.java +++ b/Mage.Sets/src/mage/cards/c/CultivatorColossus.java @@ -82,7 +82,7 @@ class CultivatorColossusEffect extends OneShotEffect { TargetCard target = new TargetCardInHand( 0, 1, StaticFilters.FILTER_CARD_LAND ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { break; diff --git a/Mage.Sets/src/mage/cards/c/CultivatorDrone.java b/Mage.Sets/src/mage/cards/c/CultivatorDrone.java index 8341e351bc8..9ad8d2038f5 100644 --- a/Mage.Sets/src/mage/cards/c/CultivatorDrone.java +++ b/Mage.Sets/src/mage/cards/c/CultivatorDrone.java @@ -80,7 +80,7 @@ class CultivatorDroneManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.getColor(game).isColorless()) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/CulturalExchange.java b/Mage.Sets/src/mage/cards/c/CulturalExchange.java index 740d5c8f4f8..630f77988f6 100644 --- a/Mage.Sets/src/mage/cards/c/CulturalExchange.java +++ b/Mage.Sets/src/mage/cards/c/CulturalExchange.java @@ -73,17 +73,17 @@ class CulturalExchangeEffect extends OneShotEffect { FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creatures " + player2.getLogName() + " controls"); filter1.add(new ControllerIdPredicate(player1.getId())); filter2.add(new ControllerIdPredicate(player2.getId())); - int creatureCount1 = game.getBattlefield().count(filter1, source.getSourceId(), source.getControllerId(), game); - int creatureCount2 = game.getBattlefield().count(filter2, source.getSourceId(), source.getControllerId(), game); + int creatureCount1 = game.getBattlefield().count(filter1, source.getControllerId(), source, game); + int creatureCount2 = game.getBattlefield().count(filter2, source.getControllerId(), source, game); int creaturesToSwitch = Math.min(creatureCount1, creatureCount2); if (creaturesToSwitch == 0) { return true; } TargetCreaturePermanent target1 = new TargetCreaturePermanent(0, creaturesToSwitch, filter1, true); - if (target1.choose(Outcome.Benefit, controller.getId(), source.getSourceId(), game)) { + if (target1.choose(Outcome.Benefit, controller.getId(), source.getSourceId(), source, game)) { int otherToSwitch = target1.getTargets().size(); TargetCreaturePermanent target2 = new TargetCreaturePermanent(otherToSwitch, otherToSwitch, filter2, true); - if (target2.choose(Outcome.Benefit, controller.getId(), source.getSourceId(), game)) { + if (target2.choose(Outcome.Benefit, controller.getId(), source.getSourceId(), source, game)) { for (UUID creatureId : target1.getTargets()) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { diff --git a/Mage.Sets/src/mage/cards/c/CunningAbduction.java b/Mage.Sets/src/mage/cards/c/CunningAbduction.java index b3f5c7f8dae..8346b21c01a 100644 --- a/Mage.Sets/src/mage/cards/c/CunningAbduction.java +++ b/Mage.Sets/src/mage/cards/c/CunningAbduction.java @@ -66,7 +66,7 @@ class CunningAbductionExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (opponent != null && sourceObject != null) { opponent.revealCards(sourceObject.getName(), opponent.getHand(), game); Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/c/Curfew.java b/Mage.Sets/src/mage/cards/c/Curfew.java index 09962322f25..dfa61d4627a 100644 --- a/Mage.Sets/src/mage/cards/c/Curfew.java +++ b/Mage.Sets/src/mage/cards/c/Curfew.java @@ -3,7 +3,6 @@ package mage.cards.c; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -57,7 +56,7 @@ class CurfewEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game) > 0) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_CREATURE, true); - player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game); + player.choose(Outcome.ReturnToHand, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { player.moveCards(permanent, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/c/CurseOfConformity.java b/Mage.Sets/src/mage/cards/c/CurseOfConformity.java index 41d8c9d9d19..08121eda261 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfConformity.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfConformity.java @@ -75,7 +75,7 @@ class CurseOfConformityEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { switch (layer) { case TypeChangingEffects_4: diff --git a/Mage.Sets/src/mage/cards/c/CurseOfHospitality.java b/Mage.Sets/src/mage/cards/c/CurseOfHospitality.java index 28264cd8bdd..d24421778ba 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfHospitality.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfHospitality.java @@ -75,7 +75,7 @@ enum CurseOfHospitalityPredicate implements ObjectSourcePlayerPredicate input, Game game) { - Permanent permanent = game.getPermanent(input.getSourceId()); + Permanent permanent = input.getSource().getSourcePermanentIfItStillExists(game); UUID defenderId = game.getCombat().getDefenderId(input.getObject().getId()); return permanent != null && defenderId != null && defenderId.equals(permanent.getAttachedTo()); } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfLeeches.java b/Mage.Sets/src/mage/cards/c/CurseOfLeeches.java index 8758a9d82b7..7f57e1ac4fd 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfLeeches.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfLeeches.java @@ -83,7 +83,7 @@ class CurseOfLeechesEffect extends ReplacementEffectImpl { } TargetPlayer target = new TargetPlayer(); target.withChooseHint("Player to attach to").setNotTarget(true); - controller.choose(Outcome.Detriment, target, source.getSourceId(), game); + controller.choose(Outcome.Detriment, target, source, game); Permanent permanent = source.getSourcePermanentIfItStillExists(game); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/c/CurseOfTheCabal.java b/Mage.Sets/src/mage/cards/c/CurseOfTheCabal.java index b5c96b950ca..48a77cf2ba7 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfTheCabal.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfTheCabal.java @@ -85,10 +85,10 @@ class CurseOfTheCabalSacrificeEffect extends OneShotEffect { return true; } Target target = new TargetControlledPermanent(amount, amount, StaticFilters.FILTER_CONTROLLED_PERMANENT, true); - if (target.canChoose(source.getSourceId(), targetPlayer.getId(), game)) { + if (target.canChoose(targetPlayer.getId(), source, game)) { while (!target.isChosen() - && target.canChoose(source.getSourceId(), targetPlayer.getId(), game) && targetPlayer.canRespond()) { - targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + && target.canChoose(targetPlayer.getId(), source, game) && targetPlayer.canRespond()) { + targetPlayer.choose(Outcome.Sacrifice, target, source, game); } //sacrifice all chosen (non null) permanents target.getTargets().stream() diff --git a/Mage.Sets/src/mage/cards/c/CurseOfThePiercedHeart.java b/Mage.Sets/src/mage/cards/c/CurseOfThePiercedHeart.java index 1841f5cac30..d59cbc44296 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfThePiercedHeart.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfThePiercedHeart.java @@ -78,7 +78,7 @@ class CurseOfThePiercedHeartEffect extends OneShotEffect { if (controller == null || opponent == null) { return false; } - if (game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, source.getSourceId(), opponent.getId(), game) < 1 + if (game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, opponent.getId(), source, game) < 1 || !controller.chooseUse(Outcome.Damage, "Redirect to a planeswalker controlled by " + opponent.getLogName() + "?", source, game)) { return opponent.damage(1, source.getSourceId(), source, game) > 0; } @@ -86,7 +86,7 @@ class CurseOfThePiercedHeartEffect extends OneShotEffect { filter.add(new ControllerIdPredicate(opponent.getId())); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { return permanent.damage(1, source.getSourceId(), source, game, false, true) > 0; diff --git a/Mage.Sets/src/mage/cards/c/CursedScroll.java b/Mage.Sets/src/mage/cards/c/CursedScroll.java index 2c73f1c341d..07347ac7d4c 100644 --- a/Mage.Sets/src/mage/cards/c/CursedScroll.java +++ b/Mage.Sets/src/mage/cards/c/CursedScroll.java @@ -59,7 +59,7 @@ class CursedScrollEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (sourceObject != null && controller != null && cardName != null && !cardName.isEmpty()) { if (!controller.getHand().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/c/CustodiSquire.java b/Mage.Sets/src/mage/cards/c/CustodiSquire.java index e7f0179df61..7482f8be3d4 100644 --- a/Mage.Sets/src/mage/cards/c/CustodiSquire.java +++ b/Mage.Sets/src/mage/cards/c/CustodiSquire.java @@ -104,7 +104,7 @@ class CustodiSquireVote extends VoteHandler { public Card playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null || controller.getGraveyard().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ) < 1) { return null; } diff --git a/Mage.Sets/src/mage/cards/c/CutTheTethers.java b/Mage.Sets/src/mage/cards/c/CutTheTethers.java index ff6c7f510c4..d63bf76705b 100644 --- a/Mage.Sets/src/mage/cards/c/CutTheTethers.java +++ b/Mage.Sets/src/mage/cards/c/CutTheTethers.java @@ -67,7 +67,7 @@ class CutTheTethersEffect extends OneShotEffect { } Cards toHand = new CardsImpl(); for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { Player player = game.getPlayer(permanent.getOwnerId()); if (player == null) { diff --git a/Mage.Sets/src/mage/cards/c/CyberdriveAwakener.java b/Mage.Sets/src/mage/cards/c/CyberdriveAwakener.java index a1cfa8d872e..4418ffff38d 100644 --- a/Mage.Sets/src/mage/cards/c/CyberdriveAwakener.java +++ b/Mage.Sets/src/mage/cards/c/CyberdriveAwakener.java @@ -80,7 +80,7 @@ class CyberdriveAwakenerEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); game.getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game) + .getActivePermanents(filter, source.getControllerId(), source, game) .stream() .filter(Objects::nonNull) .map(permanent -> new MageObjectReference(permanent, game)) diff --git a/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java b/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java index 88cdd41de4f..85d7b3a4ab0 100644 --- a/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java +++ b/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java @@ -69,7 +69,7 @@ class CyclopsGladiatorEffect extends OneShotEffect { filter.add(new ControllerIdPredicate(defenderId)); TargetCreaturePermanent target = new TargetCreaturePermanent(filter); Player player = game.getPlayer(source.getControllerId()); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { if (player != null && player.chooseTarget(Outcome.Detriment, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent cyclops = game.getPermanent(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java b/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java index 28b49ec0c78..88312e02a36 100644 --- a/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java +++ b/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java @@ -83,7 +83,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) { diff --git a/Mage.Sets/src/mage/cards/d/DalakosCrafterOfWonders.java b/Mage.Sets/src/mage/cards/d/DalakosCrafterOfWonders.java index 0e7fc4685c1..e925f4042c8 100644 --- a/Mage.Sets/src/mage/cards/d/DalakosCrafterOfWonders.java +++ b/Mage.Sets/src/mage/cards/d/DalakosCrafterOfWonders.java @@ -97,7 +97,7 @@ enum DalakosCrafterOfWondersCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isArtifact(game); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/d/DanseMacabre.java b/Mage.Sets/src/mage/cards/d/DanseMacabre.java index 1b767ccae65..04e3c7ffab6 100644 --- a/Mage.Sets/src/mage/cards/d/DanseMacabre.java +++ b/Mage.Sets/src/mage/cards/d/DanseMacabre.java @@ -87,13 +87,13 @@ class DanseMacabreEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player == null || game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ) < 1) { continue; } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { continue; @@ -124,7 +124,7 @@ class DanseMacabreEffect extends OneShotEffect { return true; } target.setNotTarget(true); - controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game); + controller.choose(Outcome.PutCreatureInPlay, target, source, game); controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java b/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java index ca776d07782..ccd5f04e61c 100644 --- a/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java +++ b/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java @@ -82,7 +82,7 @@ class DarettiSacrificeEffect extends OneShotEffect { return false; } Target target = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true); - if (!target.canChoose(source.getSourceId(), controller.getId(), game) + if (!target.canChoose(controller.getId(), source, game) || !controller.chooseTarget(outcome, target, source, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java b/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java index 2ffdcc63812..72f7d565315 100644 --- a/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java +++ b/Mage.Sets/src/mage/cards/d/DarigaazTheIgniter.java @@ -79,7 +79,7 @@ class DarigaazTheIgniterEffect extends OneShotEffect { damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(choice.getColor())); - int damage = damagedPlayer.getHand().count(filter, source.getSourceId(), source.getControllerId(), game); + int damage = damagedPlayer.getHand().count(filter, source.getControllerId(), source, game); if (damage > 0) { damagedPlayer.damage(damage, source.getSourceId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/d/DaringThief.java b/Mage.Sets/src/mage/cards/d/DaringThief.java index 6638c65078f..8ca8d4fef4d 100644 --- a/Mage.Sets/src/mage/cards/d/DaringThief.java +++ b/Mage.Sets/src/mage/cards/d/DaringThief.java @@ -72,7 +72,7 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo @Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { if (super.canTarget(controllerId, id, source, game)) { - Set cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game); + Set cardTypes = getOpponentPermanentCardTypes(controllerId, game); Permanent permanent = game.getPermanent(id); for (CardType type : permanent.getCardType(game)) { if (cardTypes.contains(type)) { @@ -84,13 +84,13 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { // get all cardtypes from opponents permanents - Set cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game); + Set cardTypes = getOpponentPermanentCardTypes(sourceControllerId, game); Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { for (CardType type : permanent.getCardType(game)) { if (cardTypes.contains(type)) { @@ -109,7 +109,7 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo return new TargetControlledPermanentSharingOpponentPermanentCardType(this); } - private EnumSet getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) { + private EnumSet getOpponentPermanentCardTypes(UUID sourceControllerId, Game game) { Player controller = game.getPlayer(sourceControllerId); EnumSet cardTypes = EnumSet.noneOf(CardType.class); if (controller != null) { @@ -154,12 +154,12 @@ class DaringThiefSecondTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); if (firstTarget != null) { - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (permanent.shareTypes(firstTarget, game)) { possibleTargets.add(permanent.getId()); diff --git a/Mage.Sets/src/mage/cards/d/DarkIntimations.java b/Mage.Sets/src/mage/cards/d/DarkIntimations.java index 947dff69c8b..bdc801ede14 100644 --- a/Mage.Sets/src/mage/cards/d/DarkIntimations.java +++ b/Mage.Sets/src/mage/cards/d/DarkIntimations.java @@ -101,7 +101,7 @@ class DarkIntimationsEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { TargetPermanent target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } @@ -120,8 +120,8 @@ class DarkIntimationsEffect extends OneShotEffect { } } TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filterCard); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.ReturnToHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/d/DarkSphere.java b/Mage.Sets/src/mage/cards/d/DarkSphere.java index 7a170798509..dd33b03f9bd 100644 --- a/Mage.Sets/src/mage/cards/d/DarkSphere.java +++ b/Mage.Sets/src/mage/cards/d/DarkSphere.java @@ -70,13 +70,13 @@ class DarkSpherePreventionEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); DamageEvent damageEvent = (DamageEvent) event; if (controller != null) { controller.damage((int) Math.ceil(damageEvent.getAmount() / 2.0), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects()); diff --git a/Mage.Sets/src/mage/cards/d/DarkestHour.java b/Mage.Sets/src/mage/cards/d/DarkestHour.java index d8609cd4ea9..fcc3dabac5d 100644 --- a/Mage.Sets/src/mage/cards/d/DarkestHour.java +++ b/Mage.Sets/src/mage/cards/d/DarkestHour.java @@ -49,7 +49,7 @@ class DarkestHourEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { permanent.getColor(game).setColor(ObjectColor.BLACK); } return true; diff --git a/Mage.Sets/src/mage/cards/d/DaughterOfAutumn.java b/Mage.Sets/src/mage/cards/d/DaughterOfAutumn.java index 8bfcd985ede..5fe6e3339b0 100644 --- a/Mage.Sets/src/mage/cards/d/DaughterOfAutumn.java +++ b/Mage.Sets/src/mage/cards/d/DaughterOfAutumn.java @@ -81,7 +81,7 @@ class DaughterOfAutumnPreventDamageTargetEffect extends RedirectionEffect { public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { - if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { + if (filter.match(permanent, permanent.getControllerId(), source, game)) { if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { if (event.getTargetId() != null) { TargetPermanent target = new TargetPermanent(); diff --git a/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java b/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java index 535c7ab7ac0..7e2757a2c52 100644 --- a/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java +++ b/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java @@ -87,7 +87,7 @@ class DauntlessBodyguardChooseCreatureEffect extends OneShotEffect { Permanent mageObject = game.getPermanentEntering(source.getSourceId()); if (controller != null && mageObject != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (controller.choose(this.outcome, target, source.getSourceId(), game)) { + if (controller.choose(this.outcome, target, source, game)) { Permanent chosenCreature = game.getPermanent(target.getFirstTarget()); if (chosenCreature != null) { game.getState().setValue(mageObject.getId() + "_chosenCreature", new MageObjectReference(chosenCreature, game)); diff --git a/Mage.Sets/src/mage/cards/d/DauthiVoidwalker.java b/Mage.Sets/src/mage/cards/d/DauthiVoidwalker.java index e6fb283c5f9..f68400a3137 100644 --- a/Mage.Sets/src/mage/cards/d/DauthiVoidwalker.java +++ b/Mage.Sets/src/mage/cards/d/DauthiVoidwalker.java @@ -141,7 +141,7 @@ class DauthiVoidwalkerPlayEffect extends OneShotEffect { TargetCardInExile target = new TargetCardInExile( 0, 1, filter, null, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/d/DawnbreakReclaimer.java b/Mage.Sets/src/mage/cards/d/DawnbreakReclaimer.java index cb95219643b..e637f81d39f 100644 --- a/Mage.Sets/src/mage/cards/d/DawnbreakReclaimer.java +++ b/Mage.Sets/src/mage/cards/d/DawnbreakReclaimer.java @@ -94,8 +94,8 @@ class DawnbreakReclaimerEffect extends OneShotEffect { Player opponent = null; Card cardOpponentGraveyard = null; chosenCreatureOpponentGraveyard.setNotTarget(true); - if (chosenCreatureOpponentGraveyard.canChoose(source.getSourceId(), source.getControllerId(), game)) { - controller.choose(Outcome.Detriment, chosenCreatureOpponentGraveyard, source.getSourceId(), game); + if (chosenCreatureOpponentGraveyard.canChoose(source.getControllerId(), source, game)) { + controller.choose(Outcome.Detriment, chosenCreatureOpponentGraveyard, source, game); cardOpponentGraveyard = game.getCard(chosenCreatureOpponentGraveyard.getFirstTarget()); if (cardOpponentGraveyard != null) { opponent = game.getPlayer(cardOpponentGraveyard.getOwnerId()); @@ -109,7 +109,7 @@ class DawnbreakReclaimerEffect extends OneShotEffect { if (opponent == null) { // if no card from opponent was available controller has to chose an opponent to select a creature card in controllers graveyard TargetOpponent targetOpponent = new TargetOpponent(true); - controller.choose(outcome, targetOpponent, source.getSourceId(), game); + controller.choose(outcome, targetOpponent, source, game); opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent != null) { game.informPlayers(sourceObject.getLogName() @@ -126,8 +126,8 @@ class DawnbreakReclaimerEffect extends OneShotEffect { TargetCardInGraveyard targetControllerGaveyard = new TargetCardInGraveyard(filterCreatureCard); targetControllerGaveyard.setNotTarget(true); Card controllerCreatureCard = null; - if (targetControllerGaveyard.canChoose(source.getSourceId(), opponent.getId(), game) - && opponent.choose(outcome, targetControllerGaveyard, source.getSourceId(), game)) { + if (targetControllerGaveyard.canChoose(opponent.getId(), source, game) + && opponent.choose(outcome, targetControllerGaveyard, source, game)) { controllerCreatureCard = game.getCard(targetControllerGaveyard.getFirstTarget()); if (controllerCreatureCard != null) { game.informPlayers(sourceObject.getLogName() diff --git a/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java b/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java index 21cb9ee126a..4d4285d40c7 100644 --- a/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java +++ b/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java @@ -78,7 +78,7 @@ class DaxosOfMeletisEffect extends OneShotEffect { if (controller != null) { Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (damagedPlayer != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); UUID exileId = CardUtil.getCardExileZoneId(game, source); Card card = damagedPlayer.getLibrary().getFromTop(game); if (card != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/d/DayOfTheDragons.java b/Mage.Sets/src/mage/cards/d/DayOfTheDragons.java index e05dbda3c96..33d3c585840 100644 --- a/Mage.Sets/src/mage/cards/d/DayOfTheDragons.java +++ b/Mage.Sets/src/mage/cards/d/DayOfTheDragons.java @@ -69,7 +69,7 @@ class DayOfTheDragonsEntersEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Set toExile = new HashSet<>(); toExile.addAll(game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)); diff --git a/Mage.Sets/src/mage/cards/d/DeadReckoning.java b/Mage.Sets/src/mage/cards/d/DeadReckoning.java index 5909fb861a1..a412639041f 100644 --- a/Mage.Sets/src/mage/cards/d/DeadReckoning.java +++ b/Mage.Sets/src/mage/cards/d/DeadReckoning.java @@ -63,10 +63,10 @@ class DeadReckoningEffect extends OneShotEffect { TargetCreaturePermanent target2 = new TargetCreaturePermanent(); if (controller != null) { - if (target1.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.Benefit, target1, source.getSourceId(), game) - && target2.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.Damage, target2, source.getSourceId(), game)) { + if (target1.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.Benefit, target1, source, game) + && target2.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.Damage, target2, source, game)) { Card creatureInGraveyard = game.getCard(target1.getFirstTarget()); if (creatureInGraveyard != null) { if (controller.putCardsOnTopOfLibrary(creatureInGraveyard, game, source, true)) { diff --git a/Mage.Sets/src/mage/cards/d/DeadlyBrew.java b/Mage.Sets/src/mage/cards/d/DeadlyBrew.java index 35c6fcf026f..0f9db1d9a64 100644 --- a/Mage.Sets/src/mage/cards/d/DeadlyBrew.java +++ b/Mage.Sets/src/mage/cards/d/DeadlyBrew.java @@ -81,10 +81,10 @@ class DeadlyBrewEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), playerId, game)) { + if (!target.canChoose(playerId, source, game)) { continue; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/d/DeadlyTempest.java b/Mage.Sets/src/mage/cards/d/DeadlyTempest.java index a924d104efc..90a33631b49 100644 --- a/Mage.Sets/src/mage/cards/d/DeadlyTempest.java +++ b/Mage.Sets/src/mage/cards/d/DeadlyTempest.java @@ -60,7 +60,7 @@ class DeadlyTempestEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Map destroyedCreatures = new HashMap<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (permanent.destroy(source, game, false)) { int count = destroyedCreatures.getOrDefault(permanent.getControllerId(), 0); destroyedCreatures.put(permanent.getControllerId(), count + 1); diff --git a/Mage.Sets/src/mage/cards/d/DeadwoodTreefolk.java b/Mage.Sets/src/mage/cards/d/DeadwoodTreefolk.java index 09c22523d4c..ac162edf3e1 100644 --- a/Mage.Sets/src/mage/cards/d/DeadwoodTreefolk.java +++ b/Mage.Sets/src/mage/cards/d/DeadwoodTreefolk.java @@ -16,7 +16,7 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.common.FilterCreatureCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.Target; import mage.target.common.TargetCardInYourGraveyard; @@ -28,7 +28,7 @@ public final class DeadwoodTreefolk extends CardImpl { private static final FilterCreatureCard filter = new FilterCreatureCard("another creature card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public DeadwoodTreefolk(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/d/DeathFrenzy.java b/Mage.Sets/src/mage/cards/d/DeathFrenzy.java index d7b35c8d05d..17b9ffcb172 100644 --- a/Mage.Sets/src/mage/cards/d/DeathFrenzy.java +++ b/Mage.Sets/src/mage/cards/d/DeathFrenzy.java @@ -57,7 +57,7 @@ class DeathFrenzyDelayedTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; - if (zEvent.isDiesEvent() && zEvent.getTarget() != null && StaticFilters.FILTER_PERMANENT_CREATURES.match(zEvent.getTarget(), sourceId, controllerId, game)) { + if (zEvent.isDiesEvent() && zEvent.getTarget() != null && StaticFilters.FILTER_PERMANENT_CREATURES.match(zEvent.getTarget(), controllerId, this, game)) { return true; } return false; diff --git a/Mage.Sets/src/mage/cards/d/DeathbonnetHulk.java b/Mage.Sets/src/mage/cards/d/DeathbonnetHulk.java index 7d39869b0f5..dfe959fbd40 100644 --- a/Mage.Sets/src/mage/cards/d/DeathbonnetHulk.java +++ b/Mage.Sets/src/mage/cards/d/DeathbonnetHulk.java @@ -73,7 +73,7 @@ class DeathbonnetHulkEffect extends OneShotEffect { } TargetCard target = new TargetCardInGraveyard(0, 1); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/d/Deathrender.java b/Mage.Sets/src/mage/cards/d/Deathrender.java index 51cc482bfcb..f452e8f5fc1 100644 --- a/Mage.Sets/src/mage/cards/d/Deathrender.java +++ b/Mage.Sets/src/mage/cards/d/Deathrender.java @@ -71,7 +71,7 @@ class DeathrenderEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (controller != null && sourcePermanent != null) { TargetCardInHand target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_CREATURE); - if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source, game)) { Card creatureInHand = game.getCard(target.getFirstTarget()); if (creatureInHand != null) { if (controller.moveCards(creatureInHand, Zone.BATTLEFIELD, source, game)) { diff --git a/Mage.Sets/src/mage/cards/d/DebtToTheKami.java b/Mage.Sets/src/mage/cards/d/DebtToTheKami.java index 45782470c23..8942d39ff60 100644 --- a/Mage.Sets/src/mage/cards/d/DebtToTheKami.java +++ b/Mage.Sets/src/mage/cards/d/DebtToTheKami.java @@ -73,7 +73,7 @@ class DebtToTheKamiExileCreatureEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; @@ -112,7 +112,7 @@ class DebtToTheKamiExileEnchantmentEffect extends OneShotEffect { } Target target = new TargetControlledPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/d/DeclarationInStone.java b/Mage.Sets/src/mage/cards/d/DeclarationInStone.java index 17785f873e8..c0a7c294bcb 100644 --- a/Mage.Sets/src/mage/cards/d/DeclarationInStone.java +++ b/Mage.Sets/src/mage/cards/d/DeclarationInStone.java @@ -60,7 +60,7 @@ class DeclarationInStoneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetPermanent != null) { diff --git a/Mage.Sets/src/mage/cards/d/DecreeOfAnnihilation.java b/Mage.Sets/src/mage/cards/d/DecreeOfAnnihilation.java index a52cc656a0d..025cbae0efd 100644 --- a/Mage.Sets/src/mage/cards/d/DecreeOfAnnihilation.java +++ b/Mage.Sets/src/mage/cards/d/DecreeOfAnnihilation.java @@ -85,7 +85,7 @@ class DecreeOfAnnihilationEffect extends OneShotEffect { } Cards cards = new CardsImpl(); for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { cards.add(permanent); } diff --git a/Mage.Sets/src/mage/cards/d/DefilerOfSouls.java b/Mage.Sets/src/mage/cards/d/DefilerOfSouls.java index a7889898e01..4e10c0a36a2 100644 --- a/Mage.Sets/src/mage/cards/d/DefilerOfSouls.java +++ b/Mage.Sets/src/mage/cards/d/DefilerOfSouls.java @@ -83,10 +83,10 @@ class DefilerOfSoulsEffect extends OneShotEffect { //A spell or ability could have removed the only legal target this player //had, if thats the case this ability should fizzle. - if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) { + if (amount > 0 && target.canChoose(player.getId(), source, game)) { boolean abilityApplied = false; - while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + while (player.canRespond() && !target.isChosen() && target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); } for ( int idx = 0; idx < target.getTargets().size(); idx++) { diff --git a/Mage.Sets/src/mage/cards/d/DeflectingPalm.java b/Mage.Sets/src/mage/cards/d/DeflectingPalm.java index de70d22d084..9f6562ace07 100644 --- a/Mage.Sets/src/mage/cards/d/DeflectingPalm.java +++ b/Mage.Sets/src/mage/cards/d/DeflectingPalm.java @@ -62,7 +62,7 @@ class DeflectingPalmEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/d/DeliverUntoEvil.java b/Mage.Sets/src/mage/cards/d/DeliverUntoEvil.java index 5f1a212885b..4a3deaba67c 100644 --- a/Mage.Sets/src/mage/cards/d/DeliverUntoEvil.java +++ b/Mage.Sets/src/mage/cards/d/DeliverUntoEvil.java @@ -85,7 +85,7 @@ class DeliverUntoEvilEffect extends OneShotEffect { } TargetOpponent targetOpponent = new TargetOpponent(); targetOpponent.setNotTarget(true); - if (!player.choose(outcome, targetOpponent, source.getSourceId(), game)) { + if (!player.choose(outcome, targetOpponent, source, game)) { return false; } Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/d/DementiaSliver.java b/Mage.Sets/src/mage/cards/d/DementiaSliver.java index 85284e15036..9ecacbe183e 100644 --- a/Mage.Sets/src/mage/cards/d/DementiaSliver.java +++ b/Mage.Sets/src/mage/cards/d/DementiaSliver.java @@ -77,7 +77,7 @@ class DementiaSliverEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (opponent != null && sourceObject != null && cardName != null && !cardName.isEmpty()) { if (!opponent.getHand().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/d/DemonicHordes.java b/Mage.Sets/src/mage/cards/d/DemonicHordes.java index 28e10d0fcf3..671d3e4cbea 100644 --- a/Mage.Sets/src/mage/cards/d/DemonicHordes.java +++ b/Mage.Sets/src/mage/cards/d/DemonicHordes.java @@ -95,7 +95,7 @@ class DemonicHordesEffect extends OneShotEffect { choiceOpponent.setNotTarget(true); FilterLandPermanent filterLand = new FilterLandPermanent(); filterLand.add(new ControllerIdPredicate(source.getControllerId())); - if (controller.choose(Outcome.Neutral, choiceOpponent, source.getSourceId(), game)) { + if (controller.choose(Outcome.Neutral, choiceOpponent, source, game)) { Player opponent = game.getPlayer(choiceOpponent.getFirstTarget()); if (opponent != null) { Target chosenLand = new TargetLandPermanent(filterLand); diff --git a/Mage.Sets/src/mage/cards/d/DenseCanopy.java b/Mage.Sets/src/mage/cards/d/DenseCanopy.java index 7edf71bf51c..727959aef73 100644 --- a/Mage.Sets/src/mage/cards/d/DenseCanopy.java +++ b/Mage.Sets/src/mage/cards/d/DenseCanopy.java @@ -58,7 +58,7 @@ class DenseCanopyCantBlockEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/d/Dermotaxi.java b/Mage.Sets/src/mage/cards/d/Dermotaxi.java index dc1940d6325..675717c2dbf 100644 --- a/Mage.Sets/src/mage/cards/d/Dermotaxi.java +++ b/Mage.Sets/src/mage/cards/d/Dermotaxi.java @@ -88,7 +88,7 @@ class DermotaxiImprintEffect extends OneShotEffect { if (!target.canChoose(source.getControllerId(), game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/d/DescendantsPath.java b/Mage.Sets/src/mage/cards/d/DescendantsPath.java index f2eb872f118..15a5132abcc 100644 --- a/Mage.Sets/src/mage/cards/d/DescendantsPath.java +++ b/Mage.Sets/src/mage/cards/d/DescendantsPath.java @@ -77,7 +77,7 @@ class DescendantsPathEffect extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getControllerId(), game + source.getControllerId(), source, game ).stream() .anyMatch(permanent -> permanent.shareCreatureTypes(game, card))) { CardUtil.castSpellWithAttributesForFree(controller, source, game, card); diff --git a/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java b/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java index 56369a1da37..3bbcf50039d 100644 --- a/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java +++ b/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java @@ -149,8 +149,8 @@ class DescentIntoMadnessEffect extends OneShotEffect { filter.add(Predicates.not(Predicates.or(uuidPredicates))); target = new TargetControlledPermanent(0, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game) - && player.choose(Outcome.Exile, target, source.getSourceId(), game)) { + if (target.canChoose(player.getId(), source, game) + && player.choose(Outcome.Exile, target, source, game)) { for (UUID targetId : target.getTargets()) { if (!selectedObjects.contains(targetId)) { Permanent chosen = game.getPermanent(targetId); @@ -174,7 +174,7 @@ class DescentIntoMadnessEffect extends OneShotEffect { uuidPredicates.add(new CardIdPredicate(uuid)); } filterInHand.add(Predicates.not(Predicates.or(uuidPredicates))); - if (targetInHand.canChoose(source.getSourceId(), player.getId(), game) && + if (targetInHand.canChoose(player.getId(), source, game) && player.choose(Outcome.Exile, player.getHand(), targetInHand, game)) { Card card = player.getHand().get(targetInHand.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/d/DesecrationDemon.java b/Mage.Sets/src/mage/cards/d/DesecrationDemon.java index 1991ae3a46a..90bd9124845 100644 --- a/Mage.Sets/src/mage/cards/d/DesecrationDemon.java +++ b/Mage.Sets/src/mage/cards/d/DesecrationDemon.java @@ -73,10 +73,10 @@ class DesecrationDemonEffect extends OneShotEffect { filter.add(CardType.CREATURE.getPredicate()); filter.add(TargetController.YOU.getControllerPredicate()); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); - if (target.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (target.canChoose(opponent.getId(), source, game)) { if (opponent.chooseUse(Outcome.AIDontUseIt, "Sacrifice a creature to tap " + descrationDemon.getLogName() + "and put a +1/+1 counter on it?", source, game)) { - opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + opponent.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/d/Desolation.java b/Mage.Sets/src/mage/cards/d/Desolation.java index ab24fda9780..e71475caaf7 100644 --- a/Mage.Sets/src/mage/cards/d/Desolation.java +++ b/Mage.Sets/src/mage/cards/d/Desolation.java @@ -69,10 +69,10 @@ class DesolationEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + if (!target.canChoose(player.getId(), source, game)) { continue; } - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanents.add(permanent); diff --git a/Mage.Sets/src/mage/cards/d/DesperateGambit.java b/Mage.Sets/src/mage/cards/d/DesperateGambit.java index 2e9d4d1ce22..d516d09dfd6 100644 --- a/Mage.Sets/src/mage/cards/d/DesperateGambit.java +++ b/Mage.Sets/src/mage/cards/d/DesperateGambit.java @@ -65,7 +65,7 @@ class DesperateGambitEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), source, game); Player you = game.getPlayer(source.getControllerId()); if(you != null) { wonFlip = you.flipCoin(source, game, true); diff --git a/Mage.Sets/src/mage/cards/d/DetentionSphere.java b/Mage.Sets/src/mage/cards/d/DetentionSphere.java index eb162004602..2737ad3267c 100644 --- a/Mage.Sets/src/mage/cards/d/DetentionSphere.java +++ b/Mage.Sets/src/mage/cards/d/DetentionSphere.java @@ -77,7 +77,7 @@ class DetentionSphereEntersEffect extends OneShotEffect { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && exileId != null && targetPermanent != null && controller != null) { if (CardUtil.haveEmptyName(targetPermanent)) { // face down creature diff --git a/Mage.Sets/src/mage/cards/d/Detritivore.java b/Mage.Sets/src/mage/cards/d/Detritivore.java index c0f8ef457d5..ed04f93a184 100644 --- a/Mage.Sets/src/mage/cards/d/Detritivore.java +++ b/Mage.Sets/src/mage/cards/d/Detritivore.java @@ -24,7 +24,6 @@ import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.common.TargetNonBasicLandPermanent; @@ -113,7 +112,7 @@ class NonBasicLandsInOpponentsGraveyards implements DynamicValue { if (controller.hasOpponent(playerUUID, game)) { Player player = game.getPlayer(playerUUID); if (player != null) { - amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + amount += player.getGraveyard().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } } } diff --git a/Mage.Sets/src/mage/cards/d/DevastatingMastery.java b/Mage.Sets/src/mage/cards/d/DevastatingMastery.java index 204e2298e46..01e48fcba33 100644 --- a/Mage.Sets/src/mage/cards/d/DevastatingMastery.java +++ b/Mage.Sets/src/mage/cards/d/DevastatingMastery.java @@ -89,7 +89,7 @@ class DevastatingMasteryAlternativeCostEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent( 0, 2, StaticFilters.FILTER_PERMANENTS_NON_LAND, true ); - opponent.choose(Outcome.ReturnToHand, target, source.getSourceId(), game); + opponent.choose(Outcome.ReturnToHand, target, source, game); return opponent.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/d/DevourFlesh.java b/Mage.Sets/src/mage/cards/d/DevourFlesh.java index 2526ef94c78..7a129dde457 100644 --- a/Mage.Sets/src/mage/cards/d/DevourFlesh.java +++ b/Mage.Sets/src/mage/cards/d/DevourFlesh.java @@ -66,7 +66,7 @@ class DevourFleshSacrificeEffect extends OneShotEffect { int realCount = game.getBattlefield().countAll(filter, player.getId(), game); if (realCount > 0) { Target target = new TargetControlledPermanent(1, 1, filter, true); - while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) { + while (player.canRespond() && !target.isChosen() && target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/d/DevouringHellion.java b/Mage.Sets/src/mage/cards/d/DevouringHellion.java index fe3be168fad..5a547c90b37 100644 --- a/Mage.Sets/src/mage/cards/d/DevouringHellion.java +++ b/Mage.Sets/src/mage/cards/d/DevouringHellion.java @@ -81,7 +81,7 @@ class DevouringHellionEffect extends OneShotEffect { return false; } Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } int xValue = 0; diff --git a/Mage.Sets/src/mage/cards/d/DevoutInvocation.java b/Mage.Sets/src/mage/cards/d/DevoutInvocation.java index 567c3b194e6..fb8681984cf 100644 --- a/Mage.Sets/src/mage/cards/d/DevoutInvocation.java +++ b/Mage.Sets/src/mage/cards/d/DevoutInvocation.java @@ -67,7 +67,7 @@ class DevoutInvocationEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, DevoutInvocation.filter, true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); if (target.getTargets().isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/cards/d/DiffusionSliver.java b/Mage.Sets/src/mage/cards/d/DiffusionSliver.java index 80fced50b9f..6ea1e05da49 100644 --- a/Mage.Sets/src/mage/cards/d/DiffusionSliver.java +++ b/Mage.Sets/src/mage/cards/d/DiffusionSliver.java @@ -14,7 +14,6 @@ import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -74,7 +73,7 @@ class DiffusionSliverTriggeredAbility extends TriggeredAbilityImpl { return false; } Permanent creature = game.getPermanent(event.getTargetId()); - if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) { + if (creature == null || !filter.match(creature, getControllerId(), this, game)) { return false; } this.getEffects().clear(); diff --git a/Mage.Sets/src/mage/cards/d/DiscipleOfBolas.java b/Mage.Sets/src/mage/cards/d/DiscipleOfBolas.java index 0cea7a7c65f..eaf4605b92a 100644 --- a/Mage.Sets/src/mage/cards/d/DiscipleOfBolas.java +++ b/Mage.Sets/src/mage/cards/d/DiscipleOfBolas.java @@ -68,7 +68,7 @@ class DiscipleOfBolasEffect extends OneShotEffect { if (controller != null) { Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true); target.setRequired(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { controller.chooseTarget(outcome, target, source, game); Permanent sacrificed = game.getPermanent(target.getFirstTarget()); if (sacrificed != null) { diff --git a/Mage.Sets/src/mage/cards/d/DiscipleOfDeceit.java b/Mage.Sets/src/mage/cards/d/DiscipleOfDeceit.java index e93917805ea..1834f1c9d86 100644 --- a/Mage.Sets/src/mage/cards/d/DiscipleOfDeceit.java +++ b/Mage.Sets/src/mage/cards/d/DiscipleOfDeceit.java @@ -73,7 +73,7 @@ class DiscipleOfDeceitEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (player != null && mageObject != null) { Cost cost = new DiscardTargetCost(new TargetCardInHand(new FilterNonlandCard())); String message = "Discard a nonland card to search your library?"; diff --git a/Mage.Sets/src/mage/cards/d/DiscoveryDispersal.java b/Mage.Sets/src/mage/cards/d/DiscoveryDispersal.java index 08cbf7a1024..83c78119a1c 100644 --- a/Mage.Sets/src/mage/cards/d/DiscoveryDispersal.java +++ b/Mage.Sets/src/mage/cards/d/DiscoveryDispersal.java @@ -104,7 +104,7 @@ class DispersalEffect extends OneShotEffect { filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, highestCMC)); filter.add(new ControllerIdPredicate(opponentId)); Target target = new TargetPermanent(1, 1, filter, true); - if (opponent.choose(outcome, target, source.getSourceId(), game)) { + if (opponent.choose(outcome, target, source, game)) { if (target.getFirstTarget() == null) { continue; } diff --git a/Mage.Sets/src/mage/cards/d/DiseasedVermin.java b/Mage.Sets/src/mage/cards/d/DiseasedVermin.java index ad0957bafaf..7b1c68458f1 100644 --- a/Mage.Sets/src/mage/cards/d/DiseasedVermin.java +++ b/Mage.Sets/src/mage/cards/d/DiseasedVermin.java @@ -23,7 +23,6 @@ import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPlayer; @@ -98,8 +97,8 @@ class DiseasedVerminEffect extends OneShotEffect { if (sourcePermanent != null && controller != null) { TargetPlayer targetOpponent = new TargetPlayer(1, 1, false, filter); - if (targetOpponent.canChoose(source.getSourceId(), controller.getId(), game) - && controller.choose(Outcome.Damage, targetOpponent, source.getSourceId(), game)) { + if (targetOpponent.canChoose(controller.getId(), source, game) + && controller.choose(Outcome.Damage, targetOpponent, source, game)) { Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent != null && sourcePermanent.getCounters(game).getCount(CounterType.INFECTION) > 0) { diff --git a/Mage.Sets/src/mage/cards/d/Dismantle.java b/Mage.Sets/src/mage/cards/d/Dismantle.java index 023f24e1121..d18c739c372 100644 --- a/Mage.Sets/src/mage/cards/d/Dismantle.java +++ b/Mage.Sets/src/mage/cards/d/Dismantle.java @@ -72,7 +72,7 @@ class DismantleEffect extends OneShotEffect { permanent.destroy(source, game, false); if (counterCount > 0) { Target target = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent("an artifact you control"), true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Benefit, target, source, game); Permanent artifact = game.getPermanent(target.getFirstTarget()); Counter counter; diff --git a/Mage.Sets/src/mage/cards/d/Disorder.java b/Mage.Sets/src/mage/cards/d/Disorder.java index 3c6182bb79e..1a0fdd93b65 100644 --- a/Mage.Sets/src/mage/cards/d/Disorder.java +++ b/Mage.Sets/src/mage/cards/d/Disorder.java @@ -74,7 +74,7 @@ class DisorderEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (Player player : game .getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game) + .getActivePermanents(filter, source.getControllerId(), source, game) .stream() .filter(Objects::nonNull) .map(Controllable::getControllerId) diff --git a/Mage.Sets/src/mage/cards/d/DistantMelody.java b/Mage.Sets/src/mage/cards/d/DistantMelody.java index f36597a4b9e..9c9787df4ad 100644 --- a/Mage.Sets/src/mage/cards/d/DistantMelody.java +++ b/Mage.Sets/src/mage/cards/d/DistantMelody.java @@ -59,7 +59,7 @@ class DistantMelodyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate()); diff --git a/Mage.Sets/src/mage/cards/d/DivineReckoning.java b/Mage.Sets/src/mage/cards/d/DivineReckoning.java index 946a25e9803..5155dac6d92 100644 --- a/Mage.Sets/src/mage/cards/d/DivineReckoning.java +++ b/Mage.Sets/src/mage/cards/d/DivineReckoning.java @@ -14,7 +14,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.TimingRule; import mage.filter.StaticFilters; import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; @@ -68,8 +67,8 @@ class DivineReckoningEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { Target target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { + while (player.canRespond() && !target.isChosen() && target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Benefit, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); @@ -80,7 +79,7 @@ class DivineReckoningEffect extends OneShotEffect { } } - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source, game)) { if (!chosen.contains(permanent)) { permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/d/DiviningWitch.java b/Mage.Sets/src/mage/cards/d/DiviningWitch.java index af7cab017d1..2d2e6ceb1c9 100644 --- a/Mage.Sets/src/mage/cards/d/DiviningWitch.java +++ b/Mage.Sets/src/mage/cards/d/DiviningWitch.java @@ -71,7 +71,7 @@ public final class DiviningWitch extends CardImpl { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/d/DjinnOfWishes.java b/Mage.Sets/src/mage/cards/d/DjinnOfWishes.java index d383053fc98..18ca6122497 100644 --- a/Mage.Sets/src/mage/cards/d/DjinnOfWishes.java +++ b/Mage.Sets/src/mage/cards/d/DjinnOfWishes.java @@ -70,7 +70,7 @@ class DjinnOfWishesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); Cards cards = new CardsImpl(card); diff --git a/Mage.Sets/src/mage/cards/d/DoOrDie.java b/Mage.Sets/src/mage/cards/d/DoOrDie.java index b6e700a8998..509d5b85666 100644 --- a/Mage.Sets/src/mage/cards/d/DoOrDie.java +++ b/Mage.Sets/src/mage/cards/d/DoOrDie.java @@ -67,7 +67,7 @@ class DoOrDieEffect extends OneShotEffect { TargetCreaturePermanent creatures = new TargetCreaturePermanent(0, count, new FilterCreaturePermanent("creatures to put in the first pile"), true); List pile1 = new ArrayList<>(); creatures.setRequired(false); - if (player.choose(Outcome.Neutral, creatures, source.getSourceId(), game)) { + if (player.choose(Outcome.Neutral, creatures, source, game)) { List targets = creatures.getTargets(); for (UUID targetId : targets) { Permanent p = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/d/DocentOfPerfection.java b/Mage.Sets/src/mage/cards/d/DocentOfPerfection.java index eff5ca4030d..d2e8d111aa0 100644 --- a/Mage.Sets/src/mage/cards/d/DocentOfPerfection.java +++ b/Mage.Sets/src/mage/cards/d/DocentOfPerfection.java @@ -96,7 +96,7 @@ class DocentOfPerfectionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) >= 3) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) >= 3) { return new TransformSourceEffect().apply(game, source); } } diff --git a/Mage.Sets/src/mage/cards/d/DoomCannon.java b/Mage.Sets/src/mage/cards/d/DoomCannon.java index b081a673447..f04d62fd208 100644 --- a/Mage.Sets/src/mage/cards/d/DoomCannon.java +++ b/Mage.Sets/src/mage/cards/d/DoomCannon.java @@ -68,9 +68,9 @@ class DoomCannonFilter extends FilterControlledCreaturePermanent { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (super.match(permanent, sourceId, playerId, game)) { - SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(sourceId, game); + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (super.match(permanent, playerId, source, game)) { + SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game); if (subType != null && permanent.hasSubtype(subType, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/d/DoomForetold.java b/Mage.Sets/src/mage/cards/d/DoomForetold.java index 5ae9c226bbd..6a59095a0da 100644 --- a/Mage.Sets/src/mage/cards/d/DoomForetold.java +++ b/Mage.Sets/src/mage/cards/d/DoomForetold.java @@ -86,7 +86,7 @@ class DoomForetoldEffect extends OneShotEffect { if (game.getBattlefield().contains(filter2, source, game, 1)) { TargetPermanent target = new TargetPermanent(filter2); target.setNotTarget(true); - if (player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Sacrifice, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && permanent.sacrifice(source, game)) { return true; diff --git a/Mage.Sets/src/mage/cards/d/Doomfall.java b/Mage.Sets/src/mage/cards/d/Doomfall.java index 7b59a64f99f..030c2aff728 100644 --- a/Mage.Sets/src/mage/cards/d/Doomfall.java +++ b/Mage.Sets/src/mage/cards/d/Doomfall.java @@ -74,7 +74,7 @@ class DoomfallEffect extends OneShotEffect { if (targetPlayer != null) { Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (targetPlayer.choose(outcome, target, source.getSourceId(), game)) { + if (targetPlayer.choose(outcome, target, source, game)) { targetPlayer.moveCards(game.getPermanent(target.getFirstTarget()), Zone.EXILED, source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/d/Doomgape.java b/Mage.Sets/src/mage/cards/d/Doomgape.java index d114db688b8..db4cc41cd93 100644 --- a/Mage.Sets/src/mage/cards/d/Doomgape.java +++ b/Mage.Sets/src/mage/cards/d/Doomgape.java @@ -74,7 +74,7 @@ class DoomgapeEffect extends OneShotEffect { if (controller != null) { Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Sacrifice, target, source, game)) { Permanent creature = game.getPermanent(target.getFirstTarget()); if (creature != null) { if (creature.sacrifice(source, game)) { diff --git a/Mage.Sets/src/mage/cards/d/DoublingChant.java b/Mage.Sets/src/mage/cards/d/DoublingChant.java index 9607085e063..c917c1c62b4 100644 --- a/Mage.Sets/src/mage/cards/d/DoublingChant.java +++ b/Mage.Sets/src/mage/cards/d/DoublingChant.java @@ -69,7 +69,7 @@ class DoublingChantEffect extends OneShotEffect { } Set names = game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ) .stream() .filter(Objects::nonNull) diff --git a/Mage.Sets/src/mage/cards/d/Dracoplasm.java b/Mage.Sets/src/mage/cards/d/Dracoplasm.java index 80b1a77d3c7..03dd066c61b 100644 --- a/Mage.Sets/src/mage/cards/d/Dracoplasm.java +++ b/Mage.Sets/src/mage/cards/d/Dracoplasm.java @@ -96,7 +96,7 @@ class DracoplasmEffect extends ReplacementEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (creature != null && controller != null) { Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } controller.chooseTarget(Outcome.Detriment, target, source, game); diff --git a/Mage.Sets/src/mage/cards/d/DrafnasRestoration.java b/Mage.Sets/src/mage/cards/d/DrafnasRestoration.java index 8d0fbc575ce..24ce96f52ba 100644 --- a/Mage.Sets/src/mage/cards/d/DrafnasRestoration.java +++ b/Mage.Sets/src/mage/cards/d/DrafnasRestoration.java @@ -12,7 +12,6 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.filter.common.FilterArtifactCard; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.events.TargetEvent; import mage.game.stack.StackObject; import mage.players.Player; @@ -61,14 +60,14 @@ class DrafnasRestorationTarget extends TargetCardInGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); if (object instanceof StackObject) { Player targetPlayer = game.getPlayer(((StackObject) object).getStackAbility().getFirstTarget()); if (targetPlayer != null) { - for (Card card : targetPlayer.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : targetPlayer.getGraveyard().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { possibleTargets.add(card.getId()); } } diff --git a/Mage.Sets/src/mage/cards/d/DragonkinBerserker.java b/Mage.Sets/src/mage/cards/d/DragonkinBerserker.java index 58b0065c766..fd7162fa5a0 100644 --- a/Mage.Sets/src/mage/cards/d/DragonkinBerserker.java +++ b/Mage.Sets/src/mage/cards/d/DragonkinBerserker.java @@ -72,7 +72,7 @@ class DragonkinBerserkerEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { CardUtil.reduceCost(abilityToModify, game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game )); return true; } diff --git a/Mage.Sets/src/mage/cards/d/DragonsDisciple.java b/Mage.Sets/src/mage/cards/d/DragonsDisciple.java index ea6fc91d699..30afb797215 100644 --- a/Mage.Sets/src/mage/cards/d/DragonsDisciple.java +++ b/Mage.Sets/src/mage/cards/d/DragonsDisciple.java @@ -85,7 +85,7 @@ class DragonsDiscipleEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); if (controller != null && sourcePermanent != null) { TargetCardInHand target = new TargetCardInHand(filter); - if (!target.possibleTargets(source.getSourceId(), source.getControllerId(), game).isEmpty() + if (!target.possibleTargets(source.getControllerId(), source, game).isEmpty() && controller.chooseUse(outcome, "Reveal a Dragon card from your hand?", source, game) && controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/d/DragonsFire.java b/Mage.Sets/src/mage/cards/d/DragonsFire.java index acf4da3a752..af5f6e0d073 100644 --- a/Mage.Sets/src/mage/cards/d/DragonsFire.java +++ b/Mage.Sets/src/mage/cards/d/DragonsFire.java @@ -133,7 +133,7 @@ class DragonsFireCost extends CostImpl { switch (chosenZone) { case HAND: targets.add(new TargetCardInHand(handFilter)); - if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), source, game)) { Card card = game.getCard(targets.getFirstTarget()); if (card != null) { dragonZone = DragonZone.HAND; @@ -144,7 +144,7 @@ class DragonsFireCost extends CostImpl { break; case BATTLEFIELD: targets.add(new TargetControlledPermanent(battlefieldFilter)); - if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(targets.getFirstTarget()); if (permanent != null) { dragonZone = DragonZone.BATTLEFIELD; diff --git a/Mage.Sets/src/mage/cards/d/DrainPower.java b/Mage.Sets/src/mage/cards/d/DrainPower.java index fbe0f63f208..73d90162a52 100644 --- a/Mage.Sets/src/mage/cards/d/DrainPower.java +++ b/Mage.Sets/src/mage/cards/d/DrainPower.java @@ -114,7 +114,7 @@ class DrainPowerEffect extends OneShotEffect { FilterLandPermanent filter2 = new FilterLandPermanent("land you control to tap for mana (remaining: " + permList.size() + ')'); filter2.add(new PermanentInListPredicate(permList)); target = new TargetPermanent(1, 1, filter2, true); - while (!target.isChosen() && target.canChoose(source.getSourceId(), targetPlayer.getId(), game) && targetPlayer.canRespond()) { + while (!target.isChosen() && target.canChoose(targetPlayer.getId(), source, game) && targetPlayer.canRespond()) { targetPlayer.chooseTarget(Outcome.Neutral, target, source, game); } permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/d/DrakeFamiliar.java b/Mage.Sets/src/mage/cards/d/DrakeFamiliar.java index dd81c36763c..a0a58e5b397 100644 --- a/Mage.Sets/src/mage/cards/d/DrakeFamiliar.java +++ b/Mage.Sets/src/mage/cards/d/DrakeFamiliar.java @@ -66,7 +66,7 @@ class DrakeFamiliarEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_PERMANENT_ENCHANTMENT); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseUse(outcome, "Return an enchantment to its owner's hand?", source, game)) { controller.chooseTarget(Outcome.ReturnToHand, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/d/DralnusCrusade.java b/Mage.Sets/src/mage/cards/d/DralnusCrusade.java index 3a868b93052..63786171698 100755 --- a/Mage.Sets/src/mage/cards/d/DralnusCrusade.java +++ b/Mage.Sets/src/mage/cards/d/DralnusCrusade.java @@ -49,7 +49,7 @@ class DralnusCrusadeEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source, game)) { switch (layer) { case TypeChangingEffects_4: permanent.addSubType(game, SubType.ZOMBIE); diff --git a/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java b/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java index 58c6deb298f..68ba166c204 100644 --- a/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java +++ b/Mage.Sets/src/mage/cards/d/DreadhordeArcanist.java @@ -74,7 +74,7 @@ enum DreadhordeArcanistPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getManaValue() <= sourcePermanent.getPower().getValue(); } diff --git a/Mage.Sets/src/mage/cards/d/DreamHalls.java b/Mage.Sets/src/mage/cards/d/DreamHalls.java index 51b608af534..c2177337cae 100644 --- a/Mage.Sets/src/mage/cards/d/DreamHalls.java +++ b/Mage.Sets/src/mage/cards/d/DreamHalls.java @@ -12,7 +12,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.filter.predicate.mageobject.SharesColorWithSourcePredicate; import mage.game.Game; import mage.players.Player; @@ -45,7 +45,7 @@ class DreamHallsEffect extends ContinuousEffectImpl { private static final FilterCard filter = new FilterCard("a card that shares a color with that spell"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); filter.add(SharesColorWithSourcePredicate.instance); } diff --git a/Mage.Sets/src/mage/cards/d/DreamTides.java b/Mage.Sets/src/mage/cards/d/DreamTides.java index 9a0dab7cfa0..5cb1b723072 100644 --- a/Mage.Sets/src/mage/cards/d/DreamTides.java +++ b/Mage.Sets/src/mage/cards/d/DreamTides.java @@ -81,7 +81,7 @@ class DreamTidesEffect extends OneShotEffect { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.AIDontUseIt, "Pay {2} and untap a tapped nongreen creature under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (player.choose(Outcome.Detriment, tappedCreatureTarget, source.getSourceId(), game)) { + if (player.choose(Outcome.Detriment, tappedCreatureTarget, source, game)) { Cost cost = ManaUtil.createManaCost(2, false); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/d/DropOfHoney.java b/Mage.Sets/src/mage/cards/d/DropOfHoney.java index f51ef99936e..860af8120f7 100644 --- a/Mage.Sets/src/mage/cards/d/DropOfHoney.java +++ b/Mage.Sets/src/mage/cards/d/DropOfHoney.java @@ -89,8 +89,8 @@ class DropOfHoneyEffect extends OneShotEffect { filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, leastPower)); Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { + if (controller.choose(outcome, target, source, game)) { permanentToDestroy = game.getPermanent(target.getFirstTarget()); } } @@ -123,7 +123,7 @@ class DropOfHoneyStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURES, this.getSourceId(), this.getControllerId(), game) == 0; + return game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURES, this.getControllerId(), this, game) == 0; } @Override diff --git a/Mage.Sets/src/mage/cards/d/DruidOfPurification.java b/Mage.Sets/src/mage/cards/d/DruidOfPurification.java index 37ec1c0e3ca..7839dcefe59 100644 --- a/Mage.Sets/src/mage/cards/d/DruidOfPurification.java +++ b/Mage.Sets/src/mage/cards/d/DruidOfPurification.java @@ -76,7 +76,7 @@ class DruidOfPurificationEffect extends OneShotEffect { "artifact or enchantment not controlled by " + controller.getName() ); filter.add(Predicates.not(new ControllerIdPredicate(controller.getId()))); - if (game.getBattlefield().count(filter, source.getControllerId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) < 1) { return false; } TargetPermanent target = new TargetPermanent(0, 1, filter); @@ -88,7 +88,7 @@ class DruidOfPurificationEffect extends OneShotEffect { continue; } target.clearChosen(); - player.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game); + player.choose(Outcome.DestroyPermanent, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { game.informPlayers(player.getLogName() + " has not chosen a permanent"); diff --git a/Mage.Sets/src/mage/cards/d/Duneblast.java b/Mage.Sets/src/mage/cards/d/Duneblast.java index d306f8f68d0..6a46f88bd33 100644 --- a/Mage.Sets/src/mage/cards/d/Duneblast.java +++ b/Mage.Sets/src/mage/cards/d/Duneblast.java @@ -65,10 +65,10 @@ class DuneblastEffect extends OneShotEffect { Target target = new TargetCreaturePermanent(0,1,new FilterCreaturePermanent("creature to keep"), true); target.setRequired(true); Permanent creatureToKeep = null; - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (controller.choose(outcome, target, source, game)) { creatureToKeep = game.getPermanent(target.getFirstTarget()); } - for(Permanent creature: game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source.getSourceId(), game)) { + for(Permanent creature: game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source, game)) { if (!Objects.equals(creature, creatureToKeep)) { creature.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/d/Duplicity.java b/Mage.Sets/src/mage/cards/d/Duplicity.java index 2867b40dd88..18b2e57e938 100644 --- a/Mage.Sets/src/mage/cards/d/Duplicity.java +++ b/Mage.Sets/src/mage/cards/d/Duplicity.java @@ -75,7 +75,7 @@ class DuplicityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (controller.getLibrary().hasCards()) { @@ -111,7 +111,7 @@ class DuplicityExileHandEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (!controller.getHand().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/d/DustOfMoments.java b/Mage.Sets/src/mage/cards/d/DustOfMoments.java index af66f7fe6a9..d390fa5b6f8 100644 --- a/Mage.Sets/src/mage/cards/d/DustOfMoments.java +++ b/Mage.Sets/src/mage/cards/d/DustOfMoments.java @@ -81,7 +81,7 @@ public final class DustOfMoments extends CardImpl { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { updatePermanents(source, game, controller, sourceObject); updateSuspended(source, game, controller, sourceObject); diff --git a/Mage.Sets/src/mage/cards/d/DutifulAttendant.java b/Mage.Sets/src/mage/cards/d/DutifulAttendant.java index 5c2f7f560f3..e50a9136818 100644 --- a/Mage.Sets/src/mage/cards/d/DutifulAttendant.java +++ b/Mage.Sets/src/mage/cards/d/DutifulAttendant.java @@ -11,7 +11,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterCreatureCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -23,7 +23,7 @@ public final class DutifulAttendant extends CardImpl { private static final FilterCreatureCard filter = new FilterCreatureCard("another target creature card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public DutifulAttendant(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/d/DwarvenShrine.java b/Mage.Sets/src/mage/cards/d/DwarvenShrine.java index 16e76e0790c..c09a4a42cfd 100644 --- a/Mage.Sets/src/mage/cards/d/DwarvenShrine.java +++ b/Mage.Sets/src/mage/cards/d/DwarvenShrine.java @@ -88,7 +88,7 @@ class DwarvenShrineEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int count = 0; - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject); if (spell != null) { diff --git a/Mage.Sets/src/mage/cards/e/EMPBlast.java b/Mage.Sets/src/mage/cards/e/EMPBlast.java index 8a7bf01487a..e5775833dd7 100644 --- a/Mage.Sets/src/mage/cards/e/EMPBlast.java +++ b/Mage.Sets/src/mage/cards/e/EMPBlast.java @@ -59,7 +59,7 @@ class EMPBlastEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent artifact : game.getBattlefield().getActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent artifact : game.getBattlefield().getActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), source, game)) { artifact.tap(source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/e/EarthshakerKhenra.java b/Mage.Sets/src/mage/cards/e/EarthshakerKhenra.java index 41343176fdb..529169415ec 100644 --- a/Mage.Sets/src/mage/cards/e/EarthshakerKhenra.java +++ b/Mage.Sets/src/mage/cards/e/EarthshakerKhenra.java @@ -73,7 +73,7 @@ enum EarthshakerKhenraPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getPower().getValue() <= sourcePermanent.getPower().getValue(); } } diff --git a/Mage.Sets/src/mage/cards/e/EccentricFarmer.java b/Mage.Sets/src/mage/cards/e/EccentricFarmer.java index 018ce65be2b..86dbdc7cc0b 100644 --- a/Mage.Sets/src/mage/cards/e/EccentricFarmer.java +++ b/Mage.Sets/src/mage/cards/e/EccentricFarmer.java @@ -74,7 +74,7 @@ class EccentricFarmerEffect extends OneShotEffect { TargetCard target = new TargetCardInYourGraveyard( 0, 1, StaticFilters.FILTER_CARD_LAND, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/e/EchoBaseCommando.java b/Mage.Sets/src/mage/cards/e/EchoBaseCommando.java index 7812cab8b0b..aee603a7e70 100644 --- a/Mage.Sets/src/mage/cards/e/EchoBaseCommando.java +++ b/Mage.Sets/src/mage/cards/e/EchoBaseCommando.java @@ -86,7 +86,7 @@ class EchoBaseCommandoEffect extends CostModificationEffectImpl { public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) { Permanent permanent = game.getPermanent(abilityToModify.getSourceId()); - if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (filter.match(permanent, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/e/EcologicalAppreciation.java b/Mage.Sets/src/mage/cards/e/EcologicalAppreciation.java index 8b69d84bab7..2af61be2533 100644 --- a/Mage.Sets/src/mage/cards/e/EcologicalAppreciation.java +++ b/Mage.Sets/src/mage/cards/e/EcologicalAppreciation.java @@ -114,7 +114,7 @@ class EcologicalAppreciationEffect extends OneShotEffect { TargetOpponent targetOpponent = new TargetOpponent(); targetOpponent.setNotTarget(true); - player.choose(outcome, targetOpponent, source.getSourceId(), game); + player.choose(outcome, targetOpponent, source, game); Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent != null) { diff --git a/Mage.Sets/src/mage/cards/e/EerieUltimatum.java b/Mage.Sets/src/mage/cards/e/EerieUltimatum.java index 8ea52cecc14..a36bfdeef37 100644 --- a/Mage.Sets/src/mage/cards/e/EerieUltimatum.java +++ b/Mage.Sets/src/mage/cards/e/EerieUltimatum.java @@ -10,7 +10,6 @@ import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; -import mage.filter.FilterCard; import mage.filter.common.FilterPermanentCard; import mage.game.Game; import mage.players.Player; @@ -106,8 +105,8 @@ class EerieUltimatumTarget extends TargetCardInYourGraveyard { @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Set names = this.getTargets() .stream() .map(game::getCard) diff --git a/Mage.Sets/src/mage/cards/e/EgoErasure.java b/Mage.Sets/src/mage/cards/e/EgoErasure.java index c0077e492c1..5e04a97b332 100644 --- a/Mage.Sets/src/mage/cards/e/EgoErasure.java +++ b/Mage.Sets/src/mage/cards/e/EgoErasure.java @@ -64,7 +64,7 @@ class EgoErasureEffect extends ContinuousEffectImpl { game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getFirstTarget(), source.getSourceId(), game + source.getFirstTarget(), source, game ).stream() .map(permanent -> new MageObjectReference(permanent, game)) .forEach(affectedObjectList::add); diff --git a/Mage.Sets/src/mage/cards/e/ElderfangRitualist.java b/Mage.Sets/src/mage/cards/e/ElderfangRitualist.java index 1dd64d47396..5d2cfdf3f0c 100644 --- a/Mage.Sets/src/mage/cards/e/ElderfangRitualist.java +++ b/Mage.Sets/src/mage/cards/e/ElderfangRitualist.java @@ -11,7 +11,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.filter.FilterCard; import mage.filter.common.FilterBySubtypeCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -22,7 +22,7 @@ public final class ElderfangRitualist extends CardImpl { private static final FilterCard filter = new FilterBySubtypeCard(SubType.ELF); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); filter.setMessage("another target Elf card from your graveyard"); } diff --git a/Mage.Sets/src/mage/cards/e/EldraziTemple.java b/Mage.Sets/src/mage/cards/e/EldraziTemple.java index 88eed29e1c6..4dec3aa3b47 100644 --- a/Mage.Sets/src/mage/cards/e/EldraziTemple.java +++ b/Mage.Sets/src/mage/cards/e/EldraziTemple.java @@ -68,7 +68,7 @@ class EldraziTempleCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.hasSubtype(SubType.ELDRAZI, game) && object.getColor(game).isColorless(); } } diff --git a/Mage.Sets/src/mage/cards/e/Electryte.java b/Mage.Sets/src/mage/cards/e/Electryte.java index 1af4897951f..a1967a2bb5a 100644 --- a/Mage.Sets/src/mage/cards/e/Electryte.java +++ b/Mage.Sets/src/mage/cards/e/Electryte.java @@ -91,7 +91,7 @@ class ElectryteEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent thisCreature = game.getPermanent(source.getSourceId()); int amount = thisCreature.getPower().getValue(); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.damage(amount, source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/e/EliteArcanist.java b/Mage.Sets/src/mage/cards/e/EliteArcanist.java index 1bc1403f022..1fc5c6999e6 100644 --- a/Mage.Sets/src/mage/cards/e/EliteArcanist.java +++ b/Mage.Sets/src/mage/cards/e/EliteArcanist.java @@ -103,7 +103,7 @@ class EliteArcanistImprintEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null && !player.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && player.choose(Outcome.Benefit, player.getHand(), target, game)) { Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java b/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java index e7098e13835..ba8eb40f970 100644 --- a/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java +++ b/Mage.Sets/src/mage/cards/e/ElsewhereFlask.java @@ -116,7 +116,7 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl { game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .map(permanent -> new MageObjectReference(permanent, game)) .forEach(affectedObjectList::add); diff --git a/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java b/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java index 6f935d1921f..1a7524e7728 100644 --- a/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java +++ b/Mage.Sets/src/mage/cards/e/ElvishSoultiller.java @@ -67,7 +67,7 @@ class ElvishSoultillerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceCreatureType(mageObject); if (controller.choose(outcome, typeChoice, game)) { @@ -77,7 +77,7 @@ class ElvishSoultillerEffect extends OneShotEffect { Cards cardsToLibrary = new CardsImpl(); FilterCreatureCard filter = new FilterCreatureCard(); filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate()); - cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)); + cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getControllerId(), source, game)); controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false); controller.shuffleLibrary(source, game); return true; diff --git a/Mage.Sets/src/mage/cards/e/EmbalmersTools.java b/Mage.Sets/src/mage/cards/e/EmbalmersTools.java index b9eed1188f6..57ea87557fb 100644 --- a/Mage.Sets/src/mage/cards/e/EmbalmersTools.java +++ b/Mage.Sets/src/mage/cards/e/EmbalmersTools.java @@ -90,7 +90,7 @@ class EmbalmersToolsEffect extends CostModificationEffectImpl { || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) { // Activated abilities of creatures Card card = game.getCard(abilityToModify.getSourceId()); - if (filter.match(card, source.getSourceId(), source.getControllerId(), game) && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { + if (filter.match(card, source.getControllerId(), source, game) && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { return true; } } diff --git a/Mage.Sets/src/mage/cards/e/EmergentUltimatum.java b/Mage.Sets/src/mage/cards/e/EmergentUltimatum.java index 9f5b0981c37..39d140b8e3b 100644 --- a/Mage.Sets/src/mage/cards/e/EmergentUltimatum.java +++ b/Mage.Sets/src/mage/cards/e/EmergentUltimatum.java @@ -87,7 +87,7 @@ class EmergentUltimatumEffect extends OneShotEffect { } TargetOpponent targetOpponent = new TargetOpponent(); targetOpponent.setNotTarget(true); - player.choose(outcome, targetOpponent, source.getSourceId(), game); + player.choose(outcome, targetOpponent, source, game); Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent == null) { if (searched) { diff --git a/Mage.Sets/src/mage/cards/e/EmissaryOfDespair.java b/Mage.Sets/src/mage/cards/e/EmissaryOfDespair.java index 5fcdd686358..3310daf217e 100644 --- a/Mage.Sets/src/mage/cards/e/EmissaryOfDespair.java +++ b/Mage.Sets/src/mage/cards/e/EmissaryOfDespair.java @@ -54,7 +54,7 @@ class EmissaryOfDespairCount implements DynamicValue { } FilterArtifactPermanent filter = new FilterArtifactPermanent(); filter.add(new ControllerIdPredicate(effect.getTargetPointer().getFirst(game, sourceAbility))); - return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } @Override diff --git a/Mage.Sets/src/mage/cards/e/EmissaryOfHope.java b/Mage.Sets/src/mage/cards/e/EmissaryOfHope.java index f121794ffed..201c5541c1f 100644 --- a/Mage.Sets/src/mage/cards/e/EmissaryOfHope.java +++ b/Mage.Sets/src/mage/cards/e/EmissaryOfHope.java @@ -67,7 +67,7 @@ class EmissaryOfHopeEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player sourcePlayer = game.getPlayer(source.getControllerId()); if (targetPlayer != null && sourcePlayer != null) { - int amount = game.getBattlefield().count(filter, source.getSourceId(), targetPlayer.getId(), game); + int amount = game.getBattlefield().count(filter, targetPlayer.getId(), source, game); if (amount > 0) { sourcePlayer.gainLife(amount, game, source); } diff --git a/Mage.Sets/src/mage/cards/e/EmptyTheLaboratory.java b/Mage.Sets/src/mage/cards/e/EmptyTheLaboratory.java index 74e0868a828..dd9e856e39d 100644 --- a/Mage.Sets/src/mage/cards/e/EmptyTheLaboratory.java +++ b/Mage.Sets/src/mage/cards/e/EmptyTheLaboratory.java @@ -74,7 +74,7 @@ class EmptyTheLaboratoryEffect extends OneShotEffect { int toSacrifice = Math.min( source.getManaCostsToPay().getX(), game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ) ); if (toSacrifice < 1) { @@ -82,7 +82,7 @@ class EmptyTheLaboratoryEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(toSacrifice, filter); target.setNotTarget(true); - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); int sacrificed = 0; for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); diff --git a/Mage.Sets/src/mage/cards/e/EnchantedEvening.java b/Mage.Sets/src/mage/cards/e/EnchantedEvening.java index 7cfb26dbc41..92fceea6609 100644 --- a/Mage.Sets/src/mage/cards/e/EnchantedEvening.java +++ b/Mage.Sets/src/mage/cards/e/EnchantedEvening.java @@ -51,7 +51,7 @@ public final class EnchantedEvening extends CardImpl { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_PERMANENT, source.getControllerId(), - source.getSourceId(), game + source, game )) { if (permanent != null) { permanent.addCardType(game, CardType.ENCHANTMENT); diff --git a/Mage.Sets/src/mage/cards/e/EndlessHorizons.java b/Mage.Sets/src/mage/cards/e/EndlessHorizons.java index 739586d3d5d..e5a3899e76c 100644 --- a/Mage.Sets/src/mage/cards/e/EndlessHorizons.java +++ b/Mage.Sets/src/mage/cards/e/EndlessHorizons.java @@ -116,7 +116,7 @@ class EndlessHorizonsEffect2 extends OneShotEffect { 0, 1, filter, CardUtil.getExileZoneId(game, source) ); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); return card != null && controller.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java b/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java index 1318712c0ae..16c1575cbc9 100644 --- a/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java +++ b/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java @@ -72,7 +72,7 @@ class EngineeredExplosivesEffect extends OneShotEffect { MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); if(engineeredExplosives instanceof Permanent){ int count = ((Permanent)engineeredExplosives).getCounters(game).getCount(CounterType.CHARGE); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if(permanent.getManaValue() == count){ permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/e/EngulfTheShore.java b/Mage.Sets/src/mage/cards/e/EngulfTheShore.java index b8d85cb541e..20489199db3 100644 --- a/Mage.Sets/src/mage/cards/e/EngulfTheShore.java +++ b/Mage.Sets/src/mage/cards/e/EngulfTheShore.java @@ -67,11 +67,11 @@ class EngulfTheShoreEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int islands = game.getBattlefield().count(filter, source.getControllerId(), source, game); FilterPermanent creatureFilter = new FilterCreaturePermanent(); creatureFilter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, islands + 1)); Set cardsToHand = new HashSet<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source, game)) { cardsToHand.add(permanent); } controller.moveCards(cardsToHand, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/e/EnigmaticIncarnation.java b/Mage.Sets/src/mage/cards/e/EnigmaticIncarnation.java index 2c796bd0556..a572a8fb9cb 100644 --- a/Mage.Sets/src/mage/cards/e/EnigmaticIncarnation.java +++ b/Mage.Sets/src/mage/cards/e/EnigmaticIncarnation.java @@ -77,12 +77,12 @@ class EnigmaticIncarnationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player == null - || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0 + || game.getBattlefield().count(filter, source.getControllerId(), source, game) == 0 || !player.chooseUse(outcome, "Sacrifice an enchantment?", source, game)) { return false; } TargetPermanent target = new TargetPermanent(0, 1, filter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/e/EnslavedHorror.java b/Mage.Sets/src/mage/cards/e/EnslavedHorror.java index 1048f609aaf..96ccd7cf08f 100644 --- a/Mage.Sets/src/mage/cards/e/EnslavedHorror.java +++ b/Mage.Sets/src/mage/cards/e/EnslavedHorror.java @@ -78,7 +78,7 @@ class EnslavedHorrorEffect extends OneShotEffect { filterCreatureCard.add(new OwnerIdPredicate(playerId)); TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, filterCreatureCard); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), playerId, game) + if (target.canChoose(playerId, source, game) && player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/e/EntrailsFeaster.java b/Mage.Sets/src/mage/cards/e/EntrailsFeaster.java index 7b84a0e3316..cb01061c6f6 100644 --- a/Mage.Sets/src/mage/cards/e/EntrailsFeaster.java +++ b/Mage.Sets/src/mage/cards/e/EntrailsFeaster.java @@ -70,8 +70,8 @@ class EntrailsFeasterEffect extends OneShotEffect { Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game); TargetCardInGraveyard target = new TargetCardInGraveyard(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(outcome, "Exile a creature card from a graveyard?", source, game)) { - if (controller.choose(Outcome.Exile, target, source.getId(), game)) { + if (target.canChoose(controller.getId(), source, game) && controller.chooseUse(outcome, "Exile a creature card from a graveyard?", source, game)) { + if (controller.choose(Outcome.Exile, target, source, game)) { Card cardChosen = game.getCard(target.getFirstTarget()); if (cardChosen != null) { controller.moveCardsToExile(cardChosen, source, game, true, null, ""); diff --git a/Mage.Sets/src/mage/cards/e/EntrapmentManeuver.java b/Mage.Sets/src/mage/cards/e/EntrapmentManeuver.java index c15dba03b56..1af385b71d8 100644 --- a/Mage.Sets/src/mage/cards/e/EntrapmentManeuver.java +++ b/Mage.Sets/src/mage/cards/e/EntrapmentManeuver.java @@ -70,7 +70,7 @@ class EntrapmentManeuverSacrificeEffect extends OneShotEffect { int realCount = game.getBattlefield().countAll(filter, player.getId(), game); if (realCount > 0) { Target target = new TargetControlledPermanent(1, 1, filter, true); - while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) { + while (player.canRespond() && !target.isChosen() && target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java b/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java index c40996a8311..ef5800585a5 100644 --- a/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java +++ b/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java @@ -62,7 +62,7 @@ class EpiphanyAtTheDrownyardEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/e/Equipoise.java b/Mage.Sets/src/mage/cards/e/Equipoise.java index 58f9013da3a..2528317645a 100644 --- a/Mage.Sets/src/mage/cards/e/Equipoise.java +++ b/Mage.Sets/src/mage/cards/e/Equipoise.java @@ -81,8 +81,8 @@ class EquipoiseEffect extends OneShotEffect { private void phaseOutCardType(Player controller, Player targetPlayer, CardType cardType, Ability source, Game game) { FilterPermanent filter = new FilterControlledPermanent(); filter.add(cardType.getPredicate()); - int numberController = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game); - int numberTargetPlayer = game.getBattlefield().count(filter, source.getSourceId(), targetPlayer.getId(), game); + int numberController = game.getBattlefield().count(filter, controller.getId(), source, game); + int numberTargetPlayer = game.getBattlefield().count(filter, targetPlayer.getId(), source, game); int excess = numberTargetPlayer - numberController; if (excess > 0) { FilterPermanent filterChoose = new FilterPermanent(cardType.toString().toLowerCase(Locale.ENGLISH) + (excess > 1 ? "s" : "") + " of target player"); diff --git a/Mage.Sets/src/mage/cards/e/ErraticMutation.java b/Mage.Sets/src/mage/cards/e/ErraticMutation.java index cade3c25a7e..49875cc0841 100644 --- a/Mage.Sets/src/mage/cards/e/ErraticMutation.java +++ b/Mage.Sets/src/mage/cards/e/ErraticMutation.java @@ -62,7 +62,7 @@ class ErraticMutationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { CardsImpl toReveal = new CardsImpl(); Card nonLandCard = null; diff --git a/Mage.Sets/src/mage/cards/e/EscapedShapeshifter.java b/Mage.Sets/src/mage/cards/e/EscapedShapeshifter.java index 935988818fc..e8b27784556 100644 --- a/Mage.Sets/src/mage/cards/e/EscapedShapeshifter.java +++ b/Mage.Sets/src/mage/cards/e/EscapedShapeshifter.java @@ -69,7 +69,7 @@ class EscapedShapeshifterEffect extends ContinuousEffectImpl { game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .filter(Objects::nonNull) .filter(permanent -> !permanent.getName().equals("Escaped Shapeshifter")) diff --git a/Mage.Sets/src/mage/cards/e/EsiorWardwingFamiliar.java b/Mage.Sets/src/mage/cards/e/EsiorWardwingFamiliar.java index 5e018812035..2b0978c5623 100644 --- a/Mage.Sets/src/mage/cards/e/EsiorWardwingFamiliar.java +++ b/Mage.Sets/src/mage/cards/e/EsiorWardwingFamiliar.java @@ -98,7 +98,7 @@ class EsiorWardwingFamiliarEffect extends CostModificationEffectImpl { if (allTargets.stream() .map(game::getPermanent) .filter(Objects::nonNull) - .anyMatch(permanent -> !filter.match(permanent, source.getSourceId(), source.getControllerId(), game))) { + .anyMatch(permanent -> !filter.match(permanent, source.getControllerId(), source, game))) { return false; } } @@ -106,7 +106,7 @@ class EsiorWardwingFamiliarEffect extends CostModificationEffectImpl { return allTargets.stream() .map(game::getPermanent) .filter(Objects::nonNull) - .anyMatch(permanent -> filter.match(permanent, source.getSourceId(), source.getControllerId(), game)); + .anyMatch(permanent -> filter.match(permanent, source.getControllerId(), source, game)); } @Override diff --git a/Mage.Sets/src/mage/cards/e/EsixFractalBloom.java b/Mage.Sets/src/mage/cards/e/EsixFractalBloom.java index ccfacd565e1..0a9bcf4e171 100644 --- a/Mage.Sets/src/mage/cards/e/EsixFractalBloom.java +++ b/Mage.Sets/src/mage/cards/e/EsixFractalBloom.java @@ -91,7 +91,7 @@ class EsixFractalBloomEffect extends ReplacementEffectImpl { && game.isActivePlayer(source.getControllerId()) && !EsixFractalBloomWatcher.checkPlayer(source.getControllerId(), game) && game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ) > 0; } @@ -102,7 +102,7 @@ class EsixFractalBloomEffect extends ReplacementEffectImpl { return false; } TargetPermanent target = new TargetPermanent(0, 1, filter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/e/EssenceFilter.java b/Mage.Sets/src/mage/cards/e/EssenceFilter.java index 6dc8f067651..e48445b574e 100644 --- a/Mage.Sets/src/mage/cards/e/EssenceFilter.java +++ b/Mage.Sets/src/mage/cards/e/EssenceFilter.java @@ -66,11 +66,11 @@ class EssenceFilterEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (controller.chooseUse(outcome, "Destroy all enchantments? (otherwise all nonwhite enchantments are destroyed)", source, game)) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterEnchantmentPermanent(), controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterEnchantmentPermanent(), controller.getId(), source, game)) { permanent.destroy(source, game, false); } } else { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source, game)) { permanent.destroy(source, game, false); } } diff --git a/Mage.Sets/src/mage/cards/e/EstridTheMasked.java b/Mage.Sets/src/mage/cards/e/EstridTheMasked.java index 796383b3ea0..77ef58cfd69 100644 --- a/Mage.Sets/src/mage/cards/e/EstridTheMasked.java +++ b/Mage.Sets/src/mage/cards/e/EstridTheMasked.java @@ -149,10 +149,10 @@ class EstridTheMaskedGraveyardEffect extends OneShotEffect { return false; } controller.moveCards(controller.getGraveyard().getCards( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ), Zone.BATTLEFIELD, source, game); controller.moveCards(controller.getGraveyard().getCards( - filter2, source.getSourceId(), source.getControllerId(), game + filter2, source.getControllerId(), source, game ), Zone.BATTLEFIELD, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/e/EunuchsIntrigues.java b/Mage.Sets/src/mage/cards/e/EunuchsIntrigues.java index 49f803d8361..1e4b88821b1 100644 --- a/Mage.Sets/src/mage/cards/e/EunuchsIntrigues.java +++ b/Mage.Sets/src/mage/cards/e/EunuchsIntrigues.java @@ -67,8 +67,8 @@ class EunuchsIntriguesEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); filter.add(new ControllerIdPredicate(player.getId())); Target target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) { + if (target.canChoose(player.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(player.getId(), source, game) && player.canRespond()) { player.chooseTarget(Outcome.DestroyPermanent, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/e/Eureka.java b/Mage.Sets/src/mage/cards/e/Eureka.java index c62b9e91acc..207f07f1b1a 100644 --- a/Mage.Sets/src/mage/cards/e/Eureka.java +++ b/Mage.Sets/src/mage/cards/e/Eureka.java @@ -75,7 +75,7 @@ class EurekaEffect extends OneShotEffect { if (currentPlayer != null && currentPlayer.canRespond() && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { target.clearChosen(); - if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game) + if (target.canChoose(currentPlayer.getId(), source, game) && currentPlayer.chooseUse(outcome, "Put permanent from your hand to play?", source, game)) { if (target.chooseTarget(outcome, currentPlayer.getId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/e/EvilTwin.java b/Mage.Sets/src/mage/cards/e/EvilTwin.java index c2f531b9f34..058ce6f2afb 100644 --- a/Mage.Sets/src/mage/cards/e/EvilTwin.java +++ b/Mage.Sets/src/mage/cards/e/EvilTwin.java @@ -80,7 +80,7 @@ class EvilTwinPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { Permanent permanent = input.getObject(); - Permanent twin = game.getPermanent(input.getSourceId()); + Permanent twin = input.getSource().getSourcePermanentIfItStillExists(game); return CardUtil.haveSameNames(permanent, twin); } diff --git a/Mage.Sets/src/mage/cards/e/ExertInfluence.java b/Mage.Sets/src/mage/cards/e/ExertInfluence.java index c56cb657859..135a09f3006 100644 --- a/Mage.Sets/src/mage/cards/e/ExertInfluence.java +++ b/Mage.Sets/src/mage/cards/e/ExertInfluence.java @@ -62,7 +62,7 @@ class ExertInfluenceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (controller != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/e/Exhume.java b/Mage.Sets/src/mage/cards/e/Exhume.java index e1d5724ca38..c0de24ec1de 100644 --- a/Mage.Sets/src/mage/cards/e/Exhume.java +++ b/Mage.Sets/src/mage/cards/e/Exhume.java @@ -68,7 +68,7 @@ class ExhumeEffect extends OneShotEffect { filterCreatureCard.add(new OwnerIdPredicate(playerId)); TargetCardInGraveyard target = new TargetCardInGraveyard(filterCreatureCard); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), playerId, game) + if (target.canChoose(playerId, source, game) && player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/e/ExperimentKraj.java b/Mage.Sets/src/mage/cards/e/ExperimentKraj.java index 9967d4ed624..0d4efac3aad 100644 --- a/Mage.Sets/src/mage/cards/e/ExperimentKraj.java +++ b/Mage.Sets/src/mage/cards/e/ExperimentKraj.java @@ -76,7 +76,7 @@ class ExperimentKrajEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Permanent perm = game.getPermanent(source.getSourceId()); if (perm != null) { - for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)){ + for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)){ for (Ability ability: creature.getAbilities()) { if (ability instanceof ActivatedAbility) { perm.addAbility(ability, source.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/e/ExplosiveSingularity.java b/Mage.Sets/src/mage/cards/e/ExplosiveSingularity.java index b7b09459fab..48e52061fe2 100644 --- a/Mage.Sets/src/mage/cards/e/ExplosiveSingularity.java +++ b/Mage.Sets/src/mage/cards/e/ExplosiveSingularity.java @@ -68,7 +68,7 @@ class ExplosiveSingularityEffect extends CostModificationEffectImpl { if (game.inCheckPlayableState()) { reduction = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_UNTAPPED_CREATURES, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); } else { reduction = ((List) spellAbility.getEffects().get(0).getValue("tappedPermanents")).size(); diff --git a/Mage.Sets/src/mage/cards/e/Expropriate.java b/Mage.Sets/src/mage/cards/e/Expropriate.java index 04aa42b4f37..8808e10acca 100644 --- a/Mage.Sets/src/mage/cards/e/Expropriate.java +++ b/Mage.Sets/src/mage/cards/e/Expropriate.java @@ -94,14 +94,14 @@ class ExpropriateEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent(); filter.add(new ControllerIdPredicate(playerId)); moneyCount = Math.min(game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ), moneyCount); if (moneyCount == 0) { continue; } TargetPermanent target = new TargetPermanent(moneyCount, filter); target.setNotTarget(true); - player.choose(Outcome.GainControl, target, source.getSourceId(), game); + player.choose(Outcome.GainControl, target, source, game); target.getTargets() .stream() .map(game::getPermanent) diff --git a/Mage.Sets/src/mage/cards/e/Extinction.java b/Mage.Sets/src/mage/cards/e/Extinction.java index 91c13915ab1..4edfef0a8fb 100644 --- a/Mage.Sets/src/mage/cards/e/Extinction.java +++ b/Mage.Sets/src/mage/cards/e/Extinction.java @@ -53,7 +53,7 @@ class ExtinctionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject); diff --git a/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java b/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java index 875a24b820d..ea21ec077e9 100644 --- a/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java +++ b/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java @@ -74,7 +74,7 @@ class ExtinctionEventEffect extends OneShotEffect { ) ? oddFilter : evenFilter; return player.moveCards( game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ).stream().collect(Collectors.toSet()), Zone.EXILED, source, game ); } diff --git a/Mage.Sets/src/mage/cards/e/Extirpate.java b/Mage.Sets/src/mage/cards/e/Extirpate.java index 511bc378496..9109c8c3e75 100644 --- a/Mage.Sets/src/mage/cards/e/Extirpate.java +++ b/Mage.Sets/src/mage/cards/e/Extirpate.java @@ -79,7 +79,7 @@ class ExtirpateEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Card chosenCard = game.getCard(getTargetPointer().getFirst(game, source)); if (chosenCard != null && sourceObject != null && controller != null) { Player owner = game.getPlayer(chosenCard.getOwnerId()); diff --git a/Mage.Sets/src/mage/cards/e/ExtractFromDarkness.java b/Mage.Sets/src/mage/cards/e/ExtractFromDarkness.java index 6626d71ad26..49054494bd4 100644 --- a/Mage.Sets/src/mage/cards/e/ExtractFromDarkness.java +++ b/Mage.Sets/src/mage/cards/e/ExtractFromDarkness.java @@ -64,7 +64,7 @@ class ExtractFromDarknessEffect extends OneShotEffect { if (controller != null) { Target target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { return controller.moveCards(game.getCard(target.getFirstTarget()), Zone.BATTLEFIELD, source, game); } diff --git a/Mage.Sets/src/mage/cards/e/EyeForAnEye.java b/Mage.Sets/src/mage/cards/e/EyeForAnEye.java index cff03e1f6ad..a61532bfd86 100644 --- a/Mage.Sets/src/mage/cards/e/EyeForAnEye.java +++ b/Mage.Sets/src/mage/cards/e/EyeForAnEye.java @@ -59,7 +59,7 @@ class EyeForAnEyeEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java index 0f531170ec3..61f75b12e4b 100644 --- a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java +++ b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java @@ -15,7 +15,6 @@ import mage.filter.FilterPermanent; import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -79,7 +78,7 @@ class EyeOfSingularityETBEffect extends OneShotEffect { Map cardNames = new HashMap<>(); Map toDestroy = new HashMap<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { String cardName = permanent.getName(); if (cardNames.get(cardName) == null) { cardNames.put(cardName, permanent.getId()); @@ -166,7 +165,7 @@ class EyeOfSingularityTriggeredEffect extends OneShotEffect { } String cn = etbPermanent.getName(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { String cardName = permanent.getName(); if (cardName.equals(cn) && !Objects.equals(permanent.getId(), etbPermanent.getId())) { toDestroy.put(permanent.getId(), 1); diff --git a/Mage.Sets/src/mage/cards/e/EzurisPredation.java b/Mage.Sets/src/mage/cards/e/EzurisPredation.java index 3c2b5556728..842b0054083 100644 --- a/Mage.Sets/src/mage/cards/e/EzurisPredation.java +++ b/Mage.Sets/src/mage/cards/e/EzurisPredation.java @@ -78,7 +78,7 @@ class EzurisPredationEffect extends OneShotEffect { if (controller != null) { FilterCreaturePermanent filterCreature = new FilterCreaturePermanent(); filterCreature.add(TargetController.OPPONENT.getControllerPredicate()); - List creaturesOfOpponents = game.getBattlefield().getActivePermanents(filterCreature, source.getControllerId(), source.getSourceId(), game); + List creaturesOfOpponents = game.getBattlefield().getActivePermanents(filterCreature, source.getControllerId(), source, game); Set morSet = new HashSet<>(); if (!creaturesOfOpponents.isEmpty()) { CreateTokenEffect effect = new CreateTokenEffect(new PhyrexianBeastToken(), creaturesOfOpponents.size()); diff --git a/Mage.Sets/src/mage/cards/f/FaerieImpostor.java b/Mage.Sets/src/mage/cards/f/FaerieImpostor.java index 94dc8006f78..163db673c29 100644 --- a/Mage.Sets/src/mage/cards/f/FaerieImpostor.java +++ b/Mage.Sets/src/mage/cards/f/FaerieImpostor.java @@ -75,7 +75,7 @@ class FaerieImpostorEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseUse(outcome, "Return another creature you control to its owner's hand?", source, game)) { controller.chooseTarget(Outcome.ReturnToHand, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/f/FaithsReward.java b/Mage.Sets/src/mage/cards/f/FaithsReward.java index 7c643ba5a9b..1f80e9bd001 100644 --- a/Mage.Sets/src/mage/cards/f/FaithsReward.java +++ b/Mage.Sets/src/mage/cards/f/FaithsReward.java @@ -63,7 +63,7 @@ class FaithsRewardEffect extends OneShotEffect { return false; } return player.moveCards(player.getGraveyard().getCards( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ), Zone.BATTLEFIELD, source, game); } diff --git a/Mage.Sets/src/mage/cards/f/FaithsShield.java b/Mage.Sets/src/mage/cards/f/FaithsShield.java index 5dad4847529..6aa767c0a0f 100644 --- a/Mage.Sets/src/mage/cards/f/FaithsShield.java +++ b/Mage.Sets/src/mage/cards/f/FaithsShield.java @@ -62,7 +62,7 @@ class FaithsShieldEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && mageObject != null) { if (FatefulHourCondition.instance.apply(game, source)) { ChoiceColor choice = new ChoiceColor(); diff --git a/Mage.Sets/src/mage/cards/f/FalkenrathGorger.java b/Mage.Sets/src/mage/cards/f/FalkenrathGorger.java index d18775a0eb9..733b4fe1707 100644 --- a/Mage.Sets/src/mage/cards/f/FalkenrathGorger.java +++ b/Mage.Sets/src/mage/cards/f/FalkenrathGorger.java @@ -97,7 +97,7 @@ class FalkenrathGorgerEffect extends ContinuousEffectImpl { } // Exile for (Card card : game.getExile().getAllCards(game)) { - if (filter.match(card, source.getSourceId(), controller.getId(), game)) { + if (filter.match(card, controller.getId(), source, game)) { if (card.isOwnedBy(controller.getId())) { addMadnessToCard(game, card, usedMadnessAbilities); } diff --git a/Mage.Sets/src/mage/cards/f/FallOfTheThran.java b/Mage.Sets/src/mage/cards/f/FallOfTheThran.java index 133369a151b..a1c9cd03dbe 100644 --- a/Mage.Sets/src/mage/cards/f/FallOfTheThran.java +++ b/Mage.Sets/src/mage/cards/f/FallOfTheThran.java @@ -81,8 +81,8 @@ class FallOfTheThranReturnEffect extends OneShotEffect { TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(2, 2, StaticFilters.FILTER_CARD_LAND); target.setNotTarget(true); target.setTargetController(playerId); - if (target.canChoose(source.getSourceId(), playerId, game)) { - player.choose(outcome, target, source.getSourceId(), game); + if (target.canChoose(playerId, source, game)) { + player.choose(outcome, target, source, game); if (target.getTargets().size() == 2) { toBattlefield.put(playerId, new CardsImpl(target.getTargets()).getCards(game)); } diff --git a/Mage.Sets/src/mage/cards/f/FalseOrders.java b/Mage.Sets/src/mage/cards/f/FalseOrders.java index 8b4b1cf5bed..b97db6b90df 100644 --- a/Mage.Sets/src/mage/cards/f/FalseOrders.java +++ b/Mage.Sets/src/mage/cards/f/FalseOrders.java @@ -139,8 +139,8 @@ class FalseOrdersUnblockEffect extends OneShotEffect { FilterAttackingCreature filter = new FilterAttackingCreature("creature attacking " + targetsController.getLogName()); filter.add(new PermanentInListPredicate(list)); TargetAttackingCreature target = new TargetAttackingCreature(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } else { diff --git a/Mage.Sets/src/mage/cards/f/FatalLore.java b/Mage.Sets/src/mage/cards/f/FatalLore.java index 9ea81f4c759..8c452c49dc7 100644 --- a/Mage.Sets/src/mage/cards/f/FatalLore.java +++ b/Mage.Sets/src/mage/cards/f/FatalLore.java @@ -72,8 +72,8 @@ class FatalLoreEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature"); filter.add(new ControllerIdPredicate(chosenOpponent.getId())); TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false); - if (target.canChoose(source.getSourceId(), controller.getId(), game) - && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game) + && controller.choose(Outcome.DestroyPermanent, target, source, game)) { for (UUID targetId : target.getTargets()) { Effect destroyCreature = new DestroyTargetEffect(true); destroyCreature.setTargetPointer(new FixedTarget(targetId, game)); diff --git a/Mage.Sets/src/mage/cards/f/FathomFleetSwordjack.java b/Mage.Sets/src/mage/cards/f/FathomFleetSwordjack.java index 19d57116cae..31c99ec2d5a 100644 --- a/Mage.Sets/src/mage/cards/f/FathomFleetSwordjack.java +++ b/Mage.Sets/src/mage/cards/f/FathomFleetSwordjack.java @@ -67,7 +67,7 @@ class FathomFleetSwordjackEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int artifactCount = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); return artifactCount > 0 && game.damagePlayerOrPlaneswalker( game.getCombat().getDefenderId(source.getSourceId()), artifactCount, diff --git a/Mage.Sets/src/mage/cards/f/FathomTrawl.java b/Mage.Sets/src/mage/cards/f/FathomTrawl.java index 1815cb1a5ea..070a62fd964 100644 --- a/Mage.Sets/src/mage/cards/f/FathomTrawl.java +++ b/Mage.Sets/src/mage/cards/f/FathomTrawl.java @@ -52,7 +52,7 @@ public final class FathomTrawl extends CardImpl { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (controller == null || sourceObject == null) { return false; diff --git a/Mage.Sets/src/mage/cards/f/FeastOfWorms.java b/Mage.Sets/src/mage/cards/f/FeastOfWorms.java index 1a2f718ae3e..eaa6b37e31b 100644 --- a/Mage.Sets/src/mage/cards/f/FeastOfWorms.java +++ b/Mage.Sets/src/mage/cards/f/FeastOfWorms.java @@ -77,7 +77,7 @@ class FeastOfWormsEffect extends OneShotEffect { filter.add(new ControllerIdPredicate(targetPlayer.getId())); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); - if (target.canChoose(source.getSourceId(), targetPlayer.getId(), game)) { + if (target.canChoose(targetPlayer.getId(), source, game)) { targetPlayer.chooseTarget(Outcome.Sacrifice, target, source, game); Permanent land = game.getPermanent(target.getFirstTarget()); if (land != null) { diff --git a/Mage.Sets/src/mage/cards/f/FeedThePack.java b/Mage.Sets/src/mage/cards/f/FeedThePack.java index 4351254bb29..f8d16ae5030 100644 --- a/Mage.Sets/src/mage/cards/f/FeedThePack.java +++ b/Mage.Sets/src/mage/cards/f/FeedThePack.java @@ -68,7 +68,7 @@ class FeedThePackEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Target target = new TargetPermanent(filter); Player player = game.getPlayer(source.getControllerId()); - if (player != null && player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (player != null && player.choose(Outcome.PutCreatureInPlay, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && permanent.sacrifice(source, game)) { int toughness = permanent.getToughness().getValue(); diff --git a/Mage.Sets/src/mage/cards/f/FelineSovereign.java b/Mage.Sets/src/mage/cards/f/FelineSovereign.java index 9644337613f..5bedbb9cc9a 100644 --- a/Mage.Sets/src/mage/cards/f/FelineSovereign.java +++ b/Mage.Sets/src/mage/cards/f/FelineSovereign.java @@ -19,7 +19,6 @@ import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; @@ -107,7 +106,7 @@ class FelineSovereignTriggeredAbility extends TriggeredAbilityImpl { DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; Permanent p = game.getPermanent(event.getSourceId()); if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId()) && - filter.match(p, getSourceId(), getControllerId(), game) && + filter.match(p, getControllerId(), this, game) && !damagedPlayerIds.contains(event.getPlayerId())) { damagedPlayerIds.add(event.getPlayerId()); this.getTargets().clear(); diff --git a/Mage.Sets/src/mage/cards/f/FellTheMighty.java b/Mage.Sets/src/mage/cards/f/FellTheMighty.java index 79e039b7a8a..b69a54b2d81 100644 --- a/Mage.Sets/src/mage/cards/f/FellTheMighty.java +++ b/Mage.Sets/src/mage/cards/f/FellTheMighty.java @@ -60,7 +60,7 @@ class FellTheMightyEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && targetCreature != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source, game)) { if (permanent.getPower().getValue() > targetCreature.getPower().getValue()) { permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/f/FertileImagination.java b/Mage.Sets/src/mage/cards/f/FertileImagination.java index 88f59648943..f122c197a22 100644 --- a/Mage.Sets/src/mage/cards/f/FertileImagination.java +++ b/Mage.Sets/src/mage/cards/f/FertileImagination.java @@ -76,7 +76,7 @@ class FertileImaginationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player player = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(source.getFirstTarget()); if (player != null && opponent != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/f/FertileThicket.java b/Mage.Sets/src/mage/cards/f/FertileThicket.java index 1144cf7cf1d..1d5b3faa942 100644 --- a/Mage.Sets/src/mage/cards/f/FertileThicket.java +++ b/Mage.Sets/src/mage/cards/f/FertileThicket.java @@ -69,7 +69,7 @@ class FertileThicketEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); controller.lookAtCards(sourceObject.getIdName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/f/FesteringWound.java b/Mage.Sets/src/mage/cards/f/FesteringWound.java index 0c3af910d8d..d870c05fbec 100644 --- a/Mage.Sets/src/mage/cards/f/FesteringWound.java +++ b/Mage.Sets/src/mage/cards/f/FesteringWound.java @@ -68,7 +68,7 @@ class FesteringWoundEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID sourceId = source.getSourceId(); + UUID sourceId = source != null ? source.getSourceId() : null; int amount = game.getPermanent(sourceId).getCounters(game).getCount(CounterType.INFECTION); UUID id = this.getTargetPointer().getFirst(game, source); Player player = game.getPlayer(id); diff --git a/Mage.Sets/src/mage/cards/f/FickleEfreet.java b/Mage.Sets/src/mage/cards/f/FickleEfreet.java index 4b32a9a51a7..b7fa0c2d222 100644 --- a/Mage.Sets/src/mage/cards/f/FickleEfreet.java +++ b/Mage.Sets/src/mage/cards/f/FickleEfreet.java @@ -72,8 +72,8 @@ class FickleEfreetChangeControlEffect extends OneShotEffect { if (!controller.flipCoin(source, game, true)) { if (sourcePermanent != null) { Target target = new TargetOpponent(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } diff --git a/Mage.Sets/src/mage/cards/f/FiendOfTheShadows.java b/Mage.Sets/src/mage/cards/f/FiendOfTheShadows.java index 04ac8592278..ac2b9cd96c9 100644 --- a/Mage.Sets/src/mage/cards/f/FiendOfTheShadows.java +++ b/Mage.Sets/src/mage/cards/f/FiendOfTheShadows.java @@ -80,7 +80,7 @@ class FiendOfTheShadowsEffect extends OneShotEffect { return false; } TargetCard targetCard = new TargetDiscard(player.getId()); - player.choose(outcome, targetCard, source.getSourceId(), game); + player.choose(outcome, targetCard, source, game); Card card = game.getCard(targetCard.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/f/FightOrFlight.java b/Mage.Sets/src/mage/cards/f/FightOrFlight.java index fdf1419eb96..6e49d396493 100644 --- a/Mage.Sets/src/mage/cards/f/FightOrFlight.java +++ b/Mage.Sets/src/mage/cards/f/FightOrFlight.java @@ -72,7 +72,7 @@ class FightOrFlightEffect extends OneShotEffect { TargetCreaturePermanent creatures = new TargetCreaturePermanent(0, count, new FilterCreaturePermanent("creatures to put in the first pile"), true); List pile1 = new ArrayList<>(); creatures.setRequired(false); - if (player.choose(Outcome.Neutral, creatures, source.getSourceId(), game)) { + if (player.choose(Outcome.Neutral, creatures, source, game)) { List targets = creatures.getTargets(); for (UUID targetId : targets) { Permanent p = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/f/FindFinality.java b/Mage.Sets/src/mage/cards/f/FindFinality.java index 47f69b73e71..609f697ee47 100644 --- a/Mage.Sets/src/mage/cards/f/FindFinality.java +++ b/Mage.Sets/src/mage/cards/f/FindFinality.java @@ -84,7 +84,7 @@ class FinalityEffect extends OneShotEffect { Target target = new TargetControlledCreaturePermanent(0, 1); target.setNotTarget(true); if (player.choose( - Outcome.BoostCreature, target, source.getSourceId(), game + Outcome.BoostCreature, target, source, game )) { Effect effect = new AddCountersTargetEffect( CounterType.P1P1.createInstance(2) diff --git a/Mage.Sets/src/mage/cards/f/FireJuggler.java b/Mage.Sets/src/mage/cards/f/FireJuggler.java index e68eb240e1c..98dfa91aa27 100644 --- a/Mage.Sets/src/mage/cards/f/FireJuggler.java +++ b/Mage.Sets/src/mage/cards/f/FireJuggler.java @@ -1,7 +1,5 @@ - package mage.cards.f; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.BecomesBlockedSourceTriggeredAbility; import mage.abilities.effects.common.DamageAllEffect; @@ -11,16 +9,24 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.FilterPermanent; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; + +import java.util.UUID; /** - * * @author BursegSardaukar */ public final class FireJuggler extends CardImpl { - + + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public FireJuggler(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); this.subtype.add(SubType.GOBLIN); this.subtype.add(SubType.SHAMAN); @@ -28,9 +34,9 @@ public final class FireJuggler extends CardImpl { this.toughness = new MageInt(2); // Whenever Fire Juggler becomes blocked, clash with an opponent. If you win, Fire Juggler deals 4 damage to each creature blocking it. - FilterPermanent filter = new FilterPermanent("creature blocking it"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - this.addAbility(new BecomesBlockedSourceTriggeredAbility(new DoIfClashWonEffect(new DamageAllEffect(4,filter)),false)); + this.addAbility(new BecomesBlockedSourceTriggeredAbility( + new DoIfClashWonEffect(new DamageAllEffect(4, filter)), false + )); } private FireJuggler(final FireJuggler card) { diff --git a/Mage.Sets/src/mage/cards/f/Fireball.java b/Mage.Sets/src/mage/cards/f/Fireball.java index 6b563f9b1a5..2a444dcb2c0 100644 --- a/Mage.Sets/src/mage/cards/f/Fireball.java +++ b/Mage.Sets/src/mage/cards/f/Fireball.java @@ -123,7 +123,7 @@ class FireballTargetCreatureOrPlayer extends TargetAnyTarget { } for (int numberTargets = 1; numberTargets == 1 || xVal / (numberTargets - 1) > 1; numberTargets++) { - Set possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game); + Set possibleTargets = possibleTargets(source.getControllerId(), source, game); // less possible targets than we're trying to set if (possibleTargets.size() < numberTargets) { return options; diff --git a/Mage.Sets/src/mage/cards/f/FirjasRetribution.java b/Mage.Sets/src/mage/cards/f/FirjasRetribution.java index 7eb316a407e..5b9fde1d43c 100644 --- a/Mage.Sets/src/mage/cards/f/FirjasRetribution.java +++ b/Mage.Sets/src/mage/cards/f/FirjasRetribution.java @@ -80,7 +80,7 @@ enum FirjasRetributionPredicate implements ObjectSourcePlayerPredicate input, Game game) { - Permanent permanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent permanent = input.getSource().getSourcePermanentOrLKI(game); return permanent != null && input.getObject().getPower().getValue() < permanent.getPower().getValue(); } } diff --git a/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java b/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java index c53a5a0ee99..d02ee912206 100644 --- a/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java +++ b/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java @@ -16,7 +16,6 @@ import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.common.TargetAnyTarget; @@ -89,7 +88,7 @@ class FiveAlarmFireTriggeredAbility extends TriggeredAbilityImpl { || event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { if (((DamagedEvent) event).isCombatDamage() && !triggeringCreatures.contains(event.getSourceId())) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent != null && filter.match(permanent, sourceId, controllerId, game)) { + if (permanent != null && filter.match(permanent, controllerId, this, game)) { triggeringCreatures.add(event.getSourceId()); return true; } diff --git a/Mage.Sets/src/mage/cards/f/FlamescrollCelebrant.java b/Mage.Sets/src/mage/cards/f/FlamescrollCelebrant.java index e901d7c39f8..003a0c07ccb 100644 --- a/Mage.Sets/src/mage/cards/f/FlamescrollCelebrant.java +++ b/Mage.Sets/src/mage/cards/f/FlamescrollCelebrant.java @@ -135,7 +135,7 @@ class RevelInSilenceEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { Player activePlayer = game.getPlayer(game.getActivePlayerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (activePlayer == null || mageObject == null) { return null; } diff --git a/Mage.Sets/src/mage/cards/f/Flash.java b/Mage.Sets/src/mage/cards/f/Flash.java index 6e52b341c07..a5aba127c0d 100644 --- a/Mage.Sets/src/mage/cards/f/Flash.java +++ b/Mage.Sets/src/mage/cards/f/Flash.java @@ -67,7 +67,7 @@ class FlashEffect extends OneShotEffect { } TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/f/FlashOfInsight.java b/Mage.Sets/src/mage/cards/f/FlashOfInsight.java index 7a8a577922b..d11bccc77b6 100644 --- a/Mage.Sets/src/mage/cards/f/FlashOfInsight.java +++ b/Mage.Sets/src/mage/cards/f/FlashOfInsight.java @@ -73,7 +73,7 @@ class FlashOfInsightEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/f/FloodOfTears.java b/Mage.Sets/src/mage/cards/f/FloodOfTears.java index b8d376cb1d9..4882ea2f870 100644 --- a/Mage.Sets/src/mage/cards/f/FloodOfTears.java +++ b/Mage.Sets/src/mage/cards/f/FloodOfTears.java @@ -66,7 +66,7 @@ class FloodOfTearsEffect extends OneShotEffect { return false; } List nonlands = game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source, game ); Cards cards = new CardsImpl(); if (!nonlands.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/f/FlowstoneSalamander.java b/Mage.Sets/src/mage/cards/f/FlowstoneSalamander.java index a712462d265..ae5146d2786 100644 --- a/Mage.Sets/src/mage/cards/f/FlowstoneSalamander.java +++ b/Mage.Sets/src/mage/cards/f/FlowstoneSalamander.java @@ -1,7 +1,5 @@ - package mage.cards.f; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -11,28 +9,33 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author LoneFox */ public final class FlowstoneSalamander extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public FlowstoneSalamander(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{R}"); this.subtype.add(SubType.SALAMANDER); this.power = new MageInt(3); this.toughness = new MageInt(4); // {R}: Flowstone Salamander deals 1 damage to target creature blocking it. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new ManaCostsImpl("{R}")); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking it"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new ManaCostsImpl<>("{R}")); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/f/FoldIntoAether.java b/Mage.Sets/src/mage/cards/f/FoldIntoAether.java index b50bab29071..007dbb93bf6 100644 --- a/Mage.Sets/src/mage/cards/f/FoldIntoAether.java +++ b/Mage.Sets/src/mage/cards/f/FoldIntoAether.java @@ -67,9 +67,9 @@ class FoldIntoAetherEffect extends OneShotEffect { if (game.getStack().counter(targetId, source, game)) { TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE); if (spellController != null - && target.canChoose(source.getSourceId(), spellController.getId(), game) + && target.canChoose(spellController.getId(), source, game) && spellController.chooseUse(Outcome.Neutral, "Put a creature card from your hand in play?", source, game) - && spellController.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + && spellController.choose(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { spellController.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java b/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java index 8b1f6031ddd..c35ac5b5df3 100644 --- a/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java +++ b/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java @@ -14,7 +14,6 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentToken; @@ -69,8 +68,8 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl { boolean cardReturned = false; TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - if (target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { + if (target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/f/ForcedMarch.java b/Mage.Sets/src/mage/cards/f/ForcedMarch.java index 89ef76f2001..ab807fb5df1 100644 --- a/Mage.Sets/src/mage/cards/f/ForcedMarch.java +++ b/Mage.Sets/src/mage/cards/f/ForcedMarch.java @@ -55,8 +55,7 @@ class ForcedMarchEffect extends OneShotEffect { // for(Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.CREATURE)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), - source.getSourceId(), - game)) { + source, game)) { if (permanent.getManaValue() <= source.getManaCostsToPay().getX()) { permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/f/Forcefield.java b/Mage.Sets/src/mage/cards/f/Forcefield.java index 95248b163ad..bc6bf89cf61 100644 --- a/Mage.Sets/src/mage/cards/f/Forcefield.java +++ b/Mage.Sets/src/mage/cards/f/Forcefield.java @@ -75,7 +75,7 @@ class ForcefieldEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { Target target = new TargetCreaturePermanent(1, 1, filter, true); - if (controller.choose(Outcome.PreventDamage, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PreventDamage, target, source, game)) { Permanent creature = game.getPermanent(target.getFirstTarget()); if (creature != null) { game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + creature.getLogName()); diff --git a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java index c255352f377..d23fa7bd949 100644 --- a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java +++ b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java @@ -97,11 +97,11 @@ public final class ForgottenAncient extends CardImpl { do { Target target = new TargetCreaturePermanent(1, 1, filter, true); - if (!target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (!target.canChoose(controller.getId(), source, game)) { break; } - if (!target.choose(Outcome.BoostCreature, source.getControllerId(), source.getSourceId(), game)) { + if (!target.choose(Outcome.BoostCreature, source.getControllerId(), source.getSourceId(), source, game)) { break; } diff --git a/Mage.Sets/src/mage/cards/f/ForgottenLore.java b/Mage.Sets/src/mage/cards/f/ForgottenLore.java index bdd376c6911..fb29ad8060a 100644 --- a/Mage.Sets/src/mage/cards/f/ForgottenLore.java +++ b/Mage.Sets/src/mage/cards/f/ForgottenLore.java @@ -72,7 +72,7 @@ class ForgottenLoreEffect extends OneShotEffect { do { chosenCard = new TargetCardInGraveyard(filter); chosenCard.setNotTarget(true); - if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (chosenCard.canChoose(opponent.getId(), source, game)) { opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game); card = game.getCard(chosenCard.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/f/ForkInTheRoad.java b/Mage.Sets/src/mage/cards/f/ForkInTheRoad.java index 5f69825c1b1..83382ba1a24 100644 --- a/Mage.Sets/src/mage/cards/f/ForkInTheRoad.java +++ b/Mage.Sets/src/mage/cards/f/ForkInTheRoad.java @@ -61,7 +61,7 @@ class ForkInTheRoadEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/f/FortunateFew.java b/Mage.Sets/src/mage/cards/f/FortunateFew.java index add2923cdae..17ad5a29e6a 100644 --- a/Mage.Sets/src/mage/cards/f/FortunateFew.java +++ b/Mage.Sets/src/mage/cards/f/FortunateFew.java @@ -75,7 +75,7 @@ class FortunateFewEffect extends OneShotEffect { Target target = new TargetNonlandPermanent(filter); target.setNotTarget(true); - if (player.choose(Outcome.Exile, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Exile, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { chosenCards.put(permanent, 1); @@ -85,7 +85,7 @@ class FortunateFewEffect extends OneShotEffect { } } - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source, game)) { if (!chosenCards.containsKey(permanent)) { permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/f/FracturingGust.java b/Mage.Sets/src/mage/cards/f/FracturingGust.java index 35a58aa0eba..f0fad487032 100644 --- a/Mage.Sets/src/mage/cards/f/FracturingGust.java +++ b/Mage.Sets/src/mage/cards/f/FracturingGust.java @@ -62,7 +62,7 @@ class FracturingGustDestroyEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int destroyedPermanents = 0; - for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent.destroy(source, game, false)) { ++destroyedPermanents; } diff --git a/Mage.Sets/src/mage/cards/f/FrayingOmnipotence.java b/Mage.Sets/src/mage/cards/f/FrayingOmnipotence.java index 4c68897da8b..63c6e8a7236 100644 --- a/Mage.Sets/src/mage/cards/f/FrayingOmnipotence.java +++ b/Mage.Sets/src/mage/cards/f/FrayingOmnipotence.java @@ -89,7 +89,7 @@ class FrayingOmnipotenceEffect extends OneShotEffect { continue; } FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 2.0); + int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, player.getId(), source, game) / 2.0); if (creaturesToSacrifice == 0) { continue; } diff --git a/Mage.Sets/src/mage/cards/f/FreeForAll.java b/Mage.Sets/src/mage/cards/f/FreeForAll.java index c82f5d67618..630f6bc995c 100644 --- a/Mage.Sets/src/mage/cards/f/FreeForAll.java +++ b/Mage.Sets/src/mage/cards/f/FreeForAll.java @@ -73,7 +73,7 @@ class FreeForAllExileAllEffect extends OneShotEffect { } Cards cards = new CardsImpl(); game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game ).stream().forEach(cards::add); player.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)); cards.getCards(game) diff --git a/Mage.Sets/src/mage/cards/f/FriendlyFire.java b/Mage.Sets/src/mage/cards/f/FriendlyFire.java index 56e12f1db8b..d9ef0cad56a 100644 --- a/Mage.Sets/src/mage/cards/f/FriendlyFire.java +++ b/Mage.Sets/src/mage/cards/f/FriendlyFire.java @@ -56,7 +56,7 @@ class FriendlyFireEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null) { diff --git a/Mage.Sets/src/mage/cards/f/Fumble.java b/Mage.Sets/src/mage/cards/f/Fumble.java index c5d056b86b1..1d0cbd6eed3 100644 --- a/Mage.Sets/src/mage/cards/f/Fumble.java +++ b/Mage.Sets/src/mage/cards/f/Fumble.java @@ -86,7 +86,7 @@ class FumbleEffect extends OneShotEffect { if (!attachments.isEmpty()) { Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true); Permanent newCreature = null; - if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) { + if (player.choose(Outcome.BoostCreature, target, source, game)) { newCreature = game.getPermanent(target.getFirstTarget()); } for (Permanent attachment : attachments) { diff --git a/Mage.Sets/src/mage/cards/g/GalepowderMage.java b/Mage.Sets/src/mage/cards/g/GalepowderMage.java index 8aecee8b049..7cd3bbcc429 100644 --- a/Mage.Sets/src/mage/cards/g/GalepowderMage.java +++ b/Mage.Sets/src/mage/cards/g/GalepowderMage.java @@ -82,7 +82,7 @@ class GalepowderMageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (getTargetPointer().getFirst(game, source) != null) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java b/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java index e4a7041c787..319645a2568 100644 --- a/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java +++ b/Mage.Sets/src/mage/cards/g/GalvanicBombardment.java @@ -64,7 +64,7 @@ class GalvanicBombardmentCardsInControllerGraveyardCount implements DynamicValue int amount = 0; Player controller = game.getPlayer(sourceAbility.getControllerId()); if (controller != null) { - amount += controller.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + amount += controller.getGraveyard().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } return amount + 2; } diff --git a/Mage.Sets/src/mage/cards/g/GatherThePack.java b/Mage.Sets/src/mage/cards/g/GatherThePack.java index 90c9164598c..27edb597ded 100644 --- a/Mage.Sets/src/mage/cards/g/GatherThePack.java +++ b/Mage.Sets/src/mage/cards/g/GatherThePack.java @@ -64,7 +64,7 @@ class GatherThePackEffect extends OneShotEffect { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); - int creatures = cards.count(StaticFilters.FILTER_CARD_CREATURE, source.getSourceId(), source.getControllerId(), game); + int creatures = cards.count(StaticFilters.FILTER_CARD_CREATURE, source.getControllerId(), source, game); if (creatures > 0) { int max = 1; if (SpellMasteryCondition.instance.apply(game, source) && creatures > 1) { diff --git a/Mage.Sets/src/mage/cards/g/GauntletsOfChaos.java b/Mage.Sets/src/mage/cards/g/GauntletsOfChaos.java index 62b186cb372..00b45620169 100644 --- a/Mage.Sets/src/mage/cards/g/GauntletsOfChaos.java +++ b/Mage.Sets/src/mage/cards/g/GauntletsOfChaos.java @@ -83,13 +83,13 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { // get all cardtypes from opponents permanents - Set cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game); + Set cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), sourceControllerId, game); Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { for (CardType type : permanent.getCardType(game)) { if (cardTypes.contains(type)) { @@ -153,12 +153,12 @@ class GauntletsOfChaosSecondTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); if (firstTarget != null) { - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (permanent.shareTypes(firstTarget, game)) { possibleTargets.add(permanent.getId()); diff --git a/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java b/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java index a8446ec66e0..cc4ac222032 100644 --- a/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java +++ b/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java @@ -101,7 +101,7 @@ class GazeOfTheGorgonEffect extends OneShotEffect { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toDestroy = new ArrayList<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!creature.getId().equals(targetCreature.getSourceId())) { if (watcher.creatureHasBlockedAttacker(new MageObjectReference(creature, game), targetCreature, game) || watcher.creatureHasBlockedAttacker(targetCreature, new MageObjectReference(creature, game), game)) { toDestroy.add(creature); diff --git a/Mage.Sets/src/mage/cards/g/GeneralsRegalia.java b/Mage.Sets/src/mage/cards/g/GeneralsRegalia.java index 2bdabe9cf07..903fb86398c 100644 --- a/Mage.Sets/src/mage/cards/g/GeneralsRegalia.java +++ b/Mage.Sets/src/mage/cards/g/GeneralsRegalia.java @@ -67,7 +67,7 @@ class GeneralsRegaliaEffect extends RedirectionEffect { @Override public void init(Ability source, Game game) { - this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/g/GenesisHydra.java b/Mage.Sets/src/mage/cards/g/GenesisHydra.java index 2b5cd6c7a21..fd9e56ba7f7 100644 --- a/Mage.Sets/src/mage/cards/g/GenesisHydra.java +++ b/Mage.Sets/src/mage/cards/g/GenesisHydra.java @@ -80,7 +80,7 @@ class GenesisHydraPutOntoBattlefieldEffect extends OneShotEffect { filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, count + 1)); TargetCard target1 = new TargetCard(Zone.LIBRARY, filter); target1.setRequired(false); - if (cards.count(filter, controller.getId(), source.getSourceId(), game) > 0) { + if (cards.count(filter, source.getSourceId(), source, game) > 0) { if (controller.choose(Outcome.PutCardInPlay, cards, target1, game)) { Card card = cards.get(target1.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/g/GeodeRager.java b/Mage.Sets/src/mage/cards/g/GeodeRager.java index f88c93825e0..91435e17034 100644 --- a/Mage.Sets/src/mage/cards/g/GeodeRager.java +++ b/Mage.Sets/src/mage/cards/g/GeodeRager.java @@ -69,7 +69,7 @@ class GeodeRagerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURE, source.getFirstTarget(), source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_CREATURE, source.getFirstTarget(), source, game )) { if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/g/GerrardWeatherlightHero.java b/Mage.Sets/src/mage/cards/g/GerrardWeatherlightHero.java index 5e756d89b67..2f22fbb9fcc 100644 --- a/Mage.Sets/src/mage/cards/g/GerrardWeatherlightHero.java +++ b/Mage.Sets/src/mage/cards/g/GerrardWeatherlightHero.java @@ -85,7 +85,7 @@ class GerrardWeatherlightHeroEffect extends OneShotEffect { return false; } return player.moveCards(player.getGraveyard().getCards( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ), Zone.BATTLEFIELD, source, game); } } diff --git a/Mage.Sets/src/mage/cards/g/Gerrymandering.java b/Mage.Sets/src/mage/cards/g/Gerrymandering.java index 0c2ce27e9a3..6e6a2fc6e85 100644 --- a/Mage.Sets/src/mage/cards/g/Gerrymandering.java +++ b/Mage.Sets/src/mage/cards/g/Gerrymandering.java @@ -66,7 +66,7 @@ class GerrymanderingEffect extends OneShotEffect { if (controller != null) { // Exile all lands. Cards exiledCards = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, source.getControllerId(), source, game)) { exiledCards.add(permanent); playerLandCount.putIfAbsent(permanent.getControllerId(), 0); playerLandCount.put(permanent.getControllerId(), playerLandCount.get(permanent.getControllerId()) + 1); diff --git a/Mage.Sets/src/mage/cards/g/GhastlordOfFugue.java b/Mage.Sets/src/mage/cards/g/GhastlordOfFugue.java index 9c6f0c5d343..63af38912c6 100644 --- a/Mage.Sets/src/mage/cards/g/GhastlordOfFugue.java +++ b/Mage.Sets/src/mage/cards/g/GhastlordOfFugue.java @@ -70,7 +70,7 @@ class GhastlordOfFugueEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (targetPlayer != null && sourceObject != null && controller != null) { diff --git a/Mage.Sets/src/mage/cards/g/GideonsIntervention.java b/Mage.Sets/src/mage/cards/g/GideonsIntervention.java index 1549b31485a..72aaaf97791 100644 --- a/Mage.Sets/src/mage/cards/g/GideonsIntervention.java +++ b/Mage.Sets/src/mage/cards/g/GideonsIntervention.java @@ -73,7 +73,7 @@ class GideonsInterventionCantCastEffect extends ContinuousRuleModifyingEffectImp @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (mageObject != null && cardName != null) { return "You can't cast a card named " + cardName + " (" + mageObject.getIdName() + ")."; diff --git a/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java b/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java index 49ee47ae86e..d4fc9a84db1 100644 --- a/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java +++ b/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java @@ -80,7 +80,7 @@ class GideonsSacrificeEffect extends OneShotEffect { } Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } game.addEffect(new GideonsSacrificeEffectReplacementEffect( diff --git a/Mage.Sets/src/mage/cards/g/GiftOfDoom.java b/Mage.Sets/src/mage/cards/g/GiftOfDoom.java index 15265c8dc64..a21e5565c87 100644 --- a/Mage.Sets/src/mage/cards/g/GiftOfDoom.java +++ b/Mage.Sets/src/mage/cards/g/GiftOfDoom.java @@ -128,7 +128,7 @@ class GiftOfDoomEffect extends OneShotEffect { } TargetCreaturePermanent target = new TargetCreaturePermanent(filter); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game) + if (player.choose(outcome, target, source, game) && game.getPermanent(target.getFirstTarget()) != null && !game.getPermanent(target.getFirstTarget()).cantBeAttachedBy(giftOfDoom, source, game, false)) { game.getState().setValue("attachTo:" + giftOfDoom.getId(), target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java index fa18a622a6a..4cb287eddd8 100644 --- a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java +++ b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java @@ -76,8 +76,8 @@ class GiltspireAvengerTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); for (UUID targetId : availablePossibleTargets) { @@ -90,15 +90,15 @@ class GiltspireAvengerTarget extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int remainingTargets = this.minNumberOfTargets - targets.size(); if (remainingTargets == 0) { return true; } int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) { count++; diff --git a/Mage.Sets/src/mage/cards/g/GlacialCrasher.java b/Mage.Sets/src/mage/cards/g/GlacialCrasher.java index 3d6ddd350c2..14e1ce95714 100644 --- a/Mage.Sets/src/mage/cards/g/GlacialCrasher.java +++ b/Mage.Sets/src/mage/cards/g/GlacialCrasher.java @@ -76,7 +76,7 @@ class GlacialCrasherEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1; + return game.getBattlefield().count(filter, source.getControllerId(), source, game) < 1; } return false; } diff --git a/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java b/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java index fd5cdfc454e..ca751d63529 100644 --- a/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java +++ b/Mage.Sets/src/mage/cards/g/GlacianPowerstoneEngineer.java @@ -130,7 +130,7 @@ class GlacianPowerstoneEngineerCost extends VariableCostImpl { @Override public int getMaxValue(Ability source, Game game) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + return game.getBattlefield().count(filter, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/g/GlamerSpinners.java b/Mage.Sets/src/mage/cards/g/GlamerSpinners.java index bc4ac48c054..135212959c8 100644 --- a/Mage.Sets/src/mage/cards/g/GlamerSpinners.java +++ b/Mage.Sets/src/mage/cards/g/GlamerSpinners.java @@ -102,8 +102,8 @@ class GlamerSpinnersEffect extends OneShotEffect { LinkedList auras = new LinkedList<>(); auras.addAll(targetPermanent.getAttachments()); if (source.getSourceObjectZoneChangeCounter() == glamerSpinners.getZoneChangeCounter(game) // not blinked - && chosenPermanentToAttachAuras.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) { + && chosenPermanentToAttachAuras.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source, game)) { Permanent permanentToAttachAuras = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget()); if (permanentToAttachAuras != null) { for (UUID auraId : auras) { diff --git a/Mage.Sets/src/mage/cards/g/Glimmerpost.java b/Mage.Sets/src/mage/cards/g/Glimmerpost.java index 82a56d59f20..499490f6a32 100644 --- a/Mage.Sets/src/mage/cards/g/Glimmerpost.java +++ b/Mage.Sets/src/mage/cards/g/Glimmerpost.java @@ -63,7 +63,7 @@ class GlimmerpostEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int amount = game.getBattlefield().count(filter, source.getControllerId(), source, game); Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.gainLife(amount, game, source); diff --git a/Mage.Sets/src/mage/cards/g/GlimpseOfTomorrow.java b/Mage.Sets/src/mage/cards/g/GlimpseOfTomorrow.java index aafcd2a15ea..88a839b2184 100644 --- a/Mage.Sets/src/mage/cards/g/GlimpseOfTomorrow.java +++ b/Mage.Sets/src/mage/cards/g/GlimpseOfTomorrow.java @@ -77,7 +77,7 @@ class GlimpseOfTomorrowEffect extends OneShotEffect { return false; } List permanents = game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ); int count = permanents.size(); player.shuffleCardsToLibrary(new CardsImpl(permanents), game, source); diff --git a/Mage.Sets/src/mage/cards/g/GlintHawk.java b/Mage.Sets/src/mage/cards/g/GlintHawk.java index 9ed60010291..deeb51a55f4 100644 --- a/Mage.Sets/src/mage/cards/g/GlintHawk.java +++ b/Mage.Sets/src/mage/cards/g/GlintHawk.java @@ -69,7 +69,7 @@ class GlintHawkEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseUse(outcome, "Return an artifact you control to its owner's hand?", source, game)) { controller.chooseTarget(Outcome.ReturnToHand, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/g/GlobalRuin.java b/Mage.Sets/src/mage/cards/g/GlobalRuin.java index 320840510c6..23cf7b005f0 100644 --- a/Mage.Sets/src/mage/cards/g/GlobalRuin.java +++ b/Mage.Sets/src/mage/cards/g/GlobalRuin.java @@ -70,7 +70,7 @@ class GlobalRuinDestroyLandEffect extends OneShotEffect { FilterControlledLandPermanent filter = new FilterControlledLandPermanent(landName + " you control"); filter.add(landName.getPredicate()); Target target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(outcome, target, source, game); lands.add(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/g/GloriousProtector.java b/Mage.Sets/src/mage/cards/g/GloriousProtector.java index 6dce19bb5da..bdc56b54e00 100644 --- a/Mage.Sets/src/mage/cards/g/GloriousProtector.java +++ b/Mage.Sets/src/mage/cards/g/GloriousProtector.java @@ -95,7 +95,7 @@ class GloriousProtectorEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); if (target.getTargets().isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/cards/g/GlowsporeShaman.java b/Mage.Sets/src/mage/cards/g/GlowsporeShaman.java index c058d1667cb..7954c5ee4b8 100644 --- a/Mage.Sets/src/mage/cards/g/GlowsporeShaman.java +++ b/Mage.Sets/src/mage/cards/g/GlowsporeShaman.java @@ -79,7 +79,7 @@ class GlowsporeShamanEffect extends OneShotEffect { } Target target = new TargetCardInYourGraveyard(0, 1, filter, true); if (player.chooseUse(outcome, "Put a land card on top of your library?", source, game) - && player.choose(outcome, target, source.getSourceId(), game)) { + && player.choose(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { return player.putCardsOnTopOfLibrary(new CardsImpl(card), game, source, false); diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfDelusion.java b/Mage.Sets/src/mage/cards/g/GlyphOfDelusion.java index 13e76804812..14fbd9ab1c9 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphOfDelusion.java +++ b/Mage.Sets/src/mage/cards/g/GlyphOfDelusion.java @@ -74,14 +74,14 @@ class GlyphOfDelusionSecondTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); if (firstTarget != null) { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, sourceId, game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, source, game)) { if (!targets.containsKey(creature.getId()) && creature.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (watcher.creatureHasBlockedAttacker(new MageObjectReference(creature, game), new MageObjectReference(firstTarget, game), game)) { possibleTargets.add(creature.getId()); diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java b/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java index 6c010d962d6..ed663973bc9 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java +++ b/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java @@ -108,7 +108,7 @@ class GlyphOfDoomEffect extends OneShotEffect { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toDestroy = new ArrayList<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!creature.getId().equals(targetCreature.getSourceId())) { if (watcher.creatureHasBlockedAttacker(new MageObjectReference(creature, game), targetCreature, game)) { toDestroy.add(creature); diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java b/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java index 96e569be88d..cc59afba816 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java +++ b/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java @@ -85,7 +85,7 @@ class GlyphOfReincarnationEffect extends OneShotEffect { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { Map destroyed = new HashMap<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!creature.getId().equals(targetWall.getId())) { if (watcher.creatureHasBlockedAttacker(new MageObjectReference(creature, game), new MageObjectReference(targetWall, game), game)) { if (creature.destroy(source, game, true) @@ -108,7 +108,7 @@ class GlyphOfReincarnationEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(player.getId())); Target targetCreature = new TargetCardInGraveyard(filter); targetCreature.setNotTarget(true); - if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game) + if (targetCreature.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, targetCreature, source, game)) { Card card = game.getCard(targetCreature.getFirstTarget()); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { diff --git a/Mage.Sets/src/mage/cards/g/GnarlrootTrapper.java b/Mage.Sets/src/mage/cards/g/GnarlrootTrapper.java index 2453f52ae2a..a06cc5c3f86 100644 --- a/Mage.Sets/src/mage/cards/g/GnarlrootTrapper.java +++ b/Mage.Sets/src/mage/cards/g/GnarlrootTrapper.java @@ -88,7 +88,7 @@ class GnarlrootTrapperManaCondition extends CreatureCastManaCondition { @Override public boolean apply(Game game, Ability source) { if (super.apply(game, source)) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.hasSubtype(SubType.ELF, game) && object.isCreature(game); } diff --git a/Mage.Sets/src/mage/cards/g/GoShintaiOfHiddenCruelty.java b/Mage.Sets/src/mage/cards/g/GoShintaiOfHiddenCruelty.java index fdcf7b47f61..e1568353f42 100644 --- a/Mage.Sets/src/mage/cards/g/GoShintaiOfHiddenCruelty.java +++ b/Mage.Sets/src/mage/cards/g/GoShintaiOfHiddenCruelty.java @@ -87,7 +87,7 @@ enum GoShintaiOfHiddenCrueltyPredicate implements ObjectSourcePlayerPredicate input, Game game) { return input.getObject().getToughness().getValue() <= game.getBattlefield().count( - filter, input.getSourceId(), input.getPlayerId(), game + filter, input.getPlayerId(), input.getSource(), game ); } } diff --git a/Mage.Sets/src/mage/cards/g/GoblinAssassin.java b/Mage.Sets/src/mage/cards/g/GoblinAssassin.java index 4c84b403a93..9ff79b9becc 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinAssassin.java +++ b/Mage.Sets/src/mage/cards/g/GoblinAssassin.java @@ -69,7 +69,7 @@ class GoblinAssassinTriggeredEffect extends OneShotEffect { if (player != null && !player.flipCoin(source, game, false)) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/g/GoblinCharbelcher.java b/Mage.Sets/src/mage/cards/g/GoblinCharbelcher.java index 4c3cebb5812..e443c2d2eb7 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinCharbelcher.java +++ b/Mage.Sets/src/mage/cards/g/GoblinCharbelcher.java @@ -62,7 +62,7 @@ class GoblinCharbelcherEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { boolean isMountain = false; - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (controller == null || sourceObject == null) { return false; diff --git a/Mage.Sets/src/mage/cards/g/GoblinFestival.java b/Mage.Sets/src/mage/cards/g/GoblinFestival.java index 66510d6bec5..4b59c287929 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinFestival.java +++ b/Mage.Sets/src/mage/cards/g/GoblinFestival.java @@ -71,8 +71,8 @@ class GoblinFestivalChangeControlEffect extends OneShotEffect { if (!controller.flipCoin(source, game, true)) { if (sourcePermanent != null) { Target target = new TargetOpponent(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } diff --git a/Mage.Sets/src/mage/cards/g/GoblinGathering.java b/Mage.Sets/src/mage/cards/g/GoblinGathering.java index 7f93f57fbc8..8c4fff2afba 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinGathering.java +++ b/Mage.Sets/src/mage/cards/g/GoblinGathering.java @@ -56,8 +56,8 @@ enum GoblinGatheringDynamicValue implements DynamicValue { Player player = game.getPlayer(sourceAbility.getControllerId()); if (player != null) { amount += player.getGraveyard().count( - filter, sourceAbility.getSourceId(), - sourceAbility.getControllerId(), game + filter, + sourceAbility.getControllerId(), sourceAbility, game ); } return amount + 2; diff --git a/Mage.Sets/src/mage/cards/g/GoblinGuide.java b/Mage.Sets/src/mage/cards/g/GoblinGuide.java index d70184c2b71..330bfa84700 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinGuide.java +++ b/Mage.Sets/src/mage/cards/g/GoblinGuide.java @@ -119,7 +119,7 @@ class GoblinGuideEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player defender = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && defender != null) { Card card = defender.getLibrary().getFromTop(game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/g/GoblinJavelineer.java b/Mage.Sets/src/mage/cards/g/GoblinJavelineer.java index d8879575b88..074ccd261ae 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinJavelineer.java +++ b/Mage.Sets/src/mage/cards/g/GoblinJavelineer.java @@ -1,25 +1,32 @@ package mage.cards.g; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BecomesBlockedSourceTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; -import mage.constants.SubType; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.SubType; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author weirddan455 */ public final class GoblinJavelineer extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public GoblinJavelineer(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}"); @@ -32,10 +39,10 @@ public final class GoblinJavelineer extends CardImpl { this.addAbility(HasteAbility.getInstance()); // Whenever Goblin Javelineer becomes blocked, it deals 1 damage to target creature blocking it. - Ability ability = new BecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(1, "it"), false); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking it"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new BecomesBlockedSourceTriggeredAbility( + new DamageTargetEffect(1, "it"), false + ); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java b/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java index d143fc2df33..6deeeeca435 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java +++ b/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java @@ -98,7 +98,7 @@ class GoblinPsychopathEffect extends ReplacementEffectImpl { } // TODO: make this redirect damage from all blockers controller.damage(event.getAmount(), source.getSourceId(), source, game); - String sourceLogName = game.getObject(source.getSourceId()).getLogName() + ": "; + String sourceLogName = game.getObject(source).getLogName() + ": "; game.informPlayers(sourceLogName + "Redirected " + event.getAmount() + " damage to " + controller.getLogName()); this.discard(); return true; diff --git a/Mage.Sets/src/mage/cards/g/GoblinSecretAgent.java b/Mage.Sets/src/mage/cards/g/GoblinSecretAgent.java index 9a03bbee82c..ed754f85e04 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinSecretAgent.java +++ b/Mage.Sets/src/mage/cards/g/GoblinSecretAgent.java @@ -67,7 +67,7 @@ class GoblinSecretAgentEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (!controller.getHand().isEmpty()) { CardsImpl randomCard = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/g/GoblinShrine.java b/Mage.Sets/src/mage/cards/g/GoblinShrine.java index a94b797c423..ff992ab47bf 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinShrine.java +++ b/Mage.Sets/src/mage/cards/g/GoblinShrine.java @@ -83,7 +83,7 @@ class EnchantedPermanentSubtypeCondition implements Condition { if (enchantment != null) { Permanent permanent = game.getPermanent(enchantment.getAttachedTo()); if (permanent != null) { - return filter.match(permanent, source.getSourceId(), enchantment.getControllerId(), game); + return filter.match(permanent, enchantment.getControllerId(), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/g/GoblinSnowman.java b/Mage.Sets/src/mage/cards/g/GoblinSnowman.java index 3864aeb71e5..b45bfb7c08a 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinSnowman.java +++ b/Mage.Sets/src/mage/cards/g/GoblinSnowman.java @@ -1,53 +1,53 @@ - package mage.cards.g; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BlocksSourceTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.PreventCombatDamageBySourceEffect; import mage.abilities.effects.common.PreventCombatDamageToSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; -import mage.constants.Zone; -import mage.filter.common.FilterAttackingCreature; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author BursegSardaukar */ public final class GoblinSnowman extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature it's blocking"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKED_BY); + } + public GoblinSnowman(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); this.subtype.add(SubType.GOBLIN); this.power = new MageInt(1); this.toughness = new MageInt(1); //Whenever Goblin Snowman blocks, prevent all combat damage that would be dealt to and dealt by it this turn. - Effect effect = new PreventCombatDamageBySourceEffect(Duration.EndOfTurn); - effect.setText("prevent all combat damage that would be dealt to"); - Ability ability = new BlocksSourceTriggeredAbility(effect, false); - effect = new PreventCombatDamageToSourceEffect(Duration.EndOfTurn); - effect.setText("and dealt by it this turn"); - ability.addEffect(effect); + Ability ability = new BlocksSourceTriggeredAbility(new PreventCombatDamageBySourceEffect(Duration.EndOfTurn) + .setText("prevent all combat damage that would be dealt to"), false); + ability.addEffect(new PreventCombatDamageToSourceEffect(Duration.EndOfTurn) + .setText("and dealt by it this turn")); this.addAbility(ability); //{T}: Goblin Snowman deals 1 damage to target creature it's blocking. - FilterAttackingCreature filter = new FilterAttackingCreature("creature it's blocking"); - filter.add(new BlockedByIdPredicate(this.getId())); - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); - ability.addTarget(new TargetCreaturePermanent(filter)); + ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new TapSourceCost()); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/g/GoblinWarCry.java b/Mage.Sets/src/mage/cards/g/GoblinWarCry.java index 8357c4a0c29..5379a244223 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinWarCry.java +++ b/Mage.Sets/src/mage/cards/g/GoblinWarCry.java @@ -67,8 +67,8 @@ class GoblinWarCryEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); filter.add(new ControllerIdPredicate(player.getId())); Target target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) { + if (target.canChoose(player.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(player.getId(), source, game) && player.canRespond()) { player.chooseTarget(Outcome.DestroyPermanent, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/g/GodEternalBontu.java b/Mage.Sets/src/mage/cards/g/GodEternalBontu.java index 0aacb71005e..9ecefcfaa55 100644 --- a/Mage.Sets/src/mage/cards/g/GodEternalBontu.java +++ b/Mage.Sets/src/mage/cards/g/GodEternalBontu.java @@ -86,7 +86,7 @@ class GodEternalBontuEffect extends OneShotEffect { return false; } Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } int counter = 0; diff --git a/Mage.Sets/src/mage/cards/g/GodPharaohsGift.java b/Mage.Sets/src/mage/cards/g/GodPharaohsGift.java index 70677d46ea6..efecd2d6ba2 100644 --- a/Mage.Sets/src/mage/cards/g/GodPharaohsGift.java +++ b/Mage.Sets/src/mage/cards/g/GodPharaohsGift.java @@ -77,7 +77,7 @@ class GodPharaohsGiftEffect extends OneShotEffect { TargetCardInYourGraveyard target = new TargetCardInYourGraveyard( 0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD, true ); - controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game); + controller.choose(Outcome.PutCreatureInPlay, target, source, game); Card cardChosen = game.getCard(target.getFirstTarget()); if (cardChosen == null || !controller.moveCards(cardChosen, Zone.EXILED, source, game)) { return false; diff --git a/Mage.Sets/src/mage/cards/g/GodosIrregulars.java b/Mage.Sets/src/mage/cards/g/GodosIrregulars.java index 76b3c7ef7ff..0509a8cf862 100644 --- a/Mage.Sets/src/mage/cards/g/GodosIrregulars.java +++ b/Mage.Sets/src/mage/cards/g/GodosIrregulars.java @@ -1,7 +1,6 @@ package mage.cards.g; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -11,19 +10,26 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class GodosIrregulars extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public GodosIrregulars(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WARRIOR); @@ -31,10 +37,8 @@ public final class GodosIrregulars extends CardImpl { this.toughness = new MageInt(1); // {R}: Godo's Irregulars deals 1 damage to target creature blocking it. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new ManaCostsImpl("{R}")); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking it"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new ManaCostsImpl<>("{R}")); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/g/Godsend.java b/Mage.Sets/src/mage/cards/g/Godsend.java index 46ea22c8031..31a3e78b63d 100644 --- a/Mage.Sets/src/mage/cards/g/Godsend.java +++ b/Mage.Sets/src/mage/cards/g/Godsend.java @@ -181,7 +181,7 @@ class GodsendRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast this spell because a card with the same name is exiled by " + mageObject.getLogName() + '.'; } diff --git a/Mage.Sets/src/mage/cards/g/GoldenRatio.java b/Mage.Sets/src/mage/cards/g/GoldenRatio.java index 174d40baf80..bd2a099d8b8 100644 --- a/Mage.Sets/src/mage/cards/g/GoldenRatio.java +++ b/Mage.Sets/src/mage/cards/g/GoldenRatio.java @@ -48,7 +48,7 @@ enum GoldenRatioValue implements DynamicValue { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - sourceAbility.getControllerId(), sourceAbility.getSourceId(), game + sourceAbility.getControllerId(), sourceAbility, game ) .stream() .filter(Objects::nonNull) diff --git a/Mage.Sets/src/mage/cards/g/GrabTheReins.java b/Mage.Sets/src/mage/cards/g/GrabTheReins.java index 4aa300b4be9..bf9d7c668a2 100644 --- a/Mage.Sets/src/mage/cards/g/GrabTheReins.java +++ b/Mage.Sets/src/mage/cards/g/GrabTheReins.java @@ -82,7 +82,7 @@ class GrabTheReinsEffect extends OneShotEffect { Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); target.setTargetName("a creature to sacrifice"); - if (!target.canChoose(source.getSourceId(), controllerId, game)) { + if (!target.canChoose(controllerId, source, game)) { return false; } Player player = game.getPlayer(controllerId); diff --git a/Mage.Sets/src/mage/cards/g/GrandAbolisher.java b/Mage.Sets/src/mage/cards/g/GrandAbolisher.java index 87043a8ced6..cc81e188852 100644 --- a/Mage.Sets/src/mage/cards/g/GrandAbolisher.java +++ b/Mage.Sets/src/mage/cards/g/GrandAbolisher.java @@ -70,7 +70,7 @@ class GrandAbolisherEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { Player activePlayer = game.getPlayer(game.getActivePlayerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (activePlayer != null && mageObject != null) { return "You can't cast spells or activate abilities of artifacts, creatures, or enchantments during the turns of " + activePlayer.getLogName() + " (" + mageObject.getLogName() + ')'; diff --git a/Mage.Sets/src/mage/cards/g/GrandArchitect.java b/Mage.Sets/src/mage/cards/g/GrandArchitect.java index 27dc7d00e9a..2a53c4a73b3 100644 --- a/Mage.Sets/src/mage/cards/g/GrandArchitect.java +++ b/Mage.Sets/src/mage/cards/g/GrandArchitect.java @@ -140,7 +140,7 @@ class GrandArchitectManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isArtifact(game); } } diff --git a/Mage.Sets/src/mage/cards/g/GrappleWithThePast.java b/Mage.Sets/src/mage/cards/g/GrappleWithThePast.java index 540beb7a986..50333867a55 100644 --- a/Mage.Sets/src/mage/cards/g/GrappleWithThePast.java +++ b/Mage.Sets/src/mage/cards/g/GrappleWithThePast.java @@ -72,9 +72,9 @@ class GrappleWithThePastEffect extends OneShotEffect { } TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseUse(outcome, "Return a creature or land card from your graveyard to hand?", source, game) - && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + && controller.choose(Outcome.ReturnToHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/g/GraveConsequences.java b/Mage.Sets/src/mage/cards/g/GraveConsequences.java index 68cbdd79372..7ecdae2a3d3 100644 --- a/Mage.Sets/src/mage/cards/g/GraveConsequences.java +++ b/Mage.Sets/src/mage/cards/g/GraveConsequences.java @@ -74,7 +74,7 @@ class GraveConsequencesEffect extends OneShotEffect { for (Player player : players) { TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Cards cards = new CardsImpl(target.getTargets()); if (!cards.isEmpty()) { player.moveCards(cards, Zone.EXILED, source, game); diff --git a/Mage.Sets/src/mage/cards/g/GraveEndeavor.java b/Mage.Sets/src/mage/cards/g/GraveEndeavor.java index 410fb8dc9f7..5835cbf62f5 100644 --- a/Mage.Sets/src/mage/cards/g/GraveEndeavor.java +++ b/Mage.Sets/src/mage/cards/g/GraveEndeavor.java @@ -82,7 +82,7 @@ class GraveEndeavorEffect extends OneShotEffect { if (player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) { TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - player.choose(outcome, target, source.getControllerId(), game); + player.choose(outcome, target, source, game); if (target.getFirstTarget() != null) { new ReturnFromGraveyardToBattlefieldWithCounterTargetEffect( CounterType.P1P1.createInstance(first) diff --git a/Mage.Sets/src/mage/cards/g/GraveExchange.java b/Mage.Sets/src/mage/cards/g/GraveExchange.java index 79415dc1081..cd1dc65f8fa 100644 --- a/Mage.Sets/src/mage/cards/g/GraveExchange.java +++ b/Mage.Sets/src/mage/cards/g/GraveExchange.java @@ -70,8 +70,8 @@ class GraveExchangeEffect extends OneShotEffect { Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game) - && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (target.canChoose(player.getId(), source, game) + && player.choose(Outcome.Sacrifice, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { return permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/g/GravePact.java b/Mage.Sets/src/mage/cards/g/GravePact.java index c49d11236e6..7f400126ed8 100644 --- a/Mage.Sets/src/mage/cards/g/GravePact.java +++ b/Mage.Sets/src/mage/cards/g/GravePact.java @@ -104,7 +104,7 @@ class GravePactEffect extends OneShotEffect { if (player != null && !playerId.equals(source.getControllerId())) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/g/GraveSifter.java b/Mage.Sets/src/mage/cards/g/GraveSifter.java index 849376547fb..ca2a8f5de39 100644 --- a/Mage.Sets/src/mage/cards/g/GraveSifter.java +++ b/Mage.Sets/src/mage/cards/g/GraveSifter.java @@ -70,7 +70,7 @@ class GraveSifterEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); typeChoice.setMessage("Choose creature type to return cards from your graveyard"); Player controller = game.getPlayer(source.getControllerId()); Set toHand = new HashSet<>(); diff --git a/Mage.Sets/src/mage/cards/g/Graxiplon.java b/Mage.Sets/src/mage/cards/g/Graxiplon.java index c6c2ede6f3b..6649e3605ab 100644 --- a/Mage.Sets/src/mage/cards/g/Graxiplon.java +++ b/Mage.Sets/src/mage/cards/g/Graxiplon.java @@ -51,8 +51,6 @@ enum GraxiplonCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(source.getSourceId(), game)); - return player == null || GreatestSharedCreatureTypeCount.getValue( - player.getId(), source.getSourceId(), game - ) < 3; + return player == null || GreatestSharedCreatureTypeCount.getValue(player.getId(), source, game) < 3; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/g/Greedo.java b/Mage.Sets/src/mage/cards/g/Greedo.java index f5192db19eb..e0af3f9f168 100644 --- a/Mage.Sets/src/mage/cards/g/Greedo.java +++ b/Mage.Sets/src/mage/cards/g/Greedo.java @@ -1,7 +1,5 @@ - package mage.cards.g; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; @@ -10,29 +8,39 @@ import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.abilities.keyword.FirstStrikeAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.SuperType; import mage.filter.FilterCard; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; import mage.target.common.TargetCardInLibrary; +import java.util.UUID; + /** - * * @author Styxo */ public final class Greedo extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by {this}"); private static final FilterCard filterCard = new FilterCard("Hunter or Rogue card"); static { - filterCard.add(Predicates.or(SubType.ROGUE.getPredicate(), SubType.HUNTER.getPredicate())); + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + filterCard.add(Predicates.or( + SubType.ROGUE.getPredicate(), + SubType.HUNTER.getPredicate() + )); } public Greedo(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{R}{G}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.RODIAN); this.subtype.add(SubType.HUNTER); @@ -40,12 +48,15 @@ public final class Greedo extends CardImpl { this.toughness = new MageInt(4); // Creatures blocking or blocked by Greedo have first strike. - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), new BlockingAttackerIdPredicate(this.getId()))); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(FirstStrikeAbility.getInstance(), Duration.WhileOnBattlefield, filter, "Creatures blocking or blocked by {this} have first strike"))); + this.addAbility(new SimpleStaticAbility(new GainAbilityAllEffect( + FirstStrikeAbility.getInstance(), Duration.WhileOnBattlefield, filter, + "Creatures blocking or blocked by {this} have first strike" + ))); // When Greedo dies, you may search your library for Hunter or Rogue card, reveal it, and put it into your hand. - this.addAbility(new DiesSourceTriggeredAbility(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true), true)); + this.addAbility(new DiesSourceTriggeredAbility(new SearchLibraryPutInHandEffect( + new TargetCardInLibrary(filterCard), true + ), true)); } private Greedo(final Greedo card) { diff --git a/Mage.Sets/src/mage/cards/g/GrenzoHavocRaiser.java b/Mage.Sets/src/mage/cards/g/GrenzoHavocRaiser.java index 6a0782158bf..7b2a6338ad3 100644 --- a/Mage.Sets/src/mage/cards/g/GrenzoHavocRaiser.java +++ b/Mage.Sets/src/mage/cards/g/GrenzoHavocRaiser.java @@ -146,7 +146,7 @@ class GrenzoHavocRaiserEffect extends OneShotEffect { if (controller != null) { Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (damagedPlayer != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); UUID exileId = CardUtil.getCardExileZoneId(game, source); Card card = damagedPlayer.getLibrary().getFromTop(game); if (card != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/g/GrenzosRuffians.java b/Mage.Sets/src/mage/cards/g/GrenzosRuffians.java index 4087ba1dfa6..b0aada02c58 100644 --- a/Mage.Sets/src/mage/cards/g/GrenzosRuffians.java +++ b/Mage.Sets/src/mage/cards/g/GrenzosRuffians.java @@ -66,7 +66,7 @@ class GrenzosRuffiansEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { UUID damagedOpponent = this.getTargetPointer().getFirst(game, source); int amount = (Integer) getValue("damage"); - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && amount > 0 && damagedOpponent != null) { for (UUID playerId : game.getOpponents(source.getControllerId())) { if (!Objects.equals(playerId, damagedOpponent)) { diff --git a/Mage.Sets/src/mage/cards/g/GrevenPredatorCaptain.java b/Mage.Sets/src/mage/cards/g/GrevenPredatorCaptain.java index 5e4ff833ca6..90c3adf21af 100644 --- a/Mage.Sets/src/mage/cards/g/GrevenPredatorCaptain.java +++ b/Mage.Sets/src/mage/cards/g/GrevenPredatorCaptain.java @@ -113,7 +113,7 @@ class GrevenPredatorCaptainEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent( 0, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true ); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/g/GriftersBlade.java b/Mage.Sets/src/mage/cards/g/GriftersBlade.java index 75f145a2152..a65e8fe8600 100644 --- a/Mage.Sets/src/mage/cards/g/GriftersBlade.java +++ b/Mage.Sets/src/mage/cards/g/GriftersBlade.java @@ -80,7 +80,7 @@ class GriftersBladeChooseCreatureEffect extends OneShotEffect { if (controller != null && mageObject != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (controller.choose(this.outcome, target, source.getSourceId(), game)) { + if (controller.choose(this.outcome, target, source, game)) { Permanent attachToCreature = game.getPermanent(target.getFirstTarget()); if (attachToCreature != null) { attachToCreature.addAttachment(mageObject.getId(), source, game); diff --git a/Mage.Sets/src/mage/cards/g/GrimCaptainsCall.java b/Mage.Sets/src/mage/cards/g/GrimCaptainsCall.java index 93a422646f1..363b2ac7f2c 100644 --- a/Mage.Sets/src/mage/cards/g/GrimCaptainsCall.java +++ b/Mage.Sets/src/mage/cards/g/GrimCaptainsCall.java @@ -72,7 +72,7 @@ class GrimCaptainsCallEffect extends OneShotEffect { FilterCreatureCard filter = new FilterCreatureCard(subType.getDescription() + " card"); filter.add(subType.getPredicate()); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard(filter)); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { if (controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/g/GrimoireThief.java b/Mage.Sets/src/mage/cards/g/GrimoireThief.java index 04eaba460ad..201b6e2e16d 100644 --- a/Mage.Sets/src/mage/cards/g/GrimoireThief.java +++ b/Mage.Sets/src/mage/cards/g/GrimoireThief.java @@ -182,7 +182,7 @@ class GrimoireThiefCounterspellEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Cards cards = new CardsImpl(); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Set exileZones = (Set) game.getState().getValue( GrimoireThief.VALUE_PREFIX + source.getSourceId().toString()); if (exileZones != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/g/GripOfChaos.java b/Mage.Sets/src/mage/cards/g/GripOfChaos.java index 37665fb7bd7..1fa727907ff 100644 --- a/Mage.Sets/src/mage/cards/g/GripOfChaos.java +++ b/Mage.Sets/src/mage/cards/g/GripOfChaos.java @@ -15,7 +15,6 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.stack.StackObject; import mage.target.Target; import mage.target.targetpointer.FixedTarget; @@ -125,7 +124,7 @@ class GripOfChaosEffect extends OneShotEffect { Mode mode = stackObject.getStackAbility().getModes().get(modeId); for (Target target : mode.getTargets()) { UUID oldTargetId = target.getFirstTarget(); - Set possibleTargets = target.possibleTargets(stackObject.getSourceId(), stackObject.getControllerId(), game); + Set possibleTargets = target.possibleTargets(stackObject.getControllerId(), source, game); if (possibleTargets.contains(stackObject.getId())) { // The stackObject can't target itself possibleTargets.remove(stackObject.getId()); } diff --git a/Mage.Sets/src/mage/cards/g/GrizzledAngler.java b/Mage.Sets/src/mage/cards/g/GrizzledAngler.java index 3726aae9f96..59d3015cdc2 100644 --- a/Mage.Sets/src/mage/cards/g/GrizzledAngler.java +++ b/Mage.Sets/src/mage/cards/g/GrizzledAngler.java @@ -76,7 +76,7 @@ class GrizzledAnglerEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { controller.millCards(2, source, game); - if (controller.getGraveyard().count(filter, source.getSourceId(), source.getControllerId(), game) >= 1) { + if (controller.getGraveyard().count(filter, source.getControllerId(), source, game) >= 1) { return new TransformSourceEffect().apply(game, source); } } diff --git a/Mage.Sets/src/mage/cards/g/GruesomeMenagerie.java b/Mage.Sets/src/mage/cards/g/GruesomeMenagerie.java index d033c58cfae..586f9b41fa6 100644 --- a/Mage.Sets/src/mage/cards/g/GruesomeMenagerie.java +++ b/Mage.Sets/src/mage/cards/g/GruesomeMenagerie.java @@ -85,7 +85,7 @@ class GruesomeMenagerieEffect extends OneShotEffect { Target target; target = new TargetCardInYourGraveyard(filter1); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { cards.add(card); @@ -93,7 +93,7 @@ class GruesomeMenagerieEffect extends OneShotEffect { } target = new TargetCardInYourGraveyard(filter2); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { cards.add(card); @@ -101,7 +101,7 @@ class GruesomeMenagerieEffect extends OneShotEffect { } target = new TargetCardInYourGraveyard(filter3); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { cards.add(card); diff --git a/Mage.Sets/src/mage/cards/g/GuardDogs.java b/Mage.Sets/src/mage/cards/g/GuardDogs.java index 8c470c10fb4..3659e5dc4a3 100644 --- a/Mage.Sets/src/mage/cards/g/GuardDogs.java +++ b/Mage.Sets/src/mage/cards/g/GuardDogs.java @@ -69,7 +69,7 @@ class GuardDogsEffect extends PreventionEffectImpl { public void init(Ability source, Game game) { this.controlledTarget = new TargetControlledPermanent(); this.controlledTarget.setNotTarget(true); - this.controlledTarget.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.controlledTarget.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/g/GuardianProject.java b/Mage.Sets/src/mage/cards/g/GuardianProject.java index 27f3158c6cc..8807dc986ec 100644 --- a/Mage.Sets/src/mage/cards/g/GuardianProject.java +++ b/Mage.Sets/src/mage/cards/g/GuardianProject.java @@ -72,7 +72,7 @@ class GuardianProjectTriggeredAbility extends EntersBattlefieldAllTriggeredAbili @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); - if (!filter.match(permanent, sourceId, controllerId, game)) { + if (!filter.match(permanent, controllerId, this, game)) { return false; } diff --git a/Mage.Sets/src/mage/cards/g/GuidedPassage.java b/Mage.Sets/src/mage/cards/g/GuidedPassage.java index ee90202993f..f2af2b4f1ec 100644 --- a/Mage.Sets/src/mage/cards/g/GuidedPassage.java +++ b/Mage.Sets/src/mage/cards/g/GuidedPassage.java @@ -71,7 +71,7 @@ class GuidedPassageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/g/GuildSummit.java b/Mage.Sets/src/mage/cards/g/GuildSummit.java index d3b79f90809..271258213ba 100644 --- a/Mage.Sets/src/mage/cards/g/GuildSummit.java +++ b/Mage.Sets/src/mage/cards/g/GuildSummit.java @@ -81,7 +81,7 @@ class GuildSummitEffect extends OneShotEffect { int tappedAmount = 0; Player you = game.getPlayer(source.getControllerId()); TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), source, game)) { for (UUID creatureId : target.getTargets()) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { diff --git a/Mage.Sets/src/mage/cards/g/Gurzigost.java b/Mage.Sets/src/mage/cards/g/Gurzigost.java index a8782180369..8a2c0a46be8 100644 --- a/Mage.Sets/src/mage/cards/g/Gurzigost.java +++ b/Mage.Sets/src/mage/cards/g/Gurzigost.java @@ -77,7 +77,7 @@ class GurzigostCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), source, game)) { for (UUID targetId: targets.get(0).getTargets()) { Card card = game.getCard(targetId); if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) { @@ -93,7 +93,7 @@ class GurzigostCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/g/GusthasScepter.java b/Mage.Sets/src/mage/cards/g/GusthasScepter.java index ed64cf25dd3..633ff738d4f 100644 --- a/Mage.Sets/src/mage/cards/g/GusthasScepter.java +++ b/Mage.Sets/src/mage/cards/g/GusthasScepter.java @@ -117,10 +117,10 @@ class GusthasScepterReturnEffect extends OneShotEffect { } TargetCard target = new TargetCardInExile(filter, CardUtil.getExileZoneId(game, source)); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); return card != null && player.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java b/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java index 88f599718fc..a3eb3d82a3a 100644 --- a/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java +++ b/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java @@ -109,7 +109,7 @@ class GyrusWakerOfCorpsesPowerLessThanSourcePredicate implements ObjectSourcePla @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getPower().getValue() < sourcePermanent.getPower().getValue(); } diff --git a/Mage.Sets/src/mage/cards/h/HagraMauling.java b/Mage.Sets/src/mage/cards/h/HagraMauling.java index e0c1fd0a4ba..7041fbeb24b 100644 --- a/Mage.Sets/src/mage/cards/h/HagraMauling.java +++ b/Mage.Sets/src/mage/cards/h/HagraMauling.java @@ -86,7 +86,7 @@ enum HagraMaulingCondition implements Condition { public boolean apply(Game game, Ability source) { for (UUID playerId : game.getOpponents(source.getControllerId())) { Player player = game.getPlayer(playerId); - if (player != null && game.getBattlefield().count(filter, source.getSourceId(), playerId, game) == 0) { + if (player != null && game.getBattlefield().count(filter, playerId, source, game) == 0) { return true; } } diff --git a/Mage.Sets/src/mage/cards/h/HaktosTheUnscarred.java b/Mage.Sets/src/mage/cards/h/HaktosTheUnscarred.java index dd5a6e39c14..9d8380face6 100644 --- a/Mage.Sets/src/mage/cards/h/HaktosTheUnscarred.java +++ b/Mage.Sets/src/mage/cards/h/HaktosTheUnscarred.java @@ -106,7 +106,7 @@ enum HaktosTheUnscarredPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Object obj = game.getState().getValue(input.getSourceId() + "" + game.getState().getZoneChangeCounter(input.getSourceId()) + "_haktos_number"); + Object obj = game.getState().getValue(input.getSourceId() + "" + input.getSource().getSourceObjectZoneChangeCounter() + "_haktos_number"); if (!(obj instanceof Integer)) { return false; } diff --git a/Mage.Sets/src/mage/cards/h/HallowedBurial.java b/Mage.Sets/src/mage/cards/h/HallowedBurial.java index 84468903153..0ce0602ae9c 100644 --- a/Mage.Sets/src/mage/cards/h/HallowedBurial.java +++ b/Mage.Sets/src/mage/cards/h/HallowedBurial.java @@ -58,7 +58,7 @@ class HallowedBurialEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source, game)) { controller.moveCardToLibraryWithInfo(creature, source, game, Zone.BATTLEFIELD, false, true); } return true; diff --git a/Mage.Sets/src/mage/cards/h/HalvarGodOfBattle.java b/Mage.Sets/src/mage/cards/h/HalvarGodOfBattle.java index d2e1568137b..4c7a78f5516 100644 --- a/Mage.Sets/src/mage/cards/h/HalvarGodOfBattle.java +++ b/Mage.Sets/src/mage/cards/h/HalvarGodOfBattle.java @@ -193,7 +193,7 @@ class HalvarGodOfBattlePredicate implements ObjectSourcePlayerPredicate input, Game game) { UUID attachedTo = input.getObject().getAttachedTo(); Permanent permanent = game.getPermanent(attachedTo); - return permanent != null && filter.match(permanent, input.getSourceId(), input.getPlayerId(), game); + return permanent != null && filter.match(permanent, input.getPlayerId(), input.getSource(), game); } @Override diff --git a/Mage.Sets/src/mage/cards/h/HammerMage.java b/Mage.Sets/src/mage/cards/h/HammerMage.java index 43bbc3f775c..28517cfec32 100644 --- a/Mage.Sets/src/mage/cards/h/HammerMage.java +++ b/Mage.Sets/src/mage/cards/h/HammerMage.java @@ -71,7 +71,7 @@ class HammerMageEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { FilterArtifactPermanent filter = new FilterArtifactPermanent(); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1)); - for(Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for(Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.destroy(source, game, false); } return true; diff --git a/Mage.Sets/src/mage/cards/h/HandOfVecna.java b/Mage.Sets/src/mage/cards/h/HandOfVecna.java index cc4dcb9d483..e7a63d433c9 100644 --- a/Mage.Sets/src/mage/cards/h/HandOfVecna.java +++ b/Mage.Sets/src/mage/cards/h/HandOfVecna.java @@ -93,7 +93,7 @@ class HandOfVecnaEffect extends OneShotEffect { Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); Permanent equipped = game.getPermanent(sourcePermanent != null ? sourcePermanent.getAttachedTo() : null); List chooseable = game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ); if (equipped != null) { chooseable.add(equipped); @@ -115,7 +115,7 @@ class HandOfVecnaEffect extends OneShotEffect { )); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); toBoost = game.getPermanent(target.getFirstTarget()); } int xValue = player.getHand().size(); diff --git a/Mage.Sets/src/mage/cards/h/HandToHand.java b/Mage.Sets/src/mage/cards/h/HandToHand.java index 8592b589bbf..a16e107c437 100644 --- a/Mage.Sets/src/mage/cards/h/HandToHand.java +++ b/Mage.Sets/src/mage/cards/h/HandToHand.java @@ -60,7 +60,7 @@ class HandToHandEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "During combat, players can't cast instant spells or activate abilities that aren't mana abilities (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/h/HansEriksson.java b/Mage.Sets/src/mage/cards/h/HansEriksson.java index 8b9d8743c62..9ab3cfa6b5e 100644 --- a/Mage.Sets/src/mage/cards/h/HansEriksson.java +++ b/Mage.Sets/src/mage/cards/h/HansEriksson.java @@ -96,7 +96,7 @@ class HansErikssonEffect extends OneShotEffect { UUID defenderId; if (game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, - source.getSourceId(), defendingPlayerId, game + defendingPlayerId, source, game ) < 1) { defenderId = defendingPlayerId; } else { @@ -107,7 +107,7 @@ class HansErikssonEffect extends OneShotEffect { filter.getPermanentFilter().add(new ControllerIdPredicate(defendingPlayerId)); TargetPlayerOrPlaneswalker target = new TargetPlayerOrPlaneswalker(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); defenderId = target.getFirstTarget(); } if (defenderId != null) { diff --git a/Mage.Sets/src/mage/cards/h/HaphazardBombardment.java b/Mage.Sets/src/mage/cards/h/HaphazardBombardment.java index c47128fc40a..65df8af396f 100644 --- a/Mage.Sets/src/mage/cards/h/HaphazardBombardment.java +++ b/Mage.Sets/src/mage/cards/h/HaphazardBombardment.java @@ -79,7 +79,7 @@ class HaphazardBombardmentEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent("nonenchantment permanents you don't control"); filter.add(Predicates.not(CardType.ENCHANTMENT.getPredicate())); filter.add(TargetController.OPPONENT.getControllerPredicate()); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); if (permanents.size() > 4) { permanents.clear(); TargetPermanent target = new TargetPermanent(4, 4, filter, true); @@ -127,7 +127,7 @@ class HaphazardBombardmentEndOfTurnEffect extends OneShotEffect { filter.add(TargetController.NOT_YOU.getControllerPredicate()); filter.add(CounterType.AIM.getPredicate()); filter.add(Predicates.not(new AbilityPredicate(IndestructibleAbility.class))); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); if (!permanents.isEmpty()) { Permanent permanent = permanents.get(RandomUtil.nextInt(permanents.size())); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/h/HaraldUnitesTheElves.java b/Mage.Sets/src/mage/cards/h/HaraldUnitesTheElves.java index 0f3a8467b21..e27bf4964f5 100644 --- a/Mage.Sets/src/mage/cards/h/HaraldUnitesTheElves.java +++ b/Mage.Sets/src/mage/cards/h/HaraldUnitesTheElves.java @@ -105,7 +105,7 @@ class HaraldUnitesTheElvesEffect extends OneShotEffect { } player.millCards(3, source, game); TargetCard targetCard = new TargetCardInYourGraveyard(0, 1, filter, true); - player.choose(outcome, targetCard, source.getSourceId(), game); + player.choose(outcome, targetCard, source, game); Card card = player.getGraveyard().get(targetCard.getFirstTarget(), game); if (card != null) { player.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/h/HarborSerpent.java b/Mage.Sets/src/mage/cards/h/HarborSerpent.java index f2e1ed29835..2d1cef11242 100644 --- a/Mage.Sets/src/mage/cards/h/HarborSerpent.java +++ b/Mage.Sets/src/mage/cards/h/HarborSerpent.java @@ -73,6 +73,6 @@ class HarborSerpentEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { return permanent.getId().equals(source.getSourceId()) && - game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 5; + game.getBattlefield().count(filter, source.getControllerId(), source, game) < 5; } } diff --git a/Mage.Sets/src/mage/cards/h/HargildeKindlyRunechanter.java b/Mage.Sets/src/mage/cards/h/HargildeKindlyRunechanter.java index a850f611fd5..1b4e99a4c26 100644 --- a/Mage.Sets/src/mage/cards/h/HargildeKindlyRunechanter.java +++ b/Mage.Sets/src/mage/cards/h/HargildeKindlyRunechanter.java @@ -77,7 +77,7 @@ enum HargildeKindlyRunechanterCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isArtifact(game); } } diff --git a/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java b/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java index 95dccfa4bcd..77c94ecc327 100644 --- a/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java +++ b/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java @@ -64,7 +64,7 @@ class HarmonicConvergenceEffect extends OneShotEffect { FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent(); filter.add(new OwnerIdPredicate(player.getId())); Cards toLib = new CardsImpl(); - for(Permanent enchantment: game.getBattlefield().getActivePermanents(filter, playerId, source.getSourceId(), game)) { + for(Permanent enchantment: game.getBattlefield().getActivePermanents(filter, playerId, source, game)) { toLib.add(enchantment); } player.putCardsOnTopOfLibrary(toLib, game, source, true); diff --git a/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java b/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java index 8b65230b2e2..35480f08b4d 100644 --- a/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java +++ b/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java @@ -66,7 +66,7 @@ class HarmonyOfNatureEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, HarmonyOfNature.filter, true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); if (target.getTargets().isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/cards/h/HarmsWay.java b/Mage.Sets/src/mage/cards/h/HarmsWay.java index fc6ce082e3e..2925c2d5d46 100644 --- a/Mage.Sets/src/mage/cards/h/HarmsWay.java +++ b/Mage.Sets/src/mage/cards/h/HarmsWay.java @@ -63,7 +63,7 @@ class HarmsWayPreventDamageTargetEffect extends RedirectionEffect { @Override public void init(Ability source, Game game) { - this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/h/HarshJustice.java b/Mage.Sets/src/mage/cards/h/HarshJustice.java index bfe5fc9d6ed..e708178119c 100644 --- a/Mage.Sets/src/mage/cards/h/HarshJustice.java +++ b/Mage.Sets/src/mage/cards/h/HarshJustice.java @@ -122,7 +122,7 @@ class HarshJusticeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int damage = (Integer) this.getValue("damage"); UUID sourceId = (UUID) this.getValue("sourceId"); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && damage > 0 && sourceId != null) { Permanent targetObject = game.getPermanentOrLKIBattlefield(sourceId); if (targetObject != null) { diff --git a/Mage.Sets/src/mage/cards/h/HarshMercy.java b/Mage.Sets/src/mage/cards/h/HarshMercy.java index d953e915ce1..6b92aab46b3 100644 --- a/Mage.Sets/src/mage/cards/h/HarshMercy.java +++ b/Mage.Sets/src/mage/cards/h/HarshMercy.java @@ -63,7 +63,7 @@ class HarshMercyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Set chosenTypes = new HashSet<>(); PlayerIteration: diff --git a/Mage.Sets/src/mage/cards/h/HavenOfTheSpiritDragon.java b/Mage.Sets/src/mage/cards/h/HavenOfTheSpiritDragon.java index 5dc1de2f5ce..f7ad7b3c6a1 100644 --- a/Mage.Sets/src/mage/cards/h/HavenOfTheSpiritDragon.java +++ b/Mage.Sets/src/mage/cards/h/HavenOfTheSpiritDragon.java @@ -96,7 +96,7 @@ class HavenOfTheSpiritManaCondition extends CreatureCastManaCondition { @Override public boolean apply(Game game, Ability source, UUID manaProducer, Cost costToPay) { if (super.apply(game, source)) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.hasSubtype(SubType.DRAGON, game) && object.isCreature(game)) { return true; diff --git a/Mage.Sets/src/mage/cards/h/HazduhrTheAbbot.java b/Mage.Sets/src/mage/cards/h/HazduhrTheAbbot.java index 6cebc5701eb..e4e72630d2c 100644 --- a/Mage.Sets/src/mage/cards/h/HazduhrTheAbbot.java +++ b/Mage.Sets/src/mage/cards/h/HazduhrTheAbbot.java @@ -88,7 +88,7 @@ class HazduhrTheAbbotRedirectDamageEffect extends RedirectionEffect { public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { - if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { + if (filter.match(permanent, permanent.getControllerId(), source, game)) { if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { if (event.getTargetId() != null) { TargetPermanent target = new TargetPermanent(); diff --git a/Mage.Sets/src/mage/cards/h/HealingGrace.java b/Mage.Sets/src/mage/cards/h/HealingGrace.java index e692b74283f..beb6f4e7eda 100644 --- a/Mage.Sets/src/mage/cards/h/HealingGrace.java +++ b/Mage.Sets/src/mage/cards/h/HealingGrace.java @@ -62,7 +62,7 @@ class HealingGraceEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/h/HeartPiercerManticore.java b/Mage.Sets/src/mage/cards/h/HeartPiercerManticore.java index 0adb9947c01..4d7f1ac9977 100644 --- a/Mage.Sets/src/mage/cards/h/HeartPiercerManticore.java +++ b/Mage.Sets/src/mage/cards/h/HeartPiercerManticore.java @@ -78,7 +78,7 @@ class HeartPiercerManticoreSacrificeEffect extends OneShotEffect { Target target = new TargetControlledCreaturePermanent( 1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true ); - if (!controller.choose(outcome, target, source.getSourceId(), game)) { + if (!controller.choose(outcome, target, source, game)) { return false; } Permanent toSacrifice = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/h/HeatStroke.java b/Mage.Sets/src/mage/cards/h/HeatStroke.java index a24d538a28c..ee6d08fbd46 100644 --- a/Mage.Sets/src/mage/cards/h/HeatStroke.java +++ b/Mage.Sets/src/mage/cards/h/HeatStroke.java @@ -60,7 +60,7 @@ class HeatStrokeEffect extends OneShotEffect { BlockedThisTurnWatcher blockedWatcher = game.getState().getWatcher(BlockedThisTurnWatcher.class); WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = game.getState().getWatcher(WasBlockedThisTurnWatcher.class); - Set inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); + Set inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)); boolean toRet = false; Set toDestroy = new HashSet<>(); diff --git a/Mage.Sets/src/mage/cards/h/HeavenlyBlademaster.java b/Mage.Sets/src/mage/cards/h/HeavenlyBlademaster.java index 6f480568238..6c2063e8871 100644 --- a/Mage.Sets/src/mage/cards/h/HeavenlyBlademaster.java +++ b/Mage.Sets/src/mage/cards/h/HeavenlyBlademaster.java @@ -108,7 +108,7 @@ class HeavenlyBlademasterEffect extends OneShotEffect { return false; } Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } target.getTargets().stream().map( diff --git a/Mage.Sets/src/mage/cards/h/HedronAlignment.java b/Mage.Sets/src/mage/cards/h/HedronAlignment.java index 35ff43f0a60..2d2ed094628 100644 --- a/Mage.Sets/src/mage/cards/h/HedronAlignment.java +++ b/Mage.Sets/src/mage/cards/h/HedronAlignment.java @@ -87,15 +87,15 @@ class HedronAlignmentEffect extends OneShotEffect { if (!game.getBattlefield().contains(filterPermanent, source, game, 1)) { return true; } - if (controller.getHand().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) { + if (controller.getHand().getCards(filterCard, controller.getId(), source, game).isEmpty()) { return true; } - if (controller.getGraveyard().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) { + if (controller.getGraveyard().getCards(filterCard, controller.getId(), source, game).isEmpty()) { return true; } Cards cardsToCheck = new CardsImpl(); cardsToCheck.addAll(game.getExile().getAllCards(game)); - if (cardsToCheck.count(filterCard, source.getSourceId(), controller.getId(), game) == 0) { + if (cardsToCheck.count(filterCard, controller.getId(), source, game) == 0) { return true; } controller.won(game); diff --git a/Mage.Sets/src/mage/cards/h/HellcarverDemon.java b/Mage.Sets/src/mage/cards/h/HellcarverDemon.java index 696695154dd..3dc14d8aae0 100644 --- a/Mage.Sets/src/mage/cards/h/HellcarverDemon.java +++ b/Mage.Sets/src/mage/cards/h/HellcarverDemon.java @@ -72,7 +72,7 @@ class HellcarverDemonEffect extends OneShotEffect { MageObjectReference sourceMor = new MageObjectReference(source); for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (!sourceMor.refersTo(permanent, game)) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/h/HellkiteCourser.java b/Mage.Sets/src/mage/cards/h/HellkiteCourser.java index a0948290de0..1a67fd84e3b 100644 --- a/Mage.Sets/src/mage/cards/h/HellkiteCourser.java +++ b/Mage.Sets/src/mage/cards/h/HellkiteCourser.java @@ -84,7 +84,7 @@ class HellkiteCourserEffect extends OneShotEffect { } TargetCard target = new TargetCard(0, 1, Zone.COMMAND, filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/h/HellraiserGoblin.java b/Mage.Sets/src/mage/cards/h/HellraiserGoblin.java index 4a94d00f5d6..1e3c498e0b6 100644 --- a/Mage.Sets/src/mage/cards/h/HellraiserGoblin.java +++ b/Mage.Sets/src/mage/cards/h/HellraiserGoblin.java @@ -77,7 +77,7 @@ class AttacksIfAbleAllEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/h/HelmOfKaldra.java b/Mage.Sets/src/mage/cards/h/HelmOfKaldra.java index f48b62c8c02..80ce48c96b4 100644 --- a/Mage.Sets/src/mage/cards/h/HelmOfKaldra.java +++ b/Mage.Sets/src/mage/cards/h/HelmOfKaldra.java @@ -80,13 +80,13 @@ class HelmOfKaldraCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - if (game.getBattlefield().count(HelmOfKaldra.filterHelm, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(HelmOfKaldra.filterHelm, source.getControllerId(), source, game) < 1) { return false; } - if (game.getBattlefield().count(HelmOfKaldra.filterSword, source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(HelmOfKaldra.filterSword, source.getControllerId(), source, game) < 1) { return false; } - return game.getBattlefield().count(HelmOfKaldra.filterShield, source.getSourceId(), source.getControllerId(), game) >= 1; + return game.getBattlefield().count(HelmOfKaldra.filterShield, source.getControllerId(), source, game) >= 1; } } diff --git a/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java b/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java index 703f309f677..549d0b57c1e 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java +++ b/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java @@ -89,7 +89,7 @@ class HeraldOfLeshracCumulativeCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Target target = new TargetPermanent(filter); - if (target.choose(Outcome.GainControl, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.GainControl, controllerId, source.getSourceId(), source, game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame); effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game)); game.addEffect(effect, ability); @@ -101,7 +101,7 @@ class HeraldOfLeshracCumulativeCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return game.getBattlefield().contains(filter, source.getSourceId(), controllerId, game, 1); + return game.getBattlefield().contains(filter, source.getSourceId(), controllerId, source, game, 1); } @Override @@ -135,7 +135,7 @@ class HeraldOfLeshracLeavesEffect extends OneShotEffect { FilterPermanent filter = new FilterLandPermanent(); filter.add(new OwnerIdPredicate(playerId)); filter.add(new ControllerIdPredicate(source.getControllerId())); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, playerId); effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/h/HeraldicBanner.java b/Mage.Sets/src/mage/cards/h/HeraldicBanner.java index 4171169e3f8..07ea12d1f92 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldicBanner.java +++ b/Mage.Sets/src/mage/cards/h/HeraldicBanner.java @@ -74,7 +74,7 @@ class HeraldicBannerEffect extends ContinuousEffectImpl { return false; } for (Permanent perm : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source, game )) { if (perm.getColor(game).contains(color)) { perm.addPower(1); diff --git a/Mage.Sets/src/mage/cards/h/HeraldsHorn.java b/Mage.Sets/src/mage/cards/h/HeraldsHorn.java index 6ecea121edd..2a41716f9e2 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldsHorn.java +++ b/Mage.Sets/src/mage/cards/h/HeraldsHorn.java @@ -69,7 +69,7 @@ class HeraldsHornEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); // Look at the top card of your library. if (controller != null && controller.getLibrary().hasCards() && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/h/HeritageDruid.java b/Mage.Sets/src/mage/cards/h/HeritageDruid.java index 7f60c77c1a2..168bce74b79 100644 --- a/Mage.Sets/src/mage/cards/h/HeritageDruid.java +++ b/Mage.Sets/src/mage/cards/h/HeritageDruid.java @@ -75,7 +75,7 @@ class HeritageDruidManaEffect extends BasicManaEffect { @Override public List getNetMana(Game game, Ability source) { if (game != null && game.inCheckPlayableState()) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3; + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game) / 3; List netMana = new ArrayList<>(); if (count > 0) { netMana.add(Mana.GreenMana(count * 3)); diff --git a/Mage.Sets/src/mage/cards/h/HeroesPodium.java b/Mage.Sets/src/mage/cards/h/HeroesPodium.java index 1caa0258eca..c79f3eafbac 100644 --- a/Mage.Sets/src/mage/cards/h/HeroesPodium.java +++ b/Mage.Sets/src/mage/cards/h/HeroesPodium.java @@ -69,7 +69,7 @@ class HeroesPodiumLegendaryCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - int value = game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + int value = game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); if (value > 0) { value--; } diff --git a/Mage.Sets/src/mage/cards/h/HighcliffFelidar.java b/Mage.Sets/src/mage/cards/h/HighcliffFelidar.java index 50873c7db5b..2c5298546d1 100644 --- a/Mage.Sets/src/mage/cards/h/HighcliffFelidar.java +++ b/Mage.Sets/src/mage/cards/h/HighcliffFelidar.java @@ -101,7 +101,7 @@ class HighcliffFelidarEffect extends OneShotEffect { filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, maxPower)); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (controller.choose(outcome, target, source, game)) { toDestroy.add(target.getFirstTarget()); } } diff --git a/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java b/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java index 013d99f54d2..84d856df425 100644 --- a/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java +++ b/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java @@ -73,7 +73,7 @@ class HisokaMinamoSenseiDiscardTargetCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), source, game)) { Player player = game.getPlayer(controllerId); if(player != null) { for (UUID targetId : targets.get(0).getTargets()) { @@ -91,7 +91,7 @@ class HisokaMinamoSenseiDiscardTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/h/HistoriansWisdom.java b/Mage.Sets/src/mage/cards/h/HistoriansWisdom.java index 540838ad4eb..263e8b5bd6b 100644 --- a/Mage.Sets/src/mage/cards/h/HistoriansWisdom.java +++ b/Mage.Sets/src/mage/cards/h/HistoriansWisdom.java @@ -89,6 +89,6 @@ enum HistoriansWisdomCondition implements Condition { } FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new PowerPredicate(ComparisonType.MORE_THAN, creature.getPower().getValue())); - return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).isEmpty(); + return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).isEmpty(); } } diff --git a/Mage.Sets/src/mage/cards/h/HitRun.java b/Mage.Sets/src/mage/cards/h/HitRun.java index 33924e502d9..c6ec92b5745 100644 --- a/Mage.Sets/src/mage/cards/h/HitRun.java +++ b/Mage.Sets/src/mage/cards/h/HitRun.java @@ -77,8 +77,8 @@ class HitEffect extends OneShotEffect { CardType.CREATURE.getPredicate())); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), targetPlayer.getId(), game)) { - targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(targetPlayer.getId(), source, game)) { + targetPlayer.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); @@ -113,7 +113,7 @@ class RunEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int attackingCreatures = game.getBattlefield().count(new FilterAttackingCreature(), controller.getId(), controller.getId(), game); + int attackingCreatures = game.getBattlefield().count(new FilterAttackingCreature(), controller.getId(), source, game); if (attackingCreatures > 1) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(), controller.getId(), game)) { ContinuousEffect effect = new BoostTargetEffect(attackingCreatures - 1, 0, Duration.EndOfTurn); diff --git a/Mage.Sets/src/mage/cards/h/HiveheartShaman.java b/Mage.Sets/src/mage/cards/h/HiveheartShaman.java index a6e5ecb11be..f0190fa0308 100644 --- a/Mage.Sets/src/mage/cards/h/HiveheartShaman.java +++ b/Mage.Sets/src/mage/cards/h/HiveheartShaman.java @@ -82,7 +82,7 @@ enum HiveheartShamanPredicate implements ObjectSourcePlayerPredicate { return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - input.getPlayerId(), input.getSourceId(), game + input.getPlayerId(), input.getSource(), game ) .stream() .map(permanent -> permanent.getSubtype(game)) diff --git a/Mage.Sets/src/mage/cards/h/HoodedBlightfang.java b/Mage.Sets/src/mage/cards/h/HoodedBlightfang.java index f0dc0bfeeed..175fb6c960c 100644 --- a/Mage.Sets/src/mage/cards/h/HoodedBlightfang.java +++ b/Mage.Sets/src/mage/cards/h/HoodedBlightfang.java @@ -88,7 +88,7 @@ class HoodedBlightfangTriggeredAbility extends TriggeredAbilityImpl { if (permanent == null || damaged == null || !StaticFilters.FILTER_PERMANENT_PLANESWALKER.match(damaged, game) - || !HoodedBlightfang.filter.match(permanent, this.getSourceId(), this.getControllerId(), game)) { + || !HoodedBlightfang.filter.match(permanent, this.getControllerId(), this, game)) { return false; } this.getEffects().setTargetPointer(new FixedTarget(damaged.getId(), damaged.getZoneChangeCounter(game))); diff --git a/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java b/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java index adb93334408..fe028e533f9 100644 --- a/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java +++ b/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java @@ -54,7 +54,7 @@ class HumOfTheRadixCostIncreaseEffect extends CostModificationEffectImpl { public boolean apply(Game game, Ability source, Ability abilityToModify) { CardUtil.increaseCost(abilityToModify, game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, - abilityToModify.getControllerId(), source.getSourceId(), game + abilityToModify.getControllerId(), source, game ).size()); return true; } diff --git a/Mage.Sets/src/mage/cards/h/Humiliate.java b/Mage.Sets/src/mage/cards/h/Humiliate.java index b372d5f2302..4e0730d49d0 100644 --- a/Mage.Sets/src/mage/cards/h/Humiliate.java +++ b/Mage.Sets/src/mage/cards/h/Humiliate.java @@ -66,14 +66,14 @@ class HumiliateEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ) < 1) { return false; } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); target.withChooseHint("+1/+1 counter"); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); return permanent != null && permanent.addCounters( CounterType.P1P1.createInstance(), source.getControllerId(), source, game diff --git a/Mage.Sets/src/mage/cards/h/Humility.java b/Mage.Sets/src/mage/cards/h/Humility.java index f936d256fd6..5018b6122f5 100644 --- a/Mage.Sets/src/mage/cards/h/Humility.java +++ b/Mage.Sets/src/mage/cards/h/Humility.java @@ -62,7 +62,7 @@ public final class Humility extends CardImpl { Player player = game.getPlayer(source.getControllerId()); if (player != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { + new FilterCreaturePermanent(), source.getControllerId(), source, game)) { switch (layer) { case AbilityAddingRemovingEffects_6: permanent.removeAllAbilities(source.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/h/HuntedNightmare.java b/Mage.Sets/src/mage/cards/h/HuntedNightmare.java index ab2e8d9a12f..726a64e530e 100644 --- a/Mage.Sets/src/mage/cards/h/HuntedNightmare.java +++ b/Mage.Sets/src/mage/cards/h/HuntedNightmare.java @@ -78,7 +78,7 @@ class HuntedNightmareEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); return permanent != null && permanent.addCounters(CounterType.DEATHTOUCH.createInstance(), player.getId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/h/Hushbringer.java b/Mage.Sets/src/mage/cards/h/Hushbringer.java index 868fbef763c..db685204da7 100644 --- a/Mage.Sets/src/mage/cards/h/Hushbringer.java +++ b/Mage.Sets/src/mage/cards/h/Hushbringer.java @@ -99,7 +99,7 @@ class HushbringerEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject enteringObject = game.getObject(event.getSourceId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Ability ability = (Ability) getValue("targetAbility"); if (enteringObject == null || sourceObject == null || ability == null) { return null; diff --git a/Mage.Sets/src/mage/cards/h/HushwingGryff.java b/Mage.Sets/src/mage/cards/h/HushwingGryff.java index 6dacad7ea24..8b3bc1ca75b 100644 --- a/Mage.Sets/src/mage/cards/h/HushwingGryff.java +++ b/Mage.Sets/src/mage/cards/h/HushwingGryff.java @@ -68,7 +68,7 @@ class HushwingGryffEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject enteringObject = game.getObject(event.getSourceId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Ability ability = (Ability) getValue("targetAbility"); if (enteringObject != null && sourceObject != null && ability != null) { MageObject abilitObject = game.getObject(ability.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/h/HydraOmnivore.java b/Mage.Sets/src/mage/cards/h/HydraOmnivore.java index 4042b708962..fa7ad52ecfd 100644 --- a/Mage.Sets/src/mage/cards/h/HydraOmnivore.java +++ b/Mage.Sets/src/mage/cards/h/HydraOmnivore.java @@ -62,7 +62,7 @@ class HydraOmnivoreEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { UUID damagedOpponent = this.getTargetPointer().getFirst(game, source); int amount = (Integer) getValue("damage"); - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && amount > 0 && damagedOpponent != null) { for (UUID playerId : game.getOpponents(source.getControllerId())) { if (!Objects.equals(playerId, damagedOpponent)) { diff --git a/Mage.Sets/src/mage/cards/h/Hypergenesis.java b/Mage.Sets/src/mage/cards/h/Hypergenesis.java index c687e3fcbee..ef05c0ad68a 100644 --- a/Mage.Sets/src/mage/cards/h/Hypergenesis.java +++ b/Mage.Sets/src/mage/cards/h/Hypergenesis.java @@ -88,7 +88,7 @@ class HypergenesisEffect extends OneShotEffect { firstInactivePlayer = currentPlayer.getId(); } target.clearChosen(); - if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game) + if (target.canChoose(currentPlayer.getId(), source, game) && currentPlayer.chooseUse(outcome, "Put card from your hand to play?", source, game)) { if (target.chooseTarget(outcome, currentPlayer.getId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/i/IceCauldron.java b/Mage.Sets/src/mage/cards/i/IceCauldron.java index 30f5a15f066..7971da9c264 100644 --- a/Mage.Sets/src/mage/cards/i/IceCauldron.java +++ b/Mage.Sets/src/mage/cards/i/IceCauldron.java @@ -98,7 +98,7 @@ class IceCauldronExileEffect extends OneShotEffect { TargetCard target = new TargetCard(Zone.HAND, filter); target.setNotTarget(true); Card chosenCard = null; - if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Benefit, target, source, game)) { chosenCard = controller.getHand().get(target.getFirstTarget(), game); } if (chosenCard != null) { diff --git a/Mage.Sets/src/mage/cards/i/IcebreakerKraken.java b/Mage.Sets/src/mage/cards/i/IcebreakerKraken.java index dcd18091a4b..908536028f4 100644 --- a/Mage.Sets/src/mage/cards/i/IcebreakerKraken.java +++ b/Mage.Sets/src/mage/cards/i/IcebreakerKraken.java @@ -98,7 +98,7 @@ class IcebreakerKrakenEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE, - source.getFirstTarget(), source.getControllerId(), game + source.getFirstTarget(), source, game )) { if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/i/IgnitionTeam.java b/Mage.Sets/src/mage/cards/i/IgnitionTeam.java index 7714d69baa2..9027cf29265 100644 --- a/Mage.Sets/src/mage/cards/i/IgnitionTeam.java +++ b/Mage.Sets/src/mage/cards/i/IgnitionTeam.java @@ -72,7 +72,7 @@ class TappedLandsCount implements DynamicValue { if (sourceAbility != null) { FilterLandPermanent filter = new FilterLandPermanent("tapped lands on the battlefield"); filter.add(TappedPredicate.TAPPED); - return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } return 0; } diff --git a/Mage.Sets/src/mage/cards/i/IllGottenGains.java b/Mage.Sets/src/mage/cards/i/IllGottenGains.java index 707325a27c7..fbd2081849c 100644 --- a/Mage.Sets/src/mage/cards/i/IllGottenGains.java +++ b/Mage.Sets/src/mage/cards/i/IllGottenGains.java @@ -71,7 +71,7 @@ class IllGottenGainsEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { Target target = new TargetCardInYourGraveyard(0, 3, new FilterCard()); - if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), source, game)) { player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/i/IlluminatedFolio.java b/Mage.Sets/src/mage/cards/i/IlluminatedFolio.java index 8a1073e8ad8..53337be7ab0 100644 --- a/Mage.Sets/src/mage/cards/i/IlluminatedFolio.java +++ b/Mage.Sets/src/mage/cards/i/IlluminatedFolio.java @@ -11,7 +11,6 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; import mage.constants.CardType; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; @@ -68,14 +67,14 @@ class IlluminatedFolioTarget extends TargetCardInHand { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - return super.canChoose(sourceId, sourceControllerId, game) - && !possibleTargets(sourceId,sourceControllerId, game).isEmpty(); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + return super.canChoose(sourceControllerId, source, game) + && !possibleTargets(sourceControllerId, source, game).isEmpty(); } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId,sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); if (this.getTargets().size() == 1) { Card card = game.getCard(this.getTargets().get(0)); possibleTargets.removeIf( diff --git a/Mage.Sets/src/mage/cards/i/IllusionaryPresence.java b/Mage.Sets/src/mage/cards/i/IllusionaryPresence.java index cd3b943c7f9..6f47376227d 100644 --- a/Mage.Sets/src/mage/cards/i/IllusionaryPresence.java +++ b/Mage.Sets/src/mage/cards/i/IllusionaryPresence.java @@ -78,7 +78,7 @@ class IllusionaryPresenceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { SubType landTypeChoice = SubType.byDescription((String) game.getState().getValue(mageObject.getId().toString() + "BasicLandType")); if (landTypeChoice != null) { diff --git a/Mage.Sets/src/mage/cards/i/IllusionaryTerrain.java b/Mage.Sets/src/mage/cards/i/IllusionaryTerrain.java index ef07e66981f..88cd2c1d18e 100644 --- a/Mage.Sets/src/mage/cards/i/IllusionaryTerrain.java +++ b/Mage.Sets/src/mage/cards/i/IllusionaryTerrain.java @@ -155,7 +155,7 @@ class ChooseTwoBasicLandTypesEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { diff --git a/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java b/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java index 682dbb69c20..cb5500d50f9 100644 --- a/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java +++ b/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java @@ -74,7 +74,7 @@ class ImmaculateMagistrateEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (count > 0) { permanent.addCounters(CounterType.P1P1.createInstance(count), source.getControllerId(), source, game); return true; diff --git a/Mage.Sets/src/mage/cards/i/ImmortalCoil.java b/Mage.Sets/src/mage/cards/i/ImmortalCoil.java index 1e2338d203f..6f9cb5623c7 100644 --- a/Mage.Sets/src/mage/cards/i/ImmortalCoil.java +++ b/Mage.Sets/src/mage/cards/i/ImmortalCoil.java @@ -118,7 +118,7 @@ class ImmortalCoilPreventionEffect extends PreventionEffectImpl { if (player != null) { TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(Math.min(damage, player.getGraveyard().size()), StaticFilters.FILTER_CARD); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); player.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game); } event.setAmount(0); diff --git a/Mage.Sets/src/mage/cards/i/ImpelledGiant.java b/Mage.Sets/src/mage/cards/i/ImpelledGiant.java index a6d6885dd09..11772f68b11 100644 --- a/Mage.Sets/src/mage/cards/i/ImpelledGiant.java +++ b/Mage.Sets/src/mage/cards/i/ImpelledGiant.java @@ -83,7 +83,7 @@ class ImpelledGiantCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { @@ -100,7 +100,7 @@ class ImpelledGiantCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/i/ImpendingDisaster.java b/Mage.Sets/src/mage/cards/i/ImpendingDisaster.java index 60eef97cc75..cd3ef30dec0 100644 --- a/Mage.Sets/src/mage/cards/i/ImpendingDisaster.java +++ b/Mage.Sets/src/mage/cards/i/ImpendingDisaster.java @@ -48,7 +48,7 @@ public final class ImpendingDisaster extends CardImpl { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().count(new FilterLandPermanent(), source.getSourceId(), source.getControllerId(), game) >= 7; + return game.getBattlefield().count(new FilterLandPermanent(), source.getControllerId(), source, game) >= 7; } } } diff --git a/Mage.Sets/src/mage/cards/i/ImperialEdict.java b/Mage.Sets/src/mage/cards/i/ImperialEdict.java index a0385149646..4380a201a29 100644 --- a/Mage.Sets/src/mage/cards/i/ImperialEdict.java +++ b/Mage.Sets/src/mage/cards/i/ImperialEdict.java @@ -66,8 +66,8 @@ class ImperialEdictEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); filter.add(new ControllerIdPredicate(player.getId())); Target target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) { + if (target.canChoose(player.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(player.getId(), source, game) && player.canRespond()) { player.chooseTarget(Outcome.DestroyPermanent, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/i/ImpetuousProtege.java b/Mage.Sets/src/mage/cards/i/ImpetuousProtege.java index 5a33ae46571..e7059b86a70 100644 --- a/Mage.Sets/src/mage/cards/i/ImpetuousProtege.java +++ b/Mage.Sets/src/mage/cards/i/ImpetuousProtege.java @@ -77,7 +77,7 @@ class ImpetuousProtegeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int maxPower = 0; - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { maxPower = Math.max(maxPower, creature.getPower().getValue()); } game.addEffect(new BoostSourceEffect(maxPower, 0, Duration.EndOfTurn), source); diff --git a/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java b/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java index eac63ee6692..f99d57e6bb1 100644 --- a/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java +++ b/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java @@ -78,14 +78,14 @@ class ImpromptuRaidEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Card card = controller.getLibrary().getFromTop(game); if (card != null) { Cards cards = new CardsImpl(); cards.add(card); controller.revealCards(sourceObject.getName(), cards, game); - if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) { + if (filterPutInGraveyard.match(card, source.getControllerId(), source, game)) { controller.moveCards(card, Zone.GRAVEYARD, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/i/InameAsOne.java b/Mage.Sets/src/mage/cards/i/InameAsOne.java index 9df76aa7fdf..534465cba2b 100644 --- a/Mage.Sets/src/mage/cards/i/InameAsOne.java +++ b/Mage.Sets/src/mage/cards/i/InameAsOne.java @@ -90,7 +90,7 @@ class InameAsOneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Card targetCard = game.getCard(getTargetPointer().getFirst(game, source)); if (controller != null && sourceObject != null && targetCard != null) { if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit card?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/i/InameLifeAspect.java b/Mage.Sets/src/mage/cards/i/InameLifeAspect.java index e5450bcb15c..79e7c52b9f1 100644 --- a/Mage.Sets/src/mage/cards/i/InameLifeAspect.java +++ b/Mage.Sets/src/mage/cards/i/InameLifeAspect.java @@ -76,7 +76,7 @@ class InameLifeAspectEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit cards?", source, game)) { Effect effect = new ReturnToHandTargetEffect(); diff --git a/Mage.Sets/src/mage/cards/i/IncandescentSoulstoke.java b/Mage.Sets/src/mage/cards/i/IncandescentSoulstoke.java index 2aa5999d909..eb03b377ad9 100644 --- a/Mage.Sets/src/mage/cards/i/IncandescentSoulstoke.java +++ b/Mage.Sets/src/mage/cards/i/IncandescentSoulstoke.java @@ -93,7 +93,7 @@ class IncandescentSoulstokeEffect extends OneShotEffect { FilterCard filter = new FilterCreatureCard(); filter.add(SubType.ELEMENTAL.getPredicate()); TargetCardInHand target = new TargetCardInHand(filter); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { diff --git a/Mage.Sets/src/mage/cards/i/IncarnationTechnique.java b/Mage.Sets/src/mage/cards/i/IncarnationTechnique.java index 3834d8b8aa6..20cf455002f 100644 --- a/Mage.Sets/src/mage/cards/i/IncarnationTechnique.java +++ b/Mage.Sets/src/mage/cards/i/IncarnationTechnique.java @@ -67,10 +67,10 @@ class IncarnationTechniqueEffect extends OneShotEffect { player.millCards(5, source, game); TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return true; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { player.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/i/InciteHysteria.java b/Mage.Sets/src/mage/cards/i/InciteHysteria.java index c8458ed25ee..faa103baec5 100644 --- a/Mage.Sets/src/mage/cards/i/InciteHysteria.java +++ b/Mage.Sets/src/mage/cards/i/InciteHysteria.java @@ -69,7 +69,7 @@ class InciteHysteriaEffect extends OneShotEffect { Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); if (target != null) { ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (permanent.getColor(game).shares(color)) { ContinuousEffect effect = new GainAbilityTargetEffect(new CantBlockAbility(), Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/i/IncubationDruid.java b/Mage.Sets/src/mage/cards/i/IncubationDruid.java index 9fbb7f8f404..0bc69a192da 100644 --- a/Mage.Sets/src/mage/cards/i/IncubationDruid.java +++ b/Mage.Sets/src/mage/cards/i/IncubationDruid.java @@ -195,7 +195,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect { return types; } inManaTypeCalculation = true; - List lands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, source.getControllerId(), source.getSourceId(), game); + List lands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, source.getControllerId(), source, game); for (Permanent land : lands) { Abilities mana = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD); for (ActivatedManaAbilityImpl ability : mana) { diff --git a/Mage.Sets/src/mage/cards/i/InfernalDenizen.java b/Mage.Sets/src/mage/cards/i/InfernalDenizen.java index c5d0fd92572..55af6908f0c 100644 --- a/Mage.Sets/src/mage/cards/i/InfernalDenizen.java +++ b/Mage.Sets/src/mage/cards/i/InfernalDenizen.java @@ -108,15 +108,15 @@ class InfernalDenizenEffect extends OneShotEffect { creature.tap(source, game); } TargetOpponent targetOpp = new TargetOpponent(true); - if (targetOpp.canChoose(source.getSourceId(), player.getId(), game) - && targetOpp.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) { + if (targetOpp.canChoose(player.getId(), source, game) + && targetOpp.choose(Outcome.Detriment, player.getId(), source.getSourceId(), source, game)) { Player opponent = game.getPlayer(targetOpp.getFirstTarget()); if (opponent != null) { FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature controlled by " + player.getLogName()); filter2.add(new ControllerIdPredicate(player.getId())); TargetCreaturePermanent targetCreature = new TargetCreaturePermanent(1, 1, filter2, true); targetCreature.setTargetController(opponent.getId()); - if (targetCreature.canChoose(source.getSourceId(), id, game) + if (targetCreature.canChoose(id, source, game) && opponent.chooseUse(Outcome.GainControl, "Gain control of a creature?", source, game) && opponent.chooseTarget(Outcome.GainControl, targetCreature, source, game)) { ConditionalContinuousEffect giveEffect = new ConditionalContinuousEffect( diff --git a/Mage.Sets/src/mage/cards/i/InfernalHarvest.java b/Mage.Sets/src/mage/cards/i/InfernalHarvest.java index 28a3e0ce38a..2133d76aeac 100644 --- a/Mage.Sets/src/mage/cards/i/InfernalHarvest.java +++ b/Mage.Sets/src/mage/cards/i/InfernalHarvest.java @@ -106,7 +106,7 @@ class InfernalHarvestAdditionalCost extends VariableCostImpl { return false; } Player player = game.getPlayer(controllerId); - if (player == null || !targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) { + if (player == null || !targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), source, game)) { return false; } return paid = player.moveCards( diff --git a/Mage.Sets/src/mage/cards/i/InfernalOffering.java b/Mage.Sets/src/mage/cards/i/InfernalOffering.java index 210eb5926ea..57b779d2c1a 100644 --- a/Mage.Sets/src/mage/cards/i/InfernalOffering.java +++ b/Mage.Sets/src/mage/cards/i/InfernalOffering.java @@ -72,7 +72,7 @@ class InfernalOfferingSacrificeEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Target target = new TargetOpponent(true); - target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { //Choose creatures to sacrifice @@ -80,7 +80,7 @@ class InfernalOfferingSacrificeEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) { if (playerId.equals(player.getId()) || playerId.equals(opponent.getId())) { target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true); - if (target.choose(Outcome.Sacrifice, playerId, source.getControllerId(), game)) { + if (target.choose(Outcome.Sacrifice, playerId, source.getControllerId(), source, game)) { toSacrifice.put(playerId, target.getFirstTarget()); } } @@ -130,10 +130,10 @@ class InfernalOfferingReturnEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetOpponent(true); - target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(target.getFirstTarget()); target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard")); - if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), source, game)) { Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); @@ -141,7 +141,7 @@ class InfernalOfferingReturnEffect extends OneShotEffect { } if (opponent != null) { target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard")); - if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), source, game)) { Card card = opponent.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { opponent.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/i/InfernalTutor.java b/Mage.Sets/src/mage/cards/i/InfernalTutor.java index 489b25114ad..1b7f4d8d2b9 100644 --- a/Mage.Sets/src/mage/cards/i/InfernalTutor.java +++ b/Mage.Sets/src/mage/cards/i/InfernalTutor.java @@ -73,7 +73,7 @@ class InfernalTutorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (!controller.getHand().isEmpty()) { Card cardToReveal = null; diff --git a/Mage.Sets/src/mage/cards/i/InfiltratorsMagemark.java b/Mage.Sets/src/mage/cards/i/InfiltratorsMagemark.java index 7fb640f4b0d..f97afd7e261 100644 --- a/Mage.Sets/src/mage/cards/i/InfiltratorsMagemark.java +++ b/Mage.Sets/src/mage/cards/i/InfiltratorsMagemark.java @@ -88,6 +88,6 @@ class InfiltratorsMagemarkCantBeBlockedAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/i/InkTreaderNephilim.java b/Mage.Sets/src/mage/cards/i/InkTreaderNephilim.java index ff0a225da3b..9f584c8820d 100644 --- a/Mage.Sets/src/mage/cards/i/InkTreaderNephilim.java +++ b/Mage.Sets/src/mage/cards/i/InkTreaderNephilim.java @@ -138,7 +138,7 @@ class InkTreaderNephilimEffect extends CopySpellForEachItCouldTargetEffect { return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_PERMANENT_CREATURE, - player.getId(), source.getSourceId(), game + player.getId(), source, game ).stream() .filter(Objects::nonNull) .filter(p -> !p.equals(permanent)) diff --git a/Mage.Sets/src/mage/cards/i/InniazTheGaleForce.java b/Mage.Sets/src/mage/cards/i/InniazTheGaleForce.java index 3562ec3dc75..c4bb03519b6 100644 --- a/Mage.Sets/src/mage/cards/i/InniazTheGaleForce.java +++ b/Mage.Sets/src/mage/cards/i/InniazTheGaleForce.java @@ -107,8 +107,8 @@ class InniazTheGaleForceEffect extends OneShotEffect { } private void chooseTargets(Player controller, Game game, Ability source) { - if (game.getBattlefield().count(this.filter, source.getSourceId(), source.getControllerId(), game) > 0) { - controller.choose(Outcome.Neutral, this.target, source.getSourceId(), game); + if (game.getBattlefield().count(this.filter, source.getControllerId(), source, game) > 0) { + controller.choose(Outcome.Neutral, this.target, source, game); } } diff --git a/Mage.Sets/src/mage/cards/i/InnocentTraveler.java b/Mage.Sets/src/mage/cards/i/InnocentTraveler.java index 8e6d2edf044..aa66ac6579a 100644 --- a/Mage.Sets/src/mage/cards/i/InnocentTraveler.java +++ b/Mage.Sets/src/mage/cards/i/InnocentTraveler.java @@ -79,9 +79,9 @@ class InnocentTravelerEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), opponent.getId(), game) + if (!target.canChoose(opponent.getId(), source, game) || !opponent.chooseUse(Outcome.AIDontUseIt, "Sacrifice a creature?", source, game) - || !opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + || !opponent.choose(Outcome.Sacrifice, target, source, game)) { continue; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/i/Inquisition.java b/Mage.Sets/src/mage/cards/i/Inquisition.java index 4808dec5034..be89d3d9ba0 100644 --- a/Mage.Sets/src/mage/cards/i/Inquisition.java +++ b/Mage.Sets/src/mage/cards/i/Inquisition.java @@ -60,7 +60,7 @@ class InquisitionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer != null) { diff --git a/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java b/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java index 017823e60f2..2a3c340f495 100644 --- a/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java +++ b/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java @@ -89,7 +89,7 @@ class InscriptionOfAbundanceEffect extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getFirstTarget(), source.getSourceId(), game + source.getFirstTarget(), source, game ).stream() .filter(Objects::nonNull) .map(MageObject::getPower) diff --git a/Mage.Sets/src/mage/cards/i/Insist.java b/Mage.Sets/src/mage/cards/i/Insist.java index 68bc2c45084..4be52a9113d 100644 --- a/Mage.Sets/src/mage/cards/i/Insist.java +++ b/Mage.Sets/src/mage/cards/i/Insist.java @@ -78,7 +78,7 @@ class InsistEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This spell can't be countered (" + sourceObject.getName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/i/IntellectualOffering.java b/Mage.Sets/src/mage/cards/i/IntellectualOffering.java index 4bb7af53ada..3be2950e05d 100644 --- a/Mage.Sets/src/mage/cards/i/IntellectualOffering.java +++ b/Mage.Sets/src/mage/cards/i/IntellectualOffering.java @@ -63,7 +63,7 @@ class IntellectualOfferingDrawEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Target target = new TargetOpponent(true); - target.choose(Outcome.DrawCard, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.DrawCard, source.getControllerId(), source.getSourceId(), source, game); player.drawCards(3, source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { @@ -96,7 +96,7 @@ class IntellectualOfferingUntapEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Target target = new TargetOpponent(true); - target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), source, game); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterNonlandPermanent(), player.getId(), game)) { permanent.untap(game); } diff --git a/Mage.Sets/src/mage/cards/i/InvokeDespair.java b/Mage.Sets/src/mage/cards/i/InvokeDespair.java index edfc786b31c..99ca02842ac 100644 --- a/Mage.Sets/src/mage/cards/i/InvokeDespair.java +++ b/Mage.Sets/src/mage/cards/i/InvokeDespair.java @@ -69,7 +69,7 @@ class InvokeDespairEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - opponent.choose(outcome, target, source.getSourceId(), game); + opponent.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); boolean sacrificed = false; if (permanent != null) { @@ -81,7 +81,7 @@ class InvokeDespairEffect extends OneShotEffect { } target = new TargetControlledPermanent(enchantmentFilter); target.setNotTarget(true); - opponent.choose(outcome, target, source.getSourceId(), game); + opponent.choose(outcome, target, source, game); permanent = game.getPermanent(target.getFirstTarget()); sacrificed = false; if (permanent != null) { @@ -93,7 +93,7 @@ class InvokeDespairEffect extends OneShotEffect { } target = new TargetControlledPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER); target.setNotTarget(true); - opponent.choose(outcome, target, source.getSourceId(), game); + opponent.choose(outcome, target, source, game); permanent = game.getPermanent(target.getFirstTarget()); sacrificed = false; if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/i/InvokeJustice.java b/Mage.Sets/src/mage/cards/i/InvokeJustice.java index de8a604f78e..9662a047a43 100644 --- a/Mage.Sets/src/mage/cards/i/InvokeJustice.java +++ b/Mage.Sets/src/mage/cards/i/InvokeJustice.java @@ -84,7 +84,7 @@ class InvokeJusticeEffect extends OneShotEffect { } TargetAmount target = new TargetPermanentAmount(4, filter); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/i/IonaShieldOfEmeria.java b/Mage.Sets/src/mage/cards/i/IonaShieldOfEmeria.java index 34c419fefaa..5866ece3a74 100644 --- a/Mage.Sets/src/mage/cards/i/IonaShieldOfEmeria.java +++ b/Mage.Sets/src/mage/cards/i/IonaShieldOfEmeria.java @@ -67,7 +67,7 @@ class IonaShieldOfEmeriaReplacementEffect extends ContinuousRuleModifyingEffectI @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null && chosenColor != null) { return "You can't cast " + chosenColor.toString() + " spells (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/i/IsochronScepter.java b/Mage.Sets/src/mage/cards/i/IsochronScepter.java index 5237a6c8cb5..dc454a3b565 100644 --- a/Mage.Sets/src/mage/cards/i/IsochronScepter.java +++ b/Mage.Sets/src/mage/cards/i/IsochronScepter.java @@ -80,7 +80,7 @@ class IsochronScepterImprintEffect extends OneShotEffect { if (controller != null) { if (!controller.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.choose(Outcome.Benefit, controller.getHand(), target, game)) { Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/i/IwamoriOfTheOpenFist.java b/Mage.Sets/src/mage/cards/i/IwamoriOfTheOpenFist.java index d20131802f3..b4d0ed82e34 100644 --- a/Mage.Sets/src/mage/cards/i/IwamoriOfTheOpenFist.java +++ b/Mage.Sets/src/mage/cards/i/IwamoriOfTheOpenFist.java @@ -81,7 +81,7 @@ class IwamoriOfTheOpenFistEffect extends OneShotEffect { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); Target target = new TargetCardInHand(filter); - if (opponent != null && target.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (opponent != null && target.canChoose(opponent.getId(), source, game)) { if (opponent.chooseUse(Outcome.PutCreatureInPlay, "Put a legendary creature card from your hand onto the battlefield?", source, game)) { if (target.chooseTarget(Outcome.PutCreatureInPlay, opponent.getId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/i/IzzetStaticaster.java b/Mage.Sets/src/mage/cards/i/IzzetStaticaster.java index 163a71b6350..65a4ff8fe6b 100644 --- a/Mage.Sets/src/mage/cards/i/IzzetStaticaster.java +++ b/Mage.Sets/src/mage/cards/i/IzzetStaticaster.java @@ -84,7 +84,7 @@ class IzzetStaticasterDamageEffect extends OneShotEffect { } else { filter.add(new NamePredicate(targetPermanent.getName())); } - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.damage(1, source.getSourceId(), source, game, false, true); } return true; diff --git a/Mage.Sets/src/mage/cards/j/JacesDefeat.java b/Mage.Sets/src/mage/cards/j/JacesDefeat.java index 007bdbb1f09..4de69688399 100644 --- a/Mage.Sets/src/mage/cards/j/JacesDefeat.java +++ b/Mage.Sets/src/mage/cards/j/JacesDefeat.java @@ -73,7 +73,7 @@ class JacesDefeatEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { for (UUID targetId : getTargetPointer().getTargets(game, source) ) { Spell spell = game.getStack().getSpell(targetId); diff --git a/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java b/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java index 9a361e3ca1e..2c8b16ac3f7 100644 --- a/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java +++ b/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java @@ -68,7 +68,7 @@ class JaddiLifestriderEffect extends OneShotEffect { int tappedAmount = 0; Player you = game.getPlayer(source.getControllerId()); TargetCreaturePermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), source, game)) { for (UUID creatureId : target.getTargets()) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { diff --git a/Mage.Sets/src/mage/cards/j/JadeMonolith.java b/Mage.Sets/src/mage/cards/j/JadeMonolith.java index 51fa65d4bc4..b3aa82be4a3 100644 --- a/Mage.Sets/src/mage/cards/j/JadeMonolith.java +++ b/Mage.Sets/src/mage/cards/j/JadeMonolith.java @@ -70,14 +70,14 @@ class JadeMonolithRedirectionEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); Permanent targetCreature = game.getPermanent(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); DamageEvent damageEvent = (DamageEvent) event; if (controller != null && targetCreature != null && sourceObject != null) { controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects()); diff --git a/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java b/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java index bcada6b0520..c613a9c8d51 100644 --- a/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java +++ b/Mage.Sets/src/mage/cards/j/JadziOracleOfArcavios.java @@ -240,7 +240,7 @@ class JourneyToTheOracleEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand( 0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_LANDS ); - player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game); + player.choose(Outcome.PutCardInPlay, target, source, game); return player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); } } diff --git a/Mage.Sets/src/mage/cards/j/JalumGrifter.java b/Mage.Sets/src/mage/cards/j/JalumGrifter.java index c54f86e9966..03fc79a70df 100644 --- a/Mage.Sets/src/mage/cards/j/JalumGrifter.java +++ b/Mage.Sets/src/mage/cards/j/JalumGrifter.java @@ -94,8 +94,8 @@ class JalumGrifterEffect extends OneShotEffect { } Target target = new TargetControlledPermanent(2, 2, new FilterControlledLandPermanent(), true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } diff --git a/Mage.Sets/src/mage/cards/j/JanglingAutomaton.java b/Mage.Sets/src/mage/cards/j/JanglingAutomaton.java index 7d179ab9af0..7bcaa9c9f26 100644 --- a/Mage.Sets/src/mage/cards/j/JanglingAutomaton.java +++ b/Mage.Sets/src/mage/cards/j/JanglingAutomaton.java @@ -62,7 +62,7 @@ class JanglingAutomatonEffect extends OneShotEffect { if (defenderId != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(defenderId)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.untap(game); } return true; diff --git a/Mage.Sets/src/mage/cards/j/JarJarBinks.java b/Mage.Sets/src/mage/cards/j/JarJarBinks.java index c32f09b2485..ba0b5207421 100644 --- a/Mage.Sets/src/mage/cards/j/JarJarBinks.java +++ b/Mage.Sets/src/mage/cards/j/JarJarBinks.java @@ -156,8 +156,8 @@ class JarJarBinksTapEffect extends OneShotEffect { filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, highestPower)); Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { + if (controller.choose(outcome, target, source, game)) { permanentToTap = game.getPermanent(target.getFirstTarget()); } } diff --git a/Mage.Sets/src/mage/cards/j/JestersScepter.java b/Mage.Sets/src/mage/cards/j/JestersScepter.java index 32d8e747810..d56fba15e63 100644 --- a/Mage.Sets/src/mage/cards/j/JestersScepter.java +++ b/Mage.Sets/src/mage/cards/j/JestersScepter.java @@ -76,7 +76,7 @@ class JestersScepterEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player targetedPlayer = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && targetedPlayer != null && sourceObject != null) { @@ -125,7 +125,7 @@ class JestersScepterLookAtCardEffect extends AsThoughEffectImpl { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/j/JeweledTorque.java b/Mage.Sets/src/mage/cards/j/JeweledTorque.java index ad295d7912f..621c971e718 100644 --- a/Mage.Sets/src/mage/cards/j/JeweledTorque.java +++ b/Mage.Sets/src/mage/cards/j/JeweledTorque.java @@ -61,7 +61,7 @@ enum JeweledTorquePredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent permanent = game.getPermanent(input.getSourceId()); + Permanent permanent = input.getSource().getSourcePermanentIfItStillExists(game); if (permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/j/JotunGrunt.java b/Mage.Sets/src/mage/cards/j/JotunGrunt.java index 1bc87e837b4..bd7ae020c3f 100644 --- a/Mage.Sets/src/mage/cards/j/JotunGrunt.java +++ b/Mage.Sets/src/mage/cards/j/JotunGrunt.java @@ -62,7 +62,7 @@ class JotunGruntCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Removal, controllerId, source.getSourceId(), source, game)) { for (UUID targetId: targets.get(0).getTargets()) { Card card = game.getCard(targetId); if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) { @@ -78,7 +78,7 @@ class JotunGruntCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/j/JourneyForTheElixir.java b/Mage.Sets/src/mage/cards/j/JourneyForTheElixir.java index 659918ec2b3..9f0ed072089 100644 --- a/Mage.Sets/src/mage/cards/j/JourneyForTheElixir.java +++ b/Mage.Sets/src/mage/cards/j/JourneyForTheElixir.java @@ -70,7 +70,7 @@ class JourneyForTheElixirEffect extends OneShotEffect { player.searchLibrary(targetCardInLibrary, source, game); Cards cards = new CardsImpl(targetCardInLibrary.getTargets()); TargetCard target = new JourneyForTheElixirGraveyardTarget(cards); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); cards.addAll(target.getTargets()); player.revealCards(source, cards, game); player.moveCards(cards, Zone.HAND, source, game); @@ -177,8 +177,8 @@ class JourneyForTheElixirGraveyardTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Cards alreadyTargeted = new CardsImpl(this.getTargets()); alreadyTargeted.addAll(cards); boolean hasBasic = alreadyTargeted diff --git a/Mage.Sets/src/mage/cards/j/JovensFerrets.java b/Mage.Sets/src/mage/cards/j/JovensFerrets.java index 1f91fe9a7e8..653aad5159d 100644 --- a/Mage.Sets/src/mage/cards/j/JovensFerrets.java +++ b/Mage.Sets/src/mage/cards/j/JovensFerrets.java @@ -82,7 +82,7 @@ class JovensFerretsEffect extends OneShotEffect { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toTap = new ArrayList<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!creature.getId().equals(source.getSourceId())) { if (watcher.creatureHasBlockedAttacker(sourcePermanent, creature, game)) { toTap.add(creature); diff --git a/Mage.Sets/src/mage/cards/j/JumpTrooper.java b/Mage.Sets/src/mage/cards/j/JumpTrooper.java index 20ed86e9b3e..e168b67cb01 100644 --- a/Mage.Sets/src/mage/cards/j/JumpTrooper.java +++ b/Mage.Sets/src/mage/cards/j/JumpTrooper.java @@ -83,7 +83,7 @@ class JumpTrooperTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { Permanent creature = game.getPermanent(event.getTargetId()); - if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) { + if (creature != null && filter.match(creature, getControllerId(), this, game)) { this.getTargets().clear(); TargetStackObject target = new TargetStackObject(); target.add(event.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/j/JunkDiver.java b/Mage.Sets/src/mage/cards/j/JunkDiver.java index 02a416c5f48..48fe6c08d0a 100644 --- a/Mage.Sets/src/mage/cards/j/JunkDiver.java +++ b/Mage.Sets/src/mage/cards/j/JunkDiver.java @@ -13,7 +13,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterArtifactCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -25,7 +25,7 @@ public final class JunkDiver extends CardImpl { private static final FilterArtifactCard filter = new FilterArtifactCard("another target artifact card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public JunkDiver(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/k/KaaliaOfTheVast.java b/Mage.Sets/src/mage/cards/k/KaaliaOfTheVast.java index 45880434739..0daa958af2c 100644 --- a/Mage.Sets/src/mage/cards/k/KaaliaOfTheVast.java +++ b/Mage.Sets/src/mage/cards/k/KaaliaOfTheVast.java @@ -13,7 +13,6 @@ import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCardInHand; @@ -120,7 +119,7 @@ class KaaliaOfTheVastEffect extends OneShotEffect { return false; } TargetCardInHand target = new TargetCardInHand(filter); - if (target.canChoose(source.getSourceId(), controller.getId(), game) && target.choose(outcome, controller.getId(), source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game) && target.choose(outcome, controller.getId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { UUID cardId = target.getFirstTarget(); Card card = game.getCard(cardId); diff --git a/Mage.Sets/src/mage/cards/k/KahoMinamoHistorian.java b/Mage.Sets/src/mage/cards/k/KahoMinamoHistorian.java index 63db0d2d487..f30d6267dba 100644 --- a/Mage.Sets/src/mage/cards/k/KahoMinamoHistorian.java +++ b/Mage.Sets/src/mage/cards/k/KahoMinamoHistorian.java @@ -84,7 +84,7 @@ class KahoMinamoHistorianEffect extends SearchEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (controller.searchLibrary(target, source, game)) { UUID exileZone = CardUtil.getCardExileZoneId(game, source); diff --git a/Mage.Sets/src/mage/cards/k/KaimaTheFracturedCalm.java b/Mage.Sets/src/mage/cards/k/KaimaTheFracturedCalm.java index f2944791881..91fcfcefc02 100644 --- a/Mage.Sets/src/mage/cards/k/KaimaTheFracturedCalm.java +++ b/Mage.Sets/src/mage/cards/k/KaimaTheFracturedCalm.java @@ -68,7 +68,7 @@ class KaimaTheFracturedCalmEffect extends OneShotEffect { int goaded = 0; for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (permanent .getAttachments() diff --git a/Mage.Sets/src/mage/cards/k/KalonianHydra.java b/Mage.Sets/src/mage/cards/k/KalonianHydra.java index c47a872f4e4..9d44e4580ec 100644 --- a/Mage.Sets/src/mage/cards/k/KalonianHydra.java +++ b/Mage.Sets/src/mage/cards/k/KalonianHydra.java @@ -15,10 +15,8 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; -import mage.constants.TargetController; import mage.counters.CounterType; import mage.filter.StaticFilters; -import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -73,7 +71,7 @@ class KalonianHydraEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE_P1P1, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE_P1P1, source.getControllerId(), source, game); for (Permanent permanent : permanents) { int existingCounters = permanent.getCounters(game).getCount(CounterType.P1P1); if (existingCounters > 0) { diff --git a/Mage.Sets/src/mage/cards/k/KamahlsSummons.java b/Mage.Sets/src/mage/cards/k/KamahlsSummons.java index cc9c27c89c4..b9d5c50615f 100644 --- a/Mage.Sets/src/mage/cards/k/KamahlsSummons.java +++ b/Mage.Sets/src/mage/cards/k/KamahlsSummons.java @@ -61,7 +61,7 @@ class KamahlsSummonsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Map revealedCards = new HashMap<>(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { @@ -69,7 +69,7 @@ class KamahlsSummonsEffect extends OneShotEffect { if (player != null) { if (player.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_CREATURE); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Cards cards = new CardsImpl(target.getTargets()); controller.revealCards(sourceObject.getIdName(), cards, game); revealedCards.put(playerId, target.getTargets().size()); diff --git a/Mage.Sets/src/mage/cards/k/KamahlsWill.java b/Mage.Sets/src/mage/cards/k/KamahlsWill.java index 251dacffce0..cd59cb8a5b8 100644 --- a/Mage.Sets/src/mage/cards/k/KamahlsWill.java +++ b/Mage.Sets/src/mage/cards/k/KamahlsWill.java @@ -91,7 +91,7 @@ class KamahlsWillEffect extends OneShotEffect { } for (Permanent creature : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (creature == null || creature.getPower().getValue() < 1) { continue; diff --git a/Mage.Sets/src/mage/cards/k/KarfellHarbinger.java b/Mage.Sets/src/mage/cards/k/KarfellHarbinger.java index 1130d6edb6f..344118bc279 100644 --- a/Mage.Sets/src/mage/cards/k/KarfellHarbinger.java +++ b/Mage.Sets/src/mage/cards/k/KarfellHarbinger.java @@ -75,7 +75,7 @@ class KarfellHarbingerManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isInstantOrSorcery(game); } return source instanceof ForetellAbility; diff --git a/Mage.Sets/src/mage/cards/k/KarnLiberated.java b/Mage.Sets/src/mage/cards/k/KarnLiberated.java index 0908f788ed5..d83d596df4e 100644 --- a/Mage.Sets/src/mage/cards/k/KarnLiberated.java +++ b/Mage.Sets/src/mage/cards/k/KarnLiberated.java @@ -238,7 +238,7 @@ class KarnPlayerExileEffect extends OneShotEffect { return false; } TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game) + if (target.canChoose(player.getId(), source, game) && target.chooseTarget(Outcome.Exile, player.getId(), source, game)) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); return player.moveCardsToExile(new CardsImpl(target.getTargets()).getCards(game), source, game, true, exileId, sourceObject.getIdName()); diff --git a/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java b/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java index 3192b09c4c1..0ad22cce20b 100644 --- a/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java +++ b/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java @@ -1,6 +1,5 @@ package mage.cards.k; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.effects.OneShotEffect; @@ -10,17 +9,19 @@ import mage.cards.*; import mage.constants.*; import mage.counters.CounterType; import mage.filter.FilterCard; -import mage.game.ExileZone; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.token.KarnConstructToken; import mage.players.Player; import mage.target.Target; import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; import mage.target.common.TargetOpponent; -import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; /** * @author spjspj @@ -35,17 +36,15 @@ public final class KarnScionOfUrza extends CardImpl { this.setStartingLoyalty(5); // +1: Reveal the top two cards of your library. An opponent chooses one of them. Put that card into your hand and exile the other with a silver counter on it. - LoyaltyAbility ability1 = new LoyaltyAbility(new KarnPlus1Effect(), 1); - this.addAbility(ability1); + this.addAbility(new LoyaltyAbility(new KarnPlus1Effect(), 1)); // -1: Put a card you own with a silver counter on it from exile into your hand. - LoyaltyAbility ability2 = new LoyaltyAbility(new KarnMinus1Effect(), -1); - this.addAbility(ability2); + this.addAbility(new LoyaltyAbility(new KarnMinus1Effect(), -1)); // -2: Create a 0/0 colorless Construct artifact creature token with "This creature gets +1/+1 for each artifact you control." - LoyaltyAbility ability3 = new LoyaltyAbility(new CreateTokenEffect(new KarnConstructToken(), 1), -2); - ability3.addHint(ArtifactYouControlHint.instance); - this.addAbility(ability3); + this.addAbility(new LoyaltyAbility(new CreateTokenEffect( + new KarnConstructToken(), 1 + ), -2).addHint(ArtifactYouControlHint.instance)); } private KarnScionOfUrza(final KarnScionOfUrza card) { @@ -78,44 +77,47 @@ class KarnPlus1Effect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (sourceObject == null || controller == null) { + if (controller == null) { return false; } Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2)); - if (cards.isEmpty()) { return true; } - controller.revealCards(staticText, cards, game); + controller.revealCards(source, cards, game); Card cardToHand; - if (cards.size() == 1) { - cardToHand = cards.getRandom(game); - } else { - Player opponent; - Set opponents = game.getOpponents(controller.getId()); - if (opponents.size() == 1) { - opponent = game.getPlayer(opponents.iterator().next()); - } else { - Target target = new TargetOpponent(true); - controller.chooseTarget(Outcome.Detriment, target, source, game); - opponent = game.getPlayer(target.getFirstTarget()); - } - TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard()); - opponent.chooseTarget(outcome, cards, target, source, game); - cardToHand = game.getCard(target.getFirstTarget()); + switch (cards.size()) { + case 0: + return false; + case 1: + cardToHand = cards.getRandom(game); + break; + default: + Player opponent; + Set opponents = game.getOpponents(controller.getId()); + if (opponents.size() == 1) { + opponent = game.getPlayer(opponents.iterator().next()); + } else { + Target target = new TargetOpponent(true); + controller.chooseTarget(Outcome.Detriment, target, source, game); + opponent = game.getPlayer(target.getFirstTarget()); + } + TargetCard target = new TargetCard(1, Zone.LIBRARY, StaticFilters.FILTER_CARD); + opponent.chooseTarget(outcome, cards, target, source, game); + cardToHand = game.getCard(target.getFirstTarget()); } if (cardToHand != null) { controller.moveCards(cardToHand, Zone.HAND, source, game); - cards.remove(cardToHand); } - if (!cards.isEmpty()) { - controller.moveCards(cards, Zone.EXILED, source, game); - for (Card c : cards.getCards(game)) { - c.addCounters(CounterType.SILVER.createInstance(1), source.getControllerId(), source, game); - } + cards.retainZone(Zone.LIBRARY, game); + if (cards.isEmpty()) { + return true; } + controller.moveCards(cards, Zone.EXILED, source, game); + cards.getCards(game) + .stream() + .forEach(card -> card.addCounters(CounterType.SILVER.createInstance(1), source, game)); return true; } } @@ -148,38 +150,29 @@ class KarnMinus1Effect extends OneShotEffect { if (controller == null) { return false; } - ExileZone exZone = game.getExile().getPermanentExile(); // getExileZone(Zone.EXILED); - if (exZone == null) { - return true; - } - Card card = null; - - List exile = game.getExile().getAllCards(game); - boolean noTargets = exile.isEmpty(); - if (noTargets) { - game.informPlayer(controller, "You have no exiled cards."); - return true; - } - - Cards filteredCards = new CardsImpl(); - - for (Card exileCard : exile) { - if (exileCard.isOwnedBy(source.getControllerId()) && filter.match(exileCard, game)) { - filteredCards.add(exileCard); - } - } - - TargetCard target = new TargetCard(Zone.EXILED, filter); - target.setNotTarget(true); - if (!controller.choose(Outcome.Benefit, filteredCards, target, game)) { - return true; + Cards cards = new CardsImpl(game + .getExile() + .getCards(filter, game) + .stream() + .filter(Objects::nonNull) + .filter(card -> card.isOwnedBy(source.getControllerId())) + .collect(Collectors.toList())); + Card card; + switch (cards.size()) { + case 0: + return false; + case 1: + card = cards.getRandom(game); + break; + default: + TargetCard target = new TargetCardInExile(filter); + target.setNotTarget(true); + controller.choose(outcome, target, source, game); + card = cards.get(target.getFirstTarget(), game); } if (card == null) { - card = game.getCard(target.getFirstTarget()); + return false; } - if (card != null) { - controller.moveCards(card, Zone.HAND, source, game); - } - return true; + return card != null && controller.moveCards(card, Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java b/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java index f4874f657c7..6eeba08e646 100644 --- a/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java +++ b/Mage.Sets/src/mage/cards/k/KaronaFalseGod.java @@ -122,7 +122,7 @@ class KaronaFalseGodEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject); if (!controller.choose(Outcome.BoostCreature, typeChoice, game)) { diff --git a/Mage.Sets/src/mage/cards/k/KasminaEnigmaSage.java b/Mage.Sets/src/mage/cards/k/KasminaEnigmaSage.java index f0cc27190e6..73b34aed2ec 100644 --- a/Mage.Sets/src/mage/cards/k/KasminaEnigmaSage.java +++ b/Mage.Sets/src/mage/cards/k/KasminaEnigmaSage.java @@ -87,7 +87,7 @@ class KasminaEnigmaSageGainAbilitiesEffect extends ContinuousEffectImpl { .collect(Collectors.toList()); for (Permanent permanent : game.getState().getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (permanent == null || permanent == perm) { continue; diff --git a/Mage.Sets/src/mage/cards/k/KatabaticWinds.java b/Mage.Sets/src/mage/cards/k/KatabaticWinds.java index c3e29e029d7..8e2d4eba936 100644 --- a/Mage.Sets/src/mage/cards/k/KatabaticWinds.java +++ b/Mage.Sets/src/mage/cards/k/KatabaticWinds.java @@ -84,7 +84,7 @@ class KatabaticWindsRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/k/KathrilAspectWarper.java b/Mage.Sets/src/mage/cards/k/KathrilAspectWarper.java index 02e909f4aae..b91ddaca877 100644 --- a/Mage.Sets/src/mage/cards/k/KathrilAspectWarper.java +++ b/Mage.Sets/src/mage/cards/k/KathrilAspectWarper.java @@ -102,7 +102,7 @@ class KathrilAspectWarperEffect extends OneShotEffect { = new FilterControlledCreaturePermanent("creature to give a " + counterType + " counter"); Target target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { continue; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/k/KayasWrath.java b/Mage.Sets/src/mage/cards/k/KayasWrath.java index 72cbd5bf0d1..3e154b128a6 100644 --- a/Mage.Sets/src/mage/cards/k/KayasWrath.java +++ b/Mage.Sets/src/mage/cards/k/KayasWrath.java @@ -59,7 +59,7 @@ class KayasWrathEffect extends OneShotEffect { int counter = 0; for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_PERMANENT_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (permanent != null) { boolean isMine = permanent.isControlledBy(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/k/KazaRoilChaser.java b/Mage.Sets/src/mage/cards/k/KazaRoilChaser.java index af14498a2c2..daba849d422 100644 --- a/Mage.Sets/src/mage/cards/k/KazaRoilChaser.java +++ b/Mage.Sets/src/mage/cards/k/KazaRoilChaser.java @@ -93,7 +93,7 @@ class KazaRoilChaserEffect extends CostModificationEffectImpl { if (watcher != null) { spellsCast = watcher.getCount(source.getControllerId()); } - wizardCount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + wizardCount = game.getBattlefield().count(filter, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/k/KazanduStomper.java b/Mage.Sets/src/mage/cards/k/KazanduStomper.java index 2aebecaf339..2b7893ddb0e 100644 --- a/Mage.Sets/src/mage/cards/k/KazanduStomper.java +++ b/Mage.Sets/src/mage/cards/k/KazanduStomper.java @@ -73,7 +73,7 @@ class KazanduStomperEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent( 0, 2, StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java index 7451ab83548..75829c8c4e2 100644 --- a/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java @@ -64,8 +64,8 @@ class KeeperOfTheBeastsTarget extends TargetPlayer { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); int creaturesController = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game); @@ -78,9 +78,9 @@ class KeeperOfTheBeastsTarget extends TargetPlayer { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); Player controller = game.getPlayer(sourceControllerId); if (controller != null && targetSource != null) { for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { @@ -89,7 +89,7 @@ class KeeperOfTheBeastsTarget extends TargetPlayer { && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game) < game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game) && !player.hasLeft() - && filter.match(player, sourceId, sourceControllerId, game) + && filter.match(player, sourceControllerId, source, game) && player.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheDead.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheDead.java index 5dc7fef6231..f7feb5dabfc 100644 --- a/Mage.Sets/src/mage/cards/k/KeeperOfTheDead.java +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheDead.java @@ -71,7 +71,7 @@ class KeeperOfDeadPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { Player targetPlayer = input.getObject(); - Permanent sourceObject = game.getPermanent(input.getSourceId()); + Permanent sourceObject = input.getSource().getSourcePermanentIfItStillExists(game); Player controller = null; if (sourceObject != null) { controller = game.getPlayer(sourceObject.getControllerId()); @@ -114,16 +114,16 @@ class KeeperOfTheDeadCreatureTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); for (StackObject item : game.getState().getStack()) { - if (item.getId().equals(sourceId)) { + if (item.getId().equals(source.getSourceId())) { object = item; } - if (item.getSourceId().equals(sourceId)) { + if (item.getSourceId().equals(source.getSourceId())) { object = item; } } diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java index 60812e38b54..c3938de579f 100644 --- a/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java @@ -92,7 +92,7 @@ class KeeperOfTheLensLookFaceDownEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller == null || mageObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheLight.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheLight.java index 498322f18d5..16797d55e8c 100644 --- a/Mage.Sets/src/mage/cards/k/KeeperOfTheLight.java +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheLight.java @@ -66,8 +66,8 @@ class KeeperOfTheLightTarget extends TargetPlayer { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); int lifeController = game.getPlayer(sourceControllerId).getLife(); @@ -84,9 +84,9 @@ class KeeperOfTheLightTarget extends TargetPlayer { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); Player controller = game.getPlayer(sourceControllerId); if (controller != null && targetSource != null) { for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { @@ -94,7 +94,7 @@ class KeeperOfTheLightTarget extends TargetPlayer { if (player != null && controller.getLife() < player.getLife() && !player.hasLeft() - && filter.match(player, sourceId, sourceControllerId, game) + && filter.match(player, sourceControllerId, source, game) && player.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { diff --git a/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java b/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java index 862d3bebf5b..cfab13b1215 100644 --- a/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java +++ b/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java @@ -87,7 +87,7 @@ class KeldonBattlewagonCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { @@ -104,7 +104,7 @@ class KeldonBattlewagonCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/k/KeldonFirebombers.java b/Mage.Sets/src/mage/cards/k/KeldonFirebombers.java index 7d8ba53e6d2..528e274c6c5 100644 --- a/Mage.Sets/src/mage/cards/k/KeldonFirebombers.java +++ b/Mage.Sets/src/mage/cards/k/KeldonFirebombers.java @@ -79,7 +79,7 @@ class KeldonFirebombersEffect extends OneShotEffect { FilterLandPermanent playerFilter = filter.copy(); playerFilter.add(new ControllerIdPredicate(playerId)); Target target = new TargetLandPermanent(amount, amount, playerFilter, true); - player.choose(outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(outcome.Sacrifice, target, source, game); for (UUID landId : target.getTargets()) { Permanent land = game.getPermanent(landId); if (land != null) { diff --git a/Mage.Sets/src/mage/cards/k/KhalniGem.java b/Mage.Sets/src/mage/cards/k/KhalniGem.java index d6d6138991e..6e27ee769ca 100644 --- a/Mage.Sets/src/mage/cards/k/KhalniGem.java +++ b/Mage.Sets/src/mage/cards/k/KhalniGem.java @@ -64,7 +64,7 @@ class KhalniGemReturnToHandTargetEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); int landCount = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); if (player == null || landCount < 1) { return false; @@ -73,7 +73,7 @@ class KhalniGemReturnToHandTargetEffect extends OneShotEffect { Math.min(landCount, 2), StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND ); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/k/KheruLichLord.java b/Mage.Sets/src/mage/cards/k/KheruLichLord.java index 8c037d34192..adbacf7cae3 100644 --- a/Mage.Sets/src/mage/cards/k/KheruLichLord.java +++ b/Mage.Sets/src/mage/cards/k/KheruLichLord.java @@ -84,7 +84,7 @@ class KheruLichLordEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, source.getSourceId(), source.getControllerId(), game)); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, source.getControllerId(), source, game)); Card card = cards.getRandom(game); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/k/KheruMindEater.java b/Mage.Sets/src/mage/cards/k/KheruMindEater.java index 481e246db10..7a722dd5595 100644 --- a/Mage.Sets/src/mage/cards/k/KheruMindEater.java +++ b/Mage.Sets/src/mage/cards/k/KheruMindEater.java @@ -79,7 +79,7 @@ class KheruMindEaterExileEffect extends OneShotEffect { Target target = new TargetCardInHand(1, new FilterCard()); target.chooseTarget(Outcome.Exile, player.getId(), source, game); Card card = game.getCard(target.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (card != null && sourceObject != null) { if (player.moveCardsToExile(card, source, game, false, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName())) { card.setFaceDown(true, game); @@ -154,7 +154,7 @@ class KheruMindEaterLookAtCardEffect extends AsThoughEffectImpl { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/k/KianneDeanOfSubstance.java b/Mage.Sets/src/mage/cards/k/KianneDeanOfSubstance.java index 2bf9fd8a883..a6364745843 100644 --- a/Mage.Sets/src/mage/cards/k/KianneDeanOfSubstance.java +++ b/Mage.Sets/src/mage/cards/k/KianneDeanOfSubstance.java @@ -212,7 +212,7 @@ class ImbrahamDeanOfTheoryEffect extends OneShotEffect { } TargetCard targetCard = new TargetCardInExile(0, 1, filter, null); targetCard.setNotTarget(true); - player.choose(outcome, targetCard, source.getSourceId(), game); + player.choose(outcome, targetCard, source, game); Card card = game.getCard(targetCard.getFirstTarget()); if (card != null) { player.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/k/KillSwitch.java b/Mage.Sets/src/mage/cards/k/KillSwitch.java index fb21fcfc698..2586798764d 100644 --- a/Mage.Sets/src/mage/cards/k/KillSwitch.java +++ b/Mage.Sets/src/mage/cards/k/KillSwitch.java @@ -68,7 +68,7 @@ class KillSwitchEffect extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_PERMANENT_ARTIFACT, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ); Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); if (sourcePermanent != null) { diff --git a/Mage.Sets/src/mage/cards/k/Kindle.java b/Mage.Sets/src/mage/cards/k/Kindle.java index 9991f710a52..457244f8c50 100644 --- a/Mage.Sets/src/mage/cards/k/Kindle.java +++ b/Mage.Sets/src/mage/cards/k/Kindle.java @@ -67,7 +67,7 @@ class KindleCardsInAllGraveyardsCount implements DynamicValue { for (UUID playerUUID : playerList) { Player player = game.getPlayer(playerUUID); if (player != null) { - amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + amount += player.getGraveyard().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } } return amount + 2; diff --git a/Mage.Sets/src/mage/cards/k/KindredCharge.java b/Mage.Sets/src/mage/cards/k/KindredCharge.java index 82318a30d42..2a2d33f6a13 100644 --- a/Mage.Sets/src/mage/cards/k/KindredCharge.java +++ b/Mage.Sets/src/mage/cards/k/KindredCharge.java @@ -66,7 +66,7 @@ class KindredChargeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game); if (subType != null) { diff --git a/Mage.Sets/src/mage/cards/k/KindredDominance.java b/Mage.Sets/src/mage/cards/k/KindredDominance.java index 80f1d7d2272..13725ba97e4 100644 --- a/Mage.Sets/src/mage/cards/k/KindredDominance.java +++ b/Mage.Sets/src/mage/cards/k/KindredDominance.java @@ -59,7 +59,7 @@ class KindredDominanceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); if (controller != null && controller.choose(outcome, typeChoice, game)) { game.informPlayers(controller.getLogName() + " has chosen " + typeChoice.getChoice()); FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures not of the chosen type"); diff --git a/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java b/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java index b43bd8a4743..77d0ff745ec 100644 --- a/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java +++ b/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java @@ -118,7 +118,7 @@ class KioraRevealEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/k/KjeldoranFrostbeast.java b/Mage.Sets/src/mage/cards/k/KjeldoranFrostbeast.java index 184b9b72ebd..a84844592a8 100644 --- a/Mage.Sets/src/mage/cards/k/KjeldoranFrostbeast.java +++ b/Mage.Sets/src/mage/cards/k/KjeldoranFrostbeast.java @@ -1,26 +1,30 @@ - package mage.cards.k; -import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EndOfCombatTriggeredAbility; import mage.abilities.effects.common.DestroyAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; + +import java.util.UUID; /** - * * @author TheElk801 */ public final class KjeldoranFrostbeast extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creatures blocking or blocked by it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public KjeldoranFrostbeast(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{W}"); @@ -29,12 +33,8 @@ public final class KjeldoranFrostbeast extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(4); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures blocking or blocked by it"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); // At end of combat, destroy all creatures blocking or blocked by Kjeldoran Frostbeast. - Ability ability = new EndOfCombatTriggeredAbility(new DestroyAllEffect(filter, false), false); - this.addAbility(ability); + this.addAbility(new EndOfCombatTriggeredAbility(new DestroyAllEffect(filter, false), false)); } private KjeldoranFrostbeast(final KjeldoranFrostbeast card) { diff --git a/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java b/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java index bf0db00f753..d1886525722 100644 --- a/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java +++ b/Mage.Sets/src/mage/cards/k/KjeldoranRoyalGuard.java @@ -88,7 +88,7 @@ class KjeldoranRoyalGuardEffect extends ReplacementEffectImpl { && ((DamageEvent)event).isCombatDamage()) { Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (event.getSourceId().equals(permanent.getId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/k/KlauthUnrivaledAncient.java b/Mage.Sets/src/mage/cards/k/KlauthUnrivaledAncient.java index 50e10e69888..3cf508338d0 100644 --- a/Mage.Sets/src/mage/cards/k/KlauthUnrivaledAncient.java +++ b/Mage.Sets/src/mage/cards/k/KlauthUnrivaledAncient.java @@ -87,7 +87,7 @@ class KlauthUnrivaledAncientEffect extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_ATTACKING_CREATURES, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .filter(Objects::nonNull) .map(MageObject::getPower) diff --git a/Mage.Sets/src/mage/cards/k/KnacksawClique.java b/Mage.Sets/src/mage/cards/k/KnacksawClique.java index 86bbe3e8fe6..dd2801061ba 100644 --- a/Mage.Sets/src/mage/cards/k/KnacksawClique.java +++ b/Mage.Sets/src/mage/cards/k/KnacksawClique.java @@ -80,7 +80,7 @@ class KnacksawCliqueEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && opponent != null) { if (opponent.getLibrary().hasCards()) { Library library = opponent.getLibrary(); diff --git a/Mage.Sets/src/mage/cards/k/KnightOfDusk.java b/Mage.Sets/src/mage/cards/k/KnightOfDusk.java index 4797519f740..7fa04e00e5c 100644 --- a/Mage.Sets/src/mage/cards/k/KnightOfDusk.java +++ b/Mage.Sets/src/mage/cards/k/KnightOfDusk.java @@ -1,7 +1,5 @@ - package mage.cards.k; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -11,19 +9,26 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author dustinconrad */ public final class KnightOfDusk extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public KnightOfDusk(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.KNIGHT); @@ -31,10 +36,8 @@ public final class KnightOfDusk extends CardImpl { this.toughness = new MageInt(2); // {B}{B}: Destroy target creature blocking Knight of Dusk. - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking {this}"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{B}{B}")); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new ManaCostsImpl<>("{B}{B}")); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/k/KnightOfValor.java b/Mage.Sets/src/mage/cards/k/KnightOfValor.java index 65d0c21d273..ba893fa3238 100644 --- a/Mage.Sets/src/mage/cards/k/KnightOfValor.java +++ b/Mage.Sets/src/mage/cards/k/KnightOfValor.java @@ -1,7 +1,5 @@ - package mage.cards.k; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.LimitedTimesPerTurnActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -10,22 +8,31 @@ import mage.abilities.keyword.FlankingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; +import mage.constants.SubType; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.AbilityPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; + +import java.util.UUID; /** - * * @author LoneFox */ public final class KnightOfValor extends CardImpl { + private static final FilterCreaturePermanent filter + = new FilterCreaturePermanent("each creature without flanking blocking {this}"); + + static { + filter.add(Predicates.not(new AbilityPredicate(FlankingAbility.class))); + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public KnightOfValor(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.KNIGHT); this.power = new MageInt(2); @@ -34,10 +41,11 @@ public final class KnightOfValor extends CardImpl { // Flanking this.addAbility(new FlankingAbility()); // {1}{W}: Each creature without flanking blocking Knight of Valor gets -1/-1 until end of turn. Activate this ability only once each turn. - FilterCreaturePermanent filter = new FilterCreaturePermanent("each creature without flanking blocking {this}"); - filter.add(Predicates.not(new AbilityPredicate(FlankingAbility.class))); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - this.addAbility(new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new BoostAllEffect(-1, -1, Duration.EndOfTurn, filter, false), new ManaCostsImpl("{1}{W}"))); + this.addAbility(new LimitedTimesPerTurnActivatedAbility( + Zone.BATTLEFIELD, + new BoostAllEffect(-1, -1, Duration.EndOfTurn, filter, false), + new ManaCostsImpl<>("{1}{W}") + )); } private KnightOfValor(final KnightOfValor card) { diff --git a/Mage.Sets/src/mage/cards/k/KodamaOfTheEastTree.java b/Mage.Sets/src/mage/cards/k/KodamaOfTheEastTree.java index e85cd70256d..4001ab4c0af 100644 --- a/Mage.Sets/src/mage/cards/k/KodamaOfTheEastTree.java +++ b/Mage.Sets/src/mage/cards/k/KodamaOfTheEastTree.java @@ -124,11 +124,11 @@ class KodamaOfTheEastTreeEffect extends OneShotEffect { ComparisonType.FEWER_THAN, permanent.getManaValue() + 1 )); TargetCardInHand target = new TargetCardInHand(filter); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (!target.canChoose(source.getControllerId(), source, game) || !player.chooseUse(outcome, "Put a permanent card onto the battlefield?", source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/k/KodamasReach.java b/Mage.Sets/src/mage/cards/k/KodamasReach.java index 9ace6ccedc8..78b073b8f9b 100644 --- a/Mage.Sets/src/mage/cards/k/KodamasReach.java +++ b/Mage.Sets/src/mage/cards/k/KodamasReach.java @@ -63,7 +63,7 @@ class KodamasReachEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/k/KolvoriGodOfKinship.java b/Mage.Sets/src/mage/cards/k/KolvoriGodOfKinship.java index 44ecc57252e..3c4f82e7a47 100644 --- a/Mage.Sets/src/mage/cards/k/KolvoriGodOfKinship.java +++ b/Mage.Sets/src/mage/cards/k/KolvoriGodOfKinship.java @@ -148,7 +148,7 @@ class TheRinghartCrestManaCondition extends CreatureCastManaCondition { @Override public boolean apply(Game game, Ability source) { if (super.apply(game, source)) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null) { if (object.isLegendary()) { return true; diff --git a/Mage.Sets/src/mage/cards/k/KomainuBattleArmor.java b/Mage.Sets/src/mage/cards/k/KomainuBattleArmor.java index 61da72ca954..d993eccf9d4 100644 --- a/Mage.Sets/src/mage/cards/k/KomainuBattleArmor.java +++ b/Mage.Sets/src/mage/cards/k/KomainuBattleArmor.java @@ -128,7 +128,7 @@ class KomainuBattleArmorEffect extends OneShotEffect { } for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - playerId, source.getSourceId(), game + playerId, source, game )) { game.addEffect(new GoadTargetEffect().setTargetPointer(new FixedTarget(permanent, game)), source); } diff --git a/Mage.Sets/src/mage/cards/k/KondasBanner.java b/Mage.Sets/src/mage/cards/k/KondasBanner.java index 9ded58a3ffd..42bd3adecbd 100644 --- a/Mage.Sets/src/mage/cards/k/KondasBanner.java +++ b/Mage.Sets/src/mage/cards/k/KondasBanner.java @@ -108,7 +108,7 @@ class KondasBannerTypeBoostEffect extends BoostAllEffect { if (equipment != null && equipment.getAttachedTo() != null) { Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo()); if (equipedCreature != null) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (perm.shareCreatureTypes(game, equipedCreature)) { perm.addPower(power.calculate(game, source, this)); perm.addToughness(toughness.calculate(game, source, this)); @@ -148,7 +148,7 @@ class KondasBannerColorBoostEffect extends BoostAllEffect { if (equipment != null && equipment.getAttachedTo() != null) { Permanent equipedCreature = game.getPermanent(equipment.getAttachedTo()); if (equipedCreature != null) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (equipedCreature.getColor(game).shares(perm.getColor(game))) { perm.addPower(power.calculate(game, source, this)); perm.addToughness(toughness.calculate(game, source, this)); diff --git a/Mage.Sets/src/mage/cards/k/KorChant.java b/Mage.Sets/src/mage/cards/k/KorChant.java index 7b14735d97e..94729ddb3b4 100644 --- a/Mage.Sets/src/mage/cards/k/KorChant.java +++ b/Mage.Sets/src/mage/cards/k/KorChant.java @@ -71,7 +71,7 @@ class KorChantEffect extends RedirectionEffect { @Override public void init(Ability source, Game game) { super.init(source, game); - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/k/KorDirge.java b/Mage.Sets/src/mage/cards/k/KorDirge.java index 2d66c71f3cd..acacebbe74d 100644 --- a/Mage.Sets/src/mage/cards/k/KorDirge.java +++ b/Mage.Sets/src/mage/cards/k/KorDirge.java @@ -71,7 +71,7 @@ class KorDirgeEffect extends RedirectionEffect { @Override public void init(Ability source, Game game) { super.init(source, game); - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java b/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java index 23050d59ae0..9f5ff59456b 100644 --- a/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java +++ b/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java @@ -123,7 +123,7 @@ class KozilekDiscardCost extends CostImpl { TargetCardInHand target = new TargetCardInHand(filter); this.getTargets().clear(); this.getTargets().add(target); - if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : targets.get(0).getTargets()) { Card card = player.getHand().get(targetId, game); if (card == null) { diff --git a/Mage.Sets/src/mage/cards/k/Kudzu.java b/Mage.Sets/src/mage/cards/k/Kudzu.java index ddbfa6d95c9..9c3745caf22 100644 --- a/Mage.Sets/src/mage/cards/k/Kudzu.java +++ b/Mage.Sets/src/mage/cards/k/Kudzu.java @@ -86,7 +86,7 @@ class KudzuEffect extends OneShotEffect { target.setNotTarget(true); //not a target, it is chosen Card kudzuCard = game.getCard(source.getSourceId()); if (kudzuCard != null && landsController != null) { - if (landsController.choose(Outcome.Detriment, target, source.getId(), game)) { + if (landsController.choose(Outcome.Detriment, target, source, game)) { if (target.getFirstTarget() != null) { Permanent landChosen = game.getPermanent(target.getFirstTarget()); if (landChosen != null) { diff --git a/Mage.Sets/src/mage/cards/k/KulrathKnight.java b/Mage.Sets/src/mage/cards/k/KulrathKnight.java index b1d359845c7..c26ddddf7f2 100644 --- a/Mage.Sets/src/mage/cards/k/KulrathKnight.java +++ b/Mage.Sets/src/mage/cards/k/KulrathKnight.java @@ -84,6 +84,6 @@ class KulrathKnightRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java b/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java index ad848a5cba2..de2b58d8727 100644 --- a/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java +++ b/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java @@ -88,7 +88,7 @@ class KynaiosAndTirosEffect extends OneShotEffect { } target.clearChosen(); boolean playedLand = false; - if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game) && currentPlayer.chooseUse(outcome, "Put a land card from your hand onto the battlefield?", source, game)) { + if (target.canChoose(currentPlayer.getId(), source, game) && currentPlayer.chooseUse(outcome, "Put a land card from your hand onto the battlefield?", source, game)) { if (target.chooseTarget(outcome, currentPlayer.getId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/l/Landslide.java b/Mage.Sets/src/mage/cards/l/Landslide.java index a396fb20a9f..6bff3cab0c7 100644 --- a/Mage.Sets/src/mage/cards/l/Landslide.java +++ b/Mage.Sets/src/mage/cards/l/Landslide.java @@ -64,7 +64,7 @@ class LandslideEffect extends OneShotEffect { Player you = game.getPlayer(source.getControllerId()); if (you != null) { Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } you.chooseTarget(Outcome.Detriment, target, source, game); diff --git a/Mage.Sets/src/mage/cards/l/LastLaugh.java b/Mage.Sets/src/mage/cards/l/LastLaugh.java index 498a0813852..08300cb451e 100644 --- a/Mage.Sets/src/mage/cards/l/LastLaugh.java +++ b/Mage.Sets/src/mage/cards/l/LastLaugh.java @@ -65,7 +65,7 @@ class LastLaughStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().count(new FilterCreaturePermanent(), this.getSourceId(), this.getControllerId(), game) == 0; + return game.getBattlefield().count(new FilterCreaturePermanent(), this.getControllerId(), this, game) == 0; } @Override diff --git a/Mage.Sets/src/mage/cards/l/LastStand.java b/Mage.Sets/src/mage/cards/l/LastStand.java index 98c74e67ef0..d0a50accba1 100644 --- a/Mage.Sets/src/mage/cards/l/LastStand.java +++ b/Mage.Sets/src/mage/cards/l/LastStand.java @@ -79,27 +79,27 @@ class LastStandEffect extends OneShotEffect { // Target opponent loses 2 life for each Swamp you control Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); if (opponent != null) { - int swamps = game.getBattlefield().count(filterSwamp, source.getSourceId(), source.getControllerId(), game); + int swamps = game.getBattlefield().count(filterSwamp, source.getControllerId(), source, game); opponent.loseLife(swamps * 2, game, source, false); } // Last Stand deals damage equal to the number of Mountains you control to target creature. Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (creature != null) { - int mountains = game.getBattlefield().count(filterMountain, source.getSourceId(), source.getControllerId(), game); + int mountains = game.getBattlefield().count(filterMountain, source.getControllerId(), source, game); if (mountains > 0) { creature.damage(mountains, source.getSourceId(), source, game, false, true); } } // Create a 1/1 green Saproling creature token for each Forest you control. - int forests = game.getBattlefield().count(filterForest, source.getSourceId(), source.getControllerId(), game); + int forests = game.getBattlefield().count(filterForest, source.getControllerId(), source, game); if (forests > 0) { new CreateTokenEffect(new SaprolingToken(), forests).apply(game, source); } // You gain 2 life for each Plains you control. - int plains = game.getBattlefield().count(filterPlains, source.getSourceId(), source.getControllerId(), game); + int plains = game.getBattlefield().count(filterPlains, source.getControllerId(), source, game); controller.gainLife(plains * 2, game, source); // Draw a card for each Island you control, then discard that many cards - int islands = game.getBattlefield().count(filterIsland, source.getSourceId(), source.getControllerId(), game); + int islands = game.getBattlefield().count(filterIsland, source.getControllerId(), source, game); if (islands > 0) { controller.drawCards(islands, source, game); controller.discard(islands, false, false, source, game); diff --git a/Mage.Sets/src/mage/cards/l/Lavalanche.java b/Mage.Sets/src/mage/cards/l/Lavalanche.java index b9432f0e639..93212fd37f4 100644 --- a/Mage.Sets/src/mage/cards/l/Lavalanche.java +++ b/Mage.Sets/src/mage/cards/l/Lavalanche.java @@ -72,7 +72,7 @@ class LavalancheEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent("and each creature that player or that planeswalker's controller controls"); filter.add(CardType.CREATURE.getPredicate()); filter.add(new ControllerIdPredicate(targetPlayer.getId())); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/l/LaviniaAzoriusRenegade.java b/Mage.Sets/src/mage/cards/l/LaviniaAzoriusRenegade.java index 9419111fda6..1da6683b3d8 100644 --- a/Mage.Sets/src/mage/cards/l/LaviniaAzoriusRenegade.java +++ b/Mage.Sets/src/mage/cards/l/LaviniaAzoriusRenegade.java @@ -71,7 +71,7 @@ class LaviniaAzoriusRenegadeReplacementEffect extends ContinuousRuleModifyingEff @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast noncreature spells with mana value greater than " + getLandCount(source, event, game) + " (" + mageObject.getIdName() + ")."; } @@ -100,7 +100,7 @@ class LaviniaAzoriusRenegadeReplacementEffect extends ContinuousRuleModifyingEff int landCount = 0; UUID playerId = event.getPlayerId(); if(playerId != null) { - List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, playerId, source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, playerId, source, game); for (Permanent permanent : permanents) { if (permanent.isControlledBy(playerId)) { landCount++; diff --git a/Mage.Sets/src/mage/cards/l/LedevChampion.java b/Mage.Sets/src/mage/cards/l/LedevChampion.java index 4f90d1b3557..0a733a52153 100644 --- a/Mage.Sets/src/mage/cards/l/LedevChampion.java +++ b/Mage.Sets/src/mage/cards/l/LedevChampion.java @@ -79,8 +79,8 @@ class LedevChampionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int tappedAmount = 0; TargetCreaturePermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) - && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) + && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), source, game)) { for (UUID creatureId : target.getTargets()) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { diff --git a/Mage.Sets/src/mage/cards/l/LegionLoyalist.java b/Mage.Sets/src/mage/cards/l/LegionLoyalist.java index 290ed7147b2..41bea8a3819 100644 --- a/Mage.Sets/src/mage/cards/l/LegionLoyalist.java +++ b/Mage.Sets/src/mage/cards/l/LegionLoyalist.java @@ -68,7 +68,7 @@ class CantBeBlockedByTokenEffect extends RestrictionEffect { @Override public void init(Ability source, Game game) { affectedObjectsSet = true; - for (Permanent perm : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } diff --git a/Mage.Sets/src/mage/cards/l/LegionsInitiative.java b/Mage.Sets/src/mage/cards/l/LegionsInitiative.java index f1080766ac6..e3ffe081f0a 100644 --- a/Mage.Sets/src/mage/cards/l/LegionsInitiative.java +++ b/Mage.Sets/src/mage/cards/l/LegionsInitiative.java @@ -102,7 +102,7 @@ class LegionsInitiativeExileEffect extends OneShotEffect { Cards cards = new CardsImpl(); game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream().filter(Objects::nonNull).forEach(cards::add); return player.moveCardsToExile( cards.getCards(game), source, game, true, diff --git a/Mage.Sets/src/mage/cards/l/LensOfClarity.java b/Mage.Sets/src/mage/cards/l/LensOfClarity.java index 12f9baa9952..d96e4a21579 100644 --- a/Mage.Sets/src/mage/cards/l/LensOfClarity.java +++ b/Mage.Sets/src/mage/cards/l/LensOfClarity.java @@ -85,7 +85,7 @@ class LensOfClarityLookLibraryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller == null || mageObject == null) { return false; } @@ -148,7 +148,7 @@ class LensOfClarityLookFaceDownEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller= game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller == null || mageObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/l/LesserWerewolf.java b/Mage.Sets/src/mage/cards/l/LesserWerewolf.java index 6af8537ff7a..9e9f46690fe 100644 --- a/Mage.Sets/src/mage/cards/l/LesserWerewolf.java +++ b/Mage.Sets/src/mage/cards/l/LesserWerewolf.java @@ -12,14 +12,13 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.counters.BoostCounter; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.common.TargetCreaturePermanent; +import mage.target.TargetPermanent; import java.util.UUID; @@ -28,6 +27,13 @@ import java.util.UUID; */ public final class LesserWerewolf extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public LesserWerewolf(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); this.subtype.add(SubType.WEREWOLF); @@ -35,13 +41,12 @@ public final class LesserWerewolf extends CardImpl { this.toughness = new MageInt(4); // {B}: If Lesser Werewolf’s power is 1 or more, it gets -1/-0 until end of turn and put a -0/-1 counter on target creature blocking or blocked by Lesser Werewolf. Activate this ability only during the declare blockers step. - Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new LesserWerewolfEffect(), new ManaCostsImpl("{B}"), new IsStepCondition(PhaseStep.DECLARE_BLOCKERS, false)); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by Lesser Werewolf"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new ConditionalActivatedAbility( + Zone.BATTLEFIELD, new LesserWerewolfEffect(), new ManaCostsImpl<>("{B}"), + new IsStepCondition(PhaseStep.DECLARE_BLOCKERS, false) + ); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); - } private LesserWerewolf(final LesserWerewolf card) { @@ -75,13 +80,13 @@ class LesserWerewolfEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source)); // must be valid target - if (controller != null && sourcePermanent != null && targetPermanent != null) { - if (sourcePermanent.getPower().getValue() >= 1) { - game.addEffect(new BoostSourceEffect(-1, 0, Duration.EndOfTurn), source); - new AddCountersTargetEffect(new BoostCounter(0, -1), outcome).apply(game, source); - } - return true; + if (controller == null || sourcePermanent == null || targetPermanent == null) { + return false; } - return false; + if (sourcePermanent.getPower().getValue() >= 1) { + game.addEffect(new BoostSourceEffect(-1, 0, Duration.EndOfTurn), source); + new AddCountersTargetEffect(new BoostCounter(0, -1), outcome).apply(game, source); + } + return true; } } diff --git a/Mage.Sets/src/mage/cards/l/LeylineOfSingularity.java b/Mage.Sets/src/mage/cards/l/LeylineOfSingularity.java index ab4cd05904c..9b23e8d8652 100644 --- a/Mage.Sets/src/mage/cards/l/LeylineOfSingularity.java +++ b/Mage.Sets/src/mage/cards/l/LeylineOfSingularity.java @@ -59,7 +59,7 @@ class SetSupertypeAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.addSuperType(SuperType.LEGENDARY); } return true; diff --git a/Mage.Sets/src/mage/cards/l/Lhurgoyf.java b/Mage.Sets/src/mage/cards/l/Lhurgoyf.java index 7632bab57c4..846738bfb2f 100644 --- a/Mage.Sets/src/mage/cards/l/Lhurgoyf.java +++ b/Mage.Sets/src/mage/cards/l/Lhurgoyf.java @@ -66,7 +66,7 @@ class LhurgoyfEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { int number = 0; for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/l/Lich.java b/Mage.Sets/src/mage/cards/l/Lich.java index e507b5eefed..c37a5006608 100644 --- a/Mage.Sets/src/mage/cards/l/Lich.java +++ b/Mage.Sets/src/mage/cards/l/Lich.java @@ -168,8 +168,8 @@ class LichDamageEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetControlledPermanent(amount, amount, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - if (controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { + if (controller.choose(Outcome.Sacrifice, target, source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/l/LichsMastery.java b/Mage.Sets/src/mage/cards/l/LichsMastery.java index 74ebde08dc4..e95944317a3 100644 --- a/Mage.Sets/src/mage/cards/l/LichsMastery.java +++ b/Mage.Sets/src/mage/cards/l/LichsMastery.java @@ -197,20 +197,20 @@ class LichsMasteryLoseLifeEffect extends OneShotEffect { int permCount = game.getBattlefield().getActivePermanents(filter, controller.getId(), game).size(); if (graveCount + handCount == 0 || (permCount > 0 && controller.chooseUse(Outcome.Exile, "Exile permanent you control? (No = from hand or graveyard)", source, game))) { Target target = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Effect effect = new ExileTargetEffect(); effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game)); effect.apply(game, source); } else if (graveCount == 0 || (handCount > 0 && controller.chooseUse(Outcome.Exile, "Exile a card from your hand? (No = from graveyard)", source, game))) { Target target = new TargetCardInHand(1, 1, new FilterCard()); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.EXILED, source, game); } } else if (graveCount > 0) { Target target = new TargetCardInYourGraveyard(1, 1, new FilterCard(), true); - target.choose(Outcome.Exile, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Exile, source.getControllerId(), source.getSourceId(), source, game); Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.EXILED, source, game); diff --git a/Mage.Sets/src/mage/cards/l/LichsMirror.java b/Mage.Sets/src/mage/cards/l/LichsMirror.java index 84c5c7858ac..56f69d6ab81 100644 --- a/Mage.Sets/src/mage/cards/l/LichsMirror.java +++ b/Mage.Sets/src/mage/cards/l/LichsMirror.java @@ -70,7 +70,7 @@ class LichsMirrorEffect extends ReplacementEffectImpl { filter.add(new OwnerIdPredicate(player.getId())); toLib.addAll(player.getHand()); toLib.addAll(player.getGraveyard()); - for(Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)){ + for(Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)){ toLib.add(permanent); } player.shuffleCardsToLibrary(toLib, game, source); diff --git a/Mage.Sets/src/mage/cards/l/LiegeOfThePit.java b/Mage.Sets/src/mage/cards/l/LiegeOfThePit.java index c38c7f76f89..a42774758ad 100644 --- a/Mage.Sets/src/mage/cards/l/LiegeOfThePit.java +++ b/Mage.Sets/src/mage/cards/l/LiegeOfThePit.java @@ -84,8 +84,8 @@ class LiegeOfThePitEffect extends OneShotEffect { filter.add(AnotherPredicate.instance); Target target = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/l/LifeAndLimb.java b/Mage.Sets/src/mage/cards/l/LifeAndLimb.java index c7ac0295611..27fa809f16a 100644 --- a/Mage.Sets/src/mage/cards/l/LifeAndLimb.java +++ b/Mage.Sets/src/mage/cards/l/LifeAndLimb.java @@ -67,7 +67,7 @@ class LifeAndLimbEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { switch (layer) { case TypeChangingEffects_4: permanent.addCardType(game, CardType.CREATURE); diff --git a/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java b/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java index df403f8f1f1..3619abaa48b 100644 --- a/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java +++ b/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java @@ -83,7 +83,7 @@ class LightPawsEmperorsVoiceEffect extends OneShotEffect { return game.getBattlefield() .getActivePermanents( filter, input.getPlayerId(), - input.getSourceId(), game + input.getSource(), game ).stream() .filter(Objects::nonNull) .noneMatch(permanent -> CardUtil.haveSameNames(permanent, input.getObject())); diff --git a/Mage.Sets/src/mage/cards/l/LilianaDreadhordeGeneral.java b/Mage.Sets/src/mage/cards/l/LilianaDreadhordeGeneral.java index 69fabb6d9a4..9ff716577a5 100644 --- a/Mage.Sets/src/mage/cards/l/LilianaDreadhordeGeneral.java +++ b/Mage.Sets/src/mage/cards/l/LilianaDreadhordeGeneral.java @@ -101,13 +101,13 @@ class LilianaDreadhordeGeneralEffect extends OneShotEffect { filter.add(cardType.getPredicate()); Target target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (opponent.choose(outcome, target, source.getSourceId(), game)) { + if (opponent.choose(outcome, target, source, game)) { keepFilter.add(Predicates.not(new CardIdPredicate(target.getFirstTarget()))); } } } for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { - if (keepFilter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (keepFilter.match(permanent, source.getControllerId(), source, game)) { permanent.sacrifice(source, game); } } diff --git a/Mage.Sets/src/mage/cards/l/LilianaOfTheDarkRealms.java b/Mage.Sets/src/mage/cards/l/LilianaOfTheDarkRealms.java index 1eb3210e059..48f603ce55d 100644 --- a/Mage.Sets/src/mage/cards/l/LilianaOfTheDarkRealms.java +++ b/Mage.Sets/src/mage/cards/l/LilianaOfTheDarkRealms.java @@ -85,7 +85,7 @@ class LilianaOfTheDarkRealmsEffect extends OneShotEffect { if (player == null) { return false; } - int swamps = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int swamps = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (swamps < 1) { return false; } diff --git a/Mage.Sets/src/mage/cards/l/LilianaOfTheVeil.java b/Mage.Sets/src/mage/cards/l/LilianaOfTheVeil.java index bf41716944b..7772bf0952e 100644 --- a/Mage.Sets/src/mage/cards/l/LilianaOfTheVeil.java +++ b/Mage.Sets/src/mage/cards/l/LilianaOfTheVeil.java @@ -85,7 +85,7 @@ class LilianaOfTheVeilEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent(0, count, new FilterPermanent("permanents to put in the first pile"), true); List pile1 = new ArrayList<>(); target.setRequired(false); - if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Neutral, target, source, game)) { List targets = target.getTargets(); for (UUID targetId : targets) { Permanent p = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/l/LilianaTheLastHope.java b/Mage.Sets/src/mage/cards/l/LilianaTheLastHope.java index fedfde8ecd5..d216a1dfc9d 100644 --- a/Mage.Sets/src/mage/cards/l/LilianaTheLastHope.java +++ b/Mage.Sets/src/mage/cards/l/LilianaTheLastHope.java @@ -89,9 +89,9 @@ class LilianaTheLastHopeEffect extends OneShotEffect { } TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseUse(outcome, "Return a creature card from your graveyard to hand?", source, game) - && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + && controller.choose(Outcome.ReturnToHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/l/LilianaTheNecromancer.java b/Mage.Sets/src/mage/cards/l/LilianaTheNecromancer.java index 43abb3b7425..646ff5fad78 100644 --- a/Mage.Sets/src/mage/cards/l/LilianaTheNecromancer.java +++ b/Mage.Sets/src/mage/cards/l/LilianaTheNecromancer.java @@ -85,7 +85,7 @@ class LilianaTheNecromancerEffect extends OneShotEffect { } Target target = new TargetCardInGraveyard(0, 2, filter); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Cards cardsToMove = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/l/LilianasScrounger.java b/Mage.Sets/src/mage/cards/l/LilianasScrounger.java index bea115fe3ad..8058e8b2694 100644 --- a/Mage.Sets/src/mage/cards/l/LilianasScrounger.java +++ b/Mage.Sets/src/mage/cards/l/LilianasScrounger.java @@ -76,14 +76,14 @@ class LilianasScroungerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player == null || game.getBattlefield().count( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ) < 1 || !player.chooseUse( outcome, "Put a loyalty counter on a Liliana planeswalker you control?", source, game )) { return false; } TargetPermanent target = new TargetPermanent(0, 1, filter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); return permanent != null && permanent.addCounters(CounterType.LOYALTY.createInstance(), source.getControllerId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java b/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java index 2156ede808c..bdc7d33c8a8 100644 --- a/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java +++ b/Mage.Sets/src/mage/cards/l/LinessaZephyrMage.java @@ -97,7 +97,7 @@ class LinessaZephyrMageEffect extends OneShotEffect { // Target player returns a creature they control to its owner's hand, Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { targetPlayer.moveCards(permanent, Zone.HAND, source, game); @@ -109,7 +109,7 @@ class LinessaZephyrMageEffect extends OneShotEffect { filter.add(CardType.ARTIFACT.getPredicate()); target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { targetPlayer.moveCards(permanent, Zone.HAND, source, game); @@ -121,7 +121,7 @@ class LinessaZephyrMageEffect extends OneShotEffect { filter.add(CardType.ENCHANTMENT.getPredicate()); target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { targetPlayer.moveCards(permanent, Zone.HAND, source, game); @@ -133,7 +133,7 @@ class LinessaZephyrMageEffect extends OneShotEffect { filter.add(CardType.LAND.getPredicate()); target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { targetPlayer.moveCards(permanent, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/l/LivingBreakthrough.java b/Mage.Sets/src/mage/cards/l/LivingBreakthrough.java index ada98c582e5..31cc5e63f97 100644 --- a/Mage.Sets/src/mage/cards/l/LivingBreakthrough.java +++ b/Mage.Sets/src/mage/cards/l/LivingBreakthrough.java @@ -78,7 +78,7 @@ class LivingBreakthroughEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast spells with mana value " + manaValue + " this turn (" + mageObject.getIdName() + ")."; diff --git a/Mage.Sets/src/mage/cards/l/LlanowarDruid.java b/Mage.Sets/src/mage/cards/l/LlanowarDruid.java index 1ed02835f1c..d30a37f1664 100644 --- a/Mage.Sets/src/mage/cards/l/LlanowarDruid.java +++ b/Mage.Sets/src/mage/cards/l/LlanowarDruid.java @@ -72,7 +72,7 @@ class LlanowarDruidEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.untap(game); } return true; diff --git a/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java b/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java index 6e205ca21cb..9718bd8da0e 100644 --- a/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java +++ b/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java @@ -68,7 +68,7 @@ class LlanowarEmpathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (controller == null || sourceObject == null) { return false; diff --git a/Mage.Sets/src/mage/cards/l/LlawanCephalidEmpress.java b/Mage.Sets/src/mage/cards/l/LlawanCephalidEmpress.java index e8820ad3939..d5f90562e65 100644 --- a/Mage.Sets/src/mage/cards/l/LlawanCephalidEmpress.java +++ b/Mage.Sets/src/mage/cards/l/LlawanCephalidEmpress.java @@ -91,7 +91,7 @@ class LlawanCephalidRuleModifyingEffect extends ContinuousRuleModifyingEffectImp @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast blue creature spells (" + mageObject.getLogName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/l/Lobotomy.java b/Mage.Sets/src/mage/cards/l/Lobotomy.java index ecc9d919444..cf2aa8a9315 100644 --- a/Mage.Sets/src/mage/cards/l/Lobotomy.java +++ b/Mage.Sets/src/mage/cards/l/Lobotomy.java @@ -64,7 +64,7 @@ class LobotomyEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (targetPlayer != null && sourceObject != null && controller != null) { // reveal hand of target player diff --git a/Mage.Sets/src/mage/cards/l/LongRest.java b/Mage.Sets/src/mage/cards/l/LongRest.java index 6c33c98d469..0e06d2c73d2 100644 --- a/Mage.Sets/src/mage/cards/l/LongRest.java +++ b/Mage.Sets/src/mage/cards/l/LongRest.java @@ -64,7 +64,7 @@ class LongRestTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); Set manaValues = new HashSet<>(); for (UUID targetId : this.getTargets()) { @@ -73,7 +73,7 @@ class LongRestTarget extends TargetCardInYourGraveyard { manaValues.add(card.getManaValue()); } } - for (UUID possibleTargetId : super.possibleTargets(sourceId, sourceControllerId, game)) { + for (UUID possibleTargetId : super.possibleTargets(sourceControllerId, source, game)) { Card card = game.getCard(possibleTargetId); if (card != null && !manaValues.contains(card.getManaValue())) { possibleTargets.add(possibleTargetId); diff --git a/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java b/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java index fce2b0ad845..090eec0977e 100644 --- a/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java +++ b/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java @@ -86,7 +86,7 @@ class LordOfShatterskullPassEffect extends OneShotEffect { if (defenderId != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(defenderId)); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.damage(6, source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/l/LordOfThePit.java b/Mage.Sets/src/mage/cards/l/LordOfThePit.java index bf22afa10eb..d0bb22f878d 100644 --- a/Mage.Sets/src/mage/cards/l/LordOfThePit.java +++ b/Mage.Sets/src/mage/cards/l/LordOfThePit.java @@ -80,8 +80,8 @@ class LordOfThePitEffect extends OneShotEffect { filter.add(AnotherPredicate.instance); Target target = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/l/LostInTheWoods.java b/Mage.Sets/src/mage/cards/l/LostInTheWoods.java index 9f6d2e115e7..bbc4d0d2ca2 100644 --- a/Mage.Sets/src/mage/cards/l/LostInTheWoods.java +++ b/Mage.Sets/src/mage/cards/l/LostInTheWoods.java @@ -51,7 +51,7 @@ class LostInTheWoodsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null || controller == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/l/LoxodonPeacekeeper.java b/Mage.Sets/src/mage/cards/l/LoxodonPeacekeeper.java index d3d9f59c715..2ab58b39f5a 100644 --- a/Mage.Sets/src/mage/cards/l/LoxodonPeacekeeper.java +++ b/Mage.Sets/src/mage/cards/l/LoxodonPeacekeeper.java @@ -105,8 +105,8 @@ class LoxodonPeacekeeperEffect extends OneShotEffect { } } TargetPlayer target = new TargetPlayer(1, 1, true, filter); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } } else { diff --git a/Mage.Sets/src/mage/cards/l/Lucille.java b/Mage.Sets/src/mage/cards/l/Lucille.java index f13b8637d62..0d9f6d89b5e 100644 --- a/Mage.Sets/src/mage/cards/l/Lucille.java +++ b/Mage.Sets/src/mage/cards/l/Lucille.java @@ -83,10 +83,10 @@ class LucilleEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + if (!target.canChoose(player.getId(), source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); return permanent.sacrifice(source, game) && new WalkerToken().putOntoBattlefield(1, game, source, source.getControllerId() diff --git a/Mage.Sets/src/mage/cards/l/LumberingBattlement.java b/Mage.Sets/src/mage/cards/l/LumberingBattlement.java index 76767b99897..43a0161993f 100644 --- a/Mage.Sets/src/mage/cards/l/LumberingBattlement.java +++ b/Mage.Sets/src/mage/cards/l/LumberingBattlement.java @@ -106,7 +106,7 @@ class LumberingBattlementEffect extends OneShotEffect { return false; } Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - if (!player.choose(Outcome.Neutral, target, source.getSourceId(), game)) { + if (!player.choose(Outcome.Neutral, target, source, game)) { return false; } Set cards = new HashSet<>(); diff --git a/Mage.Sets/src/mage/cards/l/LuminescentRain.java b/Mage.Sets/src/mage/cards/l/LuminescentRain.java index ea5c1580f91..8f656a804b1 100644 --- a/Mage.Sets/src/mage/cards/l/LuminescentRain.java +++ b/Mage.Sets/src/mage/cards/l/LuminescentRain.java @@ -59,7 +59,7 @@ class LuminescentRainEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); if (player != null && player.choose(Outcome.BoostCreature, typeChoice, game)) { FilterControlledPermanent filter = new FilterControlledPermanent(); filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate()); diff --git a/Mage.Sets/src/mage/cards/l/LurkingPredators.java b/Mage.Sets/src/mage/cards/l/LurkingPredators.java index e9adf690e58..95777916ff9 100644 --- a/Mage.Sets/src/mage/cards/l/LurkingPredators.java +++ b/Mage.Sets/src/mage/cards/l/LurkingPredators.java @@ -59,7 +59,7 @@ class LurkingPredatorsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MagneticMountain.java b/Mage.Sets/src/mage/cards/m/MagneticMountain.java index 0287a7b0b63..e95f10e8223 100644 --- a/Mage.Sets/src/mage/cards/m/MagneticMountain.java +++ b/Mage.Sets/src/mage/cards/m/MagneticMountain.java @@ -87,7 +87,7 @@ class MagneticMountainEffect extends OneShotEffect { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter2, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.Benefit, "Pay {4} and untap a tapped blue creature under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter2, true); - if (player.choose(Outcome.Untap, tappedCreatureTarget, source.getSourceId(), game)) { + if (player.choose(Outcome.Untap, tappedCreatureTarget, source, game)) { Cost cost = ManaUtil.createManaCost(4, false); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); if (tappedCreature != null && cost.pay(source, game, source, player.getId(), false)) { diff --git a/Mage.Sets/src/mage/cards/m/MagnigothTreefolk.java b/Mage.Sets/src/mage/cards/m/MagnigothTreefolk.java index ea4e8d7d6db..a3cb6e0f08b 100644 --- a/Mage.Sets/src/mage/cards/m/MagnigothTreefolk.java +++ b/Mage.Sets/src/mage/cards/m/MagnigothTreefolk.java @@ -69,7 +69,7 @@ class MagnigothTreefolkEffect extends ContinuousEffectImpl { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .map(p -> SubType .getBasicLands() diff --git a/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java b/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java index 5e1d5d9046b..907df1ad160 100644 --- a/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java +++ b/Mage.Sets/src/mage/cards/m/MagusOfTheJar.java @@ -132,7 +132,7 @@ class MagusoftheJarDelayedEffect extends OneShotEffect { continue; } player.discard(player.getHand(), false, source, game); - player.moveCards(cards.getCards(filter, source.getSourceId(), playerId, game), Zone.HAND, source, game); + player.moveCards(cards.getCards(filter, playerId, source, game), Zone.HAND, source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/m/MagusOfTheScroll.java b/Mage.Sets/src/mage/cards/m/MagusOfTheScroll.java index 59ebe48a53e..1900ddc9618 100644 --- a/Mage.Sets/src/mage/cards/m/MagusOfTheScroll.java +++ b/Mage.Sets/src/mage/cards/m/MagusOfTheScroll.java @@ -65,7 +65,7 @@ class MagusOfTheScrollEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (sourceObject != null && you != null && cardName != null && !cardName.isEmpty()) { if (!you.getHand().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/m/MairsilThePretender.java b/Mage.Sets/src/mage/cards/m/MairsilThePretender.java index 7329c29521e..c5102ddb7de 100644 --- a/Mage.Sets/src/mage/cards/m/MairsilThePretender.java +++ b/Mage.Sets/src/mage/cards/m/MairsilThePretender.java @@ -93,11 +93,11 @@ class MairsilThePretenderExileEffect extends OneShotEffect { if (controller.chooseUse(Outcome.Detriment, "Exile a card from your hand? (No = from graveyard)", source, game)) { // from hand target = new TargetCardInHand(0, 1, filter); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); } else { // from graveyard target = new TargetCardInYourGraveyard(0, 1, filter); - target.choose(outcome, source.getControllerId(), source.getSourceId(), game); + target.choose(outcome, source.getControllerId(), source.getSourceId(), source, game); } Card card = controller.getHand().get(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/m/ManaBreach.java b/Mage.Sets/src/mage/cards/m/ManaBreach.java index 9134774fdfe..c9eea4fabdb 100644 --- a/Mage.Sets/src/mage/cards/m/ManaBreach.java +++ b/Mage.Sets/src/mage/cards/m/ManaBreach.java @@ -61,13 +61,13 @@ class ManaBreachEffect extends OneShotEffect { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), player.getId(), game + player.getId(), source, game ) < 1) { return false; } TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return player.moveCards(game.getPermanent(target.getFirstTarget()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/m/ManaVortex.java b/Mage.Sets/src/mage/cards/m/ManaVortex.java index 24b0dbd401b..01efb4e7a89 100644 --- a/Mage.Sets/src/mage/cards/m/ManaVortex.java +++ b/Mage.Sets/src/mage/cards/m/ManaVortex.java @@ -123,7 +123,7 @@ class ManaVortexStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().count(StaticFilters.FILTER_LANDS, this.getSourceId(), this.getControllerId(), game) == 0; + return game.getBattlefield().count(StaticFilters.FILTER_LANDS, this.getControllerId(), this, game) == 0; } @Override diff --git a/Mage.Sets/src/mage/cards/m/ManaWeb.java b/Mage.Sets/src/mage/cards/m/ManaWeb.java index 4e1709a9cc9..73567bf953b 100644 --- a/Mage.Sets/src/mage/cards/m/ManaWeb.java +++ b/Mage.Sets/src/mage/cards/m/ManaWeb.java @@ -112,7 +112,7 @@ class ManaWebeffect extends OneShotEffect { boolean tappedLands = false; for (Permanent opponentPermanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - permanent.getControllerId(), source.getSourceId(), game + permanent.getControllerId(), source, game )) { Set manaTypes = AnyColorLandsProduceManaAbility.getManaTypesFromPermanent(opponentPermanent, game); if (!Collections.disjoint(manaTypes, manaTypesSource)) { diff --git a/Mage.Sets/src/mage/cards/m/ManascapeRefractor.java b/Mage.Sets/src/mage/cards/m/ManascapeRefractor.java index 1dd80ca1346..076f44dda0a 100644 --- a/Mage.Sets/src/mage/cards/m/ManascapeRefractor.java +++ b/Mage.Sets/src/mage/cards/m/ManascapeRefractor.java @@ -77,7 +77,7 @@ class ManascapeRefractorGainAbilitiesEffect extends ContinuousEffectImpl { } for (Ability ability : game.getState() .getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game) + .getActivePermanents(filter, source.getControllerId(), source, game) .stream() .map(permanent -> permanent.getAbilities(game)) .flatMap(Collection::stream) diff --git a/Mage.Sets/src/mage/cards/m/MandateOfPeace.java b/Mage.Sets/src/mage/cards/m/MandateOfPeace.java index c763b0c8f9e..1c707ce2882 100644 --- a/Mage.Sets/src/mage/cards/m/MandateOfPeace.java +++ b/Mage.Sets/src/mage/cards/m/MandateOfPeace.java @@ -73,7 +73,7 @@ class MandateOfPeaceOpponentsCantCastSpellsEffect extends ContinuousRuleModifyin @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/m/MantleOfTheAncients.java b/Mage.Sets/src/mage/cards/m/MantleOfTheAncients.java index f37062f168a..6c8cc3da6d6 100644 --- a/Mage.Sets/src/mage/cards/m/MantleOfTheAncients.java +++ b/Mage.Sets/src/mage/cards/m/MantleOfTheAncients.java @@ -95,7 +95,7 @@ class MantleOfTheAncientsEffect extends OneShotEffect { FilterCard filter = new FilterCard("Aura or Equipment card that can be attached to " + permanent.getName()); filter.add(new MantleOfTheAncientsPredicate(permanent)); TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Cards cards = new CardsImpl(target.getTargets()); if (cards.isEmpty()) { return false; diff --git a/Mage.Sets/src/mage/cards/m/MarangRiverProwler.java b/Mage.Sets/src/mage/cards/m/MarangRiverProwler.java index 93319975761..a410726cdc9 100644 --- a/Mage.Sets/src/mage/cards/m/MarangRiverProwler.java +++ b/Mage.Sets/src/mage/cards/m/MarangRiverProwler.java @@ -91,7 +91,7 @@ class MarangRiverProwlerCastEffect extends AsThoughEffectImpl { if (card != null && card.isOwnedBy(affectedControllerId) && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD - && game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + && game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0) { return true; } } diff --git a/Mage.Sets/src/mage/cards/m/MarchFromTheTomb.java b/Mage.Sets/src/mage/cards/m/MarchFromTheTomb.java index 9288987ed6b..9e017de387c 100644 --- a/Mage.Sets/src/mage/cards/m/MarchFromTheTomb.java +++ b/Mage.Sets/src/mage/cards/m/MarchFromTheTomb.java @@ -56,7 +56,7 @@ class MarchFromTheTombTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { int cmcLeft = 8; for (UUID targetId : this.getTargets()) { Card card = game.getCard(targetId); @@ -64,7 +64,7 @@ class MarchFromTheTombTarget extends TargetCardInYourGraveyard { cmcLeft -= card.getManaValue(); } } - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Set leftPossibleTargets = new HashSet<>(); for (UUID targetId : possibleTargets) { Card card = game.getCard(targetId); diff --git a/Mage.Sets/src/mage/cards/m/MarchOfSouls.java b/Mage.Sets/src/mage/cards/m/MarchOfSouls.java index b0337f4bff4..183ed39b85b 100644 --- a/Mage.Sets/src/mage/cards/m/MarchOfSouls.java +++ b/Mage.Sets/src/mage/cards/m/MarchOfSouls.java @@ -59,7 +59,7 @@ class MarchOfSoulsEffect extends OneShotEffect { Map playersWithCreatures = new HashMap<>(); for (Permanent p : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_PERMANENT_CREATURES, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { UUID controllerId = p.getControllerId(); if (p.destroy(source, game, true)) { diff --git a/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java b/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java index a3d30b01d4c..8fc7f6aa9f4 100644 --- a/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java +++ b/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java @@ -66,7 +66,7 @@ class MarshalingTheTroopsEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, MarshalingTheTroops.filter, true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); if (target.getTargets().isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MartialImpetus.java b/Mage.Sets/src/mage/cards/m/MartialImpetus.java index 7770b595339..0516b0fae56 100644 --- a/Mage.Sets/src/mage/cards/m/MartialImpetus.java +++ b/Mage.Sets/src/mage/cards/m/MartialImpetus.java @@ -72,7 +72,7 @@ enum MartialImpetusPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent martialImpetus = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent martialImpetus = input.getSource().getSourcePermanentOrLKI(game); if (martialImpetus != null) { Permanent attachedTo = game.getPermanentOrLKIBattlefield(martialImpetus.getAttachedTo()); UUID auraControllerId = martialImpetus.getControllerId(); diff --git a/Mage.Sets/src/mage/cards/m/Martyrdom.java b/Mage.Sets/src/mage/cards/m/Martyrdom.java index 760afe28229..789fe2ff0a8 100644 --- a/Mage.Sets/src/mage/cards/m/Martyrdom.java +++ b/Mage.Sets/src/mage/cards/m/Martyrdom.java @@ -1,7 +1,6 @@ package mage.cards.m; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.mana.GenericManaCost; @@ -9,13 +8,7 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.RedirectionEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; @@ -23,8 +16,9 @@ import mage.game.permanent.Permanent; import mage.target.common.TargetAnyTarget; import mage.target.common.TargetControlledCreaturePermanent; +import java.util.UUID; + /** - * * @author L_J */ public final class Martyrdom extends CardImpl { @@ -78,7 +72,6 @@ class MartyrdomGainAbilityTargetEffect extends ContinuousEffectImpl { class MartyrdomActivatedAbility extends ActivatedAbilityImpl { - private static FilterCreaturePermanent filter = new FilterCreaturePermanent(); private UUID caster; public MartyrdomActivatedAbility(UUID caster) { @@ -94,15 +87,14 @@ class MartyrdomActivatedAbility extends ActivatedAbilityImpl { @Override public ActivationStatus canActivate(UUID playerId, Game game) { - if (playerId.equals(caster)) { - Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId()); - if (permanent != null) { - if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { - return super.canActivate(playerId, game); - } - } + if (!playerId.equals(caster)) { + return ActivationStatus.getFalse(); } - return ActivationStatus.getFalse(); + Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId()); + if (permanent == null || !permanent.isCreature(game)) { + return ActivationStatus.getFalse(); + } + return super.canActivate(playerId, game); } @Override @@ -138,7 +130,7 @@ class MartyrdomRedirectDamageTargetEffect extends RedirectionEffect { public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { - if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { + if (filter.match(permanent, permanent.getControllerId(), source, game)) { if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { if (event.getTargetId() != null) { TargetAnyTarget target = new TargetAnyTarget(); diff --git a/Mage.Sets/src/mage/cards/m/MartyrsBond.java b/Mage.Sets/src/mage/cards/m/MartyrsBond.java index 2b9d47bb5ce..a152e19f225 100644 --- a/Mage.Sets/src/mage/cards/m/MartyrsBond.java +++ b/Mage.Sets/src/mage/cards/m/MartyrsBond.java @@ -135,7 +135,7 @@ class MartyrsBondEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null && !playerId.equals(controller.getId())) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), playerId, game)) { + if (target.canChoose(playerId, source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.add(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/m/MartyrsCry.java b/Mage.Sets/src/mage/cards/m/MartyrsCry.java index 2d7e1adeed5..b5928415c93 100644 --- a/Mage.Sets/src/mage/cards/m/MartyrsCry.java +++ b/Mage.Sets/src/mage/cards/m/MartyrsCry.java @@ -75,7 +75,7 @@ class MartyrsCryEffect extends OneShotEffect { return false; } List permanents = game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ); Map playerMap = permanents .stream() diff --git a/Mage.Sets/src/mage/cards/m/MasterOfArms.java b/Mage.Sets/src/mage/cards/m/MasterOfArms.java index 650ba2fa18b..1fbef160b7a 100644 --- a/Mage.Sets/src/mage/cards/m/MasterOfArms.java +++ b/Mage.Sets/src/mage/cards/m/MasterOfArms.java @@ -1,7 +1,5 @@ - package mage.cards.m; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -12,19 +10,26 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author LoneFox */ public final class MasterOfArms extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); + } + public MasterOfArms(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.SOLDIER); this.power = new MageInt(2); @@ -32,11 +37,10 @@ public final class MasterOfArms extends CardImpl { // First strike this.addAbility(FirstStrikeAbility.getInstance()); + // {1}{W}: Tap target creature blocking Master of Arms. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TapTargetEffect(), new ManaCostsImpl("{1}{W}")); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking {this}"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new TapTargetEffect(), new ManaCostsImpl<>("{1}{W}")); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java index f8451295410..8e1af2b218f 100644 --- a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java +++ b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java @@ -116,7 +116,7 @@ class MasterWarcraftChooseAttackersEffect extends ContinuousRuleModifyingEffectI if (!controller.chooseTarget(Outcome.Benefit, target, source, game)) { return false; // the attack declaration resumes for the active player as normal } - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source, game)) { // Choose creatures that will be attacking this combat if (target.getTargets().contains(permanent.getId())) { diff --git a/Mage.Sets/src/mage/cards/m/MeasureOfWickedness.java b/Mage.Sets/src/mage/cards/m/MeasureOfWickedness.java index 499dcd2bc31..0bcfd0d637c 100644 --- a/Mage.Sets/src/mage/cards/m/MeasureOfWickedness.java +++ b/Mage.Sets/src/mage/cards/m/MeasureOfWickedness.java @@ -19,7 +19,7 @@ import mage.constants.SubLayer; import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -34,7 +34,7 @@ public final class MeasureOfWickedness extends CardImpl { private static final FilterCard filter = new FilterCard("another card"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public MeasureOfWickedness(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/m/MeddlingMage.java b/Mage.Sets/src/mage/cards/m/MeddlingMage.java index fbe56650a40..ddd4654e737 100644 --- a/Mage.Sets/src/mage/cards/m/MeddlingMage.java +++ b/Mage.Sets/src/mage/cards/m/MeddlingMage.java @@ -70,7 +70,7 @@ class MeddlingMageReplacementEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast a spell with that name (" + mageObject.getName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/m/Melting.java b/Mage.Sets/src/mage/cards/m/Melting.java index c1827df03cd..ff759cdf784 100644 --- a/Mage.Sets/src/mage/cards/m/Melting.java +++ b/Mage.Sets/src/mage/cards/m/Melting.java @@ -61,7 +61,7 @@ class MeltingEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.getSuperType().remove(SuperType.SNOW); } return true; diff --git a/Mage.Sets/src/mage/cards/m/MemoryJar.java b/Mage.Sets/src/mage/cards/m/MemoryJar.java index 66876a13891..d5aa4537057 100644 --- a/Mage.Sets/src/mage/cards/m/MemoryJar.java +++ b/Mage.Sets/src/mage/cards/m/MemoryJar.java @@ -131,7 +131,7 @@ class MemoryJarDelayedEffect extends OneShotEffect { continue; } player.discard(player.getHand(), false, source, game); - player.moveCards(cards.getCards(filter, source.getSourceId(), playerId, game), Zone.HAND, source, game); + player.moveCards(cards.getCards(filter, playerId, source, game), Zone.HAND, source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/m/MemoryTheft.java b/Mage.Sets/src/mage/cards/m/MemoryTheft.java index ae3d3ec6007..ea88bfaf0c4 100644 --- a/Mage.Sets/src/mage/cards/m/MemoryTheft.java +++ b/Mage.Sets/src/mage/cards/m/MemoryTheft.java @@ -77,8 +77,8 @@ class MemoryTheftEffect extends OneShotEffect { filter.add(AdventurePredicate.instance); filter.add(new OwnerIdPredicate(player.getId())); TargetCard target = new TargetCardInExile(0, 1, filter, null, true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game) - || !controller.choose(outcome, target, source.getSourceId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game) + || !controller.choose(outcome, target, source, game)) { return false; } Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/m/MercadianLift.java b/Mage.Sets/src/mage/cards/m/MercadianLift.java index 57cbc2c200f..2820d04314b 100644 --- a/Mage.Sets/src/mage/cards/m/MercadianLift.java +++ b/Mage.Sets/src/mage/cards/m/MercadianLift.java @@ -85,9 +85,9 @@ class MercadianLiftEffect extends OneShotEffect { filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, numberOfCounters)); filter.setMessage("creature card with mana value " + numberOfCounters); TargetCardInHand target = new TargetCardInHand(filter); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game) - && controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + && controller.choose(Outcome.PutCardInPlay, target, source, game)) { target.setRequired(false); Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java b/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java index b61b910d7ff..91f8459dd9c 100644 --- a/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java +++ b/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java @@ -74,7 +74,7 @@ class MerchantsDockhandEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } @@ -129,7 +129,7 @@ class TapXTargetCost extends VariableCostImpl { @Override public int getMaxValue(Ability source, Game game) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + return game.getBattlefield().count(filter, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/m/MetallurgicSummonings.java b/Mage.Sets/src/mage/cards/m/MetallurgicSummonings.java index c3916cadfe6..cc1da00503e 100644 --- a/Mage.Sets/src/mage/cards/m/MetallurgicSummonings.java +++ b/Mage.Sets/src/mage/cards/m/MetallurgicSummonings.java @@ -115,8 +115,8 @@ class MetallurgicSummoningsReturnEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - return controller.moveCards(controller.getGraveyard().getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), - source.getControllerId(), game), Zone.HAND, source, game); + return controller.moveCards(controller.getGraveyard().getCards(new FilterInstantOrSorceryCard(), + source.getControllerId(), source, game), Zone.HAND, source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/m/MetalworkColossus.java b/Mage.Sets/src/mage/cards/m/MetalworkColossus.java index ac9e1e7a841..2f1ccbd1152 100644 --- a/Mage.Sets/src/mage/cards/m/MetalworkColossus.java +++ b/Mage.Sets/src/mage/cards/m/MetalworkColossus.java @@ -72,7 +72,7 @@ class MetalworkColossusCostReductionEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { int totalCMC = 0; - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { totalCMC += permanent.getManaValue(); } CardUtil.reduceCost(abilityToModify, totalCMC); diff --git a/Mage.Sets/src/mage/cards/m/Metalworker.java b/Mage.Sets/src/mage/cards/m/Metalworker.java index dbf1542a47d..efb1da4e438 100644 --- a/Mage.Sets/src/mage/cards/m/Metalworker.java +++ b/Mage.Sets/src/mage/cards/m/Metalworker.java @@ -95,7 +95,7 @@ class MetalworkerManaEffect extends ManaEffect { int artifacts = controller.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game); if (artifacts > 0) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_ARTIFACT); - if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Benefit, target, source, game)) { Cards cards = new CardsImpl(target.getTargets()); controller.revealCards(source, cards, game); return Mana.ColorlessMana(target.getTargets().size() * 2); diff --git a/Mage.Sets/src/mage/cards/m/MetamorphicAlteration.java b/Mage.Sets/src/mage/cards/m/MetamorphicAlteration.java index 0b7805593a6..a03bce8582d 100644 --- a/Mage.Sets/src/mage/cards/m/MetamorphicAlteration.java +++ b/Mage.Sets/src/mage/cards/m/MetamorphicAlteration.java @@ -72,7 +72,7 @@ class ChooseACreature extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getPermanentEntering(source.getSourceId()); if (sourceObject == null) { - sourceObject = game.getObject(source.getSourceId()); + sourceObject = game.getObject(source); } if (controller == null || sourceObject == null) { @@ -80,10 +80,10 @@ class ChooseACreature extends OneShotEffect { } Target target = new TargetCreaturePermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (!target.canChoose(controller.getId(), source, game)) { return true; } - controller.choose(Outcome.Copy, target, source.getSourceId(), game); + controller.choose(Outcome.Copy, target, source, game); Permanent chosenPermanent = game.getPermanent(target.getFirstTarget()); if (chosenPermanent != null) { game.getState().setValue(source.getSourceId().toString() + INFO_KEY, chosenPermanent.copy()); diff --git a/Mage.Sets/src/mage/cards/m/MidnightArsonist.java b/Mage.Sets/src/mage/cards/m/MidnightArsonist.java index f65ca30b814..2bea621b657 100644 --- a/Mage.Sets/src/mage/cards/m/MidnightArsonist.java +++ b/Mage.Sets/src/mage/cards/m/MidnightArsonist.java @@ -65,7 +65,7 @@ enum MidnightArsonistAdjuster implements TargetAdjuster { @Override public void adjustTargets(Ability ability, Game game) { - int vampires = game.getBattlefield().count(filter, ability.getSourceId(), ability.getControllerId(), game); + int vampires = game.getBattlefield().count(filter, ability.getControllerId(), ability, game); ability.getTargets().clear(); ability.addTarget(new TargetPermanent(0, vampires, filter2)); } diff --git a/Mage.Sets/src/mage/cards/m/MightMakesRight.java b/Mage.Sets/src/mage/cards/m/MightMakesRight.java index 0e6054e7a38..39778cbe061 100644 --- a/Mage.Sets/src/mage/cards/m/MightMakesRight.java +++ b/Mage.Sets/src/mage/cards/m/MightMakesRight.java @@ -65,7 +65,7 @@ enum ControlsEachCreatureWithGreatestPowerCondition implements Condition { public boolean apply(Game game, Ability source) { Integer maxPower = null; boolean result = false; - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/m/MilitiasPride.java b/Mage.Sets/src/mage/cards/m/MilitiasPride.java index 6a6723d8fbc..0fddaca3ee7 100644 --- a/Mage.Sets/src/mage/cards/m/MilitiasPride.java +++ b/Mage.Sets/src/mage/cards/m/MilitiasPride.java @@ -62,7 +62,7 @@ class MilitiasPrideTriggerAbility extends TriggeredAbilityImpl { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); filter.add(TokenPredicate.FALSE); Permanent permanent = game.getPermanent(event.getSourceId()); - return permanent != null && filter.match(permanent, sourceId, controllerId, game); + return permanent != null && filter.match(permanent, controllerId, this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/m/MinamosMeddling.java b/Mage.Sets/src/mage/cards/m/MinamosMeddling.java index f7a479c444b..1a0ae290801 100644 --- a/Mage.Sets/src/mage/cards/m/MinamosMeddling.java +++ b/Mage.Sets/src/mage/cards/m/MinamosMeddling.java @@ -56,7 +56,7 @@ class MinamosMeddlingCounterTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MinionOfTheMighty.java b/Mage.Sets/src/mage/cards/m/MinionOfTheMighty.java index 098e7f691d2..6420b9064e4 100644 --- a/Mage.Sets/src/mage/cards/m/MinionOfTheMighty.java +++ b/Mage.Sets/src/mage/cards/m/MinionOfTheMighty.java @@ -79,7 +79,7 @@ class MinionOfTheMightyEffect extends OneShotEffect { if (controller == null) { return false; } - target.choose(outcome, controller.getId(), source.getSourceId(), game); + target.choose(outcome, controller.getId(), source.getSourceId(), source, game); Card card = controller.getHand().get(target.getFirstTarget(), game); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/m/MirrodinBesieged.java b/Mage.Sets/src/mage/cards/m/MirrodinBesieged.java index 7b3b4aa04a8..e1d44f3ec3e 100644 --- a/Mage.Sets/src/mage/cards/m/MirrodinBesieged.java +++ b/Mage.Sets/src/mage/cards/m/MirrodinBesieged.java @@ -92,7 +92,7 @@ class MirrodinBesiegedEffect extends OneShotEffect { if (player == null || opponent == null) { return false; } - if (player.getGraveyard().getCards(StaticFilters.FILTER_CARD_ARTIFACT, source.getSourceId(), source.getControllerId(), game).size() >= 15) { + if (player.getGraveyard().getCards(StaticFilters.FILTER_CARD_ARTIFACT, source.getControllerId(), source, game).size() >= 15) { opponent.lost(game); } return true; diff --git a/Mage.Sets/src/mage/cards/m/MirrorBox.java b/Mage.Sets/src/mage/cards/m/MirrorBox.java index e4748264444..e5af340a22f 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorBox.java +++ b/Mage.Sets/src/mage/cards/m/MirrorBox.java @@ -112,10 +112,10 @@ class MirrorBoxBoostEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { List permanents = game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ); for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { int amount = getAmount(permanents, permanent, game); permanent.addPower(amount); diff --git a/Mage.Sets/src/mage/cards/m/MirrorEntity.java b/Mage.Sets/src/mage/cards/m/MirrorEntity.java index 2e616b5b630..1fbc00356a5 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorEntity.java +++ b/Mage.Sets/src/mage/cards/m/MirrorEntity.java @@ -74,7 +74,7 @@ class MirrorEntityEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); for (Permanent perm : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURES, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_CREATURES, source.getControllerId(), source, game )) { affectedObjectList.add(new MageObjectReference(perm, game)); } diff --git a/Mage.Sets/src/mage/cards/m/MirrorOfFate.java b/Mage.Sets/src/mage/cards/m/MirrorOfFate.java index 59a89973f76..129c0b09c4e 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorOfFate.java +++ b/Mage.Sets/src/mage/cards/m/MirrorOfFate.java @@ -73,7 +73,7 @@ class MirrorOfFateEffect extends OneShotEffect { // Choose up to seven face-up exiled cards you own CardsImpl cards = new CardsImpl(); MirrorOfFateTarget targetExile = new MirrorOfFateTarget(); - if (controller.choose(outcome, targetExile, source.getSourceId(), game)) { + if (controller.choose(outcome, targetExile, source, game)) { cards.addAll(targetExile.getTargets()); } // Exile all the cards from your library diff --git a/Mage.Sets/src/mage/cards/m/MirrorwingDragon.java b/Mage.Sets/src/mage/cards/m/MirrorwingDragon.java index 276d36347be..f0a073dcbe5 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorwingDragon.java +++ b/Mage.Sets/src/mage/cards/m/MirrorwingDragon.java @@ -147,7 +147,7 @@ class MirrorwingDragonCopySpellEffect extends CopySpellForEachItCouldTargetEffec return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - player.getId(), source.getSourceId(), game + player.getId(), source, game ).stream() .filter(Objects::nonNull) .filter(p -> !p.equals(permanent)) diff --git a/Mage.Sets/src/mage/cards/m/MissionBriefing.java b/Mage.Sets/src/mage/cards/m/MissionBriefing.java index ad927f71f81..e35936a7a1a 100644 --- a/Mage.Sets/src/mage/cards/m/MissionBriefing.java +++ b/Mage.Sets/src/mage/cards/m/MissionBriefing.java @@ -73,7 +73,7 @@ class MissionBriefingEffect extends OneShotEffect { player.surveil(2, source, game); Target target = new TargetCardInYourGraveyard( new FilterInstantOrSorceryCard("instant or sorcery card from your graveyard")); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return true; } Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/m/Mistfolk.java b/Mage.Sets/src/mage/cards/m/Mistfolk.java index f4b6c58b68b..9d7ad8921d0 100644 --- a/Mage.Sets/src/mage/cards/m/Mistfolk.java +++ b/Mage.Sets/src/mage/cards/m/Mistfolk.java @@ -65,7 +65,7 @@ enum MistfolkPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourceObject = game.getPermanent(input.getSourceId()); + Permanent sourceObject = input.getSource().getSourcePermanentIfItStillExists(game); if (sourceObject == null || input.getObject() == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MistformWarchief.java b/Mage.Sets/src/mage/cards/m/MistformWarchief.java index bc6260c717f..6a5fc06e793 100644 --- a/Mage.Sets/src/mage/cards/m/MistformWarchief.java +++ b/Mage.Sets/src/mage/cards/m/MistformWarchief.java @@ -62,7 +62,7 @@ class MistformWarchiefPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - MageObject sourceObject = game.getObject(input.getSourceId()); + MageObject sourceObject = input.getSource().getSourceObject(game); return sourceObject != null && sourceObject.shareCreatureTypes(game, input.getObject()); } diff --git a/Mage.Sets/src/mage/cards/m/MitoticManipulation.java b/Mage.Sets/src/mage/cards/m/MitoticManipulation.java index 19e57b7565b..c9a6cf9fe2d 100644 --- a/Mage.Sets/src/mage/cards/m/MitoticManipulation.java +++ b/Mage.Sets/src/mage/cards/m/MitoticManipulation.java @@ -80,7 +80,7 @@ class MitoticManipulationEffect extends OneShotEffect { if (!namePredicates.isEmpty() && !cardsFromTop.isEmpty()) { filter.add(Predicates.or(namePredicates)); TargetCard target = new TargetCard(Zone.LIBRARY, filter); - if (cardsFromTop.count(filter, source.getSourceId(), source.getControllerId(), game) > 0 + if (cardsFromTop.count(filter, source.getControllerId(), source, game) > 0 && controller.chooseUse(Outcome.PutCardInPlay, "Put a card on the battlefield?", source, game)) { if (controller.choose(Outcome.PutCardInPlay, cardsFromTop, target, game)) { Card card = cardsFromTop.get(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java b/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java index b5bc737a42c..93dc1c03861 100644 --- a/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java +++ b/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java @@ -109,11 +109,11 @@ class MizzixOfTheIzmagnusCostReductionEffect extends CostModificationEffectImpl if (abilityToModify instanceof SpellAbility && abilityToModify.isControlledBy(source.getControllerId())) { Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); if (spell != null) { - return StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(spell, source.getSourceId(), source.getControllerId(), game); + return StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(spell, source.getControllerId(), source, game); } else if (game.inCheckPlayableState()) { // Spell is not on the stack yet, but possible playable spells are determined Card sourceCard = game.getCard(abilityToModify.getSourceId()); - return sourceCard != null && StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(sourceCard, source.getSourceId(), source.getControllerId(), game); + return sourceCard != null && StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(sourceCard, source.getControllerId(), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/m/MizzixsMastery.java b/Mage.Sets/src/mage/cards/m/MizzixsMastery.java index 9dd993e1587..91855af4a0d 100644 --- a/Mage.Sets/src/mage/cards/m/MizzixsMastery.java +++ b/Mage.Sets/src/mage/cards/m/MizzixsMastery.java @@ -118,7 +118,7 @@ class MizzixsMasteryOverloadEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Set cardsToExile = controller.getGraveyard().getCards( - new FilterInstantOrSorceryCard(), source.getId(), source.getControllerId(), game); + new FilterInstantOrSorceryCard(), source.getControllerId(), source, game); if (!cardsToExile.isEmpty()) { if (controller.moveCards(cardsToExile, Zone.EXILED, source, game)) { Cards copiedCards = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/m/MogisGodOfSlaughter.java b/Mage.Sets/src/mage/cards/m/MogisGodOfSlaughter.java index 3911453757e..57eb1ce009e 100644 --- a/Mage.Sets/src/mage/cards/m/MogisGodOfSlaughter.java +++ b/Mage.Sets/src/mage/cards/m/MogisGodOfSlaughter.java @@ -85,9 +85,9 @@ class MogisGodOfSlaughterEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(1); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game) + if (target.canChoose(player.getId(), source, game) && player.chooseUse(Outcome.Detriment, "Sacrifice a creature to prevent 2 damage?", source, game) - && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + && player.choose(Outcome.Sacrifice, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && permanent.sacrifice(source, game)) { return true; diff --git a/Mage.Sets/src/mage/cards/m/MomirVigSimicVisionary.java b/Mage.Sets/src/mage/cards/m/MomirVigSimicVisionary.java index fe4eadf03d2..ddd0da64c92 100644 --- a/Mage.Sets/src/mage/cards/m/MomirVigSimicVisionary.java +++ b/Mage.Sets/src/mage/cards/m/MomirVigSimicVisionary.java @@ -88,7 +88,7 @@ class MomirVigSimicVisionaryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MonkeyMonkeyMonkey.java b/Mage.Sets/src/mage/cards/m/MonkeyMonkeyMonkey.java index 03d34fe6123..effffe74819 100644 --- a/Mage.Sets/src/mage/cards/m/MonkeyMonkeyMonkey.java +++ b/Mage.Sets/src/mage/cards/m/MonkeyMonkeyMonkey.java @@ -74,7 +74,7 @@ class ChooseLetterEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } ChoiceImpl choice = new ChoiceImpl(true); @@ -121,7 +121,7 @@ class MonkeyMonkeyMonkeyCount implements DynamicValue { Permanent permanent = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId()); if (permanent != null && game.getState().getValue(mageObject.getId() + "_letter") != null) { int letters = 0; - for (Permanent p : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), sourceAbility.getControllerId(), sourceAbility.getSourceId(), game)) { + for (Permanent p : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), sourceAbility.getControllerId(), sourceAbility, game)) { char initial = Character.toUpperCase(p.getName().charAt(0)); if (Character.toString(initial).equals(game.getState().getValue(mageObject.getId() + "_letter"))) { letters++; diff --git a/Mage.Sets/src/mage/cards/m/Moonhold.java b/Mage.Sets/src/mage/cards/m/Moonhold.java index 06fae7fd0e4..d1d169b00bc 100644 --- a/Mage.Sets/src/mage/cards/m/Moonhold.java +++ b/Mage.Sets/src/mage/cards/m/Moonhold.java @@ -77,7 +77,7 @@ class MoonholdEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "you can't play land cards this turn (" + mageObject.getIdName() + ")."; } @@ -120,7 +120,7 @@ class MoonholdEffect2 extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't play creature cards this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/m/MossbridgeTroll.java b/Mage.Sets/src/mage/cards/m/MossbridgeTroll.java index 028d0f8ad19..0db551b9830 100644 --- a/Mage.Sets/src/mage/cards/m/MossbridgeTroll.java +++ b/Mage.Sets/src/mage/cards/m/MossbridgeTroll.java @@ -119,7 +119,7 @@ class MossbridgeTrollCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { int sumPower = 0; - if (targets.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : targets.get(0).getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null && permanent.tap(source, game)) { diff --git a/Mage.Sets/src/mage/cards/m/MosswortBridge.java b/Mage.Sets/src/mage/cards/m/MosswortBridge.java index 70879f132aa..d6aa8d96cec 100644 --- a/Mage.Sets/src/mage/cards/m/MosswortBridge.java +++ b/Mage.Sets/src/mage/cards/m/MosswortBridge.java @@ -60,7 +60,7 @@ enum MosswortBridgeTotalPowerCondition implements Condition { int totalPower = 0; for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { totalPower += permanent.getPower().getValue(); if (totalPower >= 10) { diff --git a/Mage.Sets/src/mage/cards/m/MournersShield.java b/Mage.Sets/src/mage/cards/m/MournersShield.java index c486c4fe9f2..0eeb80160b7 100644 --- a/Mage.Sets/src/mage/cards/m/MournersShield.java +++ b/Mage.Sets/src/mage/cards/m/MournersShield.java @@ -141,7 +141,7 @@ class MournersShieldEffect extends PreventionEffectImpl { FilterObject filterObject = new FilterObject("a source of your choice that shares a color with the exiled card"); filterObject.add(new SharesColorPredicate(colorsAmongImprinted)); this.target = new TargetSource(filterObject); - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); if (target.getFirstTarget() != null) { mageObjectReference = new MageObjectReference(target.getFirstTarget(), game); } else { diff --git a/Mage.Sets/src/mage/cards/m/MuYanling.java b/Mage.Sets/src/mage/cards/m/MuYanling.java index 60f0889275b..8da9ea636ac 100644 --- a/Mage.Sets/src/mage/cards/m/MuYanling.java +++ b/Mage.Sets/src/mage/cards/m/MuYanling.java @@ -72,7 +72,7 @@ class MuYanlingEffect extends OneShotEffect { if (player == null) { return false; } - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, player.getId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, player.getId(), source, game)) { creature.tap(source, game); } return new AddExtraTurnControllerEffect().apply(game, source); diff --git a/Mage.Sets/src/mage/cards/m/Mudslide.java b/Mage.Sets/src/mage/cards/m/Mudslide.java index 7e890bdd832..440c02227fd 100644 --- a/Mage.Sets/src/mage/cards/m/Mudslide.java +++ b/Mage.Sets/src/mage/cards/m/Mudslide.java @@ -87,7 +87,7 @@ class MudslideEffect extends OneShotEffect { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.Benefit, "Pay {2} and untap a tapped creature without flying under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (player.choose(Outcome.Untap, tappedCreatureTarget, source.getSourceId(), game)) { + if (player.choose(Outcome.Untap, tappedCreatureTarget, source, game)) { Cost cost = ManaUtil.createManaCost(2, false); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); if (tappedCreature != null && cost.pay(source, game, source, player.getId(), false)) { diff --git a/Mage.Sets/src/mage/cards/m/MultanisDecree.java b/Mage.Sets/src/mage/cards/m/MultanisDecree.java index 62c174b36c2..78dde7d0c5a 100644 --- a/Mage.Sets/src/mage/cards/m/MultanisDecree.java +++ b/Mage.Sets/src/mage/cards/m/MultanisDecree.java @@ -57,7 +57,7 @@ class MultanisDecreeDestroyEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); int enchantmentsDestoyed = 0; - for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) { if (permanent.destroy(source, game, false)) { enchantmentsDestoyed++; } diff --git a/Mage.Sets/src/mage/cards/m/MultipleChoice.java b/Mage.Sets/src/mage/cards/m/MultipleChoice.java index bb75538f475..ccf734e83aa 100644 --- a/Mage.Sets/src/mage/cards/m/MultipleChoice.java +++ b/Mage.Sets/src/mage/cards/m/MultipleChoice.java @@ -80,17 +80,17 @@ class MultipleChoiceEffect extends OneShotEffect { return true; } TargetPlayer targetPlayer = new TargetPlayer(0, 1, true); - controller.choose(Outcome.Detriment, targetPlayer, source.getSourceId(), game); + controller.choose(Outcome.Detriment, targetPlayer, source, game); Player player = game.getPlayer(targetPlayer.getFirstTarget()); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), player.getId(), game + player.getId(), source, game ) <= 0) { return true; } TargetPermanent targetPermanent = new TargetControlledCreaturePermanent(); targetPermanent.setNotTarget(true); - player.choose(Outcome.ReturnToHand, targetPermanent, source.getSourceId(), game); + player.choose(Outcome.ReturnToHand, targetPermanent, source, game); Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget()); return permanent == null || player.moveCards(permanent, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/m/MundaAmbushLeader.java b/Mage.Sets/src/mage/cards/m/MundaAmbushLeader.java index 9e6f03dc56f..a6caec000a5 100644 --- a/Mage.Sets/src/mage/cards/m/MundaAmbushLeader.java +++ b/Mage.Sets/src/mage/cards/m/MundaAmbushLeader.java @@ -74,7 +74,7 @@ class MundaAmbushLeaderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards allCards = new CardsImpl(); allCards.addAll(controller.getLibrary().getTopCards(game, 4)); diff --git a/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java b/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java index eb0a0e2ce51..dabb9ab700d 100644 --- a/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java +++ b/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java @@ -62,7 +62,7 @@ class MurmursFromBeyondEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3)); if (!cards.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/m/MuseVessel.java b/Mage.Sets/src/mage/cards/m/MuseVessel.java index 14f48561338..ce7cbfb70ff 100644 --- a/Mage.Sets/src/mage/cards/m/MuseVessel.java +++ b/Mage.Sets/src/mage/cards/m/MuseVessel.java @@ -80,7 +80,7 @@ class MuseVesselExileEffect extends OneShotEffect { return false; } TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game) + if (target.canChoose(player.getId(), source, game) && target.chooseTarget(Outcome.Exile, player.getId(), source, game)) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); return player.moveCardsToExile(new CardsImpl(target.getTargets()).getCards(game), source, game, true, exileId, sourceObject.getIdName()); @@ -135,11 +135,11 @@ class TargetCardInMuseVesselExile extends TargetCardInExile { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - Card sourceCard = game.getCard(sourceId); + Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard != null) { - UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); + UUID exileId = CardUtil.getCardExileZoneId(game, source.getSourceId()); ExileZone exile = game.getExile().getExileZone(exileId); if (exile != null && !exile.isEmpty()) { possibleTargets.addAll(exile); @@ -149,10 +149,10 @@ class TargetCardInMuseVesselExile extends TargetCardInExile { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - Card sourceCard = game.getCard(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard != null) { - UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); + UUID exileId = CardUtil.getCardExileZoneId(game, source.getSourceId()); ExileZone exile = game.getExile().getExileZone(exileId); if (exile != null && !exile.isEmpty()) { return true; diff --git a/Mage.Sets/src/mage/cards/m/Mutiny.java b/Mage.Sets/src/mage/cards/m/Mutiny.java index aef8182e293..f520af56795 100644 --- a/Mage.Sets/src/mage/cards/m/Mutiny.java +++ b/Mage.Sets/src/mage/cards/m/Mutiny.java @@ -119,12 +119,12 @@ class MutinyFirstTarget extends TargetCreaturePermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - if (super.canChoose(sourceId, sourceControllerId, game)) { - UUID controllingPlayerId = game.getControllerId(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + if (super.canChoose(sourceControllerId, source, game)) { + UUID controllingPlayerId = game.getControllerId(source.getSourceId()); for (UUID playerId : game.getOpponents(controllingPlayerId)) { int possibleTargets = 0; - MageObject sourceObject = game.getObject(sourceId); + MageObject sourceObject = game.getObject(source); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { if (permanent.canBeTargetedBy(sourceObject, controllingPlayerId, game)) { possibleTargets++; diff --git a/Mage.Sets/src/mage/cards/m/MuzzioVisionaryArchitect.java b/Mage.Sets/src/mage/cards/m/MuzzioVisionaryArchitect.java index 20944c90d91..9f89f265a20 100644 --- a/Mage.Sets/src/mage/cards/m/MuzzioVisionaryArchitect.java +++ b/Mage.Sets/src/mage/cards/m/MuzzioVisionaryArchitect.java @@ -90,7 +90,7 @@ class MuzzioVisionaryArchitectEffect extends OneShotEffect { controller.lookAtCards(source, null, cards, game); if (!cards.isEmpty()) { TargetCard target = new TargetCard(Zone.LIBRARY, new FilterArtifactCard("artifact card to put onto the battlefield")); - if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.Benefit, cards, target, game)) { + if (target.canChoose(controller.getId(), source, game) && controller.choose(Outcome.Benefit, cards, target, game)) { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { controller.revealCards(source, new CardsImpl(card), game); diff --git a/Mage.Sets/src/mage/cards/m/MyojinOfLifesWeb.java b/Mage.Sets/src/mage/cards/m/MyojinOfLifesWeb.java index 849b1f68fea..a3288e75354 100644 --- a/Mage.Sets/src/mage/cards/m/MyojinOfLifesWeb.java +++ b/Mage.Sets/src/mage/cards/m/MyojinOfLifesWeb.java @@ -88,7 +88,7 @@ class MyojinOfLifesWebPutCreatureOnBattlefieldEffect extends OneShotEffect { } TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your hand to put onto the battlefield")); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null); } diff --git a/Mage.Sets/src/mage/cards/m/MyrBattlesphere.java b/Mage.Sets/src/mage/cards/m/MyrBattlesphere.java index d47e4bbdde6..852624be951 100644 --- a/Mage.Sets/src/mage/cards/m/MyrBattlesphere.java +++ b/Mage.Sets/src/mage/cards/m/MyrBattlesphere.java @@ -120,10 +120,10 @@ class MyrBattlesphereEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent(0, 1, filter, true); while (controller.canRespond()) { target.clearChosen(); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { Map options = new HashMap<>(); options.put("UI.right.btn.text", "Myr tapping complete"); - controller.choose(outcome, target, source.getControllerId(), game, options); + controller.choose(outcome, target, source, game, options); if (!target.getTargets().isEmpty()) { UUID creature = target.getFirstTarget(); if (creature != null) { diff --git a/Mage.Sets/src/mage/cards/m/MyrReservoir.java b/Mage.Sets/src/mage/cards/m/MyrReservoir.java index b0c627b4cf2..b7f9be919e1 100644 --- a/Mage.Sets/src/mage/cards/m/MyrReservoir.java +++ b/Mage.Sets/src/mage/cards/m/MyrReservoir.java @@ -82,7 +82,7 @@ enum MyrReservoirManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.hasSubtype(SubType.MYR, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/m/MyrRetriever.java b/Mage.Sets/src/mage/cards/m/MyrRetriever.java index 1b7aaa119a6..4bf4eb0840d 100644 --- a/Mage.Sets/src/mage/cards/m/MyrRetriever.java +++ b/Mage.Sets/src/mage/cards/m/MyrRetriever.java @@ -12,7 +12,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterArtifactCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -23,7 +23,7 @@ public final class MyrRetriever extends CardImpl { private static final FilterArtifactCard filter = new FilterArtifactCard("another target artifact card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public MyrRetriever(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java b/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java index c45bcb4a917..faef852fea0 100644 --- a/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java +++ b/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java @@ -98,15 +98,15 @@ class MythosOfSnapdaxEffect extends OneShotEffect { FilterPermanent filter = new FilterNonlandPermanent(message); filter.add(cardType.getPredicate()); filter.add(new ControllerIdPredicate(player.getId())); - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) == 0) { continue; } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); if (conditionMet) { - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); } else { - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); } toKeep.add(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/n/NahiriHeirOfTheAncients.java b/Mage.Sets/src/mage/cards/n/NahiriHeirOfTheAncients.java index 571dc51406d..439371b43a0 100644 --- a/Mage.Sets/src/mage/cards/n/NahiriHeirOfTheAncients.java +++ b/Mage.Sets/src/mage/cards/n/NahiriHeirOfTheAncients.java @@ -116,7 +116,7 @@ class NahiriHeirOfTheAncientsEffect extends OneShotEffect { .map(game::getPermanent) .filter(Objects::nonNull) .collect(Collectors.toList()); - int equipCount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int equipCount = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (tokens.isEmpty() || equipCount == 0 || !player.chooseUse(outcome, "Attach an equipment to the token?", source, game)) { @@ -133,12 +133,12 @@ class NahiriHeirOfTheAncientsEffect extends OneShotEffect { )); TargetPermanent target = new TargetPermanent(tokenFilter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); tokenCreature = game.getPermanent(target.getFirstTarget()); } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); tokenCreature.addAttachment(target.getFirstTarget(), source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/n/NahiriTheLithomancer.java b/Mage.Sets/src/mage/cards/n/NahiriTheLithomancer.java index 1b4db2b2327..344805c873e 100644 --- a/Mage.Sets/src/mage/cards/n/NahiriTheLithomancer.java +++ b/Mage.Sets/src/mage/cards/n/NahiriTheLithomancer.java @@ -100,9 +100,9 @@ class NahiriTheLithomancerFirstAbilityEffect extends OneShotEffect { if (tokenPermanent != null) { //TODO: Make sure the Equipment can legally enchant the token, preferably on targetting. Target target = new TargetControlledPermanent(0, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseUse(outcome, "Attach an Equipment you control to the created " + tokenPermanent.getIdName() + '?', source, game)) { - if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game)) { Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget()); if (equipmentPermanent != null) { Permanent attachedTo = game.getPermanent(equipmentPermanent.getAttachedTo()); @@ -151,14 +151,14 @@ class NahiriTheLithomancerSecondAbilityEffect extends OneShotEffect { if (controller != null) { if (controller.chooseUse(Outcome.PutCardInPlay, "Put an Equipment from hand? (No = from graveyard)", source, game)) { Target target = new TargetCardInHand(0, 1, filter); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } else { Target target = new TargetCardInYourGraveyard(0, 1, filter); - target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), source, game); Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java b/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java index ce13960799a..f20d10a4255 100644 --- a/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java +++ b/Mage.Sets/src/mage/cards/n/NahirisLithoforming.java @@ -67,13 +67,13 @@ class NahirisLithoformingSacrificeEffect extends OneShotEffect { } int landCount = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_LAND_SHORT_TEXT, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); landCount = Math.min(source.getManaCostsToPay().getX(), landCount); TargetPermanent target = new TargetPermanent( landCount, landCount, StaticFilters.FILTER_CONTROLLED_LAND_SHORT_TEXT, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); int counter = 0; for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); diff --git a/Mage.Sets/src/mage/cards/n/NarsetEnlightenedMaster.java b/Mage.Sets/src/mage/cards/n/NarsetEnlightenedMaster.java index b13e8422610..232cf793349 100644 --- a/Mage.Sets/src/mage/cards/n/NarsetEnlightenedMaster.java +++ b/Mage.Sets/src/mage/cards/n/NarsetEnlightenedMaster.java @@ -67,7 +67,7 @@ class NarsetEnlightenedMasterExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { Set cards = player.getLibrary().getTopCards(game, 4); player.moveCards(cards, Zone.EXILED, source, game); diff --git a/Mage.Sets/src/mage/cards/n/NarsetOfTheAncientWay.java b/Mage.Sets/src/mage/cards/n/NarsetOfTheAncientWay.java index 31e88316cc1..857d423dd33 100644 --- a/Mage.Sets/src/mage/cards/n/NarsetOfTheAncientWay.java +++ b/Mage.Sets/src/mage/cards/n/NarsetOfTheAncientWay.java @@ -100,7 +100,7 @@ class NarsetOfTheAncientWayManaCondition extends ManaCondition implements Condit if (!(source instanceof SpellAbility)) { return false; } - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && !object.isCreature(game); } diff --git a/Mage.Sets/src/mage/cards/n/NaturalBalance.java b/Mage.Sets/src/mage/cards/n/NaturalBalance.java index 93617912995..e7c4c274812 100644 --- a/Mage.Sets/src/mage/cards/n/NaturalBalance.java +++ b/Mage.Sets/src/mage/cards/n/NaturalBalance.java @@ -71,7 +71,7 @@ public final class NaturalBalance extends CardImpl { if (landCount > 5) { // chooses five lands they control and sacrifices the rest TargetControlledPermanent target = new TargetControlledPermanent(5, 5, new FilterControlledLandPermanent("lands to keep"), true); - if (target.choose(Outcome.Sacrifice, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Sacrifice, player.getId(), source.getSourceId(), source, game)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), player.getId(), game)) { if (!target.getTargets().contains(permanent.getId())) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/n/Nebuchadnezzar.java b/Mage.Sets/src/mage/cards/n/Nebuchadnezzar.java index 20004e4f676..e5f75dc6404 100644 --- a/Mage.Sets/src/mage/cards/n/Nebuchadnezzar.java +++ b/Mage.Sets/src/mage/cards/n/Nebuchadnezzar.java @@ -64,7 +64,7 @@ class NebuchadnezzarEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (opponent == null || sourceObject == null || cardName.isEmpty()) { return false; diff --git a/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java b/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java index b321e53b4b0..0dc9e8bc0e0 100644 --- a/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java +++ b/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java @@ -64,7 +64,7 @@ class NecromancersStockpileDiscardTargetCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), source, game)) { Player player = game.getPlayer(controllerId); if (player != null) { for (UUID targetId : targets.get(0).getTargets()) { @@ -83,7 +83,7 @@ class NecromancersStockpileDiscardTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/n/NecromanticSelection.java b/Mage.Sets/src/mage/cards/n/NecromanticSelection.java index b2fec3f42bc..17e543848e7 100644 --- a/Mage.Sets/src/mage/cards/n/NecromanticSelection.java +++ b/Mage.Sets/src/mage/cards/n/NecromanticSelection.java @@ -71,11 +71,11 @@ class NecromanticSelectionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Cards cards = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source, game)) { permanent.destroy(source, game, false); game.checkStateAndTriggered(); // Meren of the Clan Nel Toth bug #8515 if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) { diff --git a/Mage.Sets/src/mage/cards/n/Necroplasm.java b/Mage.Sets/src/mage/cards/n/Necroplasm.java index e8c870c903e..43352ee983c 100644 --- a/Mage.Sets/src/mage/cards/n/Necroplasm.java +++ b/Mage.Sets/src/mage/cards/n/Necroplasm.java @@ -80,7 +80,7 @@ class NecroplasmEffect extends OneShotEffect { int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, numCounters)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if(permanent != null) { permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/n/NefariousLich.java b/Mage.Sets/src/mage/cards/n/NefariousLich.java index 0d30b3c2d88..0a6673ba957 100644 --- a/Mage.Sets/src/mage/cards/n/NefariousLich.java +++ b/Mage.Sets/src/mage/cards/n/NefariousLich.java @@ -19,7 +19,6 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.Target; import mage.target.common.TargetCardInYourGraveyard; @@ -77,8 +76,8 @@ class NefariousLichDamageReplacementEffect extends ReplacementEffectImpl { Player controller = game.getPlayer(event.getPlayerId()); if (controller != null) { Target target = new TargetCardInYourGraveyard(amount, new FilterCard("card in your graveyard")); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - if (controller.choose(Outcome.Exile, target, source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { + if (controller.choose(Outcome.Exile, target, source, game)) { Set cards = new HashSet<>(amount); for (UUID targetId : target.getTargets()) { Card card = controller.getGraveyard().get(targetId, game); diff --git a/Mage.Sets/src/mage/cards/n/NeganTheColdBlooded.java b/Mage.Sets/src/mage/cards/n/NeganTheColdBlooded.java index bc812c21a67..0fcbfd29c43 100644 --- a/Mage.Sets/src/mage/cards/n/NeganTheColdBlooded.java +++ b/Mage.Sets/src/mage/cards/n/NeganTheColdBlooded.java @@ -90,16 +90,16 @@ class NeganTheColdBloodedEffect extends OneShotEffect { filter.add(new ControllerIdPredicate(opponent.getId())); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } Set choices = new HashSet<>(); - controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game); + controller.choose(Outcome.DestroyPermanent, target, source, game); UUID controllerChoice = target.getFirstTarget(); choices.add(controllerChoice); target.clearChosen(); - opponent.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game); + opponent.choose(Outcome.DestroyPermanent, target, source, game); UUID opponentChoice = target.getFirstTarget(); choices.add(opponentChoice); diff --git a/Mage.Sets/src/mage/cards/n/NessianGameWarden.java b/Mage.Sets/src/mage/cards/n/NessianGameWarden.java index 27847b82700..d508ca3422c 100644 --- a/Mage.Sets/src/mage/cards/n/NessianGameWarden.java +++ b/Mage.Sets/src/mage/cards/n/NessianGameWarden.java @@ -87,7 +87,7 @@ class NessianGameWardenEffect extends OneShotEffect { if (!cards.isEmpty()) { TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put into your hand")); - if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DrawCard, cards, target, game)) { + if (target.canChoose(controller.getId(), source, game) && controller.choose(Outcome.DrawCard, cards, target, game)) { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game); diff --git a/Mage.Sets/src/mage/cards/n/NettlevineBlight.java b/Mage.Sets/src/mage/cards/n/NettlevineBlight.java index 69587f98ab1..0d6d013e193 100644 --- a/Mage.Sets/src/mage/cards/n/NettlevineBlight.java +++ b/Mage.Sets/src/mage/cards/n/NettlevineBlight.java @@ -99,8 +99,8 @@ class NettlevineBlightEffect extends OneShotEffect { filter.add(new CanBeEnchantedByPredicate(nettlevineBlight)); Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), newController.getId(), game) - && newController.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(newController.getId(), source, game) + && newController.choose(outcome, target, source, game)) { Permanent chosenPermanent = game.getPermanent(target.getFirstTarget()); if (chosenPermanent != null) { Card nettlevineBlightCard = game.getCard(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/n/NewBlood.java b/Mage.Sets/src/mage/cards/n/NewBlood.java index 04a34f1b1a1..5f811d96ef7 100644 --- a/Mage.Sets/src/mage/cards/n/NewBlood.java +++ b/Mage.Sets/src/mage/cards/n/NewBlood.java @@ -114,7 +114,7 @@ class ChangeCreatureTypeTargetEffect extends ContinuousEffectImpl { return; } if (fromSubType == null) { - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); typeChoice.setMessage("Choose creature type to change to Vampire"); if (!controller.choose(outcome, typeChoice, game)) { discard(); diff --git a/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java b/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java index a92ed571ecf..ac3dc25563b 100644 --- a/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java +++ b/Mage.Sets/src/mage/cards/n/NicolBolasDragonGod.java @@ -87,7 +87,7 @@ class NicolBolasDragonGodGainAbilitiesEffect extends ContinuousEffectImpl { return true; } for (Permanent permanent : game.getState().getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { for (Ability ability : permanent.getAbilities()) { if (ability instanceof LoyaltyAbility) { @@ -173,7 +173,7 @@ class NicolBolasDragonGodPlusOneEffect extends OneShotEffect { } // permanent if (target.equals(targetPermanent)) { - if (opponent.choose(Outcome.Exile, targetPermanent, source.getSourceId(), game)) { + if (opponent.choose(Outcome.Exile, targetPermanent, source, game)) { MageObject mageObject = game.getObject(targetPermanent.getFirstTarget()); if (mageObject instanceof Permanent) { cardsOnBattlefield.add((Card) mageObject); diff --git a/Mage.Sets/src/mage/cards/n/NicolBolasTheDeceiver.java b/Mage.Sets/src/mage/cards/n/NicolBolasTheDeceiver.java index 5f3d56ac0ac..2a027a549c4 100644 --- a/Mage.Sets/src/mage/cards/n/NicolBolasTheDeceiver.java +++ b/Mage.Sets/src/mage/cards/n/NicolBolasTheDeceiver.java @@ -86,7 +86,7 @@ class NicolBolasTheDeceiverFirstEffect extends OneShotEffect { if (permanents > 0 && opponent.chooseUse(outcome, "Sacrifices a nonland permanent?", "Otherwise you have to discard a card or lose 3 life.", "Sacrifice", "Discard or life loss", source, game)) { Target target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND); - if (opponent.choose(outcome, target, source.getSourceId(), game)) { + if (opponent.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/n/Nightcreep.java b/Mage.Sets/src/mage/cards/n/Nightcreep.java index 9b2fb714d0d..0f60154c43b 100644 --- a/Mage.Sets/src/mage/cards/n/Nightcreep.java +++ b/Mage.Sets/src/mage/cards/n/Nightcreep.java @@ -55,7 +55,7 @@ class NightcreepLandEffect extends BecomesBasicLandTargetEffect { @Override public void init(Ability source, Game game) { super.init(source, game); - List targets = new ArrayList<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source.getSourceId(), game)); + List targets = new ArrayList<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source, game)); this.setTargetPointer(new FixedTargets(targets, game)); } @@ -79,7 +79,7 @@ class NightcreepCreatureEffect extends BecomesColorTargetEffect { @Override public void init(Ability source, Game game) { super.init(source, game); - List targets = new ArrayList<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); + List targets = new ArrayList<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)); this.setTargetPointer(new FixedTargets(targets, game)); } diff --git a/Mage.Sets/src/mage/cards/n/NightmareIncursion.java b/Mage.Sets/src/mage/cards/n/NightmareIncursion.java index 9152d18758e..9ae95cc0376 100644 --- a/Mage.Sets/src/mage/cards/n/NightmareIncursion.java +++ b/Mage.Sets/src/mage/cards/n/NightmareIncursion.java @@ -70,7 +70,7 @@ class NightmareIncursionEffect extends OneShotEffect { if (controller == null || targetPlayer == null) { return false; } - int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int amount = game.getBattlefield().count(filter, source.getControllerId(), source, game); TargetCardInLibrary target = new TargetCardInLibrary(0, amount, StaticFilters.FILTER_CARD); if (controller.searchLibrary(target, source, game, targetPlayer.getId())) { Cards cards = new CardsImpl(target.getTargets()); diff --git a/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java b/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java index 64577809c04..1c233b348a3 100644 --- a/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java +++ b/Mage.Sets/src/mage/cards/n/NightshadeAssassin.java @@ -87,12 +87,12 @@ class NightshadeAssassinEffect extends OneShotEffect { } FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(ObjectColor.BLACK)); - int blackCards = controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game); + int blackCards = controller.getHand().count(filter, source.getControllerId(), source, game); int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game); game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards."); if (cardsToReveal > 0) { TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter); - if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Benefit, target, source, game)) { controller.revealCards(sourceObject.getIdName(), new CardsImpl(target.getTargets()), game); int unboost = target.getTargets().size() * -1; ContinuousEffect effect = new BoostTargetEffect(unboost, unboost, Duration.EndOfTurn); diff --git a/Mage.Sets/src/mage/cards/n/Nihiloor.java b/Mage.Sets/src/mage/cards/n/Nihiloor.java index 72623718818..66735e34fea 100644 --- a/Mage.Sets/src/mage/cards/n/Nihiloor.java +++ b/Mage.Sets/src/mage/cards/n/Nihiloor.java @@ -120,7 +120,7 @@ class NihiloorControlEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(0, 1, filter, true); target.withChooseHint("tapping a creature controlled by " + opponent.getName()); - controller.choose(outcome, target, source.getControllerId(), game); + controller.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null || !permanent.tap(source, game)) { continue; diff --git a/Mage.Sets/src/mage/cards/n/NikoDefiesDestiny.java b/Mage.Sets/src/mage/cards/n/NikoDefiesDestiny.java index aff6ac2688b..98b25572cac 100644 --- a/Mage.Sets/src/mage/cards/n/NikoDefiesDestiny.java +++ b/Mage.Sets/src/mage/cards/n/NikoDefiesDestiny.java @@ -167,7 +167,7 @@ class NikoDefiesDestinyManaCondition extends ManaCondition implements Condition @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.getAbilities().containsClass(ForetellAbility.class); } return source instanceof ForetellAbility; diff --git a/Mage.Sets/src/mage/cards/n/NimDevourer.java b/Mage.Sets/src/mage/cards/n/NimDevourer.java index fafc11ca966..42b282d22f1 100644 --- a/Mage.Sets/src/mage/cards/n/NimDevourer.java +++ b/Mage.Sets/src/mage/cards/n/NimDevourer.java @@ -82,7 +82,7 @@ class NimDevourerEffect extends OneShotEffect { if (player != null) { Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent()); - if (target.canChoose(source.getSourceId(), player.getId(), game) && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (target.canChoose(player.getId(), source, game) && player.choose(Outcome.Sacrifice, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { return permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java b/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java index f7bb433f727..bd2aa84f94a 100644 --- a/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java +++ b/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java @@ -72,7 +72,7 @@ class NissaNaturesArtisanEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } @@ -81,7 +81,7 @@ class NissaNaturesArtisanEffect extends OneShotEffect { controller.revealCards(sourceObject.getIdName(), cards, game); Set toBattlefield = new LinkedHashSet<>(); for (Card card : cards.getCards(new FilterLandCard(), - source.getSourceId(), source.getControllerId(), game)) { + source.getControllerId(), source, game)) { cards.remove(card); toBattlefield.add(card); } diff --git a/Mage.Sets/src/mage/cards/n/NissaOfShadowedBoughs.java b/Mage.Sets/src/mage/cards/n/NissaOfShadowedBoughs.java index b805cc44228..a2d85dbe5fe 100644 --- a/Mage.Sets/src/mage/cards/n/NissaOfShadowedBoughs.java +++ b/Mage.Sets/src/mage/cards/n/NissaOfShadowedBoughs.java @@ -126,7 +126,7 @@ class NissaOfShadowedBoughsCreatureEffect extends OneShotEffect { } int lands = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); FilterCard filter = new FilterCreatureCard("creature card with mana value " + lands + " or less"); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, lands + 1)); @@ -144,7 +144,7 @@ class NissaOfShadowedBoughsCreatureEffect extends OneShotEffect { } else { target = new TargetCardInHand(filter); } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/n/NissaRevane.java b/Mage.Sets/src/mage/cards/n/NissaRevane.java index 3e3d1382640..d5680732c4e 100644 --- a/Mage.Sets/src/mage/cards/n/NissaRevane.java +++ b/Mage.Sets/src/mage/cards/n/NissaRevane.java @@ -79,7 +79,7 @@ class NissaRevaneGainLifeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - int life = 2 * game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int life = 2 * game.getBattlefield().count(filter, source.getControllerId(), source, game); if (player != null) { player.gainLife(life, game, source); } diff --git a/Mage.Sets/src/mage/cards/n/NissaSageAnimist.java b/Mage.Sets/src/mage/cards/n/NissaSageAnimist.java index c212bc3aaf8..6c2afa68a13 100644 --- a/Mage.Sets/src/mage/cards/n/NissaSageAnimist.java +++ b/Mage.Sets/src/mage/cards/n/NissaSageAnimist.java @@ -81,7 +81,7 @@ class NissaSageAnimistPlusOneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null && controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); if (card == null) { diff --git a/Mage.Sets/src/mage/cards/n/NivmagusElemental.java b/Mage.Sets/src/mage/cards/n/NivmagusElemental.java index daf54a843ce..566feaa6143 100644 --- a/Mage.Sets/src/mage/cards/n/NivmagusElemental.java +++ b/Mage.Sets/src/mage/cards/n/NivmagusElemental.java @@ -91,7 +91,7 @@ class NivmagusElementalCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/n/NoContest.java b/Mage.Sets/src/mage/cards/n/NoContest.java index 9fa1ad68dab..94dc34e86ac 100644 --- a/Mage.Sets/src/mage/cards/n/NoContest.java +++ b/Mage.Sets/src/mage/cards/n/NoContest.java @@ -55,9 +55,9 @@ class TargetCreatureWithLessPowerPermanent extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int maxPower = Integer.MIN_VALUE; // get the most powerful controlled creature that can be targeted - Card sourceCard = game.getCard(sourceId); + Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard == null) { return false; } @@ -69,7 +69,7 @@ class TargetCreatureWithLessPowerPermanent extends TargetPermanent { // now check, if another creature has less power and can be targeted FilterCreaturePermanent checkFilter = new FilterCreaturePermanent(); checkFilter.add(new PowerPredicate(ComparisonType.FEWER_THAN, maxPower)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(checkFilter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(checkFilter, sourceControllerId, source, game)) { if (permanent.canBeTargetedBy(sourceCard, sourceControllerId, game)) { return true; } @@ -78,8 +78,8 @@ class TargetCreatureWithLessPowerPermanent extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Spell spell = game.getStack().getSpell(sourceId); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null) { Permanent firstTarget = getPermanentFromFirstTarget(spell.getSpellAbility(), game); if (firstTarget != null) { @@ -89,7 +89,7 @@ class TargetCreatureWithLessPowerPermanent extends TargetPermanent { filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, power)); } } - return super.possibleTargets(sourceId, sourceControllerId, game); + return super.possibleTargets(sourceControllerId, source, game); } private Permanent getPermanentFromFirstTarget(Ability source, Game game) { diff --git a/Mage.Sets/src/mage/cards/n/NobleStand.java b/Mage.Sets/src/mage/cards/n/NobleStand.java index 4070b715592..4ecb286a742 100644 --- a/Mage.Sets/src/mage/cards/n/NobleStand.java +++ b/Mage.Sets/src/mage/cards/n/NobleStand.java @@ -57,7 +57,7 @@ class NobleStandAbility extends TriggeredAbilityImpl { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); filter.add(TokenPredicate.FALSE); Permanent permanent = game.getPermanent(event.getSourceId()); - return permanent != null && filter.match(permanent, sourceId, controllerId, game); + return permanent != null && filter.match(permanent, controllerId, this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/n/NoeticScales.java b/Mage.Sets/src/mage/cards/n/NoeticScales.java index a00ab107977..8a79f87634e 100644 --- a/Mage.Sets/src/mage/cards/n/NoeticScales.java +++ b/Mage.Sets/src/mage/cards/n/NoeticScales.java @@ -75,7 +75,7 @@ class NoeticScalesEffect extends OneShotEffect { } Cards cards = new CardsImpl(); game.getBattlefield().getActivePermanents( - filter, game.getActivePlayerId(), source.getSourceId(), game + filter, game.getActivePlayerId(), source, game ).stream().filter(Objects::nonNull).forEach(cards::add); return player.moveCards(cards, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/n/NomadMythmaker.java b/Mage.Sets/src/mage/cards/n/NomadMythmaker.java index a699cbdfca6..9ac931b86f2 100644 --- a/Mage.Sets/src/mage/cards/n/NomadMythmaker.java +++ b/Mage.Sets/src/mage/cards/n/NomadMythmaker.java @@ -87,7 +87,7 @@ class NomadMythmakerEffect extends OneShotEffect { FilterControlledCreaturePermanent FILTER = new FilterControlledCreaturePermanent("Choose a creature you control"); TargetControlledPermanent target = new TargetControlledPermanent(FILTER); target.setNotTarget(true); - if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && !permanent.cantBeAttachedBy(aura, source, game, false)) { diff --git a/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java b/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java index 6dd0c14a325..a9bb1965ebe 100644 --- a/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java +++ b/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java @@ -89,7 +89,7 @@ enum NotOfThisWorldCondition implements Condition { .flatMap(Collection::stream) .map(game::getPermanentOrLKIBattlefield) .anyMatch(permanent -> permanent != null && filter.match( - permanent, sourceSpell.getSourceId(), sourceSpell.getControllerId(), game + permanent, sourceSpell.getControllerId(), source, game )); } diff --git a/Mage.Sets/src/mage/cards/n/NovaPentacle.java b/Mage.Sets/src/mage/cards/n/NovaPentacle.java index 4ca999f98d2..ed0e2de38b0 100644 --- a/Mage.Sets/src/mage/cards/n/NovaPentacle.java +++ b/Mage.Sets/src/mage/cards/n/NovaPentacle.java @@ -69,7 +69,7 @@ class NovaPentacleEffect extends RedirectionEffect { @Override public void init(Ability source, Game game) { - this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java b/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java index c3f1810b0ec..557abfcbedc 100644 --- a/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java +++ b/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java @@ -67,7 +67,7 @@ class NovijenHeartOfProgressEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) { if (permanent.getTurnsOnBattlefield() == 0) { diff --git a/Mage.Sets/src/mage/cards/n/NoxiousVapors.java b/Mage.Sets/src/mage/cards/n/NoxiousVapors.java index def20a07d17..1ba8d834ef4 100644 --- a/Mage.Sets/src/mage/cards/n/NoxiousVapors.java +++ b/Mage.Sets/src/mage/cards/n/NoxiousVapors.java @@ -98,7 +98,7 @@ class NoxiousVaporsEffect extends OneShotEffect { FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(color)); TargetCardInHand target = new TargetCardInHand(filter); - if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { chosenCards.add(card); diff --git a/Mage.Sets/src/mage/cards/n/NullChamber.java b/Mage.Sets/src/mage/cards/n/NullChamber.java index 41202c8d10d..e1d6b53add6 100644 --- a/Mage.Sets/src/mage/cards/n/NullChamber.java +++ b/Mage.Sets/src/mage/cards/n/NullChamber.java @@ -71,7 +71,7 @@ class NullChamberChooseEffect extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - controller.choose(Outcome.Neutral, chosenOpponent, source.getSourceId(), game); + controller.choose(Outcome.Neutral, chosenOpponent, source, game); Player opponent = game.getPlayer(chosenOpponent.getFirstTarget()); String cardName = ChooseACardNameEffect.TypeOfName.NOT_BASIC_LAND_NAME.getChoice(controller, game, source, false); if (cardName != null) { @@ -123,7 +123,7 @@ class NullChamberReplacementEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast a spell with that name (" + mageObject.getName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/n/NulltreadGargantuan.java b/Mage.Sets/src/mage/cards/n/NulltreadGargantuan.java index a92d6ad3221..285a83dca3a 100644 --- a/Mage.Sets/src/mage/cards/n/NulltreadGargantuan.java +++ b/Mage.Sets/src/mage/cards/n/NulltreadGargantuan.java @@ -69,7 +69,7 @@ class NulltreadGargantuanEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); return permanent != null && player.putCardsOnTopOfLibrary(permanent, game, source, false); } diff --git a/Mage.Sets/src/mage/cards/n/NykthosParagon.java b/Mage.Sets/src/mage/cards/n/NykthosParagon.java index 73027ff59e4..e2cae10701c 100644 --- a/Mage.Sets/src/mage/cards/n/NykthosParagon.java +++ b/Mage.Sets/src/mage/cards/n/NykthosParagon.java @@ -121,7 +121,7 @@ class NykthosParagonEffect extends OneShotEffect { @Override public boolean apply (Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Integer life = (Integer) this.getValue("gainedLife"); if (controller != null && sourceObject != null && life != null) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/o/OathOfGhouls.java b/Mage.Sets/src/mage/cards/o/OathOfGhouls.java index dc1552060aa..2f45b501b9f 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfGhouls.java +++ b/Mage.Sets/src/mage/cards/o/OathOfGhouls.java @@ -108,7 +108,7 @@ class OathOfGhoulsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player firstPlayer = game.getPlayer(game.getActivePlayerId()); if (sourceObject == null || firstPlayer == null) { return false; @@ -117,7 +117,7 @@ class OathOfGhoulsEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(firstPlayer.getId())); Target target = new TargetCardInGraveyard(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), firstPlayer.getId(), game) + if (target.canChoose(firstPlayer.getId(), source, game) && firstPlayer.chooseUse(outcome, "Return a creature card from your graveyard to your hand?", source, game) && firstPlayer.chooseTarget(Outcome.ReturnToHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/o/OathOfLimDul.java b/Mage.Sets/src/mage/cards/o/OathOfLimDul.java index 89699582bcf..d81ffe08b27 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfLimDul.java +++ b/Mage.Sets/src/mage/cards/o/OathOfLimDul.java @@ -114,7 +114,7 @@ class OathOfLimDulEffect extends OneShotEffect { && controller != null) { TargetControlledPermanent target = new TargetControlledPermanent(0, numberOfControlledPermanents, filter, true); target.setNotTarget(true); - if (controller.choose(Outcome.Detriment, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Detriment, target, source, game)) { for (UUID targetPermanentId : target.getTargets()) { Permanent permanent = game.getPermanent(targetPermanentId); if (permanent != null diff --git a/Mage.Sets/src/mage/cards/o/OathOfMages.java b/Mage.Sets/src/mage/cards/o/OathOfMages.java index 6d6efdef132..2c6319d1b8c 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfMages.java +++ b/Mage.Sets/src/mage/cards/o/OathOfMages.java @@ -104,7 +104,7 @@ class OathOfMagesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player firstPlayer = game.getPlayer(game.getActivePlayerId()); Player secondPlayer = game.getPlayer(source.getFirstTarget()); if (sourceObject == null || firstPlayer == null) { diff --git a/Mage.Sets/src/mage/cards/o/OathOfNissa.java b/Mage.Sets/src/mage/cards/o/OathOfNissa.java index 83381439d6f..a7ee75b304a 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfNissa.java +++ b/Mage.Sets/src/mage/cards/o/OathOfNissa.java @@ -73,18 +73,18 @@ class OathOfNissaEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards topCards = new CardsImpl(); topCards.addAll(controller.getLibrary().getTopCards(game, 3)); if (!topCards.isEmpty()) { controller.lookAtCards(sourceObject.getIdName(), topCards, game); - int number = topCards.count(filter, source.getSourceId(), source.getControllerId(), game); + int number = topCards.count(filter, source.getControllerId(), source, game); if (number > 0) { if (controller.chooseUse(outcome, "Reveal a creature, land, or planeswalker card from the looked at cards and put it into your hand?", source, game)) { Card card; if (number == 1) { - Set cards = topCards.getCards(filter, source.getSourceId(), source.getControllerId(), game); + Set cards = topCards.getCards(filter, source.getControllerId(), source, game); card = cards.isEmpty() ? null : cards.iterator().next(); } else { TargetCard target = new TargetCard(Zone.LIBRARY, filter); diff --git a/Mage.Sets/src/mage/cards/o/OathOfScholars.java b/Mage.Sets/src/mage/cards/o/OathOfScholars.java index 194a5709b92..3f76a1c9ac7 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfScholars.java +++ b/Mage.Sets/src/mage/cards/o/OathOfScholars.java @@ -100,7 +100,7 @@ class OathOfScholarsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player firstPlayer = game.getPlayer(game.getActivePlayerId()); if (sourceObject == null || firstPlayer == null) { return false; diff --git a/Mage.Sets/src/mage/cards/o/OathkeeperTakenosDaisho.java b/Mage.Sets/src/mage/cards/o/OathkeeperTakenosDaisho.java index 09bfe9a2a06..469f7ea351b 100644 --- a/Mage.Sets/src/mage/cards/o/OathkeeperTakenosDaisho.java +++ b/Mage.Sets/src/mage/cards/o/OathkeeperTakenosDaisho.java @@ -121,7 +121,7 @@ class OathkeeperEquippedMatchesFilterCondition implements Condition { } } if (attachedTo != null) { - return filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game); + return filter.match(attachedTo, attachedTo.getControllerId(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/o/OblivionSower.java b/Mage.Sets/src/mage/cards/o/OblivionSower.java index 0a09125e602..9d03512f857 100644 --- a/Mage.Sets/src/mage/cards/o/OblivionSower.java +++ b/Mage.Sets/src/mage/cards/o/OblivionSower.java @@ -85,7 +85,7 @@ class OblivionSowerEffect extends OneShotEffect { Cards exiledCards = new CardsImpl(); exiledCards.addAll(game.getExile().getAllCards(game)); Cards exiledLands = new CardsImpl(); - exiledLands.addAll(exiledCards.getCards(filter, source.getSourceId(), controller.getId(), game)); + exiledLands.addAll(exiledCards.getCards(filter, controller.getId(), source, game)); if (!exiledLands.isEmpty() && controller.chooseUse(outcome, "Put lands into play?", source, game)) { FilterCard filterToPlay = new FilterCard("land" + (exiledLands.size() > 1 ? "s" : "") + " from exile owned by " diff --git a/Mage.Sets/src/mage/cards/o/ObsidianCharmaw.java b/Mage.Sets/src/mage/cards/o/ObsidianCharmaw.java index 753e468e5bd..eb02e1811a8 100644 --- a/Mage.Sets/src/mage/cards/o/ObsidianCharmaw.java +++ b/Mage.Sets/src/mage/cards/o/ObsidianCharmaw.java @@ -80,7 +80,7 @@ enum ObsidianCharmawValue implements DynamicValue { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_OPPONENTS_PERMANENT, - sourceAbility.getControllerId(), sourceAbility.getSourceId(), game + sourceAbility.getControllerId(), sourceAbility, game ).stream() .filter(Objects::nonNull) .filter(permanent1 -> permanent1.isLand(game)) diff --git a/Mage.Sets/src/mage/cards/o/OgreMarauder.java b/Mage.Sets/src/mage/cards/o/OgreMarauder.java index 6aabe66f59b..0d8d67d3dd8 100644 --- a/Mage.Sets/src/mage/cards/o/OgreMarauder.java +++ b/Mage.Sets/src/mage/cards/o/OgreMarauder.java @@ -69,7 +69,7 @@ class OgreMarauderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player defender = game.getPlayer(defendingPlayerId); if (defender != null && sourceObject != null) { Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)); diff --git a/Mage.Sets/src/mage/cards/o/OketraTheTrue.java b/Mage.Sets/src/mage/cards/o/OketraTheTrue.java index 493cd408fbf..cbea6bc7233 100644 --- a/Mage.Sets/src/mage/cards/o/OketraTheTrue.java +++ b/Mage.Sets/src/mage/cards/o/OketraTheTrue.java @@ -90,7 +90,7 @@ class OketraTheTrueRestrictionEffect extends RestrictionEffect { if (permanent.getId().equals(source.getSourceId())) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int permanentsOnBattlefield = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int permanentsOnBattlefield = game.getBattlefield().count(filter, source.getControllerId(), source, game); return (ComparisonType.compare(permanentsOnBattlefield, ComparisonType.FEWER_THAN, 4)); } return true; diff --git a/Mage.Sets/src/mage/cards/o/Okk.java b/Mage.Sets/src/mage/cards/o/Okk.java index d7191e37e20..ede068e8e23 100644 --- a/Mage.Sets/src/mage/cards/o/Okk.java +++ b/Mage.Sets/src/mage/cards/o/Okk.java @@ -72,7 +72,7 @@ class OkkAttackEffect extends RestrictionEffect { public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { // Search for an attacking creature with greater power - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (creature.getPower().getValue() > permanent.getPower().getValue()) { return false; } @@ -110,7 +110,7 @@ class OkkBlockEffect extends RestrictionEffect { public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { // Search for a blocking creature with greater power - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (creature.getPower().getValue() > permanent.getPower().getValue()) { return false; } diff --git a/Mage.Sets/src/mage/cards/o/OlagLudevicsHubris.java b/Mage.Sets/src/mage/cards/o/OlagLudevicsHubris.java index b3cf3cd498a..dc76a1e359f 100644 --- a/Mage.Sets/src/mage/cards/o/OlagLudevicsHubris.java +++ b/Mage.Sets/src/mage/cards/o/OlagLudevicsHubris.java @@ -98,7 +98,7 @@ class OlagLudevicsHubrisEffect extends ReplacementEffectImpl { return cards.getRandom(game); } TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return cards.get(target.getFirstTarget(), game); } diff --git a/Mage.Sets/src/mage/cards/o/OldGrowthTroll.java b/Mage.Sets/src/mage/cards/o/OldGrowthTroll.java index 20d851174a3..942c5bdc151 100644 --- a/Mage.Sets/src/mage/cards/o/OldGrowthTroll.java +++ b/Mage.Sets/src/mage/cards/o/OldGrowthTroll.java @@ -111,7 +111,7 @@ class OldGrowthTrollReturnEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (controller.choose(outcome, target, source.getSourceId(), game) + if (controller.choose(outcome, target, source, game) && game.getPermanent(target.getFirstTarget()) != null) { game.getState().setValue("attachTo:" + source.getSourceId(), target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java b/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java index 26fe7a08990..18e1a3801fb 100644 --- a/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java +++ b/Mage.Sets/src/mage/cards/o/OldManOfTheSea.java @@ -62,7 +62,7 @@ enum OldManOfTheSeaPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getPower().getValue() <= sourcePermanent.getPower().getValue(); } diff --git a/Mage.Sets/src/mage/cards/o/OliviaCrimsonBride.java b/Mage.Sets/src/mage/cards/o/OliviaCrimsonBride.java index d0ec11c3163..9f6cb112201 100644 --- a/Mage.Sets/src/mage/cards/o/OliviaCrimsonBride.java +++ b/Mage.Sets/src/mage/cards/o/OliviaCrimsonBride.java @@ -124,7 +124,7 @@ class OliviaCrimsonBrideAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().count(filter, getSourceId(), getControllerId(), game) < 1; + return game.getBattlefield().count(filter, getControllerId(), this, game) < 1; } @Override diff --git a/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java b/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java index 012724a3cc6..82f581e8fcb 100644 --- a/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java +++ b/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java @@ -77,7 +77,7 @@ class OpalEyeKondasYojimboRedirectionEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/o/Opalescence.java b/Mage.Sets/src/mage/cards/o/Opalescence.java index 633f335bc21..8c8cf57b5c2 100644 --- a/Mage.Sets/src/mage/cards/o/Opalescence.java +++ b/Mage.Sets/src/mage/cards/o/Opalescence.java @@ -71,7 +71,7 @@ public final class Opalescence extends CardImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, - source.getControllerId(), source.getSourceId(), game)) { + source.getControllerId(), source, game)) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { diff --git a/Mage.Sets/src/mage/cards/o/OpalineSliver.java b/Mage.Sets/src/mage/cards/o/OpalineSliver.java index ae353054e00..fe1762b8427 100644 --- a/Mage.Sets/src/mage/cards/o/OpalineSliver.java +++ b/Mage.Sets/src/mage/cards/o/OpalineSliver.java @@ -14,11 +14,9 @@ import mage.constants.Duration; import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterPermanent; -import mage.filter.FilterSpell; import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.stack.StackObject; /** @@ -84,7 +82,7 @@ class OpalineSliverTriggeredAbility extends TriggeredAbilityImpl { } else { return event.getTargetId().equals(this.getSourceId()) && game.getOpponents(this.controllerId).contains(event.getPlayerId()) - && StaticFilters.FILTER_SPELL_A.match(spell, getSourceId(), getControllerId(), game); + && StaticFilters.FILTER_SPELL_A.match(spell, getControllerId(), this, game); } } diff --git a/Mage.Sets/src/mage/cards/o/OpenTheOmenpaths.java b/Mage.Sets/src/mage/cards/o/OpenTheOmenpaths.java index 3b72e24161f..f4fce2bcd96 100644 --- a/Mage.Sets/src/mage/cards/o/OpenTheOmenpaths.java +++ b/Mage.Sets/src/mage/cards/o/OpenTheOmenpaths.java @@ -87,7 +87,7 @@ class OpenTheOmenpathsCondition extends ManaCondition implements Condition { if (!(source instanceof SpellAbility)) { return false; } - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && (object.isCreature(game) || object.isEnchantment(game)); } diff --git a/Mage.Sets/src/mage/cards/o/Oppression.java b/Mage.Sets/src/mage/cards/o/Oppression.java index b1b169bd65b..01cb9f8e186 100644 --- a/Mage.Sets/src/mage/cards/o/Oppression.java +++ b/Mage.Sets/src/mage/cards/o/Oppression.java @@ -49,7 +49,7 @@ class OppressionTriggeredAbility extends SpellCastAllTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { + if (spell != null && filter.match(spell, getControllerId(), this, game)) { this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } diff --git a/Mage.Sets/src/mage/cards/o/OppressiveWill.java b/Mage.Sets/src/mage/cards/o/OppressiveWill.java index f242e56bb24..73a6bcb5a18 100644 --- a/Mage.Sets/src/mage/cards/o/OppressiveWill.java +++ b/Mage.Sets/src/mage/cards/o/OppressiveWill.java @@ -58,7 +58,7 @@ class SpellSyphonEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/o/OracleEnVec.java b/Mage.Sets/src/mage/cards/o/OracleEnVec.java index 2a4658c0f3a..85c3d420b2b 100644 --- a/Mage.Sets/src/mage/cards/o/OracleEnVec.java +++ b/Mage.Sets/src/mage/cards/o/OracleEnVec.java @@ -85,8 +85,8 @@ class OracleEnVecEffect extends OneShotEffect { Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (opponent != null) { Target target = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, new FilterControlledCreaturePermanent(), true); - if (target.choose(Outcome.Neutral, opponent.getId(), source.getSourceId(), game)) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), opponent.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Neutral, opponent.getId(), source.getSourceId(), source, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), opponent.getId(), source, game)) { if (target.getTargets().contains(permanent.getId())) { RequirementEffect effect = new OracleEnVecMustAttackRequirementEffect(); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/o/OraclesAttendants.java b/Mage.Sets/src/mage/cards/o/OraclesAttendants.java index b0dca23a9e7..68247da7cf3 100644 --- a/Mage.Sets/src/mage/cards/o/OraclesAttendants.java +++ b/Mage.Sets/src/mage/cards/o/OraclesAttendants.java @@ -74,7 +74,7 @@ class OraclesAttendantsReplacementEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/o/OrbOfDragonkind.java b/Mage.Sets/src/mage/cards/o/OrbOfDragonkind.java index 54f38b0d2d0..40aefdca939 100644 --- a/Mage.Sets/src/mage/cards/o/OrbOfDragonkind.java +++ b/Mage.Sets/src/mage/cards/o/OrbOfDragonkind.java @@ -93,7 +93,7 @@ enum OrbOfDragonkindManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.hasSubtype(SubType.DRAGON, game); } } diff --git a/Mage.Sets/src/mage/cards/o/OrcishSettlers.java b/Mage.Sets/src/mage/cards/o/OrcishSettlers.java index 086060c93d2..4bbdbeaacbd 100644 --- a/Mage.Sets/src/mage/cards/o/OrcishSettlers.java +++ b/Mage.Sets/src/mage/cards/o/OrcishSettlers.java @@ -77,8 +77,8 @@ class OrcishSettlersEffect extends OneShotEffect { TargetLandPermanent target = new TargetLandPermanent(amount); Player controller = game.getPlayer(source.getControllerId()); if (controller != null - && target.canChoose(source.getSourceId(), controller.getId(), game) - && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) { + && target.canChoose(controller.getId(), source, game) + && controller.choose(Outcome.DestroyPermanent, target, source, game)) { List targets = target.getTargets(); targets.forEach((landId) -> { Permanent land = game.getPermanent(landId); diff --git a/Mage.Sets/src/mage/cards/o/OrcusPrinceOfUndeath.java b/Mage.Sets/src/mage/cards/o/OrcusPrinceOfUndeath.java index 4c5fc0b3583..9af8435040b 100644 --- a/Mage.Sets/src/mage/cards/o/OrcusPrinceOfUndeath.java +++ b/Mage.Sets/src/mage/cards/o/OrcusPrinceOfUndeath.java @@ -117,7 +117,7 @@ class OrcusPrinceOfUndeathTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); int maxManaValue = this.xValue; for (UUID targetId : this.getTargets()) { @@ -126,7 +126,7 @@ class OrcusPrinceOfUndeathTarget extends TargetCardInYourGraveyard { maxManaValue -= card.getManaValue(); } } - for (UUID possibleTargetId : super.possibleTargets(sourceId, sourceControllerId, game)) { + for (UUID possibleTargetId : super.possibleTargets(sourceControllerId, source, game)) { Card card = game.getCard(possibleTargetId); if (card != null && card.getManaValue() <= maxManaValue) { possibleTargets.add(possibleTargetId); diff --git a/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java b/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java index 6534644522b..3d94f3a69f9 100644 --- a/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java +++ b/Mage.Sets/src/mage/cards/o/OrderOfSuccession.java @@ -100,7 +100,7 @@ class OrderOfSuccessionEffect extends OneShotEffect { filter.add(new ControllerIdPredicate(nextPlayer.getId())); Target target = new TargetCreaturePermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game)) { + if (target.canChoose(currentPlayer.getId(), source, game)) { if (currentPlayer.chooseTarget(outcome, target, source, game)) { playerCreature.put(currentPlayer.getId(), target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java b/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java index a6d04407530..c7be77ddf48 100644 --- a/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java +++ b/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java @@ -130,8 +130,8 @@ class OrmosArchiveKeeperTarget extends TargetCardInHand { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Set names = this.getTargets() .stream() .map(game::getCard) diff --git a/Mage.Sets/src/mage/cards/o/OrnateKanzashi.java b/Mage.Sets/src/mage/cards/o/OrnateKanzashi.java index 544fc9ed50d..85bc8afe8e8 100644 --- a/Mage.Sets/src/mage/cards/o/OrnateKanzashi.java +++ b/Mage.Sets/src/mage/cards/o/OrnateKanzashi.java @@ -72,7 +72,7 @@ class OrnateKanzashiEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && opponent != null) { if (opponent.getLibrary().hasCards()) { Library library = opponent.getLibrary(); diff --git a/Mage.Sets/src/mage/cards/o/OrvarTheAllForm.java b/Mage.Sets/src/mage/cards/o/OrvarTheAllForm.java index 56f1772fe7a..061a70752e8 100644 --- a/Mage.Sets/src/mage/cards/o/OrvarTheAllForm.java +++ b/Mage.Sets/src/mage/cards/o/OrvarTheAllForm.java @@ -156,7 +156,7 @@ class OrvarTheAllFormEffect extends OneShotEffect { filter.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(source)))); TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return new CreateTokenCopyTargetEffect() .setTargetPointer(new FixedTarget(target.getFirstTarget(), game)) .apply(game, source); diff --git a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java index 6f58f1588aa..2c54bafed9c 100644 --- a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java +++ b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java @@ -84,7 +84,7 @@ class OrzhovAdvokistEffect extends OneShotEffect { if (player != null) { if (player.chooseUse(outcome, "Put two +1/+1 counters on a creature you control?", source, game)) { Target target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature you control (to add two +1/+1 counters on it)")); - if (player.choose(outcome, target, playerId, game)) { + if (player.choose(outcome, target, source, game)) { creatures.add(target.getFirstTarget()); players.add(player.getId()); } diff --git a/Mage.Sets/src/mage/cards/o/OutOfTime.java b/Mage.Sets/src/mage/cards/o/OutOfTime.java index bc0bd0fca97..e28d782450b 100644 --- a/Mage.Sets/src/mage/cards/o/OutOfTime.java +++ b/Mage.Sets/src/mage/cards/o/OutOfTime.java @@ -72,7 +72,7 @@ class OutOfTimePhaseOutEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List creatures = game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game); + StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game); int numCreatures = creatures.size(); if (numCreatures > 0) { Set creatureIds = new HashSet<>(numCreatures); diff --git a/Mage.Sets/src/mage/cards/o/Outbreak.java b/Mage.Sets/src/mage/cards/o/Outbreak.java index dbdfba0f03a..57f9b2294d3 100644 --- a/Mage.Sets/src/mage/cards/o/Outbreak.java +++ b/Mage.Sets/src/mage/cards/o/Outbreak.java @@ -67,7 +67,7 @@ class OutbreakEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); if (player != null && player.choose(outcome, typeChoice, game)) { game.informPlayers(player.getLogName() + " has chosen " + typeChoice.getChoice()); FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures of the chosen type"); diff --git a/Mage.Sets/src/mage/cards/o/Outwit.java b/Mage.Sets/src/mage/cards/o/Outwit.java index 0c9d7feb4c4..5d149df7767 100644 --- a/Mage.Sets/src/mage/cards/o/Outwit.java +++ b/Mage.Sets/src/mage/cards/o/Outwit.java @@ -78,12 +78,12 @@ public final class Outwit extends CardImpl { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { return canChoose(sourceControllerId, game); } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage.Sets/src/mage/cards/o/Overmaster.java b/Mage.Sets/src/mage/cards/o/Overmaster.java index 0dd8c73c6c2..e25de75cc66 100644 --- a/Mage.Sets/src/mage/cards/o/Overmaster.java +++ b/Mage.Sets/src/mage/cards/o/Overmaster.java @@ -80,7 +80,7 @@ class OvermasterEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This spell can't be countered (" + sourceObject.getName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/o/OverrideCard.java b/Mage.Sets/src/mage/cards/o/OverrideCard.java index 6da4a194b31..26d9400ea31 100644 --- a/Mage.Sets/src/mage/cards/o/OverrideCard.java +++ b/Mage.Sets/src/mage/cards/o/OverrideCard.java @@ -59,7 +59,7 @@ class OverrideEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/o/Oversimplify.java b/Mage.Sets/src/mage/cards/o/Oversimplify.java index 0c4c2a03ee8..c787abafc07 100644 --- a/Mage.Sets/src/mage/cards/o/Oversimplify.java +++ b/Mage.Sets/src/mage/cards/o/Oversimplify.java @@ -71,7 +71,7 @@ class OversimplifyEffect extends OneShotEffect { } List permanents = game.getBattlefield().getActivePermanents( StaticFilters.FILTER_PERMANENT_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ); Map playerMap = permanents .stream() diff --git a/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java b/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java index 6669b410532..75303eba78f 100644 --- a/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java +++ b/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java @@ -139,7 +139,7 @@ class OverwhelmingSplendorCantActivateEffect extends ContinuousRuleModifyingEffe @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't activate abilities that aren't mana abilities or loyalty abilities (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/p/PacksDisdain.java b/Mage.Sets/src/mage/cards/p/PacksDisdain.java index 176e990b421..5ac2813ae6f 100644 --- a/Mage.Sets/src/mage/cards/p/PacksDisdain.java +++ b/Mage.Sets/src/mage/cards/p/PacksDisdain.java @@ -64,7 +64,7 @@ class PacksDisdainEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); diff --git a/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java b/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java index dcaed81c8f3..e434fa6abac 100644 --- a/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java +++ b/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java @@ -69,7 +69,7 @@ class PactOfTheSerpentEffect extends OneShotEffect { if (player == null) { return false; } - int permCount = game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game); + int permCount = game.getBattlefield().count(filter, player.getId(), source, game); if (permCount > 0) { player.drawCards(permCount, source, game); player.loseLife(permCount, game, source, false); diff --git a/Mage.Sets/src/mage/cards/p/Pallimud.java b/Mage.Sets/src/mage/cards/p/Pallimud.java index 73d6beb69a5..9b75b84921c 100644 --- a/Mage.Sets/src/mage/cards/p/Pallimud.java +++ b/Mage.Sets/src/mage/cards/p/Pallimud.java @@ -63,7 +63,7 @@ class AnathemancerCount implements DynamicValue { FilterLandPermanent filter = new FilterLandPermanent("tapped lands the chosen player controls"); filter.add(TappedPredicate.TAPPED); filter.add(new ControllerIdPredicate(playerId)); - return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } } return 0; diff --git a/Mage.Sets/src/mage/cards/p/PanopticMirror.java b/Mage.Sets/src/mage/cards/p/PanopticMirror.java index 34e7bc91e81..8eace8b92cc 100644 --- a/Mage.Sets/src/mage/cards/p/PanopticMirror.java +++ b/Mage.Sets/src/mage/cards/p/PanopticMirror.java @@ -80,7 +80,7 @@ class PanopticMirrorExileEffect extends OneShotEffect { } TargetCardInHand target = new TargetCardInHand(filter); - if (player.choose(Outcome.PlayForFree, target, source.getSourceId(), game)) { + if (player.choose(Outcome.PlayForFree, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { card.moveToExile(CardUtil.getCardExileZoneId(game, source), "Panoptic Mirror", source, game); diff --git a/Mage.Sets/src/mage/cards/p/ParadisePlume.java b/Mage.Sets/src/mage/cards/p/ParadisePlume.java index 38f7d0347b2..110f069faba 100644 --- a/Mage.Sets/src/mage/cards/p/ParadisePlume.java +++ b/Mage.Sets/src/mage/cards/p/ParadisePlume.java @@ -74,7 +74,7 @@ class ParadisePlumeSpellCastTriggeredAbility extends TriggeredAbilityImpl { filter.add(new ColorPredicate(color)); Spell spell = game.getStack().getSpell(event.getTargetId()); return (spell != null - && filter.match(spell, getSourceId(), getControllerId(), game)); + && filter.match(spell, getControllerId(), this, game)); } return false; } diff --git a/Mage.Sets/src/mage/cards/p/Paraselene.java b/Mage.Sets/src/mage/cards/p/Paraselene.java index 457fe3ef54d..df4e7607f14 100644 --- a/Mage.Sets/src/mage/cards/p/Paraselene.java +++ b/Mage.Sets/src/mage/cards/p/Paraselene.java @@ -51,7 +51,7 @@ class ParaseleneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int count = 0; - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) { if (permanent.destroy(source, game, false)) { count++; } diff --git a/Mage.Sets/src/mage/cards/p/PardicMiner.java b/Mage.Sets/src/mage/cards/p/PardicMiner.java index bfd991f3bc9..ed645495ec7 100644 --- a/Mage.Sets/src/mage/cards/p/PardicMiner.java +++ b/Mage.Sets/src/mage/cards/p/PardicMiner.java @@ -71,7 +71,7 @@ class PardicMinerEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't play lands this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java b/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java index 19752823852..153a1f80265 100644 --- a/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java +++ b/Mage.Sets/src/mage/cards/p/PatriarchsBidding.java @@ -60,7 +60,7 @@ class PatriarchsBiddingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Set chosenTypes = new HashSet<>(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/p/PatronOfTheOrochi.java b/Mage.Sets/src/mage/cards/p/PatronOfTheOrochi.java index cd23c54c398..e76e169bc80 100644 --- a/Mage.Sets/src/mage/cards/p/PatronOfTheOrochi.java +++ b/Mage.Sets/src/mage/cards/p/PatronOfTheOrochi.java @@ -76,7 +76,7 @@ class PatronOfTheOrochiEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.untap(game); } return true; diff --git a/Mage.Sets/src/mage/cards/p/PatternMatcher.java b/Mage.Sets/src/mage/cards/p/PatternMatcher.java index 6bac73e92c4..7ff91538d38 100644 --- a/Mage.Sets/src/mage/cards/p/PatternMatcher.java +++ b/Mage.Sets/src/mage/cards/p/PatternMatcher.java @@ -77,7 +77,7 @@ class RegularExpression extends OneShotEffect { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .map(Permanent::getName) .filter(Objects::nonNull) diff --git a/Mage.Sets/src/mage/cards/p/PeerPressure.java b/Mage.Sets/src/mage/cards/p/PeerPressure.java index 607a50661b5..a69e227b40a 100644 --- a/Mage.Sets/src/mage/cards/p/PeerPressure.java +++ b/Mage.Sets/src/mage/cards/p/PeerPressure.java @@ -65,7 +65,7 @@ class PeerPressureEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice choice = new ChoiceCreatureType(game.getObject(source)); if (controller != null && controller.choose(Outcome.GainControl, choice, game)) { String chosenType = choice.getChoice(); game.informPlayers(controller.getLogName() + " has chosen " + chosenType); @@ -83,7 +83,7 @@ class PeerPressureEffect extends OneShotEffect { } } if (playerWithMost != null && playerWithMost.equals(controller.getId())) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType), controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType), controller.getId(), source, game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame); effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/p/Penance.java b/Mage.Sets/src/mage/cards/p/Penance.java index 090a100378f..77abfcd09e4 100644 --- a/Mage.Sets/src/mage/cards/p/Penance.java +++ b/Mage.Sets/src/mage/cards/p/Penance.java @@ -63,7 +63,7 @@ class PenanceEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/p/Peregrination.java b/Mage.Sets/src/mage/cards/p/Peregrination.java index e8a9de463c3..c3b288f7323 100644 --- a/Mage.Sets/src/mage/cards/p/Peregrination.java +++ b/Mage.Sets/src/mage/cards/p/Peregrination.java @@ -65,7 +65,7 @@ class PeregrinationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/p/PerilousPredicament.java b/Mage.Sets/src/mage/cards/p/PerilousPredicament.java index bad01d2beab..2769bd4908c 100644 --- a/Mage.Sets/src/mage/cards/p/PerilousPredicament.java +++ b/Mage.Sets/src/mage/cards/p/PerilousPredicament.java @@ -71,14 +71,14 @@ class PerilousPredicamentSacrificeOpponentsEffect extends OneShotEffect { filterNonArtifact.add(new ControllerIdPredicate(player.getId())); if (game.getBattlefield().countAll(filterArtifact, player.getId(), game) > 0) { TargetPermanent target = new TargetPermanent(1, 1, filterArtifact, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } } if (game.getBattlefield().countAll(filterNonArtifact, player.getId(), game) > 0) { TargetPermanent target = new TargetPermanent(1, 1, filterNonArtifact, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/p/PerilousResearch.java b/Mage.Sets/src/mage/cards/p/PerilousResearch.java index 337b5ad5ab8..2ac08f26c1d 100644 --- a/Mage.Sets/src/mage/cards/p/PerilousResearch.java +++ b/Mage.Sets/src/mage/cards/p/PerilousResearch.java @@ -62,7 +62,7 @@ class PerilousResearchEffect extends OneShotEffect { if (player != null) { Target target = new TargetControlledPermanent(); - if (target.canChoose(source.getSourceId(), player.getId(), game) && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (target.canChoose(player.getId(), source, game) && player.choose(Outcome.Sacrifice, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { return permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/p/Persecute.java b/Mage.Sets/src/mage/cards/p/Persecute.java index 5e46d347235..a919d88211a 100644 --- a/Mage.Sets/src/mage/cards/p/Persecute.java +++ b/Mage.Sets/src/mage/cards/p/Persecute.java @@ -59,7 +59,7 @@ class PersecuteEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); ChoiceColor choice = new ChoiceColor(); if (controller == null diff --git a/Mage.Sets/src/mage/cards/p/PestilenceRats.java b/Mage.Sets/src/mage/cards/p/PestilenceRats.java index b671d6cca76..8cc8f423997 100644 --- a/Mage.Sets/src/mage/cards/p/PestilenceRats.java +++ b/Mage.Sets/src/mage/cards/p/PestilenceRats.java @@ -13,7 +13,7 @@ import mage.constants.Duration; import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterPermanent; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; /** * @@ -24,7 +24,7 @@ public final class PestilenceRats extends CardImpl { private static final FilterPermanent filter = new FilterPermanent("other Rats on the battlefield"); static{ filter.add(SubType.RAT.getPredicate()); - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public PestilenceRats(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/p/PestilentHaze.java b/Mage.Sets/src/mage/cards/p/PestilentHaze.java index 13e92c8ff58..98397956749 100644 --- a/Mage.Sets/src/mage/cards/p/PestilentHaze.java +++ b/Mage.Sets/src/mage/cards/p/PestilentHaze.java @@ -62,7 +62,7 @@ class PestilentHazeEffect extends OneShotEffect { game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_PERMANENT_PLANESWALKER, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .forEach(permanent -> permanent.removeCounters(CounterType.LOYALTY.createInstance(2), source, game)); return true; diff --git a/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java b/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java index 73d5b7a2973..e6cd389cb72 100644 --- a/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java +++ b/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java @@ -57,7 +57,7 @@ class PetalsOfInsightEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java b/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java index 55a2bb9fd83..b66088424d1 100644 --- a/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java +++ b/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java @@ -62,7 +62,7 @@ class PhosphorescentFeastEffect extends OneShotEffect { } if (player.getHand().count(new FilterCard(), game) > 0) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCard()); - if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, target, source, game)) { Cards cards = new CardsImpl(); for (UUID uuid : target.getTargets()) { diff --git a/Mage.Sets/src/mage/cards/p/PhylacteryLich.java b/Mage.Sets/src/mage/cards/p/PhylacteryLich.java index 05794d5e5d9..3bfe3601195 100644 --- a/Mage.Sets/src/mage/cards/p/PhylacteryLich.java +++ b/Mage.Sets/src/mage/cards/p/PhylacteryLich.java @@ -111,8 +111,8 @@ class PhylacteryLichEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { + if (player.choose(Outcome.Neutral, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.PHYLACTERY.createInstance(), source.getControllerId(), source, game); diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianDreadnought.java b/Mage.Sets/src/mage/cards/p/PhyrexianDreadnought.java index a036ab16ca5..5ae10fe9b60 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianDreadnought.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianDreadnought.java @@ -72,7 +72,7 @@ class PhyrexianDreadnoughtSacrificeCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { int sumPower = 0; - if (targets.choose(Outcome.Sacrifice, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Sacrifice, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : targets.get(0).getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null && permanent.sacrifice(source, game)) { diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java b/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java index 0f8cec5c36b..ee3c8a96093 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java @@ -69,7 +69,7 @@ class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't activate abilities of sources with that name (" + mageObject.getName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/p/PiasRevolution.java b/Mage.Sets/src/mage/cards/p/PiasRevolution.java index 9785a5a756e..7826ac4b3a1 100644 --- a/Mage.Sets/src/mage/cards/p/PiasRevolution.java +++ b/Mage.Sets/src/mage/cards/p/PiasRevolution.java @@ -117,7 +117,7 @@ class PiasRevolutionTriggeredAbility extends TriggeredAbilityImpl { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.isDiesEvent()) { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); - if (permanent != null && filter.match(permanent, sourceId, controllerId, game)) { + if (permanent != null && filter.match(permanent, controllerId, this, game)) { for (Effect effect : this.getEffects()) { effect.setValue("permanentId", event.getTargetId()); } diff --git a/Mage.Sets/src/mage/cards/p/PilgrimOfJustice.java b/Mage.Sets/src/mage/cards/p/PilgrimOfJustice.java index 13d2ef5310f..4567105d0de 100644 --- a/Mage.Sets/src/mage/cards/p/PilgrimOfJustice.java +++ b/Mage.Sets/src/mage/cards/p/PilgrimOfJustice.java @@ -87,7 +87,7 @@ class PilgrimOfJusticeEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/p/PilgrimOfVirtue.java b/Mage.Sets/src/mage/cards/p/PilgrimOfVirtue.java index 6b6a1344cac..3d32b9de466 100644 --- a/Mage.Sets/src/mage/cards/p/PilgrimOfVirtue.java +++ b/Mage.Sets/src/mage/cards/p/PilgrimOfVirtue.java @@ -87,7 +87,7 @@ class PilgrimOfVirtueEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java b/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java index b64fd74f636..28cee80e143 100644 --- a/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java +++ b/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java @@ -55,7 +55,7 @@ class PillarOfOriginsManaBuilder extends ConditionalManaBuilder { public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) { creatureType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && mana.getAny() == 0) { game.informPlayers(controller.getLogName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() + " (can only be spent to cast creatures of type " + creatureType + ")"); @@ -96,7 +96,7 @@ class PillarOfOriginsManaCondition extends CreatureCastManaCondition { // check: ... to cast a creature spell if (super.apply(game, source)) { // check: ... of the chosen type - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/p/PiousKitsune.java b/Mage.Sets/src/mage/cards/p/PiousKitsune.java index 588758d7cff..5c0c79f819f 100644 --- a/Mage.Sets/src/mage/cards/p/PiousKitsune.java +++ b/Mage.Sets/src/mage/cards/p/PiousKitsune.java @@ -83,7 +83,7 @@ class PiousKitsuneEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { boolean result; result = new AddCountersSourceEffect(CounterType.DEVOTION.createInstance()).apply(game, source); - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { int life = permanent.getCounters(game).getCount(CounterType.DEVOTION); diff --git a/Mage.Sets/src/mage/cards/p/PlagueReaver.java b/Mage.Sets/src/mage/cards/p/PlagueReaver.java index d3c1801198f..a09f62eabfc 100644 --- a/Mage.Sets/src/mage/cards/p/PlagueReaver.java +++ b/Mage.Sets/src/mage/cards/p/PlagueReaver.java @@ -87,7 +87,7 @@ class PlagueReaverSacrificeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/p/Plaguecrafter.java b/Mage.Sets/src/mage/cards/p/Plaguecrafter.java index aa1215b050b..2baf7d8d832 100644 --- a/Mage.Sets/src/mage/cards/p/Plaguecrafter.java +++ b/Mage.Sets/src/mage/cards/p/Plaguecrafter.java @@ -90,9 +90,9 @@ class PlaguecrafterEffect extends OneShotEffect { CardType.PLANESWALKER.getPredicate() )); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { while (!target.isChosen() && player.canRespond()) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); } perms.addAll(target.getTargets()); } else { diff --git a/Mage.Sets/src/mage/cards/p/PlanarBirth.java b/Mage.Sets/src/mage/cards/p/PlanarBirth.java index 7e460dfb6ab..a8f5318252b 100644 --- a/Mage.Sets/src/mage/cards/p/PlanarBirth.java +++ b/Mage.Sets/src/mage/cards/p/PlanarBirth.java @@ -62,7 +62,7 @@ class PlanarBirthEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - toBattlefield.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_BASIC_LAND, source.getSourceId(), controller.getId(), game)); + toBattlefield.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_BASIC_LAND, controller.getId(), source, game)); } } controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); diff --git a/Mage.Sets/src/mage/cards/p/PlanarCollapse.java b/Mage.Sets/src/mage/cards/p/PlanarCollapse.java index 77709aa0b35..79e5e08c402 100644 --- a/Mage.Sets/src/mage/cards/p/PlanarCollapse.java +++ b/Mage.Sets/src/mage/cards/p/PlanarCollapse.java @@ -46,7 +46,7 @@ public final class PlanarCollapse extends CardImpl { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), source.getControllerId(), game) >= 4; + return game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game) >= 4; } } } diff --git a/Mage.Sets/src/mage/cards/p/PlanarGuide.java b/Mage.Sets/src/mage/cards/p/PlanarGuide.java index f41d3116427..c366fbe99c7 100644 --- a/Mage.Sets/src/mage/cards/p/PlanarGuide.java +++ b/Mage.Sets/src/mage/cards/p/PlanarGuide.java @@ -67,11 +67,11 @@ class PlanarGuideExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (sourceObject != null && controller != null) { Set toExile = new HashSet<>(); - toExile.addAll(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); + toExile.addAll(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)); controller.moveCardsToExile(toExile, source, game, true, source.getSourceId(), sourceObject.getIdName()); ExileZone exile = game.getExile().getExileZone(source.getSourceId()); if (exile != null && !exile.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/p/PlanarOverlay.java b/Mage.Sets/src/mage/cards/p/PlanarOverlay.java index 9a397e94038..2174db94ccc 100644 --- a/Mage.Sets/src/mage/cards/p/PlanarOverlay.java +++ b/Mage.Sets/src/mage/cards/p/PlanarOverlay.java @@ -67,7 +67,7 @@ class PlanarOverlayEffect extends OneShotEffect { filter.add(landName.getPredicate()); filter.add(TargetController.YOU.getControllerPredicate()); Target target = new TargetLandPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(outcome, target, source, game); lands.add(game.getPermanent(target.getFirstTarget())); } diff --git a/Mage.Sets/src/mage/cards/p/PlaneboundAccomplice.java b/Mage.Sets/src/mage/cards/p/PlaneboundAccomplice.java index f8509ccd998..4d59ae3cda9 100644 --- a/Mage.Sets/src/mage/cards/p/PlaneboundAccomplice.java +++ b/Mage.Sets/src/mage/cards/p/PlaneboundAccomplice.java @@ -81,7 +81,7 @@ class PlaneboundAccompliceEffect extends OneShotEffect { return true; } TargetCardInHand target = new TargetCardInHand(filter); - if (!controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (!controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { return true; } Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/p/PledgeOfLoyalty.java b/Mage.Sets/src/mage/cards/p/PledgeOfLoyalty.java index 1fd372e25b6..c74c0ac7371 100644 --- a/Mage.Sets/src/mage/cards/p/PledgeOfLoyalty.java +++ b/Mage.Sets/src/mage/cards/p/PledgeOfLoyalty.java @@ -72,7 +72,7 @@ enum PledgeOfLoyaltyPredicate implements ObjectSourcePlayerPredicate .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT, - input.getPlayerId(), input.getSourceId(), game + input.getPlayerId(), input.getSource(), game ).stream() .anyMatch(permanent -> permanent.getColor(game).shares(color)); } diff --git a/Mage.Sets/src/mage/cards/p/PolymorphistsJest.java b/Mage.Sets/src/mage/cards/p/PolymorphistsJest.java index 1ad549483b8..721d81b047a 100644 --- a/Mage.Sets/src/mage/cards/p/PolymorphistsJest.java +++ b/Mage.Sets/src/mage/cards/p/PolymorphistsJest.java @@ -62,7 +62,7 @@ class PolymorphistsJestEffect extends ContinuousEffectImpl { game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - getTargetPointer().getFirst(game, source), source.getSourceId(), game + getTargetPointer().getFirst(game, source), source, game ).stream() .map(permanent -> new MageObjectReference(permanent, game)) .forEach(affectedObjectList::add); diff --git a/Mage.Sets/src/mage/cards/p/PolymorphousRush.java b/Mage.Sets/src/mage/cards/p/PolymorphousRush.java index 60233d3f703..1097da357b2 100644 --- a/Mage.Sets/src/mage/cards/p/PolymorphousRush.java +++ b/Mage.Sets/src/mage/cards/p/PolymorphousRush.java @@ -69,7 +69,7 @@ class PolymorphousRushCopyEffect extends OneShotEffect { Target target = new TargetCreaturePermanent(new FilterCreaturePermanent("")); target.setNotTarget(true); target.setTargetName("a creature on the battlefield (creature to copy)"); - if (target.canChoose(source.getId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) { + if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { Permanent copyFromCreature = game.getPermanent(target.getFirstTarget()); if (copyFromCreature != null) { for (UUID copyToId : getTargetPointer().getTargets(game, source)) { diff --git a/Mage.Sets/src/mage/cards/p/PoppetFactory.java b/Mage.Sets/src/mage/cards/p/PoppetFactory.java index 0dd45685704..862f5e6ec0c 100644 --- a/Mage.Sets/src/mage/cards/p/PoppetFactory.java +++ b/Mage.Sets/src/mage/cards/p/PoppetFactory.java @@ -76,7 +76,7 @@ class PoppetFactoryEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { switch (layer) { case AbilityAddingRemovingEffects_6: diff --git a/Mage.Sets/src/mage/cards/p/PorphyryNodes.java b/Mage.Sets/src/mage/cards/p/PorphyryNodes.java index 6ed42490729..a6b24365ca4 100644 --- a/Mage.Sets/src/mage/cards/p/PorphyryNodes.java +++ b/Mage.Sets/src/mage/cards/p/PorphyryNodes.java @@ -93,8 +93,8 @@ class PorphyryNodesEffect extends OneShotEffect { filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, leastPower)); Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { + if (controller.choose(outcome, target, source, game)) { permanentToDestroy = game.getPermanent(target.getFirstTarget()); } } @@ -127,7 +127,7 @@ class PorphyryNodesStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().count(PorphyryNodes.filter, this.getSourceId(), this.getControllerId(), game) == 0; + return game.getBattlefield().count(PorphyryNodes.filter, this.getControllerId(), this, game) == 0; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PortOfKarfell.java b/Mage.Sets/src/mage/cards/p/PortOfKarfell.java index e9861125187..b838903cd1f 100644 --- a/Mage.Sets/src/mage/cards/p/PortOfKarfell.java +++ b/Mage.Sets/src/mage/cards/p/PortOfKarfell.java @@ -78,10 +78,10 @@ class PortOfKarfellEffect extends OneShotEffect { player.millCards(4, source, game); TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return true; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); diff --git a/Mage.Sets/src/mage/cards/p/PowderKeg.java b/Mage.Sets/src/mage/cards/p/PowderKeg.java index afc9a251195..e60027d165e 100644 --- a/Mage.Sets/src/mage/cards/p/PowderKeg.java +++ b/Mage.Sets/src/mage/cards/p/PowderKeg.java @@ -72,7 +72,7 @@ class PowderKegEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent(); filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate())); filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, count)); - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { perm.destroy(source, game, false); } return true; diff --git a/Mage.Sets/src/mage/cards/p/PowerDepot.java b/Mage.Sets/src/mage/cards/p/PowerDepot.java index 73b5ea4fe67..990f9b9be77 100644 --- a/Mage.Sets/src/mage/cards/p/PowerDepot.java +++ b/Mage.Sets/src/mage/cards/p/PowerDepot.java @@ -74,7 +74,7 @@ enum PowerDepotCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isArtifact(game); } } diff --git a/Mage.Sets/src/mage/cards/p/PowerSink.java b/Mage.Sets/src/mage/cards/p/PowerSink.java index 0a9b3271587..289ebd02190 100644 --- a/Mage.Sets/src/mage/cards/p/PowerSink.java +++ b/Mage.Sets/src/mage/cards/p/PowerSink.java @@ -66,7 +66,7 @@ class PowerSinkCounterUnlessPaysEffect extends OneShotEffect { if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && controller != null && sourceObject != null) { int amount = source.getManaCostsToPay().getX(); if (amount > 0) { diff --git a/Mage.Sets/src/mage/cards/p/PowerstoneMinefield.java b/Mage.Sets/src/mage/cards/p/PowerstoneMinefield.java index 6871fbed40c..e69f54accc4 100644 --- a/Mage.Sets/src/mage/cards/p/PowerstoneMinefield.java +++ b/Mage.Sets/src/mage/cards/p/PowerstoneMinefield.java @@ -12,7 +12,6 @@ import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -59,7 +58,7 @@ class PowerstoneMinefieldTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (filter.match(permanent, getControllerId(), this, game)) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(permanent, game)); } diff --git a/Mage.Sets/src/mage/cards/p/Pox.java b/Mage.Sets/src/mage/cards/p/Pox.java index 62e0023aba6..ad9a77092cd 100644 --- a/Mage.Sets/src/mage/cards/p/Pox.java +++ b/Mage.Sets/src/mage/cards/p/Pox.java @@ -86,7 +86,7 @@ class PoxEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 3.0); + int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, player.getId(), source, game) / 3.0); if (creaturesToSacrifice > 0) { Target target = new TargetControlledCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true); target.chooseTarget(Outcome.Sacrifice, playerId, source, game); @@ -104,7 +104,7 @@ class PoxEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { FilterControlledLandPermanent filter = new FilterControlledLandPermanent(); - int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 3.0); + int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, player.getId(), source, game) / 3.0); if (landsToSacrifice > 0) { Target target = new TargetControlledPermanent(landsToSacrifice, landsToSacrifice, filter, true); target.chooseTarget(Outcome.Sacrifice, playerId, source, game); diff --git a/Mage.Sets/src/mage/cards/p/PrecursorGolem.java b/Mage.Sets/src/mage/cards/p/PrecursorGolem.java index 3193a0944c8..14055e2644d 100644 --- a/Mage.Sets/src/mage/cards/p/PrecursorGolem.java +++ b/Mage.Sets/src/mage/cards/p/PrecursorGolem.java @@ -144,7 +144,7 @@ class PrecursorGolemCopySpellEffect extends CopySpellForEachItCouldTargetEffect Permanent permanent = game.getPermanent((UUID) getValue("targetedGolem")); return game.getBattlefield() .getActivePermanents( - filter, player.getId(), source.getSourceId(), game + filter, player.getId(), source, game ).stream() .filter(Objects::nonNull) .filter(p -> !p.equals(permanent)) diff --git a/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java b/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java index 021dc61b36e..3431375138f 100644 --- a/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java +++ b/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java @@ -70,8 +70,8 @@ class PreeminentCaptainEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); TargetCardInHand target = new TargetCardInHand(filter); - if (controller != null && target.canChoose(source.getSourceId(), controller.getId(), game) - && target.choose(outcome, controller.getId(), source.getSourceId(), game)) { + if (controller != null && target.canChoose(controller.getId(), source, game) + && target.choose(outcome, controller.getId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { UUID cardId = target.getFirstTarget(); Card card = controller.getHand().get(cardId, game); diff --git a/Mage.Sets/src/mage/cards/p/PrematureBurial.java b/Mage.Sets/src/mage/cards/p/PrematureBurial.java index cdf917f8900..90b28af2dde 100644 --- a/Mage.Sets/src/mage/cards/p/PrematureBurial.java +++ b/Mage.Sets/src/mage/cards/p/PrematureBurial.java @@ -65,11 +65,11 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - MageObject targetSource = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + MageObject targetSource = game.getObject(source); ETBSinceYourLastTurnWatcher watcher = game.getState().getWatcher(ETBSinceYourLastTurnWatcher.class); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (watcher != null && watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) { return true; diff --git a/Mage.Sets/src/mage/cards/p/PriestOfTheBlessedGraf.java b/Mage.Sets/src/mage/cards/p/PriestOfTheBlessedGraf.java index c7f0ff1ae68..e53b005ea4e 100644 --- a/Mage.Sets/src/mage/cards/p/PriestOfTheBlessedGraf.java +++ b/Mage.Sets/src/mage/cards/p/PriestOfTheBlessedGraf.java @@ -83,7 +83,7 @@ enum PriestOfTheBlessedGrafValue implements DynamicValue { .getActivePermanents( StaticFilters.FILTER_LAND, source.getControllerId(), - source.getSourceId(), game + source, game ).stream() .map(Controllable::getControllerId) .collect(Collectors.toMap(Function.identity(), u -> 1, Integer::sum)); diff --git a/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java b/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java index 23a784c96b5..de09b3299f6 100644 --- a/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java +++ b/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java @@ -92,10 +92,10 @@ class PriestOfTheWakeningSunEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { - if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + if (controller.getHand().count(filter, source.getControllerId(), source, game) > 0) { if (controller.chooseUse(outcome, "Reveal a Dinosaur card?", source, game)) { TargetCardInHand target = new TargetCardInHand(0, 1, filter); if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/p/PrimalBeyond.java b/Mage.Sets/src/mage/cards/p/PrimalBeyond.java index 4154f90de1f..ceb104e0a1f 100644 --- a/Mage.Sets/src/mage/cards/p/PrimalBeyond.java +++ b/Mage.Sets/src/mage/cards/p/PrimalBeyond.java @@ -82,7 +82,7 @@ class PrimalBeyondManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.hasSubtype(SubType.ELEMENTAL, game); } } diff --git a/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java b/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java index c4f3c0acbf8..ce5744e1519 100644 --- a/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java +++ b/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java @@ -87,7 +87,7 @@ class PrimalEmpathyEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/p/PrimalWellspring.java b/Mage.Sets/src/mage/cards/p/PrimalWellspring.java index ab26a7e5e15..5b081add0d0 100644 --- a/Mage.Sets/src/mage/cards/p/PrimalWellspring.java +++ b/Mage.Sets/src/mage/cards/p/PrimalWellspring.java @@ -78,7 +78,7 @@ class PyrimalWellspringTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getData().equals(abilityOriginalId)) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { + if (spell != null && filter.match(spell, getControllerId(), this, game)) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } diff --git a/Mage.Sets/src/mage/cards/p/PrimevalProtector.java b/Mage.Sets/src/mage/cards/p/PrimevalProtector.java index 1249e131245..9d5bcd5044f 100644 --- a/Mage.Sets/src/mage/cards/p/PrimevalProtector.java +++ b/Mage.Sets/src/mage/cards/p/PrimevalProtector.java @@ -85,7 +85,7 @@ class PrimevalProtectorCostReductionEffect extends CostModificationEffectImpl { public boolean apply(Game game, Ability source, Ability abilityToModify) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int reductionAmount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int reductionAmount = game.getBattlefield().count(filter, source.getControllerId(), source, game); CardUtil.reduceCost(abilityToModify, reductionAmount); return true; } diff --git a/Mage.Sets/src/mage/cards/p/PrimordialMist.java b/Mage.Sets/src/mage/cards/p/PrimordialMist.java index aed0a8ee77e..7351d56fa39 100644 --- a/Mage.Sets/src/mage/cards/p/PrimordialMist.java +++ b/Mage.Sets/src/mage/cards/p/PrimordialMist.java @@ -83,14 +83,14 @@ class PrimordialMistCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (target.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { Card card = game.getCard(source.getSourceId()); if (card != null) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/p/PrismaticStrands.java b/Mage.Sets/src/mage/cards/p/PrismaticStrands.java index 803605e2a27..242af3e501d 100644 --- a/Mage.Sets/src/mage/cards/p/PrismaticStrands.java +++ b/Mage.Sets/src/mage/cards/p/PrismaticStrands.java @@ -76,7 +76,7 @@ class PrismaticStrandsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { ChoiceColor choice = new ChoiceColor(); controller.choose(Outcome.PreventDamage, choice, game); diff --git a/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java b/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java index 050443cac41..198f63905ca 100644 --- a/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java +++ b/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java @@ -68,7 +68,7 @@ class ProfanerOfTheDeadReturnEffect extends OneShotEffect { filter.add(TargetController.OPPONENT.getControllerPredicate()); filter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, exploitedCreature.getToughness().getValue())); Cards cardsToHand = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { cardsToHand.add(permanent); } controller.moveCards(cardsToHand, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/p/ProfessorOnyx.java b/Mage.Sets/src/mage/cards/p/ProfessorOnyx.java index 2ed5ca66be3..1a1d3aa264f 100644 --- a/Mage.Sets/src/mage/cards/p/ProfessorOnyx.java +++ b/Mage.Sets/src/mage/cards/p/ProfessorOnyx.java @@ -126,7 +126,7 @@ class ProfessorOnyxEffect extends OneShotEffect { TargetDiscard target = new TargetDiscard( 0, 1, StaticFilters.FILTER_CARD, playerId ); - player.choose(Outcome.Discard, target, source.getSourceId(), game); + player.choose(Outcome.Discard, target, source, game); playerMap.put(playerId, game.getCard(target.getFirstTarget())); } for (UUID playerId : game.getOpponents(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/p/PromiseOfLoyalty.java b/Mage.Sets/src/mage/cards/p/PromiseOfLoyalty.java index 1a0847bb96e..3a03bf6bae5 100644 --- a/Mage.Sets/src/mage/cards/p/PromiseOfLoyalty.java +++ b/Mage.Sets/src/mage/cards/p/PromiseOfLoyalty.java @@ -67,13 +67,13 @@ class PromiseOfLoyaltyEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), playerId, game + playerId, source, game ) < 1) { continue; } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/p/Prophecy.java b/Mage.Sets/src/mage/cards/p/Prophecy.java index 26d3f8daa76..282250b8454 100644 --- a/Mage.Sets/src/mage/cards/p/Prophecy.java +++ b/Mage.Sets/src/mage/cards/p/Prophecy.java @@ -66,7 +66,7 @@ class ProphecyEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null || targetPlayer == null || controller == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/p/ProtectiveSphere.java b/Mage.Sets/src/mage/cards/p/ProtectiveSphere.java index 568ba369b55..a74c315252d 100644 --- a/Mage.Sets/src/mage/cards/p/ProtectiveSphere.java +++ b/Mage.Sets/src/mage/cards/p/ProtectiveSphere.java @@ -88,7 +88,7 @@ class ProtectiveSphereEffect extends PreventionEffectImpl { CardUtil.addToolTipMarkTags("Last mana used for protective ability: " + source.getManaCostsToPay().getUsedManaToPay()), game); } - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/p/PrototypePortal.java b/Mage.Sets/src/mage/cards/p/PrototypePortal.java index bc455c55467..858ab8e3e50 100644 --- a/Mage.Sets/src/mage/cards/p/PrototypePortal.java +++ b/Mage.Sets/src/mage/cards/p/PrototypePortal.java @@ -97,7 +97,7 @@ class PrototypePortalEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (!controller.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_ARTIFACT); diff --git a/Mage.Sets/src/mage/cards/p/PryingQuestions.java b/Mage.Sets/src/mage/cards/p/PryingQuestions.java index 7648643d4e1..8bb3fd0ba88 100644 --- a/Mage.Sets/src/mage/cards/p/PryingQuestions.java +++ b/Mage.Sets/src/mage/cards/p/PryingQuestions.java @@ -64,7 +64,7 @@ class PryingQuestionsEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand(); target.setNotTarget(true); target.setTargetName("a card from your hand to put on top of your library"); - targetOpponent.choose(Outcome.Detriment, target, source.getSourceId(), game); + targetOpponent.choose(Outcome.Detriment, target, source, game); Card card = targetOpponent.getHand().get(target.getFirstTarget(), game); if (card != null) { targetOpponent.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false); diff --git a/Mage.Sets/src/mage/cards/p/PsychicBattle.java b/Mage.Sets/src/mage/cards/p/PsychicBattle.java index 5f16ba8501d..f7b4116d71c 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicBattle.java +++ b/Mage.Sets/src/mage/cards/p/PsychicBattle.java @@ -101,7 +101,7 @@ class PsychicBattleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { Map manacostMap = new HashMap<>(); for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/p/PsychicIntrusion.java b/Mage.Sets/src/mage/cards/p/PsychicIntrusion.java index c1715b61647..8fdab756c3e 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicIntrusion.java +++ b/Mage.Sets/src/mage/cards/p/PsychicIntrusion.java @@ -68,7 +68,7 @@ class PsychicIntrusionExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (opponent != null && sourceObject != null) { opponent.revealCards(sourceObject.getName(), opponent.getHand(), game); Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/p/PucasMischief.java b/Mage.Sets/src/mage/cards/p/PucasMischief.java index 9c3c739ccc9..bec4dc4d74d 100644 --- a/Mage.Sets/src/mage/cards/p/PucasMischief.java +++ b/Mage.Sets/src/mage/cards/p/PucasMischief.java @@ -63,11 +63,11 @@ class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } @@ -112,12 +112,12 @@ class PucasMischiefSecondTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); if (firstTarget != null) { - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (firstTarget.getManaValue() >= permanent.getManaValue()) { possibleTargets.add(permanent.getId()); diff --git a/Mage.Sets/src/mage/cards/p/PureReflection.java b/Mage.Sets/src/mage/cards/p/PureReflection.java index 280e3bcdd20..91f0a7b923d 100644 --- a/Mage.Sets/src/mage/cards/p/PureReflection.java +++ b/Mage.Sets/src/mage/cards/p/PureReflection.java @@ -68,7 +68,7 @@ public final class PureReflection extends CardImpl { // destroy all Reflections FilterPermanent filter = new FilterPermanent("Reflections"); filter.add(SubType.REFLECTION.getPredicate()); - game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).forEach((permanent) -> { + game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).forEach((permanent) -> { permanent.destroy(source, game,false); }); game.getState().processAction(game); diff --git a/Mage.Sets/src/mage/cards/p/PurgingScythe.java b/Mage.Sets/src/mage/cards/p/PurgingScythe.java index 84c3744262a..47f697e0c00 100644 --- a/Mage.Sets/src/mage/cards/p/PurgingScythe.java +++ b/Mage.Sets/src/mage/cards/p/PurgingScythe.java @@ -85,8 +85,8 @@ class PurgingScytheEffect extends OneShotEffect { filter.add(new ToughnessPredicate(ComparisonType.EQUAL_TO, leastToughness)); Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { + if (controller.choose(outcome, target, source, game)) { permanentToDamage = game.getPermanent(target.getFirstTarget()); } } diff --git a/Mage.Sets/src/mage/cards/p/PurphorosBronzeBlooded.java b/Mage.Sets/src/mage/cards/p/PurphorosBronzeBlooded.java index 00e7cf2696b..396936b60fb 100644 --- a/Mage.Sets/src/mage/cards/p/PurphorosBronzeBlooded.java +++ b/Mage.Sets/src/mage/cards/p/PurphorosBronzeBlooded.java @@ -107,7 +107,7 @@ class PurphurosBronzeBloodedEffect extends OneShotEffect { return true; } TargetCardInHand target = new TargetCardInHand(filter); - if (!controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (!controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { return true; } Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/p/Putrefaction.java b/Mage.Sets/src/mage/cards/p/Putrefaction.java index 3b46d4d2d30..7a89783453b 100644 --- a/Mage.Sets/src/mage/cards/p/Putrefaction.java +++ b/Mage.Sets/src/mage/cards/p/Putrefaction.java @@ -58,7 +58,7 @@ class PutrefactionTriggeredAbility extends SpellCastAllTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filterGreenOrWhiteSpell.match(spell, getSourceId(), getControllerId(), game)) { + if (spell != null && filterGreenOrWhiteSpell.match(spell, getControllerId(), this, game)) { this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } diff --git a/Mage.Sets/src/mage/cards/p/PyromancersGoggles.java b/Mage.Sets/src/mage/cards/p/PyromancersGoggles.java index e0d275217f4..9b9ef58deea 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersGoggles.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersGoggles.java @@ -17,7 +17,6 @@ import mage.filter.common.FilterInstantOrSorcerySpell; import mage.filter.predicate.mageobject.ColorPredicate; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.stack.Spell; import mage.target.targetpointer.FixedTarget; @@ -86,7 +85,7 @@ class PyromancersGogglesTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getData().equals(abilityOriginalId)) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { + if (spell != null && filter.match(spell, getControllerId(), this, game)) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } diff --git a/Mage.Sets/src/mage/cards/q/QarsiDeceiver.java b/Mage.Sets/src/mage/cards/q/QarsiDeceiver.java index 796af6814b0..086c12f658e 100644 --- a/Mage.Sets/src/mage/cards/q/QarsiDeceiver.java +++ b/Mage.Sets/src/mage/cards/q/QarsiDeceiver.java @@ -71,7 +71,7 @@ class QarsiDeceiverManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object instanceof Spell) { if (((Spell) object).isFaceDown(game)) { return true; diff --git a/Mage.Sets/src/mage/cards/q/Quakebringer.java b/Mage.Sets/src/mage/cards/q/Quakebringer.java index 820fcea1702..59a94214a43 100644 --- a/Mage.Sets/src/mage/cards/q/Quakebringer.java +++ b/Mage.Sets/src/mage/cards/q/Quakebringer.java @@ -75,7 +75,7 @@ class QuakebringerTriggeredAbility extends TriggeredAbilityImpl { return game.isActivePlayer(getControllerId()); case GRAVEYARD: return game.isActivePlayer(game.getOwnerId(getSourceId())) - && game.getBattlefield().count(filter, getSourceId(), getControllerId(), game) > 0; + && game.getBattlefield().count(filter, getControllerId(), this, game) > 0; } return false; } diff --git a/Mage.Sets/src/mage/cards/q/QuestForTheHolyRelic.java b/Mage.Sets/src/mage/cards/q/QuestForTheHolyRelic.java index 7b4ec91c3b2..c010b787e1a 100644 --- a/Mage.Sets/src/mage/cards/q/QuestForTheHolyRelic.java +++ b/Mage.Sets/src/mage/cards/q/QuestForTheHolyRelic.java @@ -93,7 +93,7 @@ class QuestForTheHolyRelicEffect extends OneShotEffect { if (card != null && controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent equipment = game.getPermanent(card.getId()); Target targetCreature = new TargetControlledCreaturePermanent(); - if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) { + if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source, game)) { Permanent permanent = game.getPermanent(targetCreature.getFirstTarget()); permanent.addAttachment(equipment.getId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/r/RadiantPerformer.java b/Mage.Sets/src/mage/cards/r/RadiantPerformer.java index 8ec84b230d2..0a14e6dc75c 100644 --- a/Mage.Sets/src/mage/cards/r/RadiantPerformer.java +++ b/Mage.Sets/src/mage/cards/r/RadiantPerformer.java @@ -131,7 +131,7 @@ class RadiantPerformerEffect extends CopySpellForEachItCouldTargetEffect { .orElse(null); game.getBattlefield() .getActivePermanents( - StaticFilters.FILTER_PERMANENT, player.getId(), source.getSourceId(), game + StaticFilters.FILTER_PERMANENT, player.getId(), source, game ).stream() .filter(Objects::nonNull) .filter(p -> !p.equals(game.getPermanent(targeted))) diff --git a/Mage.Sets/src/mage/cards/r/Radiate.java b/Mage.Sets/src/mage/cards/r/Radiate.java index 5e8eeabc69e..3898c50a951 100644 --- a/Mage.Sets/src/mage/cards/r/Radiate.java +++ b/Mage.Sets/src/mage/cards/r/Radiate.java @@ -134,7 +134,7 @@ class RadiateEffect extends CopySpellForEachItCouldTargetEffect { .orElse(null); game.getBattlefield() .getActivePermanents( - StaticFilters.FILTER_PERMANENT, player.getId(), source.getSourceId(), game + StaticFilters.FILTER_PERMANENT, player.getId(), source, game ).stream() .filter(Objects::nonNull) .filter(p -> !p.equals(game.getPermanent(targeted))) diff --git a/Mage.Sets/src/mage/cards/r/RagingRiver.java b/Mage.Sets/src/mage/cards/r/RagingRiver.java index a712afc0885..157501fc9b1 100644 --- a/Mage.Sets/src/mage/cards/r/RagingRiver.java +++ b/Mage.Sets/src/mage/cards/r/RagingRiver.java @@ -86,13 +86,13 @@ class RagingRiverEffect extends OneShotEffect { FilterControlledCreaturePermanent filterBlockers = new FilterControlledCreaturePermanent("creatures without flying you control to assign to the \"left\" pile (creatures not chosen will be assigned to the \"right\" pile)"); filterBlockers.add(Predicates.not(new AbilityPredicate(FlyingAbility.class))); Target target = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, filterBlockers, true); - if (target.canChoose(source.getSourceId(), defenderId, game)) { + if (target.canChoose(defenderId, source, game)) { if (defender.chooseTarget(Outcome.Neutral, target, source, game)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), defenderId, game)) { if (target.getTargets().contains(permanent.getId())) { left.add(permanent); leftLog.add(permanent); - } else if (filterBlockers.match(permanent, source.getSourceId(), defenderId, game)) { + } else if (filterBlockers.match(permanent, defenderId, source, game)) { right.add(permanent); rightLog.add(permanent); } diff --git a/Mage.Sets/src/mage/cards/r/RagsRiches.java b/Mage.Sets/src/mage/cards/r/RagsRiches.java index 25443012c5e..3306ee4bc3c 100644 --- a/Mage.Sets/src/mage/cards/r/RagsRiches.java +++ b/Mage.Sets/src/mage/cards/r/RagsRiches.java @@ -76,7 +76,7 @@ class RichesEffect extends OneShotEffect { if (opponent != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (opponent.choose(Outcome.Detriment, target, source.getSourceId(), game)) { + if (opponent.choose(Outcome.Detriment, target, source, game)) { creaturesToSteal.add(target.getTargets().get(0)); } } diff --git a/Mage.Sets/src/mage/cards/r/RaidingParty.java b/Mage.Sets/src/mage/cards/r/RaidingParty.java index 60b23191a5e..2c6991e1049 100644 --- a/Mage.Sets/src/mage/cards/r/RaidingParty.java +++ b/Mage.Sets/src/mage/cards/r/RaidingParty.java @@ -101,7 +101,7 @@ class RaidingPartyEffect extends OneShotEffect { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); int tappedCount = 0; Target untappedCreatureTarget = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, filter, true); - if (player.choose(Outcome.Benefit, untappedCreatureTarget, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, untappedCreatureTarget, source, game)) { tappedCount = untappedCreatureTarget.getTargets().size(); for (UUID creatureId : untappedCreatureTarget.getTargets()) { Permanent creature = game.getPermanentOrLKIBattlefield(creatureId); @@ -112,7 +112,7 @@ class RaidingPartyEffect extends OneShotEffect { } if (tappedCount > 0) { Target plainsToSaveTarget = new TargetPermanent(0, tappedCount * 2, filter2, true); - if (player.choose(Outcome.Benefit, plainsToSaveTarget, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, plainsToSaveTarget, source, game)) { for (UUID plainsId : plainsToSaveTarget.getTargets()) { plainsToSave.add(plainsId); Permanent plains = game.getPermanent(plainsId); @@ -124,7 +124,7 @@ class RaidingPartyEffect extends OneShotEffect { } } } - for (Permanent plains : game.getBattlefield().getActivePermanents(filter2, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent plains : game.getBattlefield().getActivePermanents(filter2, source.getControllerId(), source, game)) { if (!plainsToSave.contains(plains.getId())) { plains.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/r/RaiseTheDraugr.java b/Mage.Sets/src/mage/cards/r/RaiseTheDraugr.java index 8e6c1295a83..f53cdc145ba 100644 --- a/Mage.Sets/src/mage/cards/r/RaiseTheDraugr.java +++ b/Mage.Sets/src/mage/cards/r/RaiseTheDraugr.java @@ -74,8 +74,8 @@ class RaiseTheDraugrTarget extends TargetCardInYourGraveyard { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - MageObject targetSource = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + MageObject targetSource = game.getObject(source); Player player = game.getPlayer(sourceControllerId); if (player == null) { return false; @@ -84,7 +84,7 @@ class RaiseTheDraugrTarget extends TargetCardInYourGraveyard { return false; } List cards = player.getGraveyard().getCards( - filter, sourceId, sourceControllerId, game + filter, sourceControllerId, source, game ).stream().collect(Collectors.toList()); if (cards.size() < 2) { return false; diff --git a/Mage.Sets/src/mage/cards/r/RakdosCharm.java b/Mage.Sets/src/mage/cards/r/RakdosCharm.java index 877048ddad4..5f8d0203455 100644 --- a/Mage.Sets/src/mage/cards/r/RakdosCharm.java +++ b/Mage.Sets/src/mage/cards/r/RakdosCharm.java @@ -66,7 +66,7 @@ public final class RakdosCharm extends CardImpl { FilterPermanent filter = new FilterPermanent(); filter.add(CardType.CREATURE.getPredicate()); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null) { controller.damage(1, permanent.getId(), source, game); diff --git a/Mage.Sets/src/mage/cards/r/RallyTheRighteous.java b/Mage.Sets/src/mage/cards/r/RallyTheRighteous.java index b023e3dad84..21bf66e984b 100644 --- a/Mage.Sets/src/mage/cards/r/RallyTheRighteous.java +++ b/Mage.Sets/src/mage/cards/r/RallyTheRighteous.java @@ -65,7 +65,7 @@ class RallyTheRighteousUntapEffect extends OneShotEffect { if (target != null) { ObjectColor color = target.getColor(game); target.untap(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (permanent.getColor(game).shares(color) && !permanent.getId().equals(target.getId())) { permanent.untap(game); } @@ -94,7 +94,7 @@ class RallyTheRighteousBoostEffect extends ContinuousEffectImpl { if (target != null) { affectedObjectList.add(new MageObjectReference(target, game)); ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) { affectedObjectList.add(new MageObjectReference(permanent, game)); } diff --git a/Mage.Sets/src/mage/cards/r/RampageOfTheClans.java b/Mage.Sets/src/mage/cards/r/RampageOfTheClans.java index a05dfd1a88f..e778f768168 100644 --- a/Mage.Sets/src/mage/cards/r/RampageOfTheClans.java +++ b/Mage.Sets/src/mage/cards/r/RampageOfTheClans.java @@ -61,7 +61,7 @@ class RampageOfTheClansEffect extends OneShotEffect { Map playersWithPermanents = new HashMap<>(); for (Permanent p : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { UUID controllerId = p.getControllerId(); if (p.destroy(source, game, false)) { diff --git a/Mage.Sets/src/mage/cards/r/RampageOfTheValkyries.java b/Mage.Sets/src/mage/cards/r/RampageOfTheValkyries.java index cdd2845b220..bd5f0d149ab 100644 --- a/Mage.Sets/src/mage/cards/r/RampageOfTheValkyries.java +++ b/Mage.Sets/src/mage/cards/r/RampageOfTheValkyries.java @@ -77,10 +77,10 @@ class RampageOfTheValkyriesEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), playerId, game)) { + if (!target.canChoose(playerId, source, game)) { continue; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); perms.add(target.getFirstTarget()); } for (UUID permID : perms) { diff --git a/Mage.Sets/src/mage/cards/r/RampagingFerocidon.java b/Mage.Sets/src/mage/cards/r/RampagingFerocidon.java index 643d0b355bb..aa4d29bc318 100644 --- a/Mage.Sets/src/mage/cards/r/RampagingFerocidon.java +++ b/Mage.Sets/src/mage/cards/r/RampagingFerocidon.java @@ -88,7 +88,7 @@ class RampagingFerocidonEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); Player player = game.getPlayer(event.getPlayerId()); if (mageObject != null && player != null) { return player.getLogName() + " can't get " + event.getAmount() + " life (" + mageObject.getIdName() + ")."; diff --git a/Mage.Sets/src/mage/cards/r/RangeTrooper.java b/Mage.Sets/src/mage/cards/r/RangeTrooper.java index 059cb4a3469..2aa6a6e11f2 100644 --- a/Mage.Sets/src/mage/cards/r/RangeTrooper.java +++ b/Mage.Sets/src/mage/cards/r/RangeTrooper.java @@ -71,7 +71,7 @@ class RangeTrooperEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (permanent != null && sourceObject != null) { if (permanent.moveToExile(source.getSourceId(), sourceObject.getIdName(), source, game)) { Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false); diff --git a/Mage.Sets/src/mage/cards/r/RangerCaptainOfEos.java b/Mage.Sets/src/mage/cards/r/RangerCaptainOfEos.java index 8d6122791c0..5e17f7dec7c 100644 --- a/Mage.Sets/src/mage/cards/r/RangerCaptainOfEos.java +++ b/Mage.Sets/src/mage/cards/r/RangerCaptainOfEos.java @@ -85,7 +85,7 @@ class RangerCaptainOfEosEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast noncreature spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/r/RavagerOfTheFells.java b/Mage.Sets/src/mage/cards/r/RavagerOfTheFells.java index 75d0f2abc71..e01bb4e0b06 100644 --- a/Mage.Sets/src/mage/cards/r/RavagerOfTheFells.java +++ b/Mage.Sets/src/mage/cards/r/RavagerOfTheFells.java @@ -119,16 +119,16 @@ class RavagerOfTheFellsTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); for (StackObject item : game.getState().getStack()) { - if (item.getId().equals(sourceId)) { + if (item.getId().equals(source.getSourceId())) { object = item; } - if (item.getSourceId().equals(sourceId)) { + if (item.getSourceId().equals(source.getSourceId())) { object = item; } } diff --git a/Mage.Sets/src/mage/cards/r/RavenousRotbelly.java b/Mage.Sets/src/mage/cards/r/RavenousRotbelly.java index 0c90d344ad4..81ca082e72d 100644 --- a/Mage.Sets/src/mage/cards/r/RavenousRotbelly.java +++ b/Mage.Sets/src/mage/cards/r/RavenousRotbelly.java @@ -75,7 +75,7 @@ class RavenousRotbellyEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(0, 3, filter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); int amount = 0; for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); diff --git a/Mage.Sets/src/mage/cards/r/RavingOniSlave.java b/Mage.Sets/src/mage/cards/r/RavingOniSlave.java index 99d500be093..645c329801e 100644 --- a/Mage.Sets/src/mage/cards/r/RavingOniSlave.java +++ b/Mage.Sets/src/mage/cards/r/RavingOniSlave.java @@ -63,7 +63,7 @@ class RavingOniSlaveEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - if (game.getBattlefield().count(new FilterCreaturePermanent(SubType.DEMON, "Demon"), source.getSourceId(), source.getControllerId(), game) < 1) { + if (game.getBattlefield().count(new FilterCreaturePermanent(SubType.DEMON, "Demon"), source.getControllerId(), source, game) < 1) { controller.loseLife(3, game, source, false); } return true; diff --git a/Mage.Sets/src/mage/cards/r/RaziasPurification.java b/Mage.Sets/src/mage/cards/r/RaziasPurification.java index 09c27708bed..45cfedbbcd8 100644 --- a/Mage.Sets/src/mage/cards/r/RaziasPurification.java +++ b/Mage.Sets/src/mage/cards/r/RaziasPurification.java @@ -61,9 +61,9 @@ class RaziasPurificationEffect extends OneShotEffect { Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true); - if (player != null && target1.canChoose(source.getSourceId(), player.getId(), game)) { + if (player != null && target1.canChoose(player.getId(), source, game)) { int chosenPermanents = 0; - while (player.canRespond() && !target1.isChosen() && target1.canChoose(source.getSourceId(), player.getId(), game) && chosenPermanents < 3) { + while (player.canRespond() && !target1.isChosen() && target1.canChoose(player.getId(), source, game) && chosenPermanents < 3) { player.chooseTarget(Outcome.Benefit, target1, source, game); for (UUID targetId : target1.getTargets()) { Permanent p = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/r/RealitySpasm.java b/Mage.Sets/src/mage/cards/r/RealitySpasm.java index b4ff575f8bd..8c145d24001 100644 --- a/Mage.Sets/src/mage/cards/r/RealitySpasm.java +++ b/Mage.Sets/src/mage/cards/r/RealitySpasm.java @@ -59,7 +59,7 @@ class RealitySpasmTapEffect extends OneShotEffect { int numberToTap = source.getManaCostsToPay().getX(); numberToTap = Math.min(game.getBattlefield().getAllActivePermanents().size(), numberToTap); TargetPermanent target = new TargetPermanent(numberToTap, filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { List targets = target.getTargets(); for (UUID targetId : targets) { @@ -99,7 +99,7 @@ class RealitySpasmUntapEffect extends OneShotEffect { int numberToTap = source.getManaCostsToPay().getX(); numberToTap = Math.min(game.getBattlefield().getAllActivePermanents().size(), numberToTap); TargetPermanent target = new TargetPermanent(numberToTap, filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { List targets = target.getTargets(); for (UUID targetId : targets) { diff --git a/Mage.Sets/src/mage/cards/r/RealmRazer.java b/Mage.Sets/src/mage/cards/r/RealmRazer.java index eb94b29230c..9b887201a75 100644 --- a/Mage.Sets/src/mage/cards/r/RealmRazer.java +++ b/Mage.Sets/src/mage/cards/r/RealmRazer.java @@ -67,7 +67,7 @@ class ExileAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.moveToExile(source.getSourceId(), "Realm Razer", source, game); } diff --git a/Mage.Sets/src/mage/cards/r/RealmsUncharted.java b/Mage.Sets/src/mage/cards/r/RealmsUncharted.java index 66be7129b49..472cd5f8c77 100644 --- a/Mage.Sets/src/mage/cards/r/RealmsUncharted.java +++ b/Mage.Sets/src/mage/cards/r/RealmsUncharted.java @@ -81,7 +81,7 @@ class RealmsUnchartedEffect extends OneShotEffect { if (cards.size() > 2) { TargetOpponent targetOpponent = new TargetOpponent(); targetOpponent.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); Cards cardsToKeep = new CardsImpl(); cardsToKeep.addAll(cards); diff --git a/Mage.Sets/src/mage/cards/r/Realmwright.java b/Mage.Sets/src/mage/cards/r/Realmwright.java index 96b76907af1..2c3441e00f8 100644 --- a/Mage.Sets/src/mage/cards/r/Realmwright.java +++ b/Mage.Sets/src/mage/cards/r/Realmwright.java @@ -113,7 +113,7 @@ class RealmwrightEffect extends ContinuousEffectImpl { } for (Permanent land : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (land == null || land.hasSubtype(choice, game)) { continue; diff --git a/Mage.Sets/src/mage/cards/r/ReapIntellect.java b/Mage.Sets/src/mage/cards/r/ReapIntellect.java index 0d5fde0fd59..2c964c81201 100644 --- a/Mage.Sets/src/mage/cards/r/ReapIntellect.java +++ b/Mage.Sets/src/mage/cards/r/ReapIntellect.java @@ -74,7 +74,7 @@ class ReapIntellectEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (targetPlayer != null && sourceObject != null && controller != null) { // reveal hand of target player diff --git a/Mage.Sets/src/mage/cards/r/RebbecArchitectOfAscension.java b/Mage.Sets/src/mage/cards/r/RebbecArchitectOfAscension.java index e5f023a7ba0..f1bfbf404e9 100644 --- a/Mage.Sets/src/mage/cards/r/RebbecArchitectOfAscension.java +++ b/Mage.Sets/src/mage/cards/r/RebbecArchitectOfAscension.java @@ -70,7 +70,7 @@ enum RebbecArchitectOfAscensionPredicate implements ObjectSourcePlayerPredicate< return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, - game.getControllerId(input.getSourceId()), input.getSourceId(), game + game.getControllerId(input.getSourceId()), input.getSource(), game ).stream() .filter(Objects::nonNull) .mapToInt(MageObject::getManaValue) diff --git a/Mage.Sets/src/mage/cards/r/Rebound.java b/Mage.Sets/src/mage/cards/r/Rebound.java index eae18ec190e..adf5cbd7db1 100644 --- a/Mage.Sets/src/mage/cards/r/Rebound.java +++ b/Mage.Sets/src/mage/cards/r/Rebound.java @@ -66,7 +66,7 @@ class ReboundEffect extends OneShotEffect { && controller != null) { spell.getSpellAbility().getTargets().clear(); TargetPlayer targetPlayer = new TargetPlayer(); - if (controller.choose(Outcome.Neutral, targetPlayer, source.getSourceId(), game)) { + if (controller.choose(Outcome.Neutral, targetPlayer, source, game)) { spell.getSpellAbility().addTarget(targetPlayer); game.informPlayers("The target of the spell was changed to " + targetPlayer.getTargetedName(game)); return true; diff --git a/Mage.Sets/src/mage/cards/r/Recall.java b/Mage.Sets/src/mage/cards/r/Recall.java index 974f8ba0285..6289e4028ac 100644 --- a/Mage.Sets/src/mage/cards/r/Recall.java +++ b/Mage.Sets/src/mage/cards/r/Recall.java @@ -68,7 +68,7 @@ class RecallEffect extends OneShotEffect { // then return a card from your graveyard to your hand for each card discarded this way TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard()); target.setNotTarget(true); - target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game); + target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), source, game); controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/r/Reciprocate.java b/Mage.Sets/src/mage/cards/r/Reciprocate.java index 1ec811f1158..2f5426def95 100644 --- a/Mage.Sets/src/mage/cards/r/Reciprocate.java +++ b/Mage.Sets/src/mage/cards/r/Reciprocate.java @@ -61,8 +61,8 @@ class ReciprocateTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); for (UUID targetId : availablePossibleTargets) { @@ -75,16 +75,16 @@ class ReciprocateTarget extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int remainingTargets = this.minNumberOfTargets - targets.size(); if (remainingTargets == 0) { return true; } int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource != null) { PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) { count++; diff --git a/Mage.Sets/src/mage/cards/r/RecklessCrew.java b/Mage.Sets/src/mage/cards/r/RecklessCrew.java index ef9c09b7619..3b46270613c 100644 --- a/Mage.Sets/src/mage/cards/r/RecklessCrew.java +++ b/Mage.Sets/src/mage/cards/r/RecklessCrew.java @@ -64,10 +64,10 @@ class RecklessCrewEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int equipCount = game.getBattlefield().count( - filter1, source.getSourceId(), source.getControllerId(), game + filter1, source.getControllerId(), source, game ); int vehicleCount = game.getBattlefield().count( - filter2, source.getSourceId(), source.getControllerId(), game + filter2, source.getControllerId(), source, game ); if (equipCount + vehicleCount < 1) { return false; @@ -88,7 +88,7 @@ class RecklessCrewEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(0, 1, filter1, true); target.withChooseHint("(to attach to " + permanent.getIdName() + ")"); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); permanent.addAttachment(target.getFirstTarget(), source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/r/ReckonerShakedown.java b/Mage.Sets/src/mage/cards/r/ReckonerShakedown.java index e373efb09fd..fb198136f67 100644 --- a/Mage.Sets/src/mage/cards/r/ReckonerShakedown.java +++ b/Mage.Sets/src/mage/cards/r/ReckonerShakedown.java @@ -93,7 +93,7 @@ class ReckonerShakedownEffect extends OneShotEffect { } TargetPermanent targetPermanent = new TargetPermanent(filter); targetPermanent.setNotTarget(true); - player.choose(Outcome.BoostCreature, targetPermanent, source.getSourceId(), game); + player.choose(Outcome.BoostCreature, targetPermanent, source, game); Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.P1P1.createInstance(2), source, game); diff --git a/Mage.Sets/src/mage/cards/r/RefractionTrap.java b/Mage.Sets/src/mage/cards/r/RefractionTrap.java index c7d8f930938..f0af5d69b50 100644 --- a/Mage.Sets/src/mage/cards/r/RefractionTrap.java +++ b/Mage.Sets/src/mage/cards/r/RefractionTrap.java @@ -106,7 +106,7 @@ class RefractionTrapPreventDamageEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); super.init(source, game); } diff --git a/Mage.Sets/src/mage/cards/r/RegnasSanction.java b/Mage.Sets/src/mage/cards/r/RegnasSanction.java index 7717297b92a..91d66e9afce 100644 --- a/Mage.Sets/src/mage/cards/r/RegnasSanction.java +++ b/Mage.Sets/src/mage/cards/r/RegnasSanction.java @@ -83,7 +83,7 @@ class RegnasSanctionEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); if (game.getBattlefield().contains(filter, source, game, 1) - && player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + && player.choose(Outcome.Benefit, target, source, game)) { filterToTap.add(Predicates.not(new PermanentIdPredicate(target.getFirstTarget()))); } } @@ -94,7 +94,7 @@ class RegnasSanctionEffect extends OneShotEffect { .map(Predicates::not) .forEach(filterToTap::add); for (Permanent permanent : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game )) { if (choice.getFriends().stream().map(MageItem::getId).anyMatch(permanent::isControlledBy)) { permanent.addCounters(CounterType.P1P1.createInstance(), source, game); diff --git a/Mage.Sets/src/mage/cards/r/ReignOfTerror.java b/Mage.Sets/src/mage/cards/r/ReignOfTerror.java index 71499a45ea4..620f7a8a33c 100644 --- a/Mage.Sets/src/mage/cards/r/ReignOfTerror.java +++ b/Mage.Sets/src/mage/cards/r/ReignOfTerror.java @@ -73,7 +73,7 @@ class ReignOfTerrorEffect extends OneShotEffect { "", "Green", "White", source, game ) ? greenFilter : whiteFilter; int died = game.getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game) + .getActivePermanents(filter, source.getControllerId(), source, game) .stream() .mapToInt(permanent -> permanent.destroy(source, game, true) ? 1 : 0) .sum(); diff --git a/Mage.Sets/src/mage/cards/r/ReignOfThePit.java b/Mage.Sets/src/mage/cards/r/ReignOfThePit.java index 15d500f4990..15936203a88 100644 --- a/Mage.Sets/src/mage/cards/r/ReignOfThePit.java +++ b/Mage.Sets/src/mage/cards/r/ReignOfThePit.java @@ -68,9 +68,9 @@ class ReignOfThePitEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { while (!target.isChosen() && player.canRespond()) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); } perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/r/Reincarnation.java b/Mage.Sets/src/mage/cards/r/Reincarnation.java index 81250560bda..baf5e354ec4 100644 --- a/Mage.Sets/src/mage/cards/r/Reincarnation.java +++ b/Mage.Sets/src/mage/cards/r/Reincarnation.java @@ -143,7 +143,7 @@ class ReincarnationDelayedEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(player.getId())); Target targetCreature = new TargetCardInGraveyard(filter); targetCreature.setNotTarget(true); - if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game) + if (targetCreature.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, targetCreature, source, game)) { Card card = game.getCard(targetCreature.getFirstTarget()); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { diff --git a/Mage.Sets/src/mage/cards/r/ReinsOfPower.java b/Mage.Sets/src/mage/cards/r/ReinsOfPower.java index 7f1ab2982ca..848d6df633d 100644 --- a/Mage.Sets/src/mage/cards/r/ReinsOfPower.java +++ b/Mage.Sets/src/mage/cards/r/ReinsOfPower.java @@ -76,12 +76,12 @@ class ReinsOfPowerEffect extends OneShotEffect { // You and that opponent each gain control of all creatures the other controls until end of turn. Set yourCreatures = new HashSet<>(); Set opponentCreatures = new HashSet<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source, game)) { yourCreatures.add(permanent.getId()); } FilterCreaturePermanent filterOpponent = new FilterCreaturePermanent(); filterOpponent.add(new ControllerIdPredicate(opponentId)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filterOpponent, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filterOpponent, source.getControllerId(), source, game)) { opponentCreatures.add(permanent.getId()); } for (UUID creatureId : yourCreatures) { diff --git a/Mage.Sets/src/mage/cards/r/ReinsOfTheVinesteed.java b/Mage.Sets/src/mage/cards/r/ReinsOfTheVinesteed.java index f97d8b80521..a3ab0474701 100644 --- a/Mage.Sets/src/mage/cards/r/ReinsOfTheVinesteed.java +++ b/Mage.Sets/src/mage/cards/r/ReinsOfTheVinesteed.java @@ -85,7 +85,7 @@ class ReinsOfTheVinesteedEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent(FILTER); target.setNotTarget(true); if (controller != null - && controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + && controller.choose(Outcome.PutCardInPlay, target, source, game)) { Permanent targetPermanent = game.getPermanent(target.getFirstTarget()); if (!targetPermanent.cantBeAttachedBy(aura, source, game, false)) { game.getState().setValue("attachTo:" + aura.getId(), targetPermanent); diff --git a/Mage.Sets/src/mage/cards/r/RelentlessDead.java b/Mage.Sets/src/mage/cards/r/RelentlessDead.java index f0c19dddf28..4a562026809 100644 --- a/Mage.Sets/src/mage/cards/r/RelentlessDead.java +++ b/Mage.Sets/src/mage/cards/r/RelentlessDead.java @@ -13,7 +13,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.filter.predicate.mageobject.ManaValuePredicate; import mage.game.Game; import mage.players.Player; @@ -79,7 +79,7 @@ class RelentlessDeadEffect extends OneShotEffect { FilterCard filter = new FilterCard("Another target Zombie card with mana value {" + payCount + "}"); filter.add(SubType.ZOMBIE.getPredicate()); filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, payCount)); - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter); if (controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/r/RelentlessPursuit.java b/Mage.Sets/src/mage/cards/r/RelentlessPursuit.java index b67f29782e0..1d156693a96 100644 --- a/Mage.Sets/src/mage/cards/r/RelentlessPursuit.java +++ b/Mage.Sets/src/mage/cards/r/RelentlessPursuit.java @@ -65,7 +65,7 @@ class RelentlessPursuitEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/r/RelentlessRats.java b/Mage.Sets/src/mage/cards/r/RelentlessRats.java index 475ccb9b5ea..79a1c9c8343 100644 --- a/Mage.Sets/src/mage/cards/r/RelentlessRats.java +++ b/Mage.Sets/src/mage/cards/r/RelentlessRats.java @@ -69,7 +69,7 @@ public final class RelentlessRats extends CardImpl { @Override public boolean apply(Game game, Ability source) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1; + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game) - 1; if (count > 0) { Permanent target = game.getPermanent(source.getSourceId()); if (target != null) { diff --git a/Mage.Sets/src/mage/cards/r/RemorselessPunishment.java b/Mage.Sets/src/mage/cards/r/RemorselessPunishment.java index 97cf6ccebc4..2a4405214c6 100644 --- a/Mage.Sets/src/mage/cards/r/RemorselessPunishment.java +++ b/Mage.Sets/src/mage/cards/r/RemorselessPunishment.java @@ -79,10 +79,10 @@ class RemorselessPunishmentEffect extends OneShotEffect { return; } } - if (game.getBattlefield().containsControlled(filter, source.getSourceId(), opponent.getId(), game, 1)) { + if (game.getBattlefield().containsControlled(filter, source.getSourceId(), opponent.getId(), source, game, 1)) { if (opponent.chooseUse(outcome, "Choose your " + iteration + " punishment.", null, "Sacrifice a creature or planeswalker", "Lose 5 life", source, game)) { TargetPermanent target = new TargetPermanent(1, 1, filter, true); - if (target.choose(Outcome.Sacrifice, opponent.getId(), source.getId(), game)) { + if (target.choose(Outcome.Sacrifice, opponent.getId(), source.getId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/r/RenderSilent.java b/Mage.Sets/src/mage/cards/r/RenderSilent.java index f868ee002a6..d2f18055614 100644 --- a/Mage.Sets/src/mage/cards/r/RenderSilent.java +++ b/Mage.Sets/src/mage/cards/r/RenderSilent.java @@ -107,7 +107,7 @@ class RenderSilentEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/r/RenownedWeaponsmith.java b/Mage.Sets/src/mage/cards/r/RenownedWeaponsmith.java index 71770063055..15d9b60bcba 100644 --- a/Mage.Sets/src/mage/cards/r/RenownedWeaponsmith.java +++ b/Mage.Sets/src/mage/cards/r/RenownedWeaponsmith.java @@ -83,7 +83,7 @@ class RenownedWeaponsmithCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return (object != null && object.isArtifact(game)); } @@ -110,7 +110,7 @@ class RenownedWeaponsmithEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { TargetCardInLibrary target = new TargetCardInLibrary(filter); if (controller.searchLibrary(target, source, game)) { diff --git a/Mage.Sets/src/mage/cards/r/Replenish.java b/Mage.Sets/src/mage/cards/r/Replenish.java index 3c0376be3be..59de2d17685 100644 --- a/Mage.Sets/src/mage/cards/r/Replenish.java +++ b/Mage.Sets/src/mage/cards/r/Replenish.java @@ -56,8 +56,8 @@ class ReplenishEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - return controller.moveCards(controller.getGraveyard().getCards(new FilterEnchantmentCard(), source.getSourceId(), - source.getControllerId(), game), Zone.BATTLEFIELD, source, game); + return controller.moveCards(controller.getGraveyard().getCards(new FilterEnchantmentCard(), + source.getControllerId(), source, game), Zone.BATTLEFIELD, source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/r/RescuerSphinx.java b/Mage.Sets/src/mage/cards/r/RescuerSphinx.java index caa6c5b79c9..a3a46dc9703 100644 --- a/Mage.Sets/src/mage/cards/r/RescuerSphinx.java +++ b/Mage.Sets/src/mage/cards/r/RescuerSphinx.java @@ -87,7 +87,7 @@ class RescuerSphinxEffect extends OneShotEffect { return false; } Target target = new TargetPermanent(0, 1, filter, true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/r/ResoluteStrike.java b/Mage.Sets/src/mage/cards/r/ResoluteStrike.java index df88ff51118..bbe8a6612c3 100644 --- a/Mage.Sets/src/mage/cards/r/ResoluteStrike.java +++ b/Mage.Sets/src/mage/cards/r/ResoluteStrike.java @@ -69,12 +69,12 @@ class ResoluteStrikeEffect extends OneShotEffect { if (player == null || permanent == null || !permanent.hasSubtype(SubType.WARRIOR, game) - || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0 + || game.getBattlefield().count(filter, source.getControllerId(), source, game) == 0 || !player.chooseUse(outcome, "Attach an equipment you control?", source, game)) { return false; } TargetPermanent targetPermanent = new TargetPermanent(0, 1, filter, true); - player.choose(outcome, targetPermanent, source.getSourceId(), game); + player.choose(outcome, targetPermanent, source, game); return permanent.addAttachment(targetPermanent.getFirstTarget(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java b/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java index 29b5272f92c..d7d8188f893 100644 --- a/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java +++ b/Mage.Sets/src/mage/cards/r/ResplendentMarshal.java @@ -89,11 +89,11 @@ class ResplendentMarshalEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Card exiledCard = game.getCard(targetPointer.getFirst(game, source)); if (controller != null && sourceObject != null && exiledCard != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, source.getControllerId(), source, game)) { if (permanent.shareCreatureTypes(game, exiledCard)) { permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game); if (!game.isSimulation()) { diff --git a/Mage.Sets/src/mage/cards/r/Retether.java b/Mage.Sets/src/mage/cards/r/Retether.java index 032b1a9ed6c..bdd936f6871 100644 --- a/Mage.Sets/src/mage/cards/r/Retether.java +++ b/Mage.Sets/src/mage/cards/r/Retether.java @@ -74,7 +74,7 @@ class RetetherEffect extends OneShotEffect { if (controller != null) { Map auraMap = new HashMap<>(); auraCardsInGraveyard: - for (Card aura : controller.getGraveyard().getCards(filterAura, source.getSourceId(), source.getControllerId(), game)) { + for (Card aura : controller.getGraveyard().getCards(filterAura, source.getControllerId(), source, game)) { if (aura != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature to enchant (" + aura.getLogName() + ')'); filter.add(new CanBeEnchantedByPredicate(aura)); @@ -100,9 +100,9 @@ class RetetherEffect extends OneShotEffect { if (target != null) { target.getFilter().add(CardType.CREATURE.getPredicate()); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { target.setTargetName("creature to enchant (" + aura.getLogName() + ')'); - if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && !permanent.cantBeAttachedBy(aura, source, game, true)) { auraMap.put(aura, permanent); diff --git a/Mage.Sets/src/mage/cards/r/RetracedImage.java b/Mage.Sets/src/mage/cards/r/RetracedImage.java index 44a715d73a9..d6450056fdb 100644 --- a/Mage.Sets/src/mage/cards/r/RetracedImage.java +++ b/Mage.Sets/src/mage/cards/r/RetracedImage.java @@ -61,8 +61,8 @@ class RetracedImageEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), controller.getId(), game) - && controller.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), source, game) + && controller.choose(outcome, target, source, game)) { Card chosenCard = game.getCard(target.getFirstTarget()); if (chosenCard != null) { Cards cards = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/r/ReturnFromExtinction.java b/Mage.Sets/src/mage/cards/r/ReturnFromExtinction.java index 0714310fd31..7c77ece8f41 100644 --- a/Mage.Sets/src/mage/cards/r/ReturnFromExtinction.java +++ b/Mage.Sets/src/mage/cards/r/ReturnFromExtinction.java @@ -74,8 +74,8 @@ class ReturnFromExtinctionTarget extends TargetCardInYourGraveyard { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - MageObject targetSource = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + MageObject targetSource = game.getObject(source); Player player = game.getPlayer(sourceControllerId); if (player == null) { return false; @@ -84,7 +84,7 @@ class ReturnFromExtinctionTarget extends TargetCardInYourGraveyard { return false; } List cards = player.getGraveyard().getCards( - filter, sourceId, sourceControllerId, game + filter, sourceControllerId, source, game ).stream().collect(Collectors.toList()); if (cards.size() < 2) { return false; diff --git a/Mage.Sets/src/mage/cards/r/ReturnOfTheNightstalkers.java b/Mage.Sets/src/mage/cards/r/ReturnOfTheNightstalkers.java index 20724d3355b..0927aa9552a 100644 --- a/Mage.Sets/src/mage/cards/r/ReturnOfTheNightstalkers.java +++ b/Mage.Sets/src/mage/cards/r/ReturnOfTheNightstalkers.java @@ -68,7 +68,7 @@ class ReturnOfTheNightstalkersEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { controller.moveCards(controller.getGraveyard().getCards(filter1, game), Zone.BATTLEFIELD, source, game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter2, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter2, source.getControllerId(), source, game)) { permanent.destroy(source, game, false); } return true; diff --git a/Mage.Sets/src/mage/cards/r/RevealingWind.java b/Mage.Sets/src/mage/cards/r/RevealingWind.java index a8be10d36c3..ba45e8388f3 100644 --- a/Mage.Sets/src/mage/cards/r/RevealingWind.java +++ b/Mage.Sets/src/mage/cards/r/RevealingWind.java @@ -73,7 +73,7 @@ class RevealingWindEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { - while (game.getBattlefield().count(filter, source.getOriginalId(), source.getControllerId(), game) > 0 && + while (game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0 && controller.chooseUse(outcome, "Look at a face-down attacking creature?", source, game)) { if (!controller.canRespond()) { return false; diff --git a/Mage.Sets/src/mage/cards/r/ReverseDamage.java b/Mage.Sets/src/mage/cards/r/ReverseDamage.java index a42cb61cb1c..ab33be4df54 100644 --- a/Mage.Sets/src/mage/cards/r/ReverseDamage.java +++ b/Mage.Sets/src/mage/cards/r/ReverseDamage.java @@ -66,7 +66,7 @@ class ReverseDamageEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/r/RevivalExperiment.java b/Mage.Sets/src/mage/cards/r/RevivalExperiment.java index 86c35f7b9ca..6d40642a533 100644 --- a/Mage.Sets/src/mage/cards/r/RevivalExperiment.java +++ b/Mage.Sets/src/mage/cards/r/RevivalExperiment.java @@ -64,7 +64,7 @@ class RevivalExperimentEffect extends OneShotEffect { return false; } RevivalExperimentTarget target = new RevivalExperimentTarget(); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Cards cards = new CardsImpl(target.getTargets()); player.moveCards(cards, Zone.BATTLEFIELD, source, game); int toBattlefield = cards @@ -118,8 +118,8 @@ class RevivalExperimentTarget extends TargetCardInYourGraveyard { @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); possibleTargets.removeIf(uuid -> !this.canTarget(sourceControllerId, uuid, null, game)); return possibleTargets; } diff --git a/Mage.Sets/src/mage/cards/r/Revivify.java b/Mage.Sets/src/mage/cards/r/Revivify.java index 7fbf9505243..f96dd2e74bb 100644 --- a/Mage.Sets/src/mage/cards/r/Revivify.java +++ b/Mage.Sets/src/mage/cards/r/Revivify.java @@ -93,7 +93,7 @@ class RevivifyEffect extends OneShotEffect { return false; } return player.moveCards(player.getGraveyard().getCards( - Revivify.filter, source.getSourceId(), source.getControllerId(), game + Revivify.filter, source.getControllerId(), source, game ), toHand ? Zone.HAND : Zone.BATTLEFIELD, source, game); } } diff --git a/Mage.Sets/src/mage/cards/r/RevivingVapors.java b/Mage.Sets/src/mage/cards/r/RevivingVapors.java index 8acd1dcc264..991d8a7393d 100644 --- a/Mage.Sets/src/mage/cards/r/RevivingVapors.java +++ b/Mage.Sets/src/mage/cards/r/RevivingVapors.java @@ -50,7 +50,7 @@ class RevivingVaporsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/r/RevokePrivileges.java b/Mage.Sets/src/mage/cards/r/RevokePrivileges.java index baf51e77fd8..b92a7095d47 100644 --- a/Mage.Sets/src/mage/cards/r/RevokePrivileges.java +++ b/Mage.Sets/src/mage/cards/r/RevokePrivileges.java @@ -79,7 +79,7 @@ class RevokePrivilegeCantCrewEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "The creature enchanted by " + mageObject.getIdName() + " can't crew vehicles."; } diff --git a/Mage.Sets/src/mage/cards/r/RhonasTheIndomitable.java b/Mage.Sets/src/mage/cards/r/RhonasTheIndomitable.java index a815713ed79..de02aa6eab3 100644 --- a/Mage.Sets/src/mage/cards/r/RhonasTheIndomitable.java +++ b/Mage.Sets/src/mage/cards/r/RhonasTheIndomitable.java @@ -109,7 +109,7 @@ class RhonasTheIndomitableRestrictionEffect extends RestrictionEffect { if (permanent.getId().equals(source.getSourceId())) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int permanentsOnBattlefield = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int permanentsOnBattlefield = game.getBattlefield().count(filter, source.getControllerId(), source, game); return permanentsOnBattlefield < 1; // is this correct? } return true; diff --git a/Mage.Sets/src/mage/cards/r/RhysticScrying.java b/Mage.Sets/src/mage/cards/r/RhysticScrying.java index 79416b8666b..81db3e71340 100644 --- a/Mage.Sets/src/mage/cards/r/RhysticScrying.java +++ b/Mage.Sets/src/mage/cards/r/RhysticScrying.java @@ -52,7 +52,7 @@ class RhysticScryingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { boolean result = true; boolean doEffect = false; diff --git a/Mage.Sets/src/mage/cards/r/RickSteadfastLeader.java b/Mage.Sets/src/mage/cards/r/RickSteadfastLeader.java index f7ae7f7d533..c2c695c1ce7 100644 --- a/Mage.Sets/src/mage/cards/r/RickSteadfastLeader.java +++ b/Mage.Sets/src/mage/cards/r/RickSteadfastLeader.java @@ -160,7 +160,7 @@ class RickSteadfastLeaderGainEffect extends ContinuousEffectImpl { return false; } for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/r/Ricochet.java b/Mage.Sets/src/mage/cards/r/Ricochet.java index 029f4e5d193..fb9eddf9e45 100644 --- a/Mage.Sets/src/mage/cards/r/Ricochet.java +++ b/Mage.Sets/src/mage/cards/r/Ricochet.java @@ -142,7 +142,7 @@ class RicochetEffect extends OneShotEffect { target.clearChosen(); target.addTarget(loserId, sourceAbility, game); } - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (oldTargetName != null && sourceObject != null) { game.informPlayers(sourceObject.getLogName() + ": Changed target of " + spell.getLogName() + " from " + oldTargetName + " to " + loser.getLogName()); } diff --git a/Mage.Sets/src/mage/cards/r/RiftElemental.java b/Mage.Sets/src/mage/cards/r/RiftElemental.java index 54d4307e2d6..cf460ebcf39 100644 --- a/Mage.Sets/src/mage/cards/r/RiftElemental.java +++ b/Mage.Sets/src/mage/cards/r/RiftElemental.java @@ -78,7 +78,7 @@ class RiftElementalCost extends CostImpl { Player controller = game.getPlayer(controllerId); if (controller != null) { Target target = new TargetPermanentOrSuspendedCard(filter, true); - if (target.choose(Outcome.Neutral, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Neutral, controllerId, source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.removeCounters(CounterType.TIME.createInstance(), source, game); @@ -99,7 +99,7 @@ class RiftElementalCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { Target target = new TargetPermanentOrSuspendedCard(filter, true); - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java b/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java index 1fccc2e57a6..0f795093590 100644 --- a/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java +++ b/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java @@ -102,7 +102,7 @@ class RimefeatherOwlEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.addSuperType(SuperType.SNOW); } diff --git a/Mage.Sets/src/mage/cards/r/RiptideChronologist.java b/Mage.Sets/src/mage/cards/r/RiptideChronologist.java index 9500cf03bbe..e3d73ab0105 100644 --- a/Mage.Sets/src/mage/cards/r/RiptideChronologist.java +++ b/Mage.Sets/src/mage/cards/r/RiptideChronologist.java @@ -64,7 +64,7 @@ class RiptideChronologistEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject); if (player.choose(outcome, typeChoice, game)) { diff --git a/Mage.Sets/src/mage/cards/r/RiseAndShine.java b/Mage.Sets/src/mage/cards/r/RiseAndShine.java index a1606fa21e7..8b34210af9e 100644 --- a/Mage.Sets/src/mage/cards/r/RiseAndShine.java +++ b/Mage.Sets/src/mage/cards/r/RiseAndShine.java @@ -83,7 +83,7 @@ class RiseAndShineEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List permanents = game.getBattlefield().getActivePermanents( - RiseAndShine.filter, source.getControllerId(), source.getSourceId(), game + RiseAndShine.filter, source.getControllerId(), source, game ); if (permanents.isEmpty()) { return false; diff --git a/Mage.Sets/src/mage/cards/r/RiseFall.java b/Mage.Sets/src/mage/cards/r/RiseFall.java index 9ee4135c3a8..0adf51a8418 100644 --- a/Mage.Sets/src/mage/cards/r/RiseFall.java +++ b/Mage.Sets/src/mage/cards/r/RiseFall.java @@ -107,7 +107,7 @@ class FallEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/r/RisenExecutioner.java b/Mage.Sets/src/mage/cards/r/RisenExecutioner.java index d18787d5d02..bb68af55bc5 100644 --- a/Mage.Sets/src/mage/cards/r/RisenExecutioner.java +++ b/Mage.Sets/src/mage/cards/r/RisenExecutioner.java @@ -15,7 +15,7 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.game.Game; import mage.game.stack.Spell; import mage.players.Player; @@ -104,7 +104,7 @@ class RisenExecutionerCostIncreasingEffect extends CostModificationEffectImpl { protected static final FilterCreatureCard filter = new FilterCreatureCard(); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } RisenExecutionerCostIncreasingEffect() { @@ -120,7 +120,7 @@ class RisenExecutionerCostIncreasingEffect extends CostModificationEffectImpl { public boolean apply(Game game, Ability source, Ability abilityToModify) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - CardUtil.increaseCost(abilityToModify, controller.getGraveyard().count(filter, source.getSourceId(), source.getControllerId(), game)); + CardUtil.increaseCost(abilityToModify, controller.getGraveyard().count(filter, source.getControllerId(), source, game)); } return true; } diff --git a/Mage.Sets/src/mage/cards/r/RiskyMove.java b/Mage.Sets/src/mage/cards/r/RiskyMove.java index c6769da6b51..3717d1a1950 100644 --- a/Mage.Sets/src/mage/cards/r/RiskyMove.java +++ b/Mage.Sets/src/mage/cards/r/RiskyMove.java @@ -152,16 +152,16 @@ class RiskyMoveFlipCoinEffect extends OneShotEffect { Target target1 = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true); Target target2 = new TargetOpponent(true); - if (target1.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target1.canChoose(controller.getId(), source, game)) { while (!target1.isChosen() - && target1.canChoose(source.getSourceId(), controller.getId(), game) + && target1.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target1, source, game); } } - if (target2.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target2.canChoose(controller.getId(), source, game)) { while (!target2.isChosen() - && target2.canChoose(source.getSourceId(), controller.getId(), game) + && target2.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target2, source, game); } diff --git a/Mage.Sets/src/mage/cards/r/RiteOfHarmony.java b/Mage.Sets/src/mage/cards/r/RiteOfHarmony.java index d5e5db6d7c5..94a6543cfe1 100644 --- a/Mage.Sets/src/mage/cards/r/RiteOfHarmony.java +++ b/Mage.Sets/src/mage/cards/r/RiteOfHarmony.java @@ -9,7 +9,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.TimingRule; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.Predicates; import mage.game.Game; @@ -72,7 +71,7 @@ class RiteOfHarmonyTriggeredAbility extends DelayedTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanent(targetId); - return filter.match(permanent, getSourceId(), getControllerId(), game); + return filter.match(permanent, getControllerId(), this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/r/RiteOfPassage.java b/Mage.Sets/src/mage/cards/r/RiteOfPassage.java index e4b6f9b6c8a..01ac2560174 100644 --- a/Mage.Sets/src/mage/cards/r/RiteOfPassage.java +++ b/Mage.Sets/src/mage/cards/r/RiteOfPassage.java @@ -13,7 +13,6 @@ import mage.counters.CounterType; import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -69,7 +68,7 @@ class RiteOfPassageTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanent(targetId); - if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent != null && filter.match(permanent, getControllerId(), this, game)) { getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); return true; } diff --git a/Mage.Sets/src/mage/cards/r/RithTheAwakener.java b/Mage.Sets/src/mage/cards/r/RithTheAwakener.java index f514b727bc9..635069f0016 100644 --- a/Mage.Sets/src/mage/cards/r/RithTheAwakener.java +++ b/Mage.Sets/src/mage/cards/r/RithTheAwakener.java @@ -81,7 +81,7 @@ class RithTheAwakenerEffect extends OneShotEffect { game.informPlayers(controller.getLogName() + " chooses " + choice.getColor()); FilterPermanent filter = new FilterPermanent(); filter.add(new ColorPredicate(choice.getColor())); - int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game); + int cardsWithColor = game.getBattlefield().count(filter, controller.getId(), source, game); if (cardsWithColor > 0) { new CreateTokenEffect(new SaprolingToken(), cardsWithColor).apply(game, source); } diff --git a/Mage.Sets/src/mage/cards/r/RiversRebuke.java b/Mage.Sets/src/mage/cards/r/RiversRebuke.java index bbce02913d5..d221d30d464 100644 --- a/Mage.Sets/src/mage/cards/r/RiversRebuke.java +++ b/Mage.Sets/src/mage/cards/r/RiversRebuke.java @@ -59,7 +59,7 @@ class RiversRebukeReturnToHandEffect extends OneShotEffect { Cards cards = new CardsImpl(); game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND, - source.getFirstTarget(), source.getSourceId(), game + source.getFirstTarget(), source, game ).stream().forEach(cards::add); return player.moveCards(cards, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/r/RoarOfJukai.java b/Mage.Sets/src/mage/cards/r/RoarOfJukai.java index e8ec849ce7a..cb80d2e199f 100644 --- a/Mage.Sets/src/mage/cards/r/RoarOfJukai.java +++ b/Mage.Sets/src/mage/cards/r/RoarOfJukai.java @@ -85,7 +85,7 @@ class RoarOfJukaiEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (new PermanentsOnTheBattlefieldCondition(filter).apply(game, source)) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBlocked, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBlocked, source.getControllerId(), source, game)) { ContinuousEffect effect = new BoostTargetEffect(2, 2, Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java b/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java index b9973446f01..8f382fae4c4 100644 --- a/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java +++ b/Mage.Sets/src/mage/cards/r/RoarOfTheCrowd.java @@ -62,7 +62,7 @@ class RoarOfTheCrowdEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId())); + Choice typeChoice = new ChoiceCreatureType(game.getObject(source)); if (!player.choose(Outcome.LoseLife, typeChoice, game)) { return false; } diff --git a/Mage.Sets/src/mage/cards/r/RofellossGift.java b/Mage.Sets/src/mage/cards/r/RofellossGift.java index be7e66e7e2a..a475486a81f 100644 --- a/Mage.Sets/src/mage/cards/r/RofellossGift.java +++ b/Mage.Sets/src/mage/cards/r/RofellossGift.java @@ -84,7 +84,7 @@ class RofellossGiftEffect extends OneShotEffect { int enchantmentsToReturn = Math.min(player.getGraveyard().count(filter2, game), targetCardInHand.getTargets().size()); TargetCardInYourGraveyard targetCardInYourGraveyard = new TargetCardInYourGraveyard(enchantmentsToReturn, filter2); targetCardInYourGraveyard.setNotTarget(true); - if (!player.choose(outcome, targetCardInYourGraveyard, source.getSourceId(), game)) { + if (!player.choose(outcome, targetCardInYourGraveyard, source, game)) { return false; } cards = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/r/RogueSkycaptain.java b/Mage.Sets/src/mage/cards/r/RogueSkycaptain.java index 5b52e1cc54b..fe0089d759b 100644 --- a/Mage.Sets/src/mage/cards/r/RogueSkycaptain.java +++ b/Mage.Sets/src/mage/cards/r/RogueSkycaptain.java @@ -88,7 +88,7 @@ class RogueSkycaptainEffect extends OneShotEffect { } else { Target target = new TargetOpponent(true); target.setNotTarget(true); - target.choose(Outcome.GainControl, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.GainControl, source.getControllerId(), source.getSourceId(), source, game); opponent = game.getPlayer(target.getFirstTarget()); } if (opponent != null) { diff --git a/Mage.Sets/src/mage/cards/r/RohgahhOfKherKeep.java b/Mage.Sets/src/mage/cards/r/RohgahhOfKherKeep.java index 0a55641ed1f..498c3a96e93 100644 --- a/Mage.Sets/src/mage/cards/r/RohgahhOfKherKeep.java +++ b/Mage.Sets/src/mage/cards/r/RohgahhOfKherKeep.java @@ -103,7 +103,7 @@ class RohgahhOfKherKeepEffect extends OneShotEffect { || !cost.pay(source, game, source, player.getId(), false)) { TargetOpponent target = new TargetOpponent(); Player opponent = null; - if (target.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Detriment, player.getId(), source.getSourceId(), source, game)) { opponent = game.getPlayer(target.getFirstTarget()); } new TapAllEffect(filter).apply(game, source); diff --git a/Mage.Sets/src/mage/cards/r/RoleReversal.java b/Mage.Sets/src/mage/cards/r/RoleReversal.java index 5e5c8843679..9e0042487ed 100644 --- a/Mage.Sets/src/mage/cards/r/RoleReversal.java +++ b/Mage.Sets/src/mage/cards/r/RoleReversal.java @@ -69,11 +69,11 @@ class TargetPermanentsThatShareCardType extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { Set cardTypes = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { for (CardType cardType : permanent.getCardType(game)) { if (cardTypes.contains(cardType)) { diff --git a/Mage.Sets/src/mage/cards/r/RonaDiscipleOfGix.java b/Mage.Sets/src/mage/cards/r/RonaDiscipleOfGix.java index 5ba2ecda517..b08e7f7de62 100644 --- a/Mage.Sets/src/mage/cards/r/RonaDiscipleOfGix.java +++ b/Mage.Sets/src/mage/cards/r/RonaDiscipleOfGix.java @@ -99,7 +99,7 @@ class RonaDiscipleOfGixPlayNonLandEffect extends AsThoughEffectImpl { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (card != null && !card.isLand(game) && sourceObject != null) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)); if (exileId != null) { diff --git a/Mage.Sets/src/mage/cards/r/RoninCliffrider.java b/Mage.Sets/src/mage/cards/r/RoninCliffrider.java index 8e3b1a24416..fb6127fba91 100644 --- a/Mage.Sets/src/mage/cards/r/RoninCliffrider.java +++ b/Mage.Sets/src/mage/cards/r/RoninCliffrider.java @@ -69,7 +69,7 @@ class RoninCliffriderEffect extends OneShotEffect { if (defenderId != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(defenderId)); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.damage(1, source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/r/RoonOfTheHiddenRealm.java b/Mage.Sets/src/mage/cards/r/RoonOfTheHiddenRealm.java index f8625e03d39..6ad268ff282 100644 --- a/Mage.Sets/src/mage/cards/r/RoonOfTheHiddenRealm.java +++ b/Mage.Sets/src/mage/cards/r/RoonOfTheHiddenRealm.java @@ -86,7 +86,7 @@ class RoonOfTheHiddenRealmEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (getTargetPointer().getFirst(game, source) != null) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/r/RootsOfWisdom.java b/Mage.Sets/src/mage/cards/r/RootsOfWisdom.java index 45eb9ab37e6..4ed83007bb2 100644 --- a/Mage.Sets/src/mage/cards/r/RootsOfWisdom.java +++ b/Mage.Sets/src/mage/cards/r/RootsOfWisdom.java @@ -75,8 +75,8 @@ class RootsOfWisdomEffect extends OneShotEffect { player.millCards(3, source, game); TargetCard targetCard = new TargetCardInYourGraveyard(filter); targetCard.setNotTarget(true); - if (targetCard.canChoose(source.getSourceId(), source.getControllerId(), game) - && player.choose(outcome, targetCard, source.getSourceId(), game)) { + if (targetCard.canChoose(source.getControllerId(), source, game) + && player.choose(outcome, targetCard, source, game)) { Card card = player.getGraveyard().get(targetCard.getFirstTarget(), game); if (card != null && player.moveCards(card, Zone.HAND, source, game)) { return true; diff --git a/Mage.Sets/src/mage/cards/r/RoyalDecree.java b/Mage.Sets/src/mage/cards/r/RoyalDecree.java index da303e1b434..d23feaf24bc 100644 --- a/Mage.Sets/src/mage/cards/r/RoyalDecree.java +++ b/Mage.Sets/src/mage/cards/r/RoyalDecree.java @@ -80,7 +80,7 @@ class RoyalDecreeAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent != null && filter.match(permanent, getControllerId(), this, game)) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { for (Effect effect : this.getEffects()) { diff --git a/Mage.Sets/src/mage/cards/r/Rumination.java b/Mage.Sets/src/mage/cards/r/Rumination.java index 786f06e174a..103c1ee52ca 100644 --- a/Mage.Sets/src/mage/cards/r/Rumination.java +++ b/Mage.Sets/src/mage/cards/r/Rumination.java @@ -65,7 +65,7 @@ public final class Rumination extends CardImpl { private boolean putOnLibrary(Player player, Ability source, Game game) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/r/Rupture.java b/Mage.Sets/src/mage/cards/r/Rupture.java index bb53ef7bab1..ca0750b8188 100644 --- a/Mage.Sets/src/mage/cards/r/Rupture.java +++ b/Mage.Sets/src/mage/cards/r/Rupture.java @@ -65,8 +65,8 @@ class RuptureEffect extends OneShotEffect { if (player != null) { int power = 0; TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("creature to sacrifice"), true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) { + if (target.canChoose(player.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(player.getId(), source, game) && player.canRespond()) { player.chooseTarget(Outcome.Sacrifice, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/r/RustElemental.java b/Mage.Sets/src/mage/cards/r/RustElemental.java index a68eb8e3cc6..0563bd7e951 100644 --- a/Mage.Sets/src/mage/cards/r/RustElemental.java +++ b/Mage.Sets/src/mage/cards/r/RustElemental.java @@ -78,8 +78,8 @@ class RustElementalEffect extends OneShotEffect { if (controller != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); // if they can pay the cost, then they must pay - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(controller.getId(), source, game)) { + controller.choose(Outcome.Sacrifice, target, source, game); Permanent artifactSacrifice = game.getPermanent(target.getFirstTarget()); if (artifactSacrifice != null) { // sacrifice the chosen artifact diff --git a/Mage.Sets/src/mage/cards/r/RuthlessTechnomancer.java b/Mage.Sets/src/mage/cards/r/RuthlessTechnomancer.java index e825319f923..1cd1bb9ced1 100644 --- a/Mage.Sets/src/mage/cards/r/RuthlessTechnomancer.java +++ b/Mage.Sets/src/mage/cards/r/RuthlessTechnomancer.java @@ -113,7 +113,7 @@ class RuthlessTechnomancerEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent( 0, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null || !permanent.sacrifice(source, game)) { return false; diff --git a/Mage.Sets/src/mage/cards/s/SacellumGodspeaker.java b/Mage.Sets/src/mage/cards/s/SacellumGodspeaker.java index 1861ec0c4bb..a21594de418 100644 --- a/Mage.Sets/src/mage/cards/s/SacellumGodspeaker.java +++ b/Mage.Sets/src/mage/cards/s/SacellumGodspeaker.java @@ -89,7 +89,7 @@ class SacellumGodspeakerEffect extends ManaEffect { public Mana produceMana(Game game, Ability source) { if (game != null) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter); - if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), source, game)) { return Mana.GreenMana(target.getTargets().size()); } } diff --git a/Mage.Sets/src/mage/cards/s/SadisticAugermage.java b/Mage.Sets/src/mage/cards/s/SadisticAugermage.java index fe3d7d4a7b1..0013753d87b 100644 --- a/Mage.Sets/src/mage/cards/s/SadisticAugermage.java +++ b/Mage.Sets/src/mage/cards/s/SadisticAugermage.java @@ -71,7 +71,7 @@ class WidespreadPanicEffect extends OneShotEffect { if (!player.getHand().isEmpty()) { TargetCardInHand target = new TargetCardInHand(); target.setTargetName("a card from your hand to put on top of your library"); - player.choose(Outcome.Detriment, target, source.getSourceId(), game); + player.choose(Outcome.Detriment, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { player.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false); diff --git a/Mage.Sets/src/mage/cards/s/SageEyeAvengers.java b/Mage.Sets/src/mage/cards/s/SageEyeAvengers.java index 26ffede2027..60ca085df22 100644 --- a/Mage.Sets/src/mage/cards/s/SageEyeAvengers.java +++ b/Mage.Sets/src/mage/cards/s/SageEyeAvengers.java @@ -70,7 +70,7 @@ class SageEyeAvengersEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null && targetCreature.getPower().getValue() < sourceObject.getPower().getValue()) { diff --git a/Mage.Sets/src/mage/cards/s/SakashimasWill.java b/Mage.Sets/src/mage/cards/s/SakashimasWill.java index 5edb0fee416..30647a25d5f 100644 --- a/Mage.Sets/src/mage/cards/s/SakashimasWill.java +++ b/Mage.Sets/src/mage/cards/s/SakashimasWill.java @@ -78,10 +78,10 @@ class SakashimasWillStealEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + if (!target.canChoose(player.getId(), source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); if (game.getPermanent(target.getFirstTarget()) == null) { return false; } @@ -116,17 +116,17 @@ class SakashimasWillCopyEffect extends OneShotEffect { } TargetPermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + if (!target.canChoose(player.getId(), source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent chosenCreature = game.getPermanent(target.getFirstTarget()); if (chosenCreature == null) { return false; } for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - player.getId(), source.getSourceId(), game + player.getId(), source, game )) { if (permanent == null || permanent.getId().equals(chosenCreature.getId())) { continue; diff --git a/Mage.Sets/src/mage/cards/s/SamiteMinistration.java b/Mage.Sets/src/mage/cards/s/SamiteMinistration.java index ed40a7d9296..601776c7784 100644 --- a/Mage.Sets/src/mage/cards/s/SamiteMinistration.java +++ b/Mage.Sets/src/mage/cards/s/SamiteMinistration.java @@ -62,7 +62,7 @@ class SamiteMinistrationEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/s/SanctumPrelate.java b/Mage.Sets/src/mage/cards/s/SanctumPrelate.java index dc4e8091093..633ea117ca3 100644 --- a/Mage.Sets/src/mage/cards/s/SanctumPrelate.java +++ b/Mage.Sets/src/mage/cards/s/SanctumPrelate.java @@ -106,7 +106,7 @@ class SanctumPrelateReplacementEffect extends ContinuousRuleModifyingEffectImpl @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast a noncreature card with that mana value (" + mageObject.getIdName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/s/SandstoneOracle.java b/Mage.Sets/src/mage/cards/s/SandstoneOracle.java index da15a23c9e2..c671054a3bc 100644 --- a/Mage.Sets/src/mage/cards/s/SandstoneOracle.java +++ b/Mage.Sets/src/mage/cards/s/SandstoneOracle.java @@ -68,7 +68,7 @@ class SandstoneOracleEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { TargetOpponent target = new TargetOpponent(true); - if (controller.choose(Outcome.DrawCard, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.DrawCard, target, source, game)) { Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName()); diff --git a/Mage.Sets/src/mage/cards/s/SanityGrinding.java b/Mage.Sets/src/mage/cards/s/SanityGrinding.java index 138cfe56f36..ddbd04d2c34 100644 --- a/Mage.Sets/src/mage/cards/s/SanityGrinding.java +++ b/Mage.Sets/src/mage/cards/s/SanityGrinding.java @@ -54,7 +54,7 @@ class SanityGrindingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java b/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java index a3f3627df24..9948aac728c 100644 --- a/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java +++ b/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java @@ -155,7 +155,7 @@ class SarkhanTheMadDragonDamageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List dragons = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List dragons = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); if (dragons != null && !dragons.isEmpty()) { for (Permanent dragon : dragons) { game.damagePlayerOrPlaneswalker(source.getFirstTarget(), dragon.getPower().getValue(), dragon.getId(), source, game, false, true); diff --git a/Mage.Sets/src/mage/cards/s/SarulfRealmEater.java b/Mage.Sets/src/mage/cards/s/SarulfRealmEater.java index 1bd2c0d63ff..556337e7f38 100644 --- a/Mage.Sets/src/mage/cards/s/SarulfRealmEater.java +++ b/Mage.Sets/src/mage/cards/s/SarulfRealmEater.java @@ -105,7 +105,7 @@ class SarulfRealmEaterEffect extends OneShotEffect { game.getBattlefield() .getActivePermanents( filter, source.getControllerId(), - source.getSourceId(), game + source, game ) .stream() .filter(Objects::nonNull) diff --git a/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java b/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java index 4280b027e89..847c2ad4b04 100644 --- a/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java +++ b/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java @@ -69,10 +69,10 @@ class SatyrWayfinderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); - boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0; + boolean properCardFound = cards.count(filterPutInHand, source.getSourceId(), source, game) > 0; if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand); diff --git a/Mage.Sets/src/mage/cards/s/SavageAlliance.java b/Mage.Sets/src/mage/cards/s/SavageAlliance.java index 81262b0952c..5c2078c4092 100644 --- a/Mage.Sets/src/mage/cards/s/SavageAlliance.java +++ b/Mage.Sets/src/mage/cards/s/SavageAlliance.java @@ -130,7 +130,7 @@ class SavageAllianceDamageEffect extends OneShotEffect { if (player != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(player.getId())); - List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent creature : creatures) { creature.damage(1, source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/s/SavageSummoning.java b/Mage.Sets/src/mage/cards/s/SavageSummoning.java index e4c37e9c9f7..1e141f40841 100644 --- a/Mage.Sets/src/mage/cards/s/SavageSummoning.java +++ b/Mage.Sets/src/mage/cards/s/SavageSummoning.java @@ -209,7 +209,7 @@ class SavageSummoningCantCounterEffect extends ContinuousRuleModifyingEffectImpl @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This creature spell can't be countered (" + sourceObject.getName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/s/SavraQueenOfTheGolgari.java b/Mage.Sets/src/mage/cards/s/SavraQueenOfTheGolgari.java index 540ae0d6397..24ea4611635 100644 --- a/Mage.Sets/src/mage/cards/s/SavraQueenOfTheGolgari.java +++ b/Mage.Sets/src/mage/cards/s/SavraQueenOfTheGolgari.java @@ -115,7 +115,7 @@ class SavraSacrificeEffect extends OneShotEffect { if (player != null && !playerId.equals(source.getControllerId())) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/s/ScalelordReckoner.java b/Mage.Sets/src/mage/cards/s/ScalelordReckoner.java index cb12d05ce57..38ed0ae8925 100644 --- a/Mage.Sets/src/mage/cards/s/ScalelordReckoner.java +++ b/Mage.Sets/src/mage/cards/s/ScalelordReckoner.java @@ -17,7 +17,6 @@ import mage.filter.common.FilterNonlandPermanent; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; @@ -81,7 +80,7 @@ class ScalelardReckonerTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { Permanent creature = game.getPermanent(event.getTargetId()); - if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) { + if (creature != null && filter.match(creature, getControllerId(), this, game)) { FilterNonlandPermanent filter = new FilterNonlandPermanent("nonland permanent that player controls"); filter.add(new ControllerIdPredicate(event.getPlayerId())); this.getTargets().clear(); diff --git a/Mage.Sets/src/mage/cards/s/ScarredPuma.java b/Mage.Sets/src/mage/cards/s/ScarredPuma.java index 13322a8c20d..75aa3dc6816 100644 --- a/Mage.Sets/src/mage/cards/s/ScarredPuma.java +++ b/Mage.Sets/src/mage/cards/s/ScarredPuma.java @@ -68,7 +68,7 @@ public final class ScarredPuma extends CardImpl { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { //excludes itself (https://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=23067) if (!Objects.equals(creature.getId(), source.getSourceId())) { ObjectColor color = creature.getColor(game); diff --git a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java index 76b7896c63f..18dfd8c8eea 100644 --- a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java +++ b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java @@ -97,7 +97,7 @@ class DoUnlessAnyOpponentPaysEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { String message; if (chooseUseText == null) { diff --git a/Mage.Sets/src/mage/cards/s/ScholarshipSponsor.java b/Mage.Sets/src/mage/cards/s/ScholarshipSponsor.java index b2dbf27f6b9..07adf34acc4 100644 --- a/Mage.Sets/src/mage/cards/s/ScholarshipSponsor.java +++ b/Mage.Sets/src/mage/cards/s/ScholarshipSponsor.java @@ -73,7 +73,7 @@ class ScholarshipSponsorEffect extends OneShotEffect { Map playerMap = game .getBattlefield() .getActivePermanents( - StaticFilters.FILTER_LAND, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_LAND, source.getControllerId(), source, game ) .stream() .map(Controllable::getControllerId) diff --git a/Mage.Sets/src/mage/cards/s/ScionOfDraco.java b/Mage.Sets/src/mage/cards/s/ScionOfDraco.java index e33c1a013c7..835f5bca5ae 100644 --- a/Mage.Sets/src/mage/cards/s/ScionOfDraco.java +++ b/Mage.Sets/src/mage/cards/s/ScionOfDraco.java @@ -75,7 +75,7 @@ class ScionOfDracoEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { ObjectColor color = permanent.getColor(game); if (color.isWhite()) { diff --git a/Mage.Sets/src/mage/cards/s/ScourgeOfFleets.java b/Mage.Sets/src/mage/cards/s/ScourgeOfFleets.java index bb41b489d0c..a71fd10567c 100644 --- a/Mage.Sets/src/mage/cards/s/ScourgeOfFleets.java +++ b/Mage.Sets/src/mage/cards/s/ScourgeOfFleets.java @@ -72,12 +72,12 @@ class ScourgeOfFleetsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int islands = game.getBattlefield().count(filter, source.getControllerId(), source, game); FilterPermanent creatureFilter = new FilterCreaturePermanent(); creatureFilter.add(TargetController.OPPONENT.getControllerPredicate()); creatureFilter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, islands + 1)); Cards cardsToHand = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source, game)) { cardsToHand.add(permanent); } controller.moveCards(cardsToHand, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/s/ScourgeOfValkas.java b/Mage.Sets/src/mage/cards/s/ScourgeOfValkas.java index b5ce0a50788..c5bd142eb92 100644 --- a/Mage.Sets/src/mage/cards/s/ScourgeOfValkas.java +++ b/Mage.Sets/src/mage/cards/s/ScourgeOfValkas.java @@ -87,7 +87,7 @@ class ScourgeOfValkasDamageEffect extends OneShotEffect { if (controller == null || enteringDragon == null) { return false; } - int dragons = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int dragons = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (dragons < 1) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/Scrambleverse.java b/Mage.Sets/src/mage/cards/s/Scrambleverse.java index 172879164d9..16117b4d358 100644 --- a/Mage.Sets/src/mage/cards/s/Scrambleverse.java +++ b/Mage.Sets/src/mage/cards/s/Scrambleverse.java @@ -56,7 +56,7 @@ class ScrambleverseEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { PlayerList players = game.getState().getPlayersInRange(source.getControllerId(), game); int count = players.size(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source, game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, players.get(RandomUtil.nextInt(count))); effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/s/Scrapheap.java b/Mage.Sets/src/mage/cards/s/Scrapheap.java index 1d37b3006d0..ad60a4cf31b 100644 --- a/Mage.Sets/src/mage/cards/s/Scrapheap.java +++ b/Mage.Sets/src/mage/cards/s/Scrapheap.java @@ -10,7 +10,6 @@ import mage.constants.Zone; import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; @@ -65,7 +64,7 @@ class ScrapheapTriggeredAbility extends TriggeredAbilityImpl { if (zEvent.isDiesEvent()) { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (permanent != null && permanent.isOwnedBy(this.getControllerId())) { - if (StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT.match(permanent, sourceId, controllerId, game)) { + if (StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT.match(permanent, controllerId, this, game)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/s/ScrapheapScrounger.java b/Mage.Sets/src/mage/cards/s/ScrapheapScrounger.java index 158189b471c..6812c8961d4 100644 --- a/Mage.Sets/src/mage/cards/s/ScrapheapScrounger.java +++ b/Mage.Sets/src/mage/cards/s/ScrapheapScrounger.java @@ -14,7 +14,7 @@ import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.common.FilterCreatureCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; import java.util.UUID; @@ -27,7 +27,7 @@ public final class ScrapheapScrounger extends CardImpl { private static final FilterCard filter = new FilterCreatureCard("another creature card"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public ScrapheapScrounger(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/s/ScrollRack.java b/Mage.Sets/src/mage/cards/s/ScrollRack.java index a5912f09cdb..c245f5b35fa 100644 --- a/Mage.Sets/src/mage/cards/s/ScrollRack.java +++ b/Mage.Sets/src/mage/cards/s/ScrollRack.java @@ -59,13 +59,13 @@ class ScrollRackEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { FilterCard filter = new FilterCard("card in your hand to exile"); TargetCardInHand target = new TargetCardInHand(0, controller.getHand().size(), filter); target.setRequired(false); int amountExiled = 0; - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { for (UUID targetId : target.getTargets()) { Card card = game.getCard(targetId); diff --git a/Mage.Sets/src/mage/cards/s/Scrounge.java b/Mage.Sets/src/mage/cards/s/Scrounge.java index a41d166a8f2..cbfe17926c0 100644 --- a/Mage.Sets/src/mage/cards/s/Scrounge.java +++ b/Mage.Sets/src/mage/cards/s/Scrounge.java @@ -64,7 +64,7 @@ class ScroungeEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(opponent.getId())); TargetCardInGraveyard chosenCard = new TargetCardInGraveyard(filter); chosenCard.setNotTarget(true); - if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (chosenCard.canChoose(opponent.getId(), source, game)) { opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game); Card card = game.getCard(chosenCard.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/ScryingSheets.java b/Mage.Sets/src/mage/cards/s/ScryingSheets.java index 2ef6b2d97e4..ea79c0cd97a 100644 --- a/Mage.Sets/src/mage/cards/s/ScryingSheets.java +++ b/Mage.Sets/src/mage/cards/s/ScryingSheets.java @@ -68,7 +68,7 @@ class ScryingSheetsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Card card = controller.getLibrary().getFromTop(game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SearingBlaze.java b/Mage.Sets/src/mage/cards/s/SearingBlaze.java index 29213010319..f9431bebdc3 100644 --- a/Mage.Sets/src/mage/cards/s/SearingBlaze.java +++ b/Mage.Sets/src/mage/cards/s/SearingBlaze.java @@ -110,10 +110,10 @@ class SearingBlazeTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); if (object instanceof StackObject) { UUID playerId = ((StackObject) object).getStackAbility().getFirstTarget(); Player player = game.getPlayerOrPlaneswalkerController(playerId); diff --git a/Mage.Sets/src/mage/cards/s/Seasinger.java b/Mage.Sets/src/mage/cards/s/Seasinger.java index 8c934c32b80..8549bfd61d1 100644 --- a/Mage.Sets/src/mage/cards/s/Seasinger.java +++ b/Mage.Sets/src/mage/cards/s/Seasinger.java @@ -81,6 +81,6 @@ enum SeasingerPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - return game.getBattlefield().contains(filter, input.getSourceId(), input.getObject().getControllerId(), game, 1); + return game.getBattlefield().contains(filter, input.getSourceId(), input.getObject().getControllerId(), input.getSource(), game, 1); } } diff --git a/Mage.Sets/src/mage/cards/s/SeasonsPast.java b/Mage.Sets/src/mage/cards/s/SeasonsPast.java index efdc6f6abc5..8ca77de851e 100644 --- a/Mage.Sets/src/mage/cards/s/SeasonsPast.java +++ b/Mage.Sets/src/mage/cards/s/SeasonsPast.java @@ -64,7 +64,7 @@ class SeasonsPastEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { SeasonsPastTarget target = new SeasonsPastTarget(); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); return true; } @@ -83,7 +83,7 @@ class SeasonsPastTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set usedCMC = new HashSet<>(); for (UUID targetId : this.getTargets()) { Card card = game.getCard(targetId); @@ -91,7 +91,7 @@ class SeasonsPastTarget extends TargetCardInYourGraveyard { usedCMC.add(card.getManaValue()); } } - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); Set leftPossibleTargets = new HashSet<>(); for (UUID targetId : possibleTargets) { Card card = game.getCard(targetId); diff --git a/Mage.Sets/src/mage/cards/s/SecludedCourtyard.java b/Mage.Sets/src/mage/cards/s/SecludedCourtyard.java index ad47df46e9c..90041f9719f 100644 --- a/Mage.Sets/src/mage/cards/s/SecludedCourtyard.java +++ b/Mage.Sets/src/mage/cards/s/SecludedCourtyard.java @@ -64,7 +64,7 @@ class SecludedCourtyardManaBuilder extends ConditionalManaBuilder { creatureType = subType; } Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && mana.getAny() == 0) { @@ -106,7 +106,7 @@ class SecludedCourtyardManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); // casting a creature card or using its ability if (creatureType != null && object != null diff --git a/Mage.Sets/src/mage/cards/s/SecondSunrise.java b/Mage.Sets/src/mage/cards/s/SecondSunrise.java index 7d8a17e573f..06e28e9a8dc 100644 --- a/Mage.Sets/src/mage/cards/s/SecondSunrise.java +++ b/Mage.Sets/src/mage/cards/s/SecondSunrise.java @@ -72,7 +72,7 @@ class SecondSunriseEffect extends OneShotEffect { continue; } result |= player.moveCards(player.getGraveyard().getCards( - filter, source.getSourceId(), source.getControllerId(), game + filter, source.getControllerId(), source, game ), Zone.BATTLEFIELD, source, game); } return result; diff --git a/Mage.Sets/src/mage/cards/s/SehtsTiger.java b/Mage.Sets/src/mage/cards/s/SehtsTiger.java index fc88912d280..88140819e39 100644 --- a/Mage.Sets/src/mage/cards/s/SehtsTiger.java +++ b/Mage.Sets/src/mage/cards/s/SehtsTiger.java @@ -68,7 +68,7 @@ class SehtsTigerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); ChoiceColor choice = new ChoiceColor(); if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) { game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); diff --git a/Mage.Sets/src/mage/cards/s/SelfInflictedWound.java b/Mage.Sets/src/mage/cards/s/SelfInflictedWound.java index d8949beecf1..594623c51a6 100644 --- a/Mage.Sets/src/mage/cards/s/SelfInflictedWound.java +++ b/Mage.Sets/src/mage/cards/s/SelfInflictedWound.java @@ -73,7 +73,7 @@ class SelfInflictedWoundEffect extends OneShotEffect { filter.add(Predicates.or(new ColorPredicate(ObjectColor.GREEN), new ColorPredicate(ObjectColor.WHITE))); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), targetOpponent.getId(), game)) { + if (target.canChoose(targetOpponent.getId(), source, game)) { targetOpponent.chooseTarget(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/s/SelflessGlyphweaver.java b/Mage.Sets/src/mage/cards/s/SelflessGlyphweaver.java index 51dfff39c29..2efa24a8c87 100644 --- a/Mage.Sets/src/mage/cards/s/SelflessGlyphweaver.java +++ b/Mage.Sets/src/mage/cards/s/SelflessGlyphweaver.java @@ -82,7 +82,7 @@ class DeadlyVanityEffect extends OneShotEffect { } TargetPermanent target = new TargetCreatureOrPlaneswalker(); target.setNotTarget(true); - controller.choose(outcome, target, source.getId(), game); + controller.choose(outcome, target, source, game); FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent(); UUID targetId = target.getFirstTarget(); diff --git a/Mage.Sets/src/mage/cards/s/SenTriplets.java b/Mage.Sets/src/mage/cards/s/SenTriplets.java index 8c53b883944..9b75c134bed 100644 --- a/Mage.Sets/src/mage/cards/s/SenTriplets.java +++ b/Mage.Sets/src/mage/cards/s/SenTriplets.java @@ -79,7 +79,7 @@ class SenTripletsRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (targetPlayer != null && mageObject != null) { return "This turn you can't cast spells or activate abilities" + " (" + mageObject.getLogName() + ')'; diff --git a/Mage.Sets/src/mage/cards/s/SengirNosferatu.java b/Mage.Sets/src/mage/cards/s/SengirNosferatu.java index 7bf5b366653..519c4d1cc32 100644 --- a/Mage.Sets/src/mage/cards/s/SengirNosferatu.java +++ b/Mage.Sets/src/mage/cards/s/SengirNosferatu.java @@ -87,7 +87,7 @@ class ReturnSengirNosferatuEffect extends OneShotEffect { } Target target = new TargetCardInExile(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (!target.canChoose(controller.getId(), source, game)) { return false; } controller.chooseTarget(Outcome.PutCreatureInPlay, target, source, game); diff --git a/Mage.Sets/src/mage/cards/s/Sentinel.java b/Mage.Sets/src/mage/cards/s/Sentinel.java index e9bb3c425b0..d0204672a2f 100644 --- a/Mage.Sets/src/mage/cards/s/Sentinel.java +++ b/Mage.Sets/src/mage/cards/s/Sentinel.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -11,42 +9,40 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.SetToughnessSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.constants.Zone; +import mage.constants.*; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.common.TargetCreaturePermanent; +import mage.target.TargetPermanent; import mage.util.CardUtil; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class Sentinel extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public Sentinel(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}"); this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(1); this.toughness = new MageInt(1); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by Sentinel"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); // 0: Change Sentinel's base toughness to 1 plus the power of target creature blocking or blocked by Sentinel. (This effect lasts indefinitely.) - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SentinelEffect(), new GenericManaCost(0)); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new SentinelEffect(), new GenericManaCost(0)); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); - } private Sentinel(final Sentinel card) { diff --git a/Mage.Sets/src/mage/cards/s/SequesteredStash.java b/Mage.Sets/src/mage/cards/s/SequesteredStash.java index d69331b118a..2e25e499af6 100644 --- a/Mage.Sets/src/mage/cards/s/SequesteredStash.java +++ b/Mage.Sets/src/mage/cards/s/SequesteredStash.java @@ -75,9 +75,9 @@ class SequesteredStashEffect extends OneShotEffect { } TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_ARTIFACT_FROM_YOUR_GRAVEYARD); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseUse(outcome, "Put an artifact card from your graveyard to library?", source, game) - && controller.choose(outcome, target, source.getSourceId(), game)) { + && controller.choose(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.LIBRARY, source, game); diff --git a/Mage.Sets/src/mage/cards/s/SerendibDjinn.java b/Mage.Sets/src/mage/cards/s/SerendibDjinn.java index 84e430bd213..0a703b3dddf 100644 --- a/Mage.Sets/src/mage/cards/s/SerendibDjinn.java +++ b/Mage.Sets/src/mage/cards/s/SerendibDjinn.java @@ -72,8 +72,8 @@ class SerendibDjinnEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(controller.getId(), source, game)) { + controller.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/s/SereneMaster.java b/Mage.Sets/src/mage/cards/s/SereneMaster.java index 56629a3f2ec..f39a4eae8d7 100644 --- a/Mage.Sets/src/mage/cards/s/SereneMaster.java +++ b/Mage.Sets/src/mage/cards/s/SereneMaster.java @@ -75,7 +75,7 @@ class SereneMasterEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature it's blocking"); filter.add(new BlockedByIdPredicate((source.getSourceId()))); Target target = new TargetCreaturePermanent(filter); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { if (controller.chooseTarget(outcome, target, source, game)) { Permanent attackingCreature = game.getPermanent(target.getFirstTarget()); if (attackingCreature != null) { diff --git a/Mage.Sets/src/mage/cards/s/SerrasEmissary.java b/Mage.Sets/src/mage/cards/s/SerrasEmissary.java index 60f167c508e..8af200f52fd 100644 --- a/Mage.Sets/src/mage/cards/s/SerrasEmissary.java +++ b/Mage.Sets/src/mage/cards/s/SerrasEmissary.java @@ -78,7 +78,7 @@ class SerrasEmissaryEffect extends ContinuousEffectImpl { controller.addAbility(ability); for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { permanent.addAbility(ability, source.getSourceId(), game); } diff --git a/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java b/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java index 6567bd0e992..7843de81e3c 100644 --- a/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java +++ b/Mage.Sets/src/mage/cards/s/SetonKrosanProtector.java @@ -80,7 +80,7 @@ class SetonKrosanProtectorManaEffect extends BasicManaEffect { public List getNetMana(Game game, Ability source) { if (game != null && game.inCheckPlayableState()) { // Because the ability can be used multiple times, multiply with untapped druids - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); List netMana = new ArrayList<>(); if (count > 0) { netMana.add(Mana.GreenMana(count)); diff --git a/Mage.Sets/src/mage/cards/s/SettleTheScore.java b/Mage.Sets/src/mage/cards/s/SettleTheScore.java index 3032e317110..0d28a8f8e74 100644 --- a/Mage.Sets/src/mage/cards/s/SettleTheScore.java +++ b/Mage.Sets/src/mage/cards/s/SettleTheScore.java @@ -71,7 +71,7 @@ class SettleTheScoreEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(filter); - if (target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.LOYALTY.createInstance(2), source.getControllerId(), source, game); diff --git a/Mage.Sets/src/mage/cards/s/SeverTheBloodline.java b/Mage.Sets/src/mage/cards/s/SeverTheBloodline.java index 4c94dc9d2e3..ae27c60569e 100644 --- a/Mage.Sets/src/mage/cards/s/SeverTheBloodline.java +++ b/Mage.Sets/src/mage/cards/s/SeverTheBloodline.java @@ -8,7 +8,6 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.TimingRule; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.NamePredicate; @@ -74,7 +73,7 @@ class SeverTheBloodlineEffect extends OneShotEffect { } else { filter.add(new NamePredicate(targetPermanent.getName())); } - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true); } return true; diff --git a/Mage.Sets/src/mage/cards/s/ShaakHerd.java b/Mage.Sets/src/mage/cards/s/ShaakHerd.java index 693b00f6f38..0bdf7a4076c 100644 --- a/Mage.Sets/src/mage/cards/s/ShaakHerd.java +++ b/Mage.Sets/src/mage/cards/s/ShaakHerd.java @@ -11,7 +11,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -23,7 +23,7 @@ public final class ShaakHerd extends CardImpl { private static final FilterCard filter = new FilterCard("another target creature card"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public ShaakHerd(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java b/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java index 06667a49972..fd4e874b817 100644 --- a/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java +++ b/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java @@ -61,7 +61,7 @@ class ShacklesOfTreacheryTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent permanent = game.getPermanent(input.getSourceId()); + Permanent permanent = input.getSource().getSourcePermanentIfItStillExists(game); return permanent != null && permanent.getAttachments().contains(input.getObject().getId()); } } diff --git a/Mage.Sets/src/mage/cards/s/ShadowgrangeArchfiend.java b/Mage.Sets/src/mage/cards/s/ShadowgrangeArchfiend.java index 301c2283035..f5bfaf1dbab 100644 --- a/Mage.Sets/src/mage/cards/s/ShadowgrangeArchfiend.java +++ b/Mage.Sets/src/mage/cards/s/ShadowgrangeArchfiend.java @@ -2,9 +2,7 @@ package mage.cards.s; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.costs.common.PayLifeCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GainLifeEffect; @@ -103,7 +101,7 @@ class ShadowgrangeArchfiendEffect extends OneShotEffect { "creature to sacrifice with power equal to " + greatestPower); filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, greatestPower)); Target target = new TargetControlledCreaturePermanent(filter); - if (opponent.choose(outcome, target, playerId, game)) { + if (opponent.choose(outcome, target, source, game)) { creatureToSacrifice = game.getPermanent(target.getFirstTarget()); } } diff --git a/Mage.Sets/src/mage/cards/s/ShadowsVerdict.java b/Mage.Sets/src/mage/cards/s/ShadowsVerdict.java index f8ef523afa4..cab7c293ccb 100644 --- a/Mage.Sets/src/mage/cards/s/ShadowsVerdict.java +++ b/Mage.Sets/src/mage/cards/s/ShadowsVerdict.java @@ -87,7 +87,7 @@ class ShadowsVerdictEffect extends OneShotEffect { game.getBattlefield() .getActivePermanents( filter, source.getControllerId(), - source.getSourceId(), game + source, game ).stream() .forEach(cards::add); game.getState() diff --git a/Mage.Sets/src/mage/cards/s/ShadrixSilverquill.java b/Mage.Sets/src/mage/cards/s/ShadrixSilverquill.java index 05d41cf56cd..109e9826b61 100644 --- a/Mage.Sets/src/mage/cards/s/ShadrixSilverquill.java +++ b/Mage.Sets/src/mage/cards/s/ShadrixSilverquill.java @@ -118,7 +118,7 @@ class ShadrixSilverquillEffect extends OneShotEffect { } for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getFirstTarget(), source.getSourceId(), game + source.getFirstTarget(), source, game )) { if (permanent == null) { continue; diff --git a/Mage.Sets/src/mage/cards/s/ShamanEnKor.java b/Mage.Sets/src/mage/cards/s/ShamanEnKor.java index f66e8fc8077..0561458fd8b 100644 --- a/Mage.Sets/src/mage/cards/s/ShamanEnKor.java +++ b/Mage.Sets/src/mage/cards/s/ShamanEnKor.java @@ -86,7 +86,7 @@ class ShamanEnKorRedirectFromTargetEffect extends RedirectionEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { TargetSource target = new TargetSource(); - target.choose(Outcome.PreventDamage, player.getId(), source.getSourceId(), game); + target.choose(Outcome.PreventDamage, player.getId(), source.getSourceId(), source, game); this.sourceObject = new MageObjectReference(target.getFirstTarget(), game); } else { discard(); @@ -102,7 +102,7 @@ class ShamanEnKorRedirectFromTargetEffect extends RedirectionEffect { public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { - if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { + if (filter.match(permanent, permanent.getControllerId(), source, game)) { if (sourceObject.equals(new MageObjectReference(event.getSourceId(), game))) { redirectTarget = new TargetPermanent(); redirectTarget.add(source.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/s/ShapeshiftersMarrow.java b/Mage.Sets/src/mage/cards/s/ShapeshiftersMarrow.java index 2752086927d..b1934ecd59d 100644 --- a/Mage.Sets/src/mage/cards/s/ShapeshiftersMarrow.java +++ b/Mage.Sets/src/mage/cards/s/ShapeshiftersMarrow.java @@ -56,7 +56,7 @@ public final class ShapeshiftersMarrow extends CardImpl { @Override public boolean apply(Game game, Ability source) { Player activePlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (activePlayer != null && sourceObject != null) { Card card = activePlayer.getLibrary().getFromTop(game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SharedAnimosity.java b/Mage.Sets/src/mage/cards/s/SharedAnimosity.java index c4eb000b72d..66b2b9ea496 100644 --- a/Mage.Sets/src/mage/cards/s/SharedAnimosity.java +++ b/Mage.Sets/src/mage/cards/s/SharedAnimosity.java @@ -69,7 +69,7 @@ class SharedAnimosityEffect extends OneShotEffect { FilterPermanent filter = new FilterAttackingCreature(); filter.add(new SharesCreatureTypePredicate(permanent)); filter.add(AnotherPredicate.instance); - int count = game.getBattlefield().count(filter, permanent.getId(), source.getControllerId(), game); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (count > 0) { game.addEffect(new BoostTargetEffect( count, 0, Duration.EndOfTurn diff --git a/Mage.Sets/src/mage/cards/s/SharedFate.java b/Mage.Sets/src/mage/cards/s/SharedFate.java index 3d9943ab38c..5e17258b97b 100644 --- a/Mage.Sets/src/mage/cards/s/SharedFate.java +++ b/Mage.Sets/src/mage/cards/s/SharedFate.java @@ -12,7 +12,6 @@ import mage.constants.*; import mage.game.ExileZone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetOpponent; @@ -66,7 +65,7 @@ class SharedFateReplacementEffect extends ReplacementEffectImpl { Player playerToDraw = game.getPlayer(event.getPlayerId()); if (playerToDraw != null && sourcePermanent != null) { TargetOpponent target = new TargetOpponent(true); - if (playerToDraw.choose(Outcome.DrawCard, target, source.getSourceId(), game)) { + if (playerToDraw.choose(Outcome.DrawCard, target, source, game)) { Player chosenPlayer = game.getPlayer(target.getFirstTarget()); if (chosenPlayer != null) { Card card = chosenPlayer.getLibrary().getFromTop(game); diff --git a/Mage.Sets/src/mage/cards/s/ShatterTheSky.java b/Mage.Sets/src/mage/cards/s/ShatterTheSky.java index 72b3ff9f46a..ccb5f6948b3 100644 --- a/Mage.Sets/src/mage/cards/s/ShatterTheSky.java +++ b/Mage.Sets/src/mage/cards/s/ShatterTheSky.java @@ -69,7 +69,7 @@ class ShatterTheSkyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { game.getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game) + .getActivePermanents(filter, source.getControllerId(), source, game) .stream() .map(Controllable::getControllerId) .distinct() diff --git a/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java b/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java index 16498be66b1..7fb2e529752 100644 --- a/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java +++ b/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java @@ -97,7 +97,7 @@ class ShattergangBrothersEffect extends OneShotEffect { if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), playerId, game) + if (target.canChoose(playerId, source, game) && player.chooseTarget(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/s/ShaukuEndbringer.java b/Mage.Sets/src/mage/cards/s/ShaukuEndbringer.java index 1ce2bcf9176..4a563f3ddd3 100644 --- a/Mage.Sets/src/mage/cards/s/ShaukuEndbringer.java +++ b/Mage.Sets/src/mage/cards/s/ShaukuEndbringer.java @@ -90,6 +90,6 @@ class ShaukuEndbringerEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { return permanent.getId().equals(source.getSourceId()) && - game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0; + game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0; } } diff --git a/Mage.Sets/src/mage/cards/s/ShelteringAncient.java b/Mage.Sets/src/mage/cards/s/ShelteringAncient.java index 6c60f4a01cc..a5c2d0743a8 100644 --- a/Mage.Sets/src/mage/cards/s/ShelteringAncient.java +++ b/Mage.Sets/src/mage/cards/s/ShelteringAncient.java @@ -71,7 +71,7 @@ class ShelteringAncientCost extends CostImpl { Player controller = game.getPlayer(controllerId); if (controller != null) { Target target = new TargetCreaturePermanent(1, 1, filter, true); - if (target.choose(Outcome.BoostCreature, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.BoostCreature, controllerId, source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.P1P1.createInstance(), controllerId, ability, game); diff --git a/Mage.Sets/src/mage/cards/s/ShieldmageAdvocate.java b/Mage.Sets/src/mage/cards/s/ShieldmageAdvocate.java index 3300e14c638..be2dd1d68fe 100644 --- a/Mage.Sets/src/mage/cards/s/ShieldmageAdvocate.java +++ b/Mage.Sets/src/mage/cards/s/ShieldmageAdvocate.java @@ -82,7 +82,7 @@ class ShieldmageAdvocateEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/s/ShiftingLoyalties.java b/Mage.Sets/src/mage/cards/s/ShiftingLoyalties.java index 360516f3d97..837b2e86035 100644 --- a/Mage.Sets/src/mage/cards/s/ShiftingLoyalties.java +++ b/Mage.Sets/src/mage/cards/s/ShiftingLoyalties.java @@ -69,11 +69,11 @@ class TargetPermanentsThatShareCardType extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { Set cardTypes = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { for (CardType cardType : permanent.getCardType(game)) { if (cardTypes.contains(cardType)) { diff --git a/Mage.Sets/src/mage/cards/s/ShiftingSky.java b/Mage.Sets/src/mage/cards/s/ShiftingSky.java index 62c144f66e6..c9ff5bd52d3 100644 --- a/Mage.Sets/src/mage/cards/s/ShiftingSky.java +++ b/Mage.Sets/src/mage/cards/s/ShiftingSky.java @@ -69,7 +69,7 @@ class ShiftingSkyEffect extends ContinuousEffectImpl { if (color == null) { return false; } - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { perm.getColor(game).setColor(color); } return true; diff --git a/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java b/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java index 8cb41f8aa12..a897c99eb32 100644 --- a/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java +++ b/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java @@ -80,7 +80,7 @@ class ShimatsuTheBloodcloakedEffect extends ReplacementEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (creature != null && controller != null) { Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledPermanent(), true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } controller.chooseTarget(Outcome.Detriment, target, source, game); diff --git a/Mage.Sets/src/mage/cards/s/ShimianNightStalker.java b/Mage.Sets/src/mage/cards/s/ShimianNightStalker.java index 3772d5f7abd..360147f92b4 100644 --- a/Mage.Sets/src/mage/cards/s/ShimianNightStalker.java +++ b/Mage.Sets/src/mage/cards/s/ShimianNightStalker.java @@ -79,7 +79,7 @@ class ShimianNightStalkerRedirectDamageEffect extends RedirectionEffect { public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { - if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { + if (filter.match(permanent, permanent.getControllerId(), source, game)) { if (event.getSourceId() != null && event.getTargetId() != null) { if (event.getSourceId().equals(getTargetPointer().getFirst(game, source)) && event.getTargetId().equals(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/s/ShimianSpecter.java b/Mage.Sets/src/mage/cards/s/ShimianSpecter.java index aa019301a50..163dd983c23 100644 --- a/Mage.Sets/src/mage/cards/s/ShimianSpecter.java +++ b/Mage.Sets/src/mage/cards/s/ShimianSpecter.java @@ -93,7 +93,7 @@ class ShimianSpecterEffect extends OneShotEffect { TargetCard target = new TargetCard(Zone.HAND, new FilterNonlandCard()); target.setNotTarget(true); Card chosenCard = null; - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(Outcome.Benefit, targetPlayer.getHand(), target, source, game)) { chosenCard = game.getCard(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/s/ShroudedLore.java b/Mage.Sets/src/mage/cards/s/ShroudedLore.java index 029746b868a..137463dca14 100644 --- a/Mage.Sets/src/mage/cards/s/ShroudedLore.java +++ b/Mage.Sets/src/mage/cards/s/ShroudedLore.java @@ -72,7 +72,7 @@ class ShroudedLoreEffect extends OneShotEffect { do { chosenCard = new TargetCardInGraveyard(filter); chosenCard.setNotTarget(true); - if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (chosenCard.canChoose(opponent.getId(), source, game)) { opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game); card = game.getCard(chosenCard.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SianiEyeOfTheStorm.java b/Mage.Sets/src/mage/cards/s/SianiEyeOfTheStorm.java index 5e0cdaa38f1..d78079e8247 100644 --- a/Mage.Sets/src/mage/cards/s/SianiEyeOfTheStorm.java +++ b/Mage.Sets/src/mage/cards/s/SianiEyeOfTheStorm.java @@ -84,7 +84,7 @@ class SianiEyeOfTheStormEffect extends OneShotEffect { if (player == null) { return false; } - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); return count > 0 && player.scry(count, source, game); } } diff --git a/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java b/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java index 261c0b6ada8..58043523b8d 100644 --- a/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java +++ b/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java @@ -92,7 +92,7 @@ class SidarKondoOfJamuraaCantBlockCreaturesSourceEffect extends RestrictionEffec if (attacker == null) { return true; } - return !filter.match(attacker, source.getSourceId(), source.getControllerId(), game); + return !filter.match(attacker, source.getControllerId(), source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/s/SiegeDragon.java b/Mage.Sets/src/mage/cards/s/SiegeDragon.java index f206729d37c..f8e0b76f1af 100644 --- a/Mage.Sets/src/mage/cards/s/SiegeDragon.java +++ b/Mage.Sets/src/mage/cards/s/SiegeDragon.java @@ -19,7 +19,6 @@ import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -127,7 +126,7 @@ class SiegeDragonDamageEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(defendingPlayerId)); filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class))); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.damage(2, source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/s/SiegeStriker.java b/Mage.Sets/src/mage/cards/s/SiegeStriker.java index 9d6aabe710e..9ae6771a37b 100644 --- a/Mage.Sets/src/mage/cards/s/SiegeStriker.java +++ b/Mage.Sets/src/mage/cards/s/SiegeStriker.java @@ -73,8 +73,8 @@ class SiegeStrikerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int tappedAmount = 0; TargetCreaturePermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) - && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) + && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), source, game)) { for (UUID creatureId : target.getTargets()) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { diff --git a/Mage.Sets/src/mage/cards/s/SigardasSummons.java b/Mage.Sets/src/mage/cards/s/SigardasSummons.java index 3b54c8be211..b142aa72d2d 100644 --- a/Mage.Sets/src/mage/cards/s/SigardasSummons.java +++ b/Mage.Sets/src/mage/cards/s/SigardasSummons.java @@ -55,7 +55,7 @@ class SigardasSummonsEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURE_P1P1, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_CREATURE_P1P1, source.getControllerId(), source, game )) { switch (layer) { case TypeChangingEffects_4: diff --git a/Mage.Sets/src/mage/cards/s/SigardasVanguard.java b/Mage.Sets/src/mage/cards/s/SigardasVanguard.java index 848778c0dce..78db6bae4df 100644 --- a/Mage.Sets/src/mage/cards/s/SigardasVanguard.java +++ b/Mage.Sets/src/mage/cards/s/SigardasVanguard.java @@ -80,7 +80,7 @@ class SigardasVanguardEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetCreaturesWithDifferentPowers(); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); if (target.getTargets().isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/SigardianZealot.java b/Mage.Sets/src/mage/cards/s/SigardianZealot.java index 8a1ba21af81..df8e32d5479 100644 --- a/Mage.Sets/src/mage/cards/s/SigardianZealot.java +++ b/Mage.Sets/src/mage/cards/s/SigardianZealot.java @@ -79,7 +79,7 @@ class SigardianZealotEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetCreaturesWithDifferentPowers(); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Cards cards = new CardsImpl(target.getTargets()); if (cards.isEmpty()) { return false; diff --git a/Mage.Sets/src/mage/cards/s/SigilOfValor.java b/Mage.Sets/src/mage/cards/s/SigilOfValor.java index c166c545d9a..2a401fb3b4b 100644 --- a/Mage.Sets/src/mage/cards/s/SigilOfValor.java +++ b/Mage.Sets/src/mage/cards/s/SigilOfValor.java @@ -110,7 +110,7 @@ class SigilOfValorCount implements DynamicValue { if (equipment != null && equipment.getAttachedTo() != null) { FilterPermanent filterPermanent = new FilterControlledCreaturePermanent(); filterPermanent.add(Predicates.not(new CardIdPredicate(equipment.getAttachedTo()))); - return game.getBattlefield().count(filterPermanent, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(filterPermanent, sourceAbility.getControllerId(), sourceAbility, game); } return 0; } diff --git a/Mage.Sets/src/mage/cards/s/Silence.java b/Mage.Sets/src/mage/cards/s/Silence.java index 99f2f84b6ae..0220cbb5091 100644 --- a/Mage.Sets/src/mage/cards/s/Silence.java +++ b/Mage.Sets/src/mage/cards/s/Silence.java @@ -60,7 +60,7 @@ class SilenceEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/s/SilvergillAdept.java b/Mage.Sets/src/mage/cards/s/SilvergillAdept.java index 12ef83ebb46..a28f9dd284b 100644 --- a/Mage.Sets/src/mage/cards/s/SilvergillAdept.java +++ b/Mage.Sets/src/mage/cards/s/SilvergillAdept.java @@ -80,7 +80,7 @@ class SilvergillAdeptCost extends CostImpl { if (player.getHand().count(filter, game) > 0 && player.chooseUse(Outcome.Benefit, "Reveal a Merfolk card? Otherwise pay {3}.", ability, game)) { TargetCardInHand target = new TargetCardInHand(filter); - if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, target, source, game)) { Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { paid = true; diff --git a/Mage.Sets/src/mage/cards/s/SimicGuildmage.java b/Mage.Sets/src/mage/cards/s/SimicGuildmage.java index aaa757e9285..f29b9cfe9c2 100644 --- a/Mage.Sets/src/mage/cards/s/SimicGuildmage.java +++ b/Mage.Sets/src/mage/cards/s/SimicGuildmage.java @@ -191,8 +191,8 @@ class MoveAuraEffect extends OneShotEffect { filterChoice.add(new ControllerIdPredicate(fromPermanent.getControllerId())); filterChoice.add(Predicates.not(new PermanentIdPredicate(fromPermanent.getId()))); chosenPermanentToAttachAuras.setTargetName("a different " + filterChoice.getMessage() + " with the same controller as the " + filterChoice.getMessage() + " the target aura is attached to"); - if (chosenPermanentToAttachAuras.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) { + if (chosenPermanentToAttachAuras.canChoose(source.getControllerId(), source, game) + && controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source, game)) { Permanent permanentToAttachAura = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget()); if (permanentToAttachAura != null) { // Check for protection diff --git a/Mage.Sets/src/mage/cards/s/Simoon.java b/Mage.Sets/src/mage/cards/s/Simoon.java index c80b24b4724..dcde950b68f 100644 --- a/Mage.Sets/src/mage/cards/s/Simoon.java +++ b/Mage.Sets/src/mage/cards/s/Simoon.java @@ -62,7 +62,7 @@ class SimoonEffect extends OneShotEffect { if (player != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(player.getId())); - List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent creature : creatures) { creature.damage(1, source.getSourceId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/s/SingleCombat.java b/Mage.Sets/src/mage/cards/s/SingleCombat.java index b854a8abea6..dd1dc7b1bf0 100644 --- a/Mage.Sets/src/mage/cards/s/SingleCombat.java +++ b/Mage.Sets/src/mage/cards/s/SingleCombat.java @@ -82,7 +82,7 @@ class SingleCombatEffect extends OneShotEffect { } Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { filterSac.add(Predicates.not(new PermanentIdPredicate(target.getFirstTarget()))); } } diff --git a/Mage.Sets/src/mage/cards/s/SirenStormtamer.java b/Mage.Sets/src/mage/cards/s/SirenStormtamer.java index 8e5b4d30a47..666f896b65f 100644 --- a/Mage.Sets/src/mage/cards/s/SirenStormtamer.java +++ b/Mage.Sets/src/mage/cards/s/SirenStormtamer.java @@ -82,7 +82,7 @@ class SirenStormtamerTargetObject extends TargetObject { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { return canChoose(sourceControllerId, game); } @@ -114,8 +114,8 @@ class SirenStormtamerTargetObject extends TargetObject { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, - Game game) { + public Set possibleTargets(UUID sourceControllerId, + Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage.Sets/src/mage/cards/s/SistersOfStoneDeath.java b/Mage.Sets/src/mage/cards/s/SistersOfStoneDeath.java index 88f3775b82a..4706a8877e0 100644 --- a/Mage.Sets/src/mage/cards/s/SistersOfStoneDeath.java +++ b/Mage.Sets/src/mage/cards/s/SistersOfStoneDeath.java @@ -12,15 +12,15 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.cards.CardsImpl; import mage.constants.*; +import mage.filter.FilterPermanent; import mage.filter.StaticFilters; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; import mage.game.ExileZone; import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; +import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; import mage.util.CardUtil; @@ -32,6 +32,13 @@ import java.util.UUID; */ public final class SistersOfStoneDeath extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public SistersOfStoneDeath(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}{G}{G}"); this.addSuperType(SuperType.LEGENDARY); @@ -41,21 +48,17 @@ public final class SistersOfStoneDeath extends CardImpl { this.toughness = new MageInt(5); // {G}: Target creature blocks Sisters of Stone Death this turn if able. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MustBeBlockedByTargetSourceEffect(), new ManaCostsImpl("{G}")); + Ability ability = new SimpleActivatedAbility(new MustBeBlockedByTargetSourceEffect(), new ManaCostsImpl<>("{G}")); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); // {B}{G}: Exile target creature blocking or blocked by Sisters of Stone Death. - Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetForSourceEffect(), new ManaCostsImpl("{B}{G}")); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by Sisters of Stone Death"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); - ability2.addTarget(new TargetCreaturePermanent(filter)); + Ability ability2 = new SimpleActivatedAbility(new ExileTargetForSourceEffect(), new ManaCostsImpl<>("{B}{G}")); + ability2.addTarget(new TargetPermanent(filter)); this.addAbility(ability2); // {2}{B}: Put a creature card exiled with Sisters of Stone Death onto the battlefield under your control. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new SistersOfStoneDeathEffect(), new ManaCostsImpl("{2}{B}"))); - + this.addAbility(new SimpleActivatedAbility(new SistersOfStoneDeathEffect(), new ManaCostsImpl<>("{2}{B}"))); } private SistersOfStoneDeath(final SistersOfStoneDeath card) { diff --git a/Mage.Sets/src/mage/cards/s/SkirkDrillSergeant.java b/Mage.Sets/src/mage/cards/s/SkirkDrillSergeant.java index b76b0be17ae..ef086d3db47 100644 --- a/Mage.Sets/src/mage/cards/s/SkirkDrillSergeant.java +++ b/Mage.Sets/src/mage/cards/s/SkirkDrillSergeant.java @@ -82,7 +82,7 @@ class SkirkDrillSergeantEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/Skred.java b/Mage.Sets/src/mage/cards/s/Skred.java index 0f544bb905e..7199c679eb5 100644 --- a/Mage.Sets/src/mage/cards/s/Skred.java +++ b/Mage.Sets/src/mage/cards/s/Skred.java @@ -61,7 +61,7 @@ class SkredDamageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int amount = game.getBattlefield().count(filter, source.getControllerId(), source, game); Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if(amount > 0) { if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/s/SkulkingKiller.java b/Mage.Sets/src/mage/cards/s/SkulkingKiller.java index 846b8c88f97..539c62fe0d1 100644 --- a/Mage.Sets/src/mage/cards/s/SkulkingKiller.java +++ b/Mage.Sets/src/mage/cards/s/SkulkingKiller.java @@ -68,7 +68,7 @@ class SkulkingKillerEffect extends OneShotEffect { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), permanent.getControllerId(), game + permanent.getControllerId(), source, game ) > 1) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/Skullwinder.java b/Mage.Sets/src/mage/cards/s/Skullwinder.java index 4ad191e5dfe..42d10ad0ace 100644 --- a/Mage.Sets/src/mage/cards/s/Skullwinder.java +++ b/Mage.Sets/src/mage/cards/s/Skullwinder.java @@ -76,14 +76,14 @@ class SkullwinderEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { TargetOpponent targetOpponent = new TargetOpponent(true); - if (controller.choose(Outcome.Detriment, targetOpponent, source.getSourceId(), game)) { + if (controller.choose(Outcome.Detriment, targetOpponent, source, game)) { Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); if (opponent != null) { game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName()); // That player returns a card from their graveyard to their hand TargetCardInYourGraveyard targetCard = new TargetCardInYourGraveyard(new FilterCard("a card from your graveyard to return to your hand")); targetCard.setNotTarget(true); - if (opponent.choose(outcome, targetCard, source.getSourceId(), game)) { + if (opponent.choose(outcome, targetCard, source, game)) { Card card = game.getCard(targetCard.getFirstTarget()); if (card != null) { opponent.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/s/SkyshroudWarBeast.java b/Mage.Sets/src/mage/cards/s/SkyshroudWarBeast.java index 33993c19f18..c3c4440b518 100644 --- a/Mage.Sets/src/mage/cards/s/SkyshroudWarBeast.java +++ b/Mage.Sets/src/mage/cards/s/SkyshroudWarBeast.java @@ -78,7 +78,7 @@ class SkyshroudWarBeastEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - MageObject target = game.getObject(source.getSourceId()); + MageObject target = game.getObject(source); if (target != null) { UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY); FilterLandPermanent filter = FilterLandPermanent.nonbasicLand(); diff --git a/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java b/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java index fe6c3c7c103..09807275293 100644 --- a/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java +++ b/Mage.Sets/src/mage/cards/s/SlipperyBogbonder.java @@ -95,12 +95,12 @@ class SlipperyBogbonderEffect extends OneShotEffect { FilterPermanent filterPermanent = filter.copy(); filterPermanent.add(Predicates.not(new PermanentIdPredicate(source.getFirstTarget()))); if (player == null || creature == null || game.getBattlefield().count( - filterPermanent, source.getSourceId(), source.getControllerId(), game + filterPermanent, source.getControllerId(), source, game ) < 1) { return false; } TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filterPermanent, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); List permanents = target .getTargets() .stream() diff --git a/Mage.Sets/src/mage/cards/s/Slithermuse.java b/Mage.Sets/src/mage/cards/s/Slithermuse.java index 20618815588..2a76763c235 100644 --- a/Mage.Sets/src/mage/cards/s/Slithermuse.java +++ b/Mage.Sets/src/mage/cards/s/Slithermuse.java @@ -77,7 +77,7 @@ class SlithermuseEffect extends OneShotEffect { if (player != null && permanent != null) { TargetOpponent target = new TargetOpponent(); target.setNotTarget(true); - if (player.choose(this.outcome, target, source.getSourceId(), game)) { + if (player.choose(this.outcome, target, source, game)) { Player chosenPlayer = game.getPlayer(target.getFirstTarget()); if (chosenPlayer != null) { game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName()); diff --git a/Mage.Sets/src/mage/cards/s/SludgeMonster.java b/Mage.Sets/src/mage/cards/s/SludgeMonster.java index 42d3a095551..eb3ebe87dcc 100644 --- a/Mage.Sets/src/mage/cards/s/SludgeMonster.java +++ b/Mage.Sets/src/mage/cards/s/SludgeMonster.java @@ -87,7 +87,7 @@ class SludgeMonsterEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { switch (layer) { case AbilityAddingRemovingEffects_6: diff --git a/Mage.Sets/src/mage/cards/s/SludgeStrider.java b/Mage.Sets/src/mage/cards/s/SludgeStrider.java index 53e6fdb4ad0..e6861cfbff2 100644 --- a/Mage.Sets/src/mage/cards/s/SludgeStrider.java +++ b/Mage.Sets/src/mage/cards/s/SludgeStrider.java @@ -76,7 +76,7 @@ class SludgeStriderTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent != null && filter.match(permanent, getControllerId(), this, game)) { return true; } } @@ -88,7 +88,7 @@ class SludgeStriderTriggeredAbility extends TriggeredAbilityImpl { if (permanent == null) { permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); } - return permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game); + return permanent != null && filter.match(permanent, getControllerId(), this, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/s/SmokeTeller.java b/Mage.Sets/src/mage/cards/s/SmokeTeller.java index d015a603401..5c2c3921145 100644 --- a/Mage.Sets/src/mage/cards/s/SmokeTeller.java +++ b/Mage.Sets/src/mage/cards/s/SmokeTeller.java @@ -78,7 +78,7 @@ class SmokeTellerLookFaceDownEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (player == null || mageObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/Smokebraider.java b/Mage.Sets/src/mage/cards/s/Smokebraider.java index 3ed7e6438f8..b24dafc8460 100644 --- a/Mage.Sets/src/mage/cards/s/Smokebraider.java +++ b/Mage.Sets/src/mage/cards/s/Smokebraider.java @@ -71,7 +71,7 @@ class SmokebraiderManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.hasSubtype(SubType.ELEMENTAL, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/Smokestack.java b/Mage.Sets/src/mage/cards/s/Smokestack.java index 64900704a14..2f96c27ac3d 100644 --- a/Mage.Sets/src/mage/cards/s/Smokestack.java +++ b/Mage.Sets/src/mage/cards/s/Smokestack.java @@ -72,9 +72,9 @@ class SmokestackEffect extends OneShotEffect { Target target = new TargetControlledPermanent(amount, amount, new FilterControlledPermanent(), true); //A spell or ability could have removed the only legal target this player //had, if thats the case this ability should fizzle. - if (target.canChoose(source.getSourceId(), activePlayer.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), activePlayer.getId(), game) && activePlayer.canRespond()) { - activePlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(activePlayer.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(activePlayer.getId(), source, game) && activePlayer.canRespond()) { + activePlayer.choose(Outcome.Sacrifice, target, source, game); } for (int idx = 0; idx < target.getTargets().size(); idx++) { diff --git a/Mage.Sets/src/mage/cards/s/SneakAttack.java b/Mage.Sets/src/mage/cards/s/SneakAttack.java index 1f832a7ab5c..2df5981e8aa 100644 --- a/Mage.Sets/src/mage/cards/s/SneakAttack.java +++ b/Mage.Sets/src/mage/cards/s/SneakAttack.java @@ -74,7 +74,7 @@ class SneakAttackEffect extends OneShotEffect { return true; } TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE); - if (!controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (!controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { return true; } Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/s/SoldeviMachinist.java b/Mage.Sets/src/mage/cards/s/SoldeviMachinist.java index afdaba0e44a..931b58d835a 100644 --- a/Mage.Sets/src/mage/cards/s/SoldeviMachinist.java +++ b/Mage.Sets/src/mage/cards/s/SoldeviMachinist.java @@ -75,7 +75,7 @@ class ArtifactAbilityManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (source != null && source.getAbilityType() == AbilityType.ACTIVATED) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.isArtifact(game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/Solfatara.java b/Mage.Sets/src/mage/cards/s/Solfatara.java index fad0047d17b..0d1f712f79c 100644 --- a/Mage.Sets/src/mage/cards/s/Solfatara.java +++ b/Mage.Sets/src/mage/cards/s/Solfatara.java @@ -68,7 +68,7 @@ class SolfataraEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't play lands this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/s/SongOfSerenity.java b/Mage.Sets/src/mage/cards/s/SongOfSerenity.java index 953646afb31..17247495746 100644 --- a/Mage.Sets/src/mage/cards/s/SongOfSerenity.java +++ b/Mage.Sets/src/mage/cards/s/SongOfSerenity.java @@ -72,6 +72,6 @@ class SongOfSerenityRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } } diff --git a/Mage.Sets/src/mage/cards/s/SorcererClass.java b/Mage.Sets/src/mage/cards/s/SorcererClass.java index 98ae21ab217..a6ddd0736c0 100644 --- a/Mage.Sets/src/mage/cards/s/SorcererClass.java +++ b/Mage.Sets/src/mage/cards/s/SorcererClass.java @@ -116,7 +116,7 @@ class SorcererClassManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isInstantOrSorcery(game); } return source instanceof ClassLevelAbility; diff --git a/Mage.Sets/src/mage/cards/s/SorcerousSpyglass.java b/Mage.Sets/src/mage/cards/s/SorcerousSpyglass.java index 1c3aabe8775..b0ec479da6d 100644 --- a/Mage.Sets/src/mage/cards/s/SorcerousSpyglass.java +++ b/Mage.Sets/src/mage/cards/s/SorcerousSpyglass.java @@ -63,10 +63,10 @@ class SorcerousSpyglassEntersEffect extends ChooseACardNameEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { TargetOpponent target = new TargetOpponent(true); - if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, target, source, game)) { Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); player.lookAtCards(sourceObject != null ? sourceObject.getIdName() : null, opponent.getHand(), game); player.chooseUse(Outcome.Benefit, "Press Ok to name a card", "You won't be able to resize the window showing opponents hand once you do", diff --git a/Mage.Sets/src/mage/cards/s/SoulFoundry.java b/Mage.Sets/src/mage/cards/s/SoulFoundry.java index 1a53da830aa..931c716c28b 100644 --- a/Mage.Sets/src/mage/cards/s/SoulFoundry.java +++ b/Mage.Sets/src/mage/cards/s/SoulFoundry.java @@ -108,7 +108,7 @@ class SoulFoundryImprintEffect extends OneShotEffect { if (controller != null) { if (!controller.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.choose(Outcome.Benefit, controller.getHand(), target, game)) { Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SoulOfShandalar.java b/Mage.Sets/src/mage/cards/s/SoulOfShandalar.java index 76a85000581..cff9b243d55 100644 --- a/Mage.Sets/src/mage/cards/s/SoulOfShandalar.java +++ b/Mage.Sets/src/mage/cards/s/SoulOfShandalar.java @@ -118,16 +118,16 @@ class SoulOfShandalarTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject object = game.getObject(sourceId); + MageObject object = game.getObject(source); for (StackObject item : game.getState().getStack()) { - if (item.getId().equals(sourceId)) { + if (item.getId().equals(source.getSourceId())) { object = item; } - if (item.getSourceId().equals(sourceId)) { + if (item.getSourceId().equals(source.getSourceId())) { object = item; } } diff --git a/Mage.Sets/src/mage/cards/s/SoulhunterRakshasa.java b/Mage.Sets/src/mage/cards/s/SoulhunterRakshasa.java index 2065ee9a530..dbc8ab39489 100644 --- a/Mage.Sets/src/mage/cards/s/SoulhunterRakshasa.java +++ b/Mage.Sets/src/mage/cards/s/SoulhunterRakshasa.java @@ -75,7 +75,7 @@ class SoulhunterRakshasaEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int amount = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (amount > 0) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/s/SoullessOne.java b/Mage.Sets/src/mage/cards/s/SoullessOne.java index 7d64872e1a7..cca6e6920d3 100644 --- a/Mage.Sets/src/mage/cards/s/SoullessOne.java +++ b/Mage.Sets/src/mage/cards/s/SoullessOne.java @@ -56,7 +56,7 @@ class SoullessOneDynamicCount implements DynamicValue { zombiesBattlefield.add(SubType.ZOMBIE.getPredicate()); zombiesInGraveyard.add(SubType.ZOMBIE.getPredicate()); - int count = game.getBattlefield().count(zombiesBattlefield, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + int count = game.getBattlefield().count(zombiesBattlefield, sourceAbility.getControllerId(), sourceAbility, game); for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/s/Soulquake.java b/Mage.Sets/src/mage/cards/s/Soulquake.java index b60cc69a706..97a05099b35 100644 --- a/Mage.Sets/src/mage/cards/s/Soulquake.java +++ b/Mage.Sets/src/mage/cards/s/Soulquake.java @@ -65,7 +65,7 @@ class SoulquakeEffect extends OneShotEffect { return false; } Set cardsToHand = new LinkedHashSet<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { cardsToHand.add((Card) permanent); } for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/s/SparkFiend.java b/Mage.Sets/src/mage/cards/s/SparkFiend.java index 800544b13d7..71fe8ce7efd 100644 --- a/Mage.Sets/src/mage/cards/s/SparkFiend.java +++ b/Mage.Sets/src/mage/cards/s/SparkFiend.java @@ -68,7 +68,7 @@ class SparkFiendEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int roll = controller.rollDice(outcome, source, game, 6, 2, 0).stream().mapToInt(x -> x).sum(); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject instanceof Permanent) { Permanent sourcePermanent = (Permanent) mageObject; if (roll == 2 || roll == 3 || roll == 12) { @@ -113,7 +113,7 @@ class SparkFiendUpkeepEffect extends OneShotEffect { if (game.getState().getValue("SparkFiend" + source.getSourceId().toString()) != null && (Integer) game.getState().getValue("SparkFiend" + source.getSourceId().toString()) != 0) { int roll = controller.rollDice(outcome, source, game, 6, 2, 0).stream().mapToInt(x -> x).sum(); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject instanceof Permanent) { Permanent sourcePermanent = (Permanent) mageObject; if (roll == 7) { diff --git a/Mage.Sets/src/mage/cards/s/Spawnbroker.java b/Mage.Sets/src/mage/cards/s/Spawnbroker.java index 58a9da3fa49..d9c342f7a27 100644 --- a/Mage.Sets/src/mage/cards/s/Spawnbroker.java +++ b/Mage.Sets/src/mage/cards/s/Spawnbroker.java @@ -69,11 +69,11 @@ class TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent extend } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } @@ -118,12 +118,12 @@ class SpawnbrokerSecondTarget extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); if (firstTarget != null) { - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) { possibleTargets.add(permanent.getId()); diff --git a/Mage.Sets/src/mage/cards/s/SpectralArcanist.java b/Mage.Sets/src/mage/cards/s/SpectralArcanist.java index cbc7ee912fd..14323e6474d 100644 --- a/Mage.Sets/src/mage/cards/s/SpectralArcanist.java +++ b/Mage.Sets/src/mage/cards/s/SpectralArcanist.java @@ -87,7 +87,7 @@ class SpectralArcanistCastEffect extends OneShotEffect { FilterCard filterCard = new FilterInstantOrSorceryCard(); filterCard.add(new ManaValuePredicate( ComparisonType.FEWER_THAN, - game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) + game.getBattlefield().count(filter, source.getControllerId(), source, game) )); Cards cards = new CardsImpl(); game.getState() diff --git a/Mage.Sets/src/mage/cards/s/SpectralDeluge.java b/Mage.Sets/src/mage/cards/s/SpectralDeluge.java index 5bc96cc27d7..50927bfd3cf 100644 --- a/Mage.Sets/src/mage/cards/s/SpectralDeluge.java +++ b/Mage.Sets/src/mage/cards/s/SpectralDeluge.java @@ -62,6 +62,6 @@ enum SpectralDelugePredicate implements ObjectSourcePlayerPredicate .getValue() <= game .getBattlefield() - .count(filter, input.getSourceId(), input.getPlayerId(), game); + .count(filter, input.getPlayerId(), input.getSource(), game); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/s/SpellRupture.java b/Mage.Sets/src/mage/cards/s/SpellRupture.java index e56e0bf547a..c110ad6b8f1 100644 --- a/Mage.Sets/src/mage/cards/s/SpellRupture.java +++ b/Mage.Sets/src/mage/cards/s/SpellRupture.java @@ -67,7 +67,7 @@ class SpellRuptureCounterUnlessPaysEffect extends OneShotEffect { if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && controller != null && sourceObject != null) { int maxPower = new GreatestPowerCountCreatureYouControl().calculate(game, source, this); Cost cost = ManaUtil.createManaCost(maxPower, true); diff --git a/Mage.Sets/src/mage/cards/s/SpellSyphon.java b/Mage.Sets/src/mage/cards/s/SpellSyphon.java index db160c2781e..575ba034f7e 100644 --- a/Mage.Sets/src/mage/cards/s/SpellSyphon.java +++ b/Mage.Sets/src/mage/cards/s/SpellSyphon.java @@ -74,7 +74,7 @@ class SpellSyphonEffect extends OneShotEffect { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); if (player != null && controller != null) { - int amount = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game); + int amount = game.getBattlefield().count(filter, controller.getId(), source, game); if (amount == 0) { game.informPlayers("Spell Syphon: no blue permanents in controller's battlefield."); } else { diff --git a/Mage.Sets/src/mage/cards/s/Spellbinder.java b/Mage.Sets/src/mage/cards/s/Spellbinder.java index d93dbc50fd0..4cf4e285d66 100644 --- a/Mage.Sets/src/mage/cards/s/Spellbinder.java +++ b/Mage.Sets/src/mage/cards/s/Spellbinder.java @@ -16,7 +16,6 @@ import mage.filter.FilterCard; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetCard; @@ -119,7 +118,7 @@ class SpellbinderImprintEffect extends OneShotEffect { if (controller != null) { if (!controller.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.choose(Outcome.Benefit, controller.getHand(), target, game)) { Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SpellboundDragon.java b/Mage.Sets/src/mage/cards/s/SpellboundDragon.java index 5e1ea5767c6..1d8be705919 100644 --- a/Mage.Sets/src/mage/cards/s/SpellboundDragon.java +++ b/Mage.Sets/src/mage/cards/s/SpellboundDragon.java @@ -73,7 +73,7 @@ class SpellboundDragonEffect extends OneShotEffect { if(you != null) { you.drawCards(1, source, game); TargetDiscard target = new TargetDiscard(you.getId()); - you.choose(Outcome.Discard, target, source.getSourceId(), game); + you.choose(Outcome.Discard, target, source, game); Card card = you.getHand().get(target.getFirstTarget(), game); if (card != null && you.discard(card, false, source, game)) { int cmc = card.getManaValue(); diff --git a/Mage.Sets/src/mage/cards/s/Spellskite.java b/Mage.Sets/src/mage/cards/s/Spellskite.java index f96b3ef70d4..07fe08f4fe7 100644 --- a/Mage.Sets/src/mage/cards/s/Spellskite.java +++ b/Mage.Sets/src/mage/cards/s/Spellskite.java @@ -67,7 +67,7 @@ class SpellskiteEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (stackObject != null && sourceObject != null) { Targets targets = new Targets(); Ability sourceAbility; diff --git a/Mage.Sets/src/mage/cards/s/SpellweaverVolute.java b/Mage.Sets/src/mage/cards/s/SpellweaverVolute.java index 029ae9eb710..77617b686a8 100644 --- a/Mage.Sets/src/mage/cards/s/SpellweaverVolute.java +++ b/Mage.Sets/src/mage/cards/s/SpellweaverVolute.java @@ -103,8 +103,8 @@ class SpellweaverVoluteEffect extends OneShotEffect { FilterCard filter = new FilterCard("instant card in a graveyard"); filter.add(CardType.INSTANT.getPredicate()); TargetCardInGraveyard auraTarget = new TargetCardInGraveyard(filter); - if (auraTarget.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(Outcome.Benefit, auraTarget, source.getSourceId(), game); + if (auraTarget.canChoose(controller.getId(), source, game)) { + controller.choose(Outcome.Benefit, auraTarget, source, game); Card newAuraTarget = game.getCard(auraTarget.getFirstTarget()); if (newAuraTarget != null) { if (enchantedCard.getId().equals(newAuraTarget.getId())) { diff --git a/Mage.Sets/src/mage/cards/s/SphinxsDecree.java b/Mage.Sets/src/mage/cards/s/SphinxsDecree.java index 2a954e26951..87e5ccb28c2 100644 --- a/Mage.Sets/src/mage/cards/s/SphinxsDecree.java +++ b/Mage.Sets/src/mage/cards/s/SphinxsDecree.java @@ -93,7 +93,7 @@ class SphinxsDecreeCantCastEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast instant or sorcery spells this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/s/SplendidReclamation.java b/Mage.Sets/src/mage/cards/s/SplendidReclamation.java index f798b78526c..a023a451d2b 100644 --- a/Mage.Sets/src/mage/cards/s/SplendidReclamation.java +++ b/Mage.Sets/src/mage/cards/s/SplendidReclamation.java @@ -56,8 +56,8 @@ class ReplenishEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - return controller.moveCards(controller.getGraveyard().getCards(new FilterLandCard(), source.getSourceId(), - source.getControllerId(), game), Zone.BATTLEFIELD, source, game, true, false, false, null); + return controller.moveCards(controller.getGraveyard().getCards(new FilterLandCard(), + source.getControllerId(), source, game), Zone.BATTLEFIELD, source, game, true, false, false, null); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SpoilsOfTheVault.java b/Mage.Sets/src/mage/cards/s/SpoilsOfTheVault.java index b230904b04c..9c48dda85ff 100644 --- a/Mage.Sets/src/mage/cards/s/SpoilsOfTheVault.java +++ b/Mage.Sets/src/mage/cards/s/SpoilsOfTheVault.java @@ -56,7 +56,7 @@ class SpoilsOfTheVaultEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (sourceObject == null || controller == null || cardName == null || cardName.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/s/SporeCloud.java b/Mage.Sets/src/mage/cards/s/SporeCloud.java index a79d04cad4a..8bce663ef36 100644 --- a/Mage.Sets/src/mage/cards/s/SporeCloud.java +++ b/Mage.Sets/src/mage/cards/s/SporeCloud.java @@ -77,7 +77,7 @@ class SporeCloudEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { List doNotUntapNextUntapStep = new ArrayList<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { doNotUntapNextUntapStep.add(permanent); } if (!doNotUntapNextUntapStep.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/s/SpyNetwork.java b/Mage.Sets/src/mage/cards/s/SpyNetwork.java index abb405b5e97..f97bf66c14e 100644 --- a/Mage.Sets/src/mage/cards/s/SpyNetwork.java +++ b/Mage.Sets/src/mage/cards/s/SpyNetwork.java @@ -70,7 +70,7 @@ class SpyNetworkLookAtTargetPlayerHandEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (you != null && targetPlayer != null) { you.lookAtCards("Hand of " + targetPlayer.getName() + " (" + (sourceObject != null ? sourceObject.getIdName() : null) + ')', targetPlayer.getHand(), game); return true; @@ -100,16 +100,16 @@ class SpyNetworkFaceDownEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && player != null && mageObject != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent("face down creature controlled by " + player.getLogName()); filter.add(FaceDownPredicate.instance); filter.add(new ControllerIdPredicate(player.getId())); TargetCreaturePermanent target = new TargetCreaturePermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { while (controller.chooseUse(outcome, "Look at a face down creature controlled by " + player.getLogName() + "?", source, game)) { target.clearChosen(); - while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + while (!target.isChosen() && target.canChoose(controller.getId(), source, game) && controller.canRespond()) { controller.chooseTarget(outcome, target, source, game); } Permanent faceDownCreature = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/s/Stabilizer.java b/Mage.Sets/src/mage/cards/s/Stabilizer.java index bd70c9553e1..d305216451a 100644 --- a/Mage.Sets/src/mage/cards/s/Stabilizer.java +++ b/Mage.Sets/src/mage/cards/s/Stabilizer.java @@ -60,7 +60,7 @@ class StabilizerEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject == null) { return null; } diff --git a/Mage.Sets/src/mage/cards/s/StadiumVendors.java b/Mage.Sets/src/mage/cards/s/StadiumVendors.java index 9faae0932cf..e31d4992e0c 100644 --- a/Mage.Sets/src/mage/cards/s/StadiumVendors.java +++ b/Mage.Sets/src/mage/cards/s/StadiumVendors.java @@ -69,7 +69,7 @@ class StadiumVendorsEffect extends OneShotEffect { return false; } TargetPlayer target = new TargetPlayer(1, 1, true); - if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.Benefit, target, source, game)) { Player player = game.getPlayer(target.getFirstTarget()); ChoiceColor colorChoice = new ChoiceColor(true); if (player == null diff --git a/Mage.Sets/src/mage/cards/s/StaffOfTheLetterMagus.java b/Mage.Sets/src/mage/cards/s/StaffOfTheLetterMagus.java index 806541bd5b2..4cb9d8ad7d7 100644 --- a/Mage.Sets/src/mage/cards/s/StaffOfTheLetterMagus.java +++ b/Mage.Sets/src/mage/cards/s/StaffOfTheLetterMagus.java @@ -65,7 +65,7 @@ class StaffOfTheLetterMagusChooseLetterEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } ChoiceImpl choice = new ChoiceImpl(true); @@ -122,7 +122,7 @@ class StaffOfTheLetterMagusEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source)); if (controller != null && spell != null) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject instanceof Permanent) { Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (permanent != null && game.getState().getValue(mageObject.getId() + "_letter") != null) { diff --git a/Mage.Sets/src/mage/cards/s/StandOrFall.java b/Mage.Sets/src/mage/cards/s/StandOrFall.java index b074b3345bc..a34a01e9620 100644 --- a/Mage.Sets/src/mage/cards/s/StandOrFall.java +++ b/Mage.Sets/src/mage/cards/s/StandOrFall.java @@ -94,7 +94,7 @@ class StandOrFallEffect extends OneShotEffect { TargetCreaturePermanent creatures = new TargetCreaturePermanent(0, count, new FilterCreaturePermanent("creatures to put in the first pile"), true); List pile1 = new ArrayList<>(); creatures.setRequired(false); - if (player.choose(Outcome.Neutral, creatures, source.getSourceId(), game)) { + if (player.choose(Outcome.Neutral, creatures, source, game)) { List targets = creatures.getTargets(); for (UUID targetId : targets) { Permanent p = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/s/Standardize.java b/Mage.Sets/src/mage/cards/s/Standardize.java index 8879005abe6..d5befc3562a 100644 --- a/Mage.Sets/src/mage/cards/s/Standardize.java +++ b/Mage.Sets/src/mage/cards/s/Standardize.java @@ -57,7 +57,7 @@ class StandardizeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String chosenType = ""; if (player != null && sourceObject != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject); diff --git a/Mage.Sets/src/mage/cards/s/StarfieldOfNyx.java b/Mage.Sets/src/mage/cards/s/StarfieldOfNyx.java index 9bf5979fb41..c8338a53746 100644 --- a/Mage.Sets/src/mage/cards/s/StarfieldOfNyx.java +++ b/Mage.Sets/src/mage/cards/s/StarfieldOfNyx.java @@ -112,7 +112,7 @@ public final class StarfieldOfNyx extends CardImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, - source.getControllerId(), source.getSourceId(), game)) { + source.getControllerId(), source, game)) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { diff --git a/Mage.Sets/src/mage/cards/s/Statecraft.java b/Mage.Sets/src/mage/cards/s/Statecraft.java index 8f9b5bf428f..bd29f19f62c 100644 --- a/Mage.Sets/src/mage/cards/s/Statecraft.java +++ b/Mage.Sets/src/mage/cards/s/Statecraft.java @@ -61,11 +61,11 @@ class StatecraftPreventionEffect extends PreventionEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game)) { Permanent sourcePermanent = game.getPermanent(event.getSourceId()); - if (sourcePermanent != null && filter.match(sourcePermanent, source.getSourceId(), source.getControllerId(), game)) { + if (sourcePermanent != null && filter.match(sourcePermanent, source.getControllerId(), source, game)) { return true; } Permanent targetPermanent = game.getPermanent(event.getTargetId()); - if (targetPermanent != null && filter.match(targetPermanent, source.getSourceId(), source.getControllerId(), game)) { + if (targetPermanent != null && filter.match(targetPermanent, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/s/SteadfastArmasaur.java b/Mage.Sets/src/mage/cards/s/SteadfastArmasaur.java index c1c6bd174d4..cbc2dab16ea 100644 --- a/Mage.Sets/src/mage/cards/s/SteadfastArmasaur.java +++ b/Mage.Sets/src/mage/cards/s/SteadfastArmasaur.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -14,19 +12,25 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author TheElk801 */ public final class SteadfastArmasaur extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by it"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public SteadfastArmasaur(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}"); @@ -38,12 +42,11 @@ public final class SteadfastArmasaur extends CardImpl { this.addAbility(VigilanceAbility.getInstance()); // {1}{W}, {T}: Steadfast Armasaur deals damage equal to its toughness to target creature blocking or blocked by it. - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by it"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(SourcePermanentToughnessValue.getInstance()), new ManaCostsImpl("{1}{W}")); + Ability ability = new SimpleActivatedAbility( + new DamageTargetEffect(SourcePermanentToughnessValue.getInstance()), new ManaCostsImpl<>("{1}{W}") + ); ability.addCost(new TapSourceCost()); - ability.addTarget(new TargetCreaturePermanent(filter)); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/s/SteamAugury.java b/Mage.Sets/src/mage/cards/s/SteamAugury.java index af6f005a577..0c7792c7edd 100644 --- a/Mage.Sets/src/mage/cards/s/SteamAugury.java +++ b/Mage.Sets/src/mage/cards/s/SteamAugury.java @@ -66,7 +66,7 @@ class SteamAuguryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Set cardsToGraveyard = new LinkedHashSet<>(); Set cardsToHand = new LinkedHashSet<>(); if (controller == null || sourceObject == null) { diff --git a/Mage.Sets/src/mage/cards/s/SteamVines.java b/Mage.Sets/src/mage/cards/s/SteamVines.java index 8bfd128b2f4..4a3f7535671 100644 --- a/Mage.Sets/src/mage/cards/s/SteamVines.java +++ b/Mage.Sets/src/mage/cards/s/SteamVines.java @@ -92,7 +92,7 @@ class SteamVinesEffect extends OneShotEffect { target.setNotTarget(true); //not a target, it is chosen Card steamVinesCard = game.getCard(source.getSourceId()); if (steamVinesCard != null && landsController != null) { - if (landsController.choose(Outcome.DestroyPermanent, target, source.getId(), game)) { + if (landsController.choose(Outcome.DestroyPermanent, target, source, game)) { if (target.getFirstTarget() != null) { Permanent landChosen = game.getPermanent(target.getFirstTarget()); if (landChosen != null) { diff --git a/Mage.Sets/src/mage/cards/s/SteelcladSerpent.java b/Mage.Sets/src/mage/cards/s/SteelcladSerpent.java index 00e88ddd5a1..45fa63baa0a 100644 --- a/Mage.Sets/src/mage/cards/s/SteelcladSerpent.java +++ b/Mage.Sets/src/mage/cards/s/SteelcladSerpent.java @@ -74,7 +74,7 @@ class SteelcladSerpentEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), permanent.getId(), game).isEmpty(); + return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).isEmpty(); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SteelyResolve.java b/Mage.Sets/src/mage/cards/s/SteelyResolve.java index b0659ecec4c..497104c058d 100644 --- a/Mage.Sets/src/mage/cards/s/SteelyResolve.java +++ b/Mage.Sets/src/mage/cards/s/SteelyResolve.java @@ -2,6 +2,8 @@ package mage.cards.s; import java.util.UUID; + +import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.ChooseCreatureTypeEffect; @@ -55,9 +57,9 @@ class FilterSteelyResolve extends FilterCreaturePermanent { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (super.match(permanent, sourceId, playerId, game)) { - SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(sourceId, game); + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (super.match(permanent, playerId, source, game)) { + SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game); if (subType != null && permanent.hasSubtype(subType, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/SternJudge.java b/Mage.Sets/src/mage/cards/s/SternJudge.java index 234bbef5740..21c7faea98a 100644 --- a/Mage.Sets/src/mage/cards/s/SternJudge.java +++ b/Mage.Sets/src/mage/cards/s/SternJudge.java @@ -70,7 +70,7 @@ class SternJudgeEffect extends OneShotEffect { continue; } player.loseLife(game.getBattlefield().count( - filter, playerId, source.getSourceId(), game + filter, source.getSourceId(), source, game ), game, source, false); } return true; diff --git a/Mage.Sets/src/mage/cards/s/StitchersApprentice.java b/Mage.Sets/src/mage/cards/s/StitchersApprentice.java index 1e8081da097..100868f5eaa 100644 --- a/Mage.Sets/src/mage/cards/s/StitchersApprentice.java +++ b/Mage.Sets/src/mage/cards/s/StitchersApprentice.java @@ -75,7 +75,7 @@ class StitchersApprenticeEffect extends OneShotEffect { if (player != null) { Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent()); - if (target.canChoose(source.getSourceId(), player.getId(), game) && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (target.canChoose(player.getId(), source, game) && player.choose(Outcome.Sacrifice, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { return permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/s/StolenStrategy.java b/Mage.Sets/src/mage/cards/s/StolenStrategy.java index 797c7b6892b..4925ba0620c 100644 --- a/Mage.Sets/src/mage/cards/s/StolenStrategy.java +++ b/Mage.Sets/src/mage/cards/s/StolenStrategy.java @@ -68,7 +68,7 @@ class StolenStrategyEffect extends OneShotEffect { if (damagedPlayer == null) { continue; } - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); UUID exileId = CardUtil.getCardExileZoneId(game, source); Card card = damagedPlayer.getLibrary().getFromTop(game); if (card != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/s/StoneIdolTrap.java b/Mage.Sets/src/mage/cards/s/StoneIdolTrap.java index 8d46cad040e..c716115b9fd 100644 --- a/Mage.Sets/src/mage/cards/s/StoneIdolTrap.java +++ b/Mage.Sets/src/mage/cards/s/StoneIdolTrap.java @@ -65,7 +65,7 @@ class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { - int reductionAmount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int reductionAmount = game.getBattlefield().count(filter, source.getControllerId(), source, game); CardUtil.reduceCost(abilityToModify, reductionAmount); return true; } diff --git a/Mage.Sets/src/mage/cards/s/StonehewerGiant.java b/Mage.Sets/src/mage/cards/s/StonehewerGiant.java index 47cf1c89c32..32c6fb962fa 100644 --- a/Mage.Sets/src/mage/cards/s/StonehewerGiant.java +++ b/Mage.Sets/src/mage/cards/s/StonehewerGiant.java @@ -94,7 +94,7 @@ class StonehewerGiantEffect extends OneShotEffect { Permanent equipment = game.getPermanent(card.getId()); Target targetCreature = new TargetControlledCreaturePermanent(); targetCreature.setNotTarget(true); - if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) { + if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source, game)) { Permanent permanent = game.getPermanent(targetCreature.getFirstTarget()); permanent.addAttachment(equipment.getId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/s/StonewiseFortifier.java b/Mage.Sets/src/mage/cards/s/StonewiseFortifier.java index abf069ca2c2..d21065c47cb 100644 --- a/Mage.Sets/src/mage/cards/s/StonewiseFortifier.java +++ b/Mage.Sets/src/mage/cards/s/StonewiseFortifier.java @@ -77,7 +77,7 @@ class StonewiseFortifierPreventAllDamageToEffect extends PreventionEffectImpl { if (!game.replaceEvent(preventEvent)) { int preventedDamage = event.getAmount(); MageObject damageSource = game.getObject(event.getSourceId()); - MageObject preventionSource = game.getObject(source.getSourceId()); + MageObject preventionSource = game.getObject(source); if (damageSource != null && preventionSource != null) { String message = " damage from " + damageSource.getName() + " prevented " + diff --git a/Mage.Sets/src/mage/cards/s/StormHerald.java b/Mage.Sets/src/mage/cards/s/StormHerald.java index 6a13a096f30..2e01d82fa1e 100644 --- a/Mage.Sets/src/mage/cards/s/StormHerald.java +++ b/Mage.Sets/src/mage/cards/s/StormHerald.java @@ -92,7 +92,7 @@ class StormHeraldEffect extends OneShotEffect { FilterCard filter = new FilterCard("aura cards to attach to creatures you control"); filter.add(SubType.AURA.getPredicate()); filter.add(new StormHeraldAttachablePredicate(controller.getId())); - Set possibleTargets = controller.getGraveyard().getCards(filter, source.getSourceId(), controller.getId(), game); + Set possibleTargets = controller.getGraveyard().getCards(filter, controller.getId(), source, game); if (!possibleTargets.isEmpty()) { TargetCard targetAuras = new TargetCard(0, Integer.MAX_VALUE, Zone.GRAVEYARD, filter); targetAuras.setNotTarget(true); @@ -107,7 +107,7 @@ class StormHeraldEffect extends OneShotEffect { filterAttachTo.add(new StormHeraldAttachableToPredicate(auraCard)); TargetPermanent targetCreature = new TargetPermanent(filterAttachTo); targetCreature.setNotTarget(true); - if (controller.choose(Outcome.PutCardInPlay, targetCreature, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, targetCreature, source, game)) { Permanent targetPermanent = game.getPermanent(targetCreature.getFirstTarget()); if (!targetPermanent.cantBeAttachedBy(auraCard, source, game, true)) { game.getState().setValue("attachTo:" + auraCard.getId(), targetPermanent); diff --git a/Mage.Sets/src/mage/cards/s/Stranglehold.java b/Mage.Sets/src/mage/cards/s/Stranglehold.java index c7043b163dd..a5cc95c0ae7 100644 --- a/Mage.Sets/src/mage/cards/s/Stranglehold.java +++ b/Mage.Sets/src/mage/cards/s/Stranglehold.java @@ -67,7 +67,7 @@ class OpponentsCantSearchLibarariesEffect extends ContinuousRuleModifyingEffectI @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't search libraries (" + mageObject.getLogName() + " in play)."; } @@ -110,7 +110,7 @@ class StrangleholdSkipExtraTurnsEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(event.getPlayerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { game.informPlayers(sourceObject.getLogName() + ": Extra turn of " + player.getLogName() + " skipped"); } diff --git a/Mage.Sets/src/mage/cards/s/StranglingGrasp.java b/Mage.Sets/src/mage/cards/s/StranglingGrasp.java index 2c78cb5ff18..0cd028601f4 100644 --- a/Mage.Sets/src/mage/cards/s/StranglingGrasp.java +++ b/Mage.Sets/src/mage/cards/s/StranglingGrasp.java @@ -101,8 +101,8 @@ class StranglingGraspEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(outcome, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/s/StrataScythe.java b/Mage.Sets/src/mage/cards/s/StrataScythe.java index 6905e435e84..a51dc971864 100644 --- a/Mage.Sets/src/mage/cards/s/StrataScythe.java +++ b/Mage.Sets/src/mage/cards/s/StrataScythe.java @@ -108,7 +108,7 @@ class SameNameAsExiledCountValue implements DynamicValue { if (permanent != null && !permanent.getImprinted().isEmpty()) { FilterPermanent filterPermanent = new FilterPermanent(); filterPermanent.add(new NamePredicate(game.getCard(permanent.getImprinted().get(0)).getName())); - value = game.getBattlefield().count(filterPermanent, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + value = game.getBattlefield().count(filterPermanent, sourceAbility.getControllerId(), sourceAbility, game); } return value; } diff --git a/Mage.Sets/src/mage/cards/s/StrongholdGambit.java b/Mage.Sets/src/mage/cards/s/StrongholdGambit.java index e5acf21277a..044d7825961 100644 --- a/Mage.Sets/src/mage/cards/s/StrongholdGambit.java +++ b/Mage.Sets/src/mage/cards/s/StrongholdGambit.java @@ -61,14 +61,14 @@ class StrongholdGambitEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Map choosenCard = new LinkedHashMap<>(); for (UUID playerId : game.getState().getPlayerList(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null && !player.getHand().isEmpty()) { TargetCardInHand target = new TargetCardInHand(); - if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, target, source, game)) { choosenCard.put(playerId, target.getFirstTarget()); } } diff --git a/Mage.Sets/src/mage/cards/s/StumpsquallHydra.java b/Mage.Sets/src/mage/cards/s/StumpsquallHydra.java index e59c1c4e8b1..118ce63f227 100644 --- a/Mage.Sets/src/mage/cards/s/StumpsquallHydra.java +++ b/Mage.Sets/src/mage/cards/s/StumpsquallHydra.java @@ -97,7 +97,7 @@ class StumpsquallHydraEffect extends OneShotEffect { } TargetAmount targetAmount = new TargetCreatureOrPlaneswalkerAmount(xValue, filter); targetAmount.setNotTarget(true); - player.choose(outcome, targetAmount, source.getSourceId(), game); + player.choose(outcome, targetAmount, source, game); for (UUID targetId : targetAmount.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { diff --git a/Mage.Sets/src/mage/cards/s/StuntedGrowth.java b/Mage.Sets/src/mage/cards/s/StuntedGrowth.java index d6250d70e7e..b8f4b61f813 100644 --- a/Mage.Sets/src/mage/cards/s/StuntedGrowth.java +++ b/Mage.Sets/src/mage/cards/s/StuntedGrowth.java @@ -66,7 +66,7 @@ class StuntedGrowthEffect extends OneShotEffect { int possibleNumber = Math.min(3, targetPlayer.getHand().size()); if (possibleNumber > 0) { Target target = new TargetCardInHand(possibleNumber, new FilterCard("cards from your hand")); - targetPlayer.choose(outcome, target, source.getSourceId(), game); + targetPlayer.choose(outcome, target, source, game); Cards cards = new CardsImpl(); for (UUID cardId: target.getTargets()) { Card card = game.getCard(cardId); diff --git a/Mage.Sets/src/mage/cards/s/SubterraneanTremors.java b/Mage.Sets/src/mage/cards/s/SubterraneanTremors.java index 88faa3308e9..fe346fcbb86 100644 --- a/Mage.Sets/src/mage/cards/s/SubterraneanTremors.java +++ b/Mage.Sets/src/mage/cards/s/SubterraneanTremors.java @@ -69,7 +69,7 @@ class SubterraneanTremorsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int damage = source.getManaCostsToPay().getX(); - UUID sourceId = source.getSourceId(); + UUID sourceId = source != null ? source.getSourceId() : null; UUID controllerId = source.getControllerId(); // X damage to each creature without flying diff --git a/Mage.Sets/src/mage/cards/s/SuddenDemise.java b/Mage.Sets/src/mage/cards/s/SuddenDemise.java index 2b0cc7769f5..a83832b93eb 100644 --- a/Mage.Sets/src/mage/cards/s/SuddenDemise.java +++ b/Mage.Sets/src/mage/cards/s/SuddenDemise.java @@ -64,7 +64,7 @@ class SuddenDemiseDamageEffect extends OneShotEffect { final int damage = source.getManaCostsToPay().getX(); FilterPermanent filter = new FilterCreaturePermanent(); filter.add(new ColorPredicate(choice.getColor())); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.damage(damage, source.getSourceId(), source, game, false, true); } return true; diff --git a/Mage.Sets/src/mage/cards/s/SuddenReclamation.java b/Mage.Sets/src/mage/cards/s/SuddenReclamation.java index 1614e991dff..1531121d612 100644 --- a/Mage.Sets/src/mage/cards/s/SuddenReclamation.java +++ b/Mage.Sets/src/mage/cards/s/SuddenReclamation.java @@ -67,7 +67,7 @@ class SuddenReclamationEffect extends OneShotEffect { Cards cardsToHand = new CardsImpl(); Target target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { @@ -76,7 +76,7 @@ class SuddenReclamationEffect extends OneShotEffect { } target = new TargetCardInYourGraveyard(new FilterLandCard("land card from your graveyard")); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game) + if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SufferThePast.java b/Mage.Sets/src/mage/cards/s/SufferThePast.java index 2ff2c16feef..e570a2dfaaa 100644 --- a/Mage.Sets/src/mage/cards/s/SufferThePast.java +++ b/Mage.Sets/src/mage/cards/s/SufferThePast.java @@ -67,7 +67,7 @@ class SufferThePastEffect extends OneShotEffect { int numberToTarget = Math.min(targetPlayer.getGraveyard().size(), source.getManaCostsToPay().getX()); TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(numberToTarget, numberToTarget, filter); if (you != null) { - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game)) { if (!target.getTargets().isEmpty()) { List targets = target.getTargets(); for (UUID targetId : targets) { diff --git a/Mage.Sets/src/mage/cards/s/SummonersEgg.java b/Mage.Sets/src/mage/cards/s/SummonersEgg.java index be40cb1805f..2c665151089 100644 --- a/Mage.Sets/src/mage/cards/s/SummonersEgg.java +++ b/Mage.Sets/src/mage/cards/s/SummonersEgg.java @@ -68,7 +68,7 @@ class SummonersEggImprintEffect extends OneShotEffect { if (controller != null && sourcePermanent != null) { if (!controller.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.choose(Outcome.Benefit, controller.getHand(), target, game)) { Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SunderingTitan.java b/Mage.Sets/src/mage/cards/s/SunderingTitan.java index 398e59c62f1..049f9295bee 100644 --- a/Mage.Sets/src/mage/cards/s/SunderingTitan.java +++ b/Mage.Sets/src/mage/cards/s/SunderingTitan.java @@ -72,7 +72,7 @@ class SunderingTitanDestroyLandEffect extends OneShotEffect { FilterLandPermanent filter = new FilterLandPermanent(landName + " to destroy"); filter.add(landName.getPredicate()); Target target = new TargetLandPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { controller.chooseTarget(outcome, target, source, game); lands.add(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/s/SunkenHope.java b/Mage.Sets/src/mage/cards/s/SunkenHope.java index 52d5b2b6224..4f910df13ee 100644 --- a/Mage.Sets/src/mage/cards/s/SunkenHope.java +++ b/Mage.Sets/src/mage/cards/s/SunkenHope.java @@ -66,9 +66,9 @@ class SunkenHopeReturnToHandEffect extends OneShotEffect { } Target target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { while (player.canRespond() && !target.isChosen() - && target.canChoose(source.getSourceId(), player.getId(), game)) { + && target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); } diff --git a/Mage.Sets/src/mage/cards/s/SurgeOfZeal.java b/Mage.Sets/src/mage/cards/s/SurgeOfZeal.java index fd0dd855f73..0af9198901f 100644 --- a/Mage.Sets/src/mage/cards/s/SurgeOfZeal.java +++ b/Mage.Sets/src/mage/cards/s/SurgeOfZeal.java @@ -69,7 +69,7 @@ class SurgeOfZealEffect extends OneShotEffect { Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); if (target != null) { ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (permanent.getColor(game).shares(color)) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/s/SurpriseDeployment.java b/Mage.Sets/src/mage/cards/s/SurpriseDeployment.java index 28c0cf00f46..b1e8ef05572 100644 --- a/Mage.Sets/src/mage/cards/s/SurpriseDeployment.java +++ b/Mage.Sets/src/mage/cards/s/SurpriseDeployment.java @@ -81,7 +81,7 @@ class SurpriseDeploymentEffect extends OneShotEffect { if (controller != null) { if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { TargetCardInHand target = new TargetCardInHand(filter); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { diff --git a/Mage.Sets/src/mage/cards/s/SurtlandFlinger.java b/Mage.Sets/src/mage/cards/s/SurtlandFlinger.java index 644ffecf644..285d0f5e803 100644 --- a/Mage.Sets/src/mage/cards/s/SurtlandFlinger.java +++ b/Mage.Sets/src/mage/cards/s/SurtlandFlinger.java @@ -76,7 +76,7 @@ class SurtlandFlingerEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent( 0, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/s/SurvivorOfTheUnseen.java b/Mage.Sets/src/mage/cards/s/SurvivorOfTheUnseen.java index d773ec1842d..f7e7ca917e1 100644 --- a/Mage.Sets/src/mage/cards/s/SurvivorOfTheUnseen.java +++ b/Mage.Sets/src/mage/cards/s/SurvivorOfTheUnseen.java @@ -80,7 +80,7 @@ class SurvivorOfTheUnseenEffect extends OneShotEffect { private boolean putOnLibrary(Player player, Ability source, Game game) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/s/SwarmShambler.java b/Mage.Sets/src/mage/cards/s/SwarmShambler.java index e82020013b1..d54acb9165d 100644 --- a/Mage.Sets/src/mage/cards/s/SwarmShambler.java +++ b/Mage.Sets/src/mage/cards/s/SwarmShambler.java @@ -90,8 +90,8 @@ class SwarmShamblerTriggeredAbility extends TriggeredAbilityImpl { Permanent permanent = game.getPermanent(event.getTargetId()); return sourceObject != null && permanent != null - && StaticFilters.FILTER_CONTROLLED_CREATURE_P1P1.match(permanent, getSourceId(), getControllerId(), game) - && StaticFilters.FILTER_SPELL_OR_ABILITY_OPPONENTS.match(sourceObject, getSourceId(), getControllerId(), game); + && StaticFilters.FILTER_CONTROLLED_CREATURE_P1P1.match(permanent, getControllerId(), this, game) + && StaticFilters.FILTER_SPELL_OR_ABILITY_OPPONENTS.match(sourceObject, getControllerId(), this, game); } @Override diff --git a/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java b/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java index cc908553689..e1bc3e05df1 100644 --- a/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java +++ b/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java @@ -69,7 +69,7 @@ class SwayOfTheStarsEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent(); filter.add(new OwnerIdPredicate(playerId)); Cards toLib = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source, game)) { toLib.add(permanent); } player.shuffleCardsToLibrary(toLib, game, source); diff --git a/Mage.Sets/src/mage/cards/s/SwiftWarkite.java b/Mage.Sets/src/mage/cards/s/SwiftWarkite.java index cf410941e49..a57c3f60887 100644 --- a/Mage.Sets/src/mage/cards/s/SwiftWarkite.java +++ b/Mage.Sets/src/mage/cards/s/SwiftWarkite.java @@ -92,7 +92,7 @@ class SwiftWarkiteEffect extends OneShotEffect { if (controller != null) { if (controller.chooseUse(Outcome.PutCardInPlay, "Put a creature card from your hand? (No = from your graveyard)", source, game)) { Target target = new TargetCardInHand(0, 1, filter); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { @@ -110,7 +110,7 @@ class SwiftWarkiteEffect extends OneShotEffect { } } else { Target target = new TargetCardInYourGraveyard(0, 1, filter); - target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), source, game); Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/s/SwordOfTruthAndJustice.java b/Mage.Sets/src/mage/cards/s/SwordOfTruthAndJustice.java index a04523a5cf5..9ee2b178d1a 100644 --- a/Mage.Sets/src/mage/cards/s/SwordOfTruthAndJustice.java +++ b/Mage.Sets/src/mage/cards/s/SwordOfTruthAndJustice.java @@ -86,7 +86,7 @@ class SwordOfTruthAndJusticeEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game); diff --git a/Mage.Sets/src/mage/cards/s/SwordPointDiplomacy.java b/Mage.Sets/src/mage/cards/s/SwordPointDiplomacy.java index 2118d5885aa..7fc28f57770 100644 --- a/Mage.Sets/src/mage/cards/s/SwordPointDiplomacy.java +++ b/Mage.Sets/src/mage/cards/s/SwordPointDiplomacy.java @@ -61,7 +61,7 @@ class SwordPointDiplomacyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/SwornDefender.java b/Mage.Sets/src/mage/cards/s/SwornDefender.java index ae30d0a4afe..c54524244c9 100644 --- a/Mage.Sets/src/mage/cards/s/SwornDefender.java +++ b/Mage.Sets/src/mage/cards/s/SwornDefender.java @@ -9,14 +9,13 @@ import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.common.TargetCreaturePermanent; +import mage.target.TargetPermanent; import mage.util.CardUtil; import java.util.UUID; @@ -26,6 +25,13 @@ import java.util.UUID; */ public final class SwornDefender extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature blocking or blocked by {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.EITHER); + } + public SwornDefender(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); this.subtype.add(SubType.HUMAN); @@ -33,14 +39,10 @@ public final class SwornDefender extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(3); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by SwornDefender"); - filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), - new BlockingAttackerIdPredicate(this.getId()))); // {1}: Sworn Defender’s power becomes the toughness of target creature blocking or being blocked by Sworn Defender minus 1 until end of turn, and Sworn Defender’s toughness becomes 1 plus the power of that creature until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SwornDefenderEffect(), new GenericManaCost(1)); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new SwornDefenderEffect(), new GenericManaCost(1)); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); - } private SwornDefender(final SwornDefender card) { diff --git a/Mage.Sets/src/mage/cards/s/SylvanHierophant.java b/Mage.Sets/src/mage/cards/s/SylvanHierophant.java index d385bc69c2b..93740e1102d 100644 --- a/Mage.Sets/src/mage/cards/s/SylvanHierophant.java +++ b/Mage.Sets/src/mage/cards/s/SylvanHierophant.java @@ -11,7 +11,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterCreatureCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; import java.util.UUID; @@ -27,7 +27,7 @@ public final class SylvanHierophant extends CardImpl { private static final FilterCreatureCard filter = new FilterCreatureCard("another target creature card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public SylvanHierophant(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/s/SylvanLibrary.java b/Mage.Sets/src/mage/cards/s/SylvanLibrary.java index 345b3b00191..2dec3dfdc65 100644 --- a/Mage.Sets/src/mage/cards/s/SylvanLibrary.java +++ b/Mage.Sets/src/mage/cards/s/SylvanLibrary.java @@ -89,7 +89,7 @@ class SylvanLibraryEffect extends OneShotEffect { FilterCard filter = new FilterCard(numberOfTargets + " cards of cards drawn this turn"); filter.add(new CardIdPredicate(cards)); TargetCardInHand target = new TargetCardInHand(numberOfTargets, filter); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Cards cardsPutBack = new CardsImpl(); for (UUID cardId : target.getTargets()) { diff --git a/Mage.Sets/src/mage/cards/s/SylvanOffering.java b/Mage.Sets/src/mage/cards/s/SylvanOffering.java index c5789a19848..f6a615026e0 100644 --- a/Mage.Sets/src/mage/cards/s/SylvanOffering.java +++ b/Mage.Sets/src/mage/cards/s/SylvanOffering.java @@ -63,7 +63,7 @@ class SylvanOfferingEffect1 extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetOpponent(true); - target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { int xValue = source.getManaCostsToPay().getX(); @@ -100,7 +100,7 @@ class SylvanOfferingEffect2 extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetOpponent(true); - target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), game); + target.choose(Outcome.Sacrifice, source.getControllerId(), source.getSourceId(), source, game); Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent != null) { int xValue = source.getManaCostsToPay().getX(); diff --git a/Mage.Sets/src/mage/cards/s/SynodSanctum.java b/Mage.Sets/src/mage/cards/s/SynodSanctum.java index 9838e9d6ec5..77eb9f2cfe4 100644 --- a/Mage.Sets/src/mage/cards/s/SynodSanctum.java +++ b/Mage.Sets/src/mage/cards/s/SynodSanctum.java @@ -78,7 +78,7 @@ class SynodSanctumEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (getTargetPointer().getFirst(game, source) != null) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/s/SyphonFlesh.java b/Mage.Sets/src/mage/cards/s/SyphonFlesh.java index 944e0d49ee3..88c09c5a6fc 100644 --- a/Mage.Sets/src/mage/cards/s/SyphonFlesh.java +++ b/Mage.Sets/src/mage/cards/s/SyphonFlesh.java @@ -65,7 +65,7 @@ class SyphonFleshEffect extends OneShotEffect { if (player != null && !playerId.equals(source.getControllerId())) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/s/SyphonMind.java b/Mage.Sets/src/mage/cards/s/SyphonMind.java index 4cff653a10d..7feddc0b5eb 100644 --- a/Mage.Sets/src/mage/cards/s/SyphonMind.java +++ b/Mage.Sets/src/mage/cards/s/SyphonMind.java @@ -63,7 +63,7 @@ class SyphonMindEffect extends OneShotEffect { Player otherPlayer = game.getPlayer(playerId); if (otherPlayer != null && !otherPlayer.getHand().isEmpty()) { TargetCardInHand target = new TargetCardInHand(); - if (otherPlayer.choose(Outcome.Discard, target, source.getSourceId(), game)) { + if (otherPlayer.choose(Outcome.Discard, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (otherPlayer.discard(card, false, source, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TahngarthFirstMate.java b/Mage.Sets/src/mage/cards/t/TahngarthFirstMate.java index a8c700033e5..ab89f75eb84 100644 --- a/Mage.Sets/src/mage/cards/t/TahngarthFirstMate.java +++ b/Mage.Sets/src/mage/cards/t/TahngarthFirstMate.java @@ -127,7 +127,7 @@ class TahngarthFirstMateEffect extends OneShotEffect { } TargetPlayerOrPlaneswalker target = new TargetPlayerOrPlaneswalker(filter); target.setNotTarget(true); - if (!controller.choose(outcome, target, source.getSourceId(), game)) { + if (!controller.choose(outcome, target, source, game)) { return false; } ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfCombat, player.getId()); diff --git a/Mage.Sets/src/mage/cards/t/Tangle.java b/Mage.Sets/src/mage/cards/t/Tangle.java index cc3f4d24b86..fa7b1d27a59 100644 --- a/Mage.Sets/src/mage/cards/t/Tangle.java +++ b/Mage.Sets/src/mage/cards/t/Tangle.java @@ -74,7 +74,7 @@ class TangleEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { List doNotUntapNextUntapStep = new ArrayList<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { doNotUntapNextUntapStep.add(permanent); } if (!doNotUntapNextUntapStep.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/t/Tariff.java b/Mage.Sets/src/mage/cards/t/Tariff.java index 205dab61c6a..4b1c7148fe7 100644 --- a/Mage.Sets/src/mage/cards/t/Tariff.java +++ b/Mage.Sets/src/mage/cards/t/Tariff.java @@ -77,7 +77,7 @@ class TariffEffect extends OneShotEffect { } private void processPlayer(Game game, Ability source, Player player) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); List creatures = getPermanentsWithTheHighestCMC(game, player.getId(), new FilterControlledCreaturePermanent()); diff --git a/Mage.Sets/src/mage/cards/t/TaskMageAssembly.java b/Mage.Sets/src/mage/cards/t/TaskMageAssembly.java index 9b511cb7c94..416b91bc353 100644 --- a/Mage.Sets/src/mage/cards/t/TaskMageAssembly.java +++ b/Mage.Sets/src/mage/cards/t/TaskMageAssembly.java @@ -65,7 +65,7 @@ class TaskMageAssemblyStateTriggeredAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { - return game.getBattlefield().count(new FilterCreaturePermanent(), this.getSourceId(), this.getControllerId(), game) == 0; + return game.getBattlefield().count(new FilterCreaturePermanent(), this.getControllerId(), this, game) == 0; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TayamLuminousEnigma.java b/Mage.Sets/src/mage/cards/t/TayamLuminousEnigma.java index fde6ef9fbed..b959e615da7 100644 --- a/Mage.Sets/src/mage/cards/t/TayamLuminousEnigma.java +++ b/Mage.Sets/src/mage/cards/t/TayamLuminousEnigma.java @@ -94,7 +94,7 @@ class TayamLuminousEnigmaCost extends RemoveCounterCost { int countersRemoved = 0; Player controller = game.getPlayer(controllerId); for (int i = 0; i < countersToRemove; i++) { - if (target.choose(Outcome.UnboostCreature, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.UnboostCreature, controllerId, source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { if (!permanent.getCounters(game).isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/t/TazeemRaptor.java b/Mage.Sets/src/mage/cards/t/TazeemRaptor.java index 0a150869ea6..329880d36c7 100644 --- a/Mage.Sets/src/mage/cards/t/TazeemRaptor.java +++ b/Mage.Sets/src/mage/cards/t/TazeemRaptor.java @@ -73,7 +73,7 @@ class TazeemRaptorEffect extends OneShotEffect { TargetPermanent target = new TargetControlledPermanent( 0, 1, StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/t/TectonicHellion.java b/Mage.Sets/src/mage/cards/t/TectonicHellion.java index d6757793bb5..22caf023a7a 100644 --- a/Mage.Sets/src/mage/cards/t/TectonicHellion.java +++ b/Mage.Sets/src/mage/cards/t/TectonicHellion.java @@ -71,7 +71,7 @@ class TectonicHellionEffect extends OneShotEffect { game.getState() .getPlayersInRange(source.getControllerId(), game) .forEach(uuid -> landMap.put(uuid, game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, uuid, source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, uuid, source, game ).size())); int max = landMap .values() diff --git a/Mage.Sets/src/mage/cards/t/TeferiMageOfZhalfir.java b/Mage.Sets/src/mage/cards/t/TeferiMageOfZhalfir.java index f3e94a8b3eb..4fa8f4920da 100644 --- a/Mage.Sets/src/mage/cards/t/TeferiMageOfZhalfir.java +++ b/Mage.Sets/src/mage/cards/t/TeferiMageOfZhalfir.java @@ -123,7 +123,7 @@ class TeferiMageOfZhalfirReplacementEffect extends ContinuousRuleModifyingEffect @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can cast spells only any time you could cast a sorcery (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/t/TeferiTimeRaveler.java b/Mage.Sets/src/mage/cards/t/TeferiTimeRaveler.java index 93559f22dfd..edd1a58596a 100644 --- a/Mage.Sets/src/mage/cards/t/TeferiTimeRaveler.java +++ b/Mage.Sets/src/mage/cards/t/TeferiTimeRaveler.java @@ -83,7 +83,7 @@ class TeferiTimeRavelerReplacementEffect extends ContinuousRuleModifyingEffectIm @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can cast spells only any time you could cast a sorcery (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/t/Teleportal.java b/Mage.Sets/src/mage/cards/t/Teleportal.java index 1392bd60a63..8e30b1ea4d7 100644 --- a/Mage.Sets/src/mage/cards/t/Teleportal.java +++ b/Mage.Sets/src/mage/cards/t/Teleportal.java @@ -73,7 +73,7 @@ class TeleportalEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { CantBeBlockedTargetEffect effect = new CantBeBlockedTargetEffect(); effect.setTargetPointer(new FixedTarget(creature.getId(), game)); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/t/TemporaryInsanity.java b/Mage.Sets/src/mage/cards/t/TemporaryInsanity.java index 92f690cc284..054a282f4cb 100644 --- a/Mage.Sets/src/mage/cards/t/TemporaryInsanity.java +++ b/Mage.Sets/src/mage/cards/t/TemporaryInsanity.java @@ -76,10 +76,10 @@ class TargetCreatureWithPowerLessThanNumberOfCardsInYourGraveyard extends Target } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - MageObject targetSource = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + MageObject targetSource = game.getObject(source); if(targetSource != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) { return true; diff --git a/Mage.Sets/src/mage/cards/t/TemptWithImmortality.java b/Mage.Sets/src/mage/cards/t/TemptWithImmortality.java index fb7dfcc85ec..2610ddad3f4 100644 --- a/Mage.Sets/src/mage/cards/t/TemptWithImmortality.java +++ b/Mage.Sets/src/mage/cards/t/TemptWithImmortality.java @@ -73,7 +73,7 @@ class TemptWithImmortalityEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(opponent.getId())); Target targetCardOpponent = new TargetCardInGraveyard(filter); - if (targetCardOpponent.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (targetCardOpponent.canChoose(opponent.getId(), source, game)) { if (opponent.chooseUse(outcome, "Return a creature card from your graveyard to the battlefield?", source, game)) { if (opponent.chooseTarget(outcome, targetCardOpponent, source, game)) { Card card = game.getCard(targetCardOpponent.getFirstTarget()); @@ -100,7 +100,7 @@ class TemptWithImmortalityEffect extends OneShotEffect { private boolean returnCreatureFromGraveToBattlefield(Player player, Ability source, Game game) { Target target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE); target.setNotTarget(false); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { if (player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/t/TemptingWurm.java b/Mage.Sets/src/mage/cards/t/TemptingWurm.java index a82d7ce2bde..46e01a107ce 100644 --- a/Mage.Sets/src/mage/cards/t/TemptingWurm.java +++ b/Mage.Sets/src/mage/cards/t/TemptingWurm.java @@ -80,7 +80,7 @@ class TemptingWurmEffect extends OneShotEffect { if (opponent != null){ Target target = new TargetCardInHand(0, Integer.MAX_VALUE, filter); - if(target.canChoose(source.getSourceId(), opponent.getId(), game)) { + if(target.canChoose(opponent.getId(), source, game)) { if (opponent.chooseUse(Outcome.PutCardInPlay , "Put any artifact, creature, enchantment, and/or land cards cards from your hand onto the battlefield?", source, game)) { if (target.chooseTarget(Outcome.PutCardInPlay, opponent.getId(), source, game)) { for (UUID cardId: target.getTargets()){ diff --git a/Mage.Sets/src/mage/cards/t/TemurSabertooth.java b/Mage.Sets/src/mage/cards/t/TemurSabertooth.java index 2f8058a3b60..d92e8faa54c 100644 --- a/Mage.Sets/src/mage/cards/t/TemurSabertooth.java +++ b/Mage.Sets/src/mage/cards/t/TemurSabertooth.java @@ -78,7 +78,7 @@ class TemurSabertoothEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { if (controller.chooseUse(outcome, "Return another creature to hand?", source, game) && controller.chooseTarget(outcome, target, source, game)) { Permanent toHand = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/t/Tephraderm.java b/Mage.Sets/src/mage/cards/t/Tephraderm.java index f9b06856ca3..5c642c96b0a 100644 --- a/Mage.Sets/src/mage/cards/t/Tephraderm.java +++ b/Mage.Sets/src/mage/cards/t/Tephraderm.java @@ -74,7 +74,7 @@ class TephradermCreatureDamageTriggeredAbility extends TriggeredAbilityImpl { Permanent sourcePermanent = game.getPermanent(event.getSourceId()); if (sourcePermanent != null - && FILTER_CREATURE.match(sourcePermanent, getSourceId(), getControllerId(), game)) { + && FILTER_CREATURE.match(sourcePermanent, getControllerId(), this, game)) { for (Effect effect : getEffects()) { if (effect instanceof DamageTargetEffect) { effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game)); @@ -120,7 +120,7 @@ class TephradermSpellDamageTriggeredAbility extends TriggeredAbilityImpl { } StackObject sourceSpell = game.getStack().getStackObject(event.getSourceId()); - if (sourceSpell != null && StaticFilters.FILTER_SPELL.match(sourceSpell, getSourceId(), getControllerId(), game)) { + if (sourceSpell != null && StaticFilters.FILTER_SPELL.match(sourceSpell, getControllerId(), this, game)) { for (Effect effect : getEffects()) { if (effect instanceof DamageTargetEffect) { effect.setTargetPointer(new FixedTarget(sourceSpell.getControllerId())); diff --git a/Mage.Sets/src/mage/cards/t/TergridGodOfFright.java b/Mage.Sets/src/mage/cards/t/TergridGodOfFright.java index c6f5de8ffc7..ce57cc7b75a 100644 --- a/Mage.Sets/src/mage/cards/t/TergridGodOfFright.java +++ b/Mage.Sets/src/mage/cards/t/TergridGodOfFright.java @@ -198,7 +198,7 @@ class TergridsLaternEffect extends OneShotEffect { Outcome aiOutcome = (targetedPlayer.getLife() <= 3 * 2) ? Outcome.Benefit : Outcome.Detriment; Set choiceSet = new HashSet<>(); - if (game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND, source.getSourceId(), targetedPlayer.getId(), game) > 0) { + if (game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND, targetedPlayer.getId(), source, game) > 0) { choiceSet.add(SACRIFICE_CHOICE); } if (targetedPlayer.getHand().size() > 0) { @@ -222,7 +222,7 @@ class TergridsLaternEffect extends OneShotEffect { case SACRIFICE_CHOICE: TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND); target.setNotTarget(true); - targetedPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + targetedPlayer.choose(Outcome.Sacrifice, target, source, game); Permanent chosenLand = game.getPermanent(target.getFirstTarget()); return chosenLand != null && chosenLand.sacrifice(source, game); case DISCARD_CHOICE: diff --git a/Mage.Sets/src/mage/cards/t/Terminus.java b/Mage.Sets/src/mage/cards/t/Terminus.java index 1bd33f97f03..87a06e7b08b 100644 --- a/Mage.Sets/src/mage/cards/t/Terminus.java +++ b/Mage.Sets/src/mage/cards/t/Terminus.java @@ -67,7 +67,7 @@ class TerminusEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(player.getId())); Cards toLib = new CardsImpl(); for (Permanent permanent : game.getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + .getActivePermanents(filter, source.getControllerId(), source, game)) { toLib.add(permanent); } player.putCardsOnBottomOfLibrary(toLib, game, source, true); diff --git a/Mage.Sets/src/mage/cards/t/Terraformer.java b/Mage.Sets/src/mage/cards/t/Terraformer.java index 40b751b1c9a..2857b042d39 100644 --- a/Mage.Sets/src/mage/cards/t/Terraformer.java +++ b/Mage.Sets/src/mage/cards/t/Terraformer.java @@ -119,7 +119,7 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl { game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .map(permanent -> new MageObjectReference(permanent, game)) .forEach(affectedObjectList::add); diff --git a/Mage.Sets/src/mage/cards/t/TeveshSzatDoomOfFools.java b/Mage.Sets/src/mage/cards/t/TeveshSzatDoomOfFools.java index 6069af8cf4a..08c6f7675c3 100644 --- a/Mage.Sets/src/mage/cards/t/TeveshSzatDoomOfFools.java +++ b/Mage.Sets/src/mage/cards/t/TeveshSzatDoomOfFools.java @@ -101,10 +101,10 @@ class TeveshSzatDoomOfFoolsSacrificeEffect extends OneShotEffect { } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } - target.choose(outcome, source.getControllerId(), source.getSourceId(), game); + target.choose(outcome, source.getControllerId(), source.getSourceId(), source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; @@ -158,7 +158,7 @@ class TeveshSzatDoomOfFoolsCommanderEffect extends OneShotEffect { // gain control of all commanders for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { game.addEffect(new GainControlTargetEffect( Duration.Custom, true diff --git a/Mage.Sets/src/mage/cards/t/TezzeretCruelMachinist.java b/Mage.Sets/src/mage/cards/t/TezzeretCruelMachinist.java index 2bd0f763736..e8a4d8b6531 100644 --- a/Mage.Sets/src/mage/cards/t/TezzeretCruelMachinist.java +++ b/Mage.Sets/src/mage/cards/t/TezzeretCruelMachinist.java @@ -87,7 +87,7 @@ class TezzeretCruelMachinistEffect extends OneShotEffect { return false; } Target target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Cards cardsToMove = new CardsImpl(target.getTargets()); if (cardsToMove.isEmpty()) { return false; diff --git a/Mage.Sets/src/mage/cards/t/TheAntiquitiesWar.java b/Mage.Sets/src/mage/cards/t/TheAntiquitiesWar.java index 77f6b4b972f..39291aab6c4 100644 --- a/Mage.Sets/src/mage/cards/t/TheAntiquitiesWar.java +++ b/Mage.Sets/src/mage/cards/t/TheAntiquitiesWar.java @@ -77,7 +77,7 @@ class TheAntiquitiesWarEffect extends ContinuousEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - for (Permanent perm : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, source.getControllerId(), source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } diff --git a/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java b/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java index 672fb6e33c5..83da310e877 100644 --- a/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java +++ b/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java @@ -77,7 +77,7 @@ class TheBattleOfEndorEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source, game)) { permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source.getControllerId(), source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/t/TheBearsOfLittjara.java b/Mage.Sets/src/mage/cards/t/TheBearsOfLittjara.java index 497dd590202..abe2a130862 100644 --- a/Mage.Sets/src/mage/cards/t/TheBearsOfLittjara.java +++ b/Mage.Sets/src/mage/cards/t/TheBearsOfLittjara.java @@ -93,7 +93,7 @@ class TheBearsOfLittjaraEffect extends OneShotEffect { } for (Permanent creature : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { if (creature == null) { continue; diff --git a/Mage.Sets/src/mage/cards/t/TheBloodskyMassacre.java b/Mage.Sets/src/mage/cards/t/TheBloodskyMassacre.java index 78c4dc81945..0799e525516 100644 --- a/Mage.Sets/src/mage/cards/t/TheBloodskyMassacre.java +++ b/Mage.Sets/src/mage/cards/t/TheBloodskyMassacre.java @@ -115,7 +115,7 @@ class TheBloodskyMassacreEffect extends OneShotEffect { if (player == null) { return false; } - int berserkers = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int berserkers = game.getBattlefield().count(filter, source.getControllerId(), source, game); player.getManaPool().addMana(new Mana(ManaType.RED, berserkers), game, source, true); return true; } diff --git a/Mage.Sets/src/mage/cards/t/TheBookOfVileDarkness.java b/Mage.Sets/src/mage/cards/t/TheBookOfVileDarkness.java index dc39217f411..63d4c062d37 100644 --- a/Mage.Sets/src/mage/cards/t/TheBookOfVileDarkness.java +++ b/Mage.Sets/src/mage/cards/t/TheBookOfVileDarkness.java @@ -11,7 +11,6 @@ import mage.abilities.costs.CostImpl; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.cards.CardsImpl; @@ -128,25 +127,25 @@ class TheBookOfVileDarknessCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { return source.getSourcePermanentIfItStillExists(game) != null - && game.getBattlefield().count(filter1, source.getSourceId(), source.getControllerId(), game) > 0 - && game.getBattlefield().count(filter2, source.getSourceId(), source.getControllerId(), game) > 0; + && game.getBattlefield().count(filter1, source.getControllerId(), source, game) > 0 + && game.getBattlefield().count(filter2, source.getControllerId(), source, game) > 0; } private static Permanent getPermanent(FilterPermanent filter, Player controller, Ability source, Game game) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); switch (count) { case 0: return null; case 1: return game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ).stream().findFirst().orElse(null); default: break; } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - controller.choose(Outcome.Sacrifice, target, source.getControllerId(), game); + controller.choose(Outcome.Sacrifice, target, source, game); return game.getPermanent(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/t/TheDeckOfManyThings.java b/Mage.Sets/src/mage/cards/t/TheDeckOfManyThings.java index 9d65ea25439..016d2a4244b 100644 --- a/Mage.Sets/src/mage/cards/t/TheDeckOfManyThings.java +++ b/Mage.Sets/src/mage/cards/t/TheDeckOfManyThings.java @@ -146,10 +146,10 @@ class TheDeckOfManyThingsReturnEffect extends OneShotEffect { } TargetCardInGraveyard target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } - player.choose(outcome, target, source.getControllerId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/t/TheElderspell.java b/Mage.Sets/src/mage/cards/t/TheElderspell.java index 8ea348358ca..0c3b4ebd570 100644 --- a/Mage.Sets/src/mage/cards/t/TheElderspell.java +++ b/Mage.Sets/src/mage/cards/t/TheElderspell.java @@ -75,7 +75,7 @@ class TheElderspellEffect extends OneShotEffect { } } TargetPermanent targetPermanent = new TargetPermanent(filter); - if (!player.choose(outcome, targetPermanent, source.getSourceId(), game)) { + if (!player.choose(outcome, targetPermanent, source, game)) { return false; } Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/t/TheFallenApart.java b/Mage.Sets/src/mage/cards/t/TheFallenApart.java index 3b311ead15f..b92acb08f8d 100644 --- a/Mage.Sets/src/mage/cards/t/TheFallenApart.java +++ b/Mage.Sets/src/mage/cards/t/TheFallenApart.java @@ -65,7 +65,7 @@ class TheFallenApartEntersEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (mageObject != null) { game.getState().setValue(mageObject.getId() + "_arms", 2); @@ -98,7 +98,7 @@ class TheFallenApartToggleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && mageObject != null) { if (game.getState().getValue(mageObject.getId() + "_arms") == null || game.getState().getValue(mageObject.getId() + "_legs") == null) { @@ -158,7 +158,7 @@ class TheFallenApartRestrictionEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return (Integer) game.getState().getValue(mageObject.getId() + "_arms") > 0; } @@ -167,7 +167,7 @@ class TheFallenApartRestrictionEffect extends RestrictionEffect { @Override public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return (Integer) game.getState().getValue(mageObject.getId() + "_legs") > 0; } diff --git a/Mage.Sets/src/mage/cards/t/TheFirstEruption.java b/Mage.Sets/src/mage/cards/t/TheFirstEruption.java index 2af887c778a..c953045ccc1 100644 --- a/Mage.Sets/src/mage/cards/t/TheFirstEruption.java +++ b/Mage.Sets/src/mage/cards/t/TheFirstEruption.java @@ -99,8 +99,8 @@ class TheFirstEruptionEffect extends OneShotEffect { Target target = new TargetControlledPermanent(1, 1, filter, false); boolean sacrificed = false; - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - while (controller.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { + while (controller.canRespond() && !target.isChosen() && target.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Sacrifice, target, source, game); } diff --git a/Mage.Sets/src/mage/cards/t/TheImmortalSun.java b/Mage.Sets/src/mage/cards/t/TheImmortalSun.java index cae359e0274..94efb82e2d8 100644 --- a/Mage.Sets/src/mage/cards/t/TheImmortalSun.java +++ b/Mage.Sets/src/mage/cards/t/TheImmortalSun.java @@ -77,7 +77,7 @@ class TheImmortalSunCantActivateEffect extends ContinuousRuleModifyingEffectImpl @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't activate loyalty abilities of planeswalkers (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/t/TheMendingOfDominaria.java b/Mage.Sets/src/mage/cards/t/TheMendingOfDominaria.java index 549b19c38d2..b6f1ae85b93 100644 --- a/Mage.Sets/src/mage/cards/t/TheMendingOfDominaria.java +++ b/Mage.Sets/src/mage/cards/t/TheMendingOfDominaria.java @@ -77,9 +77,9 @@ class TheMendingOfDominariaFirstEffect extends OneShotEffect { new MillCardsControllerEffect(2).apply(game, source); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseUse(outcome, "Return a creature card from your graveyard to hand?", source, game) - && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + && controller.choose(Outcome.ReturnToHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); @@ -110,7 +110,7 @@ class TheMendingOfDominariaSecondEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { controller.moveCards( - controller.getGraveyard().getCards(new FilterLandCard(), source.getSourceId(), source.getControllerId(), game), + controller.getGraveyard().getCards(new FilterLandCard(), source.getControllerId(), source, game), Zone.BATTLEFIELD, source, game, false, false, false, null ); for (Card card : controller.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java b/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java index ee3aa612e4e..9a296ee7bc2 100644 --- a/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java +++ b/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java @@ -71,14 +71,14 @@ class TheMimeoplasmEffect extends OneShotEffect { if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) { TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of")); targetCopy.setNotTarget(true); - if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) { + if (controller.choose(Outcome.Copy, targetCopy, source, game)) { Card cardToCopy = game.getCard(targetCopy.getFirstTarget()); if (cardToCopy != null) { FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters"); filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId()))); TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter); targetCounters.setNotTarget(true); - if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) { + if (controller.choose(Outcome.Copy, targetCounters, source, game)) { Card cardForCounters = game.getCard(targetCounters.getFirstTarget()); if (cardForCounters != null) { Cards cardsToExile = new CardsImpl(); diff --git a/Mage.Sets/src/mage/cards/t/TheTricksterGodsHeist.java b/Mage.Sets/src/mage/cards/t/TheTricksterGodsHeist.java index 39a247322de..42f97c66e4a 100644 --- a/Mage.Sets/src/mage/cards/t/TheTricksterGodsHeist.java +++ b/Mage.Sets/src/mage/cards/t/TheTricksterGodsHeist.java @@ -108,13 +108,13 @@ class TheTricksterGodsHeistTarget extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { Set cardTypes = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if (targetSource == null) { return false; } - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { continue; } diff --git a/Mage.Sets/src/mage/cards/t/TheftOfDreams.java b/Mage.Sets/src/mage/cards/t/TheftOfDreams.java index 144436f83f7..b468d54acaa 100644 --- a/Mage.Sets/src/mage/cards/t/TheftOfDreams.java +++ b/Mage.Sets/src/mage/cards/t/TheftOfDreams.java @@ -63,7 +63,7 @@ class TheftOfDreamsEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(TappedPredicate.TAPPED); filter.add(new ControllerIdPredicate(opponent.getId())); - return new DrawCardSourceControllerEffect(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game)).apply(game, source); + return new DrawCardSourceControllerEffect(game.getBattlefield().count(filter, source.getControllerId(), source, game)).apply(game, source); } return false; } diff --git a/Mage.Sets/src/mage/cards/t/ThelonOfHavenwood.java b/Mage.Sets/src/mage/cards/t/ThelonOfHavenwood.java index b87598f205f..90d91fd7dd2 100644 --- a/Mage.Sets/src/mage/cards/t/ThelonOfHavenwood.java +++ b/Mage.Sets/src/mage/cards/t/ThelonOfHavenwood.java @@ -84,7 +84,7 @@ class ThelonOfHavenwoodBoostEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { int numCounters = creature.getCounters(game).getCount(CounterType.SPORE); if (numCounters > 0) { creature.addPower(numCounters); diff --git a/Mage.Sets/src/mage/cards/t/ThelonsChant.java b/Mage.Sets/src/mage/cards/t/ThelonsChant.java index 06f25e38872..ea959e18381 100644 --- a/Mage.Sets/src/mage/cards/t/ThelonsChant.java +++ b/Mage.Sets/src/mage/cards/t/ThelonsChant.java @@ -75,7 +75,7 @@ class ThelonsChantEffect extends OneShotEffect { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); if (player.chooseUse(Outcome.Detriment, "Put a -1/-1 counter on a creature you control? (otherwise " + sourcePermanent.getLogName() + " deals 3 damage to you)", source, game) - && player.choose(Outcome.UnboostCreature, target, source.getSourceId(), game)) { + && player.choose(Outcome.UnboostCreature, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.M1M1.createInstance(), player.getId(), source, game); diff --git a/Mage.Sets/src/mage/cards/t/ThelonsCurse.java b/Mage.Sets/src/mage/cards/t/ThelonsCurse.java index 3a1549cf6e5..a364d640928 100644 --- a/Mage.Sets/src/mage/cards/t/ThelonsCurse.java +++ b/Mage.Sets/src/mage/cards/t/ThelonsCurse.java @@ -91,7 +91,7 @@ class ThelonsCurseEffect extends OneShotEffect { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.AIDontUseIt, "Pay {U} and untap a tapped blue creature under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (player.choose(Outcome.Detriment, tappedCreatureTarget, source.getSourceId(), game)) { + if (player.choose(Outcome.Detriment, tappedCreatureTarget, source, game)) { Cost cost = new ManaCostsImpl<>("{U}"); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/t/ThievesAuction.java b/Mage.Sets/src/mage/cards/t/ThievesAuction.java index 66dda41a897..32ef5468468 100644 --- a/Mage.Sets/src/mage/cards/t/ThievesAuction.java +++ b/Mage.Sets/src/mage/cards/t/ThievesAuction.java @@ -72,7 +72,7 @@ class ThievesAuctionEffect extends OneShotEffect { // Exile all nontoken permanents. Cards exiledCards = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { exiledCards.add(permanent); controller.moveCardsToExile(permanent, source, game, true, CardUtil.getCardExileZoneId(game, source.getSourceId()), "Thieves' Auction"); } diff --git a/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java b/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java index 521204f7f73..607869c008f 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtHemorrhage.java @@ -73,7 +73,7 @@ class ThoughtHemorrhageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String cardName = (String) game.getState().getValue( source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (sourceObject != null diff --git a/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java b/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java index c4ca1b7a9c0..700fda38510 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java @@ -79,7 +79,7 @@ class ThoughtsOfRuinEffect extends OneShotEffect { FilterLandPermanent playerFilter = filter.copy(); playerFilter.add(new ControllerIdPredicate(playerId)); Target target = new TargetLandPermanent(amount, amount, playerFilter, true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); for (UUID landId : target.getTargets()) { Permanent permanent = game.getPermanent(landId); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/t/ThranTome.java b/Mage.Sets/src/mage/cards/t/ThranTome.java index 43304db5bed..14525488549 100644 --- a/Mage.Sets/src/mage/cards/t/ThranTome.java +++ b/Mage.Sets/src/mage/cards/t/ThranTome.java @@ -64,7 +64,7 @@ class ThranTomeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { // validate source and controller exist Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null || controller == null) { return false; diff --git a/Mage.Sets/src/mage/cards/t/ThrasherBrute.java b/Mage.Sets/src/mage/cards/t/ThrasherBrute.java index c047b79a1fb..d2b04012262 100644 --- a/Mage.Sets/src/mage/cards/t/ThrasherBrute.java +++ b/Mage.Sets/src/mage/cards/t/ThrasherBrute.java @@ -70,9 +70,9 @@ class ThrasherBruteFilter extends FilterTeamPermanent { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - return super.match(permanent, sourceId, playerId, game) - && (sourceId.equals(permanent.getId()) + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + return super.match(permanent, playerId, source, game) + && (source.getSourceId().equals(permanent.getId()) || permanent.hasSubtype(SubType.WARRIOR, game)); } } diff --git a/Mage.Sets/src/mage/cards/t/ThreeWishes.java b/Mage.Sets/src/mage/cards/t/ThreeWishes.java index 78e06814acb..26ade1cb6c6 100644 --- a/Mage.Sets/src/mage/cards/t/ThreeWishes.java +++ b/Mage.Sets/src/mage/cards/t/ThreeWishes.java @@ -145,7 +145,7 @@ class ThreeWishesLookAtCardEffect extends AsThoughEffectImpl { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/t/ThroughTheBreach.java b/Mage.Sets/src/mage/cards/t/ThroughTheBreach.java index 460a2ec5ed2..f23160de056 100644 --- a/Mage.Sets/src/mage/cards/t/ThroughTheBreach.java +++ b/Mage.Sets/src/mage/cards/t/ThroughTheBreach.java @@ -76,7 +76,7 @@ class ThroughTheBreachEffect extends OneShotEffect { if (controller != null) { if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { diff --git a/Mage.Sets/src/mage/cards/t/ThunderbreakRegent.java b/Mage.Sets/src/mage/cards/t/ThunderbreakRegent.java index e8c31c28bca..cd5d03d3242 100644 --- a/Mage.Sets/src/mage/cards/t/ThunderbreakRegent.java +++ b/Mage.Sets/src/mage/cards/t/ThunderbreakRegent.java @@ -15,7 +15,6 @@ import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -78,7 +77,7 @@ class ThunderbreakRegentTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { Permanent creature = game.getPermanent(event.getTargetId()); - if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) { + if (creature != null && filter.match(creature, getControllerId(), this, game)) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage.Sets/src/mage/cards/t/ThunderkinAwakener.java b/Mage.Sets/src/mage/cards/t/ThunderkinAwakener.java index e8d3a109fee..72ab07be622 100644 --- a/Mage.Sets/src/mage/cards/t/ThunderkinAwakener.java +++ b/Mage.Sets/src/mage/cards/t/ThunderkinAwakener.java @@ -75,7 +75,7 @@ enum ThunderkinAwakenerPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getToughness().getValue() < sourcePermanent.getToughness().getValue(); } diff --git a/Mage.Sets/src/mage/cards/t/ThundermawHellkite.java b/Mage.Sets/src/mage/cards/t/ThundermawHellkite.java index 59305a501f8..2f2c43df000 100644 --- a/Mage.Sets/src/mage/cards/t/ThundermawHellkite.java +++ b/Mage.Sets/src/mage/cards/t/ThundermawHellkite.java @@ -84,7 +84,7 @@ class TapAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.tap(source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/t/ThunderousOrator.java b/Mage.Sets/src/mage/cards/t/ThunderousOrator.java index ca16ff18ed7..637fda50b20 100644 --- a/Mage.Sets/src/mage/cards/t/ThunderousOrator.java +++ b/Mage.Sets/src/mage/cards/t/ThunderousOrator.java @@ -87,13 +87,13 @@ class ThunderousOratorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List abilities = new ArrayList<>(); - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0) { abilities.add(new MenaceAbility()); } game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ).stream() .filter(Objects::nonNull) .map(p -> p.getAbilities(game)) diff --git a/Mage.Sets/src/mage/cards/t/ThwartTheGrave.java b/Mage.Sets/src/mage/cards/t/ThwartTheGrave.java index f3e0221f613..8ab12900e2f 100644 --- a/Mage.Sets/src/mage/cards/t/ThwartTheGrave.java +++ b/Mage.Sets/src/mage/cards/t/ThwartTheGrave.java @@ -1,5 +1,6 @@ package mage.cards.t; +import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.common.PartyCount; import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; @@ -67,8 +68,8 @@ class ThwartTheGraveTarget extends TargetCardInYourGraveyard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); if (!this.getTargets().isEmpty()) { possibleTargets.removeIf(uuid -> { Card card = game.getCard(uuid); diff --git a/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java b/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java index 641ed0497d8..f1d8f37d7f0 100644 --- a/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java +++ b/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java @@ -112,7 +112,7 @@ class TibaltTheFiendBloodedThirdEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.untap(game); diff --git a/Mage.Sets/src/mage/cards/t/TigerTribeHunter.java b/Mage.Sets/src/mage/cards/t/TigerTribeHunter.java index 02c24474774..fe3a57548fd 100644 --- a/Mage.Sets/src/mage/cards/t/TigerTribeHunter.java +++ b/Mage.Sets/src/mage/cards/t/TigerTribeHunter.java @@ -77,7 +77,7 @@ class TigerTribeHunterEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent( 0, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/t/TimberpackWolf.java b/Mage.Sets/src/mage/cards/t/TimberpackWolf.java index 12fbc4c2772..cd8f3bb5418 100644 --- a/Mage.Sets/src/mage/cards/t/TimberpackWolf.java +++ b/Mage.Sets/src/mage/cards/t/TimberpackWolf.java @@ -66,7 +66,7 @@ public final class TimberpackWolf extends CardImpl { @Override public boolean apply(Game game, Ability source) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1; + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game) - 1; if (count > 0) { Permanent target = game.getPermanent(source.getSourceId()); if (target != null) { diff --git a/Mage.Sets/src/mage/cards/t/TimeWipe.java b/Mage.Sets/src/mage/cards/t/TimeWipe.java index 3f339ac7f74..4776badd776 100644 --- a/Mage.Sets/src/mage/cards/t/TimeWipe.java +++ b/Mage.Sets/src/mage/cards/t/TimeWipe.java @@ -63,7 +63,7 @@ class TimeWipeEffect extends OneShotEffect { } Target target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (player.choose(outcome, target, source.getSourceId(), game)) { + if (player.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { player.moveCards(permanent, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/t/TinderWall.java b/Mage.Sets/src/mage/cards/t/TinderWall.java index 4f1cede0ea5..cdac2cb8828 100644 --- a/Mage.Sets/src/mage/cards/t/TinderWall.java +++ b/Mage.Sets/src/mage/cards/t/TinderWall.java @@ -1,6 +1,5 @@ package mage.cards.t; -import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.Ability; @@ -15,16 +14,24 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; -import mage.filter.common.FilterAttackingCreature; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author Plopman */ public final class TinderWall extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature it's blocking"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKED_BY); + } + public TinderWall(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}"); this.subtype.add(SubType.PLANT); @@ -35,14 +42,14 @@ public final class TinderWall extends CardImpl { // Defender this.addAbility(DefenderAbility.getInstance()); + // Sacrifice Tinder Wall: Add {R}{R}. this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.RedMana(2), new SacrificeSourceCost())); + // {R}, Sacrifice Tinder Wall: Tinder Wall deals 2 damage to target creature it's blocking. - FilterAttackingCreature filter = new FilterAttackingCreature("creature it's blocking"); - filter.add(new BlockedByIdPredicate(this.getId())); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2), new ManaCostsImpl("{R}")); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(2), new ManaCostsImpl<>("{R}")); ability.addCost(new SacrificeSourceCost()); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/t/TitansNest.java b/Mage.Sets/src/mage/cards/t/TitansNest.java index fd7d9af5279..4155b986873 100644 --- a/Mage.Sets/src/mage/cards/t/TitansNest.java +++ b/Mage.Sets/src/mage/cards/t/TitansNest.java @@ -123,7 +123,7 @@ class TitansNestManaCondition extends ManaCondition { if (!(source instanceof SpellAbility)) { return false; } - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object == null || object.getColor(game).isColorless()) { return false; } diff --git a/Mage.Sets/src/mage/cards/t/TobiasBeckett.java b/Mage.Sets/src/mage/cards/t/TobiasBeckett.java index 14871165450..c3b1b841d20 100644 --- a/Mage.Sets/src/mage/cards/t/TobiasBeckett.java +++ b/Mage.Sets/src/mage/cards/t/TobiasBeckett.java @@ -73,7 +73,7 @@ class TobiasBeckettEffect extends OneShotEffect { if (bountyTriggered != null) { Player opponent = game.getPlayer(bountyTriggered.getControllerId()); if (opponent != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); UUID exileId = CardUtil.getCardExileZoneId(game, source); Card card = opponent.getLibrary().getFromTop(game); if (card != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/t/Togglodyte.java b/Mage.Sets/src/mage/cards/t/Togglodyte.java index 2352132c9ae..6c7d613d805 100644 --- a/Mage.Sets/src/mage/cards/t/Togglodyte.java +++ b/Mage.Sets/src/mage/cards/t/Togglodyte.java @@ -71,7 +71,7 @@ class TogglodyteEntersEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (mageObject != null) { boolean toggled = true; @@ -103,7 +103,7 @@ class TogglodyteToggleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { if (game.getState().getValue(mageObject.getId() + "_toggle") == null) { return false; @@ -183,7 +183,7 @@ class TogglodyteCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return !Boolean.TRUE.equals(game.getState().getValue(mageObject.getId() + "_toggle")); } diff --git a/Mage.Sets/src/mage/cards/t/TombstoneStairwell.java b/Mage.Sets/src/mage/cards/t/TombstoneStairwell.java index 5f70fdb1803..a4ebffdc6b9 100644 --- a/Mage.Sets/src/mage/cards/t/TombstoneStairwell.java +++ b/Mage.Sets/src/mage/cards/t/TombstoneStairwell.java @@ -20,7 +20,6 @@ import mage.constants.Zone; import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; @@ -92,7 +91,7 @@ class TombstoneStairwellCreateTokenEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); - int creatureCardsInGraveyard = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, source.getControllerId(), source.getSourceId(), game); + int creatureCardsInGraveyard = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, source.getSourceId(), source, game); token.putOntoBattlefield(creatureCardsInGraveyard, game, source, playerId); for (UUID tokenId : token.getLastAddedTokenIds()) { tokensCreated.add(tokenId); diff --git a/Mage.Sets/src/mage/cards/t/TomikDistinguishedAdvokist.java b/Mage.Sets/src/mage/cards/t/TomikDistinguishedAdvokist.java index 6d9df04acaf..6fa4f7d41f1 100644 --- a/Mage.Sets/src/mage/cards/t/TomikDistinguishedAdvokist.java +++ b/Mage.Sets/src/mage/cards/t/TomikDistinguishedAdvokist.java @@ -73,7 +73,7 @@ enum TargetedByOpponentsPredicate implements ObjectSourcePlayerPredicate input, Game game) { StackObject stackObject = game.getStack().getStackObject(input.getObject().getId()); - Permanent source = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent source = input.getSource().getSourcePermanentOrLKI(game); if (stackObject != null && source != null) { Player controller = game.getPlayer(source.getControllerId()); return controller != null && game.isOpponent(controller, stackObject.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/t/ToothAndNail.java b/Mage.Sets/src/mage/cards/t/ToothAndNail.java index 0645663c720..bb44783db2b 100644 --- a/Mage.Sets/src/mage/cards/t/ToothAndNail.java +++ b/Mage.Sets/src/mage/cards/t/ToothAndNail.java @@ -73,7 +73,7 @@ class ToothAndNailPutCreatureOnBattlefieldEffect extends OneShotEffect { } TargetCardInHand target = new TargetCardInHand(0, 2, new FilterCreatureCard("creature cards")); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source, game)) { return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null); } diff --git a/Mage.Sets/src/mage/cards/t/Topple.java b/Mage.Sets/src/mage/cards/t/Topple.java index e7e7afef9ef..752823f9b33 100644 --- a/Mage.Sets/src/mage/cards/t/Topple.java +++ b/Mage.Sets/src/mage/cards/t/Topple.java @@ -53,7 +53,7 @@ class ToppleTargetCreature extends TargetCreaturePermanent { public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { if (super.canTarget(controllerId, id, source, game)) { int maxPower = 0; - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent.getPower().getValue() > maxPower) { maxPower = permanent.getPower().getValue(); } @@ -67,11 +67,11 @@ class ToppleTargetCreature extends TargetCreaturePermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { int maxPower = 0; - List activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game); + List activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource == null){ return possibleTargets; } @@ -91,8 +91,8 @@ class ToppleTargetCreature extends TargetCreaturePermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - return !possibleTargets(sourceId, sourceControllerId, game).isEmpty(); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + return !possibleTargets(sourceControllerId, source, game).isEmpty(); } @Override diff --git a/Mage.Sets/src/mage/cards/t/TormentOfHailfire.java b/Mage.Sets/src/mage/cards/t/TormentOfHailfire.java index 84242364d72..0b74d497d6f 100644 --- a/Mage.Sets/src/mage/cards/t/TormentOfHailfire.java +++ b/Mage.Sets/src/mage/cards/t/TormentOfHailfire.java @@ -69,7 +69,7 @@ class TormentOfHailfireEffect extends OneShotEffect { "Otherwise you have to discard a card or lose 3 life.", "Sacrifice", "Discard or life loss", source, game)) { Target target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND); target.setNotTarget(true); - if (opponent.choose(outcome, target, source.getSourceId(), game)) { + if (opponent.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { if (permanent.sacrifice(source, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TormentOfScarabs.java b/Mage.Sets/src/mage/cards/t/TormentOfScarabs.java index 78f81a776b3..5884bfe634d 100644 --- a/Mage.Sets/src/mage/cards/t/TormentOfScarabs.java +++ b/Mage.Sets/src/mage/cards/t/TormentOfScarabs.java @@ -80,7 +80,7 @@ class TormentOfScarabsEffect extends OneShotEffect { if (permanents > 0 && enchantedPlayer.chooseUse(outcome, "Sacrifice a nonland permanent?", "Otherwise you have to discard a card or lose 3 life.", "Sacrifice", "Discard or life loss", source, game)) { Target target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND); - if (enchantedPlayer.choose(outcome, target, source.getSourceId(), game)) { + if (enchantedPlayer.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/t/TormentOfVenom.java b/Mage.Sets/src/mage/cards/t/TormentOfVenom.java index 797b13f2f85..8a6e2bab259 100644 --- a/Mage.Sets/src/mage/cards/t/TormentOfVenom.java +++ b/Mage.Sets/src/mage/cards/t/TormentOfVenom.java @@ -76,7 +76,7 @@ class TormentOfVenomEffect extends OneShotEffect { filter.add(Predicates.not(CardType.LAND.getPredicate())); filter.add(Predicates.not(new PermanentIdPredicate(targetCreature.getId()))); Target target = new TargetPermanent(filter); - if (controllingPlayer.choose(outcome, target, source.getSourceId(), game)) { + if (controllingPlayer.choose(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/t/TorporOrb.java b/Mage.Sets/src/mage/cards/t/TorporOrb.java index 0307fa147ab..3b046deaf19 100644 --- a/Mage.Sets/src/mage/cards/t/TorporOrb.java +++ b/Mage.Sets/src/mage/cards/t/TorporOrb.java @@ -73,7 +73,7 @@ class TorporOrbEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject enteringObject = game.getObject(event.getSourceId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Ability ability = (Ability) getValue("targetAbility"); if (enteringObject != null && sourceObject != null && ability != null) { MageObject abilitObject = game.getObject(ability.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/t/TorrentSculptor.java b/Mage.Sets/src/mage/cards/t/TorrentSculptor.java index fa325a67759..17aaa98cc16 100644 --- a/Mage.Sets/src/mage/cards/t/TorrentSculptor.java +++ b/Mage.Sets/src/mage/cards/t/TorrentSculptor.java @@ -89,7 +89,7 @@ class TorrentSculptorEffect extends OneShotEffect { } TargetCard targetCard = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY); targetCard.setNotTarget(true); - player.choose(Outcome.Exile, targetCard, source.getSourceId(), game); + player.choose(Outcome.Exile, targetCard, source, game); Card card = game.getCard(targetCard.getFirstTarget()); if (card == null) { return false; diff --git a/Mage.Sets/src/mage/cards/t/TourachsChant.java b/Mage.Sets/src/mage/cards/t/TourachsChant.java index a5319bf86f6..0dc26eb98e7 100644 --- a/Mage.Sets/src/mage/cards/t/TourachsChant.java +++ b/Mage.Sets/src/mage/cards/t/TourachsChant.java @@ -75,7 +75,7 @@ class TourachsChantEffect extends OneShotEffect { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); if (player.chooseUse(Outcome.Detriment, "Put a -1/-1 counter on a creature you control? (otherwise " + sourcePermanent.getLogName() + " deals 3 damage to you)", source, game) - && player.choose(Outcome.UnboostCreature, target, source.getSourceId(), game)) { + && player.choose(Outcome.UnboostCreature, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.addCounters(CounterType.M1M1.createInstance(), player.getId(), source, game); diff --git a/Mage.Sets/src/mage/cards/t/TovolarDireOverlord.java b/Mage.Sets/src/mage/cards/t/TovolarDireOverlord.java index 6ec93b9729e..4af27bafbf5 100644 --- a/Mage.Sets/src/mage/cards/t/TovolarDireOverlord.java +++ b/Mage.Sets/src/mage/cards/t/TovolarDireOverlord.java @@ -111,7 +111,7 @@ class TovolarDireOverlordEffect extends OneShotEffect { return true; } TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - player.choose(outcome, target, source.getControllerId(), game); + player.choose(outcome, target, source, game); for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/t/TowashiGuideBot.java b/Mage.Sets/src/mage/cards/t/TowashiGuideBot.java index 27ddb16b728..051da5a6ccc 100644 --- a/Mage.Sets/src/mage/cards/t/TowashiGuideBot.java +++ b/Mage.Sets/src/mage/cards/t/TowashiGuideBot.java @@ -83,7 +83,7 @@ enum TowashiGuideBotAdjuster implements CostAdjuster { @Override public void adjustCosts(Ability ability, Game game) { CardUtil.reduceCost(ability, game.getBattlefield().count( - filter, ability.getSourceId(), ability.getControllerId(), game + filter, ability.getControllerId(), ability, game )); } } diff --git a/Mage.Sets/src/mage/cards/t/ToweringTitan.java b/Mage.Sets/src/mage/cards/t/ToweringTitan.java index 777e7118a34..4b1549af15d 100644 --- a/Mage.Sets/src/mage/cards/t/ToweringTitan.java +++ b/Mage.Sets/src/mage/cards/t/ToweringTitan.java @@ -80,7 +80,7 @@ enum ToweringTitanCount implements DynamicValue { return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, - sourceAbility.getControllerId(), sourceAbility.getSourceId(), game + sourceAbility.getControllerId(), sourceAbility, game ).stream() .filter(Objects::nonNull) .map(MageObject::getToughness) diff --git a/Mage.Sets/src/mage/cards/t/ToxrillTheCorrosive.java b/Mage.Sets/src/mage/cards/t/ToxrillTheCorrosive.java index 18b469e1022..cb6ad9ee7b6 100644 --- a/Mage.Sets/src/mage/cards/t/ToxrillTheCorrosive.java +++ b/Mage.Sets/src/mage/cards/t/ToxrillTheCorrosive.java @@ -102,7 +102,7 @@ class ToxrillTheCorrosiveEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents( StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game )) { int counter = permanent.getCounters(game).getCount(CounterType.SLIME); permanent.getPower().boostValue(-counter); diff --git a/Mage.Sets/src/mage/cards/t/TrackDown.java b/Mage.Sets/src/mage/cards/t/TrackDown.java index 9b0ac81b092..5010afc1013 100644 --- a/Mage.Sets/src/mage/cards/t/TrackDown.java +++ b/Mage.Sets/src/mage/cards/t/TrackDown.java @@ -57,7 +57,7 @@ class TrackDownEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null || controller == null) { return false; diff --git a/Mage.Sets/src/mage/cards/t/TragicArrogance.java b/Mage.Sets/src/mage/cards/t/TragicArrogance.java index 23b9dab4b99..f9d6b720a61 100644 --- a/Mage.Sets/src/mage/cards/t/TragicArrogance.java +++ b/Mage.Sets/src/mage/cards/t/TragicArrogance.java @@ -85,7 +85,7 @@ class TragicArroganceffect extends OneShotEffect { filterPlaneswalkerPermanent.add(new ControllerIdPredicate(playerId)); Target target4 = new TargetPermanent(1, 1, filterPlaneswalkerPermanent, true); - if (target1.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target1.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Benefit, target1, source, game); Permanent artifact = game.getPermanent(target1.getFirstTarget()); if (artifact != null) { @@ -94,7 +94,7 @@ class TragicArroganceffect extends OneShotEffect { target1.clearChosen(); } - if (target2.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target2.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Benefit, target2, source, game); Permanent creature = game.getPermanent(target2.getFirstTarget()); if (creature != null) { @@ -103,7 +103,7 @@ class TragicArroganceffect extends OneShotEffect { target2.clearChosen(); } - if (target3.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target3.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Benefit, target3, source, game); Permanent enchantment = game.getPermanent(target3.getFirstTarget()); if (enchantment != null) { @@ -112,7 +112,7 @@ class TragicArroganceffect extends OneShotEffect { target3.clearChosen(); } - if (target4.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target4.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Benefit, target4, source, game); Permanent planeswalker = game.getPermanent(target4.getFirstTarget()); if (planeswalker != null) { diff --git a/Mage.Sets/src/mage/cards/t/TravelingPlague.java b/Mage.Sets/src/mage/cards/t/TravelingPlague.java index 4683e2f5df7..3475406f8ae 100644 --- a/Mage.Sets/src/mage/cards/t/TravelingPlague.java +++ b/Mage.Sets/src/mage/cards/t/TravelingPlague.java @@ -133,7 +133,7 @@ class TravelingPlagueEffect extends OneShotEffect { && controllerOfEnchantedCreature != null) { TargetPermanent target = new TargetPermanent(new FilterCreaturePermanent("creature to enchant with " + travelingPlague.getName())); target.setNotTarget(true); - if (controllerOfEnchantedCreature.choose(Outcome.Detriment, target, source.getSourceId(), game)) { + if (controllerOfEnchantedCreature.choose(Outcome.Detriment, target, source, game)) { Permanent targetPermanent = game.getPermanent(target.getFirstTarget()); if (!targetPermanent.cantBeAttachedBy(travelingPlague, source, game, false)) { game.getState().setValue("attachTo:" + travelingPlague.getId(), targetPermanent); diff --git a/Mage.Sets/src/mage/cards/t/TreacherousTerrain.java b/Mage.Sets/src/mage/cards/t/TreacherousTerrain.java index 4fdd97b623e..6c915d0a1a9 100644 --- a/Mage.Sets/src/mage/cards/t/TreacherousTerrain.java +++ b/Mage.Sets/src/mage/cards/t/TreacherousTerrain.java @@ -54,7 +54,7 @@ class TreacherousTerrainEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source, game); for (UUID playerId : game.getOpponents(source.getControllerId())) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/t/TreacherousUrge.java b/Mage.Sets/src/mage/cards/t/TreacherousUrge.java index fc3bc48f4ce..8f1b1dd528e 100644 --- a/Mage.Sets/src/mage/cards/t/TreacherousUrge.java +++ b/Mage.Sets/src/mage/cards/t/TreacherousUrge.java @@ -68,7 +68,7 @@ class TreacherousUrgeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (opponent != null && sourceObject != null) { opponent.revealCards(sourceObject.getName(), opponent.getHand(), game); Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/t/TrenchGorger.java b/Mage.Sets/src/mage/cards/t/TrenchGorger.java index b7f3772777a..cfc1a6f09a7 100644 --- a/Mage.Sets/src/mage/cards/t/TrenchGorger.java +++ b/Mage.Sets/src/mage/cards/t/TrenchGorger.java @@ -68,7 +68,7 @@ class TrenchGorgerEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterLandCard("any number of land cards")); - target.choose(outcome, controller.getId(), controller.getId(), game); + target.choose(outcome, controller.getId(), controller.getId(), source, game); int count = 0; for (UUID cardId : target.getTargets()) { Card card = game.getCard(cardId); diff --git a/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java b/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java index 18f4ba1fd3c..8df3e49fe2b 100644 --- a/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java +++ b/Mage.Sets/src/mage/cards/t/TrevaTheRenewer.java @@ -78,7 +78,7 @@ class TrevaTheRenewerEffect extends OneShotEffect { game.informPlayers(controller.getLogName() + " chooses " + choice.getColor()); FilterPermanent filter = new FilterPermanent(); filter.add(new ColorPredicate(choice.getColor())); - int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game); + int cardsWithColor = game.getBattlefield().count(filter, controller.getId(), source, game); if (cardsWithColor > 0) { new GainLifeEffect(cardsWithColor).apply(game, source); } diff --git a/Mage.Sets/src/mage/cards/t/TribalUnity.java b/Mage.Sets/src/mage/cards/t/TribalUnity.java index 13f1ee817e0..b14bd4f656a 100644 --- a/Mage.Sets/src/mage/cards/t/TribalUnity.java +++ b/Mage.Sets/src/mage/cards/t/TribalUnity.java @@ -59,7 +59,7 @@ class TribalUnityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/t/TributeToHunger.java b/Mage.Sets/src/mage/cards/t/TributeToHunger.java index 2ef3150c99b..297295f1b05 100644 --- a/Mage.Sets/src/mage/cards/t/TributeToHunger.java +++ b/Mage.Sets/src/mage/cards/t/TributeToHunger.java @@ -61,7 +61,7 @@ class TributeToHungerEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && opponent != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true); - if (target.canChoose(source.getSourceId(), opponent.getId(), game)) { + if (target.canChoose(opponent.getId(), source, game)) { opponent.chooseTarget(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/t/TriumphOfGerrard.java b/Mage.Sets/src/mage/cards/t/TriumphOfGerrard.java index c0c246c8464..dd68b5f8b39 100644 --- a/Mage.Sets/src/mage/cards/t/TriumphOfGerrard.java +++ b/Mage.Sets/src/mage/cards/t/TriumphOfGerrard.java @@ -88,7 +88,7 @@ class TriumphOfGerrardTargetCreature extends TargetControlledCreaturePermanent { public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { if (super.canTarget(controllerId, id, source, game)) { int maxPower = 0; - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent.getPower().getValue() > maxPower) { maxPower = permanent.getPower().getValue(); } @@ -102,11 +102,11 @@ class TriumphOfGerrardTargetCreature extends TargetControlledCreaturePermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { int maxPower = 0; - List activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game); + List activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game); Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); if(targetSource == null){ return possibleTargets; } @@ -126,8 +126,8 @@ class TriumphOfGerrardTargetCreature extends TargetControlledCreaturePermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - return !possibleTargets(sourceId, sourceControllerId, game).isEmpty(); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + return !possibleTargets(sourceControllerId, source, game).isEmpty(); } @Override diff --git a/Mage.Sets/src/mage/cards/t/TruthOrTale.java b/Mage.Sets/src/mage/cards/t/TruthOrTale.java index c5dd402950a..c2cd531c52b 100644 --- a/Mage.Sets/src/mage/cards/t/TruthOrTale.java +++ b/Mage.Sets/src/mage/cards/t/TruthOrTale.java @@ -59,7 +59,7 @@ class TruthOrTaleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/t/TsabosDecree.java b/Mage.Sets/src/mage/cards/t/TsabosDecree.java index ceba41a0abd..a6d630ea7d6 100644 --- a/Mage.Sets/src/mage/cards/t/TsabosDecree.java +++ b/Mage.Sets/src/mage/cards/t/TsabosDecree.java @@ -60,7 +60,7 @@ class TsabosDecreeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/t/TuktukScrapper.java b/Mage.Sets/src/mage/cards/t/TuktukScrapper.java index 84fa8af5a88..13c3e32b229 100644 --- a/Mage.Sets/src/mage/cards/t/TuktukScrapper.java +++ b/Mage.Sets/src/mage/cards/t/TuktukScrapper.java @@ -121,7 +121,7 @@ class TuktukScrapperEffect extends OneShotEffect { targetArtifact.destroy(source, game, false); Player targetController = game.getPlayer(targetArtifact.getControllerId()); if (targetController != null && game.getState().getZone(targetArtifact.getId()) == Zone.GRAVEYARD) { - int alliesControlled = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int alliesControlled = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (alliesControlled > 0) { targetController.damage(alliesControlled, source.getSourceId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/t/TurfWound.java b/Mage.Sets/src/mage/cards/t/TurfWound.java index 5b9ccd88227..7383367f0f4 100644 --- a/Mage.Sets/src/mage/cards/t/TurfWound.java +++ b/Mage.Sets/src/mage/cards/t/TurfWound.java @@ -65,7 +65,7 @@ class TurfWoundEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't play lands this turn (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/t/Turnabout.java b/Mage.Sets/src/mage/cards/t/Turnabout.java index 0f53db524cc..2cf6d251ba3 100644 --- a/Mage.Sets/src/mage/cards/t/Turnabout.java +++ b/Mage.Sets/src/mage/cards/t/Turnabout.java @@ -98,7 +98,7 @@ class TurnaboutEffect extends OneShotEffect { "Tap", "Untap", source, game ); for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getFirstTarget(), source.getSourceId(), game + filter, source.getFirstTarget(), source, game )) { if (tap) { permanent.tap(source, game); diff --git a/Mage.Sets/src/mage/cards/t/TuyaBearclaw.java b/Mage.Sets/src/mage/cards/t/TuyaBearclaw.java index f4694313d94..5d3ea50ad75 100644 --- a/Mage.Sets/src/mage/cards/t/TuyaBearclaw.java +++ b/Mage.Sets/src/mage/cards/t/TuyaBearclaw.java @@ -59,7 +59,7 @@ enum TuyaBearclawValue implements DynamicValue { return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, - sourceAbility.getControllerId(), sourceAbility.getSourceId(), game + sourceAbility.getControllerId(), sourceAbility, game ).stream() .filter(Objects::nonNull) .map(MageObject::getPower) diff --git a/Mage.Sets/src/mage/cards/t/TwistAllegiance.java b/Mage.Sets/src/mage/cards/t/TwistAllegiance.java index 8fcd1ade542..a81e3d0dd7a 100644 --- a/Mage.Sets/src/mage/cards/t/TwistAllegiance.java +++ b/Mage.Sets/src/mage/cards/t/TwistAllegiance.java @@ -65,7 +65,7 @@ class TwistAllegianceEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source)); if (controller != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { // only creatures of controller & target opponent if (permanent.isControlledBy(source.getControllerId()) || permanent.isControlledBy(targetOpponent.getId())) { UUID newController = permanent.isControlledBy(source.getControllerId()) ? targetOpponent.getId() : source.getControllerId(); diff --git a/Mage.Sets/src/mage/cards/t/TwistedJustice.java b/Mage.Sets/src/mage/cards/t/TwistedJustice.java index 490c6965284..7e37bdf583f 100644 --- a/Mage.Sets/src/mage/cards/t/TwistedJustice.java +++ b/Mage.Sets/src/mage/cards/t/TwistedJustice.java @@ -63,8 +63,8 @@ class TwistedJusticeEffect extends OneShotEffect { //A spell or ability could have removed the only legal target this player //had, if thats the case this ability should fizzle. - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/u/UginTheSpiritDragon.java b/Mage.Sets/src/mage/cards/u/UginTheSpiritDragon.java index 53bdc9bb348..29b3b53b0d3 100644 --- a/Mage.Sets/src/mage/cards/u/UginTheSpiritDragon.java +++ b/Mage.Sets/src/mage/cards/u/UginTheSpiritDragon.java @@ -101,7 +101,7 @@ class UginTheSpiritDragonEffect2 extends OneShotEffect { filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc + 1)); filter.add(Predicates.not(ColorlessPredicate.instance)); Set permanentsToExile = new HashSet<>(); - permanentsToExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)); + permanentsToExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)); controller.moveCards(permanentsToExile, Zone.EXILED, source, game); return true; } @@ -130,7 +130,7 @@ class UginTheSpiritDragonEffect3 extends OneShotEffect { controller.gainLife(7, game, source); controller.drawCards(7, source, game); TargetCardInHand target = new TargetCardInHand(0, 7, new FilterPermanentCard("permanent cards")); - if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source, game)) { controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/u/UginsNexus.java b/Mage.Sets/src/mage/cards/u/UginsNexus.java index 45235baa763..2182be37cc3 100644 --- a/Mage.Sets/src/mage/cards/u/UginsNexus.java +++ b/Mage.Sets/src/mage/cards/u/UginsNexus.java @@ -63,7 +63,7 @@ class UginsNexusSkipExtraTurnsEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(event.getPlayerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { game.informPlayers(sourceObject.getLogName() + ": Extra turn of " + player.getLogName() + " skipped"); } diff --git a/Mage.Sets/src/mage/cards/u/UlamogsDespoiler.java b/Mage.Sets/src/mage/cards/u/UlamogsDespoiler.java index 1fa716eae35..c8d7288e638 100644 --- a/Mage.Sets/src/mage/cards/u/UlamogsDespoiler.java +++ b/Mage.Sets/src/mage/cards/u/UlamogsDespoiler.java @@ -78,7 +78,7 @@ class UlamogsDespoilerEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetCardInExile(2, 2, filter, null); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { if (controller.chooseTarget(outcome, target, source, game)) { Cards cardsToGraveyard = new CardsImpl(target.getTargets()); controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game); diff --git a/Mage.Sets/src/mage/cards/u/UlamogsNullifier.java b/Mage.Sets/src/mage/cards/u/UlamogsNullifier.java index 60a0647d075..5c2d36a9ecd 100644 --- a/Mage.Sets/src/mage/cards/u/UlamogsNullifier.java +++ b/Mage.Sets/src/mage/cards/u/UlamogsNullifier.java @@ -93,7 +93,7 @@ class UlamogsNullifierEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(source.getFirstTarget()); if (controller != null && spell != null) { Target target = new TargetCardInExile(2, 2, filter, null); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { if (controller.chooseTarget(outcome, target, source, game)) { Cards cardsToGraveyard = new CardsImpl(target.getTargets()); controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game); diff --git a/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java b/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java index 254c209847f..d8e0f50bd44 100644 --- a/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java +++ b/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java @@ -97,8 +97,8 @@ class UlashtTheHateSeedEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null && player != null) { - int amount = game.getBattlefield().count(filterRed, source.getSourceId(), source.getControllerId(), game); - amount += game.getBattlefield().count(filterGreen, source.getSourceId(), source.getControllerId(), game); + int amount = game.getBattlefield().count(filterRed, source.getControllerId(), source, game); + amount += game.getBattlefield().count(filterGreen, source.getControllerId(), source, game); if (amount > 0) { permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game); } diff --git a/Mage.Sets/src/mage/cards/u/Umbilicus.java b/Mage.Sets/src/mage/cards/u/Umbilicus.java index e1a6e26fc71..b1765f341b9 100644 --- a/Mage.Sets/src/mage/cards/u/Umbilicus.java +++ b/Mage.Sets/src/mage/cards/u/Umbilicus.java @@ -69,7 +69,7 @@ class BloodClockEffect extends OneShotEffect { return true; } else { Target target = new TargetControlledPermanent(); - if (target.canChoose(source.getSourceId(), player.getId(), game) && player.chooseTarget(outcome, target, source, game)) { + if (target.canChoose(player.getId(), source, game) && player.chooseTarget(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { game.informPlayers(player.getLogName() + " returns " + permanent.getName() + " to hand."); diff --git a/Mage.Sets/src/mage/cards/u/UnblinkingObserver.java b/Mage.Sets/src/mage/cards/u/UnblinkingObserver.java index 8f47ae7c5ae..2a52069338d 100644 --- a/Mage.Sets/src/mage/cards/u/UnblinkingObserver.java +++ b/Mage.Sets/src/mage/cards/u/UnblinkingObserver.java @@ -76,7 +76,7 @@ class UnblinkingObserverManaCondition extends ManaCondition implements Condition @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isInstantOrSorcery(game); } return source instanceof DisturbAbility; diff --git a/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java b/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java index 76156ad2156..c2f84fb4a31 100644 --- a/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java +++ b/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java @@ -62,7 +62,7 @@ class UnclaimedTerritoryManaBuilder extends ConditionalManaBuilder { creatureType = subType; } Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && mana.getAny() == 0) { game.informPlayers(controller.getLogName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() + " (can only be spent to cast creatures of type " + creatureType + ")"); @@ -103,7 +103,7 @@ class UnclaimedTerritoryManaCondition extends CreatureCastManaCondition { // check: ... to cast a creature spell if (super.apply(game, source)) { // check: ... of the chosen type - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/u/UnforgivingOne.java b/Mage.Sets/src/mage/cards/u/UnforgivingOne.java index 8fce59a9b31..8c4248ebe74 100644 --- a/Mage.Sets/src/mage/cards/u/UnforgivingOne.java +++ b/Mage.Sets/src/mage/cards/u/UnforgivingOne.java @@ -86,6 +86,6 @@ enum UnforgivingOnePredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { return input.getObject().getManaValue() - <= game.getBattlefield().count(filter, input.getSourceId(), input.getPlayerId(), game); + <= game.getBattlefield().count(filter, input.getPlayerId(), input.getSource(), game); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/u/UnifiedStrike.java b/Mage.Sets/src/mage/cards/u/UnifiedStrike.java index 1489e7586db..5b4afd8fd5b 100644 --- a/Mage.Sets/src/mage/cards/u/UnifiedStrike.java +++ b/Mage.Sets/src/mage/cards/u/UnifiedStrike.java @@ -73,8 +73,7 @@ class UnifiedStrikeEffect extends OneShotEffect { .getActivePermanents( filter, source.getControllerId(), - source.getSourceId(), - game + source, game ).size(); boolean successful = creature.getPower().getValue() <= soldierCount; if (successful) { diff --git a/Mage.Sets/src/mage/cards/u/UnlivingPsychopath.java b/Mage.Sets/src/mage/cards/u/UnlivingPsychopath.java index 490dc55e22e..f61653b5233 100644 --- a/Mage.Sets/src/mage/cards/u/UnlivingPsychopath.java +++ b/Mage.Sets/src/mage/cards/u/UnlivingPsychopath.java @@ -67,7 +67,7 @@ class UnlivingPsychopathPowerLessThanSourcePredicate implements ObjectSourcePlay @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getPower().getValue() < sourcePermanent.getPower().getValue(); } diff --git a/Mage.Sets/src/mage/cards/u/UntaidakeTheCloudKeeper.java b/Mage.Sets/src/mage/cards/u/UntaidakeTheCloudKeeper.java index 7257d219aa9..b1a93996612 100644 --- a/Mage.Sets/src/mage/cards/u/UntaidakeTheCloudKeeper.java +++ b/Mage.Sets/src/mage/cards/u/UntaidakeTheCloudKeeper.java @@ -77,7 +77,7 @@ class LegendaryCastManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.isLegendary()) { return true; } diff --git a/Mage.Sets/src/mage/cards/u/UrborgPanther.java b/Mage.Sets/src/mage/cards/u/UrborgPanther.java index 7f26d33f4fd..ce9179a2010 100644 --- a/Mage.Sets/src/mage/cards/u/UrborgPanther.java +++ b/Mage.Sets/src/mage/cards/u/UrborgPanther.java @@ -1,10 +1,9 @@ package mage.cards.u; -import java.util.UUID; - import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.CompositeCost; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.mana.ColoredManaCost; @@ -16,57 +15,64 @@ import mage.constants.CardType; import mage.constants.ColoredManaSymbol; import mage.constants.SubType; import mage.filter.FilterCard; +import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.NamePredicate; -import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetControlledCreaturePermanent; -import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; /** - * * @author Ketsuban */ public class UrborgPanther extends CardImpl { - private static final FilterControlledCreaturePermanent filter1 = new FilterControlledCreaturePermanent("creature named Feral Shadow"); - private static final FilterControlledCreaturePermanent filter2 = new FilterControlledCreaturePermanent("creature named Breathstealer"); - + private static final FilterPermanent filter = new FilterCreaturePermanent("creature blocking {this}"); + private static final FilterControlledCreaturePermanent filter1 + = new FilterControlledCreaturePermanent("creature named Feral Shadow"); + private static final FilterControlledCreaturePermanent filter2 + = new FilterControlledCreaturePermanent("creature named Breathstealer"); private static final FilterCard filterCard = new FilterCreatureCard("card named Spirit of the Night"); static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING); filter1.add(new NamePredicate("Feral Shadow")); filter2.add(new NamePredicate("Breathstealer")); filterCard.add(new NamePredicate("Spirit of the Night")); } public UrborgPanther(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[] { CardType.CREATURE }, "{2}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}"); this.subtype.add(SubType.NIGHTSTALKER); this.subtype.add(SubType.CAT); this.power = new MageInt(2); this.toughness = new MageInt(2); // B, Sacrifice Urborg Panther: Destroy target creature blocking Urborg Panther. - Ability ability1 = new SimpleActivatedAbility(new DestroyTargetEffect(), - new ColoredManaCost(ColoredManaSymbol.B)); - ability1.addCost(new SacrificeSourceCost()); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking {this}"); - filter.add(new BlockingAttackerIdPredicate(this.getId())); - ability1.addTarget(new TargetCreaturePermanent(filter)); - this.addAbility(ability1); + Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new ColoredManaCost(ColoredManaSymbol.B)); + ability.addCost(new SacrificeSourceCost()); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); // Sacrifice a creature named Feral Shadow, a creature named Breathstealer, and // Urborg Panther: Search your library for a card named Spirit of the Night and // put that card onto the battlefield. Then shuffle your library. - Ability ability2 = new SimpleActivatedAbility( - new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(1, 1, new FilterCard(filterCard))), - new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, filter1, true))); - ability2.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, filter2, true))); - ability2.addCost(new SacrificeSourceCost()); - this.addAbility(ability2); + this.addAbility(new SimpleActivatedAbility( + new SearchLibraryPutInPlayEffect(new TargetCardInLibrary( + 1, 1, filterCard + )), + new CompositeCost(new CompositeCost( + new SacrificeTargetCost(new TargetControlledCreaturePermanent(filter1)), + new SacrificeTargetCost(new TargetControlledCreaturePermanent(filter2)), + "" + ), new SacrificeSourceCost(), "sacrifice a creature named Feral Shadow, " + + "a creature named Breathstealer, and {this}") + )); } private UrborgPanther(final UrborgPanther card) { @@ -77,5 +83,4 @@ public class UrborgPanther extends CardImpl { public UrborgPanther copy() { return new UrborgPanther(this); } - } diff --git a/Mage.Sets/src/mage/cards/u/UrgeToFeed.java b/Mage.Sets/src/mage/cards/u/UrgeToFeed.java index 5633f662d04..cc018dc916e 100644 --- a/Mage.Sets/src/mage/cards/u/UrgeToFeed.java +++ b/Mage.Sets/src/mage/cards/u/UrgeToFeed.java @@ -63,7 +63,7 @@ class UrgeToFeedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { TargetCreaturePermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { + if (target.canChoose(source.getControllerId(), source, game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), source, game)) { for (UUID vampireId : target.getTargets()) { Permanent vampire = game.getPermanent(vampireId); if (vampire != null) { diff --git a/Mage.Sets/src/mage/cards/u/UrzaAcademyHeadmaster.java b/Mage.Sets/src/mage/cards/u/UrzaAcademyHeadmaster.java index 56481232f39..ef83c36aa2d 100644 --- a/Mage.Sets/src/mage/cards/u/UrzaAcademyHeadmaster.java +++ b/Mage.Sets/src/mage/cards/u/UrzaAcademyHeadmaster.java @@ -430,7 +430,7 @@ class UrzaAcademyHeadmasterRandomEffect extends OneShotEffect { game.informPlayers(sb.toString()); if (target != null) { - if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) { + if (target.canChoose(controller.getId(), source, game) && controller.canRespond()) { target.chooseTarget(outcome, controller.getId(), source, game); } else { // 1/19/2018 (...) If the ability that comes up requires a target and there are no legal targets available, click again until that’s not true. @@ -485,7 +485,7 @@ class UrzaAcademyHeadmasterManaEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game); + int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getControllerId(), source, game); Choice manaChoice = new ChoiceImpl(); Set choices = new LinkedHashSet<>(); choices.add("White"); @@ -558,7 +558,7 @@ class UrzaAcademyHeadmasterBrainstormEffect extends OneShotEffect { private boolean putOnLibrary(Player player, Ability source, Game game) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java b/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java index 71cf2f80418..6a541f44a82 100644 --- a/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java +++ b/Mage.Sets/src/mage/cards/u/UrzaLordHighArtificer.java @@ -125,7 +125,7 @@ class UrzaLordHighArtificerManaEffect extends BasicManaEffect { @Override public List getNetMana(Game game, Ability source) { if (game != null && game.inCheckPlayableState()) { - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); List netMana = new ArrayList<>(); if (count > 0) { netMana.add(Mana.BlueMana(count)); diff --git a/Mage.Sets/src/mage/cards/u/UrzasBauble.java b/Mage.Sets/src/mage/cards/u/UrzasBauble.java index 9a170b0770e..4360f9b830b 100644 --- a/Mage.Sets/src/mage/cards/u/UrzasBauble.java +++ b/Mage.Sets/src/mage/cards/u/UrzasBauble.java @@ -69,7 +69,7 @@ class LookAtRandomCardEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && targetPlayer != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/v/ValakutTheMoltenPinnacle.java b/Mage.Sets/src/mage/cards/v/ValakutTheMoltenPinnacle.java index b1410f17f19..9308cd121ac 100644 --- a/Mage.Sets/src/mage/cards/v/ValakutTheMoltenPinnacle.java +++ b/Mage.Sets/src/mage/cards/v/ValakutTheMoltenPinnacle.java @@ -66,7 +66,7 @@ class ValakutTheMoltenPinnacleTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - return game.getBattlefield().count(ValakutTheMoltenPinnacle.filter, getSourceId(), getControllerId(), game) > 5; + return game.getBattlefield().count(ValakutTheMoltenPinnacle.filter, getControllerId(), this, game) > 5; } @Override diff --git a/Mage.Sets/src/mage/cards/v/ValiantChangeling.java b/Mage.Sets/src/mage/cards/v/ValiantChangeling.java index f9ae21df218..0511eddac43 100644 --- a/Mage.Sets/src/mage/cards/v/ValiantChangeling.java +++ b/Mage.Sets/src/mage/cards/v/ValiantChangeling.java @@ -68,7 +68,7 @@ class ValiantChangelingCostReductionEffect extends CostModificationEffectImpl { Set subTypes = new HashSet(); int reductionAmount = 0; for (Permanent permanent : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source, game )) { if (permanent.isAllCreatureTypes(game)) { reductionAmount = 5; diff --git a/Mage.Sets/src/mage/cards/v/ValkiGodOfLies.java b/Mage.Sets/src/mage/cards/v/ValkiGodOfLies.java index 92ae7b85206..78e85638f85 100644 --- a/Mage.Sets/src/mage/cards/v/ValkiGodOfLies.java +++ b/Mage.Sets/src/mage/cards/v/ValkiGodOfLies.java @@ -113,7 +113,7 @@ class ValkiGodOfLiesRevealExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject Valki = game.getObject(source.getSourceId()); + MageObject Valki = game.getObject(source); Set cardsToExile = new LinkedHashSet<>(); if (controller != null && Valki != null) { @@ -231,7 +231,7 @@ class ValkiGodOfLiesCopyExiledEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject Valki = game.getObject(source.getSourceId()); + MageObject Valki = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && Valki != null) { diff --git a/Mage.Sets/src/mage/cards/v/VampireSocialite.java b/Mage.Sets/src/mage/cards/v/VampireSocialite.java index 758ebec5507..2660d5bc732 100644 --- a/Mage.Sets/src/mage/cards/v/VampireSocialite.java +++ b/Mage.Sets/src/mage/cards/v/VampireSocialite.java @@ -99,7 +99,7 @@ class VampireSocialiteReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (OpponentsLostLifeCondition.instance.apply(game, source)) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); - return permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return permanent != null && filter.match(permanent, source.getControllerId(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/v/Vampirism.java b/Mage.Sets/src/mage/cards/v/Vampirism.java index 0e691bf1738..bfcd2f3759a 100644 --- a/Mage.Sets/src/mage/cards/v/Vampirism.java +++ b/Mage.Sets/src/mage/cards/v/Vampirism.java @@ -80,7 +80,7 @@ class VampirismBoostEnchantedEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1; + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game) - 1; if (count > 0) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { diff --git a/Mage.Sets/src/mage/cards/v/VanishIntoMemory.java b/Mage.Sets/src/mage/cards/v/VanishIntoMemory.java index 98023881e88..cc36c1e5411 100644 --- a/Mage.Sets/src/mage/cards/v/VanishIntoMemory.java +++ b/Mage.Sets/src/mage/cards/v/VanishIntoMemory.java @@ -69,7 +69,7 @@ class VanishIntoMemoryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && permanent != null && sourceObject != null) { if (controller.moveCardsToExile(permanent, source, game, true, source.getSourceId(), sourceObject.getIdName())) { controller.drawCards(permanent.getPower().getValue(), source, game); diff --git a/Mage.Sets/src/mage/cards/v/VaporSnare.java b/Mage.Sets/src/mage/cards/v/VaporSnare.java index 2fba8df6579..8d2070ecf4c 100644 --- a/Mage.Sets/src/mage/cards/v/VaporSnare.java +++ b/Mage.Sets/src/mage/cards/v/VaporSnare.java @@ -80,8 +80,8 @@ class VaporSnareEffect extends OneShotEffect { TargetPermanent target = new TargetPermanent(1, 1, filter, false); if (controller != null - && target.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + && target.canChoose(controller.getId(), source, game)) { + controller.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if ( permanent != null ) { diff --git a/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java b/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java index e937485f268..f4f3ae2a841 100644 --- a/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java +++ b/Mage.Sets/src/mage/cards/v/VedalkenEngineer.java @@ -76,7 +76,7 @@ class VedalkenEngineerManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isArtifact(game); } } diff --git a/Mage.Sets/src/mage/cards/v/VenomousBreath.java b/Mage.Sets/src/mage/cards/v/VenomousBreath.java index 4b8321d67cb..8dd6a4fac4c 100644 --- a/Mage.Sets/src/mage/cards/v/VenomousBreath.java +++ b/Mage.Sets/src/mage/cards/v/VenomousBreath.java @@ -100,7 +100,7 @@ class VenomousBreathEffect extends OneShotEffect { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toDestroy = new ArrayList<>(); - for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!creature.getId().equals(targetCreature.getSourceId())) { if (watcher.creatureHasBlockedAttacker(new MageObjectReference(creature, game), targetCreature, game) || watcher.creatureHasBlockedAttacker(targetCreature, new MageObjectReference(creature, game), game)) { toDestroy.add(creature); diff --git a/Mage.Sets/src/mage/cards/v/VenserTheSojourner.java b/Mage.Sets/src/mage/cards/v/VenserTheSojourner.java index 72974ed9c53..5e0d1f4985e 100644 --- a/Mage.Sets/src/mage/cards/v/VenserTheSojourner.java +++ b/Mage.Sets/src/mage/cards/v/VenserTheSojourner.java @@ -83,7 +83,7 @@ class VenserTheSojournerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (getTargetPointer().getFirst(game, source) != null) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/v/VerdantSuccession.java b/Mage.Sets/src/mage/cards/v/VerdantSuccession.java index 4f8bdf989df..b9b251ccc31 100644 --- a/Mage.Sets/src/mage/cards/v/VerdantSuccession.java +++ b/Mage.Sets/src/mage/cards/v/VerdantSuccession.java @@ -117,7 +117,7 @@ class VerdantSuccessionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if(mageObject != null) { permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/v/VesselOfNascency.java b/Mage.Sets/src/mage/cards/v/VesselOfNascency.java index b6dbb4432e8..ab32f4d9eff 100644 --- a/Mage.Sets/src/mage/cards/v/VesselOfNascency.java +++ b/Mage.Sets/src/mage/cards/v/VesselOfNascency.java @@ -78,10 +78,10 @@ class VesselOfNascencyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); - boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0; + boolean properCardFound = cards.count(filterPutInHand, source.getSourceId(), source, game) > 0; if (!cards.isEmpty()) { controller.revealCards(sourceObject.getName(), cards, game); TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand); diff --git a/Mage.Sets/src/mage/cards/v/VesuvanDoppelganger.java b/Mage.Sets/src/mage/cards/v/VesuvanDoppelganger.java index b54036913f8..1c72b7ea6e1 100644 --- a/Mage.Sets/src/mage/cards/v/VesuvanDoppelganger.java +++ b/Mage.Sets/src/mage/cards/v/VesuvanDoppelganger.java @@ -82,8 +82,8 @@ class VesuvanDoppelgangerCopyEffect extends OneShotEffect { target.setRequired(false); target.setNotTarget(true); } - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - controller.choose(Outcome.Copy, target, source.getSourceId(), game); + if (target.canChoose(source.getControllerId(), source, game)) { + controller.choose(Outcome.Copy, target, source, game); Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget()); if (copyFromPermanent != null) { game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new CopyApplier() { diff --git a/Mage.Sets/src/mage/cards/v/VeteranBodyguard.java b/Mage.Sets/src/mage/cards/v/VeteranBodyguard.java index c121568e1bd..2fe265a5b11 100644 --- a/Mage.Sets/src/mage/cards/v/VeteranBodyguard.java +++ b/Mage.Sets/src/mage/cards/v/VeteranBodyguard.java @@ -3,7 +3,6 @@ package mage.cards.v; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.condition.InvertCondition; import mage.abilities.condition.common.SourceTappedCondition; import mage.abilities.decorator.ConditionalPreventionEffect; import mage.abilities.effects.PreventionEffectImpl; @@ -92,7 +91,7 @@ class VeteranBodyguardEffect extends PreventionEffectImpl { && ((DamageEvent) event).isCombatDamage()) { Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (event.getSourceId().equals(permanent.getId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/v/VeteranWarleader.java b/Mage.Sets/src/mage/cards/v/VeteranWarleader.java index c359c93b8af..6f7a380f6f4 100644 --- a/Mage.Sets/src/mage/cards/v/VeteranWarleader.java +++ b/Mage.Sets/src/mage/cards/v/VeteranWarleader.java @@ -86,7 +86,7 @@ class VeteranWarleaderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Choice abilityChoice = new ChoiceImpl(); abilityChoice.setMessage("Choose an ability to add"); diff --git a/Mage.Sets/src/mage/cards/v/VexingShusher.java b/Mage.Sets/src/mage/cards/v/VexingShusher.java index 1b626ac9a24..34c279e0bdb 100644 --- a/Mage.Sets/src/mage/cards/v/VexingShusher.java +++ b/Mage.Sets/src/mage/cards/v/VexingShusher.java @@ -76,7 +76,7 @@ class VexingShusherCantCounterTargetEffect extends ContinuousRuleModifyingEffect @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { return "This spell can't be countered (" + sourceObject.getName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java b/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java index 920a008321e..52b9e34382f 100644 --- a/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java +++ b/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java @@ -141,7 +141,7 @@ class VialSmasherTheFierceEffect extends OneShotEffect { FilterPlaneswalkerPermanent filter = new FilterPlaneswalkerPermanent("a planeswalker controlled by " + opponent.getLogName()); filter.add(new ControllerIdPredicate(opponent.getId())); TargetPermanent target = new TargetPermanent(1, 1, filter, false); - if (target.choose(Outcome.Damage, controller.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Damage, controller.getId(), source.getSourceId(), source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { return permanent.damage(damage, source.getSourceId(), source, game, false, true) > 0; diff --git a/Mage.Sets/src/mage/cards/v/ViashinoBey.java b/Mage.Sets/src/mage/cards/v/ViashinoBey.java index d9dafab5b2f..09c115906fb 100644 --- a/Mage.Sets/src/mage/cards/v/ViashinoBey.java +++ b/Mage.Sets/src/mage/cards/v/ViashinoBey.java @@ -72,9 +72,9 @@ class ViashinoBeyEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); TargetOpponent targetDefender = new TargetOpponent(); if (controller != null) { - game.getBattlefield().getAllActivePermanents(CardType.CREATURE, game).stream().filter((permanent) -> (filter.match(permanent, source.getSourceId(), source.getControllerId(), game))).forEachOrdered((permanent) -> { + game.getBattlefield().getAllActivePermanents(CardType.CREATURE, game).stream().filter((permanent) -> (filter.match(permanent, source.getControllerId(), source, game))).forEachOrdered((permanent) -> { if (game.getOpponents(controller.getId()).size() > 1) { - controller.choose(outcome.Benefit, targetDefender, source.getSourceId(), game); + controller.choose(outcome.Benefit, targetDefender, source, game); } else { targetDefender.add(game.getOpponents(controller.getId()).iterator().next(), game); } diff --git a/Mage.Sets/src/mage/cards/v/VigeanIntuition.java b/Mage.Sets/src/mage/cards/v/VigeanIntuition.java index ee22e295248..253e9c103a1 100644 --- a/Mage.Sets/src/mage/cards/v/VigeanIntuition.java +++ b/Mage.Sets/src/mage/cards/v/VigeanIntuition.java @@ -71,7 +71,7 @@ class VigeanIntuitionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player player = game.getPlayer(source.getControllerId()); if (sourceObject == null || player == null) { return false; diff --git a/Mage.Sets/src/mage/cards/v/VindictiveVampire.java b/Mage.Sets/src/mage/cards/v/VindictiveVampire.java index 7df37bc0d39..380c1998d18 100644 --- a/Mage.Sets/src/mage/cards/v/VindictiveVampire.java +++ b/Mage.Sets/src/mage/cards/v/VindictiveVampire.java @@ -111,7 +111,7 @@ class VindictiveVampireTriggeredAbility extends TriggeredAbilityImpl { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.isDiesEvent()) { if (zEvent.getTarget() != null) { - if (filter.match(zEvent.getTarget(), getSourceId(), getControllerId(), game)) { + if (filter.match(zEvent.getTarget(), getControllerId(), this, game)) { if (setTargetPointer) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId(), game)); diff --git a/Mage.Sets/src/mage/cards/v/VineGecko.java b/Mage.Sets/src/mage/cards/v/VineGecko.java index 420e3b37194..e4ebe9681ab 100644 --- a/Mage.Sets/src/mage/cards/v/VineGecko.java +++ b/Mage.Sets/src/mage/cards/v/VineGecko.java @@ -101,9 +101,7 @@ class VineGeckoWatcher extends Watcher { return; } Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && StaticFilters.FILTER_SPELL_KICKED_A.match( - spell, getSourceId(), getControllerId(), game - )) { + if (spell != null && StaticFilters.FILTER_SPELL_KICKED_A.match(spell, game)) { playerSet.add(event.getPlayerId()); } } diff --git a/Mage.Sets/src/mage/cards/v/VirtussManeuver.java b/Mage.Sets/src/mage/cards/v/VirtussManeuver.java index 8a31c0587e9..5f22150292c 100644 --- a/Mage.Sets/src/mage/cards/v/VirtussManeuver.java +++ b/Mage.Sets/src/mage/cards/v/VirtussManeuver.java @@ -81,7 +81,7 @@ class VirtussManeuverEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(player.getId())); TargetCardInGraveyard target = new TargetCardInGraveyard(filter); getBackMap.put(player.getId(), null); - if (player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + if (player.choose(Outcome.ReturnToHand, target, source, game)) { getBackMap.put(player.getId(), game.getCard(target.getFirstTarget())); } } @@ -101,7 +101,7 @@ class VirtussManeuverEffect extends OneShotEffect { continue; } TargetControlledPermanent target = new TargetControlledPermanent(1, 1, StaticFilters.FILTER_CONTROLLED_A_CREATURE, true); - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } for (UUID permID : perms) { diff --git a/Mage.Sets/src/mage/cards/v/VisionsOfDread.java b/Mage.Sets/src/mage/cards/v/VisionsOfDread.java index f86f6534086..becee61ec98 100644 --- a/Mage.Sets/src/mage/cards/v/VisionsOfDread.java +++ b/Mage.Sets/src/mage/cards/v/VisionsOfDread.java @@ -76,7 +76,7 @@ class VisionsOfDreadEffect extends OneShotEffect { StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD ); target.setNotTarget(true); - opponent.choose(Outcome.Detriment, target, source.getSourceId(), game); + opponent.choose(Outcome.Detriment, target, source, game); return controller.moveCards(game.getCard(target.getFirstTarget()), Zone.BATTLEFIELD, source, game); } } diff --git a/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java b/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java index de41c1c2d23..a3b9d021c43 100644 --- a/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java +++ b/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java @@ -71,13 +71,13 @@ class VisionsOfRuinEffect extends OneShotEffect { Player opponent = game.getPlayer(playerId); if (opponent == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, - source.getSourceId(), playerId, game + playerId, source, game ) < 1) { continue; } TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT); target.setNotTarget(true); - opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + opponent.choose(Outcome.Sacrifice, target, source, game); permanents.add(game.getPermanent(target.getFirstTarget())); } int sacrificed = 0; diff --git a/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java b/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java index ff4b32081b8..67849e1cdca 100644 --- a/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java +++ b/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java @@ -97,7 +97,7 @@ class VodalianWarMachineEffect extends OneShotEffect { if (sourcePermanent != null) { VodalianWarMachineWatcher watcher = game.getState().getWatcher(VodalianWarMachineWatcher.class); if (watcher != null && watcher.getTappedMerfolkIds(sourcePermanent, game) != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (watcher.getTappedMerfolkIds(sourcePermanent, game).contains(new MageObjectReference(permanent, game))) { permanent.destroy(source, game, false); } diff --git a/Mage.Sets/src/mage/cards/v/VoidWinnower.java b/Mage.Sets/src/mage/cards/v/VoidWinnower.java index d985f2957e4..05598b5e0de 100644 --- a/Mage.Sets/src/mage/cards/v/VoidWinnower.java +++ b/Mage.Sets/src/mage/cards/v/VoidWinnower.java @@ -68,7 +68,7 @@ class VoidWinnowerCantCastEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast spells with even mana values (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/v/VoidstoneGargoyle.java b/Mage.Sets/src/mage/cards/v/VoidstoneGargoyle.java index 8596b9668e6..34bf91bd86e 100644 --- a/Mage.Sets/src/mage/cards/v/VoidstoneGargoyle.java +++ b/Mage.Sets/src/mage/cards/v/VoidstoneGargoyle.java @@ -73,7 +73,7 @@ class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifyingEffectI @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast a spell with that name (" + mageObject.getName() + ")."; } @@ -115,7 +115,7 @@ class VoidstoneGargoyleRuleModifyingEffect2 extends ContinuousRuleModifyingEffec @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't activate abilities of sources with that name (" + mageObject.getName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/v/Voidwalk.java b/Mage.Sets/src/mage/cards/v/Voidwalk.java index 680eaa277e9..4e533d37de7 100644 --- a/Mage.Sets/src/mage/cards/v/Voidwalk.java +++ b/Mage.Sets/src/mage/cards/v/Voidwalk.java @@ -61,7 +61,7 @@ class VoidwalkEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && permanent != null && sourceObject != null) { if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) { //create delayed triggered ability diff --git a/Mage.Sets/src/mage/cards/v/VolatileClaws.java b/Mage.Sets/src/mage/cards/v/VolatileClaws.java index 720dc0cd483..f65ab4419a5 100644 --- a/Mage.Sets/src/mage/cards/v/VolatileClaws.java +++ b/Mage.Sets/src/mage/cards/v/VolatileClaws.java @@ -59,7 +59,7 @@ class VolatileClawsEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); for (Permanent perm : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURES, source.getControllerId(), source.getSourceId(), game + StaticFilters.FILTER_CONTROLLED_CREATURES, source.getControllerId(), source, game )) { affectedObjectList.add(new MageObjectReference(perm, game)); } diff --git a/Mage.Sets/src/mage/cards/v/VolcanicVision.java b/Mage.Sets/src/mage/cards/v/VolcanicVision.java index 7db71625e67..996b712a6b7 100644 --- a/Mage.Sets/src/mage/cards/v/VolcanicVision.java +++ b/Mage.Sets/src/mage/cards/v/VolcanicVision.java @@ -80,7 +80,7 @@ class VolcanicVisionReturnToHandTargetEffect extends OneShotEffect { controller.moveCards(card, Zone.HAND, source, game); int damage = card.getManaValue(); if (damage > 0) { - for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { creature.damage(damage, source.getSourceId(), source, game, false, true); } } diff --git a/Mage.Sets/src/mage/cards/v/VoldarenBloodcaster.java b/Mage.Sets/src/mage/cards/v/VoldarenBloodcaster.java index 9620ea4b8bb..4795e38dfb0 100644 --- a/Mage.Sets/src/mage/cards/v/VoldarenBloodcaster.java +++ b/Mage.Sets/src/mage/cards/v/VoldarenBloodcaster.java @@ -107,7 +107,7 @@ class VoldarenBloodcasterTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - return game.getBattlefield().count(filter, getSourceId(), getControllerId(), game) >= 5; + return game.getBattlefield().count(filter, getControllerId(), this, game) >= 5; } @Override diff --git a/Mage.Sets/src/mage/cards/v/VoldarenEstate.java b/Mage.Sets/src/mage/cards/v/VoldarenEstate.java index 0637f52e233..6f42614ec8b 100644 --- a/Mage.Sets/src/mage/cards/v/VoldarenEstate.java +++ b/Mage.Sets/src/mage/cards/v/VoldarenEstate.java @@ -75,7 +75,7 @@ class VoldarenEstateManaBuilder extends ConditionalManaBuilder { @Override public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && mana.getAny() == 0) { game.informPlayers(controller.getLogName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() + " (can only be spent to cast a Vampire spell"); @@ -108,7 +108,7 @@ class VoldarenEstateManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.hasSubtype(SubType.VAMPIRE, game); } return false; diff --git a/Mage.Sets/src/mage/cards/v/VonasHunger.java b/Mage.Sets/src/mage/cards/v/VonasHunger.java index 179fd5d6cae..2a5e2cde9a8 100644 --- a/Mage.Sets/src/mage/cards/v/VonasHunger.java +++ b/Mage.Sets/src/mage/cards/v/VonasHunger.java @@ -82,7 +82,7 @@ class VonasHungerEffect extends OneShotEffect { int numTargets = (game.getBattlefield().countAll(StaticFilters.FILTER_CONTROLLED_CREATURE, player.getId(), game) + 1) / 2; if (numTargets > 0) { TargetPermanent target = new TargetPermanent(numTargets, numTargets, StaticFilters.FILTER_CONTROLLED_CREATURE, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java b/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java index 5f556ed1e54..9302ca3d35a 100644 --- a/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java +++ b/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java @@ -90,7 +90,7 @@ class VraskaSwarmsEminenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent == null || !filter.match(permanent, getControllerId(), this, game)) { return false; } Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId()); diff --git a/Mage.Sets/src/mage/cards/w/WakingTheTrolls.java b/Mage.Sets/src/mage/cards/w/WakingTheTrolls.java index e8753fa5934..5f647571718 100644 --- a/Mage.Sets/src/mage/cards/w/WakingTheTrolls.java +++ b/Mage.Sets/src/mage/cards/w/WakingTheTrolls.java @@ -90,11 +90,11 @@ class WakingTheTrollsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int myLands = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ); int theirLands = game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getFirstTarget(), game + source.getFirstTarget(), source, game ); if (myLands <= theirLands) { return false; diff --git a/Mage.Sets/src/mage/cards/w/WalkingDesecration.java b/Mage.Sets/src/mage/cards/w/WalkingDesecration.java index b6a3d0c6867..b372f53116a 100644 --- a/Mage.Sets/src/mage/cards/w/WalkingDesecration.java +++ b/Mage.Sets/src/mage/cards/w/WalkingDesecration.java @@ -62,7 +62,7 @@ class WalkingDesecrationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null) { if (sourceObject != null) { Choice typeChoice = new ChoiceCreatureType(sourceObject); diff --git a/Mage.Sets/src/mage/cards/w/WallOfCorpses.java b/Mage.Sets/src/mage/cards/w/WallOfCorpses.java index 4b4e73dbc77..5a599138777 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfCorpses.java +++ b/Mage.Sets/src/mage/cards/w/WallOfCorpses.java @@ -1,27 +1,34 @@ package mage.cards.w; -import java.util.UUID; import mage.MageInt; +import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.keyword.DefenderAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author jeffwadsworth */ public final class WallOfCorpses extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creature {this} is blocking"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKED_BY); + } + public WallOfCorpses(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); this.subtype.add(SubType.WALL); @@ -32,14 +39,10 @@ public final class WallOfCorpses extends CardImpl { this.addAbility(DefenderAbility.getInstance()); // {B}, Sacrifice Wall of Corpses: Destroy target creature Wall of Corpses is blocking. - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature Wall of Corpses is blocking"); - filter.add(new BlockedByIdPredicate(this.getId())); - Effect effect = new DestroyTargetEffect(); - SimpleActivatedAbility ability = new SimpleActivatedAbility(effect, new ManaCostsImpl("{B}")); + Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new ManaCostsImpl<>("{B}")); + ability.addTarget(new TargetPermanent(filter)); ability.addCost(new SacrificeSourceCost()); - ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); - } private WallOfCorpses(final WallOfCorpses card) { diff --git a/Mage.Sets/src/mage/cards/w/WallOfNets.java b/Mage.Sets/src/mage/cards/w/WallOfNets.java index ddc5a01be73..3a96cd905bb 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfNets.java +++ b/Mage.Sets/src/mage/cards/w/WallOfNets.java @@ -11,8 +11,9 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.BlockedByIdPredicate; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; import java.util.UUID; @@ -21,6 +22,12 @@ import java.util.UUID; */ public final class WallOfNets extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent("creatures blocked by {this}"); + + static { + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKED_BY); + } + public WallOfNets(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); this.subtype.add(SubType.WALL); @@ -31,12 +38,15 @@ public final class WallOfNets extends CardImpl { this.addAbility(DefenderAbility.getInstance()); // At end of combat, exile all creatures blocked by Wall of Nets. - FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures blocked by {this}"); - filter.add(new BlockedByIdPredicate(this.getId())); - this.addAbility(new EndOfCombatTriggeredAbility(new ExileAllEffect(filter, true), false)); + this.addAbility(new EndOfCombatTriggeredAbility( + new ExileAllEffect(filter, true), false + )); // When Wall of Nets leaves the battlefield, return all cards exiled with Wall of Nets to the battlefield under their owners' control. - this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileEffect(Zone.BATTLEFIELD, "return all cards exiled with {this} to the battlefield under their owners' control"), false)); + this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileEffect( + Zone.BATTLEFIELD, "return all cards exiled with {this} " + + "to the battlefield under their owners' control" + ), false)); } private WallOfNets(final WallOfNets card) { diff --git a/Mage.Sets/src/mage/cards/w/WallOfStolenIdentity.java b/Mage.Sets/src/mage/cards/w/WallOfStolenIdentity.java index fb50a9c4fc2..f2604e1d4a3 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfStolenIdentity.java +++ b/Mage.Sets/src/mage/cards/w/WallOfStolenIdentity.java @@ -94,10 +94,10 @@ class WallOfStolenIdentityCopyEffect extends OneShotEffect { target.setRequired(false); target.setNotTarget(true); } - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } - controller.choose(Outcome.Copy, target, source.getSourceId(), game); + controller.choose(Outcome.Copy, target, source, game); Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget()); if (copyFromPermanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/w/WallOfVipers.java b/Mage.Sets/src/mage/cards/w/WallOfVipers.java index a3c3016fc4b..b82b64302e7 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfVipers.java +++ b/Mage.Sets/src/mage/cards/w/WallOfVipers.java @@ -3,6 +3,7 @@ package mage.cards.w; import java.util.UUID; import mage.MageInt; +import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.DestroySourceEffect; @@ -72,11 +73,11 @@ class WallOfVipersFilter extends FilterCreaturePermanent { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (super.match(permanent, sourceId, playerId, game)) { - SubType subtype = (SubType) game.getState().getValue(sourceId + "_type"); + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (super.match(permanent, playerId, source, game)) { + SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type"); for (CombatGroup combatGroup : game.getCombat().getGroups()) { - if (combatGroup.getBlockers().contains(sourceId) && combatGroup.getAttackers().contains(permanent.getId())) { + if (combatGroup.getBlockers().contains(source.getSourceId()) && combatGroup.getAttackers().contains(permanent.getId())) { return true; } } diff --git a/Mage.Sets/src/mage/cards/w/WandOfDenial.java b/Mage.Sets/src/mage/cards/w/WandOfDenial.java index 525da0ebd20..2e59b5fd9fe 100644 --- a/Mage.Sets/src/mage/cards/w/WandOfDenial.java +++ b/Mage.Sets/src/mage/cards/w/WandOfDenial.java @@ -66,7 +66,7 @@ class WandOfDenialEffect extends OneShotEffect { if (controller != null && targetPlayer != null) { Card card = targetPlayer.getLibrary().getFromTop(game); if (card != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); controller.lookAtCards(sourceObject != null ? sourceObject.getName() : "", new CardsImpl(card), game); if (!card.isLand(game) && controller.canPayLifeCost(source) diff --git a/Mage.Sets/src/mage/cards/w/WarReport.java b/Mage.Sets/src/mage/cards/w/WarReport.java index 1517fc408a3..d876bdf850f 100644 --- a/Mage.Sets/src/mage/cards/w/WarReport.java +++ b/Mage.Sets/src/mage/cards/w/WarReport.java @@ -55,8 +55,8 @@ class WarReportEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int lifeToGain = game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), source.getControllerId(), game); - lifeToGain += game.getBattlefield().count(new FilterArtifactPermanent(), source.getSourceId(), source.getControllerId(), game); + int lifeToGain = game.getBattlefield().count(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game); + lifeToGain += game.getBattlefield().count(new FilterArtifactPermanent(), source.getControllerId(), source, game); player.gainLife(lifeToGain, game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/w/WardOfBones.java b/Mage.Sets/src/mage/cards/w/WardOfBones.java index 5b7ce8d7744..71b3050d7ef 100644 --- a/Mage.Sets/src/mage/cards/w/WardOfBones.java +++ b/Mage.Sets/src/mage/cards/w/WardOfBones.java @@ -71,7 +71,7 @@ class WardOfBonesEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't play the land or cast the spell (" + mageObject.getLogName() + " in play)."; } diff --git a/Mage.Sets/src/mage/cards/w/WarrenWeirding.java b/Mage.Sets/src/mage/cards/w/WarrenWeirding.java index aa88e6a54eb..e8f9730cdc0 100644 --- a/Mage.Sets/src/mage/cards/w/WarrenWeirding.java +++ b/Mage.Sets/src/mage/cards/w/WarrenWeirding.java @@ -83,8 +83,8 @@ class WarrenWeirdingEffect extends OneShotEffect { //A spell or ability could have removed the only legal target this player //had, if thats the case this ability should fizzle. - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(player.getId(), source, game)) { + player.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanent.sacrifice(source, game); diff --git a/Mage.Sets/src/mage/cards/w/WashOut.java b/Mage.Sets/src/mage/cards/w/WashOut.java index de7251549bd..b0a3261c9da 100644 --- a/Mage.Sets/src/mage/cards/w/WashOut.java +++ b/Mage.Sets/src/mage/cards/w/WashOut.java @@ -63,7 +63,7 @@ class WashOutEffect extends OneShotEffect { ObjectColor color = choice.getColor(); FilterPermanent filter = new FilterPermanent(); filter.add(new ColorPredicate(color)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { cardsToReturn.add((Card) permanent); } return controller.moveCards(cardsToReturn, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/w/WasitoraNekoruQueen.java b/Mage.Sets/src/mage/cards/w/WasitoraNekoruQueen.java index f0ec664b390..c6ea65345fd 100644 --- a/Mage.Sets/src/mage/cards/w/WasitoraNekoruQueen.java +++ b/Mage.Sets/src/mage/cards/w/WasitoraNekoruQueen.java @@ -81,7 +81,7 @@ class WasitoraNekoruQueenEffect extends OneShotEffect { FilterControlledPermanent filter = new FilterControlledPermanent("creature"); filter.add(CardType.CREATURE.getPredicate()); TargetPermanent target = new TargetPermanent(1, 1, filter, true); - if (damagedPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) { + if (damagedPlayer.choose(Outcome.Sacrifice, target, source, game)) { Permanent objectToBeSacrificed = game.getPermanent(target.getFirstTarget()); if (objectToBeSacrificed != null) { if (objectToBeSacrificed.sacrifice(source, game)) { diff --git a/Mage.Sets/src/mage/cards/w/Watchdog.java b/Mage.Sets/src/mage/cards/w/Watchdog.java index f32ef7b8d4a..677527204fe 100644 --- a/Mage.Sets/src/mage/cards/w/Watchdog.java +++ b/Mage.Sets/src/mage/cards/w/Watchdog.java @@ -3,8 +3,8 @@ package mage.cards.w; import java.util.UUID; import mage.MageInt; +import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.condition.InvertCondition; import mage.abilities.condition.common.SourceTappedCondition; import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.common.combat.BlocksIfAbleSourceEffect; @@ -65,8 +65,8 @@ class WatchdogFilter extends FilterAttackingCreature { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (!super.match(permanent, sourceId, playerId, game)) { + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { + if (!super.match(permanent, playerId, source, game)) { return false; } diff --git a/Mage.Sets/src/mage/cards/w/WaveOfReckoning.java b/Mage.Sets/src/mage/cards/w/WaveOfReckoning.java index 0903372a6cf..f45bc486d92 100644 --- a/Mage.Sets/src/mage/cards/w/WaveOfReckoning.java +++ b/Mage.Sets/src/mage/cards/w/WaveOfReckoning.java @@ -53,7 +53,7 @@ class WaveOfReckoningDamageEffect extends OneShotEffect { FilterPermanent filter = new FilterPermanent(); filter.add(CardType.CREATURE.getPredicate()); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { int amount = permanent.getPower().getValue(); permanent.damage(amount, permanent.getId(), source, game, false, true); } diff --git a/Mage.Sets/src/mage/cards/w/WaywardGuideBeast.java b/Mage.Sets/src/mage/cards/w/WaywardGuideBeast.java index fedb8cd2510..49a34a8280b 100644 --- a/Mage.Sets/src/mage/cards/w/WaywardGuideBeast.java +++ b/Mage.Sets/src/mage/cards/w/WaywardGuideBeast.java @@ -72,14 +72,14 @@ class WaywardGuideBeastEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player == null || game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - source.getSourceId(), source.getControllerId(), game + source.getControllerId(), source, game ) == 0) { return false; } TargetPermanent target = new TargetPermanent( 1, 1, StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, true ); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/w/WebOfInertia.java b/Mage.Sets/src/mage/cards/w/WebOfInertia.java index 441254f5950..deee9777e48 100644 --- a/Mage.Sets/src/mage/cards/w/WebOfInertia.java +++ b/Mage.Sets/src/mage/cards/w/WebOfInertia.java @@ -54,7 +54,7 @@ class WebOfInertiaEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard()); if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Detriment, "Exile a card from your graveyard?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/w/WeddingRing.java b/Mage.Sets/src/mage/cards/w/WeddingRing.java index d0bf4debbf2..efe1a89df41 100644 --- a/Mage.Sets/src/mage/cards/w/WeddingRing.java +++ b/Mage.Sets/src/mage/cards/w/WeddingRing.java @@ -124,7 +124,7 @@ class WeddingRingTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (!game.isActivePlayer(event.getPlayerId()) || !game.getOpponents(getControllerId()).contains(event.getPlayerId()) - || !game.getBattlefield().contains(filter, getSourceId(), event.getPlayerId(), game, 1)) { + || !game.getBattlefield().contains(filter, getSourceId(), event.getPlayerId(), this, game, 1)) { return false; } this.getEffects().clear(); diff --git a/Mage.Sets/src/mage/cards/w/WeiAssassins.java b/Mage.Sets/src/mage/cards/w/WeiAssassins.java index 9d0a01df27b..b0b4930a988 100644 --- a/Mage.Sets/src/mage/cards/w/WeiAssassins.java +++ b/Mage.Sets/src/mage/cards/w/WeiAssassins.java @@ -76,8 +76,8 @@ class WeiAssassinsEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); filter.add(new ControllerIdPredicate(player.getId())); Target target = new TargetPermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { - while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) { + if (target.canChoose(player.getId(), source, game)) { + while (!target.isChosen() && target.canChoose(player.getId(), source, game) && player.canRespond()) { player.chooseTarget(Outcome.DestroyPermanent, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/w/WeightOfConscience.java b/Mage.Sets/src/mage/cards/w/WeightOfConscience.java index e0ff6e12b24..f4e6c265ea0 100644 --- a/Mage.Sets/src/mage/cards/w/WeightOfConscience.java +++ b/Mage.Sets/src/mage/cards/w/WeightOfConscience.java @@ -77,7 +77,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Player player = game.getPlayer(sourceControllerId); Set possibleTargets = new HashSet<>(0); if (player == null) { @@ -85,7 +85,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { } // Choosing first target if (this.getTargets().isEmpty()) { - List permanentList = game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, sourceId, game); + List permanentList = game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, source, game); if (permanentList.size() < 2) { return possibleTargets; } @@ -96,7 +96,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { } FilterPermanent filter = filterUntapped.copy(); filter.add(new SharesCreatureTypePredicate(permanent)); - if (game.getBattlefield().count(filter, sourceId, sourceControllerId, game) > 1) { + if (game.getBattlefield().count(filter, sourceControllerId, source, game) > 1) { possibleTargets.add(permanent.getId()); } } @@ -108,7 +108,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { } FilterPermanent filter = filterUntapped.copy(); filter.add(new SharesCreatureTypePredicate(firstTargetCreature)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, source, game)) { if (permanent != null) { possibleTargets.add(permanent.getId()); } @@ -118,9 +118,9 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - for (Permanent permanent1 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, sourceId, game)) { - for (Permanent permanent2 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, sourceId, game)) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + for (Permanent permanent1 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, source, game)) { + for (Permanent permanent2 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, source, game)) { if (!Objects.equals(permanent1, permanent2) && permanent1.shareCreatureTypes(game, permanent2)) { return true; } @@ -139,7 +139,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { return false; } if (this.getTargets().isEmpty()) { - List permanentList = game.getBattlefield().getActivePermanents(filterUntapped, source.getControllerId(), source.getSourceId(), game); + List permanentList = game.getBattlefield().getActivePermanents(filterUntapped, source.getControllerId(), source, game); if (permanentList.size() < 2) { return false; } @@ -149,7 +149,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { } FilterPermanent filter = filterUntapped.copy(); filter.add(new SharesCreatureTypePredicate(permanent)); - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 1) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) > 1) { return true; } } diff --git a/Mage.Sets/src/mage/cards/w/WeirdHarvest.java b/Mage.Sets/src/mage/cards/w/WeirdHarvest.java index d77c0e7170b..7ff1551ccbe 100644 --- a/Mage.Sets/src/mage/cards/w/WeirdHarvest.java +++ b/Mage.Sets/src/mage/cards/w/WeirdHarvest.java @@ -60,7 +60,7 @@ class WeirdHarvestEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { int xValue = source.getManaCostsToPay().getX(); if (xValue > 0) { diff --git a/Mage.Sets/src/mage/cards/w/WheelOfSunAndMoon.java b/Mage.Sets/src/mage/cards/w/WheelOfSunAndMoon.java index 0396b8ead84..8bc1dd2da75 100644 --- a/Mage.Sets/src/mage/cards/w/WheelOfSunAndMoon.java +++ b/Mage.Sets/src/mage/cards/w/WheelOfSunAndMoon.java @@ -96,7 +96,7 @@ class WheelOfSunAndMoonEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Card card = game.getCard(event.getTargetId()); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java b/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java index 0bc489b16b0..c996a66bc54 100644 --- a/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java +++ b/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java @@ -70,7 +70,7 @@ class WhenFluffyBunniesAttackEffect extends OneShotEffect { if (controller != null && permanent != null && controller.choose(outcome, choice, game)) { if (!game.isSimulation()) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice()); } diff --git a/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java b/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java index a376107ca62..d90bd674863 100644 --- a/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java +++ b/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java @@ -177,11 +177,11 @@ class TargetSecondPilePermanent extends TargetPermanent { } @Override - public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) { + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game, boolean flag) { if (firstPile.contains(id)) { return false; } - return super.canTarget(controllerId, id, sourceId, game, flag); + return super.canTarget(controllerId, id, source, game, flag); } @Override diff --git a/Mage.Sets/src/mage/cards/w/WhipVine.java b/Mage.Sets/src/mage/cards/w/WhipVine.java index 35c2370227d..6c87a2c6d6f 100644 --- a/Mage.Sets/src/mage/cards/w/WhipVine.java +++ b/Mage.Sets/src/mage/cards/w/WhipVine.java @@ -1,7 +1,5 @@ - package mage.cards.w; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -16,20 +14,29 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; -import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author LoneFox */ public final class WhipVine extends CardImpl { + private static final FilterPermanent filter + = new FilterCreaturePermanent("creature with flying blocked by {this}"); + + static { + filter.add(new AbilityPredicate(FlyingAbility.class)); + filter.add(BlockingOrBlockedBySourcePredicate.BLOCKED_BY); + } + public WhipVine(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); this.subtype.add(SubType.PLANT); this.subtype.add(SubType.WALL); this.power = new MageInt(1); @@ -37,17 +44,17 @@ public final class WhipVine extends CardImpl { // Defender this.addAbility(DefenderAbility.getInstance()); + // Reach this.addAbility(ReachAbility.getInstance()); + // You may choose not to untap Whip Vine during your untap step. this.addAbility(new SkipUntapOptionalAbility()); + // {tap}: Tap target creature with flying blocked by Whip Vine. That creature doesn't untap during its controller's untap step for as long as Whip Vine remains tapped. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TapTargetEffect(), new TapSourceCost()); - FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with flying blocked by {this}"); - filter.add(new AbilityPredicate(FlyingAbility.class)); - filter.add(new BlockedByIdPredicate(this.getId())); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new SimpleActivatedAbility(new TapTargetEffect(), new TapSourceCost()); ability.addEffect(new DontUntapAsLongAsSourceTappedEffect()); + ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java b/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java index f42b3b81156..656371315c7 100644 --- a/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java +++ b/Mage.Sets/src/mage/cards/w/WhiptongueHydra.java @@ -76,7 +76,7 @@ class WhiptongueHydraEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int destroyedPermanents = 0; destroyedPermanents = game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ).stream().filter( (permanent) -> (permanent.destroy(source, game, false)) ).map((_item) -> 1).reduce(destroyedPermanents, Integer::sum); diff --git a/Mage.Sets/src/mage/cards/w/WickedGuardian.java b/Mage.Sets/src/mage/cards/w/WickedGuardian.java index cb562cf9af9..1e0063ad7d7 100644 --- a/Mage.Sets/src/mage/cards/w/WickedGuardian.java +++ b/Mage.Sets/src/mage/cards/w/WickedGuardian.java @@ -75,11 +75,11 @@ class WickedGuardianEffect extends OneShotEffect { if (player == null) { return false; } - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0) { + if (game.getBattlefield().count(filter, source.getControllerId(), source, game) == 0) { return false; } TargetPermanent target = new TargetPermanent(0, 1, filter, true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/w/WidespreadPanic.java b/Mage.Sets/src/mage/cards/w/WidespreadPanic.java index 4aa1d4ad436..51aa73afe69 100644 --- a/Mage.Sets/src/mage/cards/w/WidespreadPanic.java +++ b/Mage.Sets/src/mage/cards/w/WidespreadPanic.java @@ -14,7 +14,6 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.common.TargetCardInHand; import mage.target.targetpointer.FixedTarget; @@ -104,7 +103,7 @@ class WidespreadPanicEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand(); target.setNotTarget(true); target.setTargetName("a card from your hand to put on top of your library"); - shuffler.choose(Outcome.Detriment, target, source.getSourceId(), game); + shuffler.choose(Outcome.Detriment, target, source, game); Card card = shuffler.getHand().get(target.getFirstTarget(), game); if (card != null) { shuffler.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false); diff --git a/Mage.Sets/src/mage/cards/w/WightOfPrecinctSix.java b/Mage.Sets/src/mage/cards/w/WightOfPrecinctSix.java index acb349c8df2..09f92fd5e21 100644 --- a/Mage.Sets/src/mage/cards/w/WightOfPrecinctSix.java +++ b/Mage.Sets/src/mage/cards/w/WightOfPrecinctSix.java @@ -71,7 +71,7 @@ class CardsInOpponentGraveyardsCount implements DynamicValue { for (UUID playerUUID : game.getOpponents(sourceAbility.getControllerId())) { Player player = game.getPlayer(playerUUID); if (player != null) { - amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + amount += player.getGraveyard().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } } return amount; diff --git a/Mage.Sets/src/mage/cards/w/WindsOfAbandon.java b/Mage.Sets/src/mage/cards/w/WindsOfAbandon.java index 68d31a6c17d..c4ee3546c42 100644 --- a/Mage.Sets/src/mage/cards/w/WindsOfAbandon.java +++ b/Mage.Sets/src/mage/cards/w/WindsOfAbandon.java @@ -123,7 +123,7 @@ class WindsOfAbandonOverloadEffect extends OneShotEffect { } Map playerMap = new HashMap<>(); CardsImpl cards = new CardsImpl(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source, game)) { int count = playerMap.getOrDefault(permanent.getControllerId(), 0); playerMap.put(permanent.getControllerId(), count + 1); cards.add(permanent); diff --git a/Mage.Sets/src/mage/cards/w/WintersRest.java b/Mage.Sets/src/mage/cards/w/WintersRest.java index 546d6443a72..b26c180c8d5 100644 --- a/Mage.Sets/src/mage/cards/w/WintersRest.java +++ b/Mage.Sets/src/mage/cards/w/WintersRest.java @@ -85,7 +85,7 @@ class WintersRestEffect extends DontUntapInControllersUntapStepEnchantedEffect { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ).isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/cards/w/WishclawTalisman.java b/Mage.Sets/src/mage/cards/w/WishclawTalisman.java index 5a3264ba9cd..45cccbf08a1 100644 --- a/Mage.Sets/src/mage/cards/w/WishclawTalisman.java +++ b/Mage.Sets/src/mage/cards/w/WishclawTalisman.java @@ -92,7 +92,7 @@ class WishclawTalismanEffect extends OneShotEffect { } TargetPlayer target = new TargetOpponent(); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } ContinuousEffect continuousEffect diff --git a/Mage.Sets/src/mage/cards/w/WitherbloomCommand.java b/Mage.Sets/src/mage/cards/w/WitherbloomCommand.java index 8ebc8f61768..36bc8b57ba2 100644 --- a/Mage.Sets/src/mage/cards/w/WitherbloomCommand.java +++ b/Mage.Sets/src/mage/cards/w/WitherbloomCommand.java @@ -107,10 +107,10 @@ class WitherbloomCommandEffect extends OneShotEffect { } TargetCard target = new TargetCardInYourGraveyard(1, StaticFilters.FILTER_CARD_LAND); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); return card != null && player.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/w/WoebringerDemon.java b/Mage.Sets/src/mage/cards/w/WoebringerDemon.java index 1df06a583ea..16a418ac65e 100644 --- a/Mage.Sets/src/mage/cards/w/WoebringerDemon.java +++ b/Mage.Sets/src/mage/cards/w/WoebringerDemon.java @@ -75,7 +75,7 @@ class WoebringerDemonEffect extends OneShotEffect { if (currentPlayer != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game)) { + if (target.canChoose(currentPlayer.getId(), source, game)) { currentPlayer.chooseTarget(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/w/WojekApothecary.java b/Mage.Sets/src/mage/cards/w/WojekApothecary.java index b0f4c0d3a8e..a02e2e48d07 100644 --- a/Mage.Sets/src/mage/cards/w/WojekApothecary.java +++ b/Mage.Sets/src/mage/cards/w/WojekApothecary.java @@ -80,7 +80,7 @@ class WojekApothecaryEffect extends OneShotEffect { Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); if (target != null) { ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (permanent.getColor(game).shares(color)) { ContinuousEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, 1); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/w/WojekSiren.java b/Mage.Sets/src/mage/cards/w/WojekSiren.java index 4979664e688..7b12d852118 100644 --- a/Mage.Sets/src/mage/cards/w/WojekSiren.java +++ b/Mage.Sets/src/mage/cards/w/WojekSiren.java @@ -57,7 +57,7 @@ class WojekSirenBoostEffect extends ContinuousEffectImpl { if (target != null) { affectedObjectList.add(new MageObjectReference(target, game)); ObjectColor color = target.getColor(game); - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) { if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) { affectedObjectList.add(new MageObjectReference(permanent, game)); } diff --git a/Mage.Sets/src/mage/cards/w/WoodElemental.java b/Mage.Sets/src/mage/cards/w/WoodElemental.java index 610f4ee01d9..3fa2db35426 100644 --- a/Mage.Sets/src/mage/cards/w/WoodElemental.java +++ b/Mage.Sets/src/mage/cards/w/WoodElemental.java @@ -84,7 +84,7 @@ class WoodElementalEffect extends OneShotEffect { Card sourceCard = game.getCard(source.getSourceId()); if (controller != null && sourceCard != null) { Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseTarget(Outcome.Detriment, target, source, game)) { if (!target.getTargets().isEmpty()) { int sacrificedForests = target.getTargets().size(); diff --git a/Mage.Sets/src/mage/cards/w/WordOfCommand.java b/Mage.Sets/src/mage/cards/w/WordOfCommand.java index 0bb6b35bbd3..b6a27986f67 100644 --- a/Mage.Sets/src/mage/cards/w/WordOfCommand.java +++ b/Mage.Sets/src/mage/cards/w/WordOfCommand.java @@ -74,7 +74,7 @@ class WordOfCommandEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player sourceController = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Card card = null; if (sourceController != null && targetPlayer != null && sourceObject != null) { Player controller = null; diff --git a/Mage.Sets/src/mage/cards/w/WordsOfWind.java b/Mage.Sets/src/mage/cards/w/WordsOfWind.java index 4544a0e2d9a..57cc1af92fe 100644 --- a/Mage.Sets/src/mage/cards/w/WordsOfWind.java +++ b/Mage.Sets/src/mage/cards/w/WordsOfWind.java @@ -68,7 +68,7 @@ class WordsOfWindEffect extends ReplacementEffectImpl { TargetControlledPermanent target = new TargetControlledPermanent(); List liste = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), playerId, game); if (!liste.isEmpty()) { - while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + while (!player.choose(Outcome.ReturnToHand, target, source, game)) { if (!player.canRespond()) { return false; } diff --git a/Mage.Sets/src/mage/cards/w/WorkshopAssistant.java b/Mage.Sets/src/mage/cards/w/WorkshopAssistant.java index 2eb034b5e2b..c9ab1d82513 100644 --- a/Mage.Sets/src/mage/cards/w/WorkshopAssistant.java +++ b/Mage.Sets/src/mage/cards/w/WorkshopAssistant.java @@ -12,7 +12,7 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.common.FilterArtifactCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetCardInYourGraveyard; /** @@ -24,7 +24,7 @@ public final class WorkshopAssistant extends CardImpl { private static final FilterArtifactCard filter = new FilterArtifactCard("another target artifact card from your graveyard"); static { - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); } public WorkshopAssistant(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/w/WorldBottlingKit.java b/Mage.Sets/src/mage/cards/w/WorldBottlingKit.java index 67c9e15a143..a5ab1ecd19f 100644 --- a/Mage.Sets/src/mage/cards/w/WorldBottlingKit.java +++ b/Mage.Sets/src/mage/cards/w/WorldBottlingKit.java @@ -77,7 +77,7 @@ class WorldBottlingKitEffect extends OneShotEffect { game.informPlayers(controller.getLogName() + " has chosen set " + setChosen); FilterPermanent filter = new FilterPermanent(); filter.add(Predicates.not(Predicates.and(CardType.LAND.getPredicate(), SuperType.BASIC.getPredicate()))); - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { if (permanent.getExpansionSetCode().equals(setChosen)) { controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true); diff --git a/Mage.Sets/src/mage/cards/w/WorldQueller.java b/Mage.Sets/src/mage/cards/w/WorldQueller.java index b282544c392..b5767f69e2b 100644 --- a/Mage.Sets/src/mage/cards/w/WorldQueller.java +++ b/Mage.Sets/src/mage/cards/w/WorldQueller.java @@ -118,8 +118,8 @@ class WorldQuellerEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player2 = game.getPlayer(playerId); - if (player2 != null && target.canChoose(source.getSourceId(), playerId, game)) { - while (player2.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), playerId, game)) { + if (player2 != null && target.canChoose(playerId, source, game)) { + while (player2.canRespond() && !target.isChosen() && target.canChoose(playerId, source, game)) { player2.chooseTarget(Outcome.Sacrifice, target, source, game); } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/w/Worldfire.java b/Mage.Sets/src/mage/cards/w/Worldfire.java index 8fed1fa6e7a..bf3e26a9a2e 100644 --- a/Mage.Sets/src/mage/cards/w/Worldfire.java +++ b/Mage.Sets/src/mage/cards/w/Worldfire.java @@ -57,7 +57,7 @@ class WorldfireEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.moveToExile(null, "", source, game); } for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/w/WorldgorgerDragon.java b/Mage.Sets/src/mage/cards/w/WorldgorgerDragon.java index b86c549b73d..a595c3ede52 100644 --- a/Mage.Sets/src/mage/cards/w/WorldgorgerDragon.java +++ b/Mage.Sets/src/mage/cards/w/WorldgorgerDragon.java @@ -89,7 +89,7 @@ class WorldgorgerDragonEntersEffect extends OneShotEffect { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); if (exileId != null) { Set cardsToExile = new LinkedHashSet<>(); - cardsToExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)); + cardsToExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)); controller.moveCardsToExile(cardsToExile, source, game, true, exileId, sourceObject.getIdName()); return true; } diff --git a/Mage.Sets/src/mage/cards/w/Worldpurge.java b/Mage.Sets/src/mage/cards/w/Worldpurge.java index cf2bf1dfcb8..d2f119de674 100644 --- a/Mage.Sets/src/mage/cards/w/Worldpurge.java +++ b/Mage.Sets/src/mage/cards/w/Worldpurge.java @@ -63,10 +63,10 @@ class WorldpurgeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Set allPermanents = new HashSet<>(); - allPermanents.addAll(game.getBattlefield().getActivePermanents(new FilterPermanent(), source.getControllerId(), source.getSourceId(), game)); + allPermanents.addAll(game.getBattlefield().getActivePermanents(new FilterPermanent(), source.getControllerId(), source, game)); controller.moveCards(allPermanents, Zone.HAND, source, game, false, false, true, null); game.informPlayers(sourceObject.getLogName() + " - All permanents returned to owners' hands"); @@ -78,7 +78,7 @@ class WorldpurgeEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand(0, numberInHand, new FilterCard("cards to keep in hand")); Cards cardsToLibrary = new CardsImpl(); cardsToLibrary.addAll(player.getHand()); - if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (player.choose(Outcome.Benefit, target, source, game)) { cardsToLibrary.removeAll(target.getTargets()); } player.shuffleCardsToLibrary(cardsToLibrary, game, source); diff --git a/Mage.Sets/src/mage/cards/w/WormfangDrake.java b/Mage.Sets/src/mage/cards/w/WormfangDrake.java index 3d839dddab0..fed9e9ba016 100644 --- a/Mage.Sets/src/mage/cards/w/WormfangDrake.java +++ b/Mage.Sets/src/mage/cards/w/WormfangDrake.java @@ -82,7 +82,7 @@ class WormfangDrakeExileCost extends CostImpl { Player controller = game.getPlayer(controllerId); MageObject sourceObject = ability.getSourceObject(game); if (controller != null && sourceObject != null) { - if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { UUID exileId = CardUtil.getExileZoneId(game, ability.getSourceId(), ability.getSourceObjectZoneChangeCounter()); for (UUID targetId : targets.get(0).getTargets()) { Permanent permanent = game.getPermanent(targetId); @@ -98,7 +98,7 @@ class WormfangDrakeExileCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage.Sets/src/mage/cards/w/Worship.java b/Mage.Sets/src/mage/cards/w/Worship.java index 7b30f28a871..9189e3d6e32 100644 --- a/Mage.Sets/src/mage/cards/w/Worship.java +++ b/Mage.Sets/src/mage/cards/w/Worship.java @@ -62,7 +62,7 @@ class WorshipReplacementEffect extends ReplacementEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && (controller.getLife() - event.getAmount()) < 1 - && game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), event.getPlayerId(), game) > 0 + && game.getBattlefield().count(new FilterControlledCreaturePermanent(), event.getPlayerId(), source, game) > 0 ) { event.setAmount(controller.getLife() - 1); } diff --git a/Mage.Sets/src/mage/cards/w/WrenchMind.java b/Mage.Sets/src/mage/cards/w/WrenchMind.java index 27b335baff0..0108204e86b 100644 --- a/Mage.Sets/src/mage/cards/w/WrenchMind.java +++ b/Mage.Sets/src/mage/cards/w/WrenchMind.java @@ -65,7 +65,7 @@ class WrenchMindEffect extends OneShotEffect { return !targetPlayer.discard(2, false, false, source, game).isEmpty(); } TargetDiscard target = new TargetDiscard(StaticFilters.FILTER_CARD_ARTIFACT_AN, targetPlayer.getId()); - targetPlayer.choose(Outcome.Discard, target, source.getSourceId(), game); + targetPlayer.choose(Outcome.Discard, target, source, game); Card card = targetPlayer.getHand().get(target.getFirstTarget(), game); if (card != null && targetPlayer.discard(card, false, source, game)) { return true; diff --git a/Mage.Sets/src/mage/cards/w/WretchedBanquet.java b/Mage.Sets/src/mage/cards/w/WretchedBanquet.java index d67316a87ad..b6221a53ece 100644 --- a/Mage.Sets/src/mage/cards/w/WretchedBanquet.java +++ b/Mage.Sets/src/mage/cards/w/WretchedBanquet.java @@ -60,7 +60,7 @@ class WretchedBanquetEffect extends OneShotEffect { if (targetCreature == null) { return false; } - List creatures = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game); + List creatures = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game); int minPower = targetCreature.getPower().getValue() + 1; for (Permanent creature : creatures) { diff --git a/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java b/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java index 2823f77cc10..5e0c8e4c3a4 100644 --- a/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java +++ b/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java @@ -61,7 +61,7 @@ class WriteIntoBeingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2)); controller.lookAtCards(source, null, cards, game); diff --git a/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java b/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java index 5fe1b5ac9df..5e70924a501 100644 --- a/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java +++ b/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java @@ -88,7 +88,7 @@ class XanatharGuildKingpinRuleModifyingEffect extends ContinuousRuleModifyingEff @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (targetPlayer != null && mageObject != null) { return "This turn you can't cast spells" + " (" + mageObject.getLogName() + ')'; diff --git a/Mage.Sets/src/mage/cards/x/XathridDemon.java b/Mage.Sets/src/mage/cards/x/XathridDemon.java index 503eae7aa9c..bf58c988959 100644 --- a/Mage.Sets/src/mage/cards/x/XathridDemon.java +++ b/Mage.Sets/src/mage/cards/x/XathridDemon.java @@ -84,8 +84,8 @@ class XathridDemonEffect extends OneShotEffect { filter.add(AnotherPredicate.instance); Target target = new TargetControlledCreaturePermanent(1, 1, filter, true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + if (target.canChoose(controller.getId(), source, game)) { + controller.choose(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { int amount = permanent.getPower().getValue(); diff --git a/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java b/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java index 05c76f1fd23..80e57758801 100644 --- a/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java +++ b/Mage.Sets/src/mage/cards/x/XenagosTheReveler.java @@ -75,7 +75,7 @@ class XenagosManaEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game); + int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getControllerId(), source, game); if (x == 0) { return false; } @@ -123,7 +123,7 @@ class XenagosExileEffect extends OneShotEffect { TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.EXILED, filter); target1.setNotTarget(true); if (!exiledCards.isEmpty() - && target1.canChoose(source.getSourceId(), source.getControllerId(), game) + && target1.canChoose(source.getControllerId(), source, game) && controller.choose(Outcome.PutCardInPlay, exiledCards, target1, game)) { controller.moveCards(new CardsImpl(target1.getTargets()), Zone.BATTLEFIELD, source, game); } diff --git a/Mage.Sets/src/mage/cards/y/YannikScavengingSentinel.java b/Mage.Sets/src/mage/cards/y/YannikScavengingSentinel.java index c0f1d664a7e..f5140515d9d 100644 --- a/Mage.Sets/src/mage/cards/y/YannikScavengingSentinel.java +++ b/Mage.Sets/src/mage/cards/y/YannikScavengingSentinel.java @@ -91,12 +91,12 @@ class YannikScavengingSentinelEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player == null || sourcePermanent == null - || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) { + || game.getBattlefield().count(filter, source.getControllerId(), source, game) < 1) { return false; } TargetPermanent target = new TargetPermanent(filter); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.choose(outcome, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/y/YasharnImplacableEarth.java b/Mage.Sets/src/mage/cards/y/YasharnImplacableEarth.java index 14e22f0f5db..5b042531e79 100644 --- a/Mage.Sets/src/mage/cards/y/YasharnImplacableEarth.java +++ b/Mage.Sets/src/mage/cards/y/YasharnImplacableEarth.java @@ -135,7 +135,7 @@ class YasharnImplacableEarthEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "Players can't pay life or sacrifice nonland permanents to cast spells or activate abilities. (" + mageObject.getIdName() + ")."; } diff --git a/Mage.Sets/src/mage/cards/y/YasovaDragonclaw.java b/Mage.Sets/src/mage/cards/y/YasovaDragonclaw.java index 13fd40aa40d..8abb6bee7d2 100644 --- a/Mage.Sets/src/mage/cards/y/YasovaDragonclaw.java +++ b/Mage.Sets/src/mage/cards/y/YasovaDragonclaw.java @@ -75,7 +75,7 @@ class YasovaDragonclawPowerLessThanSourcePredicate implements ObjectSourcePlayer @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getPower().getValue() < sourcePermanent.getPower().getValue(); } diff --git a/Mage.Sets/src/mage/cards/y/YorionSkyNomad.java b/Mage.Sets/src/mage/cards/y/YorionSkyNomad.java index 66b3843287d..2683adb3849 100644 --- a/Mage.Sets/src/mage/cards/y/YorionSkyNomad.java +++ b/Mage.Sets/src/mage/cards/y/YorionSkyNomad.java @@ -111,7 +111,7 @@ class YorionSkyNomadEffect extends OneShotEffect { return false; } TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); Set toExile = target.getTargets().stream().map(game::getPermanent).collect(Collectors.toSet()); UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); controller.moveCardsToExile(toExile, source, game, true, exileId, sourceObject.getIdName()); diff --git a/Mage.Sets/src/mage/cards/z/ZadaHedronGrinder.java b/Mage.Sets/src/mage/cards/z/ZadaHedronGrinder.java index b83a15a650a..6f7c87ff550 100644 --- a/Mage.Sets/src/mage/cards/z/ZadaHedronGrinder.java +++ b/Mage.Sets/src/mage/cards/z/ZadaHedronGrinder.java @@ -140,7 +140,7 @@ class ZadaHedronGrinderCopySpellEffect extends CopySpellForEachItCouldTargetEffe return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - player.getId(), source.getSourceId(), game + player.getId(), source, game ).stream() .filter(Objects::nonNull) .filter(p -> !p.equals(permanent)) diff --git a/Mage.Sets/src/mage/cards/z/ZaraRenegadeRecruiter.java b/Mage.Sets/src/mage/cards/z/ZaraRenegadeRecruiter.java index a8689d03d4e..f649003e831 100644 --- a/Mage.Sets/src/mage/cards/z/ZaraRenegadeRecruiter.java +++ b/Mage.Sets/src/mage/cards/z/ZaraRenegadeRecruiter.java @@ -101,7 +101,7 @@ class ZaraRenegadeRecruiterEffect extends OneShotEffect { UUID defenderId; if (game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER, - source.getSourceId(), player.getId(), game + player.getId(), source, game ) < 1) { defenderId = player.getId(); } else { @@ -112,7 +112,7 @@ class ZaraRenegadeRecruiterEffect extends OneShotEffect { filter.getPermanentFilter().add(new ControllerIdPredicate(player.getId())); TargetPlayerOrPlaneswalker target = new TargetPlayerOrPlaneswalker(filter); target.setNotTarget(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); defenderId = target.getFirstTarget(); } game.getCombat().addAttackerToCombat(permanent.getId(), defenderId, game); diff --git a/Mage.Sets/src/mage/cards/z/ZndrspltsJudgment.java b/Mage.Sets/src/mage/cards/z/ZndrspltsJudgment.java index b68990b4ec7..c211e1ac14c 100644 --- a/Mage.Sets/src/mage/cards/z/ZndrspltsJudgment.java +++ b/Mage.Sets/src/mage/cards/z/ZndrspltsJudgment.java @@ -73,7 +73,7 @@ class ZndrspltsJudgmentEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); filter.add(new ControllerIdPredicate(player.getId())); TargetCreaturePermanent target = new TargetCreaturePermanent(filter); - if (!player.choose(Outcome.Copy, target, source.getSourceId(), game)) { + if (!player.choose(Outcome.Copy, target, source, game)) { continue; } Effect effect = new CreateTokenCopyTargetEffect(player.getId()); @@ -84,7 +84,7 @@ class ZndrspltsJudgmentEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); filter.add(new ControllerIdPredicate(player.getId())); TargetCreaturePermanent target = new TargetCreaturePermanent(filter); - if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { + if (!player.choose(Outcome.ReturnToHand, target, source, game)) { continue; } Effect effect = new ReturnToHandTargetEffect(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/tmp/KnightOfDuskTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/tmp/KnightOfDuskTest.java new file mode 100644 index 00000000000..8240c3592c9 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/tmp/KnightOfDuskTest.java @@ -0,0 +1,86 @@ +package org.mage.test.cards.single.tmp; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class KnightOfDuskTest extends CardTestPlayerBase { + private static final String knight = "Knight of Dusk"; + private static final String lion = "Silvercoat Lion"; + private static final String murder = "Murder"; + private static final String blink = "Momentary Blink"; + + @Test + public void testRegular() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Zone.BATTLEFIELD, playerA, knight); + addCard(Zone.BATTLEFIELD, playerB, lion); + + attack(1, playerA, knight); + block(1, playerB, lion, knight); + + activateAbility(1, PhaseStep.DECLARE_BLOCKERS, playerA, "{B}{B}", lion); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, knight, 1); + assertPermanentCount(playerB, lion, 0); + assertGraveyardCount(playerA, knight, 0); + assertGraveyardCount(playerB, lion, 1); + } + + @Test + public void testLeavesBattlefield() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5); + addCard(Zone.BATTLEFIELD, playerA, knight); + addCard(Zone.BATTLEFIELD, playerB, lion); + addCard(Zone.HAND, playerA, murder); + + attack(1, playerA, knight); + block(1, playerB, lion, knight); + + activateAbility(1, PhaseStep.DECLARE_BLOCKERS, playerA, "{B}{B}", lion); + castSpell(1, PhaseStep.DECLARE_BLOCKERS, playerA, murder, knight); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, knight, 0); + assertPermanentCount(playerB, lion, 0); + assertGraveyardCount(playerA, knight, 1); + assertGraveyardCount(playerB, lion, 1); + } + + @Test + public void testLeavesBattlefieldReturns() { + addCard(Zone.BATTLEFIELD, playerA, "Scrubland", 4); + addCard(Zone.BATTLEFIELD, playerA, knight); + addCard(Zone.BATTLEFIELD, playerB, lion); + addCard(Zone.HAND, playerA, blink); + + attack(1, playerA, knight); + block(1, playerB, lion, knight); + + activateAbility(1, PhaseStep.DECLARE_BLOCKERS, playerA, "{B}{B}", lion); + castSpell(1, PhaseStep.DECLARE_BLOCKERS, playerA, blink, knight); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, knight, 1); + assertPermanentCount(playerB, lion, 0); + assertGraveyardCount(playerA, knight, 0); + assertGraveyardCount(playerB, lion, 1); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/player/RandomPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/RandomPlayer.java index d65201b1319..91cbaa1b52f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/RandomPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/RandomPlayer.java @@ -222,7 +222,7 @@ public class RandomPlayer extends ComputerPlayer { } protected boolean chooseRandomTarget(Target target, Ability source, Game game) { - Set possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game); + Set possibleTargets = target.possibleTargets(playerId, source, game); if (possibleTargets.isEmpty()) { return false; } @@ -246,12 +246,12 @@ public class RandomPlayer extends ComputerPlayer { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { return chooseRandom(target, game); } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { return chooseRandom(target, game); } @@ -294,7 +294,7 @@ public class RandomPlayer extends ComputerPlayer { @Override public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) { - Set possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game); + Set possibleTargets = target.possibleTargets(playerId, source, game); if (possibleTargets.isEmpty()) { return !target.isRequired(source); } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java index 9908787ee2a..05e9ae53f21 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java @@ -1,5 +1,6 @@ package org.mage.test.player; +import mage.abilities.Ability; import mage.choices.Choice; import mage.constants.Outcome; import mage.constants.RangeOfInfluence; @@ -7,8 +8,6 @@ import mage.game.Game; import mage.player.ai.ComputerPlayer; import mage.target.Target; -import java.util.UUID; - /** * @author JayDi85 */ @@ -43,11 +42,11 @@ public class TestComputerPlayer extends ComputerPlayer { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { if (testPlayerLink.canChooseByComputer()) { - return super.choose(outcome, target, sourceId, game); + return super.choose(outcome, target, source, game); } else { - return testPlayerLink.choose(outcome, target, sourceId, game); + return testPlayerLink.choose(outcome, target, source, game); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java index 0017004e43e..64c587fae3f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java @@ -1,5 +1,6 @@ package org.mage.test.player; +import mage.abilities.Ability; import mage.choices.Choice; import mage.constants.Outcome; import mage.constants.RangeOfInfluence; @@ -7,8 +8,6 @@ import mage.game.Game; import mage.player.ai.ComputerPlayer7; import mage.target.Target; -import java.util.UUID; - /** * Copied-pasted methods from TestComputerPlayer, see docs in there * @@ -28,11 +27,11 @@ public class TestComputerPlayer7 extends ComputerPlayer7 { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { if (testPlayerLink.canChooseByComputer()) { - return super.choose(outcome, target, sourceId, game); + return super.choose(outcome, target, source, game); } else { - return testPlayerLink.choose(outcome, target, sourceId, game); + return testPlayerLink.choose(outcome, target, source, game); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java index e55d22749f1..9f6168ff0f7 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java @@ -1,5 +1,6 @@ package org.mage.test.player; +import mage.abilities.Ability; import mage.choices.Choice; import mage.constants.Outcome; import mage.constants.RangeOfInfluence; @@ -7,8 +8,6 @@ import mage.game.Game; import mage.player.ai.ComputerPlayerMCTS; import mage.target.Target; -import java.util.UUID; - /** * Copied-pasted methods from TestComputerPlayer, see docs in there * @@ -28,11 +27,11 @@ public class TestComputerPlayerMonteCarlo extends ComputerPlayerMCTS { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { if (testPlayerLink.canChooseByComputer()) { - return super.choose(outcome, target, sourceId, game); + return super.choose(outcome, target, source, game); } else { - return testPlayerLink.choose(outcome, target, sourceId, game); + return testPlayerLink.choose(outcome, target, source, game); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 30e26d5467d..f22142073ad 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -499,7 +499,7 @@ public class TestPlayer implements Player { targetName = targetName.substring(0, targetName.length() - 11); } } - for (UUID id : currentTarget.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) { + for (UUID id : currentTarget.possibleTargets(ability.getControllerId(), ability, game)) { if (!currentTarget.getTargets().contains(id)) { MageObject object = game.getObject(id); @@ -2056,7 +2056,7 @@ public class TestPlayer implements Player { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { UUID abilityControllerId = computerPlayer.getId(); if (target.getTargetController() != null && target.getAbilityController() != null) { abilityControllerId = target.getAbilityController(); @@ -2064,7 +2064,7 @@ public class TestPlayer implements Player { // ignore player select if (target.getMessage().equals("Select a starting player")) { - return computerPlayer.choose(outcome, target, sourceId, game, options); + return computerPlayer.choose(outcome, target, source, game, options); } assertAliasSupportInChoices(true); @@ -2082,11 +2082,6 @@ public class TestPlayer implements Player { List usedChoices = new ArrayList<>(); List usedTargets = new ArrayList<>(); - Ability source = null; - StackObject stackObject = game.getStack().getStackObject(sourceId); - if (stackObject != null) { - source = stackObject.getStackAbility(); - } if ((target.getOriginalTarget() instanceof TargetPermanent) || (target.getOriginalTarget() instanceof TargetPermanentOrPlayer)) { // player target not implemted yet @@ -2112,7 +2107,7 @@ public class TestPlayer implements Player { targetName = targetName.substring(0, targetName.length() - 11); } } - for (Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent, abilityControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent, abilityControllerId, source, game)) { if (target.getTargets().contains(permanent.getId())) { continue; } @@ -2178,7 +2173,7 @@ public class TestPlayer implements Player { CheckOneChoice: for (String possibleChoice : possibleChoices) { - Set possibleCards = target.possibleTargets(sourceId, abilityControllerId, game); + Set possibleCards = target.possibleTargets(abilityControllerId, source, game); CheckTargetsList: for (UUID targetId : possibleCards) { MageObject targetObject = game.getCard(targetId); @@ -2232,7 +2227,7 @@ public class TestPlayer implements Player { if (target.getOriginalTarget() instanceof TargetSource) { Set possibleTargets; TargetSource t = ((TargetSource) target.getOriginalTarget()); - possibleTargets = t.possibleTargets(sourceId, abilityControllerId, game); + possibleTargets = t.possibleTargets(abilityControllerId, source, game); for (String choiceRecord : choices) { String[] targetList = choiceRecord.split("\\^"); boolean targetFound = false; @@ -2268,8 +2263,8 @@ public class TestPlayer implements Player { */ } - this.chooseStrictModeFailed("choice", game, getInfo(game.getObject(sourceId)) + ";\n" + getInfo(target)); - return computerPlayer.choose(outcome, target, sourceId, game, options); + this.chooseStrictModeFailed("choice", game, getInfo(game.getObject(source)) + ";\n" + getInfo(target)); + return computerPlayer.choose(outcome, target, source, game, options); } private void checkTargetDefinitionMarksSupport(Target needTarget, String targetDefinition, String canSupportChars) { @@ -2380,7 +2375,7 @@ public class TestPlayer implements Player { if (filter instanceof FilterPermanentOrSuspendedCard) { filter = ((FilterPermanentOrSuspendedCard) filter).getPermanentFilter(); } - for (Permanent permanent : game.getBattlefield().getActivePermanents((FilterPermanent) filter, abilityControllerId, sourceId, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents((FilterPermanent) filter, abilityControllerId, source, game)) { if (hasObjectTargetNameOrAlias(permanent, targetName) || (permanent.getName() + '-' + permanent.getExpansionSetCode()).equals(targetName)) { // TODO: remove exp code search? if (target.canTarget(abilityControllerId, permanent.getId(), source, game) && !target.getTargets().contains(permanent.getId())) { if ((permanent.isCopy() && !originOnly) || (!permanent.isCopy() && !copyOnly)) { @@ -3966,10 +3961,10 @@ public class TestPlayer implements Player { @Override public boolean choose(Outcome outcome, Target target, - UUID sourceId, Game game + Ability source, Game game ) { // needed to call here the TestPlayer because it's overwitten - return choose(outcome, target, sourceId, game, null); + return choose(outcome, target, source, game, null); } @Override @@ -4066,7 +4061,7 @@ public class TestPlayer implements Player { Assert.assertTrue("target amount must be <= remaining = " + target.getAmountRemaining() + " " + targetInfo, targetAmount <= target.getAmountRemaining()); if (target.getAmountRemaining() > 0) { - for (UUID possibleTarget : target.possibleTargets(source.getSourceId(), source.getControllerId(), game)) { + for (UUID possibleTarget : target.possibleTargets(source.getControllerId(), source, game)) { boolean foundTarget = false; // permanent diff --git a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java index 58ed90d7d8d..6eb65426805 100644 --- a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java +++ b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java @@ -841,12 +841,12 @@ public class PlayerStub implements Player { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { return false; } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { return false; } diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index 39e16754d5e..7d987a81323 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -966,7 +966,7 @@ public abstract class AbilityImpl implements Ability { if (target.getTargetController() != null) { abilityControllerId = target.getTargetController(); } - if (!target.canChoose(ability.getSourceId(), abilityControllerId, game)) { + if (!target.canChoose(abilityControllerId, ability, game)) { validTargets = false; break; } diff --git a/Mage/src/main/java/mage/abilities/Modes.java b/Mage/src/main/java/mage/abilities/Modes.java index 2ad8ff0e71d..d5722654c12 100644 --- a/Mage/src/main/java/mage/abilities/Modes.java +++ b/Mage/src/main/java/mage/abilities/Modes.java @@ -219,7 +219,7 @@ public class Modes extends LinkedHashMap { realMaxModes = 0; for (UUID targetPlayerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player targetPlayer = game.getPlayer(targetPlayerId); - if (((FilterPlayer) this.maxModesFilter).match(targetPlayer, source.getSourceId(), source.getControllerId(), game)) { + if (((FilterPlayer) this.maxModesFilter).match(targetPlayer, source.getControllerId(), source, game)) { realMaxModes++; } } @@ -292,7 +292,7 @@ public class Modes extends LinkedHashMap { } for (Mode mode : this.values()) { if ((!isEachModeOnlyOnce() || onceSelectedModes == null || !onceSelectedModes.contains(mode.getId())) - && mode.getTargets().canChoose(source.getSourceId(), source.getControllerId(), game)) { + && mode.getTargets().canChoose(source.getControllerId(), source, game)) { this.addSelectedMode(mode.getId()); } } @@ -309,7 +309,7 @@ public class Modes extends LinkedHashMap { UUID playerId = null; if (modeChooser == TargetController.OPPONENT) { TargetOpponent targetOpponent = new TargetOpponent(); - if (targetOpponent.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) { + if (targetOpponent.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), source, game)) { playerId = targetOpponent.getFirstTarget(); } } else { diff --git a/Mage/src/main/java/mage/abilities/TriggeredAbilityImpl.java b/Mage/src/main/java/mage/abilities/TriggeredAbilityImpl.java index 413c84a06e2..e9da3546d65 100644 --- a/Mage/src/main/java/mage/abilities/TriggeredAbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/TriggeredAbilityImpl.java @@ -331,7 +331,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge } } if (sourceObject == null) { // source is no permanent - sourceObject = game.getObject(source.getSourceId()); + sourceObject = game.getObject(source); if (sourceObject == null || sourceObject.isPermanent(game)) { return false; // No source object found => ability is not valid } diff --git a/Mage/src/main/java/mage/abilities/abilityword/GrandeurAbility.java b/Mage/src/main/java/mage/abilities/abilityword/GrandeurAbility.java index 921f53e4a66..9fcb8b55b48 100644 --- a/Mage/src/main/java/mage/abilities/abilityword/GrandeurAbility.java +++ b/Mage/src/main/java/mage/abilities/abilityword/GrandeurAbility.java @@ -8,7 +8,7 @@ import mage.abilities.effects.Effect; import mage.constants.AbilityWord; import mage.constants.Zone; import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.AnotherCardPredicate; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.filter.predicate.mageobject.NamePredicate; import mage.target.common.TargetCardInHand; @@ -26,7 +26,7 @@ public class GrandeurAbility extends ActivatedAbilityImpl { FilterCard filter = new FilterCard("another card named " + cardName); filter.add(new NamePredicate(cardName)); - filter.add(new AnotherCardPredicate()); + filter.add(AnotherPredicate.instance); this.addCost(new DiscardTargetCost(new TargetCardInHand(filter))); setAbilityWord(AbilityWord.GRANDEUR); } diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java index e78ab1da0b6..6f6c5ee1b07 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java @@ -60,7 +60,7 @@ public class AttacksAllTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (filter.match(permanent, getControllerId(), this, game)) { if (attacksYouOrYourPlaneswalker) { boolean check = false; if (event.getTargetId().equals(getControllerId())) { diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAloneControlledTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAloneControlledTriggeredAbility.java index 93b64fbc433..6f48c8cccfb 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAloneControlledTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAloneControlledTriggeredAbility.java @@ -58,7 +58,7 @@ public class AttacksAloneControlledTriggeredAbility extends TriggeredAbilityImpl return false; } Permanent permanent = game.getPermanent(game.getCombat().getAttackers().get(0)); - if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent == null || !filter.match(permanent, getControllerId(), this, game)) { return false; } if (setTargetPointer) { diff --git a/Mage/src/main/java/mage/abilities/common/AttacksCreatureYouControlTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksCreatureYouControlTriggeredAbility.java index 2545d601057..2f2171a2d42 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksCreatureYouControlTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksCreatureYouControlTriggeredAbility.java @@ -61,7 +61,7 @@ public class AttacksCreatureYouControlTriggeredAbility extends TriggeredAbilityI @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent sourcePermanent = game.getPermanent(event.getSourceId()); - if (filter.match(sourcePermanent, sourceId, controllerId, game)) { + if (filter.match(sourcePermanent, controllerId, this, game)) { if (setTargetPointer) { this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game)); } diff --git a/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java index 2ea2a0b5138..1578bf435f3 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksWithCreaturesTriggeredAbility.java @@ -57,7 +57,7 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl { .getAttackers() .stream() .map(game::getPermanent) - .filter(permanent -> filter.match(permanent, sourceId, controllerId, game)) + .filter(permanent -> filter.match(permanent, controllerId, this, game)) .mapToInt(x -> 1) .sum(); if (attackers < minAttackers) { diff --git a/Mage/src/main/java/mage/abilities/common/BecomesBlockedAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesBlockedAllTriggeredAbility.java index fc6228268ec..ce84e8e227d 100644 --- a/Mage/src/main/java/mage/abilities/common/BecomesBlockedAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BecomesBlockedAllTriggeredAbility.java @@ -42,7 +42,7 @@ public class BecomesBlockedAllTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (filter.match(permanent, getControllerId(), this, game)) { if (setTargetPointer) { this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); } diff --git a/Mage/src/main/java/mage/abilities/common/BecomesTappedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesTappedTriggeredAbility.java index 828c36ba477..856121d89b8 100644 --- a/Mage/src/main/java/mage/abilities/common/BecomesTappedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BecomesTappedTriggeredAbility.java @@ -56,7 +56,7 @@ public class BecomesTappedTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (!filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (!filter.match(permanent, getControllerId(), this, game)) { return false; } if (setTargetPointer) { diff --git a/Mage/src/main/java/mage/abilities/common/BecomesTargetAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesTargetAttachedTriggeredAbility.java index fef952f3a74..79d1fb27952 100644 --- a/Mage/src/main/java/mage/abilities/common/BecomesTargetAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BecomesTargetAttachedTriggeredAbility.java @@ -6,7 +6,6 @@ import mage.constants.Zone; import mage.filter.FilterStackObject; import mage.filter.StaticFilters; import mage.game.Game; -import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent; import mage.game.stack.StackObject; import mage.game.permanent.Permanent; @@ -56,7 +55,7 @@ public class BecomesTargetAttachedTriggeredAbility extends TriggeredAbilityImpl StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { if (event.getTargetId().equals(enchantment.getAttachedTo()) - && filter.match(sourceObject, getSourceId(), getControllerId(), game)) { + && filter.match(sourceObject, getControllerId(), this, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/common/BecomesTargetTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesTargetTriggeredAbility.java index e09b74d081e..da8d10afcd0 100644 --- a/Mage/src/main/java/mage/abilities/common/BecomesTargetTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BecomesTargetTriggeredAbility.java @@ -57,7 +57,7 @@ public class BecomesTargetTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); if (!event.getTargetId().equals(getSourceId()) - || !filter.match(sourceObject, getSourceId(), getControllerId(), game)) { + || !filter.match(sourceObject, getControllerId(), this, game)) { return false; } switch (setTargetPointer) { diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java index 70b0364d69a..713625ba41e 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java @@ -69,27 +69,24 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI return false; } permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); - if (!filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) { + if (!filterPermanent.match(permanent, getControllerId(), this, game)) { return false; } - for (Effect effect : this.getEffects()) { - effect.setValue("damage", event.getAmount()); - effect.setValue("sourceId", event.getSourceId()); - switch (setTargetPointer) { - case PLAYER: - effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); - break; - case PERMANENT: - effect.setTargetPointer(new FixedTarget(permanent, game)); - break; - case PERMANENT_TARGET: - Permanent permanent_target = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (permanent_target != null) { - effect.setTargetPointer(new FixedTarget(permanent_target, game)); - } - break; - } - + this.getEffects().setValue("damage", event.getAmount()); + this.getEffects().setValue("sourceId", event.getSourceId()); + switch (setTargetPointer) { + case PLAYER: + this.getEffects().setTargetPointer(new FixedTarget(permanent.getControllerId())); + break; + case PERMANENT: + this.getEffects().setTargetPointer(new FixedTarget(permanent, game)); + break; + case PERMANENT_TARGET: + Permanent permanent_target = game.getPermanentOrLKIBattlefield(event.getTargetId()); + if (permanent_target != null) { + this.getEffects().setTargetPointer(new FixedTarget(permanent_target, game)); + } + break; } return true; } @@ -97,6 +94,6 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI @Override public String getTriggerPhrase() { return "Whenever " + filterPermanent.getMessage() + " deals " - + (combatDamageOnly ? "combat " : "") + "damage to a creature, " ; + + (combatDamageOnly ? "combat " : "") + "damage to a creature, "; } } diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java index 7e1386d93e7..b59a77ee884 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java @@ -54,7 +54,7 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl && (!combatOnly || ((DamagedEvent) event).isCombatDamage())) { if (filter != null) { Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (!filter.match(creature, getSourceId(), getControllerId(), game)) { + if (!filter.match(creature, getControllerId(), this, game)) { return false; } } diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAllTriggeredAbility.java index faeb89e0d8b..668e0d41408 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAllTriggeredAbility.java @@ -74,7 +74,7 @@ public class DealsDamageToAPlayerAllTriggeredAbility extends TriggeredAbilityImp return false; } Permanent permanent = game.getPermanent(event.getSourceId()); - if (!filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (!filter.match(permanent, getControllerId(), this, game)) { return false; } this.getEffects().setValue("damage", event.getAmount()); diff --git a/Mage/src/main/java/mage/abilities/common/DiesCreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DiesCreatureTriggeredAbility.java index b4a49b2fa7c..1a9fa39f56e 100644 --- a/Mage/src/main/java/mage/abilities/common/DiesCreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DiesCreatureTriggeredAbility.java @@ -69,7 +69,7 @@ public class DiesCreatureTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; - if (!zEvent.isDiesEvent() || !filter.match(zEvent.getTarget(), sourceId, controllerId, game)) { + if (!zEvent.isDiesEvent() || !filter.match(zEvent.getTarget(), controllerId, this, game)) { return false; } getEffects().setValue("creatureDied", zEvent.getTarget()); diff --git a/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureOrPlaneswalkerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureOrPlaneswalkerTriggeredAbility.java index 5d11e296373..c21e14145cd 100644 --- a/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureOrPlaneswalkerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureOrPlaneswalkerTriggeredAbility.java @@ -49,7 +49,7 @@ public class DiesThisOrAnotherCreatureOrPlaneswalkerTriggeredAbility extends Tri if (zEvent.getTarget().getId().equals(this.getSourceId())) { return true; } else { - if (filter.match(zEvent.getTarget(), getSourceId(), getControllerId(), game)) { + if (filter.match(zEvent.getTarget(), getControllerId(), this, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java index bccded75fcf..ab9ec39ce08 100644 --- a/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DiesThisOrAnotherCreatureTriggeredAbility.java @@ -56,7 +56,7 @@ public class DiesThisOrAnotherCreatureTriggeredAbility extends TriggeredAbilityI if (!applyFilterOnSource && zEvent.getTarget().getId().equals(this.getSourceId())) { return true; } else { - if (filter.match(zEvent.getTarget(), getSourceId(), getControllerId(), game)) { + if (filter.match(zEvent.getTarget(), getControllerId(), this, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldAllTriggeredAbility.java index 3626a2c2b15..48ac04769b2 100644 --- a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldAllTriggeredAbility.java @@ -84,7 +84,7 @@ public class EntersBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanent(targetId); - if (!filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (!filter.match(permanent, getControllerId(), this, game)) { return false; } this.getEffects().setValue("permanentEnteringBattlefield", permanent); diff --git a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksAllTriggeredAbility.java index 1a92950bcd3..2168b6857d2 100644 --- a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksAllTriggeredAbility.java @@ -79,7 +79,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD - && filter.match(permanent, getSourceId(), getControllerId(), game)) { + && filter.match(permanent, getControllerId(), this, game)) { if (setTargetPointer != SetTargetPointer.NONE) { for (Effect effect : this.getEffects()) { switch (setTargetPointer) { @@ -98,7 +98,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil Permanent attacker = game.getPermanent(event.getSourceId()); if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED - && filter.match(attacker, getSourceId(), getControllerId(), game)) { + && filter.match(attacker, getControllerId(), this, game)) { if (setTargetPointer != SetTargetPointer.NONE) { for (Effect effect : this.getEffects()) { switch (setTargetPointer) { diff --git a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldThisOrAnotherTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldThisOrAnotherTriggeredAbility.java index ce631a0a3be..39b7be1d3ff 100644 --- a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldThisOrAnotherTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldThisOrAnotherTriggeredAbility.java @@ -52,7 +52,7 @@ public class EntersBattlefieldThisOrAnotherTriggeredAbility extends EntersBattle if (onlyControlled && !permanent.isControlledBy(this.getControllerId())) { return false; } - return filter.match(permanent, getSourceId(), getControllerId(), game); + return filter.match(permanent, getControllerId(), this, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java index 8c06dbc8a87..da979db570c 100644 --- a/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java @@ -62,7 +62,7 @@ public class LeavesBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl { if (zEvent.getFromZone() == Zone.BATTLEFIELD) { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanentOrLKIBattlefield(targetId); - if (filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (filter.match(permanent, getControllerId(), this, game)) { if (setTargetPointer != SetTargetPointer.NONE) { for (Effect effect : this.getEffects()) { switch (setTargetPointer) { diff --git a/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java index 01f60349936..78313bcb411 100644 --- a/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java @@ -82,7 +82,7 @@ public class PutCardIntoGraveFromAnywhereAllTriggeredAbility extends TriggeredAb return false; } Card card = game.getCard(event.getTargetId()); - if (card == null || card.isCopy() || !filter.match(card, getSourceId(), getControllerId(), game)) { + if (card == null || card.isCopy() || !filter.match(card, getControllerId(), this, game)) { return false; } switch (setTargetPointer) { diff --git a/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java b/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java index b207de62068..70788da37e6 100644 --- a/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java +++ b/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java @@ -118,7 +118,7 @@ class PutIntoGraveFromAnywhereEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { if (optional) { Player controller = game.getPlayer(source.getControllerId()); - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (controller == null || object == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java index 341d4088259..32bc8aaf5bf 100644 --- a/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java @@ -7,7 +7,6 @@ import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.target.targetpointer.FixedTarget; @@ -49,7 +48,7 @@ public class PutIntoGraveFromBattlefieldAllTriggeredAbility extends TriggeredAbi public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.isDiesEvent()) { - if (filter.match(zEvent.getTarget(), this.getSourceId(), this.getControllerId(), game)) { + if (filter.match(zEvent.getTarget(), this.getControllerId(), this, game)) { if (onlyToControllerGraveyard && !this.isControlledBy(game.getOwnerId(zEvent.getTargetId()))) { return false; } diff --git a/Mage/src/main/java/mage/abilities/common/SacrificeAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SacrificeAllTriggeredAbility.java index 98f38a68cad..589bf164a8d 100644 --- a/Mage/src/main/java/mage/abilities/common/SacrificeAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SacrificeAllTriggeredAbility.java @@ -58,7 +58,7 @@ public class SacrificeAllTriggeredAbility extends TriggeredAbilityImpl { break; } Permanent sacrificedPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); - return sacrificed && filter.match(sacrificedPermanent, getSourceId(), getControllerId(), game); + return sacrificed && filter.match(sacrificedPermanent, getControllerId(), this, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/SacrificePermanentTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SacrificePermanentTriggeredAbility.java index 2a0925c3340..016f5bcfea5 100644 --- a/Mage/src/main/java/mage/abilities/common/SacrificePermanentTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SacrificePermanentTriggeredAbility.java @@ -57,7 +57,7 @@ public class SacrificePermanentTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); if (!isControlledBy(event.getPlayerId()) || permanent == null - || !filter.match(permanent, getSourceId(), getControllerId(), game)) { + || !filter.match(permanent, getControllerId(), this, game)) { return false; } this.getEffects().setValue("sacrificedPermanent", permanent); diff --git a/Mage/src/main/java/mage/abilities/common/SpellCastAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SpellCastAllTriggeredAbility.java index fdb748f1f90..f3eedd69081 100644 --- a/Mage/src/main/java/mage/abilities/common/SpellCastAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SpellCastAllTriggeredAbility.java @@ -59,7 +59,7 @@ public class SpellCastAllTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (!filter.match(spell, getSourceId(), getControllerId(), game)) { + if (!filter.match(spell, getControllerId(), this, game)) { return false; } getEffects().setValue("spellCast", spell); diff --git a/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java index 775efe507ac..b49ffe73aae 100644 --- a/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SpellCastControllerTriggeredAbility.java @@ -68,7 +68,7 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (filter.match(spell, getSourceId(), getControllerId(), game)) { + if (filter.match(spell, getControllerId(), this, game)) { this.getEffects().setValue("spellCast", spell); if (rememberSource) { if (rememberSourceAsCard) { diff --git a/Mage/src/main/java/mage/abilities/common/SpellCastOpponentTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SpellCastOpponentTriggeredAbility.java index ad185bad4af..5845b595a9b 100644 --- a/Mage/src/main/java/mage/abilities/common/SpellCastOpponentTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SpellCastOpponentTriggeredAbility.java @@ -61,7 +61,7 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl { return false; } Spell spell = game.getStack().getSpell(event.getTargetId()); - if (!filter.match(spell, getSourceId(), getControllerId(), game)) { + if (!filter.match(spell, getControllerId(), this, game)) { return false; } getEffects().setValue("spellCast", spell); diff --git a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java index ca588d70d83..a28ffeaa6d1 100644 --- a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java @@ -48,7 +48,7 @@ public class TapForManaAllTriggeredAbility extends TriggeredAbilityImpl { } TappedForManaEvent manaEvent = ((TappedForManaEvent) event); Permanent permanent = manaEvent.getPermanent(); - if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent == null || !filter.match(permanent, getControllerId(), this, game)) { return false; } getEffects().setValue("mana", manaEvent.getMana()); diff --git a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java index 8ddf18e7adf..3874f6ed155 100644 --- a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java @@ -42,7 +42,7 @@ public class TapForManaAllTriggeredManaAbility extends TriggeredManaAbility { public boolean checkTrigger(GameEvent event, Game game) { TappedForManaEvent manaEvent = ((TappedForManaEvent) event); Permanent permanent = manaEvent.getPermanent(); - if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (permanent == null || !filter.match(permanent, getControllerId(), this, game)) { return false; } getEffects().setValue("mana", manaEvent.getMana()); diff --git a/Mage/src/main/java/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java index f1b45368546..48dbeee10f6 100644 --- a/Mage/src/main/java/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java @@ -67,7 +67,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl { } } Permanent permanent = game.getPermanent(event.getTargetId()); - if (filter.match(permanent, getSourceId(), getControllerId(), game)) { + if (filter.match(permanent, getControllerId(), this, game)) { if (setTargetPointer) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId(), game)); diff --git a/Mage/src/main/java/mage/abilities/common/ZoneChangeAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/ZoneChangeAllTriggeredAbility.java index f155be848ba..ec181d81956 100644 --- a/Mage/src/main/java/mage/abilities/common/ZoneChangeAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/ZoneChangeAllTriggeredAbility.java @@ -60,7 +60,7 @@ public class ZoneChangeAllTriggeredAbility extends TriggeredAbilityImpl { } else { perm = game.getPermanent(event.getTargetId()); // LevelX2: maybe this part is not neccessary } - if (filter.match(perm, sourceId, controllerId, game)) { + if (filter.match(perm, controllerId, this, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AnyPlayerControlsCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AnyPlayerControlsCondition.java index 3d32a9908c5..22bdf1741a0 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AnyPlayerControlsCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AnyPlayerControlsCondition.java @@ -19,6 +19,6 @@ public class AnyPlayerControlsCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0; + return game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0; } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttachedToMatchesFilterCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttachedToMatchesFilterCondition.java index 98fefd12798..eca3a8a38dd 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttachedToMatchesFilterCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttachedToMatchesFilterCondition.java @@ -29,7 +29,7 @@ public class AttachedToMatchesFilterCondition implements Condition { if (attachedTo == null) { attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD); } - if (filter.match(attachedTo, attachedTo.getId(), attachedTo.getControllerId(), game)) { + if (filter.match(attachedTo, attachedTo.getControllerId(), source, game)) { return true; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/CardsInControllerGraveyardCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CardsInControllerGraveyardCondition.java index fa0f86c7913..90b03f8e53f 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CardsInControllerGraveyardCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CardsInControllerGraveyardCondition.java @@ -30,7 +30,7 @@ public class CardsInControllerGraveyardCondition implements Condition { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (filter != null) { - return player != null && player.getGraveyard().count(filter, source.getSourceId(), source.getControllerId(), game) >= value; + return player != null && player.getGraveyard().count(filter, source.getControllerId(), source, game) >= value; } return player != null && player.getGraveyard().size() >= value; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestPowerCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestPowerCondition.java index 8558104f948..f3cf48580de 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestPowerCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestPowerCondition.java @@ -28,7 +28,7 @@ public enum ControlsCreatureGreatestPowerCondition implements Condition { Set controllers = new HashSet<>(); Integer maxPower = null; - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { if (permanent == null) { continue; diff --git a/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestToughnessCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestToughnessCondition.java index 2e5d8665a48..16ed887a4d7 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestToughnessCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ControlsCreatureGreatestToughnessCondition.java @@ -27,7 +27,7 @@ public enum ControlsCreatureGreatestToughnessCondition implements Condition { Set controllers = new HashSet<>(); Integer maxToughness = null; - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { if (permanent == null) { continue; diff --git a/Mage/src/main/java/mage/abilities/condition/common/ControlsPermanentGreatestCMCCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ControlsPermanentGreatestCMCCondition.java index 291ec51fa2c..92a533b372e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ControlsPermanentGreatestCMCCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ControlsPermanentGreatestCMCCondition.java @@ -32,7 +32,7 @@ public class ControlsPermanentGreatestCMCCondition implements Condition { Set controllers = new HashSet<>(); Integer maxCMC = null; - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { int cmc = permanent.getManaCost().manaValue(); if (maxCMC == null || cmc > maxCMC) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/CovenCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CovenCondition.java index 63d20df6270..6d2b558ac0b 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CovenCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CovenCondition.java @@ -21,7 +21,7 @@ public enum CovenCondition implements Condition { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getControllerId(), source.getSourceId(), game + source.getControllerId(), source, game ) .stream() .filter(Objects::nonNull) diff --git a/Mage/src/main/java/mage/abilities/condition/common/CreatureCountCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CreatureCountCondition.java index 305c0775a5b..8b2faa634e8 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CreatureCountCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CreatureCountCondition.java @@ -43,7 +43,7 @@ public class CreatureCountCondition implements Condition { } return true; case ANY: - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == creatureCount; + return game.getBattlefield().count(filter, source.getControllerId(), source, game) == creatureCount; default: throw new UnsupportedOperationException("Value for targetController not supported: " + targetController.toString()); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureColorCondition.java b/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureColorCondition.java index 12f62254b4b..66d84ea8c72 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureColorCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureColorCondition.java @@ -30,7 +30,7 @@ public class EnchantedCreatureColorCondition implements Condition { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null) { Permanent creature = game.getPermanent(enchantment.getAttachedTo()); - if(filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)){ + if(filter.match(creature, enchantment.getControllerId(), source, game)){ return true; } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureSubtypeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureSubtypeCondition.java index 5aaf26241ab..d290e129e2d 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureSubtypeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/EnchantedCreatureSubtypeCondition.java @@ -26,7 +26,7 @@ public class EnchantedCreatureSubtypeCondition implements Condition { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null) { Permanent creature = game.getPermanent(enchantment.getAttachedTo()); - if (filter.match(creature, source.getSourceId(), enchantment.getControllerId(), game)) { + if (filter.match(creature, enchantment.getControllerId(), source, game)) { return true; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/FaceDownSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/FaceDownSourceCondition.java index a71db2bb7c7..298610c8ab8 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/FaceDownSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/FaceDownSourceCondition.java @@ -19,7 +19,7 @@ public enum FaceDownSourceCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { if (mageObject instanceof Permanent) { return ((Permanent)mageObject).isFaceDown(game); diff --git a/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java index a0a3f552d20..23cf52129b1 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java @@ -32,7 +32,7 @@ public class MeldCondition implements Condition { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); filter.add(new NamePredicate(this.meldWithName)); filter.add(new OwnerIdPredicate(source.getControllerId())); - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0; + return game.getBattlefield().count(filter, source.getControllerId(), source, game) > 0; } } return false; diff --git a/Mage/src/main/java/mage/abilities/condition/common/MostCommonColorCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MostCommonColorCondition.java index 1b3c8157387..3992edf70d1 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MostCommonColorCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MostCommonColorCondition.java @@ -45,7 +45,7 @@ public class MostCommonColorCondition implements Condition { i = 0; for (ObjectColor color : ObjectColor.getAllColors()) { colorFilters[i].add(new ColorPredicate(color)); - colorCounts[i] = game.getBattlefield().count(colorFilters[i], source.getId(), source.getControllerId(), game); + colorCounts[i] = game.getBattlefield().count(colorFilters[i], source.getControllerId(), source, game); i++; } int max = 0; diff --git a/Mage/src/main/java/mage/abilities/condition/common/OathbreakerOnBattlefieldCondition.java b/Mage/src/main/java/mage/abilities/condition/common/OathbreakerOnBattlefieldCondition.java index ba27bdfbbc8..760a11d893c 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/OathbreakerOnBattlefieldCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/OathbreakerOnBattlefieldCondition.java @@ -63,7 +63,7 @@ public class OathbreakerOnBattlefieldCondition implements Condition { @Override public boolean apply(Game game, Ability source) { // source.getSourceId() is null for commander's effects - int permanentsOnBattlefield = game.getBattlefield().count(this.filter, source.getSourceId(), playerId, game); + int permanentsOnBattlefield = game.getBattlefield().count(this.filter, playerId, source, game); return permanentsOnBattlefield > 0; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/OpponentControlsPermanentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/OpponentControlsPermanentCondition.java index 25b98e853ca..bf56a6694cb 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/OpponentControlsPermanentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/OpponentControlsPermanentCondition.java @@ -53,7 +53,7 @@ public class OpponentControlsPermanentCondition implements Condition { for (UUID opponentId : game.getOpponents(source.getControllerId())) { FilterPermanent localFilter = filter.copy(); localFilter.add(new ControllerIdPredicate(opponentId)); - if (ComparisonType.compare(game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game), type, this.count)) { + if (ComparisonType.compare(game.getBattlefield().count(localFilter, source.getControllerId(), source, game), type, this.count)) { conditionApplies = true; break; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/PermanentsOnTheBattlefieldCondition.java b/Mage/src/main/java/mage/abilities/condition/common/PermanentsOnTheBattlefieldCondition.java index 0643c27dd8a..d0cfc543586 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/PermanentsOnTheBattlefieldCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/PermanentsOnTheBattlefieldCondition.java @@ -68,7 +68,7 @@ public class PermanentsOnTheBattlefieldCondition implements Condition { localFilter = filter; } return ComparisonType.compare(game.getBattlefield().count( - localFilter, source.getSourceId(), source.getControllerId(), game + localFilter, source.getControllerId(), source, game ), type, count); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceIsSpellCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceIsSpellCondition.java index 82ef4ea7352..583cedc4a30 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceIsSpellCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceIsSpellCondition.java @@ -17,7 +17,7 @@ instance; @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && !object.isLand(game); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceMatchesFilterCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceMatchesFilterCondition.java index cfacae4ec2c..ebab226cc5d 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceMatchesFilterCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceMatchesFilterCondition.java @@ -29,7 +29,7 @@ public class SourceMatchesFilterCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); - if (FILTER.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { + if (FILTER.match(permanent, permanent.getControllerId(), source, game)) { return true; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceTargetsPermanentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceTargetsPermanentCondition.java index 545518e6efa..b8558deb31a 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceTargetsPermanentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceTargetsPermanentCondition.java @@ -30,7 +30,7 @@ public class SourceTargetsPermanentCondition implements Condition { Iterator targets = sourceSpell.getStackAbility().getTargets().iterator(); while (targets.hasNext()) { Permanent permanent = game.getPermanentOrLKIBattlefield(targets.next().getFirstTarget()); - if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (filter.match(permanent, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java b/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java index 53d22aa3918..65c3cc9b592 100644 --- a/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java +++ b/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java @@ -117,7 +117,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter if (ability != null && AbilityType.SPELL == ability.getAbilityType()) { if (filter != null) { Card card = game.getCard(ability.getSourceId()); - if (!filter.match(card, ability.getSourceId(), ability.getControllerId(), game)) { + if (!filter.match(card, ability.getControllerId(), ability, game)) { return false; } } diff --git a/Mage/src/main/java/mage/abilities/costs/UseAttachedCost.java b/Mage/src/main/java/mage/abilities/costs/UseAttachedCost.java index e0c98170d7b..785a4e278fc 100644 --- a/Mage/src/main/java/mage/abilities/costs/UseAttachedCost.java +++ b/Mage/src/main/java/mage/abilities/costs/UseAttachedCost.java @@ -41,7 +41,7 @@ public abstract class UseAttachedCost extends CostImpl { public UseAttachedCost setMageObjectReference(Ability source, Game game) { this.mageObjectReference = new MageObjectReference(source.getSourceId(), game); - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null) { this.name = object.getName(); } diff --git a/Mage/src/main/java/mage/abilities/costs/common/ControlPermanentCost.java b/Mage/src/main/java/mage/abilities/costs/common/ControlPermanentCost.java deleted file mode 100644 index ad5d3f50838..00000000000 --- a/Mage/src/main/java/mage/abilities/costs/common/ControlPermanentCost.java +++ /dev/null @@ -1,39 +0,0 @@ -package mage.abilities.costs.common; - -import mage.abilities.Ability; -import mage.abilities.costs.Cost; -import mage.abilities.costs.CostImpl; -import mage.filter.common.FilterControlledPermanent; -import mage.game.Game; - -import java.util.UUID; - -public class ControlPermanentCost extends CostImpl { - private final FilterControlledPermanent filter; - - public ControlPermanentCost(FilterControlledPermanent filter) { - this.filter = filter.copy(); - this.text = "Activate only if you control " + filter.getMessage(); - } - - public ControlPermanentCost(final ControlPermanentCost cost) { - super(cost); - this.filter = cost.filter.copy(); - } - - @Override - public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return game.getBattlefield().containsControlled(filter, source.getSourceId(), controllerId, game, 1); - } - - @Override - public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - this.paid = true; - return paid; - } - - @Override - public ControlPermanentCost copy() { - return new ControlPermanentCost(this); - } -} diff --git a/Mage/src/main/java/mage/abilities/costs/common/DiscardTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/DiscardTargetCost.java index 0711f3e0aad..4ff17c8dbbb 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/DiscardTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/DiscardTargetCost.java @@ -50,7 +50,7 @@ public class DiscardTargetCost extends CostImpl { int amount = this.getTargets().get(0).getNumberOfTargets(); if (randomDiscard) { this.cards.addAll(player.discard(amount, true, true, source, game).getCards(game)); - } else if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), game)) { + } else if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), source, game)) { Cards toDiscard = new CardsImpl(); toDiscard.addAll(targets.get(0).getTargets()); Cards discarded = player.discard(toDiscard, true, source, game); @@ -71,7 +71,7 @@ public class DiscardTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java b/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java index e8cda8f583c..f8e810dc117 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ExileFromGraveCost.java @@ -78,7 +78,7 @@ public class ExileFromGraveCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : targets.get(0).getTargets()) { Card card = game.getCard(targetId); if (card == null @@ -106,7 +106,7 @@ public class ExileFromGraveCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/ExileFromHandCost.java b/Mage/src/main/java/mage/abilities/costs/common/ExileFromHandCost.java index 8d3f1a3228a..5e88fdfcd6a 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ExileFromHandCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ExileFromHandCost.java @@ -51,7 +51,7 @@ public class ExileFromHandCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { Player player = game.getPlayer(controllerId); int cmc = 0; for (UUID targetId : targets.get(0).getTargets()) { @@ -81,7 +81,7 @@ public class ExileFromHandCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/ExileTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/ExileTargetCost.java index 65e64d087fd..541a63ebf86 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ExileTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ExileTargetCost.java @@ -44,7 +44,7 @@ public class ExileTargetCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player player = game.getPlayer(ability.getControllerId()); - if (player == null || !targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (player == null || !targets.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { return paid; } Cards cards = new CardsImpl(); @@ -71,7 +71,7 @@ public class ExileTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/PutCardFromHandOnTopOfLibraryCost.java b/Mage/src/main/java/mage/abilities/costs/common/PutCardFromHandOnTopOfLibraryCost.java index fdb2d4cb48f..565bb66c1b0 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/PutCardFromHandOnTopOfLibraryCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/PutCardFromHandOnTopOfLibraryCost.java @@ -32,8 +32,8 @@ public class PutCardFromHandOnTopOfLibraryCost extends CostImpl { TargetCardInHand targetCardInHand = new TargetCardInHand(); targetCardInHand.setRequired(false); Card card; - if (targetCardInHand.canChoose(source.getSourceId(), controllerId, game) - && controller.choose(Outcome.PreventDamage, targetCardInHand, source.getSourceId(), game)) { + if (targetCardInHand.canChoose(controllerId, source, game) + && controller.choose(Outcome.PreventDamage, targetCardInHand, source, game)) { card = game.getCard(targetCardInHand.getFirstTarget()); paid = card != null && controller.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, true); } diff --git a/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java b/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java index 8c423662572..148d89c9f96 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RemoveCounterCost.java @@ -60,7 +60,7 @@ public class RemoveCounterCost extends CostImpl { return paid = true; } target.clearChosen(); - if (target.choose(Outcome.UnboostCreature, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.UnboostCreature, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { @@ -122,7 +122,7 @@ public class RemoveCounterCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } private String setText() { diff --git a/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandChosenControlledPermanentCost.java b/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandChosenControlledPermanentCost.java index b89ff713b4a..dd91a8ef466 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandChosenControlledPermanentCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandChosenControlledPermanentCost.java @@ -45,7 +45,7 @@ public class ReturnToHandChosenControlledPermanentCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), source, game)) { Set permanentsToReturn = new HashSet<>(); for (UUID targetId : targets.get(0).getTargets()) { Permanent permanent = game.getPermanent(targetId); @@ -63,7 +63,7 @@ public class ReturnToHandChosenControlledPermanentCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandFromGraveyardCost.java b/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandFromGraveyardCost.java index 00187662ad1..3a3e3adfe7c 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandFromGraveyardCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ReturnToHandFromGraveyardCost.java @@ -37,7 +37,7 @@ public class ReturnToHandFromGraveyardCost extends CostImpl { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), source, game)) { Set cardsToMove = new LinkedHashSet<>(); for (UUID targetId : targets.get(0).getTargets()) { mage.cards.Card targetCard = game.getCard(targetId); @@ -56,7 +56,7 @@ public class ReturnToHandFromGraveyardCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/RevealDragonFromHandCost.java b/Mage/src/main/java/mage/abilities/costs/common/RevealDragonFromHandCost.java index 26c0112f3ce..08d7782fab1 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RevealDragonFromHandCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RevealDragonFromHandCost.java @@ -43,7 +43,7 @@ public class RevealDragonFromHandCost extends RevealTargetFromHandCost { public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { super.pay(ability, game, source, controllerId, noMana, costToPay); revealedOrControlled = numberCardsRevealed > 0 - || game.getBattlefield().count(filter2, source.getSourceId(), controllerId, game) > 0; + || game.getBattlefield().count(filter2, controllerId, source, game) > 0; return paid = true; } diff --git a/Mage/src/main/java/mage/abilities/costs/common/RevealHandSourceControllerCost.java b/Mage/src/main/java/mage/abilities/costs/common/RevealHandSourceControllerCost.java index 88eeef728d5..cba62824fc2 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RevealHandSourceControllerCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RevealHandSourceControllerCost.java @@ -27,7 +27,7 @@ public class RevealHandSourceControllerCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { controller.revealCards(sourceObject.getName(), controller.getHand(), game); paid = true; diff --git a/Mage/src/main/java/mage/abilities/costs/common/RevealSecretOpponentCost.java b/Mage/src/main/java/mage/abilities/costs/common/RevealSecretOpponentCost.java index aa4ae4bdbcc..abf131ef2be 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RevealSecretOpponentCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RevealSecretOpponentCost.java @@ -44,7 +44,7 @@ public class RevealSecretOpponentCost extends CostImpl { ChooseSecretOpponentEffect.setSecretOwner(null, source, game); // because only once, the value is set to null Player controller = game.getPlayer(controllerId); Player opponent = game.getPlayer(opponentId); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && opponent != null && sourceObject != null) { if (sourceObject instanceof Permanent) { ((Permanent) sourceObject).addInfo(ChooseSecretOpponentEffect.SECRET_OPPONENT, null, game); diff --git a/Mage/src/main/java/mage/abilities/costs/common/RevealTargetFromHandCost.java b/Mage/src/main/java/mage/abilities/costs/common/RevealTargetFromHandCost.java index 12c206a2f4b..88b8df8416e 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RevealTargetFromHandCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RevealTargetFromHandCost.java @@ -40,7 +40,7 @@ public class RevealTargetFromHandCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), source, game)) { manaValues = 0; numberCardsRevealed = 0; Player player = game.getPlayer(controllerId); @@ -81,7 +81,7 @@ public class RevealTargetFromHandCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java index 08cbf858f45..8f790667d95 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java @@ -53,7 +53,7 @@ public class SacrificeTargetCost extends CostImpl { activator = ((ActivatedAbilityImpl) ability).getActivatorId(); } // can be cancel by user - if (targets.choose(Outcome.Sacrifice, activator, source.getSourceId(), game)) { + if (targets.choose(Outcome.Sacrifice, activator, source.getSourceId(), source, game)) { for (UUID targetId : targets.get(0).getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java index fcc8b41a238..26839ceb901 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java @@ -51,7 +51,7 @@ public class SacrificeXTargetCost extends VariableCostImpl { @Override public int getMaxValue(Ability source, Game game) { - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + return game.getBattlefield().count(filter, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/TapTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/TapTargetCost.java index 295e6b4b74b..1b4b9b11c7f 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/TapTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/TapTargetCost.java @@ -37,7 +37,7 @@ public class TapTargetCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { List permanents = new ArrayList<>(); - if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { @@ -53,7 +53,7 @@ public class TapTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } public TargetControlledPermanent getTarget() { diff --git a/Mage/src/main/java/mage/abilities/costs/common/UntapTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/UntapTargetCost.java index 7532578d9fd..ab2e938c133 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/UntapTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/UntapTargetCost.java @@ -33,7 +33,7 @@ public class UntapTargetCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (target.choose(Outcome.Untap, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Untap, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : (List) target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent == null) { @@ -47,7 +47,7 @@ public class UntapTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return target.canChoose(source.getSourceId(), controllerId, game); + return target.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/costadjusters/LegendaryCreatureCostAdjuster.java b/Mage/src/main/java/mage/abilities/costs/costadjusters/LegendaryCreatureCostAdjuster.java index 3ed266021b5..cd2406ed5f3 100644 --- a/Mage/src/main/java/mage/abilities/costs/costadjusters/LegendaryCreatureCostAdjuster.java +++ b/Mage/src/main/java/mage/abilities/costs/costadjusters/LegendaryCreatureCostAdjuster.java @@ -31,7 +31,7 @@ public enum LegendaryCreatureCostAdjuster implements CostAdjuster { @Override public void adjustCosts(Ability ability, Game game) { int count = game.getBattlefield().count( - filter, ability.getSourceId(), ability.getControllerId(), game + filter, ability.getControllerId(), ability, game ); if (count > 0) { CardUtil.reduceCost(ability, count); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ArtifactYouControlCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ArtifactYouControlCount.java index 4c626a97a9c..0e1ce3478f0 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ArtifactYouControlCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ArtifactYouControlCount.java @@ -15,7 +15,7 @@ public enum ArtifactYouControlCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, sourceAbility.getControllerId(), sourceAbility, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackingCreatureCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackingCreatureCount.java index 315505335ac..e0c512ed772 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackingCreatureCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackingCreatureCount.java @@ -48,7 +48,7 @@ public class AttackingCreatureCount implements DynamicValue { for (UUID permId : combatGroup.getAttackers()) { if (filter != null) { Permanent attacker = game.getPermanent(permId); - if (filter.match(attacker, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game)) { + if (filter.match(attacker, sourceAbility.getControllerId(), sourceAbility, game)) { count++; } } else { diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java index e54b7b16bfc..377c4338310 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java @@ -38,8 +38,8 @@ public class CardsInAllGraveyardsCount implements DynamicValue { .filter(Objects::nonNull) .map(Player::getGraveyard) .mapToInt(graveyard -> graveyard.count( - filter, sourceAbility.getSourceId(), - sourceAbility.getControllerId(), game + filter, + sourceAbility.getControllerId(), sourceAbility, game )).sum(); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java index 6702e42e1d9..aa8a0194123 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java @@ -39,7 +39,7 @@ public class CardsInControllerGraveyardCount implements DynamicValue { Player player = game.getPlayer(sourceAbility.getControllerId()); if (player != null) { return amount * player.getGraveyard().count( - filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + filter, sourceAbility.getControllerId(), sourceAbility, game ); } return 0; diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java index 2d9698e03e4..a6dfbcc5a27 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInTargetPlayersGraveyardCount.java @@ -35,7 +35,7 @@ public class CardsInTargetPlayersGraveyardCount implements DynamicValue { if (filter == null) { return player.getGraveyard().size(); } else { - return player.getGraveyard().count(filter, sourceAbility.getControllerId(), sourceAbility.getSourceId(), game); + return player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility, game); } } return 0; diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesYouControlCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesYouControlCount.java index 16ae508e8ff..a82e8d10239 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesYouControlCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesYouControlCount.java @@ -15,7 +15,7 @@ public enum CreaturesYouControlCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_CREATURES, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_CREATURES, sourceAbility.getControllerId(), sourceAbility, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/DomainValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/DomainValue.java index 506438da00e..a7b75f4f8c0 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/DomainValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/DomainValue.java @@ -38,7 +38,7 @@ public enum DomainValue implements DynamicValue { return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS, - targetPlayer, sourceAbility.getSourceId(), game + targetPlayer, sourceAbility, game ).stream() .map(permanent -> SubType .getBasicLands() diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/GateYouControlCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/GateYouControlCount.java index 61a06c39c93..112ef391d8f 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/GateYouControlCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/GateYouControlCount.java @@ -22,7 +22,7 @@ public enum GateYouControlCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/GreatestSharedCreatureTypeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/GreatestSharedCreatureTypeCount.java index 3e03869ae29..7f5d86f1e2a 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/GreatestSharedCreatureTypeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/GreatestSharedCreatureTypeCount.java @@ -26,12 +26,12 @@ public enum GreatestSharedCreatureTypeCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return getValue(sourceAbility.getControllerId(), sourceAbility.getSourceId(), game); + return getValue(sourceAbility.getControllerId(), sourceAbility, game); } - public static int getValue(UUID playerId, UUID sourceId, Game game) { + public static int getValue(UUID playerId, Ability source, Game game) { List permanentList = game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_CONTROLLED_CREATURE, playerId, sourceId, game + StaticFilters.FILTER_CONTROLLED_CREATURE, playerId, source, game ); permanentList.removeIf(Objects::isNull); int changelings = permanentList diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestCMCOfPermanentValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestCMCOfPermanentValue.java index 65bac591598..bd32b21006c 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestCMCOfPermanentValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestCMCOfPermanentValue.java @@ -34,7 +34,7 @@ public class HighestCMCOfPermanentValue implements DynamicValue { Player controller = game.getPlayer(sourceAbility.getControllerId()); if (controller != null) { for (Permanent permanent : game.getBattlefield() - .getActivePermanents(filter, sourceAbility.getControllerId(), sourceAbility.getSourceId(), game)) { + .getActivePermanents(filter, sourceAbility.getControllerId(), sourceAbility, game)) { if ((!onlyIfCanBeSacrificed || controller.canPaySacrificeCost(permanent, sourceAbility, sourceAbility.getControllerId(), game)) && permanent.getManaValue() > value) { value = permanent.getManaValue(); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/LandsYouControlCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/LandsYouControlCount.java index f2439c2c4a3..e03161b676e 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/LandsYouControlCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/LandsYouControlCount.java @@ -16,7 +16,7 @@ public enum LandsYouControlCount implements DynamicValue { public int calculate(Game game, Ability sourceAbility, Effect effect) { return game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, - sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + sourceAbility.getControllerId(), sourceAbility, game ); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java index 7c732321273..d4d6b7af37d 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java @@ -40,7 +40,7 @@ public enum PartyCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { Cards cards = new CardsImpl(game.getBattlefield().getActivePermanents( - filter, sourceAbility.getControllerId(), sourceAbility.getSourceId(), game + filter, sourceAbility.getControllerId(), sourceAbility, game ).stream().collect(Collectors.toSet())); return subTypeAssigner.getRoleCount(cards, game); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java index ff959daaa48..8581096961a 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java @@ -41,7 +41,7 @@ public class PermanentsOnBattlefieldCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - int value = game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + int value = game.getBattlefield().count(filter, sourceAbility.getControllerId(), sourceAbility, game); if (multiplier != null) { value *= multiplier; } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsYouControlCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsYouControlCount.java index 8eef2b5ca7a..eb79385dabb 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsYouControlCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PermanentsYouControlCount.java @@ -15,7 +15,7 @@ public enum PermanentsYouControlCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); + return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT, sourceAbility.getControllerId(), sourceAbility, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/UrzaTerrainValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/UrzaTerrainValue.java index 06168a722d9..57fa2b3f0ce 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/UrzaTerrainValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/UrzaTerrainValue.java @@ -34,17 +34,17 @@ public enum UrzaTerrainValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { if (subType != SubType.MINE && game.getBattlefield().count( - mineFilter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + mineFilter, sourceAbility.getControllerId(), sourceAbility, game ) < 1) { return 1; } if (subType != SubType.TOWER && game.getBattlefield().count( - towerFilter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + towerFilter, sourceAbility.getControllerId(), sourceAbility, game ) < 1) { return 1; } if (subType != SubType.POWER_PLANT && game.getBattlefield().count( - powerPlantFilter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + powerPlantFilter, sourceAbility.getControllerId(), sourceAbility, game ) < 1) { return 1; } diff --git a/Mage/src/main/java/mage/abilities/effects/AsTurnedFaceUpEffect.java b/Mage/src/main/java/mage/abilities/effects/AsTurnedFaceUpEffect.java index ba3ec38a835..380a0f914b4 100644 --- a/Mage/src/main/java/mage/abilities/effects/AsTurnedFaceUpEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/AsTurnedFaceUpEffect.java @@ -53,7 +53,7 @@ public class AsTurnedFaceUpEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { if (optional) { Player controller = game.getPlayer(source.getControllerId()); - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (controller == null || object == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java index 0aaa523f803..4c491da8d29 100644 --- a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java @@ -139,7 +139,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { controllingPlayer = game.getPlayer(card.getOwnerId()); } - if (target != null && controllingPlayer != null && controllingPlayer.choose(auraOutcome, target, card.getId(), game)) { + if (target != null && controllingPlayer != null && controllingPlayer.choose(auraOutcome, target, source, game)) { targetId = target.getFirstTarget(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousRuleModifyingEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/ContinuousRuleModifyingEffectImpl.java index 55d5b56361f..17bec187922 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousRuleModifyingEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousRuleModifyingEffectImpl.java @@ -85,7 +85,7 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect public String getInfoMessage(Ability source, GameEvent event, Game game) { if (infoMessage == null) { String message; - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null) { message = source.getRule(messageToUser ? object.getIdName() : object.getLogName()); } else { diff --git a/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java b/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java index 52db89542d2..58d31684567 100644 --- a/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java @@ -98,7 +98,7 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl { Player controller = game.getPlayer(source.getControllerId()); MageObject object = game.getPermanentEntering(source.getSourceId()); if (object == null) { - object = game.getObject(source.getSourceId()); + object = game.getObject(source); } if (controller == null || object == null) { return false; diff --git a/Mage/src/main/java/mage/abilities/effects/PlaneswalkerRedirectionEffect.java b/Mage/src/main/java/mage/abilities/effects/PlaneswalkerRedirectionEffect.java index 6a4262deef4..617b819baac 100644 --- a/Mage/src/main/java/mage/abilities/effects/PlaneswalkerRedirectionEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/PlaneswalkerRedirectionEffect.java @@ -10,7 +10,6 @@ import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.DamageEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.stack.StackObject; import mage.players.Player; @@ -60,7 +59,7 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect { redirectTarget.add(planeswalker.get(0).getId(), game); } } else { - player.choose(Outcome.Damage, redirectTarget, null, game); + player.choose(Outcome.Damage, redirectTarget, source, game); } if (!game.isSimulation()) { Permanent redirectTo = game.getPermanent(redirectTarget.getFirstTarget()); diff --git a/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java b/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java index 404791d020f..2804b557e27 100644 --- a/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java @@ -65,7 +65,7 @@ public abstract class RedirectionEffect extends ReplacementEffectImpl { if (damageToRedirect < 1) { // if multiple replacement effect apply, the rest damage can be 0, so the effect is not applied/replaced return false; } - String sourceLogName = source != null ? game.getObject(source.getSourceId()).getLogName() + ": " : ""; + String sourceLogName = source != null ? game.getObject(source).getLogName() + ": " : ""; DamageEvent damageEvent = (DamageEvent) event; int restDamage = 0; if (damageEvent.getAmount() > amountToRedirect) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java index cf332b95df1..1d372b8b79e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java @@ -34,7 +34,7 @@ public class AffinityEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { // abilityToModify.getControllerId() works with Sen Triplets and in multiplayer games, see https://github.com/magefree/mage/issues/5931 - int count = game.getBattlefield().getActivePermanents(filter, abilityToModify.getControllerId(), source.getId(), game).size(); + int count = game.getBattlefield().getActivePermanents(filter, abilityToModify.getControllerId(), source, game).size(); CardUtil.reduceCost(abilityToModify, count); return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java index 6788f5db765..91e5c45a81f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java @@ -116,7 +116,7 @@ public class AmplifyEffect extends ReplacementEffectImpl { filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId()))); } - if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) <= 0) { + if (controller.getHand().count(filter, source.getControllerId(), source, game) <= 0) { return false; } if (!controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/BalanceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/BalanceEffect.java index 4b9a19756aa..e3d2e07c1d4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/BalanceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/BalanceEffect.java @@ -78,7 +78,7 @@ public class BalanceEffect extends OneShotEffect { if (lowestHandSize > 0) { TargetCardInHand target = new TargetCardInHand(lowestHandSize, filterCardHand); - if (target.choose(Outcome.Protect, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Protect, player.getId(), source.getSourceId(), source, game)) { for (Card card : allCardsInHand) { if (card != null && target.getTargets().contains(card.getId())) { cardsToKeep.add(card); @@ -136,12 +136,12 @@ public class BalanceEffect extends OneShotEffect { continue; } - List allPermanentsOfType = game.getBattlefield().getActivePermanents(filterPermanent, player.getId(), source.getSourceId(), game); + List allPermanentsOfType = game.getBattlefield().getActivePermanents(filterPermanent, player.getId(), source, game); List permanentsToKeep = new ArrayList<>(); if (lowestPermanentsCount > 0) { TargetControlledPermanent target = new TargetControlledPermanent(lowestPermanentsCount, lowestPermanentsCount, filterPermanent, true); - if (target.choose(Outcome.Protect, player.getId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Protect, player.getId(), source.getSourceId(), source, game)) { for (Permanent permanent : allPermanentsOfType) { if (permanent != null && target.getTargets().contains(permanent.getId())) { permanentsToKeep.add(permanent); diff --git a/Mage/src/main/java/mage/abilities/effects/common/BrainstormEffect.java b/Mage/src/main/java/mage/abilities/effects/common/BrainstormEffect.java index 7e3c5b843c4..d962b3a0227 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/BrainstormEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/BrainstormEffect.java @@ -39,7 +39,7 @@ public class BrainstormEffect extends OneShotEffect { private boolean putOnLibrary(Player player, Ability source, Game game) { TargetCardInHand target = new TargetCardInHand(); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.ReturnToHand, target, source, game); Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredControlledEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredControlledEffect.java index 1b2eafcf901..9b6023211c9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredControlledEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredControlledEffect.java @@ -59,7 +59,7 @@ public class CantBeCounteredControlledEffect extends ContinuousRuleModifyingEffe public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.isControlledBy(source.getControllerId()) - && filterTarget.match(spell, source.getSourceId(), source.getControllerId(), game)) { + && filterTarget.match(spell, source.getControllerId(), source, game)) { if (filterSource == null) { return true; } else { diff --git a/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredSourceEffect.java index a56d3744fb3..9520507800d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CantBeCounteredSourceEffect.java @@ -41,7 +41,7 @@ public class CantBeCounteredSourceEffect extends ContinuousRuleModifyingEffectIm @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { StackObject stackObject = game.getStack().getStackObject(event.getTargetId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (stackObject != null && sourceObject != null) { return sourceObject.getLogName() + " can't be countered by " + stackObject.getName(); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CantBeTargetedAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CantBeTargetedAllEffect.java index a2c34d6fc8d..c32aabf7c5b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CantBeTargetedAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CantBeTargetedAllEffect.java @@ -11,7 +11,6 @@ import mage.filter.FilterPermanent; import mage.filter.FilterSpell; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.stack.StackAbility; import mage.game.stack.StackObject; @@ -64,7 +63,7 @@ public class CantBeTargetedAllEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (permanent != null && filterTarget.match(permanent, source.getControllerId(), source, game)) { StackObject stackObject = game.getStack().getStackObject(event.getSourceId()); MageObject sourceObject; if (stackObject instanceof StackAbility) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/CastCardFromOutsideTheGameEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CastCardFromOutsideTheGameEffect.java index 4b032cfc69c..a4c2c8dbc22 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CastCardFromOutsideTheGameEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CastCardFromOutsideTheGameEffect.java @@ -55,7 +55,7 @@ public class CastCardFromOutsideTheGameEffect extends OneShotEffect { return false; } - Set filtered = cards.getCards(filterCard, source.getSourceId(), source.getControllerId(), game); + Set filtered = cards.getCards(filterCard, source.getControllerId(), source, game); if (filtered.isEmpty()) { if (!game.isSimulation()) { game.informPlayer(player, "You have no " + filterCard.getMessage() + " outside the game."); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChangeATargetOfTargetSpellAbilityToSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChangeATargetOfTargetSpellAbilityToSourceEffect.java index 530dc535f38..9cfb2c7675b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChangeATargetOfTargetSpellAbilityToSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChangeATargetOfTargetSpellAbilityToSourceEffect.java @@ -32,7 +32,7 @@ public class ChangeATargetOfTargetSpellAbilityToSourceEffect extends OneShotEffe @Override public boolean apply(Game game, Ability source) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (stackObject != null && sourceObject != null) { Targets targets = new Targets(); Ability sourceAbility; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseBasicLandTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseBasicLandTypeEffect.java index 180b5b08cf9..4ded699c7fe 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseBasicLandTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseBasicLandTypeEffect.java @@ -38,7 +38,7 @@ public class ChooseBasicLandTypeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { ChoiceImpl choices = new ChoiceBasicLandType(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseCardTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseCardTypeEffect.java index f965de8ed36..4f8404396b0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseCardTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseCardTypeEffect.java @@ -49,7 +49,7 @@ public class ChooseCardTypeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceCardType(true, cardTypes); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java index ddda5e3e108..bb311417e07 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java @@ -40,7 +40,7 @@ public class ChooseColorEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } ChoiceColor choice = new ChoiceColor(); if (exceptColor != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java index 1f89ff5a785..8eef0bebdc6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java @@ -33,7 +33,7 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceCreatureType(mageObject); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java index 8100a81ac6d..e2956dab7e0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseExpansionSetEffect.java @@ -36,7 +36,7 @@ public class ChooseExpansionSetEffect extends OneShotEffect { MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java index 1ea0e9c123b..72017f024bc 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseLandTypeEffect.java @@ -33,7 +33,7 @@ public class ChooseLandTypeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceImpl(true); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseOpponentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseOpponentEffect.java index 2b3064ea026..655607fe22a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseOpponentEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseOpponentEffect.java @@ -37,11 +37,11 @@ public class ChooseOpponentEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { TargetOpponent target = new TargetOpponent(true); - if (controller.choose(this.outcome, target, source.getSourceId(), game)) { + if (controller.choose(this.outcome, target, source, game)) { Player chosenPlayer = game.getPlayer(target.getFirstTarget()); if (chosenPlayer != null) { game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + chosenPlayer.getLogName()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChoosePlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChoosePlayerEffect.java index a7e0132e654..28046a14eb9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChoosePlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChoosePlayerEffect.java @@ -35,11 +35,11 @@ public class ChoosePlayerEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller != null && mageObject != null) { TargetPlayer target = new TargetPlayer(1, 1, true); - if (controller.choose(this.outcome, target, source.getSourceId(), game)) { + if (controller.choose(this.outcome, target, source, game)) { Player chosenPlayer = game.getPlayer(target.getFirstTarget()); if (chosenPlayer != null) { game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + chosenPlayer.getLogName()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java index 7fedba19817..e1578b23237 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseSecretOpponentEffect.java @@ -4,7 +4,6 @@ import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -37,14 +36,14 @@ public class ChooseSecretOpponentEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } if (controller == null || mageObject == null) { return false; } TargetOpponent targetOpponent = new TargetOpponent(true); targetOpponent.setTargetName("opponent (secretly)"); - controller.choose(outcome, targetOpponent, source.getSourceId(), game); + controller.choose(outcome, targetOpponent, source, game); if (targetOpponent.getFirstTarget() == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CipherEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CipherEffect.java index 8dc9bdfbfd5..2722901cc02 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CipherEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CipherEffect.java @@ -65,7 +65,7 @@ public class CipherEffect extends OneShotEffect { if (controller != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + if (target.canChoose(source.getControllerId(), source, game) && controller.chooseUse(outcome, "Cipher this spell to a creature?", source, game)) { controller.chooseTarget(outcome, target, source, game); Card sourceCard = game.getCard(source.getSourceId()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ClashEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ClashEffect.java index 0cfdb3838f0..1d5d983c28f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ClashEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ClashEffect.java @@ -95,7 +95,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton { Target target = new TargetOpponent(true); target.setTargetName("an opponent to clash with"); target.setNotTarget(true); - if (!controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (!controller.choose(Outcome.Benefit, target, source, game)) { return false; } Player opponent = game.getPlayer(target.getFirstTarget()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopyPermanentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopyPermanentEffect.java index 014f2368ec3..9b446d1fd08 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopyPermanentEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopyPermanentEffect.java @@ -80,7 +80,7 @@ public class CopyPermanentEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourcePermanent = game.getPermanentEntering(source.getSourceId()); if (sourcePermanent == null) { - sourcePermanent = game.getObject(source.getSourceId()); + sourcePermanent = game.getObject(source); } if (controller == null || sourcePermanent == null) { return false; @@ -91,8 +91,8 @@ public class CopyPermanentEffect extends OneShotEffect { } else { Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { - controller.choose(Outcome.Copy, target, source.getSourceId(), game); + if (target.canChoose(controller.getId(), source, game)) { + controller.choose(Outcome.Copy, target, source, game); copyFromPermanent = game.getPermanent(target.getFirstTarget()); } } @@ -157,7 +157,7 @@ public class CopyPermanentEffect extends OneShotEffect { // select new target auraTarget.setNotTarget(true); - if (!controller.choose(auraOutcome, auraTarget, source.getSourceId(), game)) { + if (!controller.choose(auraOutcome, auraTarget, source, game)) { return true; } UUID targetId = auraTarget.getFirstTarget(); 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 11eaed42696..6d2172f7d07 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageAllEffect.java @@ -54,7 +54,7 @@ public class DamageAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DestroyAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DestroyAllEffect.java index 8769ed1a232..e2c4d522270 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DestroyAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DestroyAllEffect.java @@ -44,7 +44,7 @@ public class DestroyAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.destroy(source, game, noRegen); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/DetainAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DetainAllEffect.java index 99c5c5b07bb..beaf758408b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DetainAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DetainAllEffect.java @@ -42,7 +42,7 @@ public class DetainAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List detainedObjects = new ArrayList<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!game.isSimulation()) { game.informPlayers("Detained permanent: " + permanent.getName()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java index 62b88f4db07..64be3fed9b6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java @@ -77,7 +77,7 @@ public class DevourEffect extends ReplacementEffectImpl { } Target target = new TargetControlledPermanent(1, Integer.MAX_VALUE, devourFactor.getFilter(), true); target.setRequired(false); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } if (!controller.chooseUse(Outcome.Detriment, "Devour " + devourFactor.getCardType().toString().toLowerCase() + "s?", source, game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java index 0d7a295b6cd..c1d55d4ef8a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java @@ -42,7 +42,7 @@ public class DiscardCardControllerTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkTrigger(GameEvent event, Game game) { return event.getPlayerId().equals(getControllerId()) - && filter.match(game.getCard(event.getTargetId()), getSourceId(), getControllerId(), game); + && filter.match(game.getCard(event.getTargetId()), getControllerId(), this, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoIfClashWonEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DoIfClashWonEffect.java index 3e04f8611ba..4d2aa61f08b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoIfClashWonEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoIfClashWonEffect.java @@ -45,7 +45,7 @@ public class DoIfClashWonEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = getPayingPlayer(game, source); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (player != null && mageObject != null) { String message = null; if (chooseUseText != null) { 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 6ef58bb99b5..6db6728c292 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java @@ -80,7 +80,7 @@ public class DoIfCostPaid extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = getPayingPlayer(game, source); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (player != null && mageObject != null) { String message; if (chooseUseText == null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java index 94e9dad3259..47605b3748d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java @@ -63,7 +63,7 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Cost costToPay; String costValueMessage; if (controller != null && sourceObject != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessControllerPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessControllerPaysEffect.java index 86e5c36b7dc..d92859a57ee 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessControllerPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessControllerPaysEffect.java @@ -49,7 +49,7 @@ public class DoUnlessControllerPaysEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { String message; if (chooseUseText == null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessTargetPlayerOrTargetsControllerPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessTargetPlayerOrTargetsControllerPaysEffect.java index 2ae6240858d..4a67e5ba406 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessTargetPlayerOrTargetsControllerPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessTargetPlayerOrTargetsControllerPaysEffect.java @@ -73,7 +73,7 @@ public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEf if (targetPermanent != null) { player = game.getPlayer(targetPermanent.getControllerId()); } - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { Cost costToPay; String costValueMessage; diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java b/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java index b44e018038b..a58dc4974dd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java @@ -41,7 +41,7 @@ public class DoWhenCostPaid extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (player == null || mageObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java index c5351ce1fc4..60289092c21 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java @@ -35,7 +35,7 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "{this} doesn't untap (" + mageObject.getLogName() + ')'; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java index e016b17c4dd..ff145ffa222 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java @@ -77,7 +77,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); Permanent permanentToUntap = game.getPermanent((event.getTargetId())); if (permanentToUntap != null && mageObject != null) { return permanentToUntap.getLogName() + " doesn't untap (" + mageObject.getLogName() + ')'; diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepAllEffect.java index 075d5614c4e..372a63a9fdc 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepAllEffect.java @@ -12,7 +12,6 @@ import mage.constants.TargetController; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; @@ -77,7 +76,7 @@ public class DontUntapInControllersUntapStepAllEffect extends ContinuousRuleModi throw new RuntimeException("Type of TargetController not supported!"); } if (game.isActivePlayer(permanent.getControllerId()) && // controller's untap step - filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + filter.match(permanent, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInPlayersNextUntapStepAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInPlayersNextUntapStepAllEffect.java index cd10dc9649c..5faf2d88abe 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInPlayersNextUntapStepAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInPlayersNextUntapStepAllEffect.java @@ -11,7 +11,6 @@ import mage.constants.PhaseStep; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; @@ -55,7 +54,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); Permanent permanentToUntap = game.getPermanent((event.getTargetId())); if (permanentToUntap != null && mageObject != null) { return permanentToUntap.getLogName() + " doesn't untap (" + mageObject.getLogName() + ')'; @@ -102,7 +101,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi } if (game.isActivePlayer(permanent.getControllerId()) && // controller's untap step - filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + filter.match(permanent, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java b/Mage/src/main/java/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java index 0a02c0a162f..64d8c3fe096 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java @@ -47,7 +47,7 @@ public class EnterBattlefieldPayCostOrPutGraveyardEffect extends ReplacementEffe @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && cost != null && sourceObject != null) { boolean replace = true; if (cost.canPay(source, source, player.getId(), game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldUnderControlOfOpponentOfChoiceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldUnderControlOfOpponentOfChoiceEffect.java index 383b7e7ed5f..149732da4f3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldUnderControlOfOpponentOfChoiceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldUnderControlOfOpponentOfChoiceEffect.java @@ -43,7 +43,7 @@ public class EntersBattlefieldUnderControlOfOpponentOfChoiceEffect extends OneSh } Target target = new TargetOpponent(); target.setNotTarget(true); - if (!controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + if (!controller.choose(Outcome.Benefit, target, source, game)) { return false; } Player opponent = game.getPlayer(target.getFirstTarget()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java b/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java index 81b1f63db04..95b1f92a50f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java @@ -87,7 +87,7 @@ class EpicReplacementEffect extends ContinuousRuleModifyingEffectImpl { @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "For the rest of the game, you can't cast spells (Epic - " + mageObject.getName() + ')'; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileAllEffect.java index b6852c2c89c..a2fffcfa115 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExileAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileAllEffect.java @@ -49,7 +49,7 @@ public class ExileAllEffect extends OneShotEffect { } Cards cards = new CardsImpl(); game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game ).stream().forEach(cards::add); if (forSource) { return controller.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileFromZoneTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileFromZoneTargetEffect.java index 7007493a089..9f30540539b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExileFromZoneTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileFromZoneTargetEffect.java @@ -67,7 +67,7 @@ public class ExileFromZoneTargetEffect extends OneShotEffect { break; default: } - if (target == null || !target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target == null || !target.canChoose(player.getId(), source, game)) { return true; } target.chooseTarget(Outcome.Exile, player.getId(), source, game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java index 58d185cbffb..699b3b79d53 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java @@ -63,7 +63,7 @@ public class ExileGraveyardAllPlayersEffect extends OneShotEffect { } Player player = game.getPlayer(playerId); if (player != null) { - toExile.addAll(player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)); + toExile.addAll(player.getGraveyard().getCards(filter, source.getControllerId(), source, game)); } } controller.moveCards(toExile, Zone.EXILED, source, game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/FlipCoinEffect.java b/Mage/src/main/java/mage/abilities/effects/common/FlipCoinEffect.java index 21036b14f8b..ec30a8ed804 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/FlipCoinEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/FlipCoinEffect.java @@ -59,7 +59,7 @@ public class FlipCoinEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller == null || mageObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/GetEmblemEffect.java b/Mage/src/main/java/mage/abilities/effects/common/GetEmblemEffect.java index 907dfdf70ad..e99b3799482 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/GetEmblemEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/GetEmblemEffect.java @@ -35,7 +35,7 @@ public class GetEmblemEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java index eb9aa7b52ed..2c9dce9eff8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/GetEmblemTargetPlayerEffect.java @@ -36,7 +36,7 @@ public class GetEmblemTargetPlayerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java index beedd03ac87..2b346b9a835 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java @@ -32,7 +32,7 @@ public class LivingDeathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { Map> exiledCards = new HashMap<>(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookAtTargetPlayerHandEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookAtTargetPlayerHandEffect.java index 2425125ea55..6d3e191da93 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookAtTargetPlayerHandEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookAtTargetPlayerHandEffect.java @@ -32,7 +32,7 @@ public class LookAtTargetPlayerHandEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (you != null && targetPlayer != null) { you.lookAtCards(sourceObject != null ? sourceObject.getIdName() : null, targetPlayer.getHand(), game); return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java index ddcb26dd4d3..29cc28dcf9d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java @@ -208,7 +208,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff protected void actionWithSelectedCards(Cards cards, Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null && numberToPick.calculate(game, source, this) > 0 - && cards.count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { + && cards.count(filter, source.getControllerId(), source, game) > 0) { if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), source, game)) { FilterCard pickFilter = filter.copy(); pickFilter.setMessage(getPickText()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryMayPutToBottomEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryMayPutToBottomEffect.java index 45422fca4ba..a505bd034b6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryMayPutToBottomEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryMayPutToBottomEffect.java @@ -29,7 +29,7 @@ public class LookLibraryMayPutToBottomEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null || controller == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryTopCardTargetPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryTopCardTargetPlayerEffect.java index 39b69998c8c..7e80342e94f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryTopCardTargetPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryTopCardTargetPlayerEffect.java @@ -67,7 +67,7 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && targetPlayer != null && sourceObject != null) { Cards cards = new CardsImpl(); cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java b/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java index 28eb5727ea1..21cc64104ab 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/MeldEffect.java @@ -48,11 +48,11 @@ public class MeldEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { // Find the two permanents to meld. - UUID sourceId = source.getSourceId(); + UUID sourceId = source != null ? source.getSourceId() : null; FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature named " + meldWithName); filter.add(new NamePredicate(meldWithName)); TargetPermanent target = new TargetControlledCreaturePermanent(filter); - Set meldWithList = target.possibleTargets(sourceId, source.getControllerId(), game); + Set meldWithList = target.possibleTargets(source.getControllerId(), source, game); if (meldWithList.isEmpty()) { return false; // possible permanent has left the battlefield meanwhile } @@ -60,7 +60,7 @@ public class MeldEffect extends OneShotEffect { if (meldWithList.size() == 1) { meldWithId = meldWithList.iterator().next(); } else { - if (controller.choose(Outcome.BoostCreature, target, sourceId, game)) { + if (controller.choose(Outcome.BoostCreature, target, source, game)) { meldWithId = target.getFirstTarget(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/OpponentsCantCastChosenUntilNextTurnEffect.java b/Mage/src/main/java/mage/abilities/effects/common/OpponentsCantCastChosenUntilNextTurnEffect.java index 2eba8953dcd..5fed90bb224 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/OpponentsCantCastChosenUntilNextTurnEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/OpponentsCantCastChosenUntilNextTurnEffect.java @@ -30,7 +30,7 @@ public class OpponentsCantCastChosenUntilNextTurnEffect extends ContinuousRuleMo @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (mageObject != null && cardName != null) { return "You can't cast a card named " + cardName + " (" + mageObject.getIdName() + ")."; diff --git a/Mage/src/main/java/mage/abilities/effects/common/PermanentsEnterBattlefieldTappedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PermanentsEnterBattlefieldTappedEffect.java index dd46edbfbe1..95eb1e993fd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PermanentsEnterBattlefieldTappedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PermanentsEnterBattlefieldTappedEffect.java @@ -49,7 +49,7 @@ public class PermanentsEnterBattlefieldTappedEffect extends ReplacementEffectImp @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/PopulateEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PopulateEffect.java index 26da099df0b..a42709dc0da 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PopulateEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PopulateEffect.java @@ -66,10 +66,10 @@ public class PopulateEffect extends OneShotEffect { } Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return true; } - player.choose(Outcome.Copy, target, source.getSourceId(), game); + player.choose(Outcome.Copy, target, source, game); Permanent tokenToCopy = game.getPermanent(target.getFirstTarget()); if (tokenToCopy == null) { return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllObjectsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllObjectsEffect.java index c8984f75d88..8644fc61e90 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllObjectsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllObjectsEffect.java @@ -60,7 +60,7 @@ public class PreventAllDamageByAllObjectsEffect extends PreventionEffectImpl { return false; } if (filter instanceof FilterInPlay) { - return ((FilterInPlay) filter).match(damageSource, source.getSourceId(), source.getControllerId(), game); + return ((FilterInPlay) filter).match(damageSource, source.getControllerId(), source, game); } return filter.match(damageSource, game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllPermanentsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllPermanentsEffect.java index 58d7564d4de..1668c1a976d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllPermanentsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageByAllPermanentsEffect.java @@ -55,7 +55,7 @@ public class PreventAllDamageByAllPermanentsEffect extends PreventionEffectImpl return true; } Permanent permanent = game.getPermanent(damageEvent.getSourceId()); - if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (filter.match(permanent, source.getControllerId(), source, game)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageFromChosenSourceToYouEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageFromChosenSourceToYouEffect.java index ca8f90ff46d..fc4ed76b548 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageFromChosenSourceToYouEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageFromChosenSourceToYouEffect.java @@ -44,7 +44,7 @@ public class PreventAllDamageFromChosenSourceToYouEffect extends PreventionEffec @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToAllEffect.java index eb839ccc3c7..c7b95c41beb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToAllEffect.java @@ -92,7 +92,7 @@ public class PreventAllDamageToAllEffect extends PreventionEffectImpl { object = game.getObject(event.getTargetId()); } if (object != null) { - return filter.match(object, source.getSourceId(), source.getControllerId(), game); + return filter.match(object, source.getControllerId(), source, game); } } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventAllNonCombatDamageToAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventAllNonCombatDamageToAllEffect.java index 8edf712f0c9..750207a27eb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventAllNonCombatDamageToAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventAllNonCombatDamageToAllEffect.java @@ -49,7 +49,7 @@ public class PreventAllNonCombatDamageToAllEffect extends PreventionEffectImpl { && !((DamageEvent) event).isCombatDamage()) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } return andToYou && source.getControllerId().equals(event.getTargetId()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageBySourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageBySourceEffect.java index f31559a4ef0..56409db455a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageBySourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageBySourceEffect.java @@ -48,7 +48,7 @@ public class PreventDamageBySourceEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); mageObjectReference = new MageObjectReference(target.getFirstTarget(), game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java index 85e8cbaf888..e6324d95873 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java @@ -48,7 +48,7 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl public void init(Ability source, Game game) { super.init(source, game); Target target = source.getTargets().get(0); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (target instanceof TargetAmount && sourceObject != null) { TargetAmount multiTarget = (TargetAmount) target; for (UUID targetId : multiTarget.getTargets()) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToTargetEffect.java index 659ec194e58..68a54ea129e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToTargetEffect.java @@ -48,7 +48,7 @@ public class PreventNextDamageFromChosenSourceToTargetEffect extends PreventionE @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToYouEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToYouEffect.java index 86f10acf760..de451539114 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToYouEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventNextDamageFromChosenSourceToYouEffect.java @@ -47,7 +47,7 @@ public class PreventNextDamageFromChosenSourceToYouEffect extends PreventionEffe @Override public void init(Ability source, Game game) { - this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + this.targetSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/PutCardFromHandOntoBattlefieldEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PutCardFromHandOntoBattlefieldEffect.java index 5b07d886218..9e9f0e83e3c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PutCardFromHandOntoBattlefieldEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PutCardFromHandOntoBattlefieldEffect.java @@ -65,7 +65,7 @@ public class PutCardFromHandOntoBattlefieldEffect extends OneShotEffect { } if (player.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game)) { TargetCardInHand target = new TargetCardInHand(filter); - if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (player.choose(Outcome.PutCardInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { return player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null); diff --git a/Mage/src/main/java/mage/abilities/effects/common/RegenerateAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RegenerateAllEffect.java index 009d38db171..e3c4bc5540a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RegenerateAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RegenerateAllEffect.java @@ -33,7 +33,7 @@ public class RegenerateAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { RegenerateTargetEffect regenEffect = new RegenerateTargetEffect(); regenEffect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(regenEffect, source); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandChosenPermanentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandChosenPermanentEffect.java index f9e144fd408..6d8052f3bd1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandChosenPermanentEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandChosenPermanentEffect.java @@ -47,7 +47,7 @@ public class ReturnToHandChosenPermanentEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (player != null) { - int available = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); + int available = game.getBattlefield().count(filter, source.getControllerId(), source, game); if (available > 0) { TargetControlledPermanent target = new TargetControlledPermanent(Math.min(number, available), number, filter, true); if (player.chooseTarget(this.outcome, target, source, game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromBattlefieldAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromBattlefieldAllEffect.java index 67c74771949..b8612237a5b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromBattlefieldAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromBattlefieldAllEffect.java @@ -37,7 +37,7 @@ public class ReturnToHandFromBattlefieldAllEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Set permanentsToHand = new HashSet<>(); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanentsToHand.add(permanent); } controller.moveCards(permanentsToHand, Zone.HAND, source, game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java index 33b9c52c2d0..42068a28963 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java @@ -61,7 +61,7 @@ public class ReturnToHandFromGraveyardAllEffect extends OneShotEffect { continue; } player.moveCards(player.getGraveyard().getCards( - filter, source.getSourceId(), player.getId(), game + filter, player.getId(), source, game ), Zone.HAND, source, game); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java index 8b4c04b1d5d..f30a0b3c16f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java @@ -62,7 +62,7 @@ public class ReturnToHandSourceEffect extends OneShotEffect { MageObject mageObject; if (returnFromNextZone && game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } else { mageObject = source.getSourceObjectIfItStillExists(game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealCardsFromLibraryUntilEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealCardsFromLibraryUntilEffect.java index 65043712988..fa4c695c654 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RevealCardsFromLibraryUntilEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RevealCardsFromLibraryUntilEffect.java @@ -60,7 +60,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || !controller.getLibrary().hasCards()) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealHandSourceControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealHandSourceControllerEffect.java index cbbff8ad398..e65fc55159a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RevealHandSourceControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RevealHandSourceControllerEffect.java @@ -26,7 +26,7 @@ public class RevealHandSourceControllerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { player.revealCards(sourceObject.getIdName(), player.getHand(), game); return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealHandTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealHandTargetEffect.java index e17ead692c1..0aafaee0856 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RevealHandTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RevealHandTargetEffect.java @@ -35,7 +35,7 @@ public class RevealHandTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null && sourceObject != null) { player.revealCards(sourceObject.getIdName(), player.getHand(), game); return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealLibraryPutIntoHandEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealLibraryPutIntoHandEffect.java index c77e3560f4d..cd6f088d4aa 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RevealLibraryPutIntoHandEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RevealLibraryPutIntoHandEffect.java @@ -60,7 +60,7 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller == null || sourceObject == null) { return false; } @@ -72,7 +72,7 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect { Set cardsList = cards.getCards(game); Cards cardsToHand = new CardsImpl(); for (Card card : cardsList) { - if (filter.match(card, source.getSourceId(), controller.getId(), game)) { + if (filter.match(card, controller.getId(), source, game)) { cardsToHand.add(card); cards.remove(card); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java index 345f811de87..f60b198184e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java @@ -29,7 +29,7 @@ public class RevealTopLandToBattlefieldElseHandEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null || controller == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/RollDiceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RollDiceEffect.java index abd1ac95782..44bf5ffbbf0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RollDiceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RollDiceEffect.java @@ -43,7 +43,7 @@ public class RollDiceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && mageObject != null) { controller.rollDice(outcome, source, game, numSides); return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java index 836e5226a57..c47e0c39193 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java @@ -59,7 +59,7 @@ public class RollPlanarDieEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (controller != null && mageObject != null) { PlanarDieRollResult planarRoll = controller.rollPlanarDie(outcome, source, game); if (planarRoll == PlanarDieRollResult.CHAOS_ROLL && chaosEffects != null && chaosTargets != null) { @@ -78,7 +78,7 @@ public class RollPlanarDieEffect extends OneShotEffect { } boolean done = false; while (controller.canRespond() && effect != null && !done) { - if (target != null && !target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target != null && !target.isChosen() && target.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Benefit, target, source, game); source.addTarget(target); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java index 6077f6174b4..27e4f9d13d3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java @@ -64,9 +64,9 @@ public class SacrificeAllEffect extends OneShotEffect { if (player != null) { int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game)); TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { while (!target.isChosen() && player.canRespond()) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); } perms.addAll(target.getTargets()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/SacrificeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SacrificeEffect.java index 5d210b7086b..d19843d6247 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SacrificeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SacrificeEffect.java @@ -56,9 +56,9 @@ public class SacrificeEffect extends OneShotEffect { int realCount = game.getBattlefield().countAll(newFilter, player.getId(), game); amount = Math.min(amount, realCount); Target target = new TargetPermanent(amount, amount, newFilter, true); - if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) { + if (amount > 0 && target.canChoose(player.getId(), source, game)) { while (!target.isChosen() - && target.canChoose(source.getSourceId(), player.getId(), game) + && target.canChoose(player.getId(), source, game) && player.canRespond()) { player.chooseTarget(Outcome.Sacrifice, target, source, game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsEffect.java index 279f5562547..1e142c4f709 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsEffect.java @@ -63,7 +63,7 @@ public class SacrificeOpponentsEffect extends OneShotEffect { int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game)); if (numTargets > 0) { TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); perms.addAll(target.getTargets()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsUnlessPayEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsUnlessPayEffect.java index 9eea1cc657b..d0e86cc5886 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsUnlessPayEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SacrificeOpponentsUnlessPayEffect.java @@ -127,7 +127,7 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect { if (numTargets > 0) { TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { player.chooseTarget(Outcome.Sacrifice, target, source, game); permsToSacrifice.addAll(target.getTargets()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/TapAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TapAllEffect.java index f2a38fcf6de..fd68f43db37 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/TapAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/TapAllEffect.java @@ -37,7 +37,7 @@ public class TapAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.tap(source, game); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java index a265735c827..3cb389c5555 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapAllEffect.java @@ -29,7 +29,7 @@ public class UntapAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.untap(game); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java index c518b69802e..159f3bfad36 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapLandsEffect.java @@ -64,7 +64,7 @@ public class UntapLandsEffect extends OneShotEffect { tappedLands = game.getBattlefield().getAllActivePermanents(filter, game).size(); } TargetLandPermanent target = new TargetLandPermanent(upTo ? 0 : Math.min(tappedLands, amount), amount, filter, true); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (target.canChoose(source.getControllerId(), source, game)) { // UI Shortcut: Check if any lands are already tapped. If there are equal/fewer than amount, give the option to add those in to be untapped now. if (tappedLands <= amount && upTo) { @@ -74,7 +74,7 @@ public class UntapLandsEffect extends OneShotEffect { } } } - if (target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) { + if (target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), source, game)) { for (UUID targetId : target.getTargets()) { Permanent p = game.getPermanent(targetId); if (p != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java index 794918de4f9..b0806b06ee5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java @@ -51,7 +51,7 @@ public class AttacksIfAbleAllEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (filter.match(permanent, source.getControllerId(), source, game)) { if (eachCombat) { return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java index 494708e07e0..44d10f094c7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java @@ -41,7 +41,7 @@ public class BlocksIfAbleAllEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java index f3a1114bae2..60b424e89ba 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java @@ -42,7 +42,7 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { Permanent permanent = game.getPermanent(objectId); - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } private String getText() { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockAdditionalCreatureAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockAdditionalCreatureAllEffect.java index fdcbd7e4d4b..db83a18825d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockAdditionalCreatureAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockAdditionalCreatureAllEffect.java @@ -41,7 +41,7 @@ public class CanBlockAdditionalCreatureAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent != null) { // maxBlocks = 0 equals to "can block any number of creatures" if (amount > 0) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAnyPlayerAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAnyPlayerAllEffect.java index 40339821a31..adabfff371f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAnyPlayerAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAnyPlayerAllEffect.java @@ -38,7 +38,7 @@ public class CantAttackAnyPlayerAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java index 7e4db0db576..60f2a70d9c7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java @@ -36,7 +36,7 @@ public class CantAttackBlockAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java index b47fd8d748b..fcdac865536 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java @@ -44,7 +44,7 @@ public class CantAttackYouAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filterAttacker.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filterAttacker.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouOrPlaneswalkerAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouOrPlaneswalkerAllEffect.java index 7bc79625d7c..a5c208b1c50 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouOrPlaneswalkerAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouOrPlaneswalkerAllEffect.java @@ -34,7 +34,7 @@ public class CantAttackYouOrPlaneswalkerAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filterAttacker.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filterAttacker.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayManaAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayManaAllEffect.java index 34d21a234ef..cfd3e5e2f14 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayManaAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouUnlessPayManaAllEffect.java @@ -50,7 +50,7 @@ public class CantAttackYouUnlessPayManaAllEffect extends PayCostToAttackBlockEff // check if attacking creature fullfills filter criteria if (filterCreaturePermanent != null) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (!filterCreaturePermanent.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (!filterCreaturePermanent.match(permanent, source.getControllerId(), source, game)) { return false; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java index 1894ad25e08..e3bd52c7b94 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java @@ -41,6 +41,6 @@ public class CantBeBlockedAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllSourceEffect.java index 67930d2c521..f1f9fa54a7e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllSourceEffect.java @@ -35,7 +35,7 @@ public class CantBeBlockedByAllSourceEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game); + return !filterBlockedBy.match(blocker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllTargetEffect.java index af0518dc931..0d65d986daa 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByAllTargetEffect.java @@ -34,7 +34,7 @@ public class CantBeBlockedByAllTargetEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game); + return !filterBlockedBy.match(blocker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAllEffect.java index 51a6dc95308..ca807c9fe84 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAllEffect.java @@ -32,12 +32,12 @@ public class CantBeBlockedByCreaturesAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filterCreatures.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filterCreatures.match(permanent, source.getControllerId(), source, game); } @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - return !filterBlockedBy.match(blocker, source.getSourceId(), source.getControllerId(), game); + return !filterBlockedBy.match(blocker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java index 83259e873bf..2cf6dae0d13 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java @@ -36,7 +36,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game); + return !filter.match(blocker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java index 1f9cb728440..c858b739574 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesSourceEffect.java @@ -33,7 +33,7 @@ public class CantBeBlockedByCreaturesSourceEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game); + return !filter.match(blocker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAllEffect.java index dc4d48bf541..f36a37fc870 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByMoreThanOneAllEffect.java @@ -54,7 +54,7 @@ public class CantBeBlockedByMoreThanOneAllEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { switch (layer) { case RulesEffects: - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { perm.setMaxBlockedBy(amount); } break; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java index 4629f6ed64f..a65111d02ec 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java @@ -52,7 +52,7 @@ public class CantBeBlockedByOneAllEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { switch (layer) { case RulesEffects: - for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { perm.setMinBlockedBy(amount); } break; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedTargetEffect.java index 0d2a648f54a..081b87b3ef1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedTargetEffect.java @@ -47,7 +47,7 @@ public class CantBeBlockedTargetEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game); + return !filter.match(blocker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java index dea9bc16ecd..9480fd30fd2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java @@ -27,7 +27,7 @@ public class CantBlockAllEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java index c3a680b7712..dc1ebe1a73b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java @@ -72,7 +72,7 @@ public class CantBlockAttachedEffect extends RestrictionEffect { if (attacker == null) { return true; } - return !filter.match(attacker, source.getSourceId(), source.getControllerId(), game); + return !filter.match(attacker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java index 0d888e8caba..839c339f7d4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java @@ -40,7 +40,7 @@ public class CantBlockCreaturesSourceEffect extends RestrictionEffect { if (attacker == null) { return true; } - return !filter.match(attacker, source.getSourceId(), source.getControllerId(), game); + return !filter.match(attacker, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessPayManaAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessPayManaAllEffect.java index 8c2af74b6b7..9311f78c620 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessPayManaAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessPayManaAllEffect.java @@ -47,7 +47,7 @@ public class CantBlockUnlessPayManaAllEffect extends PayCostToAttackBlockEffectI // check if blocking creature fullfills filter criteria if (filterCreaturePermanent != null) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (!filterCreaturePermanent.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + if (!filterCreaturePermanent.match(permanent, source.getControllerId(), source, game)) { return false; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessYouControlSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessYouControlSourceEffect.java index cba3316d96d..3e1fed9d0dd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessYouControlSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockUnlessYouControlSourceEffect.java @@ -38,6 +38,6 @@ public class CantBlockUnlessYouControlSourceEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { return permanent.getId().equals(source.getSourceId()) - && game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0; + && game.getBattlefield().count(filter, source.getControllerId(), source, game) == 0; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAllEffect.java index a35c0a5af1c..8a994bcbb65 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubtypeAllEffect.java @@ -34,7 +34,7 @@ public class AddCardSubtypeAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (perm != null) { perm.addSubType(game, addedSubtype); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorAllEffect.java index 144c9c35095..3e0c8f12b14 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorAllEffect.java @@ -106,7 +106,7 @@ public class BecomesColorAllEffect extends ContinuousEffectImpl { return false; } if (setColor != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent != null) { switch (layer) { case ColorChangingEffects_5: diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java index 948ee55a5c9..1916bb5257d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorSourceEffect.java @@ -96,7 +96,7 @@ public class BecomesColorSourceEffect extends ContinuousEffectImpl { return false; } if (setColor != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { sourceObject.getColor(game).setColor(setColor); } else { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java index 57eabc7a822..065485cef8c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java @@ -63,7 +63,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { super.init(source, game); if (this.affectedObjectsSet) { for (Permanent perm : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game)) { + filter, source.getControllerId(), source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } @@ -83,7 +83,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { } } else { affectedPermanents = new HashSet<>(game.getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)); + .getActivePermanents(filter, source.getControllerId(), source, game)); } for (Permanent permanent : affectedPermanents) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureAllEffect.java index 35d9a79ad1f..4fca7dd9164 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureAllEffect.java @@ -45,7 +45,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple @Override public void init(Ability source, Game game) { super.init(source, game); - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!perm.isFaceDown(game) && !perm.isTransformable()) { affectedObjectList.add(new MageObjectReference(perm, game)); perm.setFaceDown(true, game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesSubtypeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesSubtypeAllEffect.java index d3a15c2dc67..104a4cddfb5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesSubtypeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesSubtypeAllEffect.java @@ -52,7 +52,7 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { boolean flag = false; - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent == null) { continue; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllEffect.java index f7a92d70af3..0acc9f9ed2b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllEffect.java @@ -88,7 +88,7 @@ public class BoostAllEffect extends ContinuousEffectImpl { super.init(source, game); setRuntimeData(source, game); if (this.affectedObjectsSet) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } @@ -114,7 +114,7 @@ public class BoostAllEffect extends ContinuousEffectImpl { } } else { setRuntimeData(source, game); - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) { perm.addPower(power.calculate(game, source, this)); perm.addToughness(toughness.calculate(game, source, this)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostOpponentsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostOpponentsEffect.java index 1d9aecd51b5..b84b47ab7a1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostOpponentsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostOpponentsEffect.java @@ -51,7 +51,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl { super.init(source, game); if (this.affectedObjectsSet) { Set opponents = game.getOpponents(source.getControllerId()); - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (opponents.contains(perm.getControllerId())) { affectedObjectList.add(new MageObjectReference(perm, game)); } @@ -75,7 +75,7 @@ public class BoostOpponentsEffect extends ContinuousEffectImpl { } } } else { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (opponents.contains(perm.getControllerId())) { perm.addPower(power); perm.addToughness(toughness); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java index de21045bd1d..a2324fa7515 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java @@ -61,10 +61,10 @@ public class CastAsThoughItHadFlashAllEffect extends AsThoughEffectImpl { Card cardCopy = card.copy(); cardCopy.removeAllCardTypes(game); cardCopy.addCardType(game, CardType.CREATURE); - return filter.match(cardCopy, source.getSourceId(), affectedControllerId, game); + return filter.match(cardCopy, affectedControllerId, source, game); } } - return filter.match(card, source.getSourceId(), affectedControllerId, game); + return filter.match(card, affectedControllerId, source, game); } } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CastFromHandWithoutPayingManaCostEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CastFromHandWithoutPayingManaCostEffect.java index 03efc93852e..872bc6dd5d7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CastFromHandWithoutPayingManaCostEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CastFromHandWithoutPayingManaCostEffect.java @@ -88,7 +88,7 @@ enum IsBeingCastFromHandCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object instanceof SplitCardHalf || object instanceof AdventureCardSpell || object instanceof ModalDoubleFacesCardHalf) { UUID mainCardId = ((Card) object).getMainCard().getId(); object = game.getObject(mainCardId); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CreaturesCantGetOrHaveAbilityEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CreaturesCantGetOrHaveAbilityEffect.java index 62d2c3d7d61..40b37117d15 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CreaturesCantGetOrHaveAbilityEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CreaturesCantGetOrHaveAbilityEffect.java @@ -45,7 +45,7 @@ public class CreaturesCantGetOrHaveAbilityEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent != null) { permanent.removeAbility(ability, source.getSourceId(), game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java index 52c35b7c411..c15339bbf43 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainAbilityAllEffect.java @@ -1,6 +1,5 @@ package mage.abilities.effects.common.continuous; -import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.Mode; @@ -8,7 +7,6 @@ import mage.abilities.TriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.mana.ActivatedManaAbilityImpl; -import mage.abilities.mana.SimpleManaAbility; import mage.constants.*; import mage.filter.FilterPermanent; import mage.game.Game; @@ -16,8 +14,6 @@ import mage.game.permanent.Permanent; import java.util.Iterator; import java.util.Locale; -import java.util.Map; -import java.util.UUID; /** * @author Loki @@ -70,7 +66,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { super.init(source, game); setRuntimeData(source, game); if (this.affectedObjectsSet) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } @@ -99,7 +95,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl { } } else { setRuntimeData(source, game); - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) { perm.addAbility(ability, source.getSourceId(), game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java index 40742c11582..3a1ffcdfc15 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java @@ -49,7 +49,7 @@ public class GainControlAllEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield() .getActivePermanents(filter, - source.getControllerId(), source.getSourceId(), game)) { + source.getControllerId(), source, game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, controllingPlayerId); effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllOwnedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllOwnedEffect.java index acac92fa1e4..2158438e4ba 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllOwnedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllOwnedEffect.java @@ -40,7 +40,7 @@ public class GainControlAllOwnedEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); for (Permanent permanent : game.getBattlefield().getActivePermanents( - filter, source.getControllerId(), source.getSourceId(), game + filter, source.getControllerId(), source, game )) { affectedObjectList.add(new MageObjectReference(permanent, game)); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java index fcf35711260..8d9f6c62fc9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorAllEffect.java @@ -49,7 +49,7 @@ public class GainProtectionFromColorAllEffect extends GainAbilityAllEffect { @Override public void init(Ability source, Game game) { super.init(source, game); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (sourceObject != null && controller != null) { if (!controller.choose(Outcome.Protect, choice, game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java index dee3466f5a9..fd27ec25443 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java @@ -46,7 +46,7 @@ public class GainProtectionFromColorTargetEffect extends GainAbilityTargetEffect @Override public void init(Ability source, Game game) { super.init(source, game); //To change body of generated methods, choose Tools | Templates. - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); Player controller = game.getPlayer(source.getControllerId()); if (sourceObject != null && controller != null) { if (controller.choose(Outcome.Protect, choice, game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/HasSubtypesSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/HasSubtypesSourceEffect.java index 35897da12f7..f981a7be24d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/HasSubtypesSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/HasSubtypesSourceEffect.java @@ -39,7 +39,7 @@ public final class HasSubtypesSourceEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/IsAllCreatureTypesSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/IsAllCreatureTypesSourceEffect.java index 38b3ef6de37..780c1eec80d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/IsAllCreatureTypesSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/IsAllCreatureTypesSourceEffect.java @@ -30,7 +30,7 @@ public class IsAllCreatureTypesSourceEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityAllEffect.java index f6c7595da6e..6c4dbba200e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityAllEffect.java @@ -1,9 +1,7 @@ package mage.abilities.effects.common.continuous; import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import mage.MageObject; + import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.CompoundAbility; @@ -12,7 +10,6 @@ import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; -import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.StaticFilters; import mage.game.Game; @@ -65,7 +62,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { affectedObjectList.add(new MageObjectReference(perm, game)); } @@ -93,7 +90,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl { } } } else { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { System.out.println(game.getTurn() + ", " + game.getPhase() + ": " + "remove from size " + perm.getAbilities().size()); perm.removeAbilities(ability, source.getSourceId(), game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAllEffect.java index 070183a217b..fb6fee997be 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAllAbilitiesAllEffect.java @@ -37,7 +37,7 @@ public class LoseAllAbilitiesAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { if (permanent != null) { permanent.removeAllAbilities(source.getSourceId(), game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java index 14049f882e8..b7b9b995629 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java @@ -160,6 +160,6 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl { } // must be correct card - return filter.match(cardToCheck, source.getSourceId(), affectedControllerId, game); + return filter.match(cardToCheck, affectedControllerId, source, game); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerSourceEffect.java index 88d410c411f..e90d77c8dde 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerSourceEffect.java @@ -41,7 +41,7 @@ public class SetPowerSourceEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { int value = amount.calculate(game, source, this); mageObject.getPower().setValue(value); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessAllEffect.java index 677bb5cd8a8..6450a0cb3ef 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessAllEffect.java @@ -61,7 +61,7 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl { public void init(Ability source, Game game) { super.init(source, game); if (affectedObjectsSet) { - for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } @@ -86,7 +86,7 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl { } } } else { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.getPower().setValue(newPower); permanent.getToughness().setValue(newToughness); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java index bc549cb15c6..5220b2010f2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java @@ -62,7 +62,7 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl { if (duration == Duration.Custom || isTemporary()) { mageObject = game.getPermanent(source.getSourceId()); } else { - mageObject = game.getObject(source.getSourceId()); + mageObject = game.getObject(source); } } if (mageObject == null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java index c6c5d43f103..9dcbc345dd0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java @@ -40,7 +40,7 @@ public class SetToughnessSourceEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { int value = amount.calculate(game, source, this); mageObject.getToughness().setValue(value); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessAllEffect.java index 0e071402269..0ee31ed0f96 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessAllEffect.java @@ -44,7 +44,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl { if (this.affectedObjectsSet) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (Permanent perm :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent perm :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } @@ -67,7 +67,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl { } } } else { - for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { int power = creature.getPower().getValue(); creature.getPower().setValue(creature.getToughness().getValue()); creature.getToughness().setValue(power); diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java index 1f73f4cbffb..5650069f91f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java @@ -112,7 +112,7 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI if (abilityToModify.isControlledBy(source.getControllerId())) { Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); if (spellCard != null) { - return this.filter.match(spellCard, source.getSourceId(), source.getControllerId(), game); + return this.filter.match(spellCard, source.getControllerId(), source, game); } } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java index 912e6ca53bf..aed21748b09 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java @@ -39,10 +39,10 @@ public class AddCountersAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (counter != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { permanent.addCounters(counter.copy(), source.getControllerId(), source, game); if (!game.isSimulation()) { game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName().toLowerCase(Locale.ENGLISH) diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java index ac618fb9e62..37f362d8998 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java @@ -56,7 +56,7 @@ public class AddCountersTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null && counter != null) { int affectedTargets = 0; for (UUID uuid : targetPointer.getTargets(game, source)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java index 7bcfbd5a518..7c5276979b1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java @@ -46,7 +46,7 @@ public class AddRemoveAllTimeSuspentCountersEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (controller != null && sourceObject != null) { if (counter != null) { List permanents = new ArrayList<>(game.getBattlefield().getAllActivePermanents()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java index 8bc78be649f..758dfa52c7b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java @@ -51,7 +51,7 @@ public class ProliferateEffect extends OneShotEffect { Target target = new TargetPermanentOrPlayer(0, Integer.MAX_VALUE, new FilterPermanentOrPlayerWithCounter(), true); Map options = new HashMap<>(); options.put("UI.right.btn.text", "Done"); - controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options); + controller.choose(Outcome.Benefit, target, source, game, options); for (UUID chosen : target.getTargets()) { Permanent permanent = game.getPermanent(chosen); diff --git a/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetEffect.java index 02432352abc..279a2f5abf8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetEffect.java @@ -121,7 +121,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect { TargetCard chosenCards = new TargetCard(numberToReveal, numberToReveal, Zone.HAND, new FilterCard("card in " + player.getName() + "'s hand")); chosenCards.setNotTarget(true); - if (chosenCards.canChoose(source.getSourceId(), player.getId(), game) + if (chosenCards.canChoose(player.getId(), source, game) && player.chooseTarget(Outcome.Discard, player.getHand(), chosenCards, source, game)) { if (!chosenCards.getTargets().isEmpty()) { List targets = chosenCards.getTargets(); @@ -142,7 +142,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect { + sourceCard.getZoneChangeCounter(game) + ')' : "Discard", revealedCards, game); boolean result = true; - int filteredCardsCount = revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game); + int filteredCardsCount = revealedCards.count(filter, source.getControllerId(), source, game); int numberToDiscard = Math.min(this.numberCardsToDiscard.calculate(game, source, this), filteredCardsCount); if (numberToDiscard <= 0) { return result; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CantHaveCountersSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CantHaveCountersSourceEffect.java index 851e92d6d19..35e19fc2c2b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CantHaveCountersSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CantHaveCountersSourceEffect.java @@ -36,7 +36,7 @@ public class CantHaveCountersSourceEffect extends ContinuousRuleModifyingEffectI @Override public boolean applies(GameEvent event, Ability source, Game game) { - UUID sourceId = source.getSourceId(); + UUID sourceId = source != null ? source.getSourceId() : null; if (sourceId != null) { return sourceId.equals(event.getTargetId()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java index a4c227ae982..db243014c91 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java @@ -77,6 +77,6 @@ public class PlayLandsFromGraveyardControllerEffect extends AsThoughEffectImpl { } // must be correct card - return filter.match(cardToCheck, source.getSourceId(), affectedControllerId, game); + return filter.match(cardToCheck, affectedControllerId, source, game); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/TargetsHaveToTargetPermanentIfAbleEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/TargetsHaveToTargetPermanentIfAbleEffect.java index cb1f72695a2..da9f91c7199 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/TargetsHaveToTargetPermanentIfAbleEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/TargetsHaveToTargetPermanentIfAbleEffect.java @@ -66,7 +66,7 @@ public class TargetsHaveToTargetPermanentIfAbleEffect extends ContinuousRuleModi @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You must choose at least " + this.filter.getMessage() + " on the battlefield as target if able (" + mageObject.getIdName() + ")."; } @@ -97,7 +97,7 @@ public class TargetsHaveToTargetPermanentIfAbleEffect extends ContinuousRuleModi Ability ability = (Ability) getValue("targetAbility"); if (ability != null) { // Get all the allowed permanents on the battlefield in range of the abilities controller - List allowedPermanents = game.getBattlefield().getActivePermanents(filter, event.getPlayerId(), event.getSourceId(), game); + List allowedPermanents = game.getBattlefield().getActivePermanents(filter, event.getPlayerId(), source, game); if (!allowedPermanents.isEmpty()) { boolean canTargetAllowedPermanent = false; for (UUID modeId : ability.getModes().getSelectedModes()) { diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/AmassEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/AmassEffect.java index bd57c9fe57b..10f42969471 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/AmassEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/AmassEffect.java @@ -72,7 +72,7 @@ public class AmassEffect extends OneShotEffect { } Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (!player.choose(outcome, target, source.getSourceId(), game)) { + if (!player.choose(outcome, target, source, game)) { return false; } Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/FatesealEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/FatesealEffect.java index edc2354a213..a756483ec9e 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/FatesealEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/FatesealEffect.java @@ -44,7 +44,7 @@ public class FatesealEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetOpponent(true); - if (controller.choose(outcome, target, source.getSourceId(), game)) { + if (controller.choose(outcome, target, source, game)) { Player opponent = game.getPlayer(target.getFirstTarget()); if (opponent == null) { return false; diff --git a/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java b/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java index 374bfbc53ba..8577f466eb0 100644 --- a/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java @@ -81,7 +81,7 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect { if (controller != null) { String mes = String.format("Select a color of mana to add %d of it", this.amount); if (mes != null) { - ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId())); + ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source)); if (controller.choose(outcome, choice, game)) { if (choice.getColor() != null) { Mana mana = choice.getMana(amount); diff --git a/Mage/src/main/java/mage/abilities/effects/mana/DoUnlessAnyPlayerPaysManaEffect.java b/Mage/src/main/java/mage/abilities/effects/mana/DoUnlessAnyPlayerPaysManaEffect.java index 17dd216dca3..1e9fc0993e3 100644 --- a/Mage/src/main/java/mage/abilities/effects/mana/DoUnlessAnyPlayerPaysManaEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/mana/DoUnlessAnyPlayerPaysManaEffect.java @@ -45,7 +45,7 @@ public class DoUnlessAnyPlayerPaysManaEffect extends ManaEffect { Mana mana = new Mana(); if (game != null) { Player controller = getPlayer(game, source); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); String message = CardUtil.replaceSourceName(chooseUseText, sourceObject.getName()); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); diff --git a/Mage/src/main/java/mage/abilities/hint/common/CovenHint.java b/Mage/src/main/java/mage/abilities/hint/common/CovenHint.java index b11aa75d401..556630227f4 100644 --- a/Mage/src/main/java/mage/abilities/hint/common/CovenHint.java +++ b/Mage/src/main/java/mage/abilities/hint/common/CovenHint.java @@ -23,7 +23,7 @@ public enum CovenHint implements Hint { .getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_CREATURE, - ability.getControllerId(), ability.getSourceId(), game + ability.getControllerId(), ability, game ) .stream() .filter(Objects::nonNull) diff --git a/Mage/src/main/java/mage/abilities/hint/common/DomainHint.java b/Mage/src/main/java/mage/abilities/hint/common/DomainHint.java index 3b0233e3413..0dfc98a26d6 100644 --- a/Mage/src/main/java/mage/abilities/hint/common/DomainHint.java +++ b/Mage/src/main/java/mage/abilities/hint/common/DomainHint.java @@ -24,7 +24,7 @@ public enum DomainHint implements Hint { List landTypes = game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS, - ability.getControllerId(), ability.getSourceId(), game + ability.getControllerId(), ability, game ).stream() .map(permanent -> SubType .getBasicLands() diff --git a/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java b/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java index 3d39e5b92b5..b63f1539fa2 100644 --- a/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java @@ -153,7 +153,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl { // If branch so that we also support putting Aftermath on // non-split cards for... whatever reason, in case somebody // wants to do that in the future. - UUID sourceId = source.getSourceId(); + UUID sourceId = source != null ? source.getSourceId() : null; Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard instanceof SubCard) { sourceCard = ((SubCard) sourceCard).getParentCard(); diff --git a/Mage/src/main/java/mage/abilities/keyword/AnnihilatorAbility.java b/Mage/src/main/java/mage/abilities/keyword/AnnihilatorAbility.java index 43d7cb060de..594b98cd1e2 100644 --- a/Mage/src/main/java/mage/abilities/keyword/AnnihilatorAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/AnnihilatorAbility.java @@ -9,7 +9,6 @@ import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.Target; import mage.target.common.TargetControlledPermanent; @@ -100,11 +99,11 @@ class AnnihilatorEffect extends OneShotEffect { int amount = Math.min(count, game.getBattlefield().countAll(new FilterControlledPermanent(), player.getId(), game)); if (amount > 0) { Target target = new TargetControlledPermanent(amount, amount, new FilterControlledPermanent(), true); - if (target.canChoose(source.getSourceId(), player.getId(), game)) { + if (target.canChoose(player.getId(), source, game)) { while (player.canRespond() - && target.canChoose(source.getSourceId(), player.getId(), game) + && target.canChoose(player.getId(), source, game) && !target.isChosen()) { - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); } target.getTargets().stream() .map(game::getPermanent) diff --git a/Mage/src/main/java/mage/abilities/keyword/AuraSwapAbility.java b/Mage/src/main/java/mage/abilities/keyword/AuraSwapAbility.java index e81d2526dea..67d51a58634 100644 --- a/Mage/src/main/java/mage/abilities/keyword/AuraSwapAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/AuraSwapAbility.java @@ -72,7 +72,7 @@ class AuraSwapEffect extends OneShotEffect { Permanent enchantedPermanent = game.getPermanent(auraSourcePermanent.getAttachedTo()); filterCardToCheck.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId())); TargetCardInHand target = new TargetCardInHand(filterCardToCheck); - if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source, game)) { Card auraInHand = game.getCard(target.getFirstTarget()); if (auraInHand != null) { game.getState().setValue("attachTo:" + auraInHand.getId(), enchantedPermanent); diff --git a/Mage/src/main/java/mage/abilities/keyword/BoastAbility.java b/Mage/src/main/java/mage/abilities/keyword/BoastAbility.java index 6d6ccb4e5f8..843f862b067 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BoastAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BoastAbility.java @@ -60,7 +60,7 @@ public class BoastAbility extends ActivatedAbilityImpl { return game.getBattlefield() .getActivePermanents( StaticFilters.FILTER_CONTROLLED_PERMANENT, - getControllerId(), getSourceId(), game + getControllerId(), this, game ).stream() .map(p -> p.getAbilities(game)) .flatMap(Collection::stream) diff --git a/Mage/src/main/java/mage/abilities/keyword/ChampionAbility.java b/Mage/src/main/java/mage/abilities/keyword/ChampionAbility.java index 75dc41b3793..56944abcb41 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ChampionAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ChampionAbility.java @@ -134,7 +134,7 @@ class ChampionExileCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); - if (controller == null || !targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) { + if (controller == null || !targets.choose(Outcome.Exile, controllerId, source.getSourceId(), source, game)) { return paid; } for (UUID targetId : targets.get(0).getTargets()) { @@ -156,7 +156,7 @@ class ChampionExileCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java b/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java index 4f94a333e41..bb1d8f7c496 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ConvokeAbility.java @@ -148,7 +148,7 @@ public class ConvokeAbility extends SimpleStaticAbility implements AlternateMana FilterControlledCreaturePermanent filterBasic = new FilterControlledCreaturePermanent(); // each creature can give {1} or color mana - game.getBattlefield().getActivePermanents(filterBasic, source.getControllerId(), source.getSourceId(), game) + game.getBattlefield().getActivePermanents(filterBasic, source.getControllerId(), source, game) .stream() .filter(permanent -> !permanent.isTapped()) .forEach(permanent -> { diff --git a/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java b/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java index 5aa9f43eb6a..c7793775541 100644 --- a/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java @@ -163,7 +163,7 @@ class CrewCost extends CostImpl { }; // can cancel - if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) { + if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) { int sumPower = 0; for (UUID targetId : target.getTargets()) { GameEvent event = new GameEvent(GameEvent.EventType.CREW_VEHICLE, targetId, source, controllerId); diff --git a/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java b/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java index 36dc9487810..7d1644eeb40 100644 --- a/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java @@ -61,7 +61,7 @@ class DemonstrateEffect extends OneShotEffect { } spell.createCopyOnStack(game, source, source.getControllerId(), true); TargetOpponent target = new TargetOpponent(true); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); if (game.getPlayer(target.getFirstTarget()) != null) { spell.createCopyOnStack(game, source, target.getFirstTarget(), true); } diff --git a/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java b/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java index 8de7be818ff..a0f1d1dd3bf 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java @@ -52,7 +52,7 @@ public class EmergeAbility extends SpellAbility { Player controller = game.getPlayer(this.getControllerId()); if (controller != null) { for (Permanent creature : game.getBattlefield().getActivePermanents( - new FilterControlledCreaturePermanent(), this.getControllerId(), this.getSourceId(), game)) { + new FilterControlledCreaturePermanent(), this.getControllerId(), this, game)) { ManaCost costToPay = CardUtil.reduceCost(emergeCost.copy(), creature.getManaValue()); if (costToPay.canPay(this, this, this.getControllerId(), game)) { return ActivationStatus.getTrue(this, game); @@ -66,7 +66,7 @@ public class EmergeAbility extends SpellAbility { @Override public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) { int maxCMC = 0; - for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), playerId, this.getSourceId(), game)) { + for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), playerId, this, game)) { int cmc = creature.getManaValue(); if (cmc > maxCMC) { maxCMC = cmc; @@ -88,7 +88,7 @@ public class EmergeAbility extends SpellAbility { Player controller = game.getPlayer(this.getControllerId()); if (controller != null) { TargetPermanent target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("creature to sacrifice for emerge")); - if (controller.choose(Outcome.Sacrifice, target, this.getSourceId(), game)) { + if (controller.choose(Outcome.Sacrifice, target, this, game)) { Permanent creature = game.getPermanent(target.getFirstTarget()); if (creature != null) { CardUtil.reduceCost(this, creature.getManaValue()); diff --git a/Mage/src/main/java/mage/abilities/keyword/ExploitAbility.java b/Mage/src/main/java/mage/abilities/keyword/ExploitAbility.java index b314027b7d9..9f076e5352d 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ExploitAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ExploitAbility.java @@ -72,7 +72,7 @@ class ExploitEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetPermanent(1, 1, new FilterControlledCreaturePermanent("creature to exploit"), true); - if (target.canChoose(source.getSourceId(), controller.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { controller.chooseTarget(Outcome.Sacrifice, target, source, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null ) { diff --git a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java index 8a20a4bb066..8f4d5f26cb5 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java @@ -175,7 +175,7 @@ public class ForetellAbility extends SpecialAction { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/keyword/LandwalkAbility.java b/Mage/src/main/java/mage/abilities/keyword/LandwalkAbility.java index 32bd473d13d..2436c9d6fcb 100644 --- a/Mage/src/main/java/mage/abilities/keyword/LandwalkAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/LandwalkAbility.java @@ -64,7 +64,7 @@ class LandwalkEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - if (game.getBattlefield().contains(filter, source.getSourceId(), blocker.getControllerId(), game, 1) + if (game.getBattlefield().contains(filter, source.getSourceId(), blocker.getControllerId(), source, game, 1) && null == game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_LANDWALK, null, blocker.getControllerId(), game)) { switch (filter.getMessage()) { case "plains": diff --git a/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java b/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java index 6cfe91e6e9e..6dd3e873096 100644 --- a/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java @@ -50,7 +50,7 @@ enum MentorAbilityPredicate implements ObjectSourcePlayerPredicate { @Override public boolean apply(ObjectSourcePlayer input, Game game) { - Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent sourcePermanent = input.getSource().getSourcePermanentOrLKI(game); return sourcePermanent != null && input.getObject().getPower().getValue() < sourcePermanent.getPower().getValue(); } } diff --git a/Mage/src/main/java/mage/abilities/keyword/NinjutsuAbility.java b/Mage/src/main/java/mage/abilities/keyword/NinjutsuAbility.java index 0a43464b9dc..9032e9f5098 100644 --- a/Mage/src/main/java/mage/abilities/keyword/NinjutsuAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/NinjutsuAbility.java @@ -148,7 +148,7 @@ class ReturnAttackerToHandTargetCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { - if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) { + if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), source, game)) { for (UUID targetId : targets.get(0).getTargets()) { Permanent permanent = game.getPermanent(targetId); Player controller = game.getPlayer(controllerId); @@ -165,7 +165,7 @@ class ReturnAttackerToHandTargetCost extends CostImpl { @Override public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { - return targets.canChoose(source.getSourceId(), controllerId, game); + return targets.canChoose(controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/OfferingAbility.java b/Mage/src/main/java/mage/abilities/keyword/OfferingAbility.java index ed88abc7aaf..ad13d488752 100644 --- a/Mage/src/main/java/mage/abilities/keyword/OfferingAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/OfferingAbility.java @@ -95,7 +95,7 @@ public class OfferingAbility extends StaticAbility implements AlternateManaPayme ManaOptions additionalManaOptionsForThisAbility = new ManaOptions(); // Creatures from the offerd type - game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game) + game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game) .stream() .map(Card::getSpellAbility) .filter(Objects::nonNull) @@ -164,7 +164,7 @@ class OfferingAsThoughEffect extends AsThoughEffectImpl { game.getState().setValue("offering_Id_" + card.getId(), null); } - if (game.getBattlefield().count(((OfferingAbility) source).getFilter(), source.getSourceId(), source.getControllerId(), game) > 0) { + if (game.getBattlefield().count(((OfferingAbility) source).getFilter(), source.getControllerId(), source, game) > 0) { if (game.inCheckPlayableState()) { return true; diff --git a/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java b/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java index d7130b6cf6b..835f133f7cd 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java @@ -87,9 +87,9 @@ public class ProtectionAbility extends StaticAbility { if (filter instanceof FilterCard) { if (source instanceof Permanent) { - return !((FilterCard) filter).match((Card) source, getSourceId(), ((Permanent) source).getControllerId(), game); + return !((FilterCard) filter).match((Card) source, ((Permanent) source).getControllerId(), this, game); } else if (source instanceof Card) { - return !((FilterCard) filter).match((Card) source, getSourceId(), ((Card) source).getOwnerId(), game); + return !((FilterCard) filter).match((Card) source, ((Card) source).getOwnerId(), this, game); } return true; } @@ -125,7 +125,7 @@ public class ProtectionAbility extends StaticAbility { } else if (source instanceof Card) { player = game.getPlayer(((Card) source).getOwnerId()); } - return !((FilterPlayer) filter).match(player, getSourceId(), this.getControllerId(), game); + return !((FilterPlayer) filter).match(player, this.getControllerId(), this, game); } return true; diff --git a/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java b/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java index d1c9ef37cc5..02e51cd8a84 100644 --- a/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java @@ -83,7 +83,7 @@ class RippleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (player != null) { if (!player.chooseUse(Outcome.Neutral, "Reveal " + rippleNumber + " cards from the top of your library?", source, game)) { return true; //fizzle diff --git a/Mage/src/main/java/mage/abilities/keyword/SoulbondAbility.java b/Mage/src/main/java/mage/abilities/keyword/SoulbondAbility.java index 4cc6e7f4bf2..e606fbffcb9 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SoulbondAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SoulbondAbility.java @@ -136,8 +136,8 @@ class SoulboundEntersSelfEffect extends OneShotEffect { if (controller != null) { TargetControlledPermanent target = new TargetControlledPermanent(filter); target.setNotTarget(true); - if (target.canChoose(permanent.getId(), controller.getId(), game)) { - if (controller.choose(Outcome.Benefit, target, permanent.getId(), game)) { + if (target.canChoose(controller.getId(), source, game)) { + if (controller.choose(Outcome.Benefit, target, source, game)) { Permanent chosen = game.getPermanent(target.getFirstTarget()); if (chosen != null) { chosen.setPairedCard(new MageObjectReference(permanent, game)); diff --git a/Mage/src/main/java/mage/abilities/keyword/TransmuteAbility.java b/Mage/src/main/java/mage/abilities/keyword/TransmuteAbility.java index da0f50e807b..cc246c48044 100644 --- a/Mage/src/main/java/mage/abilities/keyword/TransmuteAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/TransmuteAbility.java @@ -75,7 +75,7 @@ class TransmuteEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null && controller != null) { FilterCard filter = new FilterCard("card with mana value " + sourceObject.getManaValue()); filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, sourceObject.getManaValue())); diff --git a/Mage/src/main/java/mage/abilities/keyword/TributeAbility.java b/Mage/src/main/java/mage/abilities/keyword/TributeAbility.java index bc46c09fd2c..980c93f3c85 100644 --- a/Mage/src/main/java/mage/abilities/keyword/TributeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/TributeAbility.java @@ -5,7 +5,6 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.constants.Outcome; import mage.counters.CounterType; import mage.game.Game; @@ -74,7 +73,7 @@ class TributeEffect extends OneShotEffect { opponentId = game.getOpponents(controller.getId()).iterator().next(); } else { Target target = new TargetOpponent(); - controller.choose(outcome, target, source.getSourceId(), game); + controller.choose(outcome, target, source, game); opponentId = target.getFirstTarget(); } if (opponentId != null) { diff --git a/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java b/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java index 39d26048415..76ab7371156 100644 --- a/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java @@ -155,7 +155,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect { return types; } inManaTypeCalculation = true; - List lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent land : lands) { if (!land.getId().equals(source.getSourceId())) { types.addAll(AnyColorLandsProduceManaAbility.getManaTypesFromPermanent(land, game)); diff --git a/Mage/src/main/java/mage/abilities/mana/AnyColorPermanentTypesManaAbility.java b/Mage/src/main/java/mage/abilities/mana/AnyColorPermanentTypesManaAbility.java index fb8f9e9a1a2..c72bc21b2ed 100644 --- a/Mage/src/main/java/mage/abilities/mana/AnyColorPermanentTypesManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/AnyColorPermanentTypesManaAbility.java @@ -189,7 +189,7 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect { ObjectColor permanentColor; - List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game); for (Permanent permanent : permanents) { permanentColor = permanent.getColor(game); diff --git a/Mage/src/main/java/mage/abilities/mana/builder/common/InstantOrSorcerySpellManaBuilder.java b/Mage/src/main/java/mage/abilities/mana/builder/common/InstantOrSorcerySpellManaBuilder.java index d2018fe9748..5f52b90ef6a 100644 --- a/Mage/src/main/java/mage/abilities/mana/builder/common/InstantOrSorcerySpellManaBuilder.java +++ b/Mage/src/main/java/mage/abilities/mana/builder/common/InstantOrSorcerySpellManaBuilder.java @@ -43,7 +43,7 @@ class InstantOrSorceryCastManaCondition extends ManaCondition implements Conditi @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); return object != null && object.isInstantOrSorcery(game); } return false; diff --git a/Mage/src/main/java/mage/abilities/mana/conditional/ArtifactCastManaCondition.java b/Mage/src/main/java/mage/abilities/mana/conditional/ArtifactCastManaCondition.java index f41f9f1fc9f..573e130da16 100644 --- a/Mage/src/main/java/mage/abilities/mana/conditional/ArtifactCastManaCondition.java +++ b/Mage/src/main/java/mage/abilities/mana/conditional/ArtifactCastManaCondition.java @@ -18,7 +18,7 @@ public class ArtifactCastManaCondition extends ManaCondition implements Conditio @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.isArtifact(game)) { return true; } diff --git a/Mage/src/main/java/mage/abilities/mana/conditional/ConditionalSpellManaBuilder.java b/Mage/src/main/java/mage/abilities/mana/conditional/ConditionalSpellManaBuilder.java index a39e9d95cfa..b9d2ad51193 100644 --- a/Mage/src/main/java/mage/abilities/mana/conditional/ConditionalSpellManaBuilder.java +++ b/Mage/src/main/java/mage/abilities/mana/conditional/ConditionalSpellManaBuilder.java @@ -60,9 +60,9 @@ class SpellCastManaCondition extends ManaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if ((object instanceof StackObject)) { - return filter.match((StackObject) object, source.getSourceId(), source.getControllerId(), game); + return filter.match((StackObject) object, source.getControllerId(), source, game); } // checking mana without real cast @@ -73,7 +73,7 @@ class SpellCastManaCondition extends ManaCondition implements Condition { } else if (object instanceof Commander) { spell = new Spell(((Commander) object).getSourceObject(), (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()), game); } - return filter.match(spell, source.getSourceId(), source.getControllerId(), game); + return filter.match(spell, source.getControllerId(), source, game); } } return false; diff --git a/Mage/src/main/java/mage/abilities/mana/conditional/CreatureCastManaCondition.java b/Mage/src/main/java/mage/abilities/mana/conditional/CreatureCastManaCondition.java index 82bcc479d4c..76a1881a3bb 100644 --- a/Mage/src/main/java/mage/abilities/mana/conditional/CreatureCastManaCondition.java +++ b/Mage/src/main/java/mage/abilities/mana/conditional/CreatureCastManaCondition.java @@ -17,7 +17,7 @@ public class CreatureCastManaCondition extends ManaCondition implements Conditio @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.isCreature(game)) { return true; } diff --git a/Mage/src/main/java/mage/abilities/mana/conditional/PlaneswalkerCastManaCondition.java b/Mage/src/main/java/mage/abilities/mana/conditional/PlaneswalkerCastManaCondition.java index 7448b92ad98..c826ff8f0e5 100644 --- a/Mage/src/main/java/mage/abilities/mana/conditional/PlaneswalkerCastManaCondition.java +++ b/Mage/src/main/java/mage/abilities/mana/conditional/PlaneswalkerCastManaCondition.java @@ -18,7 +18,7 @@ public class PlaneswalkerCastManaCondition extends ManaCondition implements Cond @Override public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { - MageObject object = game.getObject(source.getSourceId()); + MageObject object = game.getObject(source); if (object != null && object.isPlaneswalker(game)) { return true; } diff --git a/Mage/src/main/java/mage/cards/CardImpl.java b/Mage/src/main/java/mage/cards/CardImpl.java index daa45f8e5d0..c902607fc61 100644 --- a/Mage/src/main/java/mage/cards/CardImpl.java +++ b/Mage/src/main/java/mage/cards/CardImpl.java @@ -550,7 +550,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { removed = true; break; default: - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); logger.fatal("Invalid from zone [" + fromZone + "] for card [" + this.getIdName() + "] source [" + (sourceObject != null ? sourceObject.getName() : "null") + ']'); break; diff --git a/Mage/src/main/java/mage/cards/Cards.java b/Mage/src/main/java/mage/cards/Cards.java index 388e985f119..d61b1bfea0e 100644 --- a/Mage/src/main/java/mage/cards/Cards.java +++ b/Mage/src/main/java/mage/cards/Cards.java @@ -1,5 +1,6 @@ package mage.cards; +import mage.abilities.Ability; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; @@ -28,7 +29,7 @@ public interface Cards extends Set, Serializable { Set getCards(FilterCard filter, Game game); - Set getCards(FilterCard filter, UUID sourceId, UUID playerId, Game game); + Set getCards(FilterCard filter, UUID playerId, Ability source, Game game); String getValue(Game game); @@ -40,7 +41,7 @@ public interface Cards extends Set, Serializable { int count(FilterCard filter, UUID playerId, Game game); - int count(FilterCard filter, UUID sourceId, UUID playerId, Game game); + int count(FilterCard filter, UUID playerId, Ability source, Game game); Cards copy(); diff --git a/Mage/src/main/java/mage/cards/CardsImpl.java b/Mage/src/main/java/mage/cards/CardsImpl.java index a3fcd217d02..76d843e716b 100644 --- a/Mage/src/main/java/mage/cards/CardsImpl.java +++ b/Mage/src/main/java/mage/cards/CardsImpl.java @@ -2,6 +2,7 @@ package mage.cards; import mage.MageItem; import mage.MageObject; +import mage.abilities.Ability; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; @@ -110,21 +111,21 @@ public class CardsImpl extends LinkedHashSet implements Cards, Serializabl } @Override - public int count(FilterCard filter, UUID sourceId, UUID playerId, Game game) { - if (sourceId == null) { + public int count(FilterCard filter, UUID playerId, Ability source, Game game) { + if (source == null) { return count(filter, playerId, game); } - return (int) this.stream().filter(card -> filter.match(game.getCard(card), sourceId, playerId, game)).count(); + return (int) this.stream().filter(card -> filter.match(game.getCard(card), playerId, source, game)).count(); } @Override - public Set getCards(FilterCard filter, UUID sourceId, UUID playerId, Game game) { + public Set getCards(FilterCard filter, UUID playerId, Ability source, Game game) { Set cards = new LinkedHashSet<>(); for (UUID cardId : this) { Card card = game.getCard(cardId); if (card != null) { - boolean match = filter.match(card, sourceId, playerId, game); + boolean match = filter.match(card, playerId, source, game); if (match) { cards.add(game.getCard(cardId)); } diff --git a/Mage/src/main/java/mage/constants/TargetController.java b/Mage/src/main/java/mage/constants/TargetController.java index a81c3610c87..de278cdd30c 100644 --- a/Mage/src/main/java/mage/constants/TargetController.java +++ b/Mage/src/main/java/mage/constants/TargetController.java @@ -84,7 +84,7 @@ public enum TargetController { } break; case ENCHANTED: - Permanent permanent = game.getPermanent(input.getSourceId()); + Permanent permanent = input.getSource().getSourcePermanentIfItStillExists(game); return permanent != null && input.getObject().isOwnedBy(permanent.getAttachedTo()); case ANY: return true; @@ -184,7 +184,7 @@ public enum TargetController { } break; case ENCHANTED: - Permanent permanent = game.getPermanent(input.getSourceId()); + Permanent permanent = input.getSource().getSourcePermanentIfItStillExists(game); return permanent != null && input.getObject().isControlledBy(permanent.getAttachedTo()); case ANY: return true; diff --git a/Mage/src/main/java/mage/filter/FilterCard.java b/Mage/src/main/java/mage/filter/FilterCard.java index bae5bcd3de9..e700f468b0c 100644 --- a/Mage/src/main/java/mage/filter/FilterCard.java +++ b/Mage/src/main/java/mage/filter/FilterCard.java @@ -1,5 +1,6 @@ package mage.filter; +import mage.abilities.Ability; import mage.cards.Card; import mage.constants.TargetController; import mage.filter.predicate.ObjectSourcePlayer; @@ -23,7 +24,7 @@ import java.util.stream.Collectors; public class FilterCard extends FilterObject { private static final long serialVersionUID = 1L; - protected List> extraPredicates = new ArrayList<>(); + protected final List> extraPredicates = new ArrayList<>(); public FilterCard() { super("card"); @@ -35,7 +36,7 @@ public class FilterCard extends FilterObject { public FilterCard(FilterCard filter) { super(filter); - this.extraPredicates = new ArrayList<>(filter.extraPredicates); + this.extraPredicates.addAll(filter.extraPredicates); } //20130711 708.6c @@ -56,14 +57,15 @@ public class FilterCard extends FilterObject { } public boolean match(Card card, UUID playerId, Game game) { - return match(card, null, playerId, game); + return match(card, playerId, null, game); } - public boolean match(Card card, UUID sourceId, UUID playerId, Game game) { + public boolean match(Card card, UUID playerId, Ability source, Game game) { if (!this.match(card, game)) { return false; } - return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(card, sourceId, playerId), game); + ObjectSourcePlayer osp = new ObjectSourcePlayer<>(card, playerId, source); + return extraPredicates.stream().allMatch(p -> p.apply(osp, game)); } public final void add(ObjectSourcePlayerPredicate predicate) { diff --git a/Mage/src/main/java/mage/filter/FilterInPlay.java b/Mage/src/main/java/mage/filter/FilterInPlay.java index db4b65b2c69..ba0b9979a7e 100644 --- a/Mage/src/main/java/mage/filter/FilterInPlay.java +++ b/Mage/src/main/java/mage/filter/FilterInPlay.java @@ -1,19 +1,18 @@ - - package mage.filter; -import java.util.UUID; +import mage.abilities.Ability; import mage.game.Game; +import java.util.UUID; + /** - * - * @author BetaSteward_at_googlemail.com * @param + * @author BetaSteward_at_googlemail.com */ public interface FilterInPlay extends Filter { - boolean match(E o, UUID sourceId, UUID playerId, Game game); + boolean match(E o, UUID playerId, Ability source, Game game); + @Override FilterInPlay copy(); - } diff --git a/Mage/src/main/java/mage/filter/FilterPermanent.java b/Mage/src/main/java/mage/filter/FilterPermanent.java index fa995d8a7dd..3c0d8dc30ec 100644 --- a/Mage/src/main/java/mage/filter/FilterPermanent.java +++ b/Mage/src/main/java/mage/filter/FilterPermanent.java @@ -1,9 +1,9 @@ package mage.filter; +import mage.abilities.Ability; import mage.constants.SubType; import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayerPredicate; -import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.permanent.Permanent; @@ -17,7 +17,7 @@ import java.util.UUID; */ public class FilterPermanent extends FilterObject implements FilterInPlay { - protected List> extraPredicates = new ArrayList<>(); + protected final List> extraPredicates = new ArrayList<>(); public FilterPermanent() { super("permanent"); @@ -41,7 +41,7 @@ public class FilterPermanent extends FilterObject implements FilterIn public FilterPermanent(final FilterPermanent filter) { super(filter); - this.extraPredicates = new ArrayList<>(filter.extraPredicates); + this.extraPredicates.addAll(filter.extraPredicates); } @Override @@ -50,12 +50,12 @@ public class FilterPermanent extends FilterObject implements FilterIn } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { if (!this.match(permanent, game) || !permanent.isPhasedIn()) { return false; } - - return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(permanent, sourceId, playerId), game); + ObjectSourcePlayer osp = new ObjectSourcePlayer(permanent, playerId, source); + return extraPredicates.stream().allMatch(p -> p.apply(osp, game)); } public final void add(ObjectSourcePlayerPredicate predicate) { diff --git a/Mage/src/main/java/mage/filter/FilterPlayer.java b/Mage/src/main/java/mage/filter/FilterPlayer.java index 7a4e0c726e1..025433028f0 100644 --- a/Mage/src/main/java/mage/filter/FilterPlayer.java +++ b/Mage/src/main/java/mage/filter/FilterPlayer.java @@ -1,8 +1,8 @@ package mage.filter; +import mage.abilities.Ability; import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayerPredicate; -import mage.filter.predicate.Predicates; import mage.game.Game; import mage.players.Player; @@ -16,7 +16,7 @@ import java.util.UUID; */ public class FilterPlayer extends FilterImpl { - protected List> extraPredicates = new ArrayList<>(); + protected final List> extraPredicates = new ArrayList<>(); public FilterPlayer() { this("player"); @@ -28,7 +28,7 @@ public class FilterPlayer extends FilterImpl { public FilterPlayer(final FilterPlayer filter) { super(filter); - this.extraPredicates = new ArrayList<>(filter.extraPredicates); + this.extraPredicates.addAll(filter.extraPredicates); } public void add(ObjectSourcePlayerPredicate predicate) { @@ -43,12 +43,12 @@ public class FilterPlayer extends FilterImpl { return object instanceof Player; } - public boolean match(Player checkPlayer, UUID sourceId, UUID sourceControllerId, Game game) { + public boolean match(Player checkPlayer, UUID sourceControllerId, Ability source, Game game) { if (!this.match(checkPlayer, game)) { return false; } - - return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(checkPlayer, sourceId, sourceControllerId), game); + ObjectSourcePlayer osp = new ObjectSourcePlayer<>(checkPlayer, sourceControllerId, source); + return extraPredicates.stream().allMatch(p -> p.apply(osp, game)); } @Override diff --git a/Mage/src/main/java/mage/filter/FilterSpell.java b/Mage/src/main/java/mage/filter/FilterSpell.java index 377ea63b0b7..e2baa8f5ba9 100644 --- a/Mage/src/main/java/mage/filter/FilterSpell.java +++ b/Mage/src/main/java/mage/filter/FilterSpell.java @@ -2,6 +2,8 @@ package mage.filter; import java.util.UUID; + +import mage.abilities.Ability; import mage.game.Game; import mage.game.stack.Spell; import mage.game.stack.StackObject; @@ -25,11 +27,11 @@ public class FilterSpell extends FilterStackObject { } @Override - public boolean match(StackObject stackObject, UUID sourceId, UUID playerId, Game game) { + public boolean match(StackObject stackObject, UUID playerId, Ability source, Game game) { if (!(stackObject instanceof Spell)) { return false; } - return super.match(stackObject, sourceId, playerId, game); + return super.match(stackObject, playerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/filter/FilterStackObject.java b/Mage/src/main/java/mage/filter/FilterStackObject.java index f6099773dd1..6f79cbf725c 100644 --- a/Mage/src/main/java/mage/filter/FilterStackObject.java +++ b/Mage/src/main/java/mage/filter/FilterStackObject.java @@ -1,8 +1,8 @@ package mage.filter; +import mage.abilities.Ability; import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayerPredicate; -import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.stack.StackObject; @@ -15,7 +15,7 @@ import java.util.UUID; */ public class FilterStackObject extends FilterObject { - protected List> extraPredicates = new ArrayList<>(); + protected final List> extraPredicates = new ArrayList<>(); public FilterStackObject() { this("spell or ability"); @@ -27,15 +27,15 @@ public class FilterStackObject extends FilterObject { public FilterStackObject(final FilterStackObject filter) { super(filter); - this.extraPredicates = new ArrayList<>(filter.extraPredicates); + this.extraPredicates.addAll(filter.extraPredicates); } - public boolean match(StackObject stackObject, UUID sourceId, UUID playerId, Game game) { + public boolean match(StackObject stackObject, UUID playerId, Ability source, Game game) { if (!this.match(stackObject, game)) { return false; } - - return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(stackObject, sourceId, playerId), game); + ObjectSourcePlayer osp = new ObjectSourcePlayer<>(stackObject, playerId, source); + return extraPredicates.stream().allMatch(p -> p.apply(osp, game)); } public final void add(ObjectSourcePlayerPredicate predicate) { diff --git a/Mage/src/main/java/mage/filter/common/FilterCreatureAttackingYou.java b/Mage/src/main/java/mage/filter/common/FilterCreatureAttackingYou.java index abe2d05ac80..10b68412a3f 100644 --- a/Mage/src/main/java/mage/filter/common/FilterCreatureAttackingYou.java +++ b/Mage/src/main/java/mage/filter/common/FilterCreatureAttackingYou.java @@ -2,7 +2,8 @@ package mage.filter.common; import java.util.UUID; -import mage.filter.common.FilterAttackingCreature; + +import mage.abilities.Ability; import mage.game.Game; import mage.game.permanent.Permanent; @@ -42,13 +43,13 @@ public class FilterCreatureAttackingYou extends FilterAttackingCreature { } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { + public boolean match(Permanent permanent, UUID playerId, Ability source, Game game) { if (orWalker) { - return super.match(permanent, sourceId, playerId, game) + return super.match(permanent, playerId, source, game) && permanent.isAttacking() // to prevent unneccessary combat checking if not attacking && playerId.equals(game.getCombat().getDefendingPlayerId(permanent.getId(), game)); } else { - return super.match(permanent, sourceId, playerId, game) + return super.match(permanent, playerId, source, game) && permanent.isAttacking() // to prevent unneccessary combat checking if not attacking && playerId.equals(game.getCombat().getDefenderId(permanent.getId())); } diff --git a/Mage/src/main/java/mage/filter/common/FilterCreatureOrPlayer.java b/Mage/src/main/java/mage/filter/common/FilterCreatureOrPlayer.java index c89ad32d6b3..f80da2f6c3d 100644 --- a/Mage/src/main/java/mage/filter/common/FilterCreatureOrPlayer.java +++ b/Mage/src/main/java/mage/filter/common/FilterCreatureOrPlayer.java @@ -1,6 +1,7 @@ package mage.filter.common; import mage.MageItem; +import mage.abilities.Ability; import mage.filter.FilterImpl; import mage.filter.FilterInPlay; import mage.filter.FilterPlayer; @@ -52,12 +53,12 @@ public class FilterCreatureOrPlayer extends FilterImpl implements Filt } @Override - public boolean match(MageItem o, UUID sourceId, UUID playerId, Game game) { + public boolean match(MageItem o, UUID playerId, Ability source, Game game) { if (super.match(o, game)) { // process predicates if (o instanceof Player) { - return playerFilter.match((Player) o, sourceId, playerId, game); + return playerFilter.match((Player) o, playerId, source, game); } else if (o instanceof Permanent) { - return creatureFilter.match((Permanent) o, sourceId, playerId, game); + return creatureFilter.match((Permanent) o, playerId, source, game); } } return false; diff --git a/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayer.java b/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayer.java index b6b6d18be11..60bd5b075b6 100644 --- a/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayer.java +++ b/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayer.java @@ -1,6 +1,7 @@ package mage.filter.common; import mage.MageItem; +import mage.abilities.Ability; import mage.filter.FilterImpl; import mage.filter.FilterInPlay; import mage.filter.FilterPermanent; @@ -64,12 +65,12 @@ public class FilterPermanentOrPlayer extends FilterImpl implements Fil } @Override - public boolean match(MageItem o, UUID sourceId, UUID playerId, Game game) { + public boolean match(MageItem o, UUID playerId, Ability source, Game game) { if (super.match(o, game)) { // process predicates if (o instanceof Player) { - return playerFilter.match((Player) o, sourceId, playerId, game); + return playerFilter.match((Player) o, playerId, source, game); } else if (o instanceof Permanent) { - return permanentFilter.match((Permanent) o, sourceId, playerId, game); + return permanentFilter.match((Permanent) o, playerId, source, game); } } return false; diff --git a/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java b/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java index e2ffcfa07f8..de468f83830 100644 --- a/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java +++ b/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java @@ -1,6 +1,7 @@ package mage.filter.common; import mage.MageItem; +import mage.abilities.Ability; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -37,8 +38,8 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer } @Override - public boolean match(MageItem o, UUID sourceId, UUID playerId, Game game) { - if (super.match(o, sourceId, playerId, game)) { // same as parent class, so can call with full params + public boolean match(MageItem o, UUID playerId, Ability source, Game game) { + if (super.match(o, playerId, source, game)) { // same as parent class, so can call with full params if (o instanceof Player) { return !((Player) o).getCounters().isEmpty(); } else if (o instanceof Permanent) { diff --git a/Mage/src/main/java/mage/filter/common/FilterPermanentOrSuspendedCard.java b/Mage/src/main/java/mage/filter/common/FilterPermanentOrSuspendedCard.java index e8e047ec006..db3150851ee 100644 --- a/Mage/src/main/java/mage/filter/common/FilterPermanentOrSuspendedCard.java +++ b/Mage/src/main/java/mage/filter/common/FilterPermanentOrSuspendedCard.java @@ -32,6 +32,7 @@ package mage.filter.common; import java.util.UUID; import mage.MageObject; +import mage.abilities.Ability; import mage.abilities.keyword.SuspendAbility; import mage.cards.Card; import mage.counters.CounterType; @@ -86,11 +87,11 @@ public class FilterPermanentOrSuspendedCard extends FilterImpl imple } @Override - public boolean match(MageObject o, UUID sourceId, UUID playerId, Game game) { + public boolean match(MageObject o, UUID playerId, Ability source, Game game) { if (o instanceof Permanent) { - return permanentFilter.match((Permanent) o, sourceId, playerId, game); + return permanentFilter.match((Permanent) o, playerId, source, game); } else if (o instanceof Card) { - return cardFilter.match((Card) o, sourceId, playerId, game); + return cardFilter.match((Card) o, playerId, source, game); } return false; } diff --git a/Mage/src/main/java/mage/filter/common/FilterSpellOrPermanent.java b/Mage/src/main/java/mage/filter/common/FilterSpellOrPermanent.java index e15fa68b20f..0f9a647f341 100644 --- a/Mage/src/main/java/mage/filter/common/FilterSpellOrPermanent.java +++ b/Mage/src/main/java/mage/filter/common/FilterSpellOrPermanent.java @@ -1,6 +1,7 @@ package mage.filter.common; import mage.MageObject; +import mage.abilities.Ability; import mage.filter.FilterImpl; import mage.filter.FilterInPlay; import mage.filter.FilterPermanent; @@ -51,11 +52,11 @@ public class FilterSpellOrPermanent extends FilterImpl implements Fi } @Override - public boolean match(MageObject o, UUID sourceId, UUID playerId, Game game) { + public boolean match(MageObject o, UUID playerId, Ability source, Game game) { if (o instanceof Spell) { - return spellFilter.match((Spell) o, sourceId, playerId, game); + return spellFilter.match((Spell) o, playerId, source, game); } else if (o instanceof Permanent) { - return permanentFilter.match((Permanent) o, sourceId, playerId, game); + return permanentFilter.match((Permanent) o, playerId, source, game); } return false; } diff --git a/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayer.java b/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayer.java index b5019768bdd..a080c55bfe2 100644 --- a/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayer.java +++ b/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayer.java @@ -1,5 +1,7 @@ package mage.filter.predicate; +import mage.abilities.Ability; + import java.util.UUID; /** @@ -11,11 +13,13 @@ public class ObjectSourcePlayer { protected final T object; protected final UUID playerId; protected final UUID sourceId; + protected final Ability source; - public ObjectSourcePlayer(T object, UUID sourceId, UUID sourceControllerId) { + public ObjectSourcePlayer(T object, UUID sourceControllerId, Ability source) { this.object = object; this.playerId = sourceControllerId; - this.sourceId = sourceId; + this.sourceId = source != null ? source.getSourceId() : null; + this.source = source; } public T getObject() { @@ -29,4 +33,8 @@ public class ObjectSourcePlayer { public UUID getSourceId() { return sourceId; } + + public Ability getSource() { + return source; + } } diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherCardPredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherCardPredicate.java deleted file mode 100644 index 6bc62682bca..00000000000 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherCardPredicate.java +++ /dev/null @@ -1,24 +0,0 @@ - -package mage.filter.predicate.mageobject; - -import mage.MageObject; -import mage.filter.predicate.ObjectSourcePlayer; -import mage.filter.predicate.ObjectSourcePlayerPredicate; -import mage.game.Game; - -/** - * - * @author North - */ -public class AnotherCardPredicate implements ObjectSourcePlayerPredicate { - - @Override - public boolean apply(ObjectSourcePlayer input, Game game) { - return !input.getSourceId().equals(input.getObject().getId()); - } - - @Override - public String toString() { - return "Another card"; - } -} \ No newline at end of file diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherPredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherPredicate.java index a7ce4548085..cca9260b1e7 100644 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/AnotherPredicate.java @@ -1,4 +1,3 @@ - package mage.filter.predicate.mageobject; import mage.MageObject; @@ -14,7 +13,11 @@ public enum AnotherPredicate implements ObjectSourcePlayerPredicate @Override public boolean apply(ObjectSourcePlayer input, Game game) { - return !input.getObject().getId().equals(input.getSourceId()); + if (!input.getObject().getId().equals(input.getSourceId())) { + return true; + } + int zcc = input.getSource().getSourceObjectZoneChangeCounter(); + return zcc != 0 && zcc != input.getObject().getZoneChangeCounter(game); } @Override diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/SharesColorWithSourcePredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/SharesColorWithSourcePredicate.java index bd76f122ecc..14fd70349ca 100644 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/SharesColorWithSourcePredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/SharesColorWithSourcePredicate.java @@ -14,12 +14,8 @@ public enum SharesColorWithSourcePredicate implements ObjectSourcePlayerPredicat @Override public boolean apply(ObjectSourcePlayer input, Game game) { - MageObject sourceObject = game.getObject(input.getSourceId()); - if (sourceObject != null) { - return input.getObject().getColor(game).shares(sourceObject.getColor(game)); - } - return false; - + MageObject sourceObject = input.getSource().getSourceObject(game); + return sourceObject != null && input.getObject().getColor(game).shares(sourceObject.getColor(game)); } @Override diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/TargetsPermanentPredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/TargetsPermanentPredicate.java index ccb8adea32e..7d2f9fe9dca 100644 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/TargetsPermanentPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/TargetsPermanentPredicate.java @@ -35,7 +35,7 @@ public class TargetsPermanentPredicate implements ObjectSourcePlayerPredicate input, Game game) { - Permanent enchantment = game.getPermanentOrLKIBattlefield(input.getSourceId()); + Permanent enchantment = input.getSource().getSourcePermanentIfItStillExists(game); return enchantment != null && !input.getObject().getId().equals(enchantment.getAttachedTo()); } diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/BlockingOrBlockedBySourcePredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/BlockingOrBlockedBySourcePredicate.java index 4e5af9d9dd6..59a7e6da33e 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/BlockingOrBlockedBySourcePredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/BlockingOrBlockedBySourcePredicate.java @@ -3,8 +3,8 @@ package mage.filter.predicate.permanent; import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.game.Game; -import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; +import mage.watchers.common.BlockingOrBlockedWatcher; import java.util.UUID; @@ -18,30 +18,20 @@ public enum BlockingOrBlockedBySourcePredicate implements ObjectSourcePlayerPred @Override public boolean apply(ObjectSourcePlayer input, Game game) { - return game - .getCombat() - .getGroups() - .stream() - .anyMatch(combatGroup -> checkBlocks(combatGroup, input.getSourceId(), input.getObject().getId())); - } - - private boolean checkBlocks(CombatGroup combatGroup, UUID thisCreature, UUID otherCreature) { + Permanent thisCreature = input.getSource().getSourcePermanentOrLKI(game); + Permanent otherCreature = input.getObject(); switch (this) { case BLOCKING: - return isBlocking(combatGroup, otherCreature, thisCreature); + return BlockingOrBlockedWatcher.check(thisCreature, otherCreature, game); case BLOCKED_BY: - return isBlocking(combatGroup, thisCreature, otherCreature); + return BlockingOrBlockedWatcher.check(otherCreature, thisCreature, game); case EITHER: - return isBlocking(combatGroup, otherCreature, thisCreature) - || isBlocking(combatGroup, thisCreature, otherCreature); + return BlockingOrBlockedWatcher.check(otherCreature, thisCreature, game) + || BlockingOrBlockedWatcher.check(thisCreature, otherCreature, game); } return false; } - private static final boolean isBlocking(CombatGroup combatGroup, UUID id1, UUID id2) { - return combatGroup.getBlockers().contains(id1) && combatGroup.getAttackers().contains(id2); - } - @Override public String toString() { return "Blocking or blocked by"; diff --git a/Mage/src/main/java/mage/game/Game.java b/Mage/src/main/java/mage/game/Game.java index 1ec9f2439fa..1aa9eb4afb3 100644 --- a/Mage/src/main/java/mage/game/Game.java +++ b/Mage/src/main/java/mage/game/Game.java @@ -80,6 +80,8 @@ public interface Game extends MageItem, Serializable, Copyable { */ MageObject getObject(UUID objectId); + MageObject getObject(Ability source); + MageObject getBaseObject(UUID objectId); MageObject getEmblem(UUID objectId); diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 0108e2ecee6..078d9f2d25c 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -441,6 +441,11 @@ public abstract class GameImpl implements Game { return object; } + @Override + public MageObject getObject(Ability source) { + return source != null ? getObject(source.getSourceId()) : null; + } + /** * Get permanent, card or command object (not spell or ability on the stack) * @@ -1293,6 +1298,7 @@ public abstract class GameImpl implements Game { newWatchers.add(new CardsDrawnThisTurnWatcher()); newWatchers.add(new ManaSpentToCastWatcher()); newWatchers.add(new ManaPaidSourceWatcher()); + newWatchers.add(new BlockingOrBlockedWatcher()); newWatchers.add(new CommanderPlaysCountWatcher()); // commander plays count uses in non commander games by some cards // runtime check - allows only GAME scope (one watcher per game) @@ -2387,7 +2393,7 @@ public abstract class GameImpl implements Game { } else { Filter auraFilter = spellAbility.getTargets().get(0).getFilter(); if (auraFilter instanceof FilterPermanent) { - if (!((FilterPermanent) auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this) + if (!((FilterPermanent) auraFilter).match(attachedTo, perm.getControllerId(), perm.getSpellAbility(), this) || attachedTo.cantBeAttachedBy(perm, null, this, true)) { Card card = this.getCard(perm.getId()); if (card != null && card.isCreature(this)) { @@ -2567,7 +2573,7 @@ public abstract class GameImpl implements Game { filterLegendName.add(SuperType.LEGENDARY.getPredicate()); filterLegendName.add(new NamePredicate(legend.getName())); filterLegendName.add(new ControllerIdPredicate(legend.getControllerId())); - if (getBattlefield().contains(filterLegendName, null, legend.getControllerId(), this, 2)) { + if (getBattlefield().contains(filterLegendName, null, legend.getControllerId(), null, this, 2)) { if (!replaceEvent(GameEvent.getEvent(GameEvent.EventType.DESTROY_PERMANENT_BY_LEGENDARY_RULE, legend.getId(), legend.getControllerId()))) { Player controller = this.getPlayer(legend.getControllerId()); if (controller != null) { @@ -3146,7 +3152,7 @@ public abstract class GameImpl implements Game { result.setRemainingAmount(amountToPrevent - result.getPreventedDamage()); } MageObject damageSource = game.getObject(damageEvent.getSourceId()); - MageObject preventionSource = game.getObject(source.getSourceId()); + MageObject preventionSource = game.getObject(source); if (damageSource != null && preventionSource != null) { MageObject targetObject = game.getObject(event.getTargetId()); diff --git a/Mage/src/main/java/mage/game/combat/Combat.java b/Mage/src/main/java/mage/game/combat/Combat.java index a4c4e224f24..2b109a1af4f 100644 --- a/Mage/src/main/java/mage/game/combat/Combat.java +++ b/Mage/src/main/java/mage/game/combat/Combat.java @@ -384,7 +384,7 @@ public class Combat implements Serializable, Copyable { } } - if (target.choose(Outcome.Benefit, attackingPlayerId, null, game)) { + if (target.choose(Outcome.Benefit, attackingPlayerId, null, null, game)) { isBanded = true; for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage/src/main/java/mage/game/command/dungeons/TombOfAnnihilationDungeon.java b/Mage/src/main/java/mage/game/command/dungeons/TombOfAnnihilationDungeon.java index 02a250a6ae0..5f56eaffdac 100644 --- a/Mage/src/main/java/mage/game/command/dungeons/TombOfAnnihilationDungeon.java +++ b/Mage/src/main/java/mage/game/command/dungeons/TombOfAnnihilationDungeon.java @@ -105,7 +105,7 @@ class VeilsOfFearEffect extends OneShotEffect { continue; } TargetDiscard target = new TargetDiscard(0, 1, StaticFilters.FILTER_CARD, playerId); - player.choose(Outcome.PreventDamage, target, source.getSourceId(), game); + player.choose(Outcome.PreventDamage, target, source, game); map.put(playerId, game.getCard(target.getFirstTarget())); } for (Map.Entry entry : map.entrySet()) { @@ -151,7 +151,7 @@ class OublietteEffect extends OneShotEffect { return true; } OublietteTarget target = new OublietteTarget(Math.min(saccable, 3)); - player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + player.choose(Outcome.Sacrifice, target, source, game); for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { @@ -207,8 +207,8 @@ class OublietteTarget extends TargetControlledPermanent { @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); possibleTargets.removeIf(uuid -> !this.canTarget(sourceControllerId, uuid, null, game)); return possibleTargets; } @@ -216,7 +216,7 @@ class OublietteTarget extends TargetControlledPermanent { static int checkTargetCount(Ability source, Game game) { List permanents = game .getBattlefield() - .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + .getActivePermanents(filter, source.getControllerId(), source, game); return cardTypeAssigner.getRoleCount(new CardsImpl(permanents), game); } } @@ -246,7 +246,7 @@ class SandfallCellEffect extends OneShotEffect { continue; } TargetPermanent target = new TargetPermanent(0, 1, TombOfAnnihilationDungeon.filter, true); - player.choose(Outcome.PreventDamage, target, source.getSourceId(), game); + player.choose(Outcome.PreventDamage, target, source, game); map.put(playerId, game.getPermanent(target.getFirstTarget())); } for (Map.Entry entry : map.entrySet()) { diff --git a/Mage/src/main/java/mage/game/command/emblems/KothOfTheHammerEmblem.java b/Mage/src/main/java/mage/game/command/emblems/KothOfTheHammerEmblem.java index ad4ecfda6d6..f21f8dfc508 100644 --- a/Mage/src/main/java/mage/game/command/emblems/KothOfTheHammerEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/KothOfTheHammerEmblem.java @@ -51,7 +51,7 @@ class KothOfTheHammerThirdEffect extends ContinuousEffectImpl { switch (layer) { case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(mountains, source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(mountains, source.getControllerId(), source, game)) { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); ability.addTarget(new TargetAnyTarget()); permanent.addAbility(ability, source.getSourceId(), game); diff --git a/Mage/src/main/java/mage/game/command/emblems/NarsetTranscendentEmblem.java b/Mage/src/main/java/mage/game/command/emblems/NarsetTranscendentEmblem.java index 80af9b6b1a8..6702ed52da7 100644 --- a/Mage/src/main/java/mage/game/command/emblems/NarsetTranscendentEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/NarsetTranscendentEmblem.java @@ -52,7 +52,7 @@ class NarsetTranscendentCantCastEffect extends ContinuousRuleModifyingEffectImpl @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { - MageObject mageObject = game.getObject(source.getSourceId()); + MageObject mageObject = game.getObject(source); if (mageObject != null) { return "You can't cast can't cast noncreature spells (it is prevented by emblem of " + mageObject.getLogName() + ')'; } diff --git a/Mage/src/main/java/mage/game/command/emblems/SerraTheBenevolentEmblem.java b/Mage/src/main/java/mage/game/command/emblems/SerraTheBenevolentEmblem.java index 1d0ad23d58a..564e6dbb0c7 100644 --- a/Mage/src/main/java/mage/game/command/emblems/SerraTheBenevolentEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/SerraTheBenevolentEmblem.java @@ -53,7 +53,7 @@ class SerraTheBenevolentEmblemEffect extends ReplacementEffectImpl { && (controller.getLife() - event.getAmount()) < 1 && game.getBattlefield().count( StaticFilters.FILTER_CONTROLLED_CREATURE, - source.getSourceId(), event.getPlayerId(), game) > 0 + event.getPlayerId(), source, game) > 0 ) { event.setAmount(controller.getLife() - 1); } diff --git a/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java b/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java index 4e498c5bfe3..87af270d4b7 100644 --- a/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java @@ -95,6 +95,6 @@ class HedronFieldsOfAgadeemRestrictionEffect extends RestrictionEffect { if (!cPlane.getPlaneType().equals(Planes.PLANE_HEDRON_FIELDS_OF_AGADEEM)) { return false; } - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } } diff --git a/Mage/src/main/java/mage/game/command/planes/TazeemPlane.java b/Mage/src/main/java/mage/game/command/planes/TazeemPlane.java index 1671cd06640..6f9ba42e1ba 100644 --- a/Mage/src/main/java/mage/game/command/planes/TazeemPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/TazeemPlane.java @@ -80,7 +80,7 @@ class TazeemCantBlockAllEffect extends RestrictionEffect { if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_TAZEEM)) { return false; } - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/game/permanent/Battlefield.java b/Mage/src/main/java/mage/game/permanent/Battlefield.java index b98857d6821..7efd77533d2 100644 --- a/Mage/src/main/java/mage/game/permanent/Battlefield.java +++ b/Mage/src/main/java/mage/game/permanent/Battlefield.java @@ -70,17 +70,16 @@ public class Battlefield implements Serializable { * influence of the specified player id and that match the supplied filter. * * @param filter - * @param sourceId - sourceId of the MageObject the calling effect/ability - * belongs to * @param sourcePlayerId + * @param source * @param game * @return count */ - public int count(FilterPermanent filter, UUID sourceId, UUID sourcePlayerId, Game game) { + public int count(FilterPermanent filter, UUID sourcePlayerId, Ability source, Game game) { if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { return (int) field.values() .stream() - .filter(permanent -> filter.match(permanent, sourceId, sourcePlayerId, game) + .filter(permanent -> filter.match(permanent, sourcePlayerId, source, game) && permanent.isPhasedIn()) .count(); } else { @@ -88,13 +87,13 @@ public class Battlefield implements Serializable { return (int) field.values() .stream() .filter(permanent -> range.contains(permanent.getControllerId()) - && filter.match(permanent, sourceId, sourcePlayerId, game) + && filter.match(permanent, sourcePlayerId, source, game) && permanent.isPhasedIn()).count(); } } public boolean containsControlled(FilterPermanent filter, Ability source, Game game, int num) { - return containsControlled(filter, source.getSourceId(), source.getControllerId(), game, num); + return containsControlled(filter, source.getSourceId(), source.getControllerId(), source, game, num); } /** @@ -105,22 +104,23 @@ public class Battlefield implements Serializable { * @param filter * @param sourceId * @param controllerId controller and source can be different (from different players) - * @param num + * @param source * @param game + * @param num * @return boolean */ - public boolean containsControlled(FilterPermanent filter, UUID sourceId, UUID controllerId, Game game, int num) { + public boolean containsControlled(FilterPermanent filter, UUID sourceId, UUID controllerId, Ability source, Game game, int num) { return field.values() .stream() .filter(permanent -> permanent.isControlledBy(controllerId) - && filter.match(permanent, sourceId, controllerId, game) + && filter.match(permanent, controllerId, source, game) && permanent.isPhasedIn()) .count() >= num; } public boolean contains(FilterPermanent filter, Ability source, Game game, int num) { - return contains(filter, source.getSourceId(), source.getControllerId(), game, num); + return contains(filter, source.getSourceId(), source.getControllerId(), source, game, num); } /** @@ -131,21 +131,22 @@ public class Battlefield implements Serializable { * @param filter * @param sourceId can be null for default SBA checks like legendary rule * @param sourcePlayerId + * @param source * @param game * @param num * @return boolean */ - public boolean contains(FilterPermanent filter, UUID sourceId, UUID sourcePlayerId, Game game, int num) { + public boolean contains(FilterPermanent filter, UUID sourceId, UUID sourcePlayerId, Ability source, Game game, int num) { if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { return field.values().stream() - .filter(permanent -> filter.match(permanent, sourceId, sourcePlayerId, game) + .filter(permanent -> filter.match(permanent, sourcePlayerId, source, game) && permanent.isPhasedIn()).count() >= num; } else { List range = game.getState().getPlayersInRange(sourcePlayerId, game); return field.values().stream() .filter(permanent -> range.contains(permanent.getControllerId()) - && filter.match(permanent, sourceId, sourcePlayerId, game) + && filter.match(permanent, sourcePlayerId, source, game) && permanent.isPhasedIn()) .count() >= num; } @@ -288,23 +289,23 @@ public class Battlefield implements Serializable { * * @param filter * @param sourcePlayerId - * @param sourceId + * @param source * @param game * @return a list of {@link Permanent} * @see Permanent */ - public List getActivePermanents(FilterPermanent filter, UUID sourcePlayerId, UUID sourceId, Game game) { + public List getActivePermanents(FilterPermanent filter, UUID sourcePlayerId, Ability source, Game game) { if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { return field.values() .stream() - .filter(perm -> perm.isPhasedIn() && filter.match(perm, sourceId, sourcePlayerId, game)) + .filter(perm -> perm.isPhasedIn() && filter.match(perm, sourcePlayerId, source, game)) .collect(Collectors.toList()); } else { List range = game.getState().getPlayersInRange(sourcePlayerId, game); return field.values() .stream() .filter(perm -> perm.isPhasedIn() && range.contains(perm.getControllerId()) - && filter.match(perm, sourceId, sourcePlayerId, game)).collect(Collectors.toList()); + && filter.match(perm, sourcePlayerId, source, game)).collect(Collectors.toList()); } } diff --git a/Mage/src/main/java/mage/game/permanent/token/SengirNosferatuBatToken.java b/Mage/src/main/java/mage/game/permanent/token/SengirNosferatuBatToken.java index 55609c11519..23662c07a3a 100644 --- a/Mage/src/main/java/mage/game/permanent/token/SengirNosferatuBatToken.java +++ b/Mage/src/main/java/mage/game/permanent/token/SengirNosferatuBatToken.java @@ -85,7 +85,7 @@ class ReturnSengirNosferatuEffect extends OneShotEffect { } Target target = new TargetCardInExile(filter); target.setNotTarget(true); - if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) { + if (!target.canChoose(source.getControllerId(), source, game)) { return false; } player.chooseTarget(Outcome.PutCreatureInPlay, target, source, game); diff --git a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java index a323b1af453..f7c2c15b15a 100644 --- a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java +++ b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java @@ -349,7 +349,7 @@ public abstract class TokenImpl extends MageObjectImpl implements Token { // select new target auraTarget.setNotTarget(true); - if (!controller.choose(auraOutcome, auraTarget, source.getSourceId(), game)) { + if (!controller.choose(auraOutcome, auraTarget, source, game)) { break; } UUID targetId = auraTarget.getFirstTarget(); diff --git a/Mage/src/main/java/mage/game/stack/SpellStack.java b/Mage/src/main/java/mage/game/stack/SpellStack.java index 8a355a85dce..473bb29b3e0 100644 --- a/Mage/src/main/java/mage/game/stack/SpellStack.java +++ b/Mage/src/main/java/mage/game/stack/SpellStack.java @@ -68,7 +68,7 @@ public class SpellStack extends ArrayDeque { // so if logic is changed here check those spells for needed changes too // Concerned cards to check: Hinder, Spell Crumple StackObject stackObject = getStackObject(objectId); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (stackObject != null && sourceObject != null) { MageObject targetSourceObject = game.getObject(stackObject.getSourceId()); String counteredObjectName, targetSourceName; diff --git a/Mage/src/main/java/mage/game/stack/StackObjectImpl.java b/Mage/src/main/java/mage/game/stack/StackObjectImpl.java index f24d4e1d73d..3acdd809b5f 100644 --- a/Mage/src/main/java/mage/game/stack/StackObjectImpl.java +++ b/Mage/src/main/java/mage/game/stack/StackObjectImpl.java @@ -324,7 +324,7 @@ public abstract class StackObjectImpl implements StackObject { if (targetNames != null && (forceChange || targetController.chooseUse(outcome, "Change this target: " + targetNames + targetAmount + '?', ability, game))) { - Set possibleTargets = target.possibleTargets(this.getSourceId(), getControllerId(), game); + Set possibleTargets = target.possibleTargets(getControllerId(), ability, game); // choose exactly one other target - already targeted objects are not counted if (forceChange && possibleTargets != null && possibleTargets.size() > 1) { // controller of spell must be used (e.g. TargetOpponent) int iteration = 0; diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index 76fa8680f71..01fdbb229f0 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -609,9 +609,9 @@ public interface Player extends MageItem, Copyable { boolean priority(Game game); - boolean choose(Outcome outcome, Target target, UUID sourceId, Game game); + boolean choose(Outcome outcome, Target target, Ability source, Game game); - boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options); + boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options); boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game); // TODO: remove to use choose with "Ability source" diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 4b13e03a1b1..67f813c860e 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -789,7 +789,7 @@ public abstract class PlayerImpl implements Player, Serializable { return toDiscard; } TargetDiscard target = new TargetDiscard(minAmount, maxAmount, StaticFilters.FILTER_CARD, getId()); - choose(Outcome.Discard, target, source != null ? source.getSourceId() : null, game); + choose(Outcome.Discard, target, source, game); toDiscard.addAll(target.getTargets()); return toDiscard; } @@ -2730,7 +2730,7 @@ public abstract class PlayerImpl implements Player, Serializable { } } - if (newTarget.choose(Outcome.Neutral, searchingController.getId(), targetPlayer.getId(), game)) { + if (newTarget.choose(Outcome.Neutral, searchingController.getId(), targetPlayer.getId(), source, game)) { target.getTargets().clear(); for (UUID targetId : newTarget.getTargets()) { target.add(targetId, game); @@ -2758,7 +2758,7 @@ public abstract class PlayerImpl implements Player, Serializable { Set cards = this.getLibrary() .getCards(game) .stream() - .filter(card -> filter.match(card, source.getSourceId(), getId(), game)) + .filter(card -> filter.match(card, getId(), source, game)) .collect(Collectors.toSet()); Card card = RandomUtil.randomFromCollection(cards); if (card == null) { @@ -4231,7 +4231,7 @@ public abstract class PlayerImpl implements Player, Serializable { } private void addCostTargetOptions(List options, Ability option, int targetNum, Game game) { - for (UUID targetId : option.getCosts().getTargets().get(targetNum).possibleTargets(option.getSourceId(), playerId, game)) { + for (UUID targetId : option.getCosts().getTargets().get(targetNum).possibleTargets(playerId, option, game)) { Ability newOption = option.copy(); newOption.getCosts().getTargets().get(targetNum).addTarget(targetId, option, game, true); if (targetNum < option.getCosts().getTargets().size() - 1) { @@ -4322,7 +4322,7 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public boolean canPaySacrificeCost(Permanent permanent, Ability source, UUID controllerId, Game game) { - return sacrificeCostFilter == null || !sacrificeCostFilter.match(permanent, source.getSourceId(), controllerId, game); + return sacrificeCostFilter == null || !sacrificeCostFilter.match(permanent, controllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/players/StubPlayer.java b/Mage/src/main/java/mage/players/StubPlayer.java index ad47e96d2a1..493ad985a23 100644 --- a/Mage/src/main/java/mage/players/StubPlayer.java +++ b/Mage/src/main/java/mage/players/StubPlayer.java @@ -37,7 +37,7 @@ import static com.google.common.collect.Iterables.getOnlyElement; public class StubPlayer extends PlayerImpl implements Player { @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game) { if (target instanceof TargetPlayer) { for (Player player : game.getPlayers().values()) { if (player.getId().equals(getId()) && target.canTarget(getId(), game)) { @@ -103,14 +103,14 @@ public class StubPlayer extends PlayerImpl implements Player { } @Override - public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map options) { + public boolean choose(Outcome outcome, Target target, Ability source, Game game, Map options) { return false; } @Override public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) { if (target.getFilter().getMessage() != null && target.getFilter().getMessage().endsWith(" more) to put on the bottom of your library")) { - chooseDiscardBottom(game, target.getMinNumberOfTargets(), new ArrayList<>(target.possibleTargets(null, null, game))) + chooseDiscardBottom(game, target.getMinNumberOfTargets(), new ArrayList<>(target.possibleTargets(null, source, game))) .forEach(cardId -> target.add(cardId, game)); } return false; diff --git a/Mage/src/main/java/mage/target/Target.java b/Mage/src/main/java/mage/target/Target.java index 72f5c25a8ae..244fda9f259 100644 --- a/Mage/src/main/java/mage/target/Target.java +++ b/Mage/src/main/java/mage/target/Target.java @@ -34,9 +34,9 @@ public interface Target extends Serializable { void setNotTarget(boolean notTarget); // methods for targets - boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game); + boolean canChoose(UUID sourceControllerId, Ability source, Game game); - Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game); + Set possibleTargets(UUID sourceControllerId, Ability source, Game game); boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game); @@ -70,7 +70,7 @@ public interface Target extends Serializable { Set possibleTargets(UUID sourceControllerId, Game game); - boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game); + boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Ability source, Game game); void add(UUID id, Game game); diff --git a/Mage/src/main/java/mage/target/TargetAmount.java b/Mage/src/main/java/mage/target/TargetAmount.java index 692cc0cb741..5fc1db14af1 100644 --- a/Mage/src/main/java/mage/target/TargetAmount.java +++ b/Mage/src/main/java/mage/target/TargetAmount.java @@ -120,7 +120,7 @@ public abstract class TargetAmount extends TargetImpl { @Override public List getTargetOptions(Ability source, Game game) { List options = new ArrayList<>(); - Set possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game); + Set possibleTargets = possibleTargets(source.getControllerId(), source, game); addTargets(this, possibleTargets, options, source, game); diff --git a/Mage/src/main/java/mage/target/TargetCard.java b/Mage/src/main/java/mage/target/TargetCard.java index c74f2b7e74c..cbcff16d392 100644 --- a/Mage/src/main/java/mage/target/TargetCard.java +++ b/Mage/src/main/java/mage/target/TargetCard.java @@ -53,13 +53,14 @@ public class TargetCard extends TargetObject { /** * Checks if there are enough {@link Card} that can be chosen. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid {@link Card} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + UUID sourceId = source != null ? source.getSourceId() : null; int possibleTargets = 0; if (getNumberOfTargets() == 0) { // if 0 target is valid, the canChoose is always true return true; @@ -72,7 +73,7 @@ public class TargetCard extends TargetObject { } switch (zone) { case HAND: - for (Card card : player.getHand().getCards(filter, sourceId, sourceControllerId, game)) { + for (Card card : player.getHand().getCards(filter, sourceControllerId, source, game)) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { possibleTargets++; if (possibleTargets >= this.minNumberOfTargets) { @@ -82,7 +83,7 @@ public class TargetCard extends TargetObject { } break; case GRAVEYARD: - for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { + for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { possibleTargets++; if (possibleTargets >= this.minNumberOfTargets) { @@ -120,7 +121,7 @@ public class TargetCard extends TargetObject { .map(game::getCard) .filter(Objects::nonNull) .filter(card -> game.getState().getZone(card.getId()).equals(Zone.COMMAND)) - .filter(card -> filter.match(card, sourceId, sourceControllerId, game)) + .filter(card -> filter.match(card, sourceControllerId, source, game)) .collect(Collectors.toList()); for (Card card : possibleCards) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { @@ -146,25 +147,26 @@ public class TargetCard extends TargetObject { */ @Override public boolean canChoose(UUID sourceControllerId, Game game) { - return canChoose(null, sourceControllerId, game); + return canChoose(sourceControllerId, null, game); } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); + UUID sourceId = source != null ? source.getSourceId() : null; for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null) { switch (zone) { case HAND: - for (Card card : player.getHand().getCards(filter, sourceId, sourceControllerId, game)) { + for (Card card : player.getHand().getCards(filter, sourceControllerId, source, game)) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { possibleTargets.add(card.getId()); } } break; case GRAVEYARD: - for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { + for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { possibleTargets.add(card.getId()); } @@ -173,7 +175,7 @@ public class TargetCard extends TargetObject { case LIBRARY: for (Card card : player.getLibrary().getUniqueCards(game)) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { - if (filter.match(card, sourceId, sourceControllerId, game)) { + if (filter.match(card, sourceControllerId, source, game)) { possibleTargets.add(card.getId()); } } @@ -182,7 +184,7 @@ public class TargetCard extends TargetObject { case EXILED: for (Card card : game.getExile().getPermanentExile().getCards(game)) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { - if (filter.match(card, sourceId, sourceControllerId, game)) { + if (filter.match(card, sourceControllerId, source, game)) { possibleTargets.add(card.getId()); } } @@ -193,7 +195,7 @@ public class TargetCard extends TargetObject { .map(game::getCard) .filter(Objects::nonNull) .filter(card -> game.getState().getZone(card.getId()).equals(Zone.COMMAND)) - .filter(card -> filter.match(card, sourceId, sourceControllerId, game)) + .filter(card -> filter.match(card, sourceControllerId, source, game)) .collect(Collectors.toList()); for (Card card : possibleCards) { if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { @@ -213,7 +215,7 @@ public class TargetCard extends TargetObject { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { - return possibleTargets(null, sourceControllerId, game); + return possibleTargets(sourceControllerId, (Ability) null, game); } // TODO: check all class targets, if it override canTarget then make sure it override ALL 3 METHODS with canTarget and possibleTargets (method with cards doesn't need) diff --git a/Mage/src/main/java/mage/target/TargetImpl.java b/Mage/src/main/java/mage/target/TargetImpl.java index 0e1100e5b48..7bb1ff0cc62 100644 --- a/Mage/src/main/java/mage/target/TargetImpl.java +++ b/Mage/src/main/java/mage/target/TargetImpl.java @@ -269,7 +269,7 @@ public abstract class TargetImpl implements Target { } @Override - public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Ability source, Game game) { Player targetController = getTargetController(game, playerId); if (targetController == null) { return false; @@ -280,7 +280,7 @@ public abstract class TargetImpl implements Target { if (!targetController.canRespond()) { return chosen; } - if (!targetController.choose(outcome, this, sourceId, game)) { + if (!targetController.choose(outcome, this, source, game)) { return chosen; } chosen = targets.size() >= getNumberOfTargets(); @@ -295,7 +295,7 @@ public abstract class TargetImpl implements Target { return false; } - List possibleTargets = new ArrayList<>(possibleTargets(source.getSourceId(), playerId, game)); + List possibleTargets = new ArrayList<>(possibleTargets(playerId, source, game)); chosen = targets.size() >= getNumberOfTargets(); do { @@ -385,7 +385,7 @@ public abstract class TargetImpl implements Target { public List getTargetOptions(Ability source, Game game) { List options = new ArrayList<>(); List possibleTargets = new ArrayList<>(); - possibleTargets.addAll(possibleTargets(source.getSourceId(), source.getControllerId(), game)); + possibleTargets.addAll(possibleTargets(source.getControllerId(), source, game)); possibleTargets.removeAll(getTargets()); // get the length of the array diff --git a/Mage/src/main/java/mage/target/TargetPermanent.java b/Mage/src/main/java/mage/target/TargetPermanent.java index fbeef9d1f77..5747ea098e4 100644 --- a/Mage/src/main/java/mage/target/TargetPermanent.java +++ b/Mage/src/main/java/mage/target/TargetPermanent.java @@ -65,21 +65,21 @@ public class TargetPermanent extends TargetObject { // second for protection from sources (e.g. protection from artifacts + equip ability) if (!isNotTarget()) { if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) - || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) { + || !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) { return false; } } - return filter.match(permanent, source.getSourceId(), controllerId, game); + return filter.match(permanent, controllerId, source, game); } else { - return filter.match(permanent, null, controllerId, game); + return filter.match(permanent, controllerId, source, game); } } return false; } - public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) { + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game, boolean flag) { Permanent permanent = game.getPermanent(id); - return filter.match(permanent, sourceId, controllerId, game); + return filter.match(permanent, controllerId, source, game); } @Override @@ -93,20 +93,20 @@ public class TargetPermanent extends TargetObject { * Takes into account notTarget parameter, in case it's true doesn't check * for protection, shroud etc. * - * @param sourceId the target event source * @param sourceControllerId controller of the target event source + * @param source * @param game * @return true if enough valid {@link Permanent} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int remainingTargets = this.minNumberOfTargets - targets.size(); if (remainingTargets <= 0) { return true; } int count = 0; - MageObject targetSource = game.getObject(sourceId); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + MageObject targetSource = game.getObject(source); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId())) { if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; @@ -149,11 +149,11 @@ public class TargetPermanent extends TargetObject { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { // TODO: check if possible targets works with setTargetController from some cards like Nicol Bolas, Dragon-God Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + MageObject targetSource = game.getObject(source); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) { if (!targets.containsKey(permanent.getId())) { if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); diff --git a/Mage/src/main/java/mage/target/TargetPlayer.java b/Mage/src/main/java/mage/target/TargetPlayer.java index e49673aac15..a5f59b11b52 100644 --- a/Mage/src/main/java/mage/target/TargetPlayer.java +++ b/Mage/src/main/java/mage/target/TargetPlayer.java @@ -55,18 +55,18 @@ public class TargetPlayer extends TargetImpl { * Checks if there are enough {@link Player} that can be chosen. Should only * be used for Ability targets since this checks for protection, shroud etc. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid {@link Player} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); - if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { + if (player != null && !player.hasLeft() && filter.match(player, sourceControllerId, source, game)) { if (player.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { @@ -103,12 +103,12 @@ public class TargetPlayer extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); - if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { + if (player != null && !player.hasLeft() && filter.match(player, sourceControllerId, source, game)) { if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, game)) { possibleTargets.add(playerId); } @@ -149,8 +149,8 @@ public class TargetPlayer extends TargetImpl { Player player = game.getPlayer(id); if (player != null) { if (source != null) { - return (isNotTarget() || player.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) - && filter.match(player, source.getSourceId(), source.getControllerId(), game); + return (isNotTarget() || player.canBeTargetedBy(game.getObject(source), source.getControllerId(), game)) + && filter.match(player, source.getControllerId(), source, game); } else { return filter.match(player, game); } diff --git a/Mage/src/main/java/mage/target/TargetSource.java b/Mage/src/main/java/mage/target/TargetSource.java index e0dae36e505..d093d389c1d 100644 --- a/Mage/src/main/java/mage/target/TargetSource.java +++ b/Mage/src/main/java/mage/target/TargetSource.java @@ -79,7 +79,7 @@ public class TargetSource extends TargetObject { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { return canChoose(sourceControllerId, game); } @@ -124,7 +124,7 @@ public class TargetSource extends TargetObject { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage/src/main/java/mage/target/TargetSpell.java b/Mage/src/main/java/mage/target/TargetSpell.java index 5523f16363e..7fdbf4110f7 100644 --- a/Mage/src/main/java/mage/target/TargetSpell.java +++ b/Mage/src/main/java/mage/target/TargetSpell.java @@ -61,21 +61,21 @@ public class TargetSpell extends TargetObject { return false; } Spell spell = game.getStack().getSpell(id); - return filter.match(spell, source.getSourceId(), source.getControllerId(), game); + return filter.match(spell, source.getControllerId(), source, game); } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { if (this.minNumberOfTargets == 0) { return true; } int count = 0; for (StackObject stackObject : game.getStack()) { // rule 114.4. A spell or ability on the stack is an illegal target for itself. - if (sourceId != null && sourceId.equals(stackObject.getSourceId())) { + if (source.getSourceId() != null && source.getSourceId().equals(stackObject.getSourceId())) { continue; } - if (canBeChosen(stackObject, sourceId, sourceControllerId, game)) { + if (canBeChosen(stackObject, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -87,20 +87,20 @@ public class TargetSpell extends TargetObject { @Override public boolean canChoose(UUID sourceControllerId, Game game) { - return canChoose(null, sourceControllerId, game); + return canChoose(sourceControllerId, null, game); } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return game.getStack().stream() - .filter(stackObject -> canBeChosen(stackObject, sourceId, sourceControllerId, game)) + .filter(stackObject -> canBeChosen(stackObject, sourceControllerId, source, game)) .map(StackObject::getId) .collect(Collectors.toSet()); } @Override public Set possibleTargets(UUID sourceControllerId, Game game) { - return this.possibleTargets(null, sourceControllerId, game); + return this.possibleTargets(sourceControllerId, null, game); } @Override @@ -108,10 +108,10 @@ public class TargetSpell extends TargetObject { return new TargetSpell(this); } - private boolean canBeChosen(StackObject stackObject, UUID sourceID, UUID sourceControllerId, Game game) { + private boolean canBeChosen(StackObject stackObject, UUID sourceControllerId, Ability source, Game game) { return stackObject instanceof Spell && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) - && filter.match(stackObject, sourceID, sourceControllerId, game); + && filter.match(stackObject, sourceControllerId, source, game); } @Override diff --git a/Mage/src/main/java/mage/target/TargetStackObject.java b/Mage/src/main/java/mage/target/TargetStackObject.java index 11c084fba93..6dc55855735 100644 --- a/Mage/src/main/java/mage/target/TargetStackObject.java +++ b/Mage/src/main/java/mage/target/TargetStackObject.java @@ -51,15 +51,15 @@ public class TargetStackObject extends TargetObject { @Override public boolean canTarget(UUID id, Ability source, Game game) { StackObject stackObject = game.getStack().getStackObject(id); - return filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); + return filter.match(stackObject, source.getControllerId(), source, game); } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; for (StackObject stackObject : game.getStack()) { if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) - && filter.match(stackObject, sourceId, sourceControllerId, game)) { + && filter.match(stackObject, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -71,15 +71,15 @@ public class TargetStackObject extends TargetObject { @Override public boolean canChoose(UUID sourceControllerId, Game game) { - return canChoose(null, sourceControllerId, game); + return canChoose(sourceControllerId, null, game); } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); for (StackObject stackObject : game.getStack()) { if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) - && filter.match(stackObject, sourceId, sourceControllerId, game)) { + && filter.match(stackObject, sourceControllerId, source, game)) { possibleTargets.add(stackObject.getId()); } } @@ -88,7 +88,7 @@ public class TargetStackObject extends TargetObject { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { - return this.possibleTargets(null, sourceControllerId, game); + return this.possibleTargets(sourceControllerId, null, game); } @Override diff --git a/Mage/src/main/java/mage/target/Targets.java b/Mage/src/main/java/mage/target/Targets.java index 2c2a0a4796c..34f09ae4e95 100644 --- a/Mage/src/main/java/mage/target/Targets.java +++ b/Mage/src/main/java/mage/target/Targets.java @@ -4,7 +4,6 @@ import mage.abilities.Ability; import mage.constants.Outcome; import mage.game.Game; import mage.game.events.GameEvent; -import mage.players.Player; import mage.target.targetpointer.*; import org.apache.log4j.Logger; @@ -46,14 +45,14 @@ public class Targets extends ArrayList { return stream().allMatch(Target::isChosen); } - public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) { + public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Ability source, Game game) { if (this.size() > 0) { - if (!canChoose(sourceId, playerId, game)) { + if (!canChoose(playerId, source, game)) { return false; } while (!isChosen()) { Target target = this.getUnchosen().get(0); - if (!target.choose(outcome, playerId, sourceId, game)) { + if (!target.choose(outcome, playerId, sourceId, source, game)) { return false; } } @@ -63,7 +62,7 @@ public class Targets extends ArrayList { public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, boolean noMana, Game game, boolean canCancel) { if (this.size() > 0) { - if (!canChoose(source.getSourceId(), playerId, game)) { + if (!canChoose(playerId, source, game)) { return false; } @@ -113,22 +112,22 @@ public class Targets extends ArrayList { /** * For target choose - * + *

* Checks if there are enough targets that can be chosen. Should only be * used for Ability targets since this checks for protection, shroud etc. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid targets exist */ - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - return stream().allMatch(target -> target.canChoose(sourceId, sourceControllerId, game)); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + return stream().allMatch(target -> target.canChoose(sourceControllerId, source, game)); } /** * For non target choose (e.g. cost pay) - * + *

* Checks if there are enough objects that can be selected. Should not be * used for Ability targets since this does not check for protection, shroud * etc. diff --git a/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java b/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java index 0d1e40e512d..03dcbd67276 100644 --- a/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java +++ b/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java @@ -50,11 +50,11 @@ public class TargetActivatedAbility extends TargetObject { && stackObject.getStackAbility() != null && stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED && source != null - && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); + && filter.match(stackObject, source.getControllerId(), source, game); } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { return canChoose(sourceControllerId, game); } @@ -71,7 +71,7 @@ public class TargetActivatedAbility extends TargetObject { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbility.java b/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbility.java index 6552c4bba01..62d5c52a4c7 100644 --- a/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbility.java +++ b/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbility.java @@ -42,14 +42,14 @@ public class TargetActivatedOrTriggeredAbility extends TargetObject { } StackObject stackObject = game.getStack().getStackObject(id); - return isActivatedOrTriggeredAbility(stackObject) && source != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); + return isActivatedOrTriggeredAbility(stackObject) && source != null && filter.match(stackObject, source.getControllerId(), source, game); } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { for (StackObject stackObject : game.getStack()) { if (isActivatedOrTriggeredAbility(stackObject) - && filter.match(stackObject, sourceId, sourceControllerId, game)) { + && filter.match(stackObject, sourceControllerId, source, game)) { return true; } } @@ -64,7 +64,7 @@ public class TargetActivatedOrTriggeredAbility extends TargetObject { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbilityOrLegendarySpell.java b/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbilityOrLegendarySpell.java index f8e04dd2f22..8a4168eb993 100644 --- a/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbilityOrLegendarySpell.java +++ b/Mage/src/main/java/mage/target/common/TargetActivatedOrTriggeredAbilityOrLegendarySpell.java @@ -44,14 +44,14 @@ public class TargetActivatedOrTriggeredAbilityOrLegendarySpell extends TargetObj } StackObject stackObject = game.getStack().getStackObject(id); - return isActivatedOrTriggeredAbilityOrLegendarySpell(stackObject) && source != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); + return isActivatedOrTriggeredAbilityOrLegendarySpell(stackObject) && source != null && filter.match(stackObject, source.getControllerId(), source, game); } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { for (StackObject stackObject : game.getStack()) { if (isActivatedOrTriggeredAbilityOrLegendarySpell(stackObject) - && filter.match(stackObject, sourceId, sourceControllerId, game)) { + && filter.match(stackObject, sourceControllerId, source, game)) { return true; } } @@ -66,7 +66,7 @@ public class TargetActivatedOrTriggeredAbilityOrLegendarySpell extends TargetObj } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage/src/main/java/mage/target/common/TargetAnyTarget.java b/Mage/src/main/java/mage/target/common/TargetAnyTarget.java index 1fd701564af..8a76cf96a1c 100644 --- a/Mage/src/main/java/mage/target/common/TargetAnyTarget.java +++ b/Mage/src/main/java/mage/target/common/TargetAnyTarget.java @@ -76,9 +76,9 @@ public class TargetAnyTarget extends TargetImpl { Player player = game.getPlayer(id); if (source != null) { - MageObject targetSource = game.getObject(source.getSourceId()); + MageObject targetSource = game.getObject(source); if (permanent != null) { - return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getControllerId(), source, game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game); @@ -96,16 +96,16 @@ public class TargetAnyTarget extends TargetImpl { * be chosen. Should only be used for Ability targets since this checks for * protection, shroud etc. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid {@link Permanent} or {@link Player} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { @@ -117,7 +117,7 @@ public class TargetAnyTarget extends TargetImpl { } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -152,7 +152,7 @@ public class TargetAnyTarget extends TargetImpl { } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game)) { + if (filter.match(permanent, sourceControllerId, null, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -164,22 +164,22 @@ public class TargetAnyTarget extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) - && filter.match(player, sourceId, sourceControllerId, game)) { + && filter.match(player, sourceControllerId, source, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) - && filter.match(permanent, sourceId, sourceControllerId, game)) { + && filter.match(permanent, sourceControllerId, source, game)) { possibleTargets.add(permanent.getId()); } } @@ -199,7 +199,7 @@ public class TargetAnyTarget extends TargetImpl { } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (filter.getPermanentFilter().match(permanent, null, sourceControllerId, game)) { + if (filter.getPermanentFilter().match(permanent, sourceControllerId, null, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetCardInExile.java b/Mage/src/main/java/mage/target/common/TargetCardInExile.java index a68aa088f7c..2457789a2cc 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInExile.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInExile.java @@ -52,7 +52,7 @@ public class TargetCardInExile extends TargetCard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); if (allExileZones) { for (Card card : game.getExile().getAllCards(game)) { @@ -74,11 +74,11 @@ public class TargetCardInExile extends TargetCard { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { if (allExileZones) { int numberTargets = 0; for(ExileZone exileZone : game.getExile().getExileZones()) { - numberTargets += exileZone.count(filter, sourceId, sourceControllerId, game); + numberTargets += exileZone.count(filter, sourceControllerId, source, game); if (numberTargets >= this.minNumberOfTargets) { return true; } @@ -86,7 +86,7 @@ public class TargetCardInExile extends TargetCard { } else { ExileZone exileZone = game.getExile().getExileZone(zoneId); if (exileZone != null) { - if (exileZone.count(filter, sourceId, sourceControllerId, game) >= this.minNumberOfTargets) { + if (exileZone.count(filter, sourceControllerId, source, game) >= this.minNumberOfTargets) { return true; } } diff --git a/Mage/src/main/java/mage/target/common/TargetCardInGraveyardOrBattlefield.java b/Mage/src/main/java/mage/target/common/TargetCardInGraveyardOrBattlefield.java index 0a4824b4eb2..a8ff770be64 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInGraveyardOrBattlefield.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInGraveyardOrBattlefield.java @@ -35,12 +35,12 @@ public class TargetCardInGraveyardOrBattlefield extends TargetCard { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - if (!super.canChoose(sourceId, sourceControllerId, game)) { - MageObject targetSource = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + if (!super.canChoose(sourceControllerId, source, game)) { + MageObject targetSource = game.getObject(source); for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBattlefield, sourceControllerId, game)) { if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) - && filterBattlefield.match(permanent, sourceId, sourceControllerId, game)) { + && filterBattlefield.match(permanent, sourceControllerId, source, game)) { return true; } } @@ -65,7 +65,7 @@ public class TargetCardInGraveyardOrBattlefield extends TargetCard { if (!super.canTarget(playerId, id, source, game)) { // in graveyard first Permanent permanent = game.getPermanent(id); if (permanent != null) { - return filterBattlefield.match(permanent, source != null ? source.getSourceId() : null, playerId, game); + return filterBattlefield.match(permanent, playerId, source, game); } } return true; @@ -86,7 +86,7 @@ public class TargetCardInGraveyardOrBattlefield extends TargetCard { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = super.possibleTargets(sourceControllerId, game); // in graveyard first for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBattlefield, sourceControllerId, game)) { - if (filterBattlefield.match(permanent, null, sourceControllerId, game)) { + if (filterBattlefield.match(permanent, sourceControllerId, null, game)) { possibleTargets.add(permanent.getId()); } } @@ -94,11 +94,11 @@ public class TargetCardInGraveyardOrBattlefield extends TargetCard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); // in graveyard first - MageObject targetSource = game.getObject(sourceId); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBattlefield, sourceControllerId, sourceId, game)) { - if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filterBattlefield.match(permanent, sourceId, sourceControllerId, game)) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); // in graveyard first + MageObject targetSource = game.getObject(source); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBattlefield, sourceControllerId, source, game)) { + if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filterBattlefield.match(permanent, sourceControllerId, source, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetCardInHand.java b/Mage/src/main/java/mage/target/common/TargetCardInHand.java index d60d8a5ad08..98211eeaa12 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInHand.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInHand.java @@ -5,7 +5,6 @@ import mage.cards.Card; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.events.TargetEvent; import mage.players.Player; import mage.target.TargetCard; @@ -57,12 +56,12 @@ public class TargetCardInHand extends TargetCard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); Player player = game.getPlayer(sourceControllerId); if (player != null) { - for (Card card : player.getHand().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : player.getHand().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { possibleTargets.add(card.getId()); } } @@ -71,12 +70,12 @@ public class TargetCardInHand extends TargetCard { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int possibleTargets = 0; Player player = game.getPlayer(sourceControllerId); if (player != null) { - for (Card card : player.getHand().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : player.getHand().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { possibleTargets++; if (possibleTargets >= this.minNumberOfTargets) { return true; diff --git a/Mage/src/main/java/mage/target/common/TargetCardInLibrary.java b/Mage/src/main/java/mage/target/common/TargetCardInLibrary.java index 59b39f4ba89..5c80d0a2e1e 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInLibrary.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInLibrary.java @@ -56,7 +56,7 @@ public class TargetCardInLibrary extends TargetCard { } @Override - public boolean choose(Outcome outcome, UUID playerId, UUID targetPlayerId, Game game) { // TODO: wtf sourceId named as targetPlayerId?! + public boolean choose(Outcome outcome, UUID playerId, UUID targetPlayerId, Ability source, Game game) { // TODO: wtf sourceId named as targetPlayerId?! Player player = game.getPlayer(playerId); Player targetPlayer = game.getPlayer(targetPlayerId); if (targetPlayer == null) { @@ -93,7 +93,7 @@ public class TargetCardInLibrary extends TargetCard { @Override public boolean canTarget(UUID id, Ability source, Game game) { Card card = game.getPlayer(source.getControllerId()).getLibrary().getCard(id, game); - return filter.match(card, source.getSourceId(), source.getControllerId(), game); + return filter.match(card, source.getControllerId(), source, game); } @Override diff --git a/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java b/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java index 097305fe5f1..97c60583b87 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java @@ -8,7 +8,6 @@ import mage.cards.Card; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.events.TargetEvent; import mage.players.Player; import mage.target.TargetCard; @@ -47,7 +46,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { return false; } } - return filter.match(card, source.getId(), playerId, game); + return filter.match(card, playerId, source, game); } } return false; @@ -72,19 +71,19 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { @Override public boolean canChoose(UUID sourceControllerId, Game game) { - return canChoose(null, sourceControllerId, game); + return canChoose(sourceControllerId, null, game); } /** * Checks if there are enough {@link Card} that can be chosen. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source - * @param game - * @return - true if enough valid {@link Card} exist + * @param source + * @param game + * @return - true if enough valid {@link Card} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int possibleTargets = 0; if (getNumberOfTargets() == 0) { // if 0 target is valid, the canChoose is always true return true; @@ -100,8 +99,8 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { if (!playerId.equals(sourceControllerId)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { possibleTargets++; if (possibleTargets >= this.minNumberOfTargets) { return true; @@ -115,7 +114,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); Player sourceController = game.getPlayer(sourceControllerId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { @@ -125,8 +124,8 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { Player player = game.getPlayer(playerId); if (player != null) { Set targetsInThisGraveyeard = new HashSet<>(); - for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { targetsInThisGraveyeard.add(card.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetCardInYourGraveyard.java b/Mage/src/main/java/mage/target/common/TargetCardInYourGraveyard.java index 5a6b38f0c7e..77ac0d5bdf1 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInYourGraveyard.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInYourGraveyard.java @@ -10,7 +10,6 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.StaticFilters; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.events.TargetEvent; import mage.players.Player; import mage.target.TargetCard; @@ -55,7 +54,7 @@ public class TargetCardInYourGraveyard extends TargetCard { Card card = game.getCard(id); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { if (game.getPlayer(source.getControllerId()).getGraveyard().contains(id)) { - return filter.match(card, source.getSourceId(), source.getControllerId(), game); + return filter.match(card, source.getControllerId(), source, game); } } return false; @@ -73,11 +72,11 @@ public class TargetCardInYourGraveyard extends TargetCard { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); Player player = game.getPlayer(sourceControllerId); - for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { possibleTargets.add(card.getId()); } } @@ -109,15 +108,15 @@ public class TargetCardInYourGraveyard extends TargetCard { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { Player player = game.getPlayer(sourceControllerId); if (player != null) { if (this.minNumberOfTargets == 0) { return true; } int possibleTargets = 0; - for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) { - if (sourceId == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, sourceId, sourceControllerId))) { + for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) { + if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) { possibleTargets++; if (possibleTargets >= this.minNumberOfTargets) { return true; diff --git a/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java b/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java index 8dc7dd5c103..f2a09bcd967 100644 --- a/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java +++ b/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java @@ -76,9 +76,9 @@ public class TargetCreatureOrPlayer extends TargetImpl { Player player = game.getPlayer(id); if (source != null) { - MageObject targetSource = game.getObject(source.getSourceId()); + MageObject targetSource = game.getObject(source); if (permanent != null) { - return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getControllerId(), source, game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game); @@ -96,15 +96,15 @@ public class TargetCreatureOrPlayer extends TargetImpl { * be chosen. Should only be used for Ability targets since this checks for * protection, shroud etc. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid {@link Permanent} or {@link Player} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { @@ -115,7 +115,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -147,7 +147,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game)) { + if (filter.match(permanent, sourceControllerId, null, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -158,20 +158,20 @@ public class TargetCreatureOrPlayer extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) - && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) { + && filter.getPlayerFilter().match(player, sourceControllerId, source, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) - && filter.getCreatureFilter().match(permanent, sourceId, sourceControllerId, game)) { + && filter.getCreatureFilter().match(permanent, sourceControllerId, source, game)) { possibleTargets.add(permanent.getId()); } } @@ -188,7 +188,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) { - if (filter.getCreatureFilter().match(permanent, null, sourceControllerId, game)) { + if (filter.getCreatureFilter().match(permanent, sourceControllerId, null, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetDefender.java b/Mage/src/main/java/mage/target/common/TargetDefender.java index d89d3a35f6e..bbd75386101 100644 --- a/Mage/src/main/java/mage/target/common/TargetDefender.java +++ b/Mage/src/main/java/mage/target/common/TargetDefender.java @@ -53,9 +53,9 @@ public class TargetDefender extends TargetImpl { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null @@ -105,9 +105,12 @@ public class TargetDefender extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + if (source == null) { + return possibleTargets(sourceControllerId, game); + } Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null diff --git a/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java b/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java index 61568fd9557..184fba5a6c7 100644 --- a/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java +++ b/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java @@ -28,8 +28,8 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { } @Override - public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) { - return opponentId != null && super.canTarget(opponentId, id, sourceId, game, flag); + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game, boolean flag) { + return opponentId != null && super.canTarget(opponentId, id, source, game, flag); } @Override @@ -41,12 +41,12 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { boolean canSourceControllerTarget = true; if (!isNotTarget()) { if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) - || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) { + || !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) { canSourceControllerTarget = false; } } canSourceControllerTarget &= super.canTarget(opponentId, id, source, game); - canSourceControllerTarget &= filter.match(permanent, source.getSourceId(), opponentId, game); + canSourceControllerTarget &= filter.match(permanent, opponentId, source, game); return canSourceControllerTarget; } } @@ -75,8 +75,8 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - MageObject sourceObject = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + MageObject sourceObject = game.getObject(source); Player player = game.getPlayer(sourceControllerId); if (sourceObject == null || player == null) { return false; @@ -88,7 +88,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { if (opp != null && player.hasOpponent(opp.getId(), game)) { for (Permanent perm : game.getBattlefield().getActivePermanents(opp.getId(), game)) { if (!targets.containsKey(perm.getId()) - && filter.match(perm, sourceId, opp.getId(), game) + && filter.match(perm, opp.getId(), source, game) && perm.canBeTargetedBy(sourceObject, sourceControllerId, game)) { counter++; if (counter >= minNumberOfTargets) { diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentAmount.java b/Mage/src/main/java/mage/target/common/TargetPermanentAmount.java index dae961df917..4f31b5d388a 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentAmount.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentAmount.java @@ -73,7 +73,7 @@ public class TargetPermanentAmount extends TargetAmount { } MageObject targetSource = source.getSourceObject(game); return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) - && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + && filter.match(permanent, source.getControllerId(), source, game); } @Override @@ -82,8 +82,8 @@ public class TargetPermanentAmount extends TargetAmount { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - return game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game).size() + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + return game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game).size() >= this.minNumberOfTargets; } @@ -94,16 +94,16 @@ public class TargetPermanentAmount extends TargetAmount { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { if (getMaxNumberOfTargets() > 0 && getTargets().size() >= getMaxNumberOfTargets()) { return getTargets() .stream() .collect(Collectors.toSet()); } - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); return game .getBattlefield() - .getActivePermanents(filter, sourceControllerId, sourceId, game) + .getActivePermanents(filter, sourceControllerId, source, game) .stream() .filter(Objects::nonNull) .filter(permanent -> permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java index 40433a2c9ac..7270ab98ed7 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java @@ -78,20 +78,20 @@ public class TargetPermanentOrPlayer extends TargetImpl { Player player = game.getPlayer(id); if (source != null) { - MageObject targetSource = game.getObject(source.getSourceId()); + MageObject targetSource = game.getObject(source); if (permanent != null) { if (!isNotTarget()) { if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), game) - || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) { + || !permanent.canBeTargetedBy(game.getObject(source), source.getControllerId(), game)) { return false; } } - return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + return filter.match(permanent, source.getControllerId(), source, game); } if (player != null) { if (!isNotTarget()) { if (!player.canBeTargetedBy(targetSource, source.getControllerId(), game) - || !filter.match(player, source.getSourceId(), source.getControllerId(), game)) { + || !filter.match(player, source.getControllerId(), source, game)) { return false; } } @@ -110,19 +110,19 @@ public class TargetPermanentOrPlayer extends TargetImpl { * {@link mage.players.Player} that can be chosen. Should only be used for * Ability targets since this checks for protection, shroud etc. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid {@link mage.game.permanent.Permanent} or * {@link mage.players.Player} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); - if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, sourceId, sourceControllerId, game)) { + if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -130,7 +130,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -163,7 +163,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent, game)) { + if (filter.match(permanent, sourceControllerId, null, game) && filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -174,17 +174,17 @@ public class TargetPermanentOrPlayer extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); - if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, sourceId, sourceControllerId, game)) { + if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, sourceControllerId, source, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceControllerId, source, game)) { possibleTargets.add(permanent.getId()); } } @@ -201,7 +201,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game)) { + if (filter.match(permanent, sourceControllerId, null, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerAmount.java b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerAmount.java index e56fd0f3a13..c9bda567b8b 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerAmount.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerAmount.java @@ -72,7 +72,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount { MageObject targetSource = source.getSourceObject(game); if (permanent != null) { return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) - && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + && filter.match(permanent, source.getControllerId(), source, game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) @@ -92,10 +92,10 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { // no max targets limit here int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player == null @@ -144,7 +144,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); // max targets limit reached (only selected can be choosen again) @@ -153,7 +153,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount { return possibleTargets; } - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); game.getState() .getPlayersInRange(sourceControllerId, game) diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentOrSuspendedCard.java b/Mage/src/main/java/mage/target/common/TargetPermanentOrSuspendedCard.java index 64d399238a1..264a488a1c2 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentOrSuspendedCard.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentOrSuspendedCard.java @@ -50,15 +50,15 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - MageObject sourceObject = game.getObject(sourceId); + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { + MageObject sourceObject = game.getObject(source); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { return true; } } for (Card card : game.getExile().getAllCards(game)) { - if (filter.match(card, sourceId, sourceControllerId, game)) { + if (filter.match(card, sourceControllerId, source, game)) { return true; } } @@ -66,16 +66,16 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(20); - MageObject sourceObject = game.getObject(sourceId); + MageObject sourceObject = game.getObject(source); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { possibleTargets.add(permanent.getId()); } } for (Card card : game.getExile().getAllCards(game)) { - if (filter.match(card, sourceId, sourceControllerId, game)) { + if (filter.match(card, sourceControllerId, source, game)) { possibleTargets.add(card.getId()); } } @@ -97,9 +97,9 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl { Permanent permanent = game.getPermanent(id); if (permanent != null) { if (source != null) { - MageObject targetSource = game.getObject(source.getSourceId()); + MageObject targetSource = game.getObject(source); return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) - && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + && filter.match(permanent, source.getControllerId(), source, game); } else { return filter.match(permanent, game); } @@ -115,12 +115,12 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl { @Override public boolean canChoose(UUID sourceControllerId, Game game) { - return this.canChoose(null, sourceControllerId, game); + return this.canChoose(sourceControllerId, null, game); } @Override public Set possibleTargets(UUID sourceControllerId, Game game) { - return this.possibleTargets(null, sourceControllerId, game); + return this.possibleTargets(sourceControllerId, null, game); } @Override diff --git a/Mage/src/main/java/mage/target/common/TargetSpellOrPermanent.java b/Mage/src/main/java/mage/target/common/TargetSpellOrPermanent.java index 3578c44ffc2..57cdd9417ca 100644 --- a/Mage/src/main/java/mage/target/common/TargetSpellOrPermanent.java +++ b/Mage/src/main/java/mage/target/common/TargetSpellOrPermanent.java @@ -88,9 +88,9 @@ public class TargetSpellOrPermanent extends TargetImpl { Permanent permanent = game.getPermanent(id); if (permanent != null) { if (source != null) { - MageObject targetSource = game.getObject(source.getSourceId()); + MageObject targetSource = game.getObject(source); return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) - && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + && filter.match(permanent, source.getControllerId(), source, game); } else { return filter.match(permanent, game); } @@ -110,21 +110,21 @@ public class TargetSpellOrPermanent extends TargetImpl { * {@link mage.game.stack.Spell} that can be chosen. Should only be used for * Ability targets since this checks for protection, shroud etc. * - * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source + * @param source * @param game * @return - true if enough valid {@link mage.game.permanent.Permanent} or * {@link mage.game.stack.Spell} exist */ @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { int count = 0; - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (StackObject stackObject : game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); if (spell != null - && !sourceId.equals(spell.getSourceId()) - && filter.match(spell, sourceId, sourceControllerId, game)) { + && !source.getSourceId().equals(spell.getSourceId()) + && filter.match(spell, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -132,7 +132,7 @@ public class TargetSpellOrPermanent extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -158,7 +158,7 @@ public class TargetSpellOrPermanent extends TargetImpl { for (StackObject stackObject : game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); if (spell != null - && filter.match(spell, null, sourceControllerId, game) && filter.match(spell, game)) { + && filter.match(spell, sourceControllerId, null, game) && filter.match(spell, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -166,7 +166,7 @@ public class TargetSpellOrPermanent extends TargetImpl { } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent, game)) { + if (filter.match(permanent, sourceControllerId, null, game) && filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -177,19 +177,19 @@ public class TargetSpellOrPermanent extends TargetImpl { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { Set possibleTargets = new HashSet<>(); - MageObject targetSource = game.getObject(sourceId); + MageObject targetSource = game.getObject(source); for (StackObject stackObject : game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); if (spell != null - && !sourceId.equals(spell.getSourceId()) - && filter.match(spell, sourceId, sourceControllerId, game)) { + && !source.getSourceId().equals(spell.getSourceId()) + && filter.match(spell, sourceControllerId, source, game)) { possibleTargets.add(spell.getId()); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) { possibleTargets.add(permanent.getId()); } } @@ -202,12 +202,12 @@ public class TargetSpellOrPermanent extends TargetImpl { for (StackObject stackObject : game.getStack()) { Spell spell = game.getStack().getSpell(stackObject.getId()); if (spell != null - && filter.match(spell, null, sourceControllerId, game)) { + && filter.match(spell, sourceControllerId, null, game)) { possibleTargets.add(spell.getId()); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) { - if (filter.match(permanent, null, sourceControllerId, game)) { + if (filter.match(permanent, sourceControllerId, null, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetTappedPermanentAsYouCast.java b/Mage/src/main/java/mage/target/common/TargetTappedPermanentAsYouCast.java index 50e75403233..cef004cf5d1 100644 --- a/Mage/src/main/java/mage/target/common/TargetTappedPermanentAsYouCast.java +++ b/Mage/src/main/java/mage/target/common/TargetTappedPermanentAsYouCast.java @@ -29,7 +29,7 @@ public class TargetTappedPermanentAsYouCast extends TargetPermanent { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return game.getBattlefield().getAllActivePermanents(getFilter(), game).stream() .filter(Permanent::isTapped) .map(Permanent::getId) @@ -37,7 +37,7 @@ public class TargetTappedPermanentAsYouCast extends TargetPermanent { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { return game.getBattlefield().getAllActivePermanents(getFilter(), game).stream() .anyMatch(Permanent::isTapped); } diff --git a/Mage/src/main/java/mage/target/common/TargetTriggeredAbility.java b/Mage/src/main/java/mage/target/common/TargetTriggeredAbility.java index 54a7e3513d9..37028f2f19a 100644 --- a/Mage/src/main/java/mage/target/common/TargetTriggeredAbility.java +++ b/Mage/src/main/java/mage/target/common/TargetTriggeredAbility.java @@ -44,7 +44,7 @@ public class TargetTriggeredAbility extends TargetObject { } @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + public boolean canChoose(UUID sourceControllerId, Ability source, Game game) { return canChoose(sourceControllerId, game); } @@ -60,7 +60,7 @@ public class TargetTriggeredAbility extends TargetObject { } @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { return possibleTargets(sourceControllerId, game); } diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 6d5236433f0..4511e4b5281 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -718,7 +718,7 @@ public final class CardUtil { public static String createObjectRealtedWindowTitle(Ability source, Game game, String textSuffix) { String title; if (source != null) { - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = game.getObject(source); if (sourceObject != null) { title = sourceObject.getIdName() + " [" + source.getSourceObjectZoneChangeCounter() + "]" @@ -988,7 +988,7 @@ public final class CardUtil { .stream() .map(Mode::getTargets) .flatMap(Collection::stream) - .map(t -> t.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) + .map(t -> t.possibleTargets(ability.getControllerId(), ability, game)) .flatMap(Collection::stream) .collect(Collectors.toSet()); } @@ -1211,7 +1211,7 @@ public final class CardUtil { void addCard(Card card, Ability source, Game game); } - private static List getCastableComponents(Card cardToCast, FilterCard filter, UUID sourceId, UUID playerId, Game game, SpellCastTracker spellCastTracker) { + private static List getCastableComponents(Card cardToCast, FilterCard filter, Ability source, UUID playerId, Game game, SpellCastTracker spellCastTracker) { List cards = new ArrayList<>(); if (cardToCast instanceof CardWithHalves) { cards.add(((CardWithHalves) cardToCast).getLeftHalfCard()); @@ -1223,7 +1223,7 @@ public final class CardUtil { cards.add(cardToCast); } cards.removeIf(Objects::isNull); - cards.removeIf(card -> !filter.match(card, sourceId, playerId, game)); + cards.removeIf(card -> !filter.match(card, playerId, source, game)); if (spellCastTracker != null) { cards.removeIf(card -> spellCastTracker.checkCard(card, game)); } @@ -1243,7 +1243,7 @@ public final class CardUtil { public static boolean castSpellWithAttributesForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter, SpellCastTracker spellCastTracker) { Map> cardMap = new HashMap<>(); for (Card card : cards.getCards(game)) { - List castableComponents = getCastableComponents(card, filter, source.getSourceId(), player.getId(), game, spellCastTracker); + List castableComponents = getCastableComponents(card, filter, source, player.getId(), game, spellCastTracker); if (!castableComponents.isEmpty()) { cardMap.put(card.getId(), castableComponents); } @@ -1292,11 +1292,11 @@ public final class CardUtil { return result; } - private static boolean checkForPlayable(Cards cards, FilterCard filter, UUID sourceId, UUID playerId, Game game, SpellCastTracker spellCastTracker) { + private static boolean checkForPlayable(Cards cards, FilterCard filter, Ability source, UUID playerId, Game game, SpellCastTracker spellCastTracker) { return cards .getCards(game) .stream() - .anyMatch(card -> !getCastableComponents(card, filter, sourceId, playerId, game, spellCastTracker).isEmpty()); + .anyMatch(card -> !getCastableComponents(card, filter, source, playerId, game, spellCastTracker).isEmpty()); } public static void castMultipleWithAttributeForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter) { @@ -1319,7 +1319,7 @@ public final class CardUtil { spellsCast++; cards.removeZone(Zone.STACK, game); } else if (!checkForPlayable( - cards, filter, source.getSourceId(), player.getId(), game, spellCastTracker + cards, filter, source, player.getId(), game, spellCastTracker ) || !player.chooseUse( Outcome.PlayForFree, "Continue casting spells?", source, game )) { diff --git a/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java b/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java new file mode 100644 index 00000000000..66e0abd5551 --- /dev/null +++ b/Mage/src/main/java/mage/watchers/common/BlockingOrBlockedWatcher.java @@ -0,0 +1,56 @@ +package mage.watchers.common; + +import mage.MageObjectReference; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; + +import java.util.*; + +/** + * @author TheElk801 + */ +public class BlockingOrBlockedWatcher extends Watcher { + + private final Map> blockerMap = new HashMap<>(); + + public BlockingOrBlockedWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + switch (event.getType()) { + case BLOCKER_DECLARED: + blockerMap + .computeIfAbsent(new MageObjectReference(event.getTargetId(), game), x -> new HashSet<>()) + .add(new MageObjectReference(event.getSourceId(), game)); + return; + case END_COMBAT_STEP_POST: + blockerMap.clear(); + return; + case REMOVED_FROM_COMBAT: + blockerMap + .values() + .stream() + .forEach(set -> set.removeIf(mor -> mor.refersTo(event.getTargetId(), game))); + } + } + + @Override + public void reset() { + super.reset(); + blockerMap.clear(); + } + + public static boolean check(Permanent attacker, Permanent blocker, Game game) { + return game.getState() + .getWatcher(BlockingOrBlockedWatcher.class) + .blockerMap + .getOrDefault(new MageObjectReference(attacker, game), Collections.emptySet()) + .stream() + .anyMatch(mor -> mor.refersTo(blocker, game)); + } +}