Improved rules text generation and removed static texts for some cards with effects:

* ExileTargetForSourceEffect
 * ReturnFromExileForSourceEffect
 * ReturnToBattlefieldUnderOwnerControlTargetEffect
 * ReturnToBattlefieldUnderYourControlTargetEffect
This commit is contained in:
Oleg Agafonov 2020-01-14 20:38:45 +04:00
parent ce3f6d8e41
commit b1b6bd600e
16 changed files with 120 additions and 97 deletions

View file

@ -69,10 +69,13 @@ public class ExileTargetForSourceEffect extends OneShotEffect {
return staticText;
}
String upToText = "";
String amountText = "";
if (mode.getTargets().get(0).getMinNumberOfTargets() < mode.getTargets().get(0).getMaxNumberOfTargets()) {
upToText = "up to " + CardUtil.numberToText(mode.getTargets().get(0).getMaxNumberOfTargets()) + " ";
amountText = "up to " + CardUtil.numberToText(mode.getTargets().get(0).getMaxNumberOfTargets()) + " ";
} else if (mode.getTargets().get(0).getMinNumberOfTargets() > 1) {
amountText = CardUtil.numberToText(mode.getTargets().get(0).getMinNumberOfTargets()) + " ";
}
String targetText = "";
if (mode.getTargets().get(0).getTargetName().contains("target ")) {
targetText = "";
@ -83,7 +86,7 @@ public class ExileTargetForSourceEffect extends OneShotEffect {
if (mode.getTargets().isEmpty()) {
return "exile it";
} else {
return "exile " + upToText + targetText + mode.getTargets().get(0).getTargetName();
return "exile " + amountText + targetText + mode.getTargets().get(0).getTargetName();
}
}
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common;
import mage.MageObject;
@ -14,7 +13,6 @@ import mage.util.CardUtil;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class ReturnFromExileForSourceEffect extends OneShotEffect {
@ -22,9 +20,10 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
private Zone returnToZone;
private boolean tapped;
private boolean previousZone;
private String returnName = "cards";
private String returnControlName;
/**
*
* @param zone Zone the card should return to
*/
public ReturnFromExileForSourceEffect(Zone zone) {
@ -36,18 +35,28 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
}
/**
*
* @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
* destroyed trigger, the exile zone is based on previous zone of the object
*/
public ReturnFromExileForSourceEffect(Zone zone, boolean tapped, boolean previousZone) {
super(Outcome.PutCardInPlay);
this.returnToZone = zone;
this.tapped = tapped;
this.previousZone = previousZone;
setText();
// different default name for zones
switch (zone) {
case BATTLEFIELD:
this.returnControlName = "its owner's";
break;
default:
this.returnControlName = "their owner's";
break;
}
updateText();
}
public ReturnFromExileForSourceEffect(final ReturnFromExileForSourceEffect effect) {
@ -55,6 +64,10 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
this.returnToZone = effect.returnToZone;
this.tapped = effect.tapped;
this.previousZone = effect.previousZone;
this.returnName = effect.returnName;
this.returnControlName = effect.returnControlName;
updateText();
}
@Override
@ -85,24 +98,30 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
return false;
}
private void setText() {
private void updateText() {
StringBuilder sb = new StringBuilder();
sb.append("return the exiled cards ");
sb.append("return the exiled " + this.returnName + " ");
switch (returnToZone) {
case BATTLEFIELD:
sb.append("to the battlefield under its owner's control");
sb.append("to the battlefield under " + this.returnControlName + " control");
if (tapped) {
sb.append(" tapped");
}
break;
case HAND:
sb.append("to their owner's hand");
sb.append("to " + this.returnControlName + " hand");
break;
case GRAVEYARD:
sb.append("to their owner's graveyard");
sb.append("to " + this.returnControlName + " graveyard");
break;
}
staticText = sb.toString();
}
public ReturnFromExileForSourceEffect withReturnName(String returnName, String returnControlName) {
this.returnName = returnName;
this.returnControlName = returnControlName;
updateText();
return this;
}
}

View file

@ -53,8 +53,8 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
private void updateText() {
this.staticText = "return " + this.returnName
+ " to the battlefield under " + this.returnUnderControlName + " control"
+ (tapped ? " tapped" : "");
+ " to the battlefield" + (tapped ? " tapped" : "")
+ " under " + this.returnUnderControlName + " control";
}
@Override

View file

@ -23,6 +23,8 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
private boolean fromExileZone;
private boolean tapped;
private boolean attacking;
private String returnName = "that card";
private String returnUnderControlName = "your";
public ReturnToBattlefieldUnderYourControlTargetEffect() {
this(false);
@ -50,12 +52,14 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
this.fromExileZone = effect.fromExileZone;
this.tapped = effect.tapped;
this.attacking = effect.attacking;
this.returnName = effect.returnName;
this.returnUnderControlName = effect.returnUnderControlName;
updateText();
}
private void updateText() {
this.staticText = "return that card to the battlefield under your control"
this.staticText = "return " + returnName + " to the battlefield under " + returnUnderControlName + " control"
+ (tapped ? " tapped" : "")
+ (tapped && attacking ? " and" : "")
+ (attacking ? " attacking" : "");
@ -111,4 +115,11 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
}
return false;
}
public ReturnToBattlefieldUnderYourControlTargetEffect withReturnNames(String returnName, String returnUnderControlName) {
this.returnName = returnName;
this.returnUnderControlName = returnUnderControlName;
updateText();
return this;
}
}