This commit is contained in:
PurpleCrowbar 2026-01-26 14:03:57 -06:00 committed by GitHub
commit cba0789dad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 9 deletions

View file

@ -76,7 +76,7 @@ public final class Sheoldred extends TransformingDoubleFacedCard {
ability.addEffect(new DestroyTargetEffect().setTargetPointer(new EachTargetPointer())
.setText("for each opponent, destroy up to one target creature or planeswalker that player controls"));
ability.addTarget(new TargetCreatureOrPlaneswalker(0, 1));
ability.setTargetAdjuster(new ForEachPlayerTargetsAdjuster(false, true));
ability.setTargetAdjuster(new ForEachPlayerTargetsAdjuster(false, true, true));
}
);

View file

@ -170,16 +170,16 @@ public interface Game extends MageItem, Serializable, Copyable<Game> {
Players getPlayers();
/**
* Static players list from start of the game. Use it to interate by starting turn order.
* Static players list from start of the game. Use it to iterate by starting turn order.
* WARNING, it's ignore range and leaved players, so use it by game engine only
*/
// TODO: check usage of getPlayerList in cards and replace by game.getState().getPlayersInRange
PlayerList getPlayerList();
/**
* Returns opponents list in range for the given playerId. Use it to interate by starting turn order.
* Returns set of opponents in range for the given playerId in turn order from start of game.
* <p>
* Warning, it will return leaved players until end of turn. For dialogs and one shot effects use excludeLeavedPlayers
* <b>Warning</b>: Includes players who left the game on the current turn. For dialogs and one shot effects usually use excludeLeavedPlayers
*/
// TODO: check usage of getOpponents in cards and replace with correct call of excludeLeavedPlayers, see #13289
default Set<UUID> getOpponents(UUID playerId) {
@ -187,8 +187,9 @@ public interface Game extends MageItem, Serializable, Copyable<Game> {
}
/**
* Returns opponents list in range for the given playerId. Use it to interate by starting turn order.
* Warning, it will return dead players until end of turn.
* Returns set of opponents in range for the given playerId in turn order from start of game.
* <p>
* <b>Warning</b>: Includes players who left the game on the current turn unless excludeLeavedPlayers is true.
*
* @param excludeLeavedPlayers exclude dead player immediately without waiting range update on next turn
*/

View file

@ -18,7 +18,8 @@ import java.util.stream.Stream;
*/
public class ForEachPlayerTargetsAdjuster extends GenericTargetAdjuster {
private final boolean owner;
private final boolean onlyOpponents; //Makes this a "For Each Opponent" adjuster
private final boolean onlyOpponents; // Makes this a "For Each Opponent" adjuster
private final boolean excludeLeavedPlayers;
/**
* Duplicates the permanent target for each player (or opponent).
@ -27,8 +28,13 @@ public class ForEachPlayerTargetsAdjuster extends GenericTargetAdjuster {
*/
public ForEachPlayerTargetsAdjuster(boolean owner, boolean onlyOpponents) {
this(owner, onlyOpponents, false);
}
public ForEachPlayerTargetsAdjuster(boolean owner, boolean onlyOpponents, boolean excludeLeavedPlayers) {
this.owner = owner;
this.onlyOpponents = onlyOpponents;
this.excludeLeavedPlayers = excludeLeavedPlayers;
}
@Override
@ -45,9 +51,9 @@ public class ForEachPlayerTargetsAdjuster extends GenericTargetAdjuster {
ability.getTargets().clear();
Stream<UUID> ids;
if (onlyOpponents) {
ids = game.getOpponents(ability.getControllerId()).stream();
ids = game.getOpponents(ability.getControllerId(), excludeLeavedPlayers).stream();
} else {
ids = game.getState().getPlayersInRange(ability.getControllerId(), game).stream();
ids = game.getState().getPlayersInRange(ability.getControllerId(), game, excludeLeavedPlayers).stream();
}
ids.forEach( id -> {
Player opponent = game.getPlayer(id);