* Added to all toUpperCase/toLowerCase calls the Locale.ENGLISH to prevent problems with some languages (e.g. Turkish). Removed some unused import statements. (#4634).

This commit is contained in:
LevelX2 2018-03-18 18:18:54 +01:00
parent 03ebdc17d8
commit b073ce1c42
147 changed files with 1419 additions and 1496 deletions

View file

@ -28,7 +28,6 @@
package mage.abilities;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.UUID;

View file

@ -27,6 +27,7 @@
*/
package mage.abilities;
import java.util.Locale;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.effects.Effect;
@ -124,7 +125,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
String superRule = super.getRule(true);
StringBuilder sb = new StringBuilder();
if (!superRule.isEmpty()) {
String ruleLow = superRule.toLowerCase();
String ruleLow = superRule.toLowerCase(Locale.ENGLISH);
if (isOptional()) {
if (ruleLow.startsWith("you ")) {
if (!ruleLow.startsWith("you may")) {

View file

@ -30,7 +30,6 @@ package mage.abilities.abilityword;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.common;
import java.util.Locale;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.AttachmentType;
@ -88,7 +89,7 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
StringBuilder sb = new StringBuilder("Whenever ");
sb.append(attachmentType.verb().toLowerCase());
sb.append(attachmentType.verb().toLowerCase(Locale.ENGLISH));
return sb.append(" creature attacks, ").append(super.getRule()).toString();
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.common;
import java.util.Locale;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.condition.Condition;
import mage.abilities.effects.Effect;
@ -129,9 +130,9 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
public String getRule() {
StringBuilder sb = new StringBuilder(getEffects().getText(modes.getMode()));
if (this.optional) {
if (sb.substring(0, 6).toLowerCase().equals("target")) {
if (sb.substring(0, 6).toLowerCase(Locale.ENGLISH).equals("target")) {
sb.insert(0, "you may have ");
} else if (!sb.substring(0, 4).toLowerCase().equals("you ")) {
} else if (!sb.substring(0, 4).toLowerCase(Locale.ENGLISH).equals("you ")) {
sb.insert(0, "you may ");
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.common;
import java.util.Locale;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.TargetController;
@ -141,9 +142,9 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
switch (targetController) {
case YOU:
if (this.optional) {
if (sb.substring(0, 6).toLowerCase().equals("target")) {
if (sb.substring(0, 6).toLowerCase(Locale.ENGLISH).equals("target")) {
sb.insert(0, "you may have ");
} else if (!sb.substring(0, 4).toLowerCase().equals("you ")) {
} else if (!sb.substring(0, 4).toLowerCase(Locale.ENGLISH).equals("you ")) {
sb.insert(0, "you may ");
}
}

View file

@ -29,7 +29,6 @@ package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.CardType;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -30,7 +30,6 @@ package mage.abilities.common;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;

View file

@ -31,9 +31,6 @@ import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.players.Player;
import java.util.Map;
import java.util.UUID;
/**

View file

@ -28,7 +28,6 @@
package mage.abilities.condition.common;
import java.util.EnumSet;
import java.util.HashSet;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.cards.Card;

View file

@ -30,7 +30,6 @@ package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.CardType;
import mage.game.Game;
import mage.game.permanent.Permanent;

View file

@ -4,7 +4,6 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.CardType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;

View file

@ -28,7 +28,6 @@
package mage.abilities.condition.common;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import mage.constants.TurnPhase;

View file

@ -30,7 +30,6 @@ package mage.abilities.condition.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.CardType;
import mage.game.Game;
/**

View file

@ -10,7 +10,6 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;

View file

@ -36,7 +36,6 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.game.Game;
import mage.players.Player;

View file

@ -36,7 +36,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*

View file

@ -30,7 +30,6 @@ package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -1,5 +1,6 @@
package mage.abilities.effects.common;
import java.util.Locale;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -88,8 +89,7 @@ public class DoIfCostPaid extends OneShotEffect {
}
}
player.resetStoredBookmark(game); // otherwise you can e.g. undo card drawn with Mentor of the Meek
}
else if (!otherwiseEffects.isEmpty()) {
} else if (!otherwiseEffects.isEmpty()) {
for (Effect effect : otherwiseEffects) {
effect.setTargetPointer(this.targetPointer);
if (effect instanceof OneShotEffect) {
@ -99,8 +99,7 @@ public class DoIfCostPaid extends OneShotEffect {
}
}
}
}
else if (!otherwiseEffects.isEmpty()) {
} else if (!otherwiseEffects.isEmpty()) {
for (Effect effect : otherwiseEffects) {
effect.setTargetPointer(this.targetPointer);
if (effect instanceof OneShotEffect) {
@ -135,12 +134,12 @@ public class DoIfCostPaid extends OneShotEffect {
StringBuilder sb = new StringBuilder();
String costText = cost.getText();
if (costText != null
&& !costText.toLowerCase().startsWith("put")
&& !costText.toLowerCase().startsWith("exile")
&& !costText.toLowerCase().startsWith("discard")
&& !costText.toLowerCase().startsWith("sacrifice")
&& !costText.toLowerCase().startsWith("remove")
&& !costText.toLowerCase().startsWith("pay")) {
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("put")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("exile")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("discard")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("remove")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("pay")) {
sb.append("pay ");
}
return sb.append(costText).toString();

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common;
import java.util.Locale;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
@ -77,7 +78,7 @@ public class EnterBattlefieldPayCostOrPutGraveyardEffect extends ReplacementEffe
boolean replace = true;
if (cost.canPay(source, source.getSourceId(), player.getId(), game)) {
if (player.chooseUse(outcome,
cost.getText().substring(0, 1).toUpperCase() + cost.getText().substring(1)
cost.getText().substring(0, 1).toUpperCase(Locale.ENGLISH) + cost.getText().substring(1)
+ "? (otherwise " + sourceObject.getLogName() + " is put into graveyard)", source, game)) {
cost.clearPaid();
replace = !cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null);

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -106,6 +107,6 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
}
private void setText() {
staticText = "target player exiles " + CardUtil.numberToText(amount, "a") + ' ' + filter.getMessage() + " from his or her " + zone.toString().toLowerCase();
staticText = "target player exiles " + CardUtil.numberToText(amount, "a") + ' ' + filter.getMessage() + " from his or her " + zone.toString().toLowerCase(Locale.ENGLISH);
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common;
import java.util.Locale;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.Cost;
@ -38,7 +39,7 @@ import mage.players.Player;
import mage.util.CardUtil;
/**
*
*
* @author fireshoes
*/
public class ExileSourceUnlessPaysEffect extends OneShotEffect {
@ -61,7 +62,7 @@ public class ExileSourceUnlessPaysEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourcePermanent != null) {
StringBuilder sb = new StringBuilder(cost.getText()).append('?');
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ")) {
if (!sb.toString().toLowerCase(Locale.ENGLISH).startsWith("exile ") && !sb.toString().toLowerCase(Locale.ENGLISH).startsWith("return ")) {
sb.insert(0, "Pay ");
}
String message = CardUtil.replaceSourceName(sb.toString(), sourcePermanent.getLogName());
@ -91,12 +92,12 @@ public class ExileSourceUnlessPaysEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder("exile {this} unless you ");
String costText = cost.getText();
if (costText.toLowerCase().startsWith("discard")
|| costText.toLowerCase().startsWith("remove")
|| costText.toLowerCase().startsWith("return")
|| costText.toLowerCase().startsWith("exile")
|| costText.toLowerCase().startsWith("sacrifice")) {
sb.append(costText.substring(0, 1).toLowerCase());
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("remove")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("return")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("exile")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
sb.append(costText.substring(1));
} else {
sb.append("pay ").append(costText);

View file

@ -31,7 +31,6 @@ import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;

View file

@ -30,7 +30,6 @@ package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.ExileZone;
import mage.game.Game;

View file

@ -30,6 +30,7 @@
package mage.abilities.effects.common;
import static java.lang.Integer.min;
import java.util.Locale;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
@ -291,7 +292,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
sb.append(" of them into your ");
}
sb.append(targetPickedCards.toString().toLowerCase());
sb.append(targetPickedCards.toString().toLowerCase(Locale.ENGLISH));
if (targetZoneLookedCards == Zone.LIBRARY) {
sb.append(". Put the rest ");

View file

@ -31,7 +31,6 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.PreventionEffectImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.events.GameEvent;

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,21 +20,20 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
@ -103,6 +102,6 @@ public class RegenerateAttachedEffect extends ReplacementEffectImpl {
}
private void setText() {
staticText = "Regenerate " + attachmentType.verb().toLowerCase() + " creature";
staticText = "Regenerate " + attachmentType.verb().toLowerCase(Locale.ENGLISH) + " creature";
}
}

View file

@ -25,14 +25,14 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.constants.Duration;
import mage.constants.Outcome;
import java.util.Locale;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -43,9 +43,9 @@ import mage.target.Target;
*
* @author maurer.it_at_gmail.com
*/
public class RegenerateTargetEffect extends ReplacementEffectImpl {
public class RegenerateTargetEffect extends ReplacementEffectImpl {
public RegenerateTargetEffect ( ) {
public RegenerateTargetEffect() {
super(Duration.EndOfTurn, Outcome.Regenerate);
}
@ -82,7 +82,7 @@ public class RegenerateTargetEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
//20110204 - 701.11c - event.getAmount() is used to signal if regeneration is allowed
return event.getAmount() == 0 && event.getTargetId().equals(targetPointer.getFirst(game, source)) && !this.used;
}
@ -95,7 +95,7 @@ public class RegenerateTargetEffect extends ReplacementEffectImpl {
sb.append("Regenerate ");
Target target = mode.getTargets().get(0);
if (target != null) {
if (!target.getTargetName().toLowerCase().startsWith("another")) {
if (!target.getTargetName().toLowerCase(Locale.ENGLISH).startsWith("another")) {
sb.append("target ");
}
sb.append(target.getTargetName());

View file

@ -5,7 +5,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -30,7 +30,6 @@ package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.abilities.effects.OneShotEffect;

View file

@ -1,5 +1,6 @@
package mage.abilities.effects.common;
import java.util.Locale;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.Cost;
@ -34,7 +35,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourcePermanent != null) {
StringBuilder sb = new StringBuilder(cost.getText()).append('?');
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ")) {
if (!sb.toString().toLowerCase(Locale.ENGLISH).startsWith("exile ") && !sb.toString().toLowerCase(Locale.ENGLISH).startsWith("return ")) {
sb.insert(0, "Pay ");
}
String message = CardUtil.replaceSourceName(sb.toString(), sourcePermanent.getLogName());
@ -69,13 +70,13 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
String costText = cost.getText();
if (costText.toLowerCase().startsWith("discard")
|| costText.toLowerCase().startsWith("remove")
|| costText.toLowerCase().startsWith("return")
|| costText.toLowerCase().startsWith("put")
|| costText.toLowerCase().startsWith("exile")
|| costText.toLowerCase().startsWith("sacrifice")) {
sb.append(costText.substring(0, 1).toLowerCase());
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("remove")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("return")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("put")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("exile")
|| costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
sb.append(costText.substring(1));
} else {
sb.append("pay ").append(costText);

View file

@ -25,15 +25,14 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common.combat;
import java.util.Locale;
import java.util.UUID;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RequirementEffect;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -51,7 +50,7 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
public MustBeBlockedByAllAttachedEffect(Duration duration, AttachmentType attachmentType) {
super(duration);
this.attachmentType = attachmentType;
staticText = "All creatures able to block " + attachmentType.verb().toLowerCase() + " creature do so";
staticText = "All creatures able to block " + attachmentType.verb().toLowerCase(Locale.ENGLISH) + " creature do so";
}
public MustBeBlockedByAllAttachedEffect(final MustBeBlockedByAllAttachedEffect effect) {

View file

@ -28,6 +28,7 @@
package mage.abilities.effects.common.continuous;
import java.util.ArrayList;
import java.util.Locale;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -104,7 +105,7 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
}
article = true;
}
sb.append(cardType.toString().toLowerCase()).append(" ");
sb.append(cardType.toString().toLowerCase(Locale.ENGLISH)).append(" ");
}
sb.append(" in addition to its other types ").append(this.getDuration().toString());
return sb.toString();

View file

@ -28,6 +28,7 @@
package mage.abilities.effects.common.continuous;
import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -110,7 +111,7 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
}
article = true;
}
sb.append(cardType.toString().toLowerCase()).append(" ");
sb.append(cardType.toString().toLowerCase(Locale.ENGLISH)).append(" ");
}
sb.append("in addition to its other types");
if (getDuration().equals(Duration.EndOfTurn)) {

View file

@ -27,13 +27,13 @@
*/
package mage.abilities.effects.common.continuous;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -126,7 +126,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
}
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ").append(target.getTargetName()).append(" get ");
} else {
if (!target.getTargetName().toUpperCase().startsWith("ANOTHER")) {
if (!target.getTargetName().toUpperCase(Locale.ENGLISH).startsWith("ANOTHER")) {
sb.append("target ");
}
sb.append(target.getTargetName()).append(" gets ");

View file

@ -29,6 +29,7 @@ package mage.abilities.effects.common.continuous;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
@ -180,12 +181,12 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
}
sb.append(filter.getMessage());
if (duration == Duration.WhileOnBattlefield) {
if (filter.getMessage().toLowerCase().startsWith("each")) {
if (filter.getMessage().toLowerCase(Locale.ENGLISH).startsWith("each")) {
sb.append(" has ");
} else {
sb.append(" have ");
}
} else if (filter.getMessage().toLowerCase().startsWith("each")) {
} else if (filter.getMessage().toLowerCase(Locale.ENGLISH).startsWith("each")) {
sb.append(" gains ");
} else {
sb.append(" gain ");

View file

@ -170,7 +170,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
}
sb.append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName()).append(" gain ");
} else {
if (!target.getTargetName().toUpperCase().startsWith("ANOTHER")) {
if (!target.getTargetName().toUpperCase(Locale.ENGLISH).startsWith("ANOTHER")) {
sb.append("target ");
}
sb.append(target.getTargetName()).append(" gains ");

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common.counter;
import java.util.Locale;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -69,7 +70,7 @@ public class AddCountersAllEffect extends OneShotEffect {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.addCounters(counter.copy(), source, game);
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName().toLowerCase()
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName().toLowerCase(Locale.ENGLISH)
+ " counter on " + permanent.getLogName());
}
}
@ -83,9 +84,9 @@ public class AddCountersAllEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder();
sb.append("put ");
if (counter.getCount() > 1) {
sb.append(CardUtil.numberToText(counter.getCount(), "a")).append(' ').append(counter.getName().toLowerCase()).append(" counters on each ");
sb.append(CardUtil.numberToText(counter.getCount(), "a")).append(' ').append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counters on each ");
} else {
sb.append("a ").append(counter.getName().toLowerCase()).append(" counter on each ");
sb.append("a ").append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter on each ");
}
sb.append(filter.getMessage());
staticText = sb.toString();

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common.counter;
import java.util.Locale;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
@ -41,7 +42,6 @@ import mage.util.CardUtil;
*
* @author LevelX2
*/
public class AddCountersAttachedEffect extends OneShotEffect {
private Counter counter;
@ -99,7 +99,7 @@ public class AddCountersAttachedEffect extends OneShotEffect {
} else {
sb.append("a ");
}
sb.append(counter.getName().toLowerCase()).append(" counter on ");
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter on ");
sb.append(textEnchanted);
if (!amount.getMessage().isEmpty()) {
sb.append(" for each ").append(amount.getMessage());

View file

@ -28,6 +28,7 @@
package mage.abilities.effects.common.counter;
import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
@ -110,7 +111,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
if (informPlayers && !game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getLogName() + " puts " + newCounter.getCount() + ' ' + newCounter.getName().toLowerCase() + " counter on " + card.getLogName());
game.informPlayers(player.getLogName() + " puts " + newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counter on " + card.getLogName());
}
}
}
@ -137,7 +138,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
int amountAdded = permanent.getCounters(game).getCount(newCounter.getName()) - before;
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getLogName() + " puts " + amountAdded + ' ' + newCounter.getName().toLowerCase() + " counter on " + permanent.getLogName());
game.informPlayers(player.getLogName() + " puts " + amountAdded + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counter on " + permanent.getLogName());
}
}
}
@ -161,7 +162,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
sb.append("a ");
plural = false;
}
sb.append(counter.getName().toLowerCase()).append(" counter");
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter");
if (plural) {
sb.append('s');
}

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common.counter;
import java.util.Locale;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
@ -102,7 +103,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
affectedTargets++;
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
+ numberAdded + ' ' + counter.getName().toLowerCase() + " counter on " + permanent.getLogName());
+ numberAdded + ' ' + counter.getName().toLowerCase(Locale.ENGLISH) + " counter on " + permanent.getLogName());
}
} else if (player != null) {
Counter newCounter = counter.copy();
@ -111,7 +112,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
affectedTargets++;
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
+ counter.getCount() + ' ' + counter.getName().toLowerCase() + " counter on " + player.getLogName());
+ counter.getCount() + ' ' + counter.getName().toLowerCase(Locale.ENGLISH) + " counter on " + player.getLogName());
}
} else if (card != null) {
card.addCounters(counter, source, game);
@ -140,7 +141,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
} else {
sb.append("a ");
}
sb.append(counter.getName().toLowerCase()).append(" counter");
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter");
if (counter.getCount() > 1) {
sb.append('s');
}

View file

@ -29,6 +29,7 @@ package mage.abilities.effects.common.counter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -98,7 +99,7 @@ public class AddRemoveAllTimeSuspentCountersEffect extends OneShotEffect {
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
.append(controller.getLogName()).append(actionStr)
.append(counter.getCount()).append(' ').append(counterName.toLowerCase())
.append(counter.getCount()).append(' ').append(counterName.toLowerCase(Locale.ENGLISH))
.append(" counter on ").append(card.getName()).toString());
}
}
@ -110,9 +111,9 @@ public class AddRemoveAllTimeSuspentCountersEffect extends OneShotEffect {
final String actionsStr2 = removeCounter ? "remove " : " put ";
sb.append(actionsStr2);
if (counter.getCount() > 1) {
sb.append(Integer.toString(counter.getCount())).append(' ').append(counter.getName().toLowerCase()).append(" counters on each ");
sb.append(Integer.toString(counter.getCount())).append(' ').append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counters on each ");
} else {
sb.append("a ").append(counter.getName().toLowerCase()).append(" counter on each ");
sb.append("a ").append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter on each ");
}
sb.append(filter.getMessage());
staticText = sb.toString();

View file

@ -30,7 +30,6 @@ package mage.abilities.effects.common.replacement;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;

View file

@ -36,7 +36,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;

View file

@ -36,7 +36,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;

View file

@ -31,7 +31,6 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;

View file

@ -32,7 +32,6 @@ import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;

View file

@ -29,6 +29,7 @@ package mage.abilities.keyword;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import mage.Mana;
import mage.ObjectColor;
@ -242,7 +243,7 @@ class ConvokeEffect extends OneShotEffect {
manaPool.addMana(Mana.ColorlessMana(1), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
}
manaName = chooseManaType.getChoice().toLowerCase();
manaName = chooseManaType.getChoice().toLowerCase(Locale.ENGLISH);
} else {
manaPool.addMana(Mana.ColorlessMana(1), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -209,8 +210,8 @@ class EchoEffect extends OneShotEffect {
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
String costText = cost.getText();
if (costText.toLowerCase().startsWith("discard")) {
sb.append(costText.substring(0, 1).toLowerCase());
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
sb.append(costText.substring(1));
} else {
sb.append("pay ").append(costText);

View file

@ -30,7 +30,6 @@ package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;

View file

@ -1,206 +1,205 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import java.util.HashSet;
import java.util.Set;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.BecomesExertSourceTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.Watcher;
/**
*
* @author LevelX2
*/
public class ExertAbility extends SimpleStaticAbility {
private String ruleText;
public ExertAbility(BecomesExertSourceTriggeredAbility ability) {
this(ability, false);
}
public ExertAbility(BecomesExertSourceTriggeredAbility ability, boolean exertOnlyOncePerTurn) {
super(Zone.BATTLEFIELD, new ExertReplacementEffect(exertOnlyOncePerTurn));
ruleText = (exertOnlyOncePerTurn
? "If {this} hasn't been exerted this turn, you may exert it"
: "You may exert {this}") + " as it attacks. ";
if (ability != null) {
this.addSubAbility(ability);
ruleText += "When you do,";
ability.getEffects().forEach(effect -> {
ruleText += " " + effect.getText(ability.getModes().getMode());
});
ruleText += ". ";
ability.setRuleVisible(false);
}
ruleText += "<i>(An exerted creature won't untap during your next untap step.)</i>";
if (exertOnlyOncePerTurn) {
getWatchers().add(new ExertedThisTurnWatcher());
}
}
public ExertAbility(final ExertAbility ability) {
super(ability);
this.ruleText = ability.ruleText;
}
@Override
public ExertAbility copy() {
return new ExertAbility(this);
}
@Override
public String getRule() {
return ruleText;
}
}
class ExertReplacementEffect extends ReplacementEffectImpl {
final private boolean exertOnlyOncePerTurn;
public ExertReplacementEffect(boolean exertOnlyOncePerTurn) {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "You may exert {this} as it attacks";
this.exertOnlyOncePerTurn = exertOnlyOncePerTurn;
}
public ExertReplacementEffect(ExertReplacementEffect effect) {
super(effect);
this.exertOnlyOncePerTurn = effect.exertOnlyOncePerTurn;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ATTACKER_DECLARED;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getSourceId().equals(source.getSourceId());
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanent(event.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
if (exertOnlyOncePerTurn) {
MageObjectReference creatureReference = new MageObjectReference(creature.getId(), creature.getZoneChangeCounter(game), game);
ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getSimpleName());
if (watcher != null && watcher.getExertedThisTurnCreatures().contains(creatureReference)) {
return false;
}
}
if (controller.chooseUse(outcome, "Exert " + creature.getLogName() + '?',
"An exerted creature won't untap during your next untap step.", "Yes", "No", source, game)) {
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " exerted " + creature.getName());
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BECOMES_EXERTED, creature.getId(), creature.getId(), creature.getControllerId()));
ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("", creature.getControllerId());
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
}
}
return false;
}
@Override
public String getText(Mode mode) {
return staticText;
}
@Override
public ExertReplacementEffect copy() {
return new ExertReplacementEffect(this);
}
}
class ExertedThisTurnWatcher extends Watcher {
private final Set<MageObjectReference> exertedThisTurnCreatures;
public ExertedThisTurnWatcher() {
super(ExertedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
exertedThisTurnCreatures = new HashSet<>();
}
public ExertedThisTurnWatcher(final ExertedThisTurnWatcher watcher) {
super(watcher);
exertedThisTurnCreatures = new HashSet<>(watcher.exertedThisTurnCreatures);
}
@Override
public Watcher copy() {
return new ExertedThisTurnWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.BECOMES_EXERTED) {
this.exertedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
}
}
public Set<MageObjectReference> getExertedThisTurnCreatures() {
return this.exertedThisTurnCreatures;
}
@Override
public void reset() {
super.reset();
exertedThisTurnCreatures.clear();
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import java.util.HashSet;
import java.util.Set;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.BecomesExertSourceTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.Watcher;
/**
*
* @author LevelX2
*/
public class ExertAbility extends SimpleStaticAbility {
private String ruleText;
public ExertAbility(BecomesExertSourceTriggeredAbility ability) {
this(ability, false);
}
public ExertAbility(BecomesExertSourceTriggeredAbility ability, boolean exertOnlyOncePerTurn) {
super(Zone.BATTLEFIELD, new ExertReplacementEffect(exertOnlyOncePerTurn));
ruleText = (exertOnlyOncePerTurn
? "If {this} hasn't been exerted this turn, you may exert it"
: "You may exert {this}") + " as it attacks. ";
if (ability != null) {
this.addSubAbility(ability);
ruleText += "When you do,";
ability.getEffects().forEach(effect -> {
ruleText += " " + effect.getText(ability.getModes().getMode());
});
ruleText += ". ";
ability.setRuleVisible(false);
}
ruleText += "<i>(An exerted creature won't untap during your next untap step.)</i>";
if (exertOnlyOncePerTurn) {
getWatchers().add(new ExertedThisTurnWatcher());
}
}
public ExertAbility(final ExertAbility ability) {
super(ability);
this.ruleText = ability.ruleText;
}
@Override
public ExertAbility copy() {
return new ExertAbility(this);
}
@Override
public String getRule() {
return ruleText;
}
}
class ExertReplacementEffect extends ReplacementEffectImpl {
final private boolean exertOnlyOncePerTurn;
public ExertReplacementEffect(boolean exertOnlyOncePerTurn) {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "You may exert {this} as it attacks";
this.exertOnlyOncePerTurn = exertOnlyOncePerTurn;
}
public ExertReplacementEffect(ExertReplacementEffect effect) {
super(effect);
this.exertOnlyOncePerTurn = effect.exertOnlyOncePerTurn;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ATTACKER_DECLARED;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getSourceId().equals(source.getSourceId());
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanent(event.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
if (exertOnlyOncePerTurn) {
MageObjectReference creatureReference = new MageObjectReference(creature.getId(), creature.getZoneChangeCounter(game), game);
ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getSimpleName());
if (watcher != null && watcher.getExertedThisTurnCreatures().contains(creatureReference)) {
return false;
}
}
if (controller.chooseUse(outcome, "Exert " + creature.getLogName() + '?',
"An exerted creature won't untap during your next untap step.", "Yes", "No", source, game)) {
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " exerted " + creature.getName());
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BECOMES_EXERTED, creature.getId(), creature.getId(), creature.getControllerId()));
ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("", creature.getControllerId());
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
}
}
return false;
}
@Override
public String getText(Mode mode) {
return staticText;
}
@Override
public ExertReplacementEffect copy() {
return new ExertReplacementEffect(this);
}
}
class ExertedThisTurnWatcher extends Watcher {
private final Set<MageObjectReference> exertedThisTurnCreatures;
public ExertedThisTurnWatcher() {
super(ExertedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
exertedThisTurnCreatures = new HashSet<>();
}
public ExertedThisTurnWatcher(final ExertedThisTurnWatcher watcher) {
super(watcher);
exertedThisTurnCreatures = new HashSet<>(watcher.exertedThisTurnCreatures);
}
@Override
public Watcher copy() {
return new ExertedThisTurnWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.BECOMES_EXERTED) {
this.exertedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
}
}
public Set<MageObjectReference> getExertedThisTurnCreatures() {
return this.exertedThisTurnCreatures;
}
@Override
public void reset() {
super.reset();
exertedThisTurnCreatures.clear();
}
}

