Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/s/Sheoldred.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Sheoldred(UUID ownerId, CardSetInfo setInfo) {
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));
}
);

Expand Down
11 changes: 6 additions & 5 deletions Mage/src/main/java/mage/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,26 @@ 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) {
return getOpponents(playerId, false);
}

/**
* 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needs for ForEachPlayerTargetsAdjuster, cause it used all the time (false excludeLeavedPlayers for some rare effects only, not targets setup).


/**
* Duplicates the permanent target for each player (or opponent).
Expand All @@ -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
Expand All @@ -45,9 +51,9 @@ public void adjustTargets(Ability ability, Game game) {
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);
Expand Down