mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Fixed a bug of AI target selection that caused endless loops during build of test project.
This commit is contained in:
parent
96f08cad9c
commit
80d3e6bd9a
3 changed files with 18 additions and 12 deletions
|
@ -75,6 +75,8 @@ import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import mage.filter.Filter;
|
||||||
|
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1947,10 +1949,14 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Permanent> threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List<UUID> targets) {
|
protected List<Permanent> threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List<UUID> targets) {
|
||||||
List<Permanent> threats = (playerId == null || sourceId ==null) ?
|
List<Permanent> threats;
|
||||||
game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game) : // all permanents within the range of the player
|
if (playerId == null) {
|
||||||
game.getBattlefield().getActivePermanents(filter, playerId, sourceId, game);
|
threats = game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game); // all permanents within the range of the player
|
||||||
|
} else {
|
||||||
|
FilterPermanent filterCopy = filter.copy();
|
||||||
|
filterCopy.add(new PlayerIdPredicate(playerId));
|
||||||
|
threats = game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game);
|
||||||
|
}
|
||||||
Iterator<Permanent> it = threats.iterator();
|
Iterator<Permanent> it = threats.iterator();
|
||||||
while (it.hasNext()) { // remove permanents already targeted
|
while (it.hasNext()) { // remove permanents already targeted
|
||||||
Permanent test = it.next();
|
Permanent test = it.next();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
public class MorticianBeetleTest extends CardTestPlayerBase {
|
public class MorticianBeetleTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that pro black can still be sacrificed
|
* Checks that creature with protection black can still be sacrificed
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSacrifice() {
|
public void testSacrifice() {
|
||||||
|
|
|
@ -52,19 +52,19 @@ public class SacrificeEffect extends OneShotEffect{
|
||||||
private String preText;
|
private String preText;
|
||||||
private DynamicValue count;
|
private DynamicValue count;
|
||||||
|
|
||||||
public SacrificeEffect ( FilterPermanent filter, DynamicValue count, String preText ) {
|
public SacrificeEffect (FilterPermanent filter, int count, String preText ) {
|
||||||
|
this(filter, new StaticValue(count), preText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SacrificeEffect (FilterPermanent filter, DynamicValue count, String preText ) {
|
||||||
super(Outcome.Sacrifice);
|
super(Outcome.Sacrifice);
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.preText = preText;
|
this.preText = preText;
|
||||||
setText();
|
setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SacrificeEffect ( FilterPermanent filter, int count, String preText ) {
|
public SacrificeEffect (final SacrificeEffect effect ) {
|
||||||
this(filter, new StaticValue(count), preText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SacrificeEffect ( final SacrificeEffect effect ) {
|
|
||||||
super(effect);
|
super(effect);
|
||||||
this.filter = effect.filter;
|
this.filter = effect.filter;
|
||||||
this.count = effect.count;
|
this.count = effect.count;
|
||||||
|
|
Loading…
Reference in a new issue