View file

@ -35,7 +35,6 @@ import mage.abilities.common.ZoneChangeTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -4,7 +4,6 @@ import mage.abilities.Ability;
import mage.abilities.EvasionAbility;
import mage.abilities.MageSingleton;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;

View file

@ -35,7 +35,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSourceEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -30,7 +30,6 @@ package mage.abilities.keyword;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.keyword.SupportEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.target.common.TargetCreaturePermanent;

View file

@ -42,7 +42,6 @@ import mage.constants.Zone;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
*

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.constants.CardType;
import mage.game.Game;
/**

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.constants.CardType;
import mage.game.Game;
/**

View file

@ -10,7 +10,6 @@ import mage.constants.SpellAbilityType;
import mage.constants.Zone;
import mage.game.Game;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

View file

@ -27,10 +27,10 @@
*/
package mage.cards.decks.importer;
import mage.cards.decks.DeckCardLists;
import java.io.File;
import java.util.Locale;
import java.util.Scanner;
import mage.cards.decks.DeckCardLists;
/**
*
@ -40,7 +40,7 @@ public final class DeckImporterUtil {
public static final String[] SIDEBOARD_MARKS = new String[]{"//sideboard", "sb: "};
public static boolean haveSideboardSection(String file){
public static boolean haveSideboardSection(String file) {
// search for sideboard section:
// or //sideboard
// or SB: 1 card name -- special deckstats.net
@ -48,10 +48,10 @@ public final class DeckImporterUtil {
File f = new File(file);
try (Scanner scanner = new Scanner(f)) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim().toLowerCase();
String line = scanner.nextLine().trim().toLowerCase(Locale.ENGLISH);
for(String mark: SIDEBOARD_MARKS){
if (line.startsWith(mark)){
for (String mark : SIDEBOARD_MARKS) {
if (line.startsWith(mark)) {
return true;
}
}
@ -65,15 +65,15 @@ public final class DeckImporterUtil {
}
public static DeckImporter getDeckImporter(String file) {
if (file.toLowerCase().endsWith("dec")) {
if (file.toLowerCase(Locale.ENGLISH).endsWith("dec")) {
return new DecDeckImporter();
} else if (file.toLowerCase().endsWith("mwdeck")) {
} else if (file.toLowerCase(Locale.ENGLISH).endsWith("mwdeck")) {
return new MWSDeckImporter();
} else if (file.toLowerCase().endsWith("txt")) {
} else if (file.toLowerCase(Locale.ENGLISH).endsWith("txt")) {
return new TxtDeckImporter(haveSideboardSection(file));
} else if (file.toLowerCase().endsWith("dck")) {
} else if (file.toLowerCase(Locale.ENGLISH).endsWith("dck")) {
return new DckDeckImporter();
} else if (file.toLowerCase().endsWith("dek")) {
} else if (file.toLowerCase(Locale.ENGLISH).endsWith("dek")) {
return new DekDeckImporter();
} else {
return null;

View file

@ -27,15 +27,15 @@
*/
package mage.cards.decks.importer;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author BetaSteward_at_googlemail.com
@ -50,8 +50,8 @@ public class TxtDeckImporter extends DeckImporter {
private boolean switchSideboardByEmptyLine = true; // all cards after first empty line will be sideboard (like mtgo format)
private int nonEmptyLinesTotal = 0;
public TxtDeckImporter(boolean haveSideboardSection){
if(haveSideboardSection){
public TxtDeckImporter(boolean haveSideboardSection) {
if (haveSideboardSection) {
switchSideboardByEmptyLine = false;
}
}
@ -63,8 +63,8 @@ public class TxtDeckImporter extends DeckImporter {
// process comment:
// skip or force to sideboard
String commentString = line.toLowerCase();
if (commentString.startsWith("//")){
String commentString = line.toLowerCase(Locale.ENGLISH);
if (commentString.startsWith("//")) {
// use start, not contains (card names may contain commands like "Legerdemain")
if (commentString.startsWith("//sideboard")) {
@ -77,15 +77,15 @@ public class TxtDeckImporter extends DeckImporter {
// remove inner card comments from text line: 2 Blinding Fog #some text (like deckstats format)
int commentDelim = line.indexOf('#');
if(commentDelim >= 0){
if (commentDelim >= 0) {
line = line.substring(0, commentDelim).trim();
}
// switch sideboard by empty line
if (switchSideboardByEmptyLine && line.isEmpty() && nonEmptyLinesTotal > 0) {
if(!sideboard){
if (!sideboard) {
sideboard = true;
}else{
} else {
sbMessage.append("Found empty line at ").append(lineCount).append(", but sideboard already used. Use //sideboard switcher OR one empty line to devide your cards.").append('\n');
}
@ -98,9 +98,9 @@ public class TxtDeckImporter extends DeckImporter {
// single line sideboard card from deckstats.net
// SB: 3 Carnage Tyrant
boolean singleLineSideBoard = false;
if (line.startsWith("SB:")){
line = line.replace("SB:", "").trim();
singleLineSideBoard = true;
if (line.startsWith("SB:")) {
line = line.replace("SB:", "").trim();
singleLineSideBoard = true;
}
line = line.replace("\t", " "); // changing tabs to blanks as delimiter
@ -122,7 +122,7 @@ public class TxtDeckImporter extends DeckImporter {
}
try {
int num = Integer.parseInt(lineNum.replaceAll("\\D+", ""));
if ((num < 0) || (num > 100)){
if ((num < 0) || (num > 100)) {
sbMessage.append("Invalid number (too small or too big): ").append(lineNum).append(" at line ").append(lineCount).append('\n');
return;
}

View file

@ -7,7 +7,6 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.cards.CardImpl;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.CardType;
import org.apache.log4j.Logger;
/**

View file

@ -397,7 +397,7 @@ public enum CardRepository {
public List<CardInfo> findCardsCaseInsensitive(String name) {
try {
String sqlName = name.toLowerCase().replaceAll("\'", "\'\'");
String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("\'", "\'\'");
GenericRawResults<CardInfo> rawResults = cardDao.queryRaw(
"select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'',
cardDao.getRawRowMapper());

View file

@ -32,8 +32,6 @@ import mage.Mana;
import mage.ObjectColor;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
/**
*

View file

@ -1,7 +1,5 @@
package mage.constants;
import mage.game.turn.Phase;
/**
*
* @author North

View file

@ -28,6 +28,7 @@
package mage.filter.predicate.other;
import java.util.HashMap;
import java.util.Locale;
import mage.cards.Card;
import mage.cards.SplitCard;
import mage.constants.SubType;
@ -70,7 +71,7 @@ public class CardTextPredicate implements Predicate<Card> {
}
// first check in card name
if (inNames && input.getName().toLowerCase().contains(text.toLowerCase())) {
if (inNames && input.getName().toLowerCase(Locale.ENGLISH).contains(text.toLowerCase(Locale.ENGLISH))) {
if (isUnique && seenCards.keySet().contains(input.getName())) {
return false;
}
@ -81,7 +82,7 @@ public class CardTextPredicate implements Predicate<Card> {
}
//separate by spaces
String[] tokens = text.toLowerCase().split(" ");
String[] tokens = text.toLowerCase(Locale.ENGLISH).split(" ");
for (String token : tokens) {
boolean found = false;
if (!token.isEmpty()) {
@ -89,20 +90,20 @@ public class CardTextPredicate implements Predicate<Card> {
if (inRules) {
if (input.isSplitCard()) {
for (String rule : ((SplitCard) input).getLeftHalfCard().getRules(game)) {
if (rule.toLowerCase().contains(token)) {
if (rule.toLowerCase(Locale.ENGLISH).contains(token)) {
found = true;
break;
}
}
for (String rule : ((SplitCard) input).getRightHalfCard().getRules(game)) {
if (rule.toLowerCase().contains(token)) {
if (rule.toLowerCase(Locale.ENGLISH).contains(token)) {
found = true;
break;
}
}
}
for (String rule : input.getRules(game)) {
if (rule.toLowerCase().contains(token)) {
if (rule.toLowerCase(Locale.ENGLISH).contains(token)) {
found = true;
break;
}

View file

@ -5,7 +5,6 @@
*/
package mage.filter.predicate.permanent;
import mage.constants.CardType;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.permanent.Permanent;

View file

@ -28,7 +28,6 @@
package mage.filter.predicate.permanent;
import java.util.UUID;
import mage.constants.CardType;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.permanent.Permanent;

View file

@ -29,7 +29,6 @@ package mage.game.combat;
import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.RequirementEffect;

View file

@ -27,7 +27,6 @@
*/
package mage.game.command;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;

View file

@ -28,9 +28,6 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -28,9 +28,6 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -28,9 +28,6 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -28,9 +28,6 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -28,9 +28,6 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -31,11 +31,6 @@ package mage.game.permanent.token;
import mage.MageInt;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.util.RandomUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Stravant

View file

@ -27,9 +27,6 @@
*/
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -28,12 +28,8 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;
/**
*

View file

@ -28,9 +28,6 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;

View file

@ -30,7 +30,6 @@ package mage.game.permanent.token;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;
import mage.abilities.keyword.TrampleAbility;
/**
*

View file

@ -27,6 +27,10 @@
*/
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectImpl;
import mage.ObjectColor;
@ -45,10 +49,6 @@ import mage.players.Player;
import mage.util.RandomUtil;
import mage.util.SubTypeList;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class Token extends MageObjectImpl {
protected String description;
@ -134,7 +134,7 @@ public class Token extends MageObjectImpl {
String cardType = this.cardType.toString().replaceAll("[^a-zA-Z0-9]", "");
String originalset = this.getOriginalExpansionSetCode();
String descriptor = name + '.' + color + '.' + subtype + '.' + cardType + '.' + this.power + '.' + this.toughness;
descriptor = descriptor.toUpperCase();
descriptor = descriptor.toUpperCase(Locale.ENGLISH);
return descriptor;
}

View file

@ -38,7 +38,6 @@ import mage.game.events.*;
import mage.game.events.TableEvent.EventType;
import mage.game.match.Match;
import mage.game.match.MatchPlayer;
import mage.game.result.ResultProtos.*;
import mage.game.result.ResultProtos.MatchPlayerProto;
import mage.game.result.ResultProtos.MatchProto;
import mage.game.result.ResultProtos.MatchQuitStatus;

View file

@ -31,7 +31,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -30,7 +30,6 @@ package mage.watchers.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;