change looping over maps (Sonar)

This commit is contained in:
Ingmar Goudt 2019-02-02 22:37:02 +01:00
parent 63718e7a6e
commit dc112215d4
11 changed files with 24 additions and 22 deletions

View file

@ -83,8 +83,8 @@ class CurseOfTheSwineEffect extends OneShotEffect {
}
}
CurseOfTheSwineBoarToken swineToken = new CurseOfTheSwineBoarToken();
for (UUID playerId : playersWithTargets.keySet()) {
swineToken.putOntoBattlefield(playersWithTargets.get(playerId), game, source.getSourceId(), playerId);
for (Map.Entry<UUID, Integer> exiledByController : playersWithTargets.entrySet()) {
swineToken.putOntoBattlefield(exiledByController.getValue(), game, source.getSourceId(), exiledByController.getKey());
}
return true;
}

View file

@ -4,6 +4,8 @@ package mage.cards.d;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import com.j256.ormlite.stmt.query.In;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -67,10 +69,10 @@ class DarkDealEffect extends OneShotEffect {
}
}
}
for (UUID playerId : cardsToDraw.keySet()) {
Player player = game.getPlayer(playerId);
for (Map.Entry<UUID, Integer> toDrawByPlayer : cardsToDraw.entrySet()) {
Player player = game.getPlayer(toDrawByPlayer.getKey());
if (player != null) {
player.drawCards(cardsToDraw.get(playerId), game);
player.drawCards(toDrawByPlayer.getValue(), game);
}
}
return true;

View file

@ -77,8 +77,8 @@ class DescentOfTheDragonsEffect extends OneShotEffect {
}
}
DragonToken dragonToken = new DragonToken();
for (UUID playerId : playersWithTargets.keySet()) {
dragonToken.putOntoBattlefield(playersWithTargets.get(playerId), game, source.getSourceId(), playerId);
for (Map.Entry<UUID, Integer> amountTokensPerPlayer : playersWithTargets.entrySet()) {
dragonToken.putOntoBattlefield(amountTokensPerPlayer.getValue(), game, source.getSourceId(), amountTokensPerPlayer.getKey());
}
return true;
}

View file

@ -110,7 +110,7 @@ class GuardianProjectTriggeredAbility extends EntersBattlefieldAllTriggeredAbili
filterPermanent.add(new NamePredicate(permanent.getName()));
filterPermanent.add(Predicates.not(new CardIdPredicate(permanent.getId())));
filterPermanent.add(new ControllerIdPredicate(controllerId));
if (game.getBattlefield().getActivePermanents(filterPermanent, controllerId, game).size() > 0) {
if (!game.getBattlefield().getActivePermanents(filterPermanent, controllerId, game).isEmpty()) {
return false;
}
return true;

View file

@ -92,10 +92,10 @@ class IncendiaryCommandDrawEffect extends OneShotEffect {
}
}
}
for (UUID playerId : cardsToDraw.keySet()) {
Player player = game.getPlayer(playerId);
for (Map.Entry<UUID, Integer> toDrawByPlayer : cardsToDraw.entrySet()) {
Player player = game.getPlayer(toDrawByPlayer.getKey());
if (player != null) {
player.drawCards(cardsToDraw.get(playerId), game);
player.drawCards(toDrawByPlayer.getValue(), game);
}
}
return true;

View file

@ -83,10 +83,10 @@ class KamahlsSummonsEffect extends OneShotEffect {
}
}
Token token = new BearToken();
for (UUID playerId : revealedCards.keySet()) {
int value = revealedCards.get(playerId);
for (Map.Entry<UUID, Integer> revealedCardsByPlayer: revealedCards.entrySet()) {
int value = revealedCardsByPlayer.getValue();
if (value > 0) {
token.putOntoBattlefield(value, game, source.getSourceId(), playerId);
token.putOntoBattlefield(value, game, source.getSourceId(), revealedCardsByPlayer.getKey());
}
}
return true;

View file

@ -67,8 +67,8 @@ class MarchOfSoulsEffect extends OneShotEffect {
}
}
SpiritWhiteToken token = new SpiritWhiteToken();
for (UUID playerId : playersWithCreatures.keySet()) {
token.putOntoBattlefield(playersWithCreatures.get(playerId), game, source.getSourceId(), playerId);
for (Map.Entry<UUID, Integer> destroyedCreaturePerPlayer : playersWithCreatures.entrySet()) {
token.putOntoBattlefield(destroyedCreaturePerPlayer.getValue(), game, source.getSourceId(), destroyedCreaturePerPlayer.getKey());
}
return true;
}

View file

@ -69,8 +69,8 @@ class RampageOfTheClansEffect extends OneShotEffect {
}
}
Token token = new CentaurToken();
for (UUID playerId : playersWithPermanents.keySet()) {
token.putOntoBattlefield(playersWithPermanents.get(playerId), game, source.getSourceId(), playerId);
for (Map.Entry<UUID, Integer> amountDestroyedByPlayer : playersWithPermanents.entrySet()) {
token.putOntoBattlefield(amountDestroyedByPlayer.getValue(), game, source.getSourceId(), amountDestroyedByPlayer.getKey());
}
return true;
}

View file

@ -53,7 +53,7 @@ public class TapAllTargetPlayerControlsEffect extends OneShotEffect {
}
return "tap all " + filter.toString() + " target " +
(mode.getTargets().size() == 0 ? "player" : mode.getTargets().get(0).getTargetName()) +
(mode.getTargets().isEmpty() ? "player" : mode.getTargets().get(0).getTargetName()) +
" controls";
}
}

View file

@ -73,7 +73,7 @@ public enum CardRepository {
try {
cardDao.callBatchTasks(() -> {
// add
if (newCards != null && newCards.size() > 0) {
if (newCards != null && !newCards.isEmpty()) {
logger.info("DB: need to add " + newCards.size() + " new cards");
try {
for (CardInfo card : newCards) {

View file

@ -70,7 +70,7 @@ public enum ExpansionRepository {
try {
expansionDao.callBatchTasks(() -> {
// add
if (newSets != null && newSets.size() > 0) {
if (newSets != null && !newSets.isEmpty()) {
logger.info("DB: need to add " + newSets.size() + " new sets");
try {
for (ExpansionInfo exp : newSets) {
@ -82,7 +82,7 @@ public enum ExpansionRepository {
}
// update
if (updatedSets != null && updatedSets.size() > 0) {
if (updatedSets != null && !updatedSets.isEmpty()) {
logger.info("DB: need to update " + updatedSets.size() + " sets");
try {
for (ExpansionInfo exp : updatedSets) {