* Fixed a bug of exile target and search other zones function searching for wrong name (fixes #541). Concerned Eradicate, Scour, Sowing Salt and Splinter.

This commit is contained in:
LevelX2 2014-08-26 12:00:01 +02:00
parent 5d9a3a5867
commit a43182ef4a
2 changed files with 12 additions and 18 deletions

View file

@ -58,38 +58,24 @@ public class ExileTargetAndSearchGraveyardHandLibraryEffect extends SearchTarget
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
String cardName = "";
UUID targetPlayerId = null;
// define cardName
if (source instanceof SpellAbility) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) {
cardName = sourceCard.getName();
}
} else {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
cardName = sourcePermanent.getName();
}
}
// get Target to exile
Target exileTarget = null;
for (Target target : source.getTargets()) {
if (!(target instanceof TargetPlayer)) {
if (target instanceof TargetPermanent) {
exileTarget = target;
break;
}
}
if (exileTarget != null && exileTarget instanceof TargetPermanent) {
if (exileTarget != null) {
Permanent permanentToExile = game.getPermanent(exileTarget.getFirstTarget());
if (permanentToExile != null) {
targetPlayerId = permanentToExile.getControllerId();
result = permanentToExile.moveToExile(null, "", source.getSourceId(), game);
this.applySearchAndExile(game, source, permanentToExile.getName(), targetPlayerId);
}
}
this.applySearchAndExile(game, source, cardName, targetPlayerId);
return result;
}

View file

@ -77,6 +77,14 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
this.graveyardExileOptional = effect.graveyardExileOptional;
}
/**
*
* @param game
* @param source
* @param cardName name of the card to exile
* @param targetPlayerId id of the target player to exile card name from his or her zones
* @return
*/
public boolean applySearchAndExile(Game game, Ability source, String cardName, UUID targetPlayerId) {
Player controller = game.getPlayer(source.getControllerId());
if (cardName != null && controller != null) {