mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
Tests: added support of TargetCardInExile, TargetCardInGraveyard and variations;
This commit is contained in:
parent
21d7207551
commit
a9451711bb
3 changed files with 84 additions and 19 deletions
|
|
@ -1263,17 +1263,18 @@ public class TestPlayer implements Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// card in exile
|
||||||
if (target instanceof TargetCardInYourGraveyard) {
|
if (target instanceof TargetCardInExile) {
|
||||||
|
TargetCardInExile targetFull = (TargetCardInExile) target;
|
||||||
for (String targetDefinition : targets) {
|
for (String targetDefinition : targets) {
|
||||||
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
||||||
String[] targetList = targetDefinition.split("\\^");
|
String[] targetList = targetDefinition.split("\\^");
|
||||||
boolean targetFound = false;
|
boolean targetFound = false;
|
||||||
for (String targetName : targetList) {
|
for (String targetName : targetList) {
|
||||||
for (Card card : computerPlayer.getGraveyard().getCards(((TargetCardInYourGraveyard) target).getFilter(), game)) {
|
for (Card card : game.getExile().getCards(targetFull.getFilter(), game)) {
|
||||||
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
||||||
if (((TargetCardInYourGraveyard) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
|
if (targetFull.canTarget(abilityControllerId, card.getId(), source, game) && !targetFull.getTargets().contains(card.getId())) {
|
||||||
target.add(card.getId(), game);
|
targetFull.add(card.getId(), game);
|
||||||
targetFound = true;
|
targetFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1285,32 +1286,80 @@ public class TestPlayer implements Player {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (target instanceof TargetCardInOpponentsGraveyard) {
|
|
||||||
|
// card in battlefield
|
||||||
|
if (target instanceof TargetCardInGraveyardOrBattlefield) {
|
||||||
|
TargetCard targetFull = (TargetCard) target;
|
||||||
|
for (String targetDefinition : targets) {
|
||||||
|
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
||||||
|
String[] targetList = targetDefinition.split("\\^");
|
||||||
|
boolean targetFound = false;
|
||||||
|
for (String targetName : targetList) {
|
||||||
|
for (Card card : game.getBattlefield().getAllActivePermanents()) {
|
||||||
|
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
||||||
|
if (targetFull.canTarget(abilityControllerId, card.getId(), source, game) && !targetFull.getTargets().contains(card.getId())) {
|
||||||
|
targetFull.add(card.getId(), game);
|
||||||
|
targetFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (targetFound) {
|
||||||
|
targets.remove(targetDefinition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// card in graveyard
|
||||||
|
if (target instanceof TargetCardInOpponentsGraveyard
|
||||||
|
|| target instanceof TargetCardInYourGraveyard
|
||||||
|
|| target instanceof TargetCardInGraveyard
|
||||||
|
|| target instanceof TargetCardInGraveyardOrBattlefield) {
|
||||||
|
TargetCard targetFull = (TargetCard) target;
|
||||||
|
|
||||||
|
List<UUID> needPlayers = game.getState().getPlayersInRange(getId(), game).toList();
|
||||||
|
// fix for opponent graveyard
|
||||||
|
if(target instanceof TargetCardInOpponentsGraveyard) {
|
||||||
|
// current player remove
|
||||||
|
Assert.assertTrue(needPlayers.contains(getId()));
|
||||||
|
needPlayers.remove(getId());
|
||||||
|
Assert.assertFalse(needPlayers.contains(getId()));
|
||||||
|
}
|
||||||
|
// fix for your graveyard
|
||||||
|
if(target instanceof TargetCardInYourGraveyard) {
|
||||||
|
// only current player
|
||||||
|
Assert.assertTrue(needPlayers.contains(getId()));
|
||||||
|
needPlayers.clear();
|
||||||
|
needPlayers.add(getId());
|
||||||
|
Assert.assertFalse(needPlayers.contains(getId()));
|
||||||
|
}
|
||||||
|
|
||||||
for (String targetDefinition : targets) {
|
for (String targetDefinition : targets) {
|
||||||
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
||||||
|
|
||||||
String[] targetList = targetDefinition.split("\\^");
|
String[] targetList = targetDefinition.split("\\^");
|
||||||
boolean targetFound = false;
|
boolean targetFound = false;
|
||||||
|
|
||||||
for (String targetName : targetList) {
|
for (String targetName : targetList) {
|
||||||
IterateOpponentsGraveyards:
|
IterateGraveyards:
|
||||||
for (UUID opponentId : game.getState().getPlayersInRange(getId(), game)) {
|
for (UUID playerId : needPlayers) {
|
||||||
if (computerPlayer.hasOpponent(opponentId, game)) {
|
Player player = game.getPlayer(playerId);
|
||||||
Player opponent = game.getPlayer(opponentId);
|
for (Card card : player.getGraveyard().getCards(targetFull.getFilter(), game)) {
|
||||||
for (Card card : opponent.getGraveyard().getCards(((TargetCardInOpponentsGraveyard) target).getFilter(), game)) {
|
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
||||||
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
if (targetFull.canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
|
||||||
if (((TargetCardInOpponentsGraveyard) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
|
target.add(card.getId(), game);
|
||||||
target.add(card.getId(), game);
|
targetFound = true;
|
||||||
targetFound = true;
|
break IterateGraveyards;
|
||||||
break IterateOpponentsGraveyards;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetFound) {
|
if (targetFound) {
|
||||||
targets.remove(targetDefinition);
|
targets.remove(targetDefinition);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,14 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
||||||
this.playerFilter = filter.playerFilter.copy();
|
this.playerFilter = filter.playerFilter.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterPlaneswalkerPermanent getFilterPermanent() {
|
||||||
|
return this.planeswalkerFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterPlayer getFilterPlayer() {
|
||||||
|
return this.playerFilter;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkObjectClass(Object object) {
|
public boolean checkObjectClass(Object object) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,10 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,6 +73,11 @@ public class Exile implements Serializable, Copyable<Exile> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Card> getCards(FilterCard filter, Game game) {
|
||||||
|
List<Card> allCards = getAllCards(game);
|
||||||
|
return allCards.stream().filter(card -> filter.match(card, game)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public List<Card> getAllCards(Game game) {
|
public List<Card> getAllCards(Game game) {
|
||||||
List<Card> cards = new ArrayList<>();
|
List<Card> cards = new ArrayList<>();
|
||||||
for (ExileZone exile : exileZones.values()) {
|
for (ExileZone exile : exileZones.values()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue