diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index bc4bf425b0..c0bef58e38 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -27,10 +27,6 @@ */ package mage.server; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; import mage.server.exceptions.UserNotFoundException; @@ -40,6 +36,11 @@ import mage.view.ChatMessage.MessageType; import mage.view.ChatMessage.SoundToPlay; import org.apache.log4j.Logger; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * @author BetaSteward_at_googlemail.com */ @@ -290,7 +291,7 @@ public enum ChatManager { } } - public ArrayList getChatSessions() { + public List getChatSessions() { return new ArrayList<>(chatSessions.values()); } diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java index 9dd362060f..32bc16bb11 100644 --- a/Mage.Server/src/main/java/mage/server/ChatSession.java +++ b/Mage.Server/src/main/java/mage/server/ChatSession.java @@ -36,10 +36,7 @@ import mage.view.ChatMessage.SoundToPlay; import org.apache.log4j.Logger; import java.text.DateFormat; -import java.util.Date; -import java.util.HashSet; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** @@ -119,7 +116,7 @@ public class ChatSession { public void broadcast(String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) { if (!message.isEmpty()) { - HashSet clientsToRemove = new HashSet<>(); + Set clientsToRemove = new HashSet<>(); ClientCallback clientCallback = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(userName, message, (withTime ? timeFormatter.format(new Date()) : ""), color, messageType, soundToPlay)); for (UUID userId : clients.keySet()) { Optional user = UserManager.instance.getUser(userId); diff --git a/Mage.Server/src/main/java/mage/server/TableManager.java b/Mage.Server/src/main/java/mage/server/TableManager.java index 047639386f..07b1f7b8e7 100644 --- a/Mage.Server/src/main/java/mage/server/TableManager.java +++ b/Mage.Server/src/main/java/mage/server/TableManager.java @@ -369,7 +369,7 @@ public enum TableManager { + " | " + sessionState + " | " + user.getName() + " (" + user.getUserState().toString() + " - " + user.getPingInfo() + ')'); } - ArrayList chatSessions = ChatManager.instance.getChatSessions(); + List chatSessions = ChatManager.instance.getChatSessions(); logger.debug("------- ChatSessions: " + chatSessions.size() + " ----------------------------------"); for (ChatSession chatSession : chatSessions) { logger.debug(chatSession.getChatId() + " " + formatter.format(chatSession.getCreateTime()) + ' ' + chatSession.getInfo() + ' ' + chatSession.getClients().values().toString()); @@ -387,7 +387,7 @@ public enum TableManager { debugServerState(); } logger.debug("TABLE HEALTH CHECK"); - ArrayList tableCopy = new ArrayList<>(tables.values()); + List
tableCopy = new ArrayList<>(tables.values()); for (Table table : tableCopy) { try { if (table.getState() != TableState.FINISHED) { diff --git a/Mage.Server/src/main/java/mage/server/User.java b/Mage.Server/src/main/java/mage/server/User.java index e4853b7629..f823e02490 100644 --- a/Mage.Server/src/main/java/mage/server/User.java +++ b/Mage.Server/src/main/java/mage/server/User.java @@ -73,7 +73,7 @@ public class User { private final String host; private final Date connectionTime; private final Map tables; - private final ArrayList tablesToDelete; + private final List tablesToDelete; private final Map gameSessions; private final Map draftSessions; private final Map userTournaments; // playerId, tournamentId diff --git a/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java b/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java index 762f33374d..4c4f116a2a 100644 --- a/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java +++ b/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java @@ -88,8 +88,8 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable { private void update() { List
allTables = new ArrayList<>(tables.values()); allTables.sort(new TableListSorter()); - ArrayList matchList = new ArrayList<>(); - ArrayList tableList = new ArrayList<>(); + List matchList = new ArrayList<>(); + List tableList = new ArrayList<>(); for (Table table : allTables) { if (table.getState() != TableState.FINISHED) { tableList.add(new TableView(table)); diff --git a/Mage.Server/src/main/java/mage/server/record/UserStatsRepository.java b/Mage.Server/src/main/java/mage/server/record/UserStatsRepository.java index 1bf6b3f474..b99eeed302 100644 --- a/Mage.Server/src/main/java/mage/server/record/UserStatsRepository.java +++ b/Mage.Server/src/main/java/mage/server/record/UserStatsRepository.java @@ -18,6 +18,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Set; public enum UserStatsRepository { @@ -107,7 +108,7 @@ public enum UserStatsRepository { // updateUserStats reads tables finished after the last DB update and reflects it to the DB. // It returns the list of user names that are upated. public List updateUserStats() { - HashSet updatedUsers = new HashSet<>(); + Set updatedUsers = new HashSet<>(); // Lock the DB so that no other updateUserStats runs at the same time. synchronized(this) { long latestEndTimeMs = this.getLatestEndTimeMs(); diff --git a/Mage.Sets/src/mage/cards/t/Tromokratis.java b/Mage.Sets/src/mage/cards/t/Tromokratis.java index 50df2af484..e83614ca77 100644 --- a/Mage.Sets/src/mage/cards/t/Tromokratis.java +++ b/Mage.Sets/src/mage/cards/t/Tromokratis.java @@ -27,9 +27,6 @@ */ package mage.cards.t; -import java.util.HashSet; -import java.util.Map; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -49,6 +46,10 @@ import mage.game.Game; import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -113,7 +114,7 @@ class CantBeBlockedUnlessAllEffect extends RestrictionEffect { return false; } // check blocker restrictions - for (Map.Entry> entry: game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).entrySet()) { + for (Map.Entry> entry: game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).entrySet()) { for (Ability ability : entry.getValue()) { if (!entry.getKey().canBlock(attacker, permanent, ability, game)) { return false; @@ -121,7 +122,7 @@ class CantBeBlockedUnlessAllEffect extends RestrictionEffect { } } // check also attacker's restriction effects - for (Map.Entry> restrictionEntry: game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) { + for (Map.Entry> restrictionEntry: game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) { for (Ability ability : restrictionEntry.getValue()) { if (!(restrictionEntry.getKey() instanceof CantBeBlockedUnlessAllEffect) && !restrictionEntry.getKey().canBeBlocked(attacker, permanent, ability, game)) { diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 05b1c6684e..b35298b230 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -27,19 +27,9 @@ */ package org.mage.test.player; -import java.io.Serializable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import mage.MageObject; import mage.MageObjectReference; -import mage.abilities.Abilities; -import mage.abilities.Ability; -import mage.abilities.ActivatedAbility; -import mage.abilities.Mode; -import mage.abilities.Modes; -import mage.abilities.SpellAbility; -import mage.abilities.TriggeredAbility; +import mage.abilities.*; import mage.abilities.costs.AlternativeSourceCosts; import mage.abilities.costs.Cost; import mage.abilities.costs.Costs; @@ -52,13 +42,7 @@ import mage.cards.Card; import mage.cards.Cards; import mage.cards.decks.Deck; import mage.choices.Choice; -import mage.constants.AbilityType; -import mage.constants.ManaType; -import mage.constants.Outcome; -import mage.constants.PhaseStep; -import mage.constants.RangeOfInfluence; -import mage.constants.SpellAbilityType; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.Counter; import mage.counters.Counters; import mage.filter.Filter; @@ -83,22 +67,15 @@ import mage.players.Library; import mage.players.ManaPool; import mage.players.Player; import mage.players.net.UserData; -import mage.target.Target; -import mage.target.TargetAmount; -import mage.target.TargetCard; -import mage.target.TargetPermanent; -import mage.target.TargetPlayer; -import mage.target.TargetSource; -import mage.target.TargetSpell; -import mage.target.common.TargetCardInHand; -import mage.target.common.TargetCardInLibrary; -import mage.target.common.TargetCardInOpponentsGraveyard; -import mage.target.common.TargetCardInYourGraveyard; -import mage.target.common.TargetCreatureOrPlayer; -import mage.target.common.TargetCreaturePermanentAmount; -import mage.target.common.TargetPermanentOrPlayer; +import mage.target.*; +import mage.target.common.*; import org.junit.Ignore; +import java.io.Serializable; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * @author BetaSteward_at_googlemail.com * @author Simown @@ -1329,7 +1306,7 @@ public class TestPlayer implements Player { } @Override - public int drawCards(int num, Game game, ArrayList appliedEffects) { + public int drawCards(int num, Game game, List appliedEffects) { return computerPlayer.drawCards(num, game, appliedEffects); } @@ -1619,7 +1596,7 @@ public class TestPlayer implements Player { } @Override - public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList appliedEffects) { + public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List appliedEffects) { return computerPlayer.damage(damage, sourceId, game, combatDamage, preventable, appliedEffects); } @@ -2284,7 +2261,7 @@ public class TestPlayer implements Player { } @Override - public boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects) { + public boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects) { return computerPlayer.moveCards(card, toZone, source, game, tapped, faceDown, byOwner, appliedEffects); } @@ -2299,7 +2276,7 @@ public class TestPlayer implements Player { } @Override - public boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects) { + public boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects) { return computerPlayer.moveCards(cards, toZone, source, game, tapped, faceDown, byOwner, appliedEffects); } diff --git a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java index 99f9d4d599..54fdb7ac45 100644 --- a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java +++ b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java @@ -27,21 +27,8 @@ */ package org.mage.test.stub; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.MageObject; -import mage.abilities.Abilities; -import mage.abilities.Ability; -import mage.abilities.ActivatedAbility; -import mage.abilities.Mode; -import mage.abilities.Modes; -import mage.abilities.SpellAbility; -import mage.abilities.TriggeredAbility; +import mage.abilities.*; import mage.abilities.costs.AlternativeSourceCosts; import mage.abilities.costs.Cost; import mage.abilities.costs.Costs; @@ -53,12 +40,7 @@ import mage.cards.Card; import mage.cards.Cards; import mage.cards.decks.Deck; import mage.choices.Choice; -import mage.constants.AbilityType; -import mage.constants.ManaType; -import mage.constants.Outcome; -import mage.constants.PlayerAction; -import mage.constants.RangeOfInfluence; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.Counter; import mage.counters.Counters; import mage.filter.FilterPermanent; @@ -80,6 +62,9 @@ import mage.target.TargetAmount; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.io.Serializable; +import java.util.*; + /** * * @author Quercitron @@ -174,7 +159,7 @@ public class PlayerStub implements Player { } @Override - public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList appliedEffects) { + public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List appliedEffects) { return 0; } @@ -563,7 +548,7 @@ public class PlayerStub implements Player { } @Override - public int drawCards(int num, Game game, ArrayList appliedEffects) { + public int drawCards(int num, Game game, List appliedEffects) { return 0; } @@ -1098,7 +1083,7 @@ public class PlayerStub implements Player { } @Override - public boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects) { + public boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects) { return false; } @@ -1113,7 +1098,7 @@ public class PlayerStub implements Player { } @Override - public boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects) { + public boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects) { return false; } diff --git a/Mage/src/main/java/mage/abilities/common/FetchLandActivatedAbility.java b/Mage/src/main/java/mage/abilities/common/FetchLandActivatedAbility.java index 9ebf0cb8b4..99cb0dc391 100644 --- a/Mage/src/main/java/mage/abilities/common/FetchLandActivatedAbility.java +++ b/Mage/src/main/java/mage/abilities/common/FetchLandActivatedAbility.java @@ -28,9 +28,6 @@ package mage.abilities.common; -import java.util.ArrayList; -import java.util.Set; - import mage.MageObject; import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.common.PayLifeCost; @@ -48,6 +45,10 @@ import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.target.common.TargetCardInLibrary; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + /** * * @author BetaSteward_at_googlemail.com @@ -67,7 +68,7 @@ public class FetchLandActivatedAbility extends ActivatedAbilityImpl { addCost(new SacrificeSourceCost()); FilterCard filter = new FilterCard(subTypeNames(subtypes)); filter.add(new CardTypePredicate(CardType.LAND)); - ArrayList> subtypePredicates = new ArrayList<>(); + List> subtypePredicates = new ArrayList<>(); for (SubType subtype : subtypes) { subtypePredicates.add(new SubtypePredicate(subtype)); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java index be6f0d6366..5e2a812def 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java @@ -27,13 +27,15 @@ */ package mage.abilities.condition.common; -import java.util.ArrayList; import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.keyword.SurgeAbility; import mage.constants.AbilityType; import mage.game.Game; +import java.util.ArrayList; +import java.util.List; + /** * * @author LevelX2 @@ -46,7 +48,7 @@ public enum SurgedCondition implements Condition { public boolean apply(Game game, Ability source) { if (source.getAbilityType() == AbilityType.TRIGGERED) { @SuppressWarnings("unchecked") - ArrayList surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId()); + List surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId()); if (surgeActivations != null) { return surgeActivations.contains(game.getState().getZoneChangeCounter(source.getSourceId()) - 1); } diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java index 55820a6134..7070938e07 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java @@ -27,11 +27,6 @@ */ package mage.abilities.effects; -import java.io.Serializable; -import java.util.*; -import java.util.Map.Entry; -import java.util.stream.Collectors; - import mage.MageObject; import mage.abilities.*; import mage.abilities.keyword.SpliceOntoArcaneAbility; @@ -54,6 +49,11 @@ import mage.players.Player; import mage.target.common.TargetCardInHand; import org.apache.log4j.Logger; +import java.io.Serializable; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; + /** * @author BetaSteward_at_googlemail.com */ @@ -192,7 +192,7 @@ public class ContinuousEffects implements Serializable { case WhileOnBattlefield: case WhileOnStack: case WhileInGraveyard: - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); if (!abilities.isEmpty()) { for (Ability ability : abilities) { // If e.g. triggerd abilities (non static) created the effect, the ability must not be in usable zone (e.g. Unearth giving Haste effect) @@ -244,11 +244,11 @@ public class ContinuousEffects implements Serializable { return effects.stream().filter(effect->effect.hasLayer(layer)).collect(Collectors.toList()); } - public HashMap> getApplicableRequirementEffects(Permanent permanent, Game game) { - HashMap> effects = new HashMap<>(); + public Map> getApplicableRequirementEffects(Permanent permanent, Game game) { + Map> effects = new HashMap<>(); for (RequirementEffect effect : requirementEffects) { - HashSet abilities = requirementEffects.getAbility(effect.getId()); - HashSet applicableAbilities = new HashSet<>(); + Set abilities = requirementEffects.getAbility(effect.getId()); + Set applicableAbilities = new HashSet<>(); for (Ability ability : abilities) { if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, ability instanceof MageSingleton ? permanent : null, null)) { if (effect.applies(permanent, ability, game)) { @@ -263,11 +263,11 @@ public class ContinuousEffects implements Serializable { return effects; } - public HashMap> getApplicableRestrictionEffects(Permanent permanent, Game game) { - HashMap> effects = new HashMap<>(); + public Map> getApplicableRestrictionEffects(Permanent permanent, Game game) { + Map> effects = new HashMap<>(); for (RestrictionEffect effect : restrictionEffects) { - HashSet abilities = restrictionEffects.getAbility(effect.getId()); - HashSet applicableAbilities = new HashSet<>(); + Set abilities = restrictionEffects.getAbility(effect.getId()); + Set applicableAbilities = new HashSet<>(); for (Ability ability : abilities) { if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, ability instanceof MageSingleton ? permanent : null, null)) { if (effect.applies(permanent, ability, game)) { @@ -282,11 +282,11 @@ public class ContinuousEffects implements Serializable { return effects; } - public HashMap> getApplicableRestrictionUntapNotMoreThanEffects(Player player, Game game) { - HashMap> effects = new HashMap<>(); + public Map> getApplicableRestrictionUntapNotMoreThanEffects(Player player, Game game) { + Map> effects = new HashMap<>(); for (RestrictionUntapNotMoreThanEffect effect : restrictionUntapNotMoreThanEffects) { - HashSet abilities = restrictionUntapNotMoreThanEffects.getAbility(effect.getId()); - HashSet applicableAbilities = new HashSet<>(); + Set abilities = restrictionUntapNotMoreThanEffects.getAbility(effect.getId()); + Set applicableAbilities = new HashSet<>(); for (Ability ability : abilities) { if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) { if (effect.applies(player, ability, game)) { @@ -307,7 +307,7 @@ public class ContinuousEffects implements Serializable { continue; } if (effect instanceof PayCostToAttackBlockEffect) { - HashSet abilities = replacementEffects.getAbility(effect.getId()); + Set abilities = replacementEffects.getAbility(effect.getId()); for (Ability ability : abilities) { // for replacment effects of static abilities do not use LKI to check if to apply if (ability.getAbilityType() != AbilityType.STATIC || ability.isInUseableZone(game, null, event)) { @@ -332,8 +332,8 @@ public class ContinuousEffects implements Serializable { * @return a list of all {@link ReplacementEffect} that apply to the current * event */ - private HashMap> getApplicableReplacementEffects(GameEvent event, Game game) { - HashMap> replaceEffects = new HashMap<>(); + private Map> getApplicableReplacementEffects(GameEvent event, Game game) { + Map> replaceEffects = new HashMap<>(); if (planeswalkerRedirectionEffect.checksEventType(event, game) && planeswalkerRedirectionEffect.applies(event, null, game)) { replaceEffects.put(planeswalkerRedirectionEffect, null); } @@ -351,8 +351,8 @@ public class ContinuousEffects implements Serializable { // TODO: Handle also gained effect that are connected to different abilities. continue; } - HashSet abilities = replacementEffects.getAbility(effect.getId()); - HashSet applicableAbilities = new HashSet<>(); + Set abilities = replacementEffects.getAbility(effect.getId()); + Set applicableAbilities = new HashSet<>(); for (Ability ability : abilities) { // for replacment effects of static abilities do not use LKI to check if to apply if (ability.getAbilityType() != AbilityType.STATIC || ability.isInUseableZone(game, null, event)) { @@ -380,8 +380,8 @@ public class ContinuousEffects implements Serializable { // TODO: Handle also gained effect that are connected to different abilities. continue; } - HashSet abilities = preventionEffects.getAbility(effect.getId()); - HashSet applicableAbilities = new HashSet<>(); + Set abilities = preventionEffects.getAbility(effect.getId()); + Set applicableAbilities = new HashSet<>(); for (Ability ability : abilities) { if (ability.getAbilityType() != AbilityType.STATIC || ability.isInUseableZone(game, null, event)) { if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) { @@ -455,7 +455,7 @@ public class ContinuousEffects implements Serializable { List costEffects = new ArrayList<>(); for (CostModificationEffect effect : costModificationEffects) { - HashSet abilities = costModificationEffects.getAbility(effect.getId()); + Set abilities = costModificationEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) { if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) { @@ -479,7 +479,7 @@ public class ContinuousEffects implements Serializable { List spliceEffects = new ArrayList<>(); for (SpliceCardEffect effect : spliceCardEffects) { - HashSet abilities = spliceCardEffects.getAbility(effect.getId()); + Set abilities = spliceCardEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (ability.getControllerId().equals(playerId) && (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null))) { if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) { @@ -500,7 +500,7 @@ public class ContinuousEffects implements Serializable { public boolean asThough(UUID objectId, AsThoughEffectType type, Ability affectedAbility, UUID controllerId, Game game) { List asThoughEffectsList = getApplicableAsThoughEffects(type, game); for (AsThoughEffect effect : asThoughEffectsList) { - HashSet abilities = asThoughEffectsMap.get(type).getAbility(effect.getId()); + Set abilities = asThoughEffectsMap.get(type).getAbility(effect.getId()); for (Ability ability : abilities) { if (affectedAbility == null) { if (effect.applies(objectId, ability, controllerId, game)) { @@ -519,7 +519,7 @@ public class ContinuousEffects implements Serializable { // First check existing only effects List asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_ONLY_MANA, game); for (AsThoughEffect effect : asThoughEffectsList) { - HashSet abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_ONLY_MANA).getAbility(effect.getId()); + Set abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_ONLY_MANA).getAbility(effect.getId()); for (Ability ability : abilities) { if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game)) || effect.applies(objectId, affectedAbility, ability, game)) { @@ -532,7 +532,7 @@ public class ContinuousEffects implements Serializable { // then check effects that allow to use other mana types to pay the current mana type to pay asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_OTHER_MANA, game); for (AsThoughEffect effect : asThoughEffectsList) { - HashSet abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_OTHER_MANA).getAbility(effect.getId()); + Set abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_OTHER_MANA).getAbility(effect.getId()); for (Ability ability : abilities) { if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game)) || effect.applies(objectId, affectedAbility, ability, game)) { @@ -557,7 +557,7 @@ public class ContinuousEffects implements Serializable { List asThoughEffectsList = new ArrayList<>(); if (asThoughEffectsMap.containsKey(type)) { for (AsThoughEffect effect : asThoughEffectsMap.get(type)) { - HashSet abilities = asThoughEffectsMap.get(type).getAbility(effect.getId()); + Set abilities = asThoughEffectsMap.get(type).getAbility(effect.getId()); for (Ability ability : abilities) { if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) { if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) { @@ -600,7 +600,7 @@ public class ContinuousEffects implements Serializable { for (CostModificationEffect effect : costEffects) { if (effect.getModificationType() == CostModificationType.INCREASE_COST) { - HashSet abilities = costModificationEffects.getAbility(effect.getId()); + Set abilities = costModificationEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (effect.applies(abilityToModify, ability, game)) { effect.apply(game, ability, abilityToModify); @@ -611,7 +611,7 @@ public class ContinuousEffects implements Serializable { for (CostModificationEffect effect : costEffects) { if (effect.getModificationType() == CostModificationType.REDUCE_COST) { - HashSet abilities = costModificationEffects.getAbility(effect.getId()); + Set abilities = costModificationEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (effect.applies(abilityToModify, ability, game)) { effect.apply(game, ability, abilityToModify); @@ -622,7 +622,7 @@ public class ContinuousEffects implements Serializable { for (CostModificationEffect effect : costEffects) { if (effect.getModificationType() == CostModificationType.SET_COST) { - HashSet abilities = costModificationEffects.getAbility(effect.getId()); + Set abilities = costModificationEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (effect.applies(abilityToModify, ability, game)) { effect.apply(game, ability, abilityToModify); @@ -647,7 +647,7 @@ public class ContinuousEffects implements Serializable { // get the applyable splice abilities List spliceAbilities = new ArrayList<>(); for (SpliceCardEffect effect : spliceEffects) { - HashSet abilities = spliceCardEffects.getAbility(effect.getId()); + Set abilities = spliceCardEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (effect.applies(abilityToModify, ability, game)) { spliceAbilities.add((SpliceOntoArcaneAbility) ability); @@ -741,14 +741,14 @@ public class ContinuousEffects implements Serializable { public boolean replaceEvent(GameEvent event, Game game) { boolean caught = false; - HashMap> consumed = new HashMap<>(); + Map> consumed = new HashMap<>(); do { - HashMap> rEffects = getApplicableReplacementEffects(event, game); + Map> rEffects = getApplicableReplacementEffects(event, game); // Remove all consumed effects (ability dependant) for (Iterator it1 = rEffects.keySet().iterator(); it1.hasNext();) { ReplacementEffect entry = it1.next(); if (consumed.containsKey(entry.getId())) { - HashSet consumedAbilitiesIds = consumed.get(entry.getId()); + Set consumedAbilitiesIds = consumed.get(entry.getId()); if (rEffects.get(entry) == null || consumedAbilitiesIds.size() == rEffects.get(entry).size()) { it1.remove(); } else { @@ -770,7 +770,7 @@ public class ContinuousEffects implements Serializable { boolean onlyOne = false; if (rEffects.size() == 1) { ReplacementEffect effect = rEffects.keySet().iterator().next(); - HashSet abilities; + Set abilities; if (effect.getEffectType() == EffectType.REPLACEMENT) { abilities = replacementEffects.getAbility(effect.getId()); } else { @@ -791,7 +791,7 @@ public class ContinuousEffects implements Serializable { int checked = 0; ReplacementEffect rEffect = null; Ability rAbility = null; - for (Map.Entry> entry : rEffects.entrySet()) { + for (Map.Entry> entry : rEffects.entrySet()) { if (entry.getValue() == null) { if (checked == index) { rEffect = entry.getKey(); @@ -800,7 +800,7 @@ public class ContinuousEffects implements Serializable { checked++; } } else { - HashSet abilities = entry.getValue(); + Set abilities = entry.getValue(); int size = abilities.size(); if (index > (checked + size - 1)) { checked += size; @@ -831,13 +831,13 @@ public class ContinuousEffects implements Serializable { // add the applied effect to the consumed effects if (rEffect != null) { if (consumed.containsKey(rEffect.getId())) { - HashSet set = consumed.get(rEffect.getId()); + Set set = consumed.get(rEffect.getId()); if (rAbility != null) { set.add(rAbility.getId()); } } else { - HashSet set = new HashSet<>(); + Set set = new HashSet<>(); if (rAbility != null) { // in case of AuraReplacementEffect or PlaneswalkerReplacementEffect there is no Ability set.add(rAbility.getId()); } @@ -860,7 +860,7 @@ public class ContinuousEffects implements Serializable { List layer = filterLayeredEffects(activeLayerEffects, Layer.CopyEffects_1); for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.CopyEffects_1, SubLayer.NA, ability, game); } @@ -876,7 +876,7 @@ public class ContinuousEffects implements Serializable { // e.g. Mind Control is controlled by Steal Enchantment while (true) { for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.ControlChangingEffects_2, SubLayer.NA, ability, game); } @@ -908,7 +908,7 @@ public class ContinuousEffects implements Serializable { continue; } List appliedAbilities = appliedEffectAbilities.get(effect); - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (appliedAbilities == null || !appliedAbilities.contains(ability)) { if (appliedAbilities == null) { @@ -955,7 +955,7 @@ public class ContinuousEffects implements Serializable { layer = filterLayeredEffects(activeLayerEffects, Layer.PTChangingEffects_7); for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (abilityActive(ability, game)) { effect.apply(Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, ability, game); @@ -963,13 +963,13 @@ public class ContinuousEffects implements Serializable { } } for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, ability, game); } } for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, ability, game); } @@ -978,21 +978,21 @@ public class ContinuousEffects implements Serializable { applyCounters.apply(Layer.PTChangingEffects_7, SubLayer.Counters_7d, null, game); for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.PTChangingEffects_7, SubLayer.SwitchPT_e, ability, game); } } layer = filterLayeredEffects(activeLayerEffects, Layer.PlayerEffects); for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.PlayerEffects, SubLayer.NA, ability, game); } } layer = filterLayeredEffects(activeLayerEffects, Layer.RulesEffects); for (ContinuousEffect effect : layer) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(Layer.RulesEffects, SubLayer.NA, ability, game); } @@ -1034,13 +1034,13 @@ public class ContinuousEffects implements Serializable { } private void applyContinuousEffect(ContinuousEffect effect, Layer currentLayer, Game game) { - HashSet abilities = layeredEffects.getAbility(effect.getId()); + Set abilities = layeredEffects.getAbility(effect.getId()); for (Ability ability : abilities) { effect.apply(currentLayer, SubLayer.NA, ability, game); } } - public HashSet getLayeredEffectAbilities(ContinuousEffect effect) { + public Set getLayeredEffectAbilities(ContinuousEffect effect) { return layeredEffects.getAbility(effect.getId()); } @@ -1135,7 +1135,7 @@ public class ContinuousEffects implements Serializable { private void setControllerForEffect(ContinuousEffectsList effects, UUID sourceId, UUID controllerId) { for (Effect effect : effects) { - HashSet abilities = effects.getAbility(effect.getId()); + Set abilities = effects.getAbility(effect.getId()); for (Ability ability : abilities) { if (ability.getSourceId() != null) { if (ability.getSourceId().equals(sourceId)) { @@ -1200,9 +1200,9 @@ public class ContinuousEffects implements Serializable { temporaryEffects.clear(); } - public Map getReplacementEffectsTexts(HashMap> rEffects, Game game) { + public Map getReplacementEffectsTexts(Map> rEffects, Game game) { Map texts = new LinkedHashMap<>(); - for (Map.Entry> entry : rEffects.entrySet()) { + for (Map.Entry> entry : rEffects.entrySet()) { if (entry.getValue() != null) { for (Ability ability : entry.getValue()) { MageObject object = game.getObject(ability.getSourceId()); @@ -1229,7 +1229,7 @@ public class ContinuousEffects implements Serializable { public UUID getControllerOfSourceId(UUID sourceId) { UUID controllerFound = null; for (PreventionEffect effect : preventionEffects) { - HashSet abilities = preventionEffects.getAbility(effect.getId()); + Set abilities = preventionEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (ability.getSourceId().equals(sourceId)) { if (controllerFound == null || controllerFound.equals(ability.getControllerId())) { @@ -1242,7 +1242,7 @@ public class ContinuousEffects implements Serializable { } } for (ReplacementEffect effect : replacementEffects) { - HashSet abilities = replacementEffects.getAbility(effect.getId()); + Set abilities = replacementEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (ability.getSourceId() != null) { if (ability.getSourceId().equals(sourceId)) { diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java index 0fad03c7bc..2a32d80895 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java @@ -27,20 +27,14 @@ */ package mage.abilities.effects; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - import mage.abilities.Ability; import mage.abilities.MageSingleton; import mage.constants.Duration; import mage.game.Game; import org.apache.log4j.Logger; +import java.util.*; + /** * @param * @author BetaSteward_at_googlemail.com @@ -50,7 +44,7 @@ public class ContinuousEffectsList extends ArrayList private static final Logger logger = Logger.getLogger(ContinuousEffectsList.class); // the effectAbilityMap holds for each effect all abilities that are connected (used) with this effect - private final Map> effectAbilityMap = new HashMap<>(); + private final Map> effectAbilityMap = new HashMap<>(); public ContinuousEffectsList() { } @@ -60,8 +54,8 @@ public class ContinuousEffectsList extends ArrayList for (ContinuousEffect cost : effects) { this.add((T) cost.copy()); } - for (Map.Entry> entry : effects.effectAbilityMap.entrySet()) { - HashSet newSet = new HashSet<>(); + for (Map.Entry> entry : effects.effectAbilityMap.entrySet()) { + Set newSet = new HashSet<>(); for (Ability ability : entry.getValue()) { newSet.add(ability.copy()); } @@ -104,7 +98,7 @@ public class ContinuousEffectsList extends ArrayList } private boolean isInactive(T effect, Game game) { - HashSet set = effectAbilityMap.get(effect.getId()); + Set set = effectAbilityMap.get(effect.getId()); if (set == null) { logger.debug("No abilities for effect found: " + effect.toString()); return false; @@ -153,7 +147,7 @@ public class ContinuousEffectsList extends ArrayList */ public void addEffect(T effect, Ability source) { if (effectAbilityMap.containsKey(effect.getId())) { - HashSet set = effectAbilityMap.get(effect.getId()); + Set set = effectAbilityMap.get(effect.getId()); for (Ability ability : set) { if (ability.getId().equals(source.getId()) && ability.getSourceId().equals(source.getSourceId())) { return; @@ -162,18 +156,18 @@ public class ContinuousEffectsList extends ArrayList set.add(source); return; } - HashSet set = new HashSet<>(); + Set set = new HashSet<>(); set.add(source); this.effectAbilityMap.put(effect.getId(), set); this.add(effect); } - public HashSet getAbility(UUID effectId) { + public Set getAbility(UUID effectId) { return effectAbilityMap.getOrDefault(effectId, new HashSet<>()); } public void removeEffects(UUID effectIdToRemove, Set abilitiesToRemove) { - HashSet abilities = effectAbilityMap.get(effectIdToRemove); + Set abilities = effectAbilityMap.get(effectIdToRemove); if (abilitiesToRemove != null && abilities != null) { abilities.removeAll(abilitiesToRemove); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java index b9d1440624..55fb38058d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseModeEffect.java @@ -27,8 +27,6 @@ */ package mage.abilities.effects.common; -import java.util.ArrayList; -import java.util.Arrays; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.choices.Choice; @@ -38,13 +36,17 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * * @author LevelX2 */ public class ChooseModeEffect extends OneShotEffect { - protected final ArrayList modes = new ArrayList(); + protected final List modes = new ArrayList(); protected final String choiceMessage; public ChooseModeEffect(String choiceMessage, String... modes) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java index d326d359d2..b02f9b4f44 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java @@ -27,8 +27,6 @@ */ package mage.abilities.effects.common; -import java.util.ArrayList; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.effects.EntersBattlefieldEffect; @@ -39,6 +37,10 @@ import mage.counters.Counter; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * Use this effect only (I guess) with EntersBattlefieldAbility like abilities * @@ -77,7 +79,7 @@ public class EntersBattlefieldWithXCountersEffect extends OneShotEffect { if (amount > 0) { Counter counterToAdd = counter.copy(); counterToAdd.add(amount - counter.getCount()); - ArrayList appliedEffects = (ArrayList) this.getValue("appliedEffects"); + List appliedEffects = (ArrayList) this.getValue("appliedEffects"); permanent.addCounters(counterToAdd, source, game, appliedEffects); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java index aa7201f1f8..1a19d10848 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseAbilityOrAnotherAbilityTargetEffect.java @@ -27,7 +27,6 @@ */ package mage.abilities.effects.common.continuous; -import java.util.HashSet; import mage.abilities.Ability; import mage.abilities.Mode; import mage.choices.ChoiceImpl; @@ -37,6 +36,9 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.Target; +import java.util.HashSet; +import java.util.Set; + /** * * @author a @@ -71,7 +73,7 @@ public class LoseAbilityOrAnotherAbilityTargetEffect extends LoseAbilityTargetEf ChoiceImpl chooseAbility = new ChoiceImpl(); chooseAbility.setMessage("What ability do you wish to remove?"); - HashSet choice = new HashSet<>(); + Set choice = new HashSet<>(); if (permanent.getAbilities().contains(ability)) { choice.add(ability.getRule()); diff --git a/Mage/src/main/java/mage/actions/MageDrawAction.java b/Mage/src/main/java/mage/actions/MageDrawAction.java index 619cd9da75..89ea2c89fb 100644 --- a/Mage/src/main/java/mage/actions/MageDrawAction.java +++ b/Mage/src/main/java/mage/actions/MageDrawAction.java @@ -1,8 +1,5 @@ package mage.actions; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.actions.impl.MageAction; import mage.actions.score.ArtificialScoringSystem; import mage.cards.Card; @@ -12,6 +9,10 @@ import mage.game.events.GameEvent; import mage.players.Player; import mage.util.CardUtil; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * Action for drawing cards. * @@ -21,12 +22,12 @@ public class MageDrawAction extends MageAction { private final Player player; private final int amount; - private final ArrayList appliedEffects; + private final List appliedEffects; private final List drawnCards; private static final int NEGATIVE_VALUE = -1000000; - public MageDrawAction(Player player, int amount, ArrayList appliedEffects) { + public MageDrawAction(Player player, int amount, List appliedEffects) { this.player = player; this.amount = amount; this.appliedEffects = appliedEffects; diff --git a/Mage/src/main/java/mage/cards/Card.java b/Mage/src/main/java/mage/cards/Card.java index 8e7debf751..728951f59e 100644 --- a/Mage/src/main/java/mage/cards/Card.java +++ b/Mage/src/main/java/mage/cards/Card.java @@ -27,16 +27,12 @@ */ package mage.cards; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.MageObject; import mage.Mana; import mage.ObjectColor; import mage.abilities.Abilities; import mage.abilities.Ability; import mage.abilities.SpellAbility; -import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.Zone; import mage.counters.Counter; @@ -46,6 +42,9 @@ import mage.game.Game; import mage.game.GameState; import mage.game.permanent.Permanent; +import java.util.List; +import java.util.UUID; + public interface Card extends MageObject { @@ -127,7 +126,7 @@ public interface Card extends MageObject { */ boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag); - boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects); + boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag, List appliedEffects); /** * Moves the card to an exile zone @@ -140,7 +139,7 @@ public interface Card extends MageObject { */ boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game); - boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects); + boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects); boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId); @@ -152,7 +151,7 @@ public interface Card extends MageObject { boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown); - boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, ArrayList appliedEffects); + boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, List appliedEffects); void setZone(Zone zone, Game game); @@ -170,7 +169,7 @@ public interface Card extends MageObject { boolean addCounters(Counter counter, Ability source, Game game); - boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects); + boolean addCounters(Counter counter, Ability source, Game game, List appliedEffects); void removeCounters(String name, int amount, Game game); diff --git a/Mage/src/main/java/mage/cards/CardImpl.java b/Mage/src/main/java/mage/cards/CardImpl.java index befa16158e..8248c1bb1b 100644 --- a/Mage/src/main/java/mage/cards/CardImpl.java +++ b/Mage/src/main/java/mage/cards/CardImpl.java @@ -27,25 +27,14 @@ */ package mage.cards; -import java.lang.reflect.Constructor; -import java.util.*; import mage.MageObject; import mage.MageObjectImpl; import mage.Mana; import mage.ObjectColor; -import mage.abilities.Abilities; -import mage.abilities.AbilitiesImpl; -import mage.abilities.Ability; -import mage.abilities.PlayLandAbility; -import mage.abilities.SpellAbility; +import mage.abilities.*; import mage.abilities.mana.ActivatedManaAbilityImpl; import mage.cards.repository.PluginClassloaderRegistery; -import mage.constants.CardType; -import mage.constants.ColoredManaSymbol; -import mage.constants.Rarity; -import mage.constants.SpellAbilityType; -import mage.constants.TimingRule; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.Counter; import mage.counters.Counters; import mage.game.*; @@ -58,6 +47,12 @@ import mage.util.GameLog; import mage.watchers.Watcher; import org.apache.log4j.Logger; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + public abstract class CardImpl extends MageObjectImpl implements Card { private static final long serialVersionUID = 1L; @@ -358,7 +353,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { } @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { Zone fromZone = game.getState().getZone(objectId); ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, ownerId, fromZone, toZone, appliedEffects); ZoneChangeInfo zoneChangeInfo; @@ -394,7 +389,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { } @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { Zone fromZone = game.getState().getZone(objectId); ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects); ZoneChangeInfo.Exile info = new ZoneChangeInfo.Exile(event, exileId, name); @@ -417,7 +412,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { } @Override - public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean faceDown, ArrayList appliedEffects) { + public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean faceDown, List appliedEffects) { ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, controllerId, fromZone, Zone.BATTLEFIELD, appliedEffects); ZoneChangeInfo.Battlefield info = new ZoneChangeInfo.Battlefield(event, faceDown, tapped); return ZonesHandler.moveCard(info, game); @@ -627,7 +622,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { } @Override - public boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects) { + public boolean addCounters(Counter counter, Ability source, Game game, List appliedEffects) { boolean returnCode = true; UUID sourceId = (source == null ? null : source.getSourceId()); GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, sourceId, getControllerOrOwner(), counter.getName(), counter.getCount()); diff --git a/Mage/src/main/java/mage/cards/MeldCard.java b/Mage/src/main/java/mage/cards/MeldCard.java index 736dd293f2..78b3834beb 100644 --- a/Mage/src/main/java/mage/cards/MeldCard.java +++ b/Mage/src/main/java/mage/cards/MeldCard.java @@ -27,8 +27,6 @@ */ package mage.cards; -import java.util.ArrayList; -import java.util.UUID; import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Zone; @@ -37,6 +35,9 @@ import mage.game.Game; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; +import java.util.List; +import java.util.UUID; + /** * * @author emerald000 @@ -133,7 +134,7 @@ public abstract class MeldCard extends CardImpl { } @Override - public boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects) { + public boolean addCounters(Counter counter, Ability source, Game game, List appliedEffects) { if (this.isMelded()) { return super.addCounters(counter, source, game, appliedEffects); } else { diff --git a/Mage/src/main/java/mage/cards/SplitCard.java b/Mage/src/main/java/mage/cards/SplitCard.java index d608390039..b3869e6bea 100644 --- a/Mage/src/main/java/mage/cards/SplitCard.java +++ b/Mage/src/main/java/mage/cards/SplitCard.java @@ -27,9 +27,6 @@ */ package mage.cards; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; import mage.abilities.Ability; @@ -39,6 +36,10 @@ import mage.constants.SpellAbilityType; import mage.constants.Zone; import mage.game.Game; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author LevelX2 @@ -91,7 +92,7 @@ public abstract class SplitCard extends CardImpl { } @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { if (super.moveToZone(toZone, sourceId, game, flag, appliedEffects)) { game.getState().setZone(getLeftHalfCard().getId(), toZone); game.getState().setZone(getRightHalfCard().getId(), toZone); @@ -101,7 +102,7 @@ public abstract class SplitCard extends CardImpl { } @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { if (super.moveToExile(exileId, name, sourceId, game, appliedEffects)) { Zone currentZone = game.getState().getZone(getId()); game.getState().setZone(getLeftHalfCard().getId(), currentZone); diff --git a/Mage/src/main/java/mage/cards/SplitCardHalfImpl.java b/Mage/src/main/java/mage/cards/SplitCardHalfImpl.java index bf8e5a40ee..8637d27e9a 100644 --- a/Mage/src/main/java/mage/cards/SplitCardHalfImpl.java +++ b/Mage/src/main/java/mage/cards/SplitCardHalfImpl.java @@ -5,13 +5,15 @@ */ package mage.cards; -import java.util.ArrayList; -import java.util.UUID; import mage.constants.CardType; import mage.constants.SpellAbilityType; import mage.constants.Zone; import mage.game.Game; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author LevelX2 @@ -51,12 +53,12 @@ public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf { } @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); } @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); } diff --git a/Mage/src/main/java/mage/game/combat/Combat.java b/Mage/src/main/java/mage/game/combat/Combat.java index bea54bfe65..d080f94c2a 100644 --- a/Mage/src/main/java/mage/game/combat/Combat.java +++ b/Mage/src/main/java/mage/game/combat/Combat.java @@ -27,15 +27,6 @@ */ package mage.game.combat; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.RequirementEffect; @@ -59,6 +50,9 @@ import mage.util.Copyable; import mage.util.trace.TraceUtil; import org.apache.log4j.Logger; +import java.io.Serializable; +import java.util.*; + /** * @author BetaSteward_at_googlemail.com */ @@ -308,7 +302,7 @@ public class Combat implements Serializable, Copyable { for (Permanent creature : player.getAvailableAttackers(game)) { boolean mustAttack = false; Set defendersForcedToAttack = new HashSet<>(); - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { RequirementEffect effect = entry.getKey(); if (effect.mustAttack(game)) { mustAttack = true; @@ -395,7 +389,7 @@ public class Combat implements Serializable, Copyable { } for (UUID attackingCreatureId : this.getAttackers()) { Permanent attackingCreature = game.getPermanent(attackingCreatureId); - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canAttackCheckAfter(numberAttackers, ability, game)) { @@ -581,7 +575,7 @@ public class Combat implements Serializable, Copyable { return; } for (Permanent possibleBlocker : game.getBattlefield().getActivePermanents(filterBlockers, attackingPlayer.getId(), game)) { - for (Map.Entry> requirementEntry : game.getContinuousEffects().getApplicableRequirementEffects(possibleBlocker, game).entrySet()) { + for (Map.Entry> requirementEntry : game.getContinuousEffects().getApplicableRequirementEffects(possibleBlocker, game).entrySet()) { if (requirementEntry.getKey().mustBlock(game)) { for (Ability ability : requirementEntry.getValue()) { UUID attackingCreatureId = requirementEntry.getKey().mustBlockAttacker(ability, game); @@ -658,7 +652,7 @@ public class Combat implements Serializable, Copyable { // Creature is already blocking but not forced to do so if (creature.getBlocking() > 0) { // get all requirement effects that apply to the creature (e.g. is able to block attacker) - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { RequirementEffect effect = entry.getKey(); // get possible mustBeBlockedByAtLeastOne blocker for (Ability ability : entry.getValue()) { @@ -680,7 +674,7 @@ public class Combat implements Serializable, Copyable { // Creature is not blocking yet if (creature.getBlocking() == 0) { // get all requirement effects that apply to the creature - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { RequirementEffect effect = entry.getKey(); // get possible mustBeBlockedByAtLeastOne blocker for (Ability ability : entry.getValue()) { @@ -980,7 +974,7 @@ public class Combat implements Serializable, Copyable { for (UUID blockingCreatureId : this.getBlockers()) { Permanent blockingCreature = game.getPermanent(blockingCreatureId); if (blockingCreature != null) { - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(blockingCreature, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(blockingCreature, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canBlockCheckAfter(ability, game)) { @@ -1000,7 +994,7 @@ public class Combat implements Serializable, Copyable { for (UUID attackingCreatureId : this.getAttackers()) { Permanent attackingCreature = game.getPermanent(attackingCreatureId); if (attackingCreature != null) { - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canBeBlockedCheckAfter(attackingCreature, ability, game)) { diff --git a/Mage/src/main/java/mage/game/draft/DraftImpl.java b/Mage/src/main/java/mage/game/draft/DraftImpl.java index 56305b33c4..702ae547fe 100644 --- a/Mage/src/main/java/mage/game/draft/DraftImpl.java +++ b/Mage/src/main/java/mage/game/draft/DraftImpl.java @@ -340,7 +340,7 @@ public abstract class DraftImpl implements Draft { @Override public void resetBufferedCards() { - HashSet setsDone = new HashSet<>(); + Set setsDone = new HashSet<>(); for(ExpansionSet set: sets) { if (!setsDone.contains(set)) { set.removeSavedCards(); diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 8dbf55f645..bc10ea7d20 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -27,10 +27,12 @@ */ package mage.game.events; +import mage.constants.Zone; + import java.io.Serializable; import java.util.ArrayList; +import java.util.List; import java.util.UUID; -import mage.constants.Zone; /** * @@ -46,7 +48,7 @@ public class GameEvent implements Serializable { protected boolean flag; protected String data; protected Zone zone; - protected ArrayList appliedEffects = new ArrayList<>(); + protected List appliedEffects = new ArrayList<>(); protected UUID customEventType = null; public enum EventType { @@ -460,7 +462,7 @@ public class GameEvent implements Serializable { * * @return */ - public ArrayList getAppliedEffects() { + public List getAppliedEffects() { return appliedEffects; } @@ -468,13 +470,13 @@ public class GameEvent implements Serializable { return type == EventType.CUSTOM_EVENT && this.customEventType.equals(customEventType); } - public void addAppliedEffects(ArrayList appliedEffects) { + public void addAppliedEffects(List appliedEffects) { if (appliedEffects != null) { this.appliedEffects.addAll(appliedEffects); } } - public void setAppliedEffects(ArrayList appliedEffects) { + public void setAppliedEffects(List appliedEffects) { if (appliedEffects != null) { if (this.appliedEffects.isEmpty()) { this.appliedEffects = appliedEffects; // Use object refecence to handle that an replacement effect can only be once applied to an event diff --git a/Mage/src/main/java/mage/game/events/ZoneChangeEvent.java b/Mage/src/main/java/mage/game/events/ZoneChangeEvent.java index f4074354e8..40b5bb2d0e 100644 --- a/Mage/src/main/java/mage/game/events/ZoneChangeEvent.java +++ b/Mage/src/main/java/mage/game/events/ZoneChangeEvent.java @@ -28,11 +28,12 @@ package mage.game.events; -import java.util.ArrayList; -import java.util.UUID; import mage.constants.Zone; import mage.game.permanent.Permanent; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -50,7 +51,7 @@ public class ZoneChangeEvent extends GameEvent { this.target = target; } - public ZoneChangeEvent(Permanent target, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone, ArrayList appliedEffects) { + public ZoneChangeEvent(Permanent target, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone, List appliedEffects) { super(EventType.ZONE_CHANGE, target.getId(), sourceId, playerId); this.fromZone = fromZone; this.toZone = toZone; @@ -66,7 +67,7 @@ public class ZoneChangeEvent extends GameEvent { this.toZone = toZone; } - public ZoneChangeEvent(UUID targetId, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone, ArrayList appliedEffects) { + public ZoneChangeEvent(UUID targetId, UUID sourceId, UUID playerId, Zone fromZone, Zone toZone, List appliedEffects) { super(EventType.ZONE_CHANGE, targetId, sourceId, playerId); this.fromZone = fromZone; this.toZone = toZone; diff --git a/Mage/src/main/java/mage/game/permanent/Permanent.java b/Mage/src/main/java/mage/game/permanent/Permanent.java index f4071c1214..c7d0a4c1d2 100644 --- a/Mage/src/main/java/mage/game/permanent/Permanent.java +++ b/Mage/src/main/java/mage/game/permanent/Permanent.java @@ -27,10 +27,6 @@ */ package mage.game.permanent; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.UUID; import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; @@ -41,6 +37,10 @@ import mage.game.Controllable; import mage.game.Game; import mage.game.GameState; +import java.util.List; +import java.util.Set; +import java.util.UUID; + public interface Permanent extends Card, Controllable { void setControllerId(UUID controllerId); @@ -129,7 +129,7 @@ public interface Permanent extends Card, Controllable { int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable); - int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable, ArrayList appliedEffects); + int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable, List appliedEffects); /** * used in combat only to deal damage at the same time @@ -267,7 +267,7 @@ public interface Permanent extends Card, Controllable { * * @return */ - HashSet getDealtDamageByThisTurn(); + Set getDealtDamageByThisTurn(); /** * Imprint some other card to this one. diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 6042e8e60f..194df0a44a 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -27,7 +27,6 @@ */ package mage.game.permanent; -import java.util.*; import mage.MageObject; import mage.MageObjectReference; import mage.ObjectColor; @@ -56,6 +55,8 @@ import mage.players.Player; import mage.util.GameLog; import mage.util.ThreadLocalStringBuilder; +import java.util.*; + /** * @author BetaSteward_at_googlemail.com */ @@ -100,7 +101,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { protected boolean deathtouched; protected List attachments = new ArrayList<>(); protected Map> connectedCards = new HashMap<>(); - protected HashSet dealtDamageByThisTurn; + protected Set dealtDamageByThisTurn; protected UUID attachedTo; protected int attachedToZoneChangeCounter; protected MageObjectReference pairedPermanent; @@ -695,7 +696,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } @Override - public int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable, ArrayList appliedEffects) { + public int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable, List appliedEffects) { return damage(damage, sourceId, game, preventable, combat, false, appliedEffects); } @@ -709,7 +710,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { * method * @return */ - private int damage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, ArrayList appliedEffects) { + private int damage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, List appliedEffects) { int damageDone = 0; if (damageAmount > 0 && canDamage(game.getObject(sourceId), game)) { if (this.isPlaneswalker()) { @@ -794,7 +795,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { deathtouched = false; } - protected int damagePlaneswalker(int damage, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, ArrayList appliedEffects) { + protected int damagePlaneswalker(int damage, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, List appliedEffects) { GameEvent event = new DamagePlaneswalkerEvent(objectId, sourceId, controllerId, damage, preventable, combat); event.setAppliedEffects(appliedEffects); if (!game.replaceEvent(event)) { @@ -812,7 +813,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return 0; } - protected int damageCreature(int damage, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, ArrayList appliedEffects) { + protected int damageCreature(int damage, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, List appliedEffects) { GameEvent event = new DamageCreatureEvent(objectId, sourceId, controllerId, damage, preventable, combat); event.setAppliedEffects(appliedEffects); if (!game.replaceEvent(event)) { @@ -1062,7 +1063,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { private boolean canAttackCheckRestrictionEffects(UUID defenderId, Game game) { //20101001 - 508.1c - for (Map.Entry> effectEntry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { + for (Map.Entry> effectEntry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { if (!effectEntry.getKey().canAttack(game)) { return false; } @@ -1090,7 +1091,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } //20101001 - 509.1b // check blocker restrictions - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { for (Ability ability : entry.getValue()) { if (!entry.getKey().canBlock(attacker, this, ability, game)) { return false; @@ -1098,7 +1099,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } } // check also attacker's restriction effects - for (Map.Entry> restrictionEntry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) { + for (Map.Entry> restrictionEntry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) { for (Ability ability : restrictionEntry.getValue()) { if (!restrictionEntry.getKey().canBeBlocked(attacker, this, ability, game)) { return false; @@ -1115,7 +1116,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } //20101001 - 509.1b - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canBlock(null, this, ability, game)) { @@ -1136,7 +1137,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { */ @Override public boolean canUseActivatedAbilities(Game game) { - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canUseActivatedAbilities(this, ability, game)) { @@ -1150,7 +1151,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { @Override public boolean canTransform(Ability source, Game game) { if (transformable) { - for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { + for (Map.Entry> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canTransform(this, ability, game)) { @@ -1237,7 +1238,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } @Override - public HashSet getDealtDamageByThisTurn() { + public Set getDealtDamageByThisTurn() { if (dealtDamageByThisTurn == null) { return new HashSet<>(); } @@ -1376,7 +1377,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { Zone fromZone = game.getState().getZone(objectId); Player controller = game.getPlayer(controllerId); if (controller != null) { @@ -1393,7 +1394,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { Zone fromZone = game.getState().getZone(objectId); ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects); ZoneChangeInfo.Exile info = new ZoneChangeInfo.Exile(event, exileId, name); diff --git a/Mage/src/main/java/mage/game/stack/Spell.java b/Mage/src/main/java/mage/game/stack/Spell.java index 1a46a0d909..2874708cfc 100644 --- a/Mage/src/main/java/mage/game/stack/Spell.java +++ b/Mage/src/main/java/mage/game/stack/Spell.java @@ -27,10 +27,6 @@ */ package mage.game.stack; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.Mana; @@ -62,6 +58,11 @@ import mage.game.permanent.PermanentCard; import mage.players.Player; import mage.util.GameLog; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -732,7 +733,7 @@ public class Spell extends StackObjImpl implements Card { } @Override - public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { + public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag, List appliedEffects) { // 706.10a If a copy of a spell is in a zone other than the stack, it ceases to exist. // If a copy of a card is in any zone other than the stack or the battlefield, it ceases to exist. // These are state-based actions. See rule 704. @@ -748,7 +749,7 @@ public class Spell extends StackObjImpl implements Card { } @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { return this.card.moveToExile(exileId, name, sourceId, game, appliedEffects); } @@ -768,7 +769,7 @@ public class Spell extends StackObjImpl implements Card { } @Override - public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, ArrayList appliedEffects) { + public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, List appliedEffects) { throw new UnsupportedOperationException("Not supported yet."); } @@ -865,7 +866,7 @@ public class Spell extends StackObjImpl implements Card { } @Override - public boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects) { + public boolean addCounters(Counter counter, Ability source, Game game, List appliedEffects) { return card.addCounters(counter, source, game, appliedEffects); } diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index f858af4c0f..e641a41c74 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -124,7 +124,7 @@ public interface Player extends MageItem, Copyable { int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable); - int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList appliedEffects); + int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List appliedEffects); // to handle rule changing effects (613.10) boolean isCanLoseLife(); @@ -350,7 +350,7 @@ public interface Player extends MageItem, Copyable { int drawCards(int num, Game game); - int drawCards(int num, Game game, ArrayList appliedEffects); + int drawCards(int num, Game game, List appliedEffects); boolean cast(SpellAbility ability, Game game, boolean noMana); @@ -674,7 +674,7 @@ public interface Player extends MageItem, Copyable { boolean moveCards(Card card, Zone toZone, Ability source, Game game); - boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects); + boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects); boolean moveCards(Set cards, Zone toZone, Ability source, Game game); @@ -694,7 +694,7 @@ public interface Player extends MageItem, Copyable { * @param appliedEffects * @return */ - boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects); + boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects); boolean moveCardsToExile(Card card, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index efff8a0413..5fba8287f2 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -27,10 +27,6 @@ */ package mage.players; -import java.io.Serializable; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.Map.Entry; import mage.ConditionalMana; import mage.MageObject; import mage.Mana; @@ -91,6 +87,11 @@ import mage.util.GameLog; import mage.util.RandomUtil; import org.apache.log4j.Logger; +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.Map.Entry; + public abstract class PlayerImpl implements Player, Serializable { private static final Logger logger = Logger.getLogger(PlayerImpl.class); @@ -621,7 +622,7 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public int drawCards(int num, Game game, ArrayList appliedEffects) { + public int drawCards(int num, Game game, List appliedEffects) { return game.doAction(new MageDrawAction(this, num, appliedEffects)); } @@ -1472,8 +1473,8 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public void untap(Game game) { // create list of all "notMoreThan" effects to track which one are consumed - HashMap>, Integer> notMoreThanEffectsUsage = new HashMap<>(); - for (Entry> restrictionEffect : game.getContinuousEffects().getApplicableRestrictionUntapNotMoreThanEffects(this, game).entrySet()) { + HashMap>, Integer> notMoreThanEffectsUsage = new HashMap<>(); + for (Entry> restrictionEffect : game.getContinuousEffects().getApplicableRestrictionUntapNotMoreThanEffects(this, game).entrySet()) { notMoreThanEffectsUsage.put(restrictionEffect, restrictionEffect.getKey().getNumber()); } @@ -1497,7 +1498,7 @@ public abstract class PlayerImpl implements Player, Serializable { do { playerCanceledSelection = false; // select permanents to untap to consume the "notMoreThan" effects - for (Map.Entry>, Integer> handledEntry : notMoreThanEffectsUsage.entrySet()) { + for (Map.Entry>, Integer> handledEntry : notMoreThanEffectsUsage.entrySet()) { // select a permanent to untap for this entry int numberToUntap = handledEntry.getValue(); if (numberToUntap > 0) { @@ -1535,7 +1536,7 @@ public abstract class PlayerImpl implements Player, Serializable { // don't allow to select same permanent twice filter.add(Predicates.not(new PermanentIdPredicate(selectedPermanent.getId()))); // reduce available untap numbers from other "UntapNotMoreThan" effects if selected permanent applies to their filter too - for (Entry>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) { + for (Entry>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) { if (notMoreThanEffect.getValue() > 0 && notMoreThanEffect.getKey().getKey().getFilter().match(selectedPermanent, game)) { notMoreThanEffect.setValue(notMoreThanEffect.getValue() - 1); } @@ -1574,7 +1575,7 @@ public abstract class PlayerImpl implements Player, Serializable { boolean doUntap = true; if (!selectedToUntap.contains(permanent)) { // if the permanent is covered by one of the restriction effects, don't untap it - for (Entry>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) { + for (Entry>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) { if (notMoreThanEffect.getKey().getKey().getFilter().match(permanent, game)) { doUntap = false; break; @@ -1601,14 +1602,14 @@ public abstract class PlayerImpl implements Player, Serializable { } } - private List getPermanentsThatCanBeUntapped(Game game, List canBeUntapped, RestrictionUntapNotMoreThanEffect handledEffect, HashMap>, Integer> notMoreThanEffectsUsage) { + private List getPermanentsThatCanBeUntapped(Game game, List canBeUntapped, RestrictionUntapNotMoreThanEffect handledEffect, Map>, Integer> notMoreThanEffectsUsage) { List leftForUntap = new ArrayList<>(); // select permanents that can still be untapped for (Permanent permanent : canBeUntapped) { if (handledEffect.getFilter().match(permanent, game)) { // matches the restricted permanents of handled entry boolean canBeSelected = true; // check if the permanent is restriced by another restriction that has left no permanent - for (Entry>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) { + for (Entry>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) { if (notMoreThanEffect.getKey().getKey().getFilter().match(permanent, game) && notMoreThanEffect.getValue() == 0) { canBeSelected = false; break; @@ -1763,12 +1764,12 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList appliedEffects) { + public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List appliedEffects) { return doDamage(damage, sourceId, game, combatDamage, preventable, appliedEffects); } @SuppressWarnings({"null", "ConstantConditions"}) - private int doDamage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList appliedEffects) { + private int doDamage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List appliedEffects) { if (damage > 0 && canDamage(game.getObject(sourceId), game)) { GameEvent event = new DamagePlayerEvent(playerId, sourceId, playerId, damage, preventable, combatDamage); event.setAppliedEffects(appliedEffects); @@ -3093,7 +3094,7 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects) { + public boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects) { Set cardList = new HashSet<>(); if (card != null) { cardList.add(card); @@ -3112,7 +3113,7 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects) { + public boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List appliedEffects) { if (cards.isEmpty()) { return true; } diff --git a/Mage/src/main/java/mage/util/trace/TraceUtil.java b/Mage/src/main/java/mage/util/trace/TraceUtil.java index e36028cb9a..8b20c8cccb 100644 --- a/Mage/src/main/java/mage/util/trace/TraceUtil.java +++ b/Mage/src/main/java/mage/util/trace/TraceUtil.java @@ -1,16 +1,14 @@ package mage.util.trace; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.StaticAbility; import mage.abilities.effects.ContinuousEffectsList; import mage.abilities.effects.RestrictionEffect; -import mage.abilities.keyword.FlyingAbility; -import mage.abilities.keyword.ReachAbility; import mage.abilities.keyword.CantBeBlockedSourceAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.IntimidateAbility; +import mage.abilities.keyword.ReachAbility; import mage.constants.Zone; import mage.game.Game; import mage.game.combat.Combat; @@ -18,9 +16,7 @@ import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; import org.apache.log4j.Logger; -import java.util.UUID; -import mage.abilities.keyword.IntimidateAbility; -import mage.constants.CardType; +import java.util.*; /** * @author magenoxx_at_gmail.com @@ -146,8 +142,8 @@ public final class TraceUtil { log.error(prefix+"Restriction effects:"); log.error(prefix+" Applied to ATTACKER:"); - HashMap> attackerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game); - for (Map.Entry> entry : attackerResEffects.entrySet()) { + Map> attackerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game); + for (Map.Entry> entry : attackerResEffects.entrySet()) { log.error(prefix+" " + entry.getKey()); log.error(prefix+" id=" + entry.getKey().getId()); for (Ability ability: entry.getValue()) { @@ -156,8 +152,8 @@ public final class TraceUtil { } log.error(prefix+" Applied to BLOCKER:"); if (blocker != null) { - HashMap> blockerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(blocker, game); - for (Map.Entry> entry : blockerResEffects.entrySet()) { + Map> blockerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(blocker, game); + for (Map.Entry> entry : blockerResEffects.entrySet()) { log.error(prefix+" " + entry.getKey()); log.error(prefix+" id=" + entry.getKey().getId()); for (Ability ability: entry.getValue()) {