Merge pull request #3007 from kubikrubikvkube/master

Enums should be compared with == but not equals()
This commit is contained in:
Derek M 2017-03-22 16:17:07 -04:00 committed by GitHub
commit cf831eea28
180 changed files with 361 additions and 357 deletions

View file

@ -137,7 +137,7 @@ public class DependentEffectsTest extends CardTestPlayerBase {
Permanent necroticOoze = getPermanent("Necrotic Ooze", playerA);
int numberOfActivatedAbilities = 0;
for (Ability ability : necroticOoze.getAbilities(currentGame)) {
if (ability.getAbilityType().equals(AbilityType.ACTIVATED)) {
if (ability.getAbilityType() == AbilityType.ACTIVATED) {
numberOfActivatedAbilities++;
}
}
@ -166,7 +166,7 @@ public class DependentEffectsTest extends CardTestPlayerBase {
Permanent necroticOoze = getPermanent("Necrotic Ooze", playerA);
int numberOfActivatedAbilities = 0;
for (Ability ability : necroticOoze.getAbilities(currentGame)) {
if (ability.getAbilityType().equals(AbilityType.ACTIVATED)) {
if (ability.getAbilityType() == AbilityType.ACTIVATED) {
numberOfActivatedAbilities++;
}
}

View file

@ -38,7 +38,7 @@ public class DivergentTransformationsTest extends CardTestPlayerBase {
addCard(Zone.LIBRARY, playerA, hGiant);
addCard(Zone.LIBRARY, playerB, mFlunkies);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, dTransformations, memnite + "^" + gBears);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, dTransformations, memnite + '^' + gBears);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();

View file

@ -236,7 +236,7 @@ public class TestPlayer implements Player {
if (group.startsWith("spell") || group.startsWith("!spell") || group.startsWith("target=null") || group.startsWith("manaInPool=")) {
break;
}
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
if (group.contains("FuseLeft-")) {
result = handleTargetString(group.substring(group.indexOf("FuseLeft-") + 9), ability, game);
} else if (group.startsWith("FuseRight-")) {

View file

@ -192,7 +192,7 @@ public abstract class MageTestBase {
}
private void parseLine(String line) {
if (parserState.equals(ParserState.EXPECTED)) {
if (parserState == ParserState.EXPECTED) {
expectedResults.add(line); // just remember for future use
return;
}
@ -248,7 +248,7 @@ public abstract class MageTestBase {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card card = cardInfo != null ? cardInfo.getCard() : null;
if (card != null) {
if (gameZone.equals(Zone.BATTLEFIELD)) {
if (gameZone == Zone.BATTLEFIELD) {
PermanentCard p = new PermanentCard(card, null, currentGame);
p.setTapped(tapped);
perms.add(p);

View file

@ -178,7 +178,7 @@ public abstract class MageTestPlayerBase {
}
private void parseLine(String line) {
if (parserState.equals(ParserState.EXPECTED)) {
if (parserState == ParserState.EXPECTED) {
expectedResults.add(line); // just remember for future use
return;
}
@ -226,7 +226,7 @@ public abstract class MageTestPlayerBase {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card card = cardInfo != null ? cardInfo.getCard() : null;
if (card != null) {
if (gameZone.equals(Zone.BATTLEFIELD)) {
if (gameZone == Zone.BATTLEFIELD) {
PermanentCard p = new PermanentCard(card, null, currentGame);
p.setTapped(tapped);
perms.add(p);

View file

@ -121,7 +121,7 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
public void addCard(Zone gameZone, TestPlayer player, String cardName, int count, boolean tapped) {
if (gameZone.equals(Zone.BATTLEFIELD)) {
if (gameZone == Zone.BATTLEFIELD) {
for (int i = 0; i < count; i++) {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card card = cardInfo != null ? cardInfo.getCard() : null;
@ -158,19 +158,19 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
*/
private List<Card> getCardList(Zone gameZone, Player player) {
if (player.equals(playerA)) {
if (gameZone.equals(Zone.HAND)) {
if (gameZone == Zone.HAND) {
return handCardsA;
} else if (gameZone.equals(Zone.GRAVEYARD)) {
} else if (gameZone == Zone.GRAVEYARD) {
return graveyardCardsA;
} else if (gameZone.equals(Zone.LIBRARY)) {
} else if (gameZone == Zone.LIBRARY) {
return libraryCardsA;
}
} else if (player.equals(playerB)) {
if (gameZone.equals(Zone.HAND)) {
if (gameZone == Zone.HAND) {
return handCardsB;
} else if (gameZone.equals(Zone.GRAVEYARD)) {
} else if (gameZone == Zone.GRAVEYARD) {
return graveyardCardsB;
} else if (gameZone.equals(Zone.LIBRARY)) {
} else if (gameZone == Zone.LIBRARY) {
return libraryCardsB;
}
}
@ -289,12 +289,12 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
if (permanent.getName().equals(cardName)) {
count++;
if (scope.equals(Filter.ComparisonScope.All)) {
if (scope == Filter.ComparisonScope.All) {
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() + ')',
toughness, permanent.getToughness().getValue());
} else if (scope.equals(Filter.ComparisonScope.Any)) {
} else if (scope == Filter.ComparisonScope.Any) {
if (power == permanent.getPower().getValue() && toughness == permanent.getToughness().getValue()) {
fit++;
break;
@ -306,7 +306,7 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
Assert.assertTrue("There is no such permanent under player's control, player=" + player.getName() +
", cardName=" + cardName, count > 0);
if (scope.equals(Filter.ComparisonScope.Any)) {
if (scope == Filter.ComparisonScope.Any) {
Assert.assertTrue("There is no such creature under player's control with specified power&toughness, player=" + player.getName() +
", cardName=" + cardName, fit > 0);
}

View file

@ -278,7 +278,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
@Override
public void addCard(Zone gameZone, TestPlayer player, String cardName, int count, boolean tapped) {
if (gameZone.equals(Zone.BATTLEFIELD)) {
if (gameZone == Zone.BATTLEFIELD) {
for (int i = 0; i < count; i++) {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card card = cardInfo != null ? cardInfo.getCard() : null;
@ -445,12 +445,12 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
for (Permanent permanent : currentGame.getBattlefield().getAllPermanents()) {
if (permanent.getName().equals(cardName) && permanent.getControllerId().equals(player.getId())) {
count++;
if (scope.equals(Filter.ComparisonScope.All)) {
if (scope == Filter.ComparisonScope.All) {
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() + ')',
toughness, permanent.getToughness().getValue());
} else if (scope.equals(Filter.ComparisonScope.Any)) {
} else if (scope == Filter.ComparisonScope.Any) {
if (power == permanent.getPower().getValue() && toughness == permanent.getToughness().getValue()) {
fit++;
break;
@ -465,7 +465,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertTrue("There is no such permanent under player's control, player=" + player.getName()
+ ", cardName=" + cardName, count > 0);
if (scope.equals(Filter.ComparisonScope.Any)) {
if (scope == 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);
}
@ -1055,7 +1055,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param clause
*/
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack, StackClause clause) {
if (StackClause.WHILE_ON_STACK.equals(clause)) {
if (StackClause.WHILE_ON_STACK == clause) {
player.addAction(turnNum, step, "activate:Cast " + cardName
+ '$' + (targetName != null && targetName.startsWith("target") ? targetName : "target=" + targetName)
+ "$spellOnStack=" + spellOnStack);
@ -1253,7 +1253,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
if (currentGame == null) {
throw new IllegalStateException("Current game is null");
}
if (scope.equals(Filter.ComparisonScope.All)) {
if (scope == Filter.ComparisonScope.All) {
throw new UnsupportedOperationException("ComparisonScope.All is not implemented.");
}