refactor: improved EachOpponentPermanentTargetsAdjuster and few card fixes (#12102)

* Wreck and Rebuild: Return a land, not a creature
* Sinister Concierge should still gain suspend with 0 targets
* Fixed Tolarian Contempt
This commit is contained in:
ssk97 2024-04-09 19:59:21 -07:00 committed by GitHub
parent fd0da67e46
commit 124d60e2b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 65 additions and 38 deletions

View file

@ -11,25 +11,23 @@ import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author notgreat
*/
public class EachOpponentPermanentTargetsAdjuster implements TargetAdjuster {
private final TargetPermanent blueprintTarget;
private TargetPermanent blueprintTarget = null;
/**
* Duplicates the permanent target for each opponent.
* Filtering of permanent's controllers will be handled inside, so
* do not pass a blueprint target with a controller restriction filter/predicate.
*
* @param blueprintTarget The target to be duplicated per opponent
*/
public EachOpponentPermanentTargetsAdjuster(TargetPermanent blueprintTarget) {
this.blueprintTarget = blueprintTarget.copy(); //Defensively copy the blueprint to ensure immutability
public EachOpponentPermanentTargetsAdjuster() {
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (blueprintTarget == null) {
blueprintTarget = (TargetPermanent) ability.getTargets().get(0).copy();
}
ability.getTargets().clear();
for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
@ -40,7 +38,7 @@ public class EachOpponentPermanentTargetsAdjuster implements TargetAdjuster {
Filter<Permanent> filter = newTarget.getFilter();
filter.add(new ControllerIdPredicate(opponentId));
if (newTarget.canChoose(ability.getControllerId(), ability, game)) {
filter.setMessage(filter.getMessage()+" controlled by " + opponent.getLogName());
filter.setMessage(filter.getMessage() + " controlled by " + opponent.getLogName());
ability.addTarget(newTarget);
}
}