mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
Cleanup: ReturnFromExileForSourceEffect (#10371)
* Cleanup ReturnFromExileForSourceEffect * Fix text
This commit is contained in:
parent
a0185ba50a
commit
4a3ce686bb
8 changed files with 28 additions and 59 deletions
|
@ -55,7 +55,7 @@ public final class AngelOfSerenity extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// When Angel of Serenity leaves the battlefield, return the exiled cards to their owners' hands.
|
// When Angel of Serenity leaves the battlefield, return the exiled cards to their owners' hands.
|
||||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.HAND, false, true), false));
|
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.HAND).withText(true, true), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AngelOfSerenity(final AngelOfSerenity card) {
|
private AngelOfSerenity(final AngelOfSerenity card) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class AshioksErasure extends CardImpl {
|
||||||
|
|
||||||
// When Ashiok's Erasure leaves the battlefield, return the exiled card to its owner's hand.
|
// When Ashiok's Erasure leaves the battlefield, return the exiled card to its owner's hand.
|
||||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(
|
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(
|
||||||
Zone.HAND, false, true
|
Zone.HAND
|
||||||
).setText("return the exiled card to its owner's hand"), false));
|
).setText("return the exiled card to its owner's hand"), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,7 @@ public final class FacelessDevourer extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// When Faceless Devourer leaves the battlefield, return the exiled card to the battlefield under its owner's control.
|
// When Faceless Devourer leaves the battlefield, return the exiled card to the battlefield under its owner's control.
|
||||||
ability = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD)
|
ability = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false);
|
||||||
.withReturnName("card", "its owner's"), false);
|
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class Gravegouger extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// When Gravegouger leaves the battlefield, return the exiled cards to their owner's graveyard.
|
// When Gravegouger leaves the battlefield, return the exiled cards to their owner's graveyard.
|
||||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.GRAVEYARD), false));
|
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.GRAVEYARD).withText(true, false), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Gravegouger(final Gravegouger card) {
|
private Gravegouger(final Gravegouger card) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public final class IcyPrison extends CardImpl {
|
||||||
new DoUnlessAnyPlayerPaysEffect(new SacrificeSourceEffect(), new GenericManaCost(3)), TargetController.YOU, false));
|
new DoUnlessAnyPlayerPaysEffect(new SacrificeSourceEffect(), new GenericManaCost(3)), TargetController.YOU, false));
|
||||||
|
|
||||||
// When Icy Prison leaves the battlefield, return the exiled card to the battlefield under its owner's control.
|
// When Icy Prison leaves the battlefield, return the exiled card to the battlefield under its owner's control.
|
||||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD, false, true), false));
|
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,7 @@ public final class Petradon extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// When Petradon leaves the battlefield, return the exiled cards to the battlefield under their owners' control.
|
// When Petradon leaves the battlefield, return the exiled cards to the battlefield under their owners' control.
|
||||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD)
|
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD).withText(true, true), false));
|
||||||
.withReturnName("cards", "their owners'"), false));
|
|
||||||
|
|
||||||
// {R}: Petradon gets +1/+0 until end of turn.
|
// {R}: Petradon gets +1/+0 until end of turn.
|
||||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl<>("{R}")));
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl<>("{R}")));
|
||||||
|
|
|
@ -37,7 +37,7 @@ public final class WormfangBehemoth extends CardImpl {
|
||||||
|
|
||||||
// When Wormfang Behemoth leaves the battlefield, return the exiled cards to their owner's hand.
|
// When Wormfang Behemoth leaves the battlefield, return the exiled cards to their owner's hand.
|
||||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(
|
this.addAbility(new LeavesBattlefieldTriggeredAbility(
|
||||||
new ReturnFromExileForSourceEffect(Zone.HAND), false
|
new ReturnFromExileForSourceEffect(Zone.HAND).withText(true, false), false
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,56 +20,25 @@ import java.util.UUID;
|
||||||
public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
private final Zone returnToZone;
|
private final Zone returnToZone;
|
||||||
private final boolean tapped;
|
private boolean pluralCards;
|
||||||
private final boolean previousZone;
|
private boolean pluralOwners;
|
||||||
private String returnName = "cards";
|
|
||||||
private String returnControlName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param zone Zone the card should return to
|
* @param zone Zone the card should return to
|
||||||
*/
|
*/
|
||||||
public ReturnFromExileForSourceEffect(Zone zone) {
|
public ReturnFromExileForSourceEffect(Zone zone) {
|
||||||
this(zone, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReturnFromExileForSourceEffect(Zone zone, boolean tapped) {
|
|
||||||
this(zone, tapped, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param zone
|
|
||||||
* @param tapped
|
|
||||||
* @param previousZone if this is used from a dies leave battlefield or
|
|
||||||
* destroyed trigger, the exile zone is based on previous zone of the object
|
|
||||||
*/
|
|
||||||
public ReturnFromExileForSourceEffect(Zone zone, boolean tapped, boolean previousZone) {
|
|
||||||
super(Outcome.PutCardInPlay);
|
super(Outcome.PutCardInPlay);
|
||||||
this.returnToZone = zone;
|
this.returnToZone = zone;
|
||||||
this.tapped = tapped;
|
this.pluralCards = false;
|
||||||
this.previousZone = previousZone;
|
this.pluralOwners = false;
|
||||||
|
|
||||||
// different default name for zones
|
|
||||||
switch (zone) {
|
|
||||||
case BATTLEFIELD:
|
|
||||||
this.returnControlName = "its owner's";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.returnControlName = "their owner's";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReturnFromExileForSourceEffect(final ReturnFromExileForSourceEffect effect) {
|
public ReturnFromExileForSourceEffect(final ReturnFromExileForSourceEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.returnToZone = effect.returnToZone;
|
this.returnToZone = effect.returnToZone;
|
||||||
this.tapped = effect.tapped;
|
this.pluralCards = effect.pluralCards;
|
||||||
this.previousZone = effect.previousZone;
|
this.pluralOwners = effect.pluralOwners;
|
||||||
this.returnName = effect.returnName;
|
|
||||||
this.returnControlName = effect.returnControlName;
|
|
||||||
|
|
||||||
updateText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,30 +77,32 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReturnFromExileForSourceEffect withText(boolean pluralCards, boolean pluralOwners) {
|
||||||
|
this.pluralCards = pluralCards;
|
||||||
|
this.pluralOwners = pluralOwners;
|
||||||
|
updateText();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateText() {
|
private void updateText() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("return the exiled ").append(this.returnName).append(" ");
|
sb.append("return the exiled ").append(pluralCards ? "cards" : "card").append(" to ");
|
||||||
|
if (returnToZone == Zone.BATTLEFIELD) {
|
||||||
|
sb.append("the battlefield under ");
|
||||||
|
}
|
||||||
|
sb.append(pluralCards ? "their " : "its ").append(pluralOwners ? "owners' " : "owner's ");
|
||||||
switch (returnToZone) {
|
switch (returnToZone) {
|
||||||
case BATTLEFIELD:
|
case BATTLEFIELD:
|
||||||
sb.append("to the battlefield under ").append(this.returnControlName).append(" control");
|
sb.append("control");
|
||||||
if (tapped) {
|
|
||||||
sb.append(" tapped");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case HAND:
|
case HAND:
|
||||||
sb.append("to ").append(this.returnControlName).append(" hand");
|
sb.append(pluralOwners ? "hands" : "hand");
|
||||||
break;
|
break;
|
||||||
case GRAVEYARD:
|
case GRAVEYARD:
|
||||||
sb.append("to ").append(this.returnControlName).append(" graveyard");
|
sb.append(pluralOwners ? "graveyards" : "graveyard");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
staticText = sb.toString();
|
staticText = sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReturnFromExileForSourceEffect withReturnName(String returnName, String returnControlName) {
|
|
||||||
this.returnName = returnName;
|
|
||||||
this.returnControlName = returnControlName;
|
|
||||||
updateText();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue