mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Merge 0b657271b5 into 162edb9351
This commit is contained in:
commit
cba0789dad
3 changed files with 16 additions and 9 deletions
|
|
@ -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));
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue