mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +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.util.*;
|
||||
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) {
|
||||
List<Permanent> threats = (playerId == null || sourceId ==null) ?
|
||||
game.getBattlefield().getActivePermanents(filter, this.getId(), sourceId, game) : // all permanents within the range of the player
|
||||
game.getBattlefield().getActivePermanents(filter, playerId, sourceId, game);
|
||||
|
||||
List<Permanent> threats;
|
||||
if (playerId == null) {
|
||||
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();
|
||||
while (it.hasNext()) { // remove permanents already targeted
|
||||
Permanent test = it.next();
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.mage.test.serverside.base.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
|
||||
public void testSacrifice() {
|
||||
|
|
|
@ -52,7 +52,11 @@ public class SacrificeEffect extends OneShotEffect{
|
|||
private String preText;
|
||||
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);
|
||||
this.filter = filter;
|
||||
this.count = count;
|
||||
|
@ -60,11 +64,7 @@ public class SacrificeEffect extends OneShotEffect{
|
|||
setText();
|
||||
}
|
||||
|
||||
public SacrificeEffect ( FilterPermanent filter, int count, String preText ) {
|
||||
this(filter, new StaticValue(count), preText);
|
||||
}
|
||||
|
||||
public SacrificeEffect ( final SacrificeEffect effect ) {
|
||||
public SacrificeEffect (final SacrificeEffect effect ) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.count = effect.count;
|
||||
|
|
Loading…
Reference in a new issue