All 1-character strings converted to primitives

"b" + "r" now changed to 'b' + 'w'.  It's more straight-forward, and may cause perfomance improvements - character primitives allocation is faster and less expensive than string creation.
This commit is contained in:
vraskulin 2017-01-27 15:57:10 +03:00
parent 31589778ca
commit f60ebfbb1f
451 changed files with 989 additions and 978 deletions

View file

@ -107,7 +107,7 @@ public class AssignNoCombatDamageSourceEffect extends ReplacementEffectImpl {
break;
default:
if (duration.toString().length() > 0) {
text += " " + duration.toString();
text += ' ' + duration.toString();
}
}
return text;

View file

@ -216,7 +216,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
}
}
if (!duration.toString().isEmpty() && !duration.equals(Duration.EndOfGame)) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -85,15 +85,15 @@ public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
}
if (choiceColor.getColor().isBlack()) {
sb.append("B");
sb.append('B');
} else if (choiceColor.getColor().isBlue()) {
sb.append("U");
sb.append('U');
} else if (choiceColor.getColor().isRed()) {
sb.append("R");
sb.append('R');
} else if (choiceColor.getColor().isGreen()) {
sb.append("G");
sb.append('G');
} else if (choiceColor.getColor().isWhite()) {
sb.append("W");
sb.append('W');
}
}
String colors = new String(sb);
@ -123,7 +123,7 @@ public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
sb.append(mode.getTargets().get(0).getFilter().getMessage());
sb.append(" becomes the color or colors of your choice");
if (duration.toString().length() > 0) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
}
return sb.toString();

View file

@ -120,6 +120,6 @@ public class BecomesColorSourceEffect extends ContinuousEffectImpl {
return staticText;
}
return "{this} becomes " + (setColor == null ? "the color of your choice" : setColor.getDescription())
+ " " + duration.toString();
+ ' ' + duration.toString();
}
}

View file

@ -143,7 +143,7 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl {
} else {
sb.append(setColor.getDescription());
}
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
return sb.toString();
}
}

View file

@ -184,7 +184,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
sb.append(" becomes a ");
}
sb.append(token.getDescription());
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
if (addStillALandText) {
if (target.getMaxNumberOfTargets() > 1) {
sb.append(". They're still lands");

View file

@ -101,7 +101,7 @@ public class BecomesCreatureTypeTargetEffect extends ContinuousEffectImpl {
StringBuilder sb = new StringBuilder();
sb.append("Target creature becomes that type");
if (!duration.toString().isEmpty() && !duration.equals(Duration.EndOfGame)) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -103,7 +103,7 @@ public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
sb.append("Target creature becomes that type");
if (!duration.toString().isEmpty()
&& !duration.equals(Duration.EndOfGame)) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -178,15 +178,15 @@ public class BoostAllEffect extends ContinuousEffectImpl {
sb.append(filter.getMessage()).append(" get ");
String p = power.toString();
if (!p.startsWith("-")) {
sb.append("+");
sb.append('+');
}
sb.append(p).append("/");
sb.append(p).append('/');
String t = toughness.toString();
if (!t.startsWith("-")) {
if (p.startsWith("-")) {
sb.append("-");
sb.append('-');
} else {
sb.append("+");
sb.append('+');
}
}
sb.append(t);

View file

@ -161,15 +161,15 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
String p = power.toString();
if (!p.startsWith("-")) {
sb.append("+");
sb.append('+');
}
sb.append(p).append("/");
sb.append(p).append('/');
String t = toughness.toString();
if (!t.startsWith("-")) {
if (p.startsWith("-")) {
sb.append("-");
sb.append('-');
} else {
sb.append("+");
sb.append('+');
}
}
sb.append(t);

View file

@ -118,20 +118,20 @@ public class BoostEnchantedEffect extends ContinuousEffectImpl {
sb.append("Enchanted creature gets ");
String p = power.toString();
if (!p.startsWith("-")) {
sb.append("+");
sb.append('+');
}
sb.append(p).append("/");
sb.append(p).append('/');
String t = toughness.toString();
if (!t.startsWith("-")) {
if (p.startsWith("-")) {
sb.append("-");
sb.append('-');
} else {
sb.append("+");
sb.append('+');
}
}
sb.append(t);
if (duration != Duration.WhileOnBattlefield) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
String message = null;
String fixedPart = null;

View file

@ -119,18 +119,18 @@ public class BoostEquippedEffect extends ContinuousEffectImpl {
sb.append("Equipped creature gets ");
String p = power.toString();
if (!p.startsWith("-"))
sb.append("+");
sb.append(p).append("/");
sb.append('+');
sb.append(p).append('/');
String t = toughness.toString();
if (!t.startsWith("-")) {
if (p.startsWith("-"))
sb.append("-");
sb.append('-');
else
sb.append("+");
sb.append('+');
}
sb.append(t);
if (duration != Duration.WhileOnBattlefield)
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
String message = power.getMessage();
if (message.length() > 0) {
sb.append(" for each ");

View file

@ -121,21 +121,21 @@ public class BoostSourceEffect extends ContinuousEffectImpl implements SourceEff
sb.append("{this} gets ");
String p = power.toString();
if(!p.startsWith("-")) {
sb.append("+");
sb.append('+');
}
sb.append(p).append("/");
sb.append(p).append('/');
String t = toughness.toString();
if(!t.startsWith("-")){
if(t.startsWith("-")) {
sb.append("-");
sb.append('-');
}
else {
sb.append("+");
sb.append('+');
}
}
sb.append(t);
if (duration != Duration.WhileOnBattlefield) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
String message = null;
String fixedPart = null;

View file

@ -133,20 +133,20 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
}
String p = power.toString();
if (!p.startsWith("-")) {
sb.append("+");
sb.append('+');
}
sb.append(p).append("/");
sb.append(p).append('/');
String t = toughness.toString();
if (!t.startsWith("-")) {
if (t.equals("0") && p.startsWith("-")) {
sb.append("-");
sb.append('-');
} else {
sb.append("+");
sb.append('+');
}
}
sb.append(t);
if (duration != Duration.WhileOnBattlefield) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
String message = null;
String fixedPart = null;

View file

@ -129,7 +129,7 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
}
sb.append(" can't gain life");
if (!this.duration.toString().isEmpty()) {
sb.append(" ");
sb.append(' ');
if (duration.equals(Duration.EndOfTurn)) {
sb.append("this turn");
} else {

View file

@ -51,7 +51,7 @@ public class CantGainLifeTargetEffect extends ContinuousEffectImpl {
if (duration.equals(Duration.EndOfTurn)) {
sb.append("this turn, ");
} else {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
}
sb.append("that player gains no life instead");

View file

@ -97,7 +97,8 @@ public class CastAsThoughItHadFlashAllEffect extends AsThoughEffectImpl {
if (duration.equals(Duration.EndOfTurn)) {
sb.append(" this turn");
} else {
sb.append(" ");
sb.append(' ');
sb.append(' ');
sb.append(duration.toString());
}
}

View file

@ -191,14 +191,14 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
sb.append(" gain ");
}
if (quotes) {
sb.append("\"");
sb.append('"');
}
sb.append(ability.getRule());
if (quotes) {
sb.append("\"");
sb.append('"');
}
if (duration.toString().length() > 0) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -137,7 +137,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
}
sb.append(ability.getRule());
if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
staticText = sb.toString();
}

View file

@ -166,7 +166,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
if (duration.equals(Duration.WhileOnBattlefield) || duration.equals(Duration.EndOfGame)) {
sb.append("have ");
if (gainedAbility.startsWith("Whenever ") || gainedAbility.startsWith("{T}")) {
gainedAbility = "\"" + gainedAbility + "\"";
gainedAbility = '"' + gainedAbility + '"';
}
}
else {
@ -174,7 +174,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
}
sb.append(gainedAbility);
if (!duration.toString().isEmpty() && !duration.equals(Duration.EndOfGame)) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
staticText = sb.toString();
}

View file

@ -63,7 +63,7 @@ public class GainAbilityControllerEffect extends ContinuousEffectImpl {
this.ability = ability;
staticText = "You have " + ability.getRule();
if (!duration.toString().isEmpty()) {
staticText += " " + duration.toString();
staticText += ' ' + duration.toString();
}
}

View file

@ -64,7 +64,7 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl implements Sou
public GainAbilitySourceEffect(Ability ability, Duration duration, boolean onCard) {
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.ability = ability;
staticText = "{this} gains " + ability.getRule() + " " + duration.toString();
staticText = "{this} gains " + ability.getRule() + ' ' + duration.toString();
this.onCard = onCard;
}

View file

@ -162,11 +162,11 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
}
StringBuilder sb = new StringBuilder();
Target target = mode.getTargets().get(0);
if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) {
sb.append("any number of target ").append(target.getTargetName()).append(" gain ");
} else if (target.getMaxNumberOfTargets() > 1) {
if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) {
sb.append("any number of target ").append(target.getTargetName()).append(" gain ");
} else if (target.getMaxNumberOfTargets() > 1) {
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
sb.append("up to ");
sb.append("up to ");
}
sb.append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName()).append(" gain ");
} else {
@ -180,7 +180,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
if (durationPhaseStep != null) {
sb.append(" until your next ").append(durationPhaseStep.toString().toLowerCase(Locale.ENGLISH));
} else if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -150,7 +150,7 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
}
sb.append(mode.getTargets().get(0).getTargetName());
if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -47,7 +47,7 @@ public class GainProtectionFromTypeTargetEffect extends GainAbilityTargetEffect
super(new ProtectionAbility(new FilterCard()), duration);
((ProtectionAbility)ability).setFilter(protectionFrom);
typeName = protectionFrom.getMessage();
staticText = "Target creature gains protection from " + typeName + " " + duration.toString();
staticText = "Target creature gains protection from " + typeName + ' ' + duration.toString();
}
public GainProtectionFromTypeTargetEffect(final GainProtectionFromTypeTargetEffect effect) {

View file

@ -28,7 +28,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl {
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.filter = filter;
this.ability = ability;
staticText = filter.getMessage() + " lose " + ability.toString() + (duration.toString().isEmpty() ? "" : " " + duration.toString());
staticText = filter.getMessage() + " lose " + ability.toString() + (duration.toString().isEmpty() ? "" : ' ' + duration.toString());
}
public LoseAbilityAllEffect(final LoseAbilityAllEffect effect) {

View file

@ -123,7 +123,7 @@ public class LoseAbilityOrAnotherAbilityTargetEffect extends LoseAbilityTargetEf
sb.append(" or ");
sb.append(ability2.getRule());
if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -27,7 +27,7 @@ public class LoseAbilitySourceEffect extends ContinuousEffectImpl{
public LoseAbilitySourceEffect(Ability ability, Duration duration){
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.LoseAbility);
this.ability = ability;
staticText = "{this} loses " + ability.getRule() + " " + duration.toString();
staticText = "{this} loses " + ability.getRule() + ' ' + duration.toString();
}
public LoseAbilitySourceEffect(final LoseAbilitySourceEffect effect){

View file

@ -93,7 +93,7 @@ public class LoseAbilityTargetEffect extends ContinuousEffectImpl {
}
sb.append(ability.getRule());
if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -96,7 +96,7 @@ public class SetCardSubtypeAttachedEffect extends ContinuousEffectImpl {
sb.append(" creature is a");
for (String subtype : this.setSubtypes) {
sb.append(" ").append(subtype);
sb.append(' ').append(subtype);
}
staticText = sb.toString();
}

View file

@ -131,9 +131,9 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl {
} else {
sb.append(" have base power and toughness ");
}
sb.append(power).append("/").append(toughness);
sb.append(power).append('/').append(toughness);
if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString());
sb.append(' ').append(duration.toString());
}
return sb.toString();
}

