removed method for preventing library search triggers

This commit is contained in:
Evan Kranzler 2020-11-13 09:40:18 -05:00
parent c693b0db2d
commit 01a0d23a55
5 changed files with 65 additions and 99 deletions

View file

@ -259,7 +259,7 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
playerName = "your";
}
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard("nonland card from " + playerName + " library"));
if (controller.searchLibrary(target, source, game, playerId, !checkList.contains(playerId))) {
if (controller.searchLibrary(target, source, game, playerId)) {
checkList.add(playerId);
UUID targetId = target.getFirstTarget();
Card card = player.getLibrary().remove(targetId, game);

View file

@ -3273,21 +3273,12 @@ public class TestPlayer implements Player {
return computerPlayer.searchLibrary(target, source, game);
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, boolean triggerEvents) {
return computerPlayer.searchLibrary(target, source, game, triggerEvents);
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId) {
return computerPlayer.searchLibrary(target, source, game, targetPlayerId);
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents) {
return computerPlayer.searchLibrary(target, source, game, targetPlayerId, triggerEvents);
}
@Override
public void lookAtAllLibraries(Ability source, Game game) {
computerPlayer.lookAtAllLibraries(source, game);
@ -3402,12 +3393,12 @@ public class TestPlayer implements Player {
public boolean canPayLifeCost(Ability ability) {
return computerPlayer.canPayLifeCost(ability);
}
@Override
public boolean getCanPayLifeCost() {
return computerPlayer.getCanPayLifeCost();
}
@Override
public void setCanPayLifeCost(boolean canPayLifeCost) {
computerPlayer.setCanPayLifeCost(canPayLifeCost);

View file

@ -1,6 +1,8 @@
package org.mage.test.stub;
import mage.ApprovingObject;
import mage.MageObject;
import mage.Mana;
import mage.abilities.*;
import mage.abilities.costs.AlternativeSourceCosts;
import mage.abilities.costs.Cost;
@ -40,8 +42,6 @@ import mage.target.common.TargetCardInLibrary;
import java.io.Serializable;
import java.util.*;
import mage.ApprovingObject;
import mage.Mana;
/**
* @author Quercitron
@ -179,12 +179,12 @@ public class PlayerStub implements Player {
public void setCanPayLifeCost(boolean canPayLifeCost) {
}
@Override
public boolean getCanPayLifeCost() {
return false;
}
@Override
public boolean canPayLifeCost(Ability ability) {
return false;
@ -579,21 +579,11 @@ public class PlayerStub implements Player {
return false;
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, boolean triggerEvents) {
return false;
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId) {
return false;
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents) {
return false;
}
@Override
public void lookAtAllLibraries(Ability source, Game game) {
}
@ -1045,19 +1035,19 @@ public class PlayerStub implements Player {
@Override
public void addAvailableTriggeredMana(List<Mana> availableTriggeredMan) {
}
}
@Override
public List<List<Mana>> getAvailableTriggeredMana() {
return null;
}
@Override
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
return 0;
}
@Override
public List<ActivatedAbility> getPlayable(Game game, boolean hidden) {
return null;

View file

@ -1,7 +1,5 @@
package mage.players;
import java.io.Serializable;
import java.util.*;
import mage.ApprovingObject;
import mage.MageItem;
import mage.MageObject;
@ -41,6 +39,9 @@ import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import mage.util.Copyable;
import java.io.Serializable;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -103,12 +104,12 @@ public interface Player extends MageItem, Copyable<Player> {
/**
* Is the player allowed to pay life for casting spells or activate activated abilities
*
* @param canPayLifeCost
*
* @param canPayLifeCost
*/
void setCanPayLifeCost(boolean canPayLifeCost);
boolean getCanPayLifeCost();
/**
@ -345,19 +346,15 @@ public interface Player extends MageItem, Copyable<Player> {
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game);
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, boolean triggerEvents);
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId);
/**
* @param target
* @param source
* @param game
* @param targetPlayerId player whose library will be searched
* @param triggerEvents whether searching will trigger any game events
* @return true if search was successful
*/
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents);
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId);
/**
* Reveals all players' libraries. Useful for abilities like Jace, Architect

View file

@ -2603,21 +2603,11 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game) {
return searchLibrary(target, source, game, playerId, true);
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, boolean triggerEvents) {
return searchLibrary(target, source, game, playerId, triggerEvents);
return searchLibrary(target, source, game, playerId);
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId) {
return searchLibrary(target, source, game, targetPlayerId, true);
}
@Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents) {
//20091005 - 701.14c
Library searchedLibrary = null;
String searchInfo = null;
@ -2636,59 +2626,57 @@ public abstract class PlayerImpl implements Player, Serializable {
}
GameEvent event = GameEvent.getEvent(GameEvent.EventType.SEARCH_LIBRARY,
targetPlayerId, source.getSourceId(), playerId, Integer.MAX_VALUE);
if (!game.replaceEvent(event)) {
if (!game.isSimulation()) {
game.informPlayers(searchInfo);
}
TargetCardInLibrary newTarget = target.copy();
int count;
int librarySearchLimit = event.getAmount();
List<Card> cardsFromTop = null;
do {
// TODO: prevent shuffling from moving the visualized cards
if (librarySearchLimit == Integer.MAX_VALUE) {
count = searchedLibrary.count(target.getFilter(), game);
if (game.replaceEvent(event)) {
return false;
}
if (!game.isSimulation()) {
game.informPlayers(searchInfo);
}
TargetCardInLibrary newTarget = target.copy();
int count;
int librarySearchLimit = event.getAmount();
List<Card> cardsFromTop = null;
do {
// TODO: prevent shuffling from moving the visualized cards
if (librarySearchLimit == Integer.MAX_VALUE) {
count = searchedLibrary.count(target.getFilter(), game);
} else {
Player targetPlayer = game.getPlayer(targetPlayerId);
if (targetPlayer == null) {
return false;
}
if (cardsFromTop == null) {
cardsFromTop = new ArrayList<>(targetPlayer.getLibrary().getTopCards(game, librarySearchLimit));
} else {
Player targetPlayer = game.getPlayer(targetPlayerId);
if (targetPlayer == null) {
return false;
}
if (cardsFromTop == null) {
cardsFromTop = new ArrayList<>(targetPlayer.getLibrary().getTopCards(game, librarySearchLimit));
} else {
cardsFromTop.retainAll(targetPlayer.getLibrary().getCards(game));
}
newTarget.setCardLimit(Math.min(librarySearchLimit, cardsFromTop.size()));
count = Math.min(searchedLibrary.count(target.getFilter(), game), librarySearchLimit);
cardsFromTop.retainAll(targetPlayer.getLibrary().getCards(game));
}
newTarget.setCardLimit(Math.min(librarySearchLimit, cardsFromTop.size()));
count = Math.min(searchedLibrary.count(target.getFilter(), game), librarySearchLimit);
}
if (count < target.getNumberOfTargets()) {
newTarget.setMinNumberOfTargets(count);
}
if (newTarget.choose(Outcome.Neutral, playerId, targetPlayerId, game)) {
if (targetPlayerId.equals(playerId) && handleLibraryCastableCards(library,
game, targetPlayerId)) { // for handling Panglacial Wurm
newTarget.clearChosen();
continue;
}
target.getTargets().clear();
for (UUID targetId : newTarget.getTargets()) {
target.add(targetId, game);
}
} else if (targetPlayerId.equals(playerId) && handleLibraryCastableCards(library,
if (count < target.getNumberOfTargets()) {
newTarget.setMinNumberOfTargets(count);
}
if (newTarget.choose(Outcome.Neutral, playerId, targetPlayerId, game)) {
if (targetPlayerId.equals(playerId) && handleLibraryCastableCards(library,
game, targetPlayerId)) { // for handling Panglacial Wurm
newTarget.clearChosen();
continue;
}
if (triggerEvents) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SEARCHED, targetPlayerId, playerId));
target.getTargets().clear();
for (UUID targetId : newTarget.getTargets()) {
target.add(targetId, game);
}
break;
} while (true);
return true;
}
return false;
} else if (targetPlayerId.equals(playerId) && handleLibraryCastableCards(library,
game, targetPlayerId)) { // for handling Panglacial Wurm
newTarget.clearChosen();
continue;
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SEARCHED, targetPlayerId, playerId));
break;
} while (true);
return true;
}
@Override