mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
a few changes to help with tests
This commit is contained in:
parent
dc2d8145fd
commit
e51b63aea8
2 changed files with 10 additions and 20 deletions
|
@ -913,7 +913,7 @@ public class TestPlayer implements Player {
|
|||
if (target.getTargetController() != null && target.getAbilityController() != null) {
|
||||
abilityControllerId = target.getAbilityController();
|
||||
}
|
||||
if (target instanceof TargetPlayer || target instanceof TargetAnyTarget) {
|
||||
if (target instanceof TargetPlayer || target instanceof TargetAnyTarget || target instanceof TargetCreatureOrPlayer) {
|
||||
for (String targetDefinition : targets) {
|
||||
if (targetDefinition.startsWith("targetPlayer=")) {
|
||||
String playerName = targetDefinition.substring(targetDefinition.indexOf("targetPlayer=") + 13);
|
||||
|
@ -929,7 +929,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
|
||||
}
|
||||
if ((target instanceof TargetPermanent) || (target instanceof TargetPermanentOrPlayer) || (target instanceof TargetAnyTarget)) {
|
||||
if ((target instanceof TargetPermanent) || (target instanceof TargetPermanentOrPlayer) || (target instanceof TargetAnyTarget) || (target instanceof TargetCreatureOrPlayer)) {
|
||||
for (String targetDefinition : targets) {
|
||||
String[] targetList = targetDefinition.split("\\^");
|
||||
boolean targetFound = false;
|
||||
|
@ -947,7 +947,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
Filter filter = target.getFilter();
|
||||
if (filter instanceof FilterCreatureOrPlayer) {
|
||||
if (filter instanceof FilterCreatureOrPlayer || filter instanceof FilterCreaturePlayerOrPlaneswalker) {
|
||||
filter = ((FilterCreatureOrPlayer) filter).getCreatureFilter();
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents((FilterPermanent) filter, game)) {
|
||||
|
|
|
@ -3,21 +3,18 @@ package mage.filter.common;
|
|||
import java.util.UUID;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.filter.FilterImpl;
|
||||
import mage.filter.FilterInPlay;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author JRHerlehy
|
||||
* Created on 4/8/18.
|
||||
* @author JRHerlehy Created on 4/8/18.
|
||||
*/
|
||||
public class FilterCreaturePlayerOrPlaneswalker extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
|
||||
public class FilterCreaturePlayerOrPlaneswalker extends FilterPermanentOrPlayer {
|
||||
|
||||
protected FilterCreaturePermanent creatureFilter;
|
||||
protected FilterPlaneswalkerPermanent planeswalkerFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterCreaturePlayerOrPlaneswalker() {
|
||||
this("any target");
|
||||
|
@ -26,29 +23,22 @@ public class FilterCreaturePlayerOrPlaneswalker extends FilterImpl<MageItem> imp
|
|||
public FilterCreaturePlayerOrPlaneswalker(String name) {
|
||||
super(name);
|
||||
creatureFilter = new FilterCreaturePermanent();
|
||||
playerFilter = new FilterPlayer();
|
||||
planeswalkerFilter = new FilterPlaneswalkerPermanent();
|
||||
}
|
||||
|
||||
public FilterCreaturePlayerOrPlaneswalker(final FilterCreaturePlayerOrPlaneswalker filter) {
|
||||
super(filter);
|
||||
this.creatureFilter = filter.creatureFilter.copy();
|
||||
this.playerFilter = filter.playerFilter.copy();
|
||||
this.planeswalkerFilter = filter.planeswalkerFilter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObjectClass(Object object) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(MageItem o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player) o, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return creatureFilter.match((Permanent) o, game) ||
|
||||
planeswalkerFilter.match((Permanent) o, game);
|
||||
return creatureFilter.match((Permanent) o, game)
|
||||
|| planeswalkerFilter.match((Permanent) o, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -58,8 +48,8 @@ public class FilterCreaturePlayerOrPlaneswalker extends FilterImpl<MageItem> imp
|
|||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player) o, sourceId, playerId, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return creatureFilter.match((Permanent) o, sourceId, playerId, game) ||
|
||||
planeswalkerFilter.match((Permanent) o, sourceId, playerId, game);
|
||||
return creatureFilter.match((Permanent) o, sourceId, playerId, game)
|
||||
|| planeswalkerFilter.match((Permanent) o, sourceId, playerId, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue