[KHM] fixed Frostpyre Arcanist being used incorrectly by AI (#7488)

This commit is contained in:
Evan Kranzler 2021-02-04 10:50:10 -05:00
parent 3727e2ea42
commit bc99de1a48
3 changed files with 60 additions and 10 deletions

View file

@ -1816,7 +1816,8 @@ public class ComputerPlayer extends PlayerImpl implements Player {
abilityControllerId = target.getAbilityController();
}
List<Card> cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), game));
// we still use playerId when getting cards even if they don't control the search
List<Card> cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), source != null ? source.getSourceId() : null, playerId, game));
while (!target.doneChosing()) {
Card card = pickTarget(abilityControllerId, cardChoices, outcome, target, source, game);
if (card != null) {

View file

@ -0,0 +1,50 @@
package org.mage.test.cards.single.khm;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author TheElk801
*/
public class FrostpyreArcanistTest extends CardTestPlayerBase {
private static final String arcanist = "Frostpyre Arcanist";
private static final String bolt = "Lightning Bolt";
@Test
public void testCanFind() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
addCard(Zone.LIBRARY, playerA, bolt);
addCard(Zone.GRAVEYARD, playerA, bolt);
addCard(Zone.HAND, playerA, arcanist);
addTarget(playerA, bolt);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, arcanist);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertLibraryCount(playerA, bolt, 0);
assertHandCount(playerA, bolt, 1);
}
@Test
public void testCantFind() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
addCard(Zone.LIBRARY, playerA, bolt);
addCard(Zone.HAND, playerA, arcanist);
addTarget(playerA, bolt);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, arcanist);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertLibraryCount(playerA, bolt, 1);
assertHandCount(playerA, bolt, 0);
}
}

View file

@ -1,11 +1,5 @@
package mage.target.common;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.cards.Card;
@ -14,12 +8,17 @@ import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCardInLibrary extends TargetCard {
@ -27,7 +26,7 @@ public class TargetCardInLibrary extends TargetCard {
private int librarySearchLimit;
public TargetCardInLibrary() {
this(1, 1, new FilterCard());
this(1, 1, StaticFilters.FILTER_CARD);
}
public TargetCardInLibrary(FilterCard filter) {
@ -93,7 +92,7 @@ public class TargetCardInLibrary extends TargetCard {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
Card card = game.getPlayer(source.getControllerId()).getLibrary().getCard(id, game);
return card != null && filter.match(card, game);
return card != null && filter.match(card, source.getSourceId(), source.getControllerId(), game);
}
@Override