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

@ -201,7 +201,7 @@ public class BattlefieldThaumaturgeTest extends CardTestPlayerBase {
* For each creature destroyed this way, its controller puts a 4/4 red Dragon creature token with flying onto the battlefield.
* Battlefield Thaumaturge should reduce the cost of the spell when cast, before he is destroyed and replaced with a dragon.
*/
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Descent of the Dragons", createTargetingString(playerACreatures) + "^" + createTargetingString(playerBCreatures));
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Descent of the Dragons", createTargetingString(playerACreatures) + '^' + createTargetingString(playerBCreatures));
setStopAt(1, PhaseStep.END_TURN);
execute();

View file

@ -200,7 +200,7 @@ public class RandomPlayer extends ComputerPlayer {
StringBuilder binary = new StringBuilder();
binary.append(Integer.toBinaryString(value));
while (binary.length() < attackersList.size()) {
binary.insert(0, "0"); //pad with zeros
binary.insert(0, '0'); //pad with zeros
}
for (int i = 0; i < attackersList.size(); i++) {
if (binary.charAt(i) == '1') {

View file

@ -491,7 +491,7 @@ public class TestPlayer implements Player {
if (numberOfActions == actions.size()) {
foundNoAction++;
if (foundNoAction > maxCallsWithoutAction) {
throw new AssertionError("More priority calls to " + getName() + " and doing no action than allowed (" + maxCallsWithoutAction + ")");
throw new AssertionError("More priority calls to " + getName() + " and doing no action than allowed (" + maxCallsWithoutAction + ')');
}
} else {
foundNoAction = 0;
@ -671,7 +671,7 @@ public class TestPlayer implements Player {
break;
}
}
} else if ((permanent.getName() + "-" + permanent.getExpansionSetCode()).equals(targetName)) {
} else if ((permanent.getName() + '-' + permanent.getExpansionSetCode()).equals(targetName)) {
if (target.isNotTarget() || ((TargetPermanent) target).canTarget(computerPlayer.getId(), permanent.getId(), source, game)) {
if ((permanent.isCopy() && !originOnly) || (!permanent.isCopy() && !copyOnly)) {
target.add(permanent.getId(), game);
@ -816,7 +816,7 @@ public class TestPlayer implements Player {
filter = ((FilterCreatureOrPlayer) filter).getCreatureFilter();
}
for (Permanent permanent : game.getBattlefield().getAllActivePermanents((FilterPermanent) filter, game)) {
if (permanent.getName().equals(targetName) || (permanent.getName() + "-" + permanent.getExpansionSetCode()).equals(targetName)) {
if (permanent.getName().equals(targetName) || (permanent.getName() + '-' + permanent.getExpansionSetCode()).equals(targetName)) {
if (target.canTarget(abilityControllerId, permanent.getId(), source, game) && !target.getTargets().contains(permanent.getId())) {
if ((permanent.isCopy() && !originOnly) || (!permanent.isCopy() && !copyOnly)) {
target.add(permanent.getId(), game);
@ -841,7 +841,7 @@ public class TestPlayer implements Player {
boolean targetFound = false;
for (String targetName : targetList) {
for (Card card : computerPlayer.getHand().getCards(((TargetCardInHand) target).getFilter(), game)) {
if (card.getName().equals(targetName) || (card.getName() + "-" + card.getExpansionSetCode()).equals(targetName)) {
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
if (((TargetCardInHand) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
target.add(card.getId(), game);
targetFound = true;
@ -863,7 +863,7 @@ public class TestPlayer implements Player {
boolean targetFound = false;
for (String targetName : targetList) {
for (Card card : computerPlayer.getGraveyard().getCards(((TargetCardInYourGraveyard) target).getFilter(), game)) {
if (card.getName().equals(targetName) || (card.getName() + "-" + card.getExpansionSetCode()).equals(targetName)) {
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
if (((TargetCardInYourGraveyard) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
target.add(card.getId(), game);
targetFound = true;
@ -890,7 +890,7 @@ public class TestPlayer implements Player {
if (computerPlayer.hasOpponent(opponentId, game)) {
Player opponent = game.getPlayer(opponentId);
for (Card card : opponent.getGraveyard().getCards(((TargetCardInOpponentsGraveyard) target).getFilter(), game)) {
if (card.getName().equals(targetName) || (card.getName() + "-" + card.getExpansionSetCode()).equals(targetName)) {
if (card.getName().equals(targetName) || (card.getName() + '-' + card.getExpansionSetCode()).equals(targetName)) {
if (((TargetCardInOpponentsGraveyard) target).canTarget(abilityControllerId, card.getId(), source, game) && !target.getTargets().contains(card.getId())) {
target.add(card.getId(), game);
targetFound = true;

View file

@ -120,7 +120,7 @@ public abstract class MageTestBase {
private static Class<?> loadPlugin(Plugin plugin) {
try {
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL());
logger.info("Loading plugin: " + plugin.getClassName());
return Class.forName(plugin.getClassName(), true, classLoader);
} catch (ClassNotFoundException ex) {
@ -133,7 +133,7 @@ public abstract class MageTestBase {
private static MatchType loadGameType(GamePlugin plugin) {
try {
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL());
logger.info("Loading game type: " + plugin.getClassName());
return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
} catch (ClassNotFoundException ex) {
@ -146,7 +146,7 @@ public abstract class MageTestBase {
private static TournamentType loadTournamentType(GamePlugin plugin) {
try {
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL());
logger.info("Loading tournament type: " + plugin.getClassName());
return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
} catch (ClassNotFoundException ex) {

View file

@ -106,7 +106,7 @@ public abstract class MageTestPlayerBase {
private static Class<?> loadPlugin(Plugin plugin) {
try {
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL());
logger.info("Loading plugin: " + plugin.getClassName());
return Class.forName(plugin.getClassName(), true, classLoader);
} catch (ClassNotFoundException ex) {
@ -119,7 +119,7 @@ public abstract class MageTestPlayerBase {
private static MatchType loadGameType(GamePlugin plugin) {
try {
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL());
logger.info("Loading game type: " + plugin.getClassName());
return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
} catch (ClassNotFoundException ex) {
@ -132,7 +132,7 @@ public abstract class MageTestPlayerBase {
private static TournamentType loadTournamentType(GamePlugin plugin) {
try {
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL());
logger.info("Loading tournament type: " + plugin.getClassName());
return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
} catch (ClassNotFoundException ex) {

View file

@ -290,9 +290,9 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
if (permanent.getName().equals(cardName)) {
count++;
if (scope.equals(Filter.ComparisonScope.All)) {
Assert.assertEquals("Power is not the same (" + power + " vs. " + permanent.getPower().getValue() + ")",
Assert.assertEquals("Power is not the same (" + power + " vs. " + permanent.getPower().getValue() + ')',
power, permanent.getPower().getValue());
Assert.assertEquals("Toughness is not the same (" + toughness + " vs. " + permanent.getToughness().getValue() + ")",
Assert.assertEquals("Toughness is not the same (" + toughness + " vs. " + permanent.getToughness().getValue() + ')',
toughness, permanent.getToughness().getValue());
} else if (scope.equals(Filter.ComparisonScope.Any)) {
if (power == permanent.getPower().getValue() && toughness == permanent.getToughness().getValue()) {
@ -372,7 +372,7 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
}
}
}
Assert.assertEquals("(Battlefield) Card counts are not equal (" + cardName + ")", count, actualCount);
Assert.assertEquals("(Battlefield) Card counts are not equal (" + cardName + ')', count, actualCount);
}
public Permanent getPermanent(String cardName, UUID controller) {
@ -387,7 +387,7 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
}
}
Assert.assertNotNull("Couldn't find a card with specified name: " + cardName, permanent0);
Assert.assertEquals("More than one permanent was found: " + cardName + "(" + count + ")", 1, count);
Assert.assertEquals("More than one permanent was found: " + cardName + '(' + count + ')', 1, count);
return permanent0;
}

View file

@ -446,9 +446,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
if (permanent.getName().equals(cardName) && permanent.getControllerId().equals(player.getId())) {
count++;
if (scope.equals(Filter.ComparisonScope.All)) {
Assert.assertEquals("Power is not the same (" + power + " vs. " + permanent.getPower().getValue() + ")",
Assert.assertEquals("Power is not the same (" + power + " vs. " + permanent.getPower().getValue() + ')',
power, permanent.getPower().getValue());
Assert.assertEquals("Toughness is not the same (" + toughness + " vs. " + permanent.getToughness().getValue() + ")",
Assert.assertEquals("Toughness is not the same (" + toughness + " vs. " + permanent.getToughness().getValue() + ')',
toughness, permanent.getToughness().getValue());
} else if (scope.equals(Filter.ComparisonScope.Any)) {
if (power == permanent.getPower().getValue() && toughness == permanent.getToughness().getValue()) {
@ -466,8 +466,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
+ ", cardName=" + cardName, count > 0);
if (scope.equals(Filter.ComparisonScope.Any)) {
Assert.assertTrue("There is no such creature under player's control with specified p/t of " + power + "/" + toughness + ", player=" + player.getName()
+ ", cardName=" + cardName + " (found similar: " + found + ", one of them: power=" + foundPower + " toughness=" + foundToughness + ")", fit > 0);
Assert.assertTrue("There is no such creature under player's control with specified p/t of " + power + '/' + toughness + ", player=" + player.getName()
+ ", cardName=" + cardName + " (found similar: " + found + ", one of them: power=" + foundPower + " toughness=" + foundToughness + ')', fit > 0);
}
}
@ -584,7 +584,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
}
Assert.assertEquals("(Battlefield) Permanents counts for " + player.getName() + " are not equal (" + cardName + ")", count, actualCount);
Assert.assertEquals("(Battlefield) Permanents counts for " + player.getName() + " are not equal (" + cardName + ')', count, actualCount);
}
@Override
@ -595,7 +595,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
actualCount++;
}
}
Assert.assertEquals("(Command Zone) Card counts are not equal (" + commandZoneObjectName + ")", count, actualCount);
Assert.assertEquals("(Command Zone) Card counts are not equal (" + commandZoneObjectName + ')', count, actualCount);
}
/**
@ -636,7 +636,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
Assert.assertNotNull("There is no such permanent " + (player == null ? "" : "for player " + player.getName()) + " on the battlefield, cardName=" + cardName, found);
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + cardName + ":" + type + ")", count, found.getCounters(currentGame).getCount(type));
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + cardName + ':' + type + ')', count, found.getCounters(currentGame).getCount(type));
}
/**
@ -659,7 +659,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
Assert.assertNotNull("There is no such card in the exile, cardName=" + cardName, found);
Assert.assertEquals("(Exile) Counter counts are not equal (" + cardName + ":" + type + ")", count, found.getCounters(currentGame).getCount(type));
Assert.assertEquals("(Exile) Counter counts are not equal (" + cardName + ':' + type + ')', count, found.getCounters(currentGame).getCount(type));
}
/**
@ -670,7 +670,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertCounterCount(Player player, CounterType type, int count) throws AssertionError {
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + player.getName() + ":" + type + ")", count, player.getCounters().getCount(type));
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + player.getName() + ':' + type + ')', count, player.getCounters().getCount(type));
}
/**
@ -691,7 +691,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ":" + type + ")", (found.getCardType().contains(type) == flag));
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', (found.getCardType().contains(type) == flag));
}
@ -713,9 +713,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ":" + type + ")", found.getCardType().contains(type));
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType().contains(type));
if (subType != null) {
Assert.assertTrue("(Battlefield) card sub-type not equal (" + cardName + ":" + subType + ")", found.getSubtype(currentGame).contains(subType));
Assert.assertTrue("(Battlefield) card sub-type not equal (" + cardName + ':' + subType + ')', found.getSubtype(currentGame).contains(subType));
}
}
@ -740,7 +740,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
Assert.assertEquals("(Battlefield) Tapped state is not equal (" + cardName + ")", tapped, found.isTapped());
Assert.assertEquals("(Battlefield) Tapped state is not equal (" + cardName + ')', tapped, found.isTapped());
}
/**
@ -781,7 +781,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
Assert.assertEquals("(Battlefield) Attacking state is not equal (" + cardName + ")", attacking, found.isAttacking());
Assert.assertEquals("(Battlefield) Attacking state is not equal (" + cardName + ')', attacking, found.isAttacking());
}
/**
@ -836,7 +836,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
Assert.assertEquals("(Exile) Card counts are not equal (" + cardName + ")", count, actualCount);
Assert.assertEquals("(Exile) Card counts are not equal (" + cardName + ')', count, actualCount);
}
/**
@ -873,7 +873,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
Assert.assertEquals("(Graveyard " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount);
Assert.assertEquals("(Graveyard " + player.getName() + ") Card counts are not equal (" + cardName + ')', count, actualCount);
}
/**
@ -904,7 +904,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
Assert.assertEquals("(Library " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount);
Assert.assertEquals("(Library " + player.getName() + ") Card counts are not equal (" + cardName + ')', count, actualCount);
}
/**
@ -938,7 +938,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
Assert.assertNotNull("Couldn't find a card with specified name: " + cardName, permanent0);
Assert.assertEquals("More than one permanent was found: " + cardName + "(" + count + ")", 1, count);
Assert.assertEquals("More than one permanent was found: " + cardName + '(' + count + ')', 1, count);
return permanent0;
}
@ -1021,11 +1021,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack, StackClause clause) {
if (StackClause.WHILE_ON_STACK.equals(clause)) {
player.addAction(turnNum, step, "activate:Cast " + cardName
+ "$" + (targetName != null && targetName.startsWith("target") ? targetName : "target=" + targetName)
+ '$' + (targetName != null && targetName.startsWith("target") ? targetName : "target=" + targetName)
+ "$spellOnStack=" + spellOnStack);
} else {
player.addAction(turnNum, step, "activate:Cast " + cardName
+ "$" + (targetName != null && targetName.startsWith("target") ? targetName : "target=" + targetName)
+ '$' + (targetName != null && targetName.startsWith("target") ? targetName : "target=" + targetName)
+ "$!spellOnStack=" + spellOnStack);
}
}
@ -1077,13 +1077,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
sb.append("$target=").append(targetName);
}
if (spellOnStack != null && !spellOnStack.isEmpty()) {
sb.append("$").append(StackClause.WHILE_ON_STACK.equals(clause) ? "" : "!").append("spellOnStack=").append(spellOnStack);
sb.append('$').append(StackClause.WHILE_ON_STACK.equals(clause) ? "" : "!").append("spellOnStack=").append(spellOnStack);
}
player.addAction(turnNum, step, sb.toString());
}
public void addCounters(int turnNum, PhaseStep step, TestPlayer player, String cardName, CounterType type, int count) {
player.addAction(turnNum, step, "addCounters:" + cardName + "$" + type.getName() + "$" + count);
player.addAction(turnNum, step, "addCounters:" + cardName + '$' + type.getName() + '$' + count);
}
public void attack(int turnNum, TestPlayer player, String attacker) {
@ -1099,7 +1099,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void block(int turnNum, TestPlayer player, String blocker, String attacker) {
player.addAction(turnNum, PhaseStep.DECLARE_BLOCKERS, "block:" + blocker + "$" + attacker);
player.addAction(turnNum, PhaseStep.DECLARE_BLOCKERS, "block:" + blocker + '$' + attacker);
}
/**

View file

@ -77,7 +77,7 @@ public class BoosterGenerationTest extends MageTestBase {
sb.append(", ");
}
}
sb.append("] (").append(cards.size()).append(")");
sb.append("] (").append(cards.size()).append(')');
return sb.toString();
}