mirror of
https://github.com/correl/mage.git
synced 2025-04-10 17:00:08 -09:00
Refactor: added missing getPlayersInRange in cards code (to ignore leaved/lost players);
This commit is contained in:
parent
04cceb9b62
commit
61a58d36c2
15 changed files with 75 additions and 110 deletions
Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai
Mage.Sets/src/mage/cards
d
e
p
s
t
Mage.Tests/src/test/java/org/mage/test
Mage/src/main/java/mage
abilities/common
game
players
|
@ -227,7 +227,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
||||||
}
|
}
|
||||||
val = minimaxAB(node, depth - 1, alpha, beta);
|
val = minimaxAB(node, depth - 1, alpha, beta);
|
||||||
} else {
|
} else {
|
||||||
logger.trace("Add Action -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(game.getPlayerList().get()).getName());
|
logger.trace("Add Action -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(game.getActivePlayerId()).getName());
|
||||||
if (allPassed(game)) {
|
if (allPassed(game)) {
|
||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
resolve(node, depth, game);
|
resolve(node, depth, game);
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -24,13 +19,17 @@ import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.players.PlayerList;
|
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.TargetCard;
|
import mage.target.TargetCard;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 5/1/2012 For each despair counter on Descent into Madness, you'll exile a permanent
|
* 5/1/2012 For each despair counter on Descent into Madness, you'll exile a permanent
|
||||||
* you control or exile a card from your hand, not both.
|
* you control or exile a card from your hand, not both.
|
||||||
* 5/1/2012 First you choose the permanents and/or cards from your hand that will be
|
* 5/1/2012 First you choose the permanents and/or cards from your hand that will be
|
||||||
* exiled. Then each other player in turn order does the same. Then all the chosen permanents
|
* exiled. Then each other player in turn order does the same. Then all the chosen permanents
|
||||||
|
@ -43,13 +42,13 @@ import mage.target.common.TargetControlledPermanent;
|
||||||
* 5/1/2012 If Descent into Madness isn't on the battlefield when its ability resolves,
|
* 5/1/2012 If Descent into Madness isn't on the battlefield when its ability resolves,
|
||||||
* use the number of counters on it when it left the battlefield to determine how many permanents
|
* use the number of counters on it when it left the battlefield to determine how many permanents
|
||||||
* and/or cards from hands to exile.
|
* and/or cards from hands to exile.
|
||||||
*
|
*
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public final class DescentIntoMadness extends CardImpl {
|
public final class DescentIntoMadness extends CardImpl {
|
||||||
|
|
||||||
public DescentIntoMadness(UUID ownerId, CardSetInfo setInfo) {
|
public DescentIntoMadness(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{B}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}");
|
||||||
|
|
||||||
|
|
||||||
// At the beginning of your upkeep, put a despair counter on Descent into Madness, then each player exiles X permanents they control and/or cards from their hand, where X is the number of despair counters on Descent into Madness.
|
// At the beginning of your upkeep, put a despair counter on Descent into Madness, then each player exiles X permanents they control and/or cards from their hand, where X is the number of despair counters on Descent into Madness.
|
||||||
|
@ -83,7 +82,7 @@ class DescentIntoMadnessEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
if (sourcePermanent != null && controller != null) {
|
if (sourcePermanent != null && controller != null) {
|
||||||
|
@ -92,18 +91,20 @@ class DescentIntoMadnessEffect extends OneShotEffect {
|
||||||
if (sourcePermanent == null) {
|
if (sourcePermanent == null) {
|
||||||
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||||
}
|
}
|
||||||
if (sourcePermanent != null && controller != null) {
|
if (sourcePermanent != null && controller != null) {
|
||||||
int count = sourcePermanent.getCounters(game).getCount(CounterType.DESPAIR);
|
int count = sourcePermanent.getCounters(game).getCount(CounterType.DESPAIR);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
// select the permanents and hand cards in turn order
|
// select the permanents and hand cards in turn order
|
||||||
LinkedList<UUID> selectedObjects = new LinkedList<>();
|
LinkedList<UUID> selectedObjects = new LinkedList<>();
|
||||||
PlayerList playerList = game.getState().getPlayerList(controller.getId());
|
|
||||||
Player currentPlayer = controller;
|
// ask all players
|
||||||
do {
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
selectCards(currentPlayer, selectedObjects, count, source, game);
|
Player currentPlayer = game.getPlayer(playerId);
|
||||||
currentPlayer = playerList.getNextInRange(controller, game);
|
if (currentPlayer != null && currentPlayer.canRespond()) {
|
||||||
} while (!currentPlayer.equals(controller) && controller.canRespond());
|
selectCards(currentPlayer, selectedObjects, count, source, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// move permanents and hand cards to exile
|
// move permanents and hand cards to exile
|
||||||
for (UUID objectId : selectedObjects) {
|
for (UUID objectId : selectedObjects) {
|
||||||
if (game.getState().getZone(objectId) == Zone.BATTLEFIELD) {
|
if (game.getState().getZone(objectId) == Zone.BATTLEFIELD) {
|
||||||
|
@ -121,10 +122,10 @@ class DescentIntoMadnessEffect extends OneShotEffect {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
|
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -134,22 +135,22 @@ class DescentIntoMadnessEffect extends OneShotEffect {
|
||||||
private void selectCards(Player player, List<UUID> selectedObjects, int count, Ability source, Game game) {
|
private void selectCards(Player player, List<UUID> selectedObjects, int count, Ability source, Game game) {
|
||||||
int amount = Math.min(count, player.getHand().size() + game.getBattlefield().getAllActivePermanents(player.getId()).size());
|
int amount = Math.min(count, player.getHand().size() + game.getBattlefield().getAllActivePermanents(player.getId()).size());
|
||||||
int cardsFromHand = 0;
|
int cardsFromHand = 0;
|
||||||
|
|
||||||
while (player.canRespond() && amount > 0) {
|
while (player.canRespond() && amount > 0) {
|
||||||
|
|
||||||
Target target;
|
Target target;
|
||||||
do {
|
do {
|
||||||
FilterControlledPermanent filter = new FilterControlledPermanent();
|
FilterControlledPermanent filter = new FilterControlledPermanent();
|
||||||
filter.setMessage("permanent you control (" + amount + " left in total)" );
|
filter.setMessage("permanent you control (" + amount + " left in total)");
|
||||||
List<PermanentIdPredicate> uuidPredicates = new ArrayList<>();
|
List<PermanentIdPredicate> uuidPredicates = new ArrayList<>();
|
||||||
for (UUID uuid :selectedObjects) {
|
for (UUID uuid : selectedObjects) {
|
||||||
uuidPredicates.add(new PermanentIdPredicate(uuid));
|
uuidPredicates.add(new PermanentIdPredicate(uuid));
|
||||||
}
|
}
|
||||||
filter.add(Predicates.not(Predicates.or(uuidPredicates)));
|
filter.add(Predicates.not(Predicates.or(uuidPredicates)));
|
||||||
|
|
||||||
target = new TargetControlledPermanent(0, 1, filter, true);
|
target = new TargetControlledPermanent(0, 1, filter, true);
|
||||||
if (target.canChoose(player.getId(), game)
|
if (target.canChoose(player.getId(), game)
|
||||||
&& player.choose(Outcome.Exile, target, source.getSourceId(), game)) {
|
&& player.choose(Outcome.Exile, target, source.getSourceId(), game)) {
|
||||||
for (UUID targetId : target.getTargets()) {
|
for (UUID targetId : target.getTargets()) {
|
||||||
if (!selectedObjects.contains(targetId)) {
|
if (!selectedObjects.contains(targetId)) {
|
||||||
Permanent chosen = game.getPermanent(targetId);
|
Permanent chosen = game.getPermanent(targetId);
|
||||||
|
@ -162,17 +163,17 @@ class DescentIntoMadnessEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (amount > 0 && !target.getTargets().isEmpty() && player.canRespond());
|
} while (amount > 0 && !target.getTargets().isEmpty() && player.canRespond());
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
TargetCard targetInHand;
|
TargetCard targetInHand;
|
||||||
do {
|
do {
|
||||||
FilterCard filterInHand = new FilterCard();
|
FilterCard filterInHand = new FilterCard();
|
||||||
filterInHand.setMessage("card from your hand (" + amount + " left in total)");
|
filterInHand.setMessage("card from your hand (" + amount + " left in total)");
|
||||||
targetInHand = new TargetCard(0, 1, Zone.HAND, filterInHand);
|
targetInHand = new TargetCard(0, 1, Zone.HAND, filterInHand);
|
||||||
List<CardIdPredicate> uuidPredicates = new ArrayList<>();
|
List<CardIdPredicate> uuidPredicates = new ArrayList<>();
|
||||||
for (UUID uuid :selectedObjects) {
|
for (UUID uuid : selectedObjects) {
|
||||||
uuidPredicates.add(new CardIdPredicate(uuid));
|
uuidPredicates.add(new CardIdPredicate(uuid));
|
||||||
}
|
}
|
||||||
filterInHand.add(Predicates.not(Predicates.or(uuidPredicates)));
|
filterInHand.add(Predicates.not(Predicates.or(uuidPredicates)));
|
||||||
if (targetInHand.canChoose(player.getId(), game) &&
|
if (targetInHand.canChoose(player.getId(), game) &&
|
||||||
player.choose(Outcome.Exile, player.getHand(), targetInHand, game)) {
|
player.choose(Outcome.Exile, player.getHand(), targetInHand, game)) {
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ class DescentIntoMadnessEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cardsFromHand > 0) {
|
if (cardsFromHand > 0) {
|
||||||
game.informPlayers(player.getLogName() + " selects " + cardsFromHand + (cardsFromHand == 1?" card":" cards") + " from their hand");
|
game.informPlayers(player.getLogName() + " selects " + cardsFromHand + (cardsFromHand == 1 ? " card" : " cards") + " from their hand");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class EnsnaringBridgeRestrictionEffect extends RestrictionEffect {
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return controller.getInRange().contains(permanent.getControllerId())
|
return game.getState().getPlayersInRange(controller.getId(), game).contains(permanent.getControllerId())
|
||||||
&& permanent.getPower().getValue() > controller.getHand().size();
|
&& permanent.getPower().getValue() > controller.getHand().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class PeaceTalksPlayersAndPermanentsCantBeTargetsOfSpellsOrActivatedAbilities ex
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
for (UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) {
|
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||||
if (event.getTargetId().equals(playerId)) {
|
if (event.getTargetId().equals(playerId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -17,8 +15,9 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author cbt33, Loki (Heartbeat of Spring)
|
* @author cbt33, Loki (Heartbeat of Spring)
|
||||||
*/
|
*/
|
||||||
public final class PriceOfGlory extends CardImpl {
|
public final class PriceOfGlory extends CardImpl {
|
||||||
|
@ -63,12 +62,8 @@ class PriceOfGloryAbility extends TriggeredAbilityImpl {
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(controllerId);
|
|
||||||
if (player == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (permanent.isLand()
|
if (permanent.isLand()
|
||||||
&& player.getInRange().contains(permanent.getControllerId())
|
&& game.getState().getPlayersInRange(controllerId, game).contains(permanent.getControllerId())
|
||||||
&& !permanent.isControlledBy(game.getActivePlayerId())) { // intervening if clause
|
&& !permanent.isControlledBy(game.getActivePlayerId())) { // intervening if clause
|
||||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -13,15 +11,15 @@ import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
*/
|
*/
|
||||||
public final class SyphonMind extends CardImpl {
|
public final class SyphonMind extends CardImpl {
|
||||||
|
|
||||||
public SyphonMind(UUID ownerId, CardSetInfo setInfo) {
|
public SyphonMind(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}");
|
||||||
|
|
||||||
|
|
||||||
// Each other player discards a card. You draw a card for each card discarded this way.
|
// Each other player discards a card. You draw a card for each card discarded this way.
|
||||||
this.getSpellAbility().addEffect(new SyphonMindEffect());
|
this.getSpellAbility().addEffect(new SyphonMindEffect());
|
||||||
|
@ -60,8 +58,8 @@ class SyphonMindEffect extends OneShotEffect {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
Player you = game.getPlayer(source.getControllerId());
|
Player you = game.getPlayer(source.getControllerId());
|
||||||
if (you != null) {
|
if (you != null) {
|
||||||
for (UUID playerId : you.getInRange()) {
|
for (UUID playerId : game.getState().getPlayersInRange(you.getId(), game)) {
|
||||||
if (!playerId.equals(source.getControllerId())) {
|
if (!playerId.equals(you.getId())) {
|
||||||
Player otherPlayer = game.getPlayer(playerId);
|
Player otherPlayer = game.getPlayer(playerId);
|
||||||
if (otherPlayer != null && !otherPlayer.getHand().isEmpty()) {
|
if (otherPlayer != null && !otherPlayer.getHand().isEmpty()) {
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand();
|
||||||
|
@ -77,7 +75,7 @@ class SyphonMindEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
you.drawCards(amount, game);
|
you.drawCards(amount, game);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
|
@ -29,8 +24,12 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author L_J
|
* @author L_J
|
||||||
*/
|
*/
|
||||||
public final class TidalFlats extends CardImpl {
|
public final class TidalFlats extends CardImpl {
|
||||||
|
@ -76,7 +75,6 @@ class TidalFlatsEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
game.getPlayerList();
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2203,11 +2203,6 @@ public class TestPlayer implements Player {
|
||||||
return computerPlayer.getCounters();
|
return computerPlayer.getCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void otherPlayerLeftGame(Game game) {
|
|
||||||
computerPlayer.otherPlayerLeftGame(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginTurn(Game game) {
|
public void beginTurn(Game game) {
|
||||||
checkLegalMovesThisTurn(game);
|
checkLegalMovesThisTurn(game);
|
||||||
|
|
|
@ -403,11 +403,6 @@ public class PlayerStub implements Player {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void otherPlayerLeftGame(Game game) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManaPool getManaPool() {
|
public ManaPool getManaPool() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -10,11 +10,9 @@ import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Jeff
|
* @author Jeff
|
||||||
*/
|
*/
|
||||||
public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
@ -59,8 +57,8 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
return yours;
|
return yours;
|
||||||
case NOT_YOU:
|
case NOT_YOU:
|
||||||
Player controller = game.getPlayer(this.getControllerId());
|
if (game.getState().getPlayersInRange(this.getControllerId(), game).contains(event.getPlayerId())
|
||||||
if (controller != null && controller.getInRange().contains(event.getPlayerId()) && !event.getPlayerId().equals(this.getControllerId())) {
|
&& !event.getPlayerId().equals(this.getControllerId())) {
|
||||||
if (getTargets().isEmpty()) {
|
if (getTargets().isEmpty()) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
@ -80,8 +78,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ANY:
|
case ANY:
|
||||||
controller = game.getPlayer(this.getControllerId());
|
if (game.getState().getPlayersInRange(this.getControllerId(), game).contains(event.getPlayerId())) {
|
||||||
if (controller != null && controller.getInRange().contains(event.getPlayerId())) {
|
|
||||||
if (getTargets().isEmpty()) {
|
if (getTargets().isEmpty()) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
@ -89,6 +86,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import mage.MageItem;
|
import mage.MageItem;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -44,6 +41,10 @@ import mage.players.Players;
|
||||||
import mage.util.MessageToClient;
|
import mage.util.MessageToClient;
|
||||||
import mage.util.functions.ApplyToPermanent;
|
import mage.util.functions.ApplyToPermanent;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public interface Game extends MageItem, Serializable {
|
public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
MatchType getGameType();
|
MatchType getGameType();
|
||||||
|
@ -127,7 +128,6 @@ public interface Game extends MageItem, Serializable {
|
||||||
return player.getInRange().stream()
|
return player.getInRange().stream()
|
||||||
.filter(opponentId -> !opponentId.equals(playerId))
|
.filter(opponentId -> !opponentId.equals(playerId))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean isActivePlayer(UUID playerId) {
|
default boolean isActivePlayer(UUID playerId) {
|
||||||
|
@ -298,9 +298,9 @@ public interface Game extends MageItem, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates and fires an damage prevention event
|
* Creates and fires an damage prevention event
|
||||||
*
|
*
|
||||||
* @param damageEvent damage event that will be replaced (instanceof check
|
* @param damageEvent damage event that will be replaced (instanceof check
|
||||||
* will be done)
|
* will be done)
|
||||||
* @param source ability that's the source of the prevention effect
|
* @param source ability that's the source of the prevention effect
|
||||||
* @param game
|
* @param game
|
||||||
* @param amountToPrevent max preventable amount
|
* @param amountToPrevent max preventable amount
|
||||||
* @return true prevention was successfull / false prevention was replaced
|
* @return true prevention was successfull / false prevention was replaced
|
||||||
|
@ -310,12 +310,12 @@ public interface Game extends MageItem, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates and fires an damage prevention event
|
* Creates and fires an damage prevention event
|
||||||
*
|
*
|
||||||
* @param event damage event that will be replaced (instanceof check will be
|
* @param event damage event that will be replaced (instanceof check will be
|
||||||
* done)
|
* done)
|
||||||
* @param source ability that's the source of the prevention effect
|
* @param source ability that's the source of the prevention effect
|
||||||
* @param game
|
* @param game
|
||||||
* @param preventAllDamage true if there is no limit to the damage that can
|
* @param preventAllDamage true if there is no limit to the damage that can
|
||||||
* be prevented
|
* be prevented
|
||||||
* @return true prevention was successfull / false prevention was replaced
|
* @return true prevention was successfull / false prevention was replaced
|
||||||
*/
|
*/
|
||||||
PreventionEffectData preventDamage(GameEvent event, Ability source, Game game, boolean preventAllDamage);
|
PreventionEffectData preventDamage(GameEvent event, Ability source, Game game, boolean preventAllDamage);
|
||||||
|
|
|
@ -635,6 +635,9 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
* Returns a list of all active players of the game in range of playerId,
|
* Returns a list of all active players of the game in range of playerId,
|
||||||
* also setting the playerId to the first/current player of the list. Also
|
* also setting the playerId to the first/current player of the list. Also
|
||||||
* returning the other players in turn order.
|
* returning the other players in turn order.
|
||||||
|
* <p>
|
||||||
|
* Not safe for continuous effects, see rule 800.4k (effects must work until end of turn even after player leaves)
|
||||||
|
* Use Player.InRange() to find active players list at the start of the turn
|
||||||
*
|
*
|
||||||
* @param playerId
|
* @param playerId
|
||||||
* @param game
|
* @param game
|
||||||
|
@ -645,7 +648,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
Player currentPlayer = game.getPlayer(playerId);
|
Player currentPlayer = game.getPlayer(playerId);
|
||||||
if (currentPlayer != null) {
|
if (currentPlayer != null) {
|
||||||
for (Player player : players.values()) {
|
for (Player player : players.values()) {
|
||||||
if (!player.hasLeft() && !player.hasLost() && currentPlayer.getInRange().contains(player.getId())) {
|
if (player.isInGame() && currentPlayer.getInRange().contains(player.getId())) {
|
||||||
newPlayerList.add(player.getId());
|
newPlayerList.add(player.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.game.permanent;
|
package mage.game.permanent;
|
||||||
|
|
||||||
import mage.abilities.keyword.PhasingAbility;
|
import mage.abilities.keyword.PhasingAbility;
|
||||||
|
@ -6,7 +5,6 @@ import mage.constants.CardType;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -85,8 +83,8 @@ public class Battlefield implements Serializable {
|
||||||
&& permanent.isPhasedIn())
|
&& permanent.isPhasedIn())
|
||||||
.count();
|
.count();
|
||||||
} else {
|
} else {
|
||||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
List<UUID> range = game.getState().getPlayersInRange(sourcePlayerId, game);
|
||||||
return (int) field.values()
|
return (int) field.values()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(permanent -> range.contains(permanent.getControllerId())
|
.filter(permanent -> range.contains(permanent.getControllerId())
|
||||||
&& filter.match(permanent, sourceId, sourcePlayerId, game)
|
&& filter.match(permanent, sourceId, sourcePlayerId, game)
|
||||||
|
@ -150,7 +148,7 @@ public class Battlefield implements Serializable {
|
||||||
&& permanent.isPhasedIn()).count() >= num;
|
&& permanent.isPhasedIn()).count() >= num;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
List<UUID> range = game.getState().getPlayersInRange(sourcePlayerId, game);
|
||||||
return field.values().stream()
|
return field.values().stream()
|
||||||
.filter(permanent -> range.contains(permanent.getControllerId())
|
.filter(permanent -> range.contains(permanent.getControllerId())
|
||||||
&& filter.match(permanent, null, sourcePlayerId, game)
|
&& filter.match(permanent, null, sourcePlayerId, game)
|
||||||
|
@ -298,12 +296,8 @@ public class Battlefield implements Serializable {
|
||||||
.filter(perm -> perm.isPhasedIn() && filter.match(perm, sourceId, sourcePlayerId, game))
|
.filter(perm -> perm.isPhasedIn() && filter.match(perm, sourceId, sourcePlayerId, game))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
Player player = game.getPlayer(sourcePlayerId);
|
List<UUID> range = game.getState().getPlayersInRange(sourcePlayerId, game);
|
||||||
if(player == null){
|
return field.values()
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
Set<UUID> range = player.getInRange();
|
|
||||||
return field.values()
|
|
||||||
.stream()
|
.stream()
|
||||||
.filter(perm -> perm.isPhasedIn() && range.contains(perm.getControllerId())
|
.filter(perm -> perm.isPhasedIn() && range.contains(perm.getControllerId())
|
||||||
&& filter.match(perm, sourceId, sourcePlayerId, game)).collect(Collectors.toList());
|
&& filter.match(perm, sourceId, sourcePlayerId, game)).collect(Collectors.toList());
|
||||||
|
@ -323,7 +317,7 @@ public class Battlefield implements Serializable {
|
||||||
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
||||||
return getAllActivePermanents();
|
return getAllActivePermanents();
|
||||||
} else {
|
} else {
|
||||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
List<UUID> range = game.getState().getPlayersInRange(sourcePlayerId, game);
|
||||||
return field.values()
|
return field.values()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(perm -> perm.isPhasedIn()
|
.filter(perm -> perm.isPhasedIn()
|
||||||
|
|
|
@ -211,13 +211,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
*/
|
*/
|
||||||
boolean canRespond();
|
boolean canRespond();
|
||||||
|
|
||||||
/**
|
|
||||||
* Called if other player left the game
|
|
||||||
*
|
|
||||||
* @param game
|
|
||||||
*/
|
|
||||||
void otherPlayerLeftGame(Game game);
|
|
||||||
|
|
||||||
ManaPool getManaPool();
|
ManaPool getManaPool();
|
||||||
|
|
||||||
Set<UUID> getInRange();
|
Set<UUID> getInRange();
|
||||||
|
|
|
@ -457,11 +457,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return counters;
|
return counters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void otherPlayerLeftGame(Game game) {
|
|
||||||
findRange(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginTurn(Game game) {
|
public void beginTurn(Game game) {
|
||||||
this.landsPlayed = 0;
|
this.landsPlayed = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue