Fixed missing locale param in string operations (#4634)

This commit is contained in:
Oleg Agafonov 2020-07-03 02:00:58 +04:00
parent da4a44445b
commit e69a021c71
12 changed files with 30 additions and 18 deletions

View file

@ -230,12 +230,12 @@ public class PickCheckBoxDialog extends MageDialog {
if (filter == null) { if (filter == null) {
filter = ""; filter = "";
} }
filter = filter.toLowerCase(); filter = filter.toLowerCase(Locale.ENGLISH);
this.dataModel.clear(); this.dataModel.clear();
this.m_dataModel.clear(); this.m_dataModel.clear();
for (KeyValueItem item : this.allItems) { for (KeyValueItem item : this.allItems) {
if (!choice.isSearchEnabled() || item.Value.toLowerCase().contains(filter)) { if (!choice.isSearchEnabled() || item.Value.toLowerCase(Locale.ENGLISH).contains(filter)) {
this.dataModel.addElement(item); this.dataModel.addElement(item);
this.m_dataModel.addElement(item.getObjectValue()); this.m_dataModel.addElement(item.getObjectValue());
} }

View file

@ -119,7 +119,7 @@ class JeganthaTheWellspringManaCondition extends ManaCondition {
private final String manaSymbol; private final String manaSymbol;
JeganthaTheWellspringManaCondition(String manaSymbol) { JeganthaTheWellspringManaCondition(String manaSymbol) {
this.manaSymbol = manaSymbol.toLowerCase(); this.manaSymbol = manaSymbol.toLowerCase(Locale.ENGLISH);
} }
@Override @Override
@ -132,6 +132,6 @@ class JeganthaTheWellspringManaCondition extends ManaCondition {
.getUnpaid() .getUnpaid()
.getText() .getText()
.split("[\\}\\{]") .split("[\\}\\{]")
).map(String::toLowerCase).anyMatch(s -> s.contains(manaSymbol)); ).map(s -> s.toLowerCase(Locale.ENGLISH)).anyMatch(s -> s.contains(manaSymbol));
} }
} }

View file

@ -95,7 +95,7 @@ class MythosOfSnapdaxEffect extends OneShotEffect {
for (Player player : playerList) { for (Player player : playerList) {
for (CardType cardType : cardTypes) { for (CardType cardType : cardTypes) {
String message = cardType.toString().equals("Artifact") ? "an " : "a "; String message = cardType.toString().equals("Artifact") ? "an " : "a ";
message += cardType.toString().toLowerCase(); message += cardType.toString().toLowerCase(Locale.ENGLISH);
message += (conditionMet && player != controller) ? " controlled by " + player.getName() : " you control"; message += (conditionMet && player != controller) ? " controlled by " + player.getName() : " you control";
FilterPermanent filter = new FilterNonlandPermanent(message); FilterPermanent filter = new FilterNonlandPermanent(message);
filter.add(cardType.getPredicate()); filter.add(cardType.getPredicate());

View file

@ -29,6 +29,7 @@ import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -110,7 +111,7 @@ class VivienMonstersAdvocateTokenEffect extends OneShotEffect {
player.choose(outcome, choice, game); player.choose(outcome, choice, game);
String chosen = choice.getChoice(); String chosen = choice.getChoice();
if (chosen != null) { if (chosen != null) {
permanent.addCounters(CounterType.findByName(chosen.toLowerCase()).createInstance(), source, game); permanent.addCounters(CounterType.findByName(chosen.toLowerCase(Locale.ENGLISH)).createInstance(), source, game);
} }
} }
return true; return true;

View file

@ -331,7 +331,7 @@ public class VerifyCardDataTest {
// replace codes for aliases // replace codes for aliases
String searchSet = MtgJson.mtgJsonToXMageCodes.getOrDefault(refSet.code, refSet.code); String searchSet = MtgJson.mtgJsonToXMageCodes.getOrDefault(refSet.code, refSet.code);
ExpansionSet mageSet = Sets.findSet(searchSet.toUpperCase()); ExpansionSet mageSet = Sets.findSet(searchSet.toUpperCase(Locale.ENGLISH));
if (mageSet == null) { if (mageSet == null) {
totalMissingSets = totalMissingSets + 1; totalMissingSets = totalMissingSets + 1;
totalMissingCards = totalMissingCards + refSet.cards.size(); totalMissingCards = totalMissingCards + refSet.cards.size();

View file

@ -6,6 +6,8 @@ import mage.constants.Duration;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import java.util.Locale;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
@ -36,7 +38,7 @@ public class ReflexiveTriggeredAbility extends DelayedTriggeredAbility {
@Override @Override
public String getRule() { public String getRule() {
return text.substring(0, 1).toUpperCase() + text.substring(1) + '.'; return text.substring(0, 1).toUpperCase(Locale.ENGLISH) + text.substring(1) + '.';
} }
public String getText() { public String getText() {

View file

@ -11,6 +11,8 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.Locale;
/** /**
* @author Plopman * @author Plopman
*/ */
@ -25,7 +27,7 @@ public class ChooseColorEffect extends OneShotEffect {
public ChooseColorEffect(Outcome outcome, String exceptColor) { public ChooseColorEffect(Outcome outcome, String exceptColor) {
super(outcome); super(outcome);
this.exceptColor = exceptColor; this.exceptColor = exceptColor;
staticText = "choose a color" + (exceptColor != null ? " other than " + exceptColor.toLowerCase() : ""); staticText = "choose a color" + (exceptColor != null ? " other than " + exceptColor.toLowerCase(Locale.ENGLISH) : "");
} }
public ChooseColorEffect(final ChooseColorEffect effect) { public ChooseColorEffect(final ChooseColorEffect effect) {

View file

@ -17,6 +17,7 @@ import mage.target.Target;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -150,7 +151,7 @@ public class RollPlanarDieEffect extends OneShotEffect {
if (effect != null) { if (effect != null) {
try { try {
String emode = effect.getText(mode); String emode = effect.getText(mode);
emode = emode.substring(0, 1).toLowerCase() + emode.substring(1); emode = emode.substring(0, 1).toLowerCase(Locale.ENGLISH) + emode.substring(1);
sb.append(emode); sb.append(emode);
} catch (Exception e) { } catch (Exception e) {
sb.append("perform the CHAOS action"); sb.append("perform the CHAOS action");

View file

@ -9,6 +9,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.Locale;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
@ -50,7 +52,7 @@ public class AddCounterChoiceSourceEffect extends OneShotEffect {
} }
private static final String cap(String string) { private static final String cap(String string) {
return string != null ? string.substring(0, 1).toUpperCase() + string.substring(1) : null; return string != null ? string.substring(0, 1).toUpperCase(Locale.ENGLISH) + string.substring(1) : null;
} }
@Override @Override

View file

@ -6,6 +6,8 @@ import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.Zone; import mage.constants.Zone;
import java.util.Locale;
/** /**
* *
* @author L_J * @author L_J
@ -69,7 +71,7 @@ public class BandsWithOtherAbility extends StaticAbility {
if (subtype != null) { if (subtype != null) {
return sb.append(' ').append(subtype.getDescription()).append('s').toString(); return sb.append(' ').append(subtype.getDescription()).append('s').toString();
} else if (supertype != null) { } else if (supertype != null) {
return sb.append(' ').append(supertype.toString().toLowerCase()).append(" creatures").toString(); return sb.append(' ').append(supertype.toString().toLowerCase(Locale.ENGLISH)).append(" creatures").toString();
} else if (bandingName != null) { } else if (bandingName != null) {
return sb.append(" creatures named ").append(bandingName).toString(); return sb.append(" creatures named ").append(bandingName).toString();
} }

View file

@ -2,6 +2,7 @@ package mage.abilities.meta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
@ -86,15 +87,15 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl {
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (triggeredAbilities[0].getRule().length() > 0) { if (triggeredAbilities[0].getRule().length() > 0) {
sb.append(triggeredAbilities[0].getRule().substring(0, 1).toUpperCase()) sb.append(triggeredAbilities[0].getRule().substring(0, 1).toUpperCase(Locale.ENGLISH))
.append(triggeredAbilities[0].getRule().substring(1).toLowerCase()); .append(triggeredAbilities[0].getRule().substring(1).toLowerCase(Locale.ENGLISH));
} }
for (int i = 1; i < (triggeredAbilities.length - 1); i++) { for (int i = 1; i < (triggeredAbilities.length - 1); i++) {
sb.append(triggeredAbilities[i].getRule().toLowerCase()); sb.append(triggeredAbilities[i].getRule().toLowerCase(Locale.ENGLISH));
} }
sb.append(" or ").append(triggeredAbilities[triggeredAbilities.length - 1].getRule().toLowerCase()); sb.append(" or ").append(triggeredAbilities[triggeredAbilities.length - 1].getRule().toLowerCase(Locale.ENGLISH));
return sb.toString() + super.getRule(); return sb.toString() + super.getRule();
} }

View file

@ -4,6 +4,7 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
/** /**
@ -23,8 +24,8 @@ public class DeckFormatsTest {
} }
// 2. must work with files // 2. must work with files
String fileName = "C:\\xmage\\deck" + "." + df.getExporter().getDefaultFileExt(); String fileName = "C:\\xmage\\deck" + "." + df.getExporter().getDefaultFileExt();
Assert.assertTrue("Must support lower ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toLowerCase()).isPresent()); Assert.assertTrue("Must support lower ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toLowerCase(Locale.ENGLISH)).isPresent());
Assert.assertTrue("Must support upper ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toUpperCase()).isPresent()); Assert.assertTrue("Must support upper ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toUpperCase(Locale.ENGLISH)).isPresent());
} }
// 3. wrong ext // 3. wrong ext