mirror of
https://github.com/correl/mage.git
synced 2025-04-09 01:01:06 -09: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
Mage.Tests/src/test/java/org/mage/test/player
Mage/src/main/java/mage
|
@ -1263,17 +1263,18 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (target instanceof TargetCardInYourGraveyard) {
|
||||
// card in exile
|
||||
if (target instanceof TargetCardInExile) {
|
||||
TargetCardInExile targetFull = (TargetCardInExile) target;
|
||||
for (String targetDefinition : targets) {
|
||||
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
||||
String[] targetList = targetDefinition.split("\\^");
|
||||
boolean targetFound = false;
|
||||
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 (((TargetCardInYourGraveyard) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
|
||||
target.add(card.getId(), game);
|
||||
if (targetFull.canTarget(abilityControllerId, card.getId(), source, game) && !targetFull.getTargets().contains(card.getId())) {
|
||||
targetFull.add(card.getId(), game);
|
||||
targetFound = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1285,32 +1286,80 @@ public class TestPlayer implements Player {
|
|||
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) {
|
||||
checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
|
||||
|
||||
String[] targetList = targetDefinition.split("\\^");
|
||||
boolean targetFound = false;
|
||||
|
||||
for (String targetName : targetList) {
|
||||
IterateOpponentsGraveyards:
|
||||
for (UUID opponentId : game.getState().getPlayersInRange(getId(), game)) {
|
||||
if (computerPlayer.hasOpponent(opponentId, game)) {
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
for (Card card : opponent.getGraveyard().getCards(((TargetCardInOpponentsGraveyard) target).getFilter(), game)) {
|
||||
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
||||
if (((TargetCardInOpponentsGraveyard) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
|
||||
target.add(card.getId(), game);
|
||||
targetFound = true;
|
||||
break IterateOpponentsGraveyards;
|
||||
}
|
||||
IterateGraveyards:
|
||||
for (UUID playerId : needPlayers) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
for (Card card : player.getGraveyard().getCards(targetFull.getFilter(), game)) {
|
||||
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
|
||||
if (targetFull.canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
|
||||
target.add(card.getId(), game);
|
||||
targetFound = true;
|
||||
break IterateGraveyards;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (targetFound) {
|
||||
targets.remove(targetDefinition);
|
||||
return true;
|
||||
|
|
|
@ -47,6 +47,14 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
|||
this.playerFilter = filter.playerFilter.copy();
|
||||
}
|
||||
|
||||
public FilterPlaneswalkerPermanent getFilterPermanent() {
|
||||
return this.planeswalkerFilter;
|
||||
}
|
||||
|
||||
public FilterPlayer getFilterPlayer() {
|
||||
return this.playerFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObjectClass(Object object) {
|
||||
return true;
|
||||
|
|
|
@ -9,7 +9,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.util.Copyable;
|
||||
|
||||
/**
|
||||
|
@ -70,6 +73,11 @@ public class Exile implements Serializable, Copyable<Exile> {
|
|||
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) {
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (ExileZone exile : exileZones.values()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue