Address crash points of JSON tests

This commit is contained in:
Zach Halpern 2019-01-10 21:27:38 -05:00
parent e4e78d5509
commit 8a5f2288f9
9 changed files with 125 additions and 87 deletions

View file

@ -69,6 +69,11 @@ public class CreateTokenTargetEffect extends OneShotEffect {
return staticText;
}
StringBuilder sb = new StringBuilder();
if (mode.getTargets().isEmpty()) {
return "";
}
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
sb.append(" creates ");
if (amount.toString().equals("1")) {

View file

@ -32,7 +32,6 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
* Attention: This effect won't work with targets controlled by different
* controllers If this is needed, the validForTurnNum has to be saved per
* controller.
*
*/
public DontUntapInControllersNextUntapStepTargetEffect() {
this("");
@ -43,10 +42,9 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
}
/**
*
* @param targetName used as target text for the generated rule text
* @param targetName used as target text for the generated rule text
* @param onlyIfControlledByPlayer the effect only works if the permanent is
* controlled by that controller, null = it works for all players
* controlled by that controller, null = it works for all players
*/
public DontUntapInControllersNextUntapStepTargetEffect(String targetName, UUID onlyIfControlledByPlayer) {
this(targetName, false, onlyIfControlledByPlayer);
@ -116,7 +114,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
}
}
}
if (allHandled) {
discard();
}
@ -149,8 +147,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
} else
return targetName + " doesn't untap during its controller's next " + (twoSteps ? "two " : "") + "untap step" + (twoSteps ? "s" : "");
} else {
return "target " + (mode == null ? "creature" : mode.getTargets().get(0).getTargetName()) + " doesn't untap during its controller's next " + (twoSteps ? "two " : "") + "untap step" + (twoSteps ? "s" : "");
return "target " + (mode == null || mode.getTargets().isEmpty() ? "creature" : mode.getTargets().get(0).getTargetName()) + " doesn't untap during its controller's next " + (twoSteps ? "two " : "") + "untap step" + (twoSteps ? "s" : "");
}
}
}
}

View file

@ -65,6 +65,11 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
return staticText;
}
StringBuilder sb = new StringBuilder();
if (mode.getTargets().isEmpty()) {
return "";
}
Target target = mode.getTargets().get(0);
sb.append("return ");
if (target.getMaxNumberOfTargets() > 1) {
@ -80,4 +85,4 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
sb.append(" under your control");
return sb.toString();
}
}
}

View file

@ -51,6 +51,10 @@ public class TapAllTargetPlayerControlsEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
if (mode.getTargets().isEmpty()) {
return "";
}
return "tap all " + filter.toString() + " target " + mode.getTargets().get(0).getTargetName() + " controls";
}
}

View file

@ -54,6 +54,10 @@ public class TapTargetEffect extends OneShotEffect {
return "tap " + staticText;
}
if (mode.getTargets().isEmpty()) {
return "";
}
Target target = mode.getTargets().get(0);
if (target.getMaxNumberOfTargets() > 1) {
if (target.getMaxNumberOfTargets() == target.getNumberOfTargets()) {

View file

@ -65,8 +65,12 @@ public class UntapTargetEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
Target target = mode.getTargets().get(0);
if (mode.getTargets().isEmpty()) {
return "";
}
Target target = mode.getTargets().get(0);
StringBuilder sb = new StringBuilder();
sb.append("untap ");
if (target.getNumberOfTargets() == 0) {
@ -84,4 +88,4 @@ public class UntapTargetEffect extends OneShotEffect {
return sb.toString();
}
}
}

View file

@ -112,6 +112,11 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
if (!staticText.isEmpty()) {
return staticText;
}
if (mode.getTargets().isEmpty()) {
return "";
}
Target target = mode.getTargets().get(0);
StringBuilder sb = new StringBuilder("gain control of ");
if (target.getMaxNumberOfTargets() > 1) {

View file

@ -80,6 +80,11 @@ public class EchoEffect extends OneShotEffect {
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
if (cost == null) {
return "";
}
String costText = cost.getText();
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));