View file

@ -66,7 +66,7 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
super(duration, Layer.PTChangingEffects_7, subLayer, Outcome.BoostCreature);
this.power = power;
this.toughness = toughness;
staticText = "{this}'s power and toughness is " + power + "/" + toughness + " " + duration.toString();
staticText = "{this}'s power and toughness is " + power + '/' + toughness + ' ' + duration.toString();
}
public SetPowerToughnessSourceEffect(final SetPowerToughnessSourceEffect effect) {

View file

@ -96,7 +96,7 @@ public class SetPowerToughnessTargetEffect extends ContinuousEffectImpl {
}
StringBuilder sb = new StringBuilder();
sb.append("target ").append(mode.getTargets().get(0).getTargetName()).append(" has base power and toughness ");
sb.append(power).append("/").append(toughness).append(" ").append(duration.toString());
sb.append(power).append('/').append(toughness).append(' ').append(duration.toString());
return sb.toString();
}

View file

@ -109,7 +109,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
StringBuilder sb = new StringBuilder();
sb.append("Switch each creature's power and toughness");
if (!duration.toString().isEmpty()) {
sb.append(" ");
sb.append(' ');
sb.append(duration.toString());
}
return sb.toString();

View file

@ -73,7 +73,7 @@ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl {
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append("Switch target ").append(mode.getTargets().get(0).getTargetName()).append("'s power and toughness")
.append(" ").append(duration.toString());
.append(' ').append(duration.toString());
return sb.toString();
}