mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* 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:
parent
5d9a3a5867
commit
a43182ef4a
2 changed files with 12 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue