Big Cleanup

This commit is contained in:
Anthony Calosa
2019-09-06 00:03:04 +08:00
parent efbd2a08eb
commit 59bf5830fe
431 changed files with 1181 additions and 1173 deletions

View File

@@ -81,7 +81,7 @@ public class AiAttackController {
this.defendingOpponent = choosePreferredDefenderPlayer(); this.defendingOpponent = choosePreferredDefenderPlayer();
this.oppList = getOpponentCreatures(this.defendingOpponent); this.oppList = getOpponentCreatures(this.defendingOpponent);
this.myList = ai.getCreaturesInPlay(); this.myList = ai.getCreaturesInPlay();
this.attackers = new ArrayList<Card>(); this.attackers = new ArrayList<>();
for (Card c : myList) { for (Card c : myList) {
if (CombatUtil.canAttack(c, this.defendingOpponent)) { if (CombatUtil.canAttack(c, this.defendingOpponent)) {
attackers.add(c); attackers.add(c);
@@ -95,7 +95,7 @@ public class AiAttackController {
this.defendingOpponent = choosePreferredDefenderPlayer(); this.defendingOpponent = choosePreferredDefenderPlayer();
this.oppList = getOpponentCreatures(this.defendingOpponent); this.oppList = getOpponentCreatures(this.defendingOpponent);
this.myList = ai.getCreaturesInPlay(); this.myList = ai.getCreaturesInPlay();
this.attackers = new ArrayList<Card>(); this.attackers = new ArrayList<>();
if (CombatUtil.canAttack(attacker, this.defendingOpponent)) { if (CombatUtil.canAttack(attacker, this.defendingOpponent)) {
attackers.add(attacker); attackers.add(attacker);
} }
@@ -103,7 +103,7 @@ public class AiAttackController {
} // overloaded constructor to evaluate single specified attacker } // overloaded constructor to evaluate single specified attacker
public static List<Card> getOpponentCreatures(final Player defender) { public static List<Card> getOpponentCreatures(final Player defender) {
List<Card> defenders = new ArrayList<Card>(); List<Card> defenders = new ArrayList<>();
defenders.addAll(defender.getCreaturesInPlay()); defenders.addAll(defender.getCreaturesInPlay());
Predicate<Card> canAnimate = new Predicate<Card>() { Predicate<Card> canAnimate = new Predicate<Card>() {
@Override @Override
@@ -151,7 +151,7 @@ public class AiAttackController {
* *
*/ */
public final static List<Card> sortAttackers(final List<Card> in) { public final static List<Card> sortAttackers(final List<Card> in) {
final List<Card> list = new ArrayList<Card>(); final List<Card> list = new ArrayList<>();
// Cards with triggers should come first (for Battle Cry) // Cards with triggers should come first (for Battle Cry)
for (final Card attacker : in) { for (final Card attacker : in) {
@@ -256,7 +256,7 @@ public class AiAttackController {
} }
public final static List<Card> getPossibleBlockers(final List<Card> blockers, final List<Card> attackers) { public final static List<Card> getPossibleBlockers(final List<Card> blockers, final List<Card> attackers) {
List<Card> possibleBlockers = new ArrayList<Card>(blockers); List<Card> possibleBlockers = new ArrayList<>(blockers);
possibleBlockers = CardLists.filter(possibleBlockers, new Predicate<Card>() { possibleBlockers = CardLists.filter(possibleBlockers, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -267,7 +267,7 @@ public class AiAttackController {
} }
public final static boolean canBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) { public final static boolean canBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) {
final List<Card> attackerList = new ArrayList<Card>(attackers); final List<Card> attackerList = new ArrayList<>(attackers);
if (!c.isCreature()) { if (!c.isCreature()) {
return false; return false;
} }
@@ -280,7 +280,7 @@ public class AiAttackController {
} }
public final static Card getCardCanBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) { public final static Card getCardCanBlockAnAttacker(final Card c, final List<Card> attackers, final boolean nextTurn) {
final List<Card> attackerList = new ArrayList<Card>(attackers); final List<Card> attackerList = new ArrayList<>(attackers);
if (!c.isCreature()) { if (!c.isCreature()) {
return null; return null;
} }
@@ -295,9 +295,9 @@ public class AiAttackController {
// this checks to make sure that the computer player doesn't lose when the human player attacks // this checks to make sure that the computer player doesn't lose when the human player attacks
// this method is used by getAttackers() // this method is used by getAttackers()
public final List<Card> notNeededAsBlockers(final Player ai, final List<Card> attackers) { public final List<Card> notNeededAsBlockers(final Player ai, final List<Card> attackers) {
final List<Card> notNeededAsBlockers = new ArrayList<Card>(attackers); final List<Card> notNeededAsBlockers = new ArrayList<>(attackers);
int fixedBlockers = 0; int fixedBlockers = 0;
final List<Card> vigilantes = new ArrayList<Card>(); final List<Card> vigilantes = new ArrayList<>();
//check for time walks //check for time walks
if (ai.getGame().getPhaseHandler().getNextTurn().equals(ai)) { if (ai.getGame().getPhaseHandler().getNextTurn().equals(ai)) {
return attackers; return attackers;
@@ -336,7 +336,7 @@ public class AiAttackController {
} }
} }
List<Card> opponentsAttackers = new ArrayList<Card>(oppList); List<Card> opponentsAttackers = new ArrayList<>(oppList);
opponentsAttackers = CardLists.filter(opponentsAttackers, new Predicate<Card>() { opponentsAttackers = CardLists.filter(opponentsAttackers, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -681,7 +681,7 @@ public class AiAttackController {
// Determine who will be attacked // Determine who will be attacked
GameEntity defender = this.chooseDefender(combat, bAssault); GameEntity defender = this.chooseDefender(combat, bAssault);
List<Card> attackersLeft = new ArrayList<Card>(this.attackers); List<Card> attackersLeft = new ArrayList<>(this.attackers);
// TODO probably use AttackConstraints instead of only GlobalAttackRestrictions? // TODO probably use AttackConstraints instead of only GlobalAttackRestrictions?
GlobalAttackRestrictions restrict = GlobalAttackRestrictions.getGlobalRestrictions(ai, combat.getDefenders()); GlobalAttackRestrictions restrict = GlobalAttackRestrictions.getGlobalRestrictions(ai, combat.getDefenders());
@@ -821,12 +821,12 @@ public class AiAttackController {
int humanForcesForAttritionalAttack = 0; int humanForcesForAttritionalAttack = 0;
// examine the potential forces // examine the potential forces
final List<Card> nextTurnAttackers = new ArrayList<Card>(); final List<Card> nextTurnAttackers = new ArrayList<>();
int candidateCounterAttackDamage = 0; int candidateCounterAttackDamage = 0;
final Player opp = this.defendingOpponent; final Player opp = this.defendingOpponent;
// get the potential damage and strength of the AI forces // get the potential damage and strength of the AI forces
final List<Card> candidateAttackers = new ArrayList<Card>(); final List<Card> candidateAttackers = new ArrayList<>();
int candidateUnblockedDamage = 0; int candidateUnblockedDamage = 0;
for (final Card pCard : this.myList) { for (final Card pCard : this.myList) {
// if the creature can attack then it's a potential attacker this // if the creature can attack then it's a potential attacker this
@@ -908,7 +908,7 @@ public class AiAttackController {
// get player life total // get player life total
int humanLife = opp.getLife(); int humanLife = opp.getLife();
// get the list of attackers up to the first blocked one // get the list of attackers up to the first blocked one
final List<Card> attritionalAttackers = new ArrayList<Card>(); final List<Card> attritionalAttackers = new ArrayList<>();
for (int x = 0; x < (this.attackers.size() - humanForces); x++) { for (int x = 0; x < (this.attackers.size() - humanForces); x++) {
attritionalAttackers.add(this.attackers.get(x)); attritionalAttackers.add(this.attackers.get(x));
} }

View File

@@ -39,7 +39,7 @@ import java.util.Map;
* @version $Id: AIProfile.java 20169 2013-03-08 08:24:17Z Agetian $ * @version $Id: AIProfile.java 20169 2013-03-08 08:24:17Z Agetian $
*/ */
public class AiProfileUtil { public class AiProfileUtil {
private static Map<String, Map<AiProps, String>> loadedProfiles = new HashMap<String, Map<AiProps, String>>(); private static Map<String, Map<AiProps, String>> loadedProfiles = new HashMap<>();
private static String AI_PROFILE_DIR; private static String AI_PROFILE_DIR;
private static final String AI_PROFILE_EXT = ".ai"; private static final String AI_PROFILE_EXT = ".ai";
@@ -74,7 +74,7 @@ public class AiProfileUtil {
* @param profileName a profile to load. * @param profileName a profile to load.
*/ */
private static final Map<AiProps, String> loadProfile(final String profileName) { private static final Map<AiProps, String> loadProfile(final String profileName) {
Map<AiProps, String> profileMap = new HashMap<AiProps, String>(); Map<AiProps, String> profileMap = new HashMap<>();
List<String> lines = FileUtil.readFile(buildFileName(profileName)); List<String> lines = FileUtil.readFile(buildFileName(profileName));
for (String line : lines) { for (String line : lines) {
@@ -122,7 +122,7 @@ public class AiProfileUtil {
*/ */
public static List<String> getAvailableProfiles() public static List<String> getAvailableProfiles()
{ {
final List<String> availableProfiles = new ArrayList<String>(); final List<String> availableProfiles = new ArrayList<>();
final File dir = new File(AI_PROFILE_DIR); final File dir = new File(AI_PROFILE_DIR);
final String[] children = dir.list(); final String[] children = dir.list();
@@ -146,7 +146,7 @@ public class AiProfileUtil {
* available profiles including special random profile tags. * available profiles including special random profile tags.
*/ */
public static List<String> getProfilesDisplayList() { public static List<String> getProfilesDisplayList() {
final List<String> availableProfiles = new ArrayList<String>(); final List<String> availableProfiles = new ArrayList<>();
availableProfiles.add(AI_PROFILE_RANDOM_MATCH); availableProfiles.add(AI_PROFILE_RANDOM_MATCH);
availableProfiles.add(AI_PROFILE_RANDOM_DUEL); availableProfiles.add(AI_PROFILE_RANDOM_DUEL);
availableProfiles.addAll(getAvailableProfiles()); availableProfiles.addAll(getAvailableProfiles());

View File

@@ -1514,7 +1514,7 @@ public class ComputerUtil {
*/ */
public static List<GameObject> predictThreatenedObjects(final Player ai, final SpellAbility sa, boolean top) { public static List<GameObject> predictThreatenedObjects(final Player ai, final SpellAbility sa, boolean top) {
final Game game = ai.getGame(); final Game game = ai.getGame();
final List<GameObject> objects = new ArrayList<GameObject>(); final List<GameObject> objects = new ArrayList<>();
if (game.getStack().isEmpty()) { if (game.getStack().isEmpty()) {
return objects; return objects;
} }
@@ -1543,8 +1543,8 @@ public class ComputerUtil {
private static Iterable<? extends GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour, private static Iterable<? extends GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour,
final SpellAbility topStack) { final SpellAbility topStack) {
Iterable<? extends GameObject> objects = new ArrayList<GameObject>(); Iterable<? extends GameObject> objects = new ArrayList<>();
final List<GameObject> threatened = new ArrayList<GameObject>(); final List<GameObject> threatened = new ArrayList<>();
ApiType saviourApi = saviour == null ? null : saviour.getApi(); ApiType saviourApi = saviour == null ? null : saviour.getApi();
int toughness = 0; int toughness = 0;
boolean grantIndestructible = false; boolean grantIndestructible = false;
@@ -1574,7 +1574,7 @@ public class ComputerUtil {
} }
} else { } else {
objects = topStack.getTargets().getTargets(); objects = topStack.getTargets().getTargets();
final List<GameObject> canBeTargeted = new ArrayList<GameObject>(); final List<GameObject> canBeTargeted = new ArrayList<>();
for (Object o : objects) { for (Object o : objects) {
if (o instanceof Card) { if (o instanceof Card) {
final Card c = (Card) o; final Card c = (Card) o;
@@ -1597,7 +1597,7 @@ public class ComputerUtil {
toughness = saviorWithSubs.hasParam("NumDef") ? toughness = saviorWithSubs.hasParam("NumDef") ?
AbilityUtils.calculateAmount(saviorWithSubs.getHostCard(), saviorWithSubs.getParam("NumDef"), saviour) : 0; AbilityUtils.calculateAmount(saviorWithSubs.getHostCard(), saviorWithSubs.getParam("NumDef"), saviour) : 0;
final List<String> keywords = saviorWithSubs.hasParam("KW") ? final List<String> keywords = saviorWithSubs.hasParam("KW") ?
Arrays.asList(saviorWithSubs.getParam("KW").split(" & ")) : new ArrayList<String>(); Arrays.asList(saviorWithSubs.getParam("KW").split(" & ")) : new ArrayList<>();
if (keywords.contains("Indestructible")) { if (keywords.contains("Indestructible")) {
grantIndestructible = true; grantIndestructible = true;
} }
@@ -1630,7 +1630,7 @@ public class ComputerUtil {
final SpellAbility sub = topStack.getSubAbility(); final SpellAbility sub = topStack.getSubAbility();
boolean noRegen = false; boolean noRegen = false;
if (sub != null && sub.getApi() == ApiType.Pump) { if (sub != null && sub.getApi() == ApiType.Pump) {
final List<String> keywords = sub.hasParam("KW") ? Arrays.asList(sub.getParam("KW").split(" & ")) : new ArrayList<String>(); final List<String> keywords = sub.hasParam("KW") ? Arrays.asList(sub.getParam("KW").split(" & ")) : new ArrayList<>();
for (String kw : keywords) { for (String kw : keywords) {
if (kw.contains("can't be regenerated")) { if (kw.contains("can't be regenerated")) {
noRegen = true; noRegen = true;
@@ -2053,7 +2053,7 @@ public class ComputerUtil {
//Too many lands! //Too many lands!
//Init //Init
int cntColors = MagicColor.WUBRG.length; int cntColors = MagicColor.WUBRG.length;
List<CardCollection> numProducers = new ArrayList<CardCollection>(cntColors); List<CardCollection> numProducers = new ArrayList<>(cntColors);
for (byte col : MagicColor.WUBRG) { for (byte col : MagicColor.WUBRG) {
numProducers.add(col, new CardCollection()); numProducers.add(col, new CardCollection());
} }
@@ -2283,7 +2283,7 @@ public class ComputerUtil {
chosen = ComputerUtilCard.getMostProminentType(list, valid); chosen = ComputerUtilCard.getMostProminentType(list, valid);
} else if (logic.equals("MostNeededType")) { } else if (logic.equals("MostNeededType")) {
// Choose a type that is in the deck, but not in hand or on the battlefield // Choose a type that is in the deck, but not in hand or on the battlefield
final List<String> basics = new ArrayList<String>(); final List<String> basics = new ArrayList<>();
basics.addAll(CardType.Constant.BASIC_TYPES); basics.addAll(CardType.Constant.BASIC_TYPES);
CardCollectionView presentCards = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand)); CardCollectionView presentCards = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
CardCollectionView possibleCards = ai.getAllCards(); CardCollectionView possibleCards = ai.getAllCards();
@@ -2588,7 +2588,7 @@ public class ComputerUtil {
int damage = 0; int damage = 0;
final Game game = player.getGame(); final Game game = player.getGame();
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card c : game.getCardsIn(ZoneType.Battlefield)) { for (Card c : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(c.getTriggers()); theTriggers.addAll(c.getTriggers());
@@ -2680,7 +2680,7 @@ public class ComputerUtil {
public static int getDamageFromETB(final Player player, final Card permanent) { public static int getDamageFromETB(final Player player, final Card permanent) {
int damage = 0; int damage = 0;
final Game game = player.getGame(); final Game game = player.getGame();
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());

View File

@@ -564,7 +564,7 @@ public class ComputerUtilCard {
AiBlockController aiBlk = new AiBlockController(ai); AiBlockController aiBlk = new AiBlockController(ai);
Combat combat = new Combat(ai); Combat combat = new Combat(ai);
combat.addAttacker(attacker, ai); combat.addAttacker(attacker, ai);
final List<Card> attackers = new ArrayList<Card>(); final List<Card> attackers = new ArrayList<>();
attackers.add(attacker); attackers.add(attacker);
aiBlk.assignBlockersGivenAttackers(combat, attackers); aiBlk.assignBlockersGivenAttackers(combat, attackers);
return ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, combat); return ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, combat);
@@ -788,7 +788,7 @@ public class ComputerUtilCard {
public static List<String> getColorByProminence(final List<Card> list) { public static List<String> getColorByProminence(final List<Card> list) {
int cntColors = MagicColor.WUBRG.length; int cntColors = MagicColor.WUBRG.length;
final List<Pair<Byte,Integer>> map = new ArrayList<Pair<Byte,Integer>>(); final List<Pair<Byte,Integer>> map = new ArrayList<>();
for(int i = 0; i < cntColors; i++) { for(int i = 0; i < cntColors; i++) {
map.add(MutablePair.of(MagicColor.WUBRG[i], 0)); map.add(MutablePair.of(MagicColor.WUBRG[i], 0));
} }
@@ -810,7 +810,7 @@ public class ComputerUtilCard {
}); });
// will this part be once dropped? // will this part be once dropped?
List<String> result = new ArrayList<String>(cntColors); List<String> result = new ArrayList<>(cntColors);
for(Pair<Byte, Integer> idx : map) { // fetch color names in the same order for(Pair<Byte, Integer> idx : map) { // fetch color names in the same order
result.add(MagicColor.toLongString(idx.getKey())); result.add(MagicColor.toLongString(idx.getKey()));
} }
@@ -882,7 +882,7 @@ public class ComputerUtilCard {
} }
}; };
public static List<String> chooseColor(SpellAbility sa, int min, int max, List<String> colorChoices) { public static List<String> chooseColor(SpellAbility sa, int min, int max, List<String> colorChoices) {
List<String> chosen = new ArrayList<String>(); List<String> chosen = new ArrayList<>();
Player ai = sa.getActivatingPlayer(); Player ai = sa.getActivatingPlayer();
final Game game = ai.getGame(); final Game game = ai.getGame();
Player opp = ai.getWeakestOpponent(); Player opp = ai.getWeakestOpponent();
@@ -1572,7 +1572,7 @@ public class ComputerUtilCard {
Card pumped = CardFactory.copyCard(c, true); Card pumped = CardFactory.copyCard(c, true);
pumped.setSickness(c.hasSickness()); pumped.setSickness(c.hasSickness());
final long timestamp = c.getGame().getNextTimestamp(); final long timestamp = c.getGame().getNextTimestamp();
final List<String> kws = new ArrayList<String>(); final List<String> kws = new ArrayList<>();
for (String kw : keywords) { for (String kw : keywords) {
if (kw.startsWith("HIDDEN")) { if (kw.startsWith("HIDDEN")) {
pumped.addHiddenExtrinsicKeyword(kw); pumped.addHiddenExtrinsicKeyword(kw);

View File

@@ -965,7 +965,7 @@ public class ComputerUtilCombat {
} }
} }
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
} }
@@ -1100,7 +1100,7 @@ public class ComputerUtilCombat {
} }
final Game game = attacker.getGame(); final Game game = attacker.getGame();
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
} }
@@ -1284,7 +1284,7 @@ public class ComputerUtilCombat {
} }
final Game game = attacker.getGame(); final Game game = attacker.getGame();
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
} }
@@ -1505,7 +1505,7 @@ public class ComputerUtilCombat {
} }
final Game game = attacker.getGame(); final Game game = attacker.getGame();
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
} }
@@ -1726,7 +1726,7 @@ public class ComputerUtilCombat {
} }
// check Destroy triggers (Cockatrice and friends) // check Destroy triggers (Cockatrice and friends)
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : attacker.getGame().getCardsIn(ZoneType.Battlefield)) { for (Card card : attacker.getGame().getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
} }
@@ -2006,7 +2006,7 @@ public class ComputerUtilCombat {
} }
final Game game = blocker.getGame(); final Game game = blocker.getGame();
final FCollection<Trigger> theTriggers = new FCollection<Trigger>(); final FCollection<Trigger> theTriggers = new FCollection<>();
for (Card card : game.getCardsIn(ZoneType.Battlefield)) { for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
} }

View File

@@ -365,7 +365,7 @@ public class ComputerUtilMana {
private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, boolean checkPlayable) { private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbility sa, final Player ai, final boolean test, boolean checkPlayable) {
adjustManaCostToAvoidNegEffects(cost, sa.getHostCard(), ai); adjustManaCostToAvoidNegEffects(cost, sa.getHostCard(), ai);
List<Mana> manaSpentToPay = test ? new ArrayList<Mana>() : sa.getPayingMana(); List<Mana> manaSpentToPay = test ? new ArrayList<>() : sa.getPayingMana();
boolean purePhyrexian = cost.containsOnlyPhyrexianMana(); boolean purePhyrexian = cost.containsOnlyPhyrexianMana();
int testEnergyPool = ai.getCounters(CounterType.ENERGY); int testEnergyPool = ai.getCounters(CounterType.ENERGY);
@@ -1359,7 +1359,7 @@ public class ComputerUtilMana {
final ListMultimap<Integer, SpellAbility> manaMap = ArrayListMultimap.create(); final ListMultimap<Integer, SpellAbility> manaMap = ArrayListMultimap.create();
final Game game = ai.getGame(); final Game game = ai.getGame();
List<ReplacementEffect> replacementEffects = new ArrayList<ReplacementEffect>(); List<ReplacementEffect> replacementEffects = new ArrayList<>();
for (final Player p : game.getPlayers()) { for (final Player p : game.getPlayers()) {
for (final Card crd : p.getAllCards()) { for (final Card crd : p.getAllCards()) {
for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) { for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
@@ -1565,7 +1565,7 @@ public class ComputerUtilMana {
* @return map between creatures and shards to convoke * @return map between creatures and shards to convoke
*/ */
public static Map<Card, ManaCostShard> getConvokeOrImproviseFromList(final ManaCost cost, List<Card> list, boolean improvise) { public static Map<Card, ManaCostShard> getConvokeOrImproviseFromList(final ManaCost cost, List<Card> list, boolean improvise) {
final Map<Card, ManaCostShard> convoke = new HashMap<Card, ManaCostShard>(); final Map<Card, ManaCostShard> convoke = new HashMap<>();
Card convoked = null; Card convoked = null;
if (!improvise) { if (!improvise) {
for (ManaCostShard toPay : cost) { for (ManaCostShard toPay : cost) {

View File

@@ -41,7 +41,7 @@ import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
public abstract class GameState { public abstract class GameState {
private static final Map<ZoneType, String> ZONES = new HashMap<ZoneType, String>(); private static final Map<ZoneType, String> ZONES = new HashMap<>();
static { static {
ZONES.put(ZoneType.Battlefield, "battlefield"); ZONES.put(ZoneType.Battlefield, "battlefield");
ZONES.put(ZoneType.Hand, "hand"); ZONES.put(ZoneType.Hand, "hand");
@@ -66,8 +66,8 @@ public abstract class GameState {
private boolean puzzleCreatorState = false; private boolean puzzleCreatorState = false;
private final Map<ZoneType, String> humanCardTexts = new EnumMap<ZoneType, String>(ZoneType.class); private final Map<ZoneType, String> humanCardTexts = new EnumMap<>(ZoneType.class);
private final Map<ZoneType, String> aiCardTexts = new EnumMap<ZoneType, String>(ZoneType.class); private final Map<ZoneType, String> aiCardTexts = new EnumMap<>(ZoneType.class);
private final Map<Integer, Card> idToCard = new HashMap<>(); private final Map<Integer, Card> idToCard = new HashMap<>();
private final Map<Card, Integer> cardToAttachId = new HashMap<>(); private final Map<Card, Integer> cardToAttachId = new HashMap<>();
@@ -1078,7 +1078,7 @@ public abstract class GameState {
p.getZone(zt).removeAllCards(true); p.getZone(zt).removeAllCards(true);
} }
Map<ZoneType, CardCollectionView> playerCards = new EnumMap<ZoneType, CardCollectionView>(ZoneType.class); Map<ZoneType, CardCollectionView> playerCards = new EnumMap<>(ZoneType.class);
for (Entry<ZoneType, String> kv : cardTexts.entrySet()) { for (Entry<ZoneType, String> kv : cardTexts.entrySet()) {
String value = kv.getValue(); String value = kv.getValue();
playerCards.put(kv.getKey(), processCardsForZone(value.isEmpty() ? new String[0] : value.split(";"), p)); playerCards.put(kv.getKey(), processCardsForZone(value.isEmpty() ? new String[0] : value.split(";"), p));
@@ -1091,7 +1091,7 @@ public abstract class GameState {
for (Entry<ZoneType, CardCollectionView> kv : playerCards.entrySet()) { for (Entry<ZoneType, CardCollectionView> kv : playerCards.entrySet()) {
PlayerZone zone = p.getZone(kv.getKey()); PlayerZone zone = p.getZone(kv.getKey());
if (kv.getKey() == ZoneType.Battlefield) { if (kv.getKey() == ZoneType.Battlefield) {
List<Card> cards = new ArrayList<Card>(); List<Card> cards = new ArrayList<>();
for (final Card c : kv.getValue()) { for (final Card c : kv.getValue()) {
if (c.isToken()) { if (c.isToken()) {
cards.add(c); cards.add(c);

View File

@@ -168,8 +168,8 @@ public class PlayerControllerAi extends PlayerController {
if (delayedReveal != null) { if (delayedReveal != null) {
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix()); reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix());
} }
FCollection<T> remaining = new FCollection<T>(optionList); FCollection<T> remaining = new FCollection<>(optionList);
List<T> selecteds = new ArrayList<T>(); List<T> selecteds = new ArrayList<>();
T selected; T selected;
do { do {
selected = chooseSingleEntityForEffect(remaining, null, sa, title, selecteds.size()>=min, targetedPlayer); selected = chooseSingleEntityForEffect(remaining, null, sa, title, selecteds.size()>=min, targetedPlayer);
@@ -1072,7 +1072,7 @@ public class PlayerControllerAi extends PlayerController {
} }
}); });
} else { } else {
return new HashMap<Card, ManaCostShard>(); return new HashMap<>();
} }
} }

View File

@@ -451,7 +451,7 @@ public class AttachAi extends SpellAbilityAi {
*/ */
private static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa, private static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa,
final boolean mandatory) { final boolean mandatory) {
List<Player> targetable = new ArrayList<Player>(); List<Player> targetable = new ArrayList<>();
for (final Player player : aiPlayer.getGame().getPlayers()) { for (final Player player : aiPlayer.getGame().getPlayers()) {
if (sa.canTarget(player)) { if (sa.canTarget(player)) {
targetable.add(player); targetable.add(player);
@@ -855,7 +855,7 @@ public class AttachAi extends SpellAbilityAi {
int totToughness = 0; int totToughness = 0;
int totPower = 0; int totPower = 0;
final List<String> keywords = new ArrayList<String>(); final List<String> keywords = new ArrayList<>();
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) { for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
final Map<String, String> stabMap = stAbility.getMapParams(); final Map<String, String> stabMap = stAbility.getMapParams();
@@ -906,7 +906,7 @@ public class AttachAi extends SpellAbilityAi {
Card c = null; Card c = null;
if (prefList == null || prefList.isEmpty()) { if (prefList == null || prefList.isEmpty()) {
prefList = new ArrayList<Card>(list); prefList = new ArrayList<>(list);
} else { } else {
c = ComputerUtilCard.getBestAI(prefList); c = ComputerUtilCard.getBestAI(prefList);
if (c != null) { if (c != null) {
@@ -960,7 +960,7 @@ public class AttachAi extends SpellAbilityAi {
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) { protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
// Check if there are any valid targets // Check if there are any valid targets
List<GameObject> targets = new ArrayList<GameObject>(); List<GameObject> targets = new ArrayList<>();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt == null) { if (tgt == null) {
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa); targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
@@ -1150,7 +1150,7 @@ public class AttachAi extends SpellAbilityAi {
int totToughness = 0; int totToughness = 0;
int totPower = 0; int totPower = 0;
final List<String> keywords = new ArrayList<String>(); final List<String> keywords = new ArrayList<>();
boolean grantingAbilities = false; boolean grantingAbilities = false;
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) { for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {

View File

@@ -482,7 +482,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
} }
List<ZoneType> origin = new ArrayList<ZoneType>(); List<ZoneType> origin = new ArrayList<>();
if (sa.hasParam("Origin")) { if (sa.hasParam("Origin")) {
origin = ZoneType.listValueOf(sa.getParam("Origin")); origin = ZoneType.listValueOf(sa.getParam("Origin"));
} }
@@ -557,7 +557,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
*/ */
private static Card basicManaFixing(final Player ai, final List<Card> list) { // Search for a Basic Land private static Card basicManaFixing(final Player ai, final List<Card> list) { // Search for a Basic Land
final CardCollectionView combined = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand)); final CardCollectionView combined = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
final List<String> basics = new ArrayList<String>(); final List<String> basics = new ArrayList<>();
// what types can I go get? // what types can I go get?
for (final String name : MagicColor.Constant.BASIC_LANDS) { for (final String name : MagicColor.Constant.BASIC_LANDS) {
@@ -1281,7 +1281,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
final List<GameObject> objects = ComputerUtil final List<GameObject> objects = ComputerUtil
.predictThreatenedObjects(ai, sa); .predictThreatenedObjects(ai, sa);
final List<Card> threatenedTargets = new ArrayList<Card>(); final List<Card> threatenedTargets = new ArrayList<>();
for (final Card c : aiPermanents) { for (final Card c : aiPermanents) {
if (objects.contains(c)) { if (objects.contains(c)) {

View File

@@ -103,7 +103,7 @@ public class ChooseGenericEffectAi extends SpellAbilityAi {
Cost unless = new Cost(unlessCost, false); Cost unless = new Cost(unlessCost, false);
SpellAbility paycost = new SpellAbility.EmptySa(sa.getHostCard(), player); SpellAbility paycost = new SpellAbility.EmptySa(sa.getHostCard(), player);
paycost.setPayCosts(unless); paycost.setPayCosts(unless);
if (ComputerUtilCost.willPayUnlessCost(sp, player, unless, false, new FCollection<Player>(player)) if (ComputerUtilCost.willPayUnlessCost(sp, player, unless, false, new FCollection<>(player))
&& ComputerUtilCost.canPayCost(paycost, player)) { && ComputerUtilCost.canPayCost(paycost, player)) {
return sp; return sp;
} }

View File

@@ -100,7 +100,7 @@ public class DamagePreventAi extends SpellAbilityAi {
tcs.add(ai); tcs.add(ai);
chance = true; chance = true;
} }
final List<Card> threatenedTargets = new ArrayList<Card>(); final List<Card> threatenedTargets = new ArrayList<>();
// filter AIs battlefield by what I can target // filter AIs battlefield by what I can target
List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard, sa); List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard, sa);
targetables = CardLists.getTargetableCards(targetables, sa); targetables = CardLists.getTargetableCards(targetables, sa);

View File

@@ -266,7 +266,7 @@ public class DebuffAi extends SpellAbilityAi {
@Override @Override
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) { protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>(); final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<>();
if (sa.getTargetRestrictions() == null) { if (sa.getTargetRestrictions() == null) {
if (mandatory) { if (mandatory) {

View File

@@ -182,7 +182,7 @@ public class LifeLoseAi extends SpellAbilityAi {
} }
final List<Player> tgtPlayers = sa.usesTargeting() && !sa.hasParam("Defined") final List<Player> tgtPlayers = sa.usesTargeting() && !sa.hasParam("Defined")
? new FCollection<Player>(sa.getTargets().getTargetPlayers()) ? new FCollection<>(sa.getTargets().getTargetPlayers())
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa); : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
// For cards like Foul Imp, ETB you lose life // For cards like Foul Imp, ETB you lose life

View File

@@ -30,7 +30,7 @@ import forge.util.MyRandom;
public class ProtectAi extends SpellAbilityAi { public class ProtectAi extends SpellAbilityAi {
private static boolean hasProtectionFrom(final Card card, final String color) { private static boolean hasProtectionFrom(final Card card, final String color) {
final List<String> onlyColors = new ArrayList<String>(MagicColor.Constant.ONLY_COLORS); final List<String> onlyColors = new ArrayList<>(MagicColor.Constant.ONLY_COLORS);
// make sure we have a valid color // make sure we have a valid color
if (!onlyColors.contains(color)) { if (!onlyColors.contains(color)) {

View File

@@ -50,7 +50,7 @@ public class PumpAllAi extends PumpAiBase {
final int power = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa); final int power = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa);
final int defense = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa); final int defense = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa);
final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<String>(); final List<String> keywords = sa.hasParam("KW") ? Arrays.asList(sa.getParam("KW").split(" & ")) : new ArrayList<>();
final PhaseType phase = game.getPhaseHandler().getPhase(); final PhaseType phase = game.getPhaseHandler().getPhase();

View File

@@ -106,7 +106,7 @@ public class RegenerateAi extends SpellAbilityAi {
// control // control
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa, true); final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa, true);
final List<Card> threatenedTargets = new ArrayList<Card>(); final List<Card> threatenedTargets = new ArrayList<>();
for (final Card c : targetables) { for (final Card c : targetables) {
if (objects.contains(c) && c.getShieldCount() == 0 && !ComputerUtil.canRegenerate(ai, c)) { if (objects.contains(c) && c.getShieldCount() == 0 && !ComputerUtil.canRegenerate(ai, c)) {

View File

@@ -47,7 +47,7 @@ public class StoreSVarAi extends SpellAbilityAi {
possibleBlockers = CardLists.filter(possibleBlockers, Presets.UNTAPPED); possibleBlockers = CardLists.filter(possibleBlockers, Presets.UNTAPPED);
int oppLife = opp.getLife(); int oppLife = opp.getLife();
int potentialDmg = 0; int potentialDmg = 0;
List<Card> currentAttackers = new ArrayList<Card>(); List<Card> currentAttackers = new ArrayList<>();
if (possibleBlockers.size() == 0) { return false; } if (possibleBlockers.size() == 0) { return false; }

View File

@@ -435,7 +435,7 @@ public class TokenAi extends SpellAbilityAi {
} }
} }
final List<String> imageNames = new ArrayList<String>(1); final List<String> imageNames = new ArrayList<>(1);
if (tokenImage.equals("")) { if (tokenImage.equals("")) {
imageNames.add(PaperToken.makeTokenFileName(TextUtil.fastReplace(colorDesc, " ", ""), tokenPower, tokenToughness, tokenName)); imageNames.add(PaperToken.makeTokenFileName(TextUtil.fastReplace(colorDesc, " ", ""), tokenPower, tokenToughness, tokenName));
} else { } else {

View File

@@ -39,7 +39,7 @@ public class TwoPilesAi extends SpellAbilityAi {
} }
final List<Player> tgtPlayers = sa.usesTargeting() && !sa.hasParam("Defined") final List<Player> tgtPlayers = sa.usesTargeting() && !sa.hasParam("Defined")
? new FCollection<Player>(sa.getTargets().getTargetPlayers()) ? new FCollection<>(sa.getTargets().getTargetPlayers())
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa); : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Defined"), sa);
final Player p = tgtPlayers.get(0); final Player p = tgtPlayers.get(0);

View File

@@ -66,7 +66,7 @@ public class UnattachAllAi extends SpellAbilityAi {
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
final Player opp = ai.getWeakestOpponent(); final Player opp = ai.getWeakestOpponent();
// Check if there are any valid targets // Check if there are any valid targets
List<GameObject> targets = new ArrayList<GameObject>(); List<GameObject> targets = new ArrayList<>();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (tgt == null) { if (tgt == null) {
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa); targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);

View File

@@ -38,7 +38,7 @@ public class GameSimulator {
aiPlayer = (Player) copier.find(origAiPlayer); aiPlayer = (Player) copier.find(origAiPlayer);
eval = new GameStateEvaluator(); eval = new GameStateEvaluator();
origLines = new ArrayList<String>(); origLines = new ArrayList<>();
debugLines = origLines; debugLines = origLines;
debugPrint = false; debugPrint = false;
@@ -52,7 +52,7 @@ public class GameSimulator {
// first and get the updated eval score, since this is what we'll // first and get the updated eval score, since this is what we'll
// want to compare to the eval score after simulating. // want to compare to the eval score after simulating.
if (COPY_STACK && !origGame.getStackZone().isEmpty()) { if (COPY_STACK && !origGame.getStackZone().isEmpty()) {
origLines = new ArrayList<String>(); origLines = new ArrayList<>();
debugLines = origLines; debugLines = origLines;
Game copyOrigGame = copier.makeCopy(); Game copyOrigGame = copier.makeCopy();
Player copyOrigAiPlayer = copyOrigGame.getPlayers().get(1); Player copyOrigAiPlayer = copyOrigGame.getPlayers().get(1);
@@ -66,12 +66,12 @@ public class GameSimulator {
private void ensureGameCopyScoreMatches(Game origGame, Player origAiPlayer) { private void ensureGameCopyScoreMatches(Game origGame, Player origAiPlayer) {
eval.setDebugging(true); eval.setDebugging(true);
List<String> simLines = new ArrayList<String>(); List<String> simLines = new ArrayList<>();
debugLines = simLines; debugLines = simLines;
Score simScore = eval.getScoreForGameState(simGame, aiPlayer); Score simScore = eval.getScoreForGameState(simGame, aiPlayer);
if (!simScore.equals(origScore)) { if (!simScore.equals(origScore)) {
// Re-eval orig with debug printing. // Re-eval orig with debug printing.
origLines = new ArrayList<String>(); origLines = new ArrayList<>();
debugLines = origLines; debugLines = origLines;
eval.getScoreForGameState(origGame, origAiPlayer); eval.getScoreForGameState(origGame, origAiPlayer);
// Print debug info. // Print debug info.
@@ -216,7 +216,7 @@ public class GameSimulator {
List<String> simLines = null; List<String> simLines = null;
if (debugPrint) { if (debugPrint) {
debugPrint("SimGame:"); debugPrint("SimGame:");
simLines = new ArrayList<String>(); simLines = new ArrayList<>();
debugLines = simLines; debugLines = simLines;
debugPrint = false; debugPrint = false;
} }
@@ -245,7 +245,7 @@ public class GameSimulator {
opponent.runWithController(new Runnable() { opponent.runWithController(new Runnable() {
@Override @Override
public void run() { public void run() {
final Set<Card> allAffectedCards = new HashSet<Card>(); final Set<Card> allAffectedCards = new HashSet<>();
game.getAction().checkStateEffects(false, allAffectedCards); game.getAction().checkStateEffects(false, allAffectedCards);
game.getStack().addAllTriggeredAbilitiesToStack(); game.getStack().addAllTriggeredAbilitiesToStack();
while (!game.getStack().isEmpty() && !game.isGameOver()) { while (!game.getStack().isEmpty() && !game.isGameOver()) {

View File

@@ -51,7 +51,7 @@ public class PossibleTargetSelector {
this.sa = sa; this.sa = sa;
this.targetingSa = targetingSa; this.targetingSa = targetingSa;
this.targetingSaIndex = targetingSaIndex; this.targetingSaIndex = targetingSaIndex;
this.validTargets = new ArrayList<GameObject>(); this.validTargets = new ArrayList<>();
generateValidTargets(sa.getHostCard().getController()); generateValidTargets(sa.getHostCard().getController());
} }
@@ -81,7 +81,7 @@ public class PossibleTargetSelector {
private static class SimilarTargetSkipper { private static class SimilarTargetSkipper {
private ArrayListMultimap<String, Card> validTargetsMap = ArrayListMultimap.create(); private ArrayListMultimap<String, Card> validTargetsMap = ArrayListMultimap.create();
private HashMap<Card, String> cardTypeStrings = new HashMap<Card, String>(); private HashMap<Card, String> cardTypeStrings = new HashMap<>();
private HashMap<Card, Integer> creatureScores; private HashMap<Card, Integer> creatureScores;
private int getCreatureScore(Card c) { private int getCreatureScore(Card c) {
@@ -91,7 +91,7 @@ public class PossibleTargetSelector {
return score; return score;
} }
} else { } else {
creatureScores = new HashMap<Card, Integer>(); creatureScores = new HashMap<>();
} }
int score = ComputerUtilCard.evaluateCreature(c); int score = ComputerUtilCard.evaluateCreature(c);

View File

@@ -18,7 +18,7 @@ public class SimulationController {
private List<GameSimulator> simulatorStack; private List<GameSimulator> simulatorStack;
private Plan.Decision bestSequence; // last action of sequence private Plan.Decision bestSequence; // last action of sequence
private Score bestScore; private Score bestScore;
private List<CachedEffect> effectCache = new ArrayList<CachedEffect>(); private List<CachedEffect> effectCache = new ArrayList<>();
private GameObject[] currentHostAndTarget; private GameObject[] currentHostAndTarget;
private static class CachedEffect { private static class CachedEffect {
@@ -39,10 +39,10 @@ public class SimulationController {
public SimulationController(Score score) { public SimulationController(Score score) {
bestScore = score; bestScore = score;
scoreStack = new ArrayList<Score>(); scoreStack = new ArrayList<>();
scoreStack.add(score); scoreStack.add(score);
simulatorStack = new ArrayList<GameSimulator>(); simulatorStack = new ArrayList<>();
currentStack = new ArrayList<Plan.Decision>(); currentStack = new ArrayList<>();
} }
private int getRecursionDepth() { private int getRecursionDepth() {
@@ -97,7 +97,7 @@ public class SimulationController {
throw new RuntimeException("getBestPlan() expects currentStack to be empty!"); throw new RuntimeException("getBestPlan() expects currentStack to be empty!");
} }
ArrayList<Plan.Decision> sequence = new ArrayList<Plan.Decision>(); ArrayList<Plan.Decision> sequence = new ArrayList<>();
Plan.Decision current = bestSequence; Plan.Decision current = bestSequence;
while (current != null) { while (current != null) {
sequence.add(current); sequence.add(current);

View File

@@ -84,7 +84,7 @@ public class SpellAbilityChoicesIterator {
} }
ChoicePoint cp = choicePoints.get(cpIndex); ChoicePoint cp = choicePoints.get(cpIndex);
// Prune duplicates. // Prune duplicates.
HashSet<String> uniqueCards = new HashSet<String>(); HashSet<String> uniqueCards = new HashSet<>();
for (int i = 0; i < fetchList.size(); i++) { for (int i = 0; i < fetchList.size(); i++) {
Card card = fetchList.get(i); Card card = fetchList.get(i);
if (uniqueCards.add(card.getName()) && uniqueCards.size() == cp.nextChoice + 1) { if (uniqueCards.add(card.getName()) && uniqueCards.size() == cp.nextChoice + 1) {
@@ -213,7 +213,7 @@ public class SpellAbilityChoicesIterator {
} }
public static List<AbilitySub> getModeCombination(List<AbilitySub> choices, int[] modeIndexes) { public static List<AbilitySub> getModeCombination(List<AbilitySub> choices, int[] modeIndexes) {
ArrayList<AbilitySub> modes = new ArrayList<AbilitySub>(); ArrayList<AbilitySub> modes = new ArrayList<>();
for (int modeIndex : modeIndexes) { for (int modeIndex : modeIndexes) {
modes.add(choices.get(modeIndex)); modes.add(choices.get(modeIndex));
} }

View File

@@ -61,7 +61,7 @@ public class SpellAbilityPicker {
List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, player); List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, player);
CardCollection landsToPlay = ComputerUtilAbility.getAvailableLandsToPlay(game, player); CardCollection landsToPlay = ComputerUtilAbility.getAvailableLandsToPlay(game, player);
if (landsToPlay != null) { if (landsToPlay != null) {
HashMap<String, Card> landsDeDupe = new HashMap<String, Card>(); HashMap<String, Card> landsDeDupe = new HashMap<>();
for (Card land : landsToPlay) { for (Card land : landsToPlay) {
Card previousLand = landsDeDupe.get(land.getName()); Card previousLand = landsDeDupe.get(land.getName());
// Skip identical lands. // Skip identical lands.
@@ -165,7 +165,7 @@ public class SpellAbilityPicker {
PhaseType currentPhase = game.getPhaseHandler().getPhase(); PhaseType currentPhase = game.getPhaseHandler().getPhase();
if (currentPhase.isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) { if (currentPhase.isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
List<SpellAbility> candidateSAs2 = new ArrayList<SpellAbility>(); List<SpellAbility> candidateSAs2 = new ArrayList<>();
for (SpellAbility sa : candidateSAs) { for (SpellAbility sa : candidateSAs) {
if (!isSorcerySpeed(sa, player)) { if (!isSorcerySpeed(sa, player)) {
System.err.println("Not sorcery: " + sa); System.err.println("Not sorcery: " + sa);

View File

@@ -175,7 +175,7 @@ public class CardStorageReader {
} }
if (zipEntriesMap == null) { if (zipEntriesMap == null) {
zipEntriesMap = new HashMap<String, ZipEntry>(); zipEntriesMap = new HashMap<>();
for (ZipEntry entry : getZipEntries()) { for (ZipEntry entry : getZipEntries()) {
zipEntriesMap.put(entry.getName(), entry); zipEntriesMap.put(entry.getName(), entry);
} }
@@ -256,7 +256,7 @@ public class CardStorageReader {
return result; return result;
} }
final List<File> allFiles = collectCardFiles(new ArrayList<File>(), this.cardsfolder); final List<File> allFiles = collectCardFiles(new ArrayList<>(), this.cardsfolder);
if (!allFiles.isEmpty()) { if (!allFiles.isEmpty()) {
int fileParts = zip == null ? NUMBER_OF_PARTS : 1 + NUMBER_OF_PARTS / 3; int fileParts = zip == null ? NUMBER_OF_PARTS : 1 + NUMBER_OF_PARTS / 3;
if (allFiles.size() < fileParts * 100) { if (allFiles.size() < fileParts * 100) {

View File

@@ -8,7 +8,7 @@ import java.util.Map;
public class FTrace { public class FTrace {
private static long appStartTime; private static long appStartTime;
private static Map<String, FTrace> traces = new HashMap<String, FTrace>(); private static Map<String, FTrace> traces = new HashMap<>();
public static void initialize() { public static void initialize() {
appStartTime = new Date().getTime(); appStartTime = new Date().getTime();

View File

@@ -110,7 +110,7 @@ public class StaticData {
private List<CardEdition> sortedEditions; private List<CardEdition> sortedEditions;
public final List<CardEdition> getSortedEditions() { public final List<CardEdition> getSortedEditions() {
if (sortedEditions == null) { if (sortedEditions == null) {
sortedEditions = new ArrayList<CardEdition>(); sortedEditions = new ArrayList<>();
for (CardEdition set : editions) { for (CardEdition set : editions) {
sortedEditions.add(set); sortedEditions.add(set);
} }

View File

@@ -41,16 +41,16 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
public final static char NameSetSeparator = '|'; public final static char NameSetSeparator = '|';
// need this to obtain cardReference by name+set+artindex // need this to obtain cardReference by name+set+artindex
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<String,Collection<PaperCard>>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
private final Map<String, PaperCard> uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); private final Map<String, PaperCard> uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
private final Map<String, CardRules> rulesByName; private final Map<String, CardRules> rulesByName;
private final Map<String, ICardFace> facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); private final Map<String, ICardFace> facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
private static Map<String, String> artPrefs = new HashMap<String, String>(); private static Map<String, String> artPrefs = new HashMap<>();
private final Map<String, String> alternateName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); private final Map<String, String> alternateName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
private final Map<String, Integer> artIds = new HashMap<String, Integer>(); private final Map<String, Integer> artIds = new HashMap<>();
private final List<PaperCard> allCards = new ArrayList<PaperCard>(); private final List<PaperCard> allCards = new ArrayList<>();
private final List<PaperCard> roAllCards = Collections.unmodifiableList(allCards); private final List<PaperCard> roAllCards = Collections.unmodifiableList(allCards);
private final CardEdition.Collection editions; private final CardEdition.Collection editions;
@@ -166,8 +166,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
} }
public void initialize(boolean logMissingPerEdition, boolean logMissingSummary) { public void initialize(boolean logMissingPerEdition, boolean logMissingSummary) {
Set<String> allMissingCards = new LinkedHashSet<String>(); Set<String> allMissingCards = new LinkedHashSet<>();
List<String> missingCards = new ArrayList<String>(); List<String> missingCards = new ArrayList<>();
CardEdition upcomingSet = null; CardEdition upcomingSet = null;
Date today = new Date(); Date today = new Date();
@@ -342,10 +342,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
if (request.artIndex <= 0) { // this stands for 'random art' if (request.artIndex <= 0) { // this stands for 'random art'
Collection<PaperCard> candidates; Collection<PaperCard> candidates;
if (reqEdition == null) { if (reqEdition == null) {
candidates = new ArrayList<PaperCard>(cards); candidates = new ArrayList<>(cards);
} }
else { else {
candidates = new ArrayList<PaperCard>(); candidates = new ArrayList<>();
for (PaperCard pc : cards) { for (PaperCard pc : cards) {
if (pc.getEdition().equalsIgnoreCase(reqEdition)) { if (pc.getEdition().equalsIgnoreCase(reqEdition)) {
candidates.add(pc); candidates.add(pc);
@@ -452,7 +452,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
firstWithoutImage = pc; //ensure first without image returns if none have image firstWithoutImage = pc; //ensure first without image returns if none have image
} }
if (cardsListReadOnly) { //ensure we don't modify a cached collection if (cardsListReadOnly) { //ensure we don't modify a cached collection
cards = new ArrayList<PaperCard>(cards); cards = new ArrayList<>(cards);
cardsListReadOnly = false; cardsListReadOnly = false;
} }
cards.remove(randomIndex); //remove card from collection and try another random card cards.remove(randomIndex); //remove card from collection and try another random card
@@ -686,7 +686,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
result = rulesByName.put(cardName, rules); result = rulesByName.put(cardName, rules);
// 1. generate all paper cards from edition data we have (either explicit, or found in res/editions, or add to unknown edition) // 1. generate all paper cards from edition data we have (either explicit, or found in res/editions, or add to unknown edition)
List<PaperCard> paperCards = new ArrayList<PaperCard>(); List<PaperCard> paperCards = new ArrayList<>();
if (null == whenItWasPrinted || whenItWasPrinted.isEmpty()) { if (null == whenItWasPrinted || whenItWasPrinted.isEmpty()) {
for (CardEdition e : editions.getOrderedEditions()) { for (CardEdition e : editions.getOrderedEditions()) {
int artIdx = 1; int artIdx = 1;

View File

@@ -24,8 +24,8 @@ final class CardFace implements ICardFace {
} }
private final static List<String> emptyList = Collections.unmodifiableList(new ArrayList<String>()); private final static List<String> emptyList = Collections.unmodifiableList(new ArrayList<>());
private final static Map<String, String> emptyMap = Collections.unmodifiableMap(new TreeMap<String, String>()); private final static Map<String, String> emptyMap = Collections.unmodifiableMap(new TreeMap<>());
private final String name; private final String name;
private String altName = null; private String altName = null;
@@ -112,12 +112,12 @@ final class CardFace implements ICardFace {
// Raw fields used for Card creation // Raw fields used for Card creation
void setNonAbilityText(String value) { this.nonAbilityText = value; } void setNonAbilityText(String value) { this.nonAbilityText = value; }
void addKeyword(String value) { if (null == this.keywords) { this.keywords = new ArrayList<String>(); } this.keywords.add(value); } void addKeyword(String value) { if (null == this.keywords) { this.keywords = new ArrayList<>(); } this.keywords.add(value); }
void addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<String>(); } this.abilities.add(value);} void addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<>(); } this.abilities.add(value);}
void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<String>(); } this.triggers.add(value);} void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<>(); } this.triggers.add(value);}
void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<String>(); } this.staticAbilities.add(value);} void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<>(); } this.staticAbilities.add(value);}
void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<String>(); } this.replacements.add(value);} void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<>(); } this.replacements.add(value);}
void addSVar(String key, String value) { if (null == this.variables) { this.variables = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); } void addSVar(String key, String value) { if (null == this.variables) { this.variables = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); }
void assignMissingFields() { // Most scripts do not specify color explicitly void assignMissingFields() { // Most scripts do not specify color explicitly

View File

@@ -627,7 +627,7 @@ public final class CardRulesPredicates {
public static final Predicate<CardRules> IS_MONOCOLOR = CardRulesPredicates.hasCntColors((byte) 1); public static final Predicate<CardRules> IS_MONOCOLOR = CardRulesPredicates.hasCntColors((byte) 1);
/** The Constant colors. */ /** The Constant colors. */
public static final List<Predicate<CardRules>> COLORS = new ArrayList<Predicate<CardRules>>(); public static final List<Predicate<CardRules>> COLORS = new ArrayList<>();
static { static {
Presets.COLORS.add(Presets.IS_WHITE); Presets.COLORS.add(Presets.IS_WHITE);
Presets.COLORS.add(Presets.IS_BLUE); Presets.COLORS.add(Presets.IS_BLUE);

View File

@@ -320,7 +320,7 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
if (isColorless()) { if (isColorless()) {
return EnumSet.of(Color.COLORLESS); return EnumSet.of(Color.COLORLESS);
} }
List<Color> list = new ArrayList<Color>(); List<Color> list = new ArrayList<>();
for (Color c : Color.values()) { for (Color c : Color.values()) {
if (hasAnyColor(c.getColormask())) { if (hasAnyColor(c.getColormask())) {
list.add(c); list.add(c);

View File

@@ -96,7 +96,7 @@ public class PrintSheet {
number -= uniqueCards; number -= uniqueCards;
} }
List<PaperCard> uniques = wantUnique ? new ArrayList<PaperCard>() : null; List<PaperCard> uniques = wantUnique ? new ArrayList<>() : null;
for(int iC = 0; iC < number; iC++) { for(int iC = 0; iC < number; iC++) {
int index = MyRandom.getRandom().nextInt(totalWeight); int index = MyRandom.getRandom().nextInt(totalWeight);
PaperCard toAdd = fetchRoulette(0, index, wantUnique ? uniques : null); PaperCard toAdd = fetchRoulette(0, index, wantUnique ? uniques : null);

View File

@@ -39,8 +39,8 @@ import java.util.Map.Entry;
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPool>> { public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPool>> {
private final Map<DeckSection, CardPool> parts = new EnumMap<DeckSection, CardPool>(DeckSection.class); private final Map<DeckSection, CardPool> parts = new EnumMap<>(DeckSection.class);
private final Set<String> tags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); private final Set<String> tags = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
// Supports deferring loading a deck until we actually need its contents. This works in conjunction with // Supports deferring loading a deck until we actually need its contents. This works in conjunction with
// the lazy card load feature to ensure we don't need to load all cards on start up. // the lazy card load feature to ensure we don't need to load all cards on start up.
private Map<String, List<String>> deferredSections; private Map<String, List<String>> deferredSections;

View File

@@ -263,7 +263,7 @@ public enum DeckFormat {
} }
} }
final List<PaperCard> erroneousCI = new ArrayList<PaperCard>(); final List<PaperCard> erroneousCI = new ArrayList<>();
Set<String> basicLandNames = new HashSet<>(); Set<String> basicLandNames = new HashSet<>();
for (final Entry<PaperCard, Integer> cp : deck.get(DeckSection.Main)) { for (final Entry<PaperCard, Integer> cp : deck.get(DeckSection.Main)) {
@@ -306,7 +306,7 @@ public enum DeckFormat {
} }
if (cardPoolFilter != null) { if (cardPoolFilter != null) {
final List<PaperCard> erroneousCI = new ArrayList<PaperCard>(); final List<PaperCard> erroneousCI = new ArrayList<>();
for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) { for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) {
if (!cardPoolFilter.apply(cp.getKey().getRules())) { if (!cardPoolFilter.apply(cp.getKey().getRules())) {
erroneousCI.add(cp.getKey()); erroneousCI.add(cp.getKey());

View File

@@ -37,7 +37,7 @@ public class DeckGroup extends DeckBase {
private static final long serialVersionUID = -1628725522049635829L; private static final long serialVersionUID = -1628725522049635829L;
private Deck humanDeck; private Deck humanDeck;
private List<Deck> aiDecks = new ArrayList<Deck>(); private List<Deck> aiDecks = new ArrayList<>();
/** /**
* Gets the human deck. * Gets the human deck.

View File

@@ -11,7 +11,7 @@ import forge.item.IPaperCard;
import forge.item.PaperCard; import forge.item.PaperCard;
public class DeckGenPool implements IDeckGenPool { public class DeckGenPool implements IDeckGenPool {
private final Map<String, PaperCard> cards = new HashMap<String, PaperCard>(); private final Map<String, PaperCard> cards = new HashMap<>();
public DeckGenPool() { public DeckGenPool() {
} }

View File

@@ -51,7 +51,7 @@ import java.util.regex.Pattern;
*/ */
public abstract class DeckGeneratorBase { public abstract class DeckGeneratorBase {
protected final DebugTrace trace = new DebugTrace(); protected final DebugTrace trace = new DebugTrace();
protected final Map<String, Integer> cardCounts = new HashMap<String, Integer>(); protected final Map<String, Integer> cardCounts = new HashMap<>();
protected int maxDuplicates = 4; protected int maxDuplicates = 4;
protected boolean useArtifacts = true; protected boolean useArtifacts = true;
protected String basicLandEdition = null; protected String basicLandEdition = null;
@@ -299,7 +299,7 @@ public abstract class DeckGeneratorBase {
protected static Map<String, Integer> countLands(ItemPool<PaperCard> outList) { protected static Map<String, Integer> countLands(ItemPool<PaperCard> outList) {
// attempt to optimize basic land counts according // attempt to optimize basic land counts according
// to color representation // to color representation
Map<String, Integer> res = new TreeMap<String, Integer>(); Map<String, Integer> res = new TreeMap<>();
// count each card color using mana costs // count each card color using mana costs
// TODO: count hybrid mana differently? // TODO: count hybrid mana differently?
for (Entry<PaperCard, Integer> cpe : outList) { for (Entry<PaperCard, Integer> cpe : outList) {
@@ -418,7 +418,7 @@ public abstract class DeckGeneratorBase {
} }
public List<String> regexLandSearch(String pattern, Iterable<PaperCard> landCards){ public List<String> regexLandSearch(String pattern, Iterable<PaperCard> landCards){
final List<String> dLands = new ArrayList<String>(); final List<String> dLands = new ArrayList<>();
Pattern p = Pattern.compile(pattern); Pattern p = Pattern.compile(pattern);
for (PaperCard card:landCards){ for (PaperCard card:landCards){
if (card.getRules().getAiHints().getRemAIDecks()) { if (card.getRules().getAiHints().getRemAIDecks()) {

View File

@@ -74,7 +74,7 @@ public class DeckFileHeader {
this.deckType = DeckFormat.smartValueOf(kvPairs.get(DeckFileHeader.DECK_TYPE), DeckFormat.Constructed); this.deckType = DeckFormat.smartValueOf(kvPairs.get(DeckFileHeader.DECK_TYPE), DeckFormat.Constructed);
this.customPool = kvPairs.getBoolean(DeckFileHeader.CSTM_POOL); this.customPool = kvPairs.getBoolean(DeckFileHeader.CSTM_POOL);
this.intendedForAi = "computer".equalsIgnoreCase(kvPairs.get(DeckFileHeader.PLAYER)) || "ai".equalsIgnoreCase(kvPairs.get(DeckFileHeader.PLAYER_TYPE)); this.intendedForAi = "computer".equalsIgnoreCase(kvPairs.get(DeckFileHeader.PLAYER)) || "ai".equalsIgnoreCase(kvPairs.get(DeckFileHeader.PLAYER_TYPE));
this.tags = new TreeSet<String>(); this.tags = new TreeSet<>();
String rawTags = kvPairs.get(DeckFileHeader.TAGS); String rawTags = kvPairs.get(DeckFileHeader.TAGS);
if( StringUtils.isNotBlank(rawTags) ) { if( StringUtils.isNotBlank(rawTags) ) {

View File

@@ -41,7 +41,7 @@ public class DeckSerializer {
} }
private static List<String> serializeDeck(Deck d) { private static List<String> serializeDeck(Deck d) {
final List<String> out = new ArrayList<String>(); final List<String> out = new ArrayList<>();
out.add(TextUtil.enclosedBracket("metadata")); out.add(TextUtil.enclosedBracket("metadata"));
out.add(TextUtil.concatNoSpace(DeckFileHeader.NAME,"=", d.getName().replaceAll("\n", ""))); out.add(TextUtil.concatNoSpace(DeckFileHeader.NAME,"=", d.getName().replaceAll("\n", "")));

View File

@@ -93,7 +93,7 @@ public class BoosterBox extends BoxedProduct {
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ','); final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
int nBoosters = 6; int nBoosters = 6;
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>(); List<Pair<String, Integer>> slots = new ArrayList<>();
for(String slotDesc : data) { for(String slotDesc : data) {
String[] kv = TextUtil.split(slotDesc, ' ', 2); String[] kv = TextUtil.split(slotDesc, ' ', 2);
if (kv[1].startsWith("Booster")) if (kv[1].startsWith("Booster"))

View File

@@ -44,7 +44,7 @@ public abstract class BoxedProduct extends SealedProduct {
} }
public List<PaperCard> getExtraCards() { public List<PaperCard> getExtraCards() {
return new ArrayList<PaperCard>(); return new ArrayList<>();
} }
@Override @Override

View File

@@ -111,7 +111,7 @@ public class FatPack extends BoxedProduct {
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ','); final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
int nBoosters = 6; int nBoosters = 6;
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>(); List<Pair<String, Integer>> slots = new ArrayList<>();
for(String slotDesc : data) { for(String slotDesc : data) {
String[] kv = TextUtil.split(slotDesc, ' ', 2); String[] kv = TextUtil.split(slotDesc, ' ', 2);
if (kv[1].startsWith("Booster")) if (kv[1].startsWith("Booster"))

View File

@@ -124,7 +124,7 @@ public class Aggregates {
} }
public static final <T> List<T> random(final Iterable<T> source, final int count) { public static final <T> List<T> random(final Iterable<T> source, final int count) {
return random(source, count, new ArrayList<T>()); return random(source, count, new ArrayList<>());
} }
public static final <T, L extends List<T>> L random(final Iterable<T> source, final int count, final L list) { public static final <T, L extends List<T>> L random(final Iterable<T> source, final int count, final L list) {
// Using Reservoir Sampling to grab X random values from source // Using Reservoir Sampling to grab X random values from source
@@ -163,7 +163,7 @@ public class Aggregates {
} }
public static final <K, U> Iterable<U> uniqueByLast(final Iterable<U> source, final Function<U, K> fnUniqueKey) { // this might be exotic public static final <K, U> Iterable<U> uniqueByLast(final Iterable<U> source, final Function<U, K> fnUniqueKey) { // this might be exotic
final Map<K, U> uniques = new Hashtable<K, U>(); final Map<K, U> uniques = new Hashtable<>();
for (final U c : source) { for (final U c : source) {
uniques.put(fnUniqueKey.apply(c), c); uniques.put(fnUniqueKey.apply(c), c);
} }
@@ -206,7 +206,7 @@ public class Aggregates {
} }
public static <T, U> Iterable<Entry<U, Integer>> groupSumBy(Iterable<Entry<T, Integer>> source, Function<T, U> fnGetField) { public static <T, U> Iterable<Entry<U, Integer>> groupSumBy(Iterable<Entry<T, Integer>> source, Function<T, U> fnGetField) {
Map<U, Integer> result = new HashMap<U, Integer>(); Map<U, Integer> result = new HashMap<>();
for (Entry<T, Integer> kv : source) { for (Entry<T, Integer> kv : source) {
U k = fnGetField.apply(kv.getKey()); U k = fnGetField.apply(kv.getKey());
Integer v = kv.getValue(); Integer v = kv.getValue();

View File

@@ -50,7 +50,7 @@ public class FileSection {
* Instantiates a new file section. * Instantiates a new file section.
*/ */
protected FileSection() { protected FileSection() {
this(new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER)); this(new TreeMap<>(String.CASE_INSENSITIVE_ORDER));
} }
protected FileSection(Map<String, String> lines0) { protected FileSection(Map<String, String> lines0) {
@@ -71,7 +71,7 @@ public class FileSection {
} }
public static Map<String, String> parseToMap(final String line, final String kvSeparator, final String pairSeparator) { public static Map<String, String> parseToMap(final String line, final String kvSeparator, final String pairSeparator) {
Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); Map<String, String> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
if (!StringUtils.isEmpty(line)) { if (!StringUtils.isEmpty(line)) {
final String[] pairs = line.split(Pattern.quote(pairSeparator)); final String[] pairs = line.split(Pattern.quote(pairSeparator));
final Pattern splitter = Pattern.compile(Pattern.quote(kvSeparator)); final Pattern splitter = Pattern.compile(Pattern.quote(kvSeparator));
@@ -211,7 +211,7 @@ public class FileSection {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static Map<String, List<String>> parseSections(final List<String> source) { public static Map<String, List<String>> parseSections(final List<String> source) {
final Map<String, List<String>> result = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER); final Map<String, List<String>> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
String currentSection = ""; String currentSection = "";
List<String> currentList = null; List<String> currentList = null;
@@ -234,7 +234,7 @@ public class FileSection {
currentList = null; currentList = null;
} else { } else {
if (currentList == null) { if (currentList == null) {
currentList = new ArrayList<String>(); currentList = new ArrayList<>();
} }
currentList.add(st); currentList.add(st);
} }

View File

@@ -196,7 +196,7 @@ public final class FileUtil {
public static List<String> readFile(final File file) { public static List<String> readFile(final File file) {
try { try {
if ((file == null) || !file.exists()) { if ((file == null) || !file.exists()) {
return new ArrayList<String>(); return new ArrayList<>();
} }
return FileUtil.readAllLines(new FileReader(file), false); return FileUtil.readAllLines(new FileReader(file), false);
} catch (final Exception ex) { } catch (final Exception ex) {
@@ -222,7 +222,7 @@ public final class FileUtil {
* @return list of strings * @return list of strings
*/ */
public static List<String> readAllLines(final Reader reader, final boolean mayTrim) { public static List<String> readAllLines(final Reader reader, final boolean mayTrim) {
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
try { try {
final BufferedReader in = new BufferedReader(reader); final BufferedReader in = new BufferedReader(reader);
String line; String line;
@@ -244,7 +244,7 @@ public final class FileUtil {
Pattern lineSplitter = Pattern.compile(Pattern.quote(" ")); Pattern lineSplitter = Pattern.compile(Pattern.quote(" "));
Pattern replacer = Pattern.compile(Pattern.quote("%20")); Pattern replacer = Pattern.compile(Pattern.quote("%20"));
List<Pair<String, String>> list = new ArrayList<Pair<String, String>>(); List<Pair<String, String>> list = new ArrayList<>();
for (String line : readFile(nameUrlFile)) { for (String line : readFile(nameUrlFile)) {
if (StringUtils.isBlank(line) || line.startsWith("#")) { if (StringUtils.isBlank(line) || line.startsWith("#")) {
@@ -271,7 +271,7 @@ public final class FileUtil {
} }
public static List<String> readFile(final URL url) { public static List<String> readFile(final URL url) {
final List<String> lines = new ArrayList<String>(); final List<String> lines = new ArrayList<>();
ThreadUtil.executeWithTimeout(new Callable<Void>() { ThreadUtil.executeWithTimeout(new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {

View File

@@ -60,12 +60,12 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
}; };
public ItemPool(final Class<T> cls) { public ItemPool(final Class<T> cls) {
this(new LinkedHashMap<T, Integer>(), cls); this(new LinkedHashMap<>(), cls);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final ItemPool<Tin> from, final Class<Tout> clsHint) { public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final ItemPool<Tin> from, final Class<Tout> clsHint) {
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint); final ItemPool<Tout> result = new ItemPool<>(clsHint);
if (from != null) { if (from != null) {
for (final Entry<Tin, Integer> e : from) { for (final Entry<Tin, Integer> e : from) {
final Tin srcKey = e.getKey(); final Tin srcKey = e.getKey();
@@ -79,7 +79,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final Iterable<Tin> from, final Class<Tout> clsHint) { public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final Iterable<Tin> from, final Class<Tout> clsHint) {
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint); final ItemPool<Tout> result = new ItemPool<>(clsHint);
if (from != null) { if (from != null) {
for (final Tin srcKey : from) { for (final Tin srcKey : from) {
if (clsHint.isInstance(srcKey)) { if (clsHint.isInstance(srcKey)) {
@@ -95,7 +95,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
items = items0; items = items0;
} }
else { else {
items = new HashMap<T, Integer>(); //prevent items being null items = new HashMap<>(); //prevent items being null
} }
myClass = cls; myClass = cls;
} }
@@ -161,7 +161,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
} }
public final List<T> toFlatList() { public final List<T> toFlatList() {
final List<T> result = new ArrayList<T>(); final List<T> result = new ArrayList<>();
for (final Entry<T, Integer> e : this) { for (final Entry<T, Integer> e : this) {
for (int i = 0; i < e.getValue(); i++) { for (int i = 0; i < e.getValue(); i++) {
result.add(e.getKey()); result.add(e.getKey());
@@ -171,7 +171,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
} }
public Map<String, Integer> toNameLookup() { public Map<String, Integer> toNameLookup() {
final Map<String, Integer> result = new HashMap<String, Integer>(); final Map<String, Integer> result = new HashMap<>();
for (final Entry<T, Integer> e : this) { for (final Entry<T, Integer> e : this) {
result.put(e.getKey().getName(), e.getValue()); result.put(e.getKey().getName(), e.getValue());
} }
@@ -183,7 +183,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
} }
public ItemPool<T> getView() { public ItemPool<T> getView() {
return new ItemPool<T>(Collections.unmodifiableMap(items), getMyClass()); return new ItemPool<>(Collections.unmodifiableMap(items), getMyClass());
} }
public void add(final T item) { public void add(final T item) {

View File

@@ -56,7 +56,7 @@ public class ItemPoolSorter<T> implements Comparator<Entry<T, Integer>> {
} }
/** The Constant byNameThenSet. */ /** The Constant byNameThenSet. */
public static final ItemPoolSorter<PaperCard> BY_NAME_THEN_SET = new ItemPoolSorter<PaperCard>( public static final ItemPoolSorter<PaperCard> BY_NAME_THEN_SET = new ItemPoolSorter<>(
new Function<Entry<PaperCard, Integer>, Comparable<?>>() { new Function<Entry<PaperCard, Integer>, Comparable<?>>() {
@Override @Override
public Comparable<?> apply(final Entry<PaperCard, Integer> from) { public Comparable<?> apply(final Entry<PaperCard, Integer> from) {

View File

@@ -195,7 +195,7 @@ public final class NameGenerator {
"Coreshaker", "Forgewulf", "Sheepspear", "Elvenworm", "Lipswalker", "Sealight", "the Rotten" "Coreshaker", "Forgewulf", "Sheepspear", "Elvenworm", "Lipswalker", "Sealight", "the Rotten"
}; };
private static List<String> usedMonikers = new ArrayList<String>(); private static List<String> usedMonikers = new ArrayList<>();
private static List<String> usedNames; private static List<String> usedNames;
private static String[] sourceList; private static String[] sourceList;
@@ -239,8 +239,8 @@ public final class NameGenerator {
break; break;
default: default:
List<String> all = new ArrayList<String>( List<String> all = new ArrayList<>(
genericMales.length + fantasyMales.length + genericFemales.length + fantasyFemales.length); genericMales.length + fantasyMales.length + genericFemales.length + fantasyFemales.length);
Collections.addAll(all, genericMales); Collections.addAll(all, genericMales);
Collections.addAll(all, fantasyMales); Collections.addAll(all, fantasyMales);
Collections.addAll(all, genericFemales); Collections.addAll(all, genericFemales);
@@ -272,7 +272,7 @@ public final class NameGenerator {
/** Generates a specified number of random names. */ /** Generates a specified number of random names. */
public static List<String> getRandomNames(final int generateAmount, final List<String> excludeNames) { public static List<String> getRandomNames(final int generateAmount, final List<String> excludeNames) {
usedNames = excludeNames; usedNames = excludeNames;
final List<String> names = new ArrayList<String>(generateAmount); final List<String> names = new ArrayList<>(generateAmount);
for (int i = 0; i < generateAmount; i++) { for (int i = 0; i < generateAmount; i++) {
getRandomName("Any", "Any", usedNames); getRandomName("Any", "Any", usedNames);
} }
@@ -281,7 +281,7 @@ public final class NameGenerator {
/** Generates a single name that doesn't match any names in the supplied list. */ /** Generates a single name that doesn't match any names in the supplied list. */
public static String getRandomName(final String gender, final String type, final String notNamed) { public static String getRandomName(final String gender, final String type, final String notNamed) {
List<String> exclude = new ArrayList<String>(1); List<String> exclude = new ArrayList<>(1);
exclude.add(notNamed); exclude.add(notNamed);
return getRandomName(gender, type, exclude); return getRandomName(gender, type, exclude);
} }

View File

@@ -71,7 +71,7 @@ public class TextUtil {
* It's faster than String.split, and allows parenthesis * It's faster than String.split, and allows parenthesis
*/ */
public static String[] splitWithParenthesis(CharSequence input, char delimiter, int maxEntries, char openPar, char closePar, boolean skipEmpty) { public static String[] splitWithParenthesis(CharSequence input, char delimiter, int maxEntries, char openPar, char closePar, boolean skipEmpty) {
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<>();
// Assume that when equal non-zero parenthesis are passed, they need to be discarded // Assume that when equal non-zero parenthesis are passed, they need to be discarded
boolean trimParenthesis = openPar == closePar && openPar > 0; boolean trimParenthesis = openPar == closePar && openPar > 0;
int nPar = 0; int nPar = 0;

View File

@@ -31,7 +31,7 @@ import java.util.Set;
public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>, Cloneable, Serializable { public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>, Cloneable, Serializable {
private static final long serialVersionUID = -1664555336364294106L; private static final long serialVersionUID = -1664555336364294106L;
private static final FCollection<?> EMPTY = new EmptyFCollection<Object>(); private static final FCollection<?> EMPTY = new EmptyFCollection<>();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> FCollection<T> getEmpty() { public static <T> FCollection<T> getEmpty() {
@@ -527,7 +527,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
@Override @Override
public Iterable<T> threadSafeIterable() { public Iterable<T> threadSafeIterable() {
//create a new linked list for iterating to make it thread safe and avoid concurrent modification exceptions //create a new linked list for iterating to make it thread safe and avoid concurrent modification exceptions
return Iterables.unmodifiableIterable(new LinkedList<T>(list)); return Iterables.unmodifiableIterable(new LinkedList<>(list));
} }
@Override @Override

View File

@@ -6,7 +6,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
private static final long serialVersionUID = 1438913784333297606L; private static final long serialVersionUID = 1438913784333297606L;
public static <T> LinkedHashMapToAmount<T> emptyMap() { public static <T> LinkedHashMapToAmount<T> emptyMap() {
return new LinkedHashMapToAmount<T>(0); return new LinkedHashMapToAmount<>(0);
} }
/** /**

View File

@@ -59,11 +59,11 @@ public final class MapToAmountUtil {
throw new NullPointerException(); throw new NullPointerException();
} }
if (map.isEmpty()) { if (map.isEmpty()) {
return new FCollection<T>(); return new FCollection<>();
} }
final int max = Collections.max(map.values()); final int max = Collections.max(map.values());
final FCollection<T> set = new FCollection<T>(); final FCollection<T> set = new FCollection<>();
for (final Entry<T, Integer> entry : map.entrySet()) { for (final Entry<T, Integer> entry : map.entrySet()) {
if (entry.getValue().intValue() == max) { if (entry.getValue().intValue() == max) {
set.add(entry.getKey()); set.add(entry.getKey());
@@ -114,11 +114,11 @@ public final class MapToAmountUtil {
throw new NullPointerException(); throw new NullPointerException();
} }
if (map.isEmpty()) { if (map.isEmpty()) {
return new FCollection<T>(); return new FCollection<>();
} }
final int min = Collections.min(map.values()); final int min = Collections.min(map.values());
final FCollection<T> set = new FCollection<T>(); final FCollection<T> set = new FCollection<>();
for (final Entry<T, Integer> entry : map.entrySet()) { for (final Entry<T, Integer> entry : map.entrySet()) {
if (entry.getValue().intValue() == min) { if (entry.getValue().intValue() == min) {
set.add(entry.getKey()); set.add(entry.getKey());

View File

@@ -35,7 +35,7 @@ import java.util.*;
public class StorageBase<T> implements IStorage<T> { public class StorageBase<T> implements IStorage<T> {
protected final Map<String, T> map; protected final Map<String, T> map;
public final static StorageBase<?> emptyMap = new StorageBase<Object>("Empty", null, new HashMap<String, Object>()); public final static StorageBase<?> emptyMap = new StorageBase<>("Empty", null, new HashMap<>());
public final String name, fullPath; public final String name, fullPath;
public StorageBase(final String name0, final IItemReader<T> io) { public StorageBase(final String name0, final IItemReader<T> io) {
@@ -55,7 +55,7 @@ public class StorageBase<T> implements IStorage<T> {
@Override @Override
public final Collection<String> getItemNames() { public final Collection<String> getItemNames() {
return new ArrayList<String>(map.keySet()); return new ArrayList<>(map.keySet());
} }
@Override @Override

View File

@@ -39,7 +39,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
private final Function<File, IStorage<T>> nestedFactory = new Function<File, IStorage<T>>() { private final Function<File, IStorage<T>> nestedFactory = new Function<File, IStorage<T>>() {
@Override @Override
public IStorage<T> apply(File file) { public IStorage<T> apply(File file) {
return new StorageImmediatelySerialized<T>(file.getName(), (IItemSerializer<T>) serializer.getReaderForFolder(file), true); return new StorageImmediatelySerialized<>(file.getName(), (IItemSerializer<T>) serializer.getReaderForFolder(file), true);
} }
}; };
@@ -57,7 +57,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) { public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) {
super(name, io); super(name, io);
this.serializer = io; this.serializer = io;
subfolders = withSubFolders ? new StorageNestedFolders<T>(io.getDirectory(), io.getSubFolders(), nestedFactory) : null; subfolders = withSubFolders ? new StorageNestedFolders<>(io.getDirectory(), io.getSubFolders(), nestedFactory) : null;
} }
/* /*

View File

@@ -9,7 +9,7 @@ public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
private final File thisFolder; private final File thisFolder;
public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) { public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) {
super("<Subfolders>", thisFolder.getPath(), new HashMap<String, IStorage<T>>()); super("<Subfolders>", thisFolder.getPath(), new HashMap<>());
this.thisFolder = thisFolder; this.thisFolder = thisFolder;
for (File sf : subfolders) { for (File sf : subfolders) {
IStorage<T> newUnit = factory.apply(sf); IStorage<T> newUnit = factory.apply(sf);

View File

@@ -52,7 +52,7 @@ public abstract class StorageReaderFile<T> extends StorageReaderBase<T> {
@Override @Override
public Map<String, T> readAll() { public Map<String, T> readAll() {
final Map<String, T> result = new TreeMap<String, T>(); final Map<String, T> result = new TreeMap<>();
int idx = 0; int idx = 0;
for (String line : FileUtil.readFile(file)) { for (String line : FileUtil.readFile(file)) {

View File

@@ -53,7 +53,7 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
} }
protected Map<String, T> createMap() { protected Map<String, T> createMap() {
return new TreeMap<String, T>(); return new TreeMap<>();
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -66,7 +66,7 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
int idx = 0; int idx = 0;
Iterable<String> contents = FileUtil.readFile(file); Iterable<String> contents = FileUtil.readFile(file);
List<String> accumulator = new ArrayList<String>(); List<String> accumulator = new ArrayList<>();
String header = null; String header = null;
for (final String s : contents) { for (final String s : contents) {

View File

@@ -75,14 +75,14 @@ public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
} }
} }
public final List<String> objectsThatFailedToLoad = new ArrayList<String>(); public final List<String> objectsThatFailedToLoad = new ArrayList<>();
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.util.IItemReader#readAll() * @see forge.util.IItemReader#readAll()
*/ */
@Override @Override
public Map<String, T> readAll() { public Map<String, T> readAll() {
final Map<String, T> result = new TreeMap<String, T>(); final Map<String, T> result = new TreeMap<>();
final File[] files = this.directory.listFiles(this.getFileFilter()); final File[] files = this.directory.listFiles(this.getFileFilter());
for (final File file : files) { for (final File file : files) {

View File

@@ -77,14 +77,14 @@ public abstract class StorageReaderRecursiveFolderWithUserFolder<T> extends Stor
} }
} }
public final List<String> objectsThatFailedToLoad = new ArrayList<String>(); public final List<String> objectsThatFailedToLoad = new ArrayList<>();
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.util.IItemReader#readAll() * @see forge.util.IItemReader#readAll()
*/ */
@Override @Override
public Map<String, T> readAll() { public Map<String, T> readAll() {
final Map<String, T> result = new TreeMap<String, T>(); final Map<String, T> result = new TreeMap<>();
Collection<File> forgeFormats = listFileTree(directory); Collection<File> forgeFormats = listFileTree(directory);
Collection<File> customFormats = listFileTree(userDirectory); Collection<File> customFormats = listFileTree(userDirectory);
@@ -115,7 +115,7 @@ public abstract class StorageReaderRecursiveFolderWithUserFolder<T> extends Stor
} }
private Collection<File> listFileTree(File dir) { private Collection<File> listFileTree(File dir) {
Set<File> fileTree = new HashSet<File>(); Set<File> fileTree = new HashSet<>();
if(dir==null||dir.listFiles(getFileFilter())==null){ if(dir==null||dir.listFiles(getFileFilter())==null){
return fileTree; return fileTree;
} }

View File

@@ -713,7 +713,7 @@ public class Game {
ingamePlayers.remove(p); ingamePlayers.remove(p);
lostPlayers.add(p); lostPlayers.add(p);
final Map<String, Object> runParams = new TreeMap<String, Object>(); final Map<String, Object> runParams = new TreeMap<>();
runParams.put("Player", p); runParams.put("Player", p);
getTriggerHandler().runTrigger(TriggerType.LosesGame, runParams, false); getTriggerHandler().runTrigger(TriggerType.LosesGame, runParams, false);
} }

View File

@@ -787,7 +787,7 @@ public class GameAction {
} }
// search for cards with static abilities // search for cards with static abilities
final FCollection<StaticAbility> staticAbilities = new FCollection<StaticAbility>(); final FCollection<StaticAbility> staticAbilities = new FCollection<>();
final CardCollection staticList = new CardCollection(); final CardCollection staticList = new CardCollection();
game.forEachCardInGame(new Visitor<Card>() { game.forEachCardInGame(new Visitor<Card>() {
@@ -880,6 +880,10 @@ public class GameAction {
c.getStaticCommandList().removeAll(toRemove); c.getStaticCommandList().removeAll(toRemove);
} }
// Exclude cards in hidden zones from update // Exclude cards in hidden zones from update
/*
* Refactoring this code to affectedCards.removeIf((Card c) -> c.isInZone(ZoneType.Library));
* causes Android build not to compile
* */
Iterator<Card> it = affectedCards.iterator(); Iterator<Card> it = affectedCards.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Card c = it.next(); Card c = it.next();

View File

@@ -8,7 +8,7 @@ import java.util.List;
import forge.trackable.TrackableObject; import forge.trackable.TrackableObject;
public class GameEntityCache<Entity extends IIdentifiable, View extends TrackableObject> { public class GameEntityCache<Entity extends IIdentifiable, View extends TrackableObject> {
private HashMap<Integer, Entity> entityCache = new HashMap<Integer, Entity>(); private HashMap<Integer, Entity> entityCache = new HashMap<>();
public void put(Integer id, Entity entity) { public void put(Integer id, Entity entity) {
entityCache.put(id, entity); entityCache.put(id, entity);
@@ -33,7 +33,7 @@ public class GameEntityCache<Entity extends IIdentifiable, View extends Trackabl
} }
public List<Entity> getList(Iterable<View> views) { public List<Entity> getList(Iterable<View> views) {
List<Entity> list = new ArrayList<Entity>(); List<Entity> list = new ArrayList<>();
addToList(views, list); addToList(views, list);
return list; return list;
} }

View File

@@ -17,7 +17,7 @@ public abstract class GameEntityView extends TrackableObject {
if (entities == null) { if (entities == null) {
return null; return null;
} }
TrackableCollection<GameEntityView> collection = new TrackableCollection<GameEntityView>(); TrackableCollection<GameEntityView> collection = new TrackableCollection<>();
for (GameEntity e : entities) { for (GameEntity e : entities) {
collection.add(e.getView()); collection.add(e.getView());
} }

View File

@@ -101,14 +101,14 @@ public class GameFormat implements Comparable<GameFormat> {
} }
allowedSetCodes = Lists.newArrayList(parsedSets); allowedSetCodes = Lists.newArrayList(parsedSets);
}else{ }else{
allowedSetCodes = new ArrayList<String>(); allowedSetCodes = new ArrayList<>();
} }
bannedCardNames = bannedCards == null ? new ArrayList<String>() : Lists.newArrayList(bannedCards); bannedCardNames = bannedCards == null ? new ArrayList<>() : Lists.newArrayList(bannedCards);
restrictedCardNames = restrictedCards == null ? new ArrayList<String>() : Lists.newArrayList(restrictedCards); restrictedCardNames = restrictedCards == null ? new ArrayList<>() : Lists.newArrayList(restrictedCards);
allowedRarities = rarities == null ? new ArrayList<CardRarity>() : rarities; allowedRarities = rarities == null ? new ArrayList<>() : rarities;
this.restrictedLegendary = restrictedLegendary; this.restrictedLegendary = restrictedLegendary;
additionalCardNames = additionalCards == null ? new ArrayList<String>() : Lists.newArrayList(additionalCards); additionalCardNames = additionalCards == null ? new ArrayList<>() : Lists.newArrayList(additionalCards);
this.allowedSetCodes_ro = Collections.unmodifiableList(allowedSetCodes); this.allowedSetCodes_ro = Collections.unmodifiableList(allowedSetCodes);
this.bannedCardNames_ro = Collections.unmodifiableList(bannedCardNames); this.bannedCardNames_ro = Collections.unmodifiableList(bannedCardNames);
@@ -195,7 +195,7 @@ public class GameFormat implements Comparable<GameFormat> {
} }
public List<PaperCard> getAllCards() { public List<PaperCard> getAllCards() {
List<PaperCard> cards = new ArrayList<PaperCard>(); List<PaperCard> cards = new ArrayList<>();
CardDb commonCards = StaticData.instance().getCommonCards(); CardDb commonCards = StaticData.instance().getCommonCards();
for (String setCode : allowedSetCodes_ro) { for (String setCode : allowedSetCodes_ro) {
CardEdition edition = StaticData.instance().getEditions().get(setCode); CardEdition edition = StaticData.instance().getEditions().get(setCode);
@@ -285,7 +285,7 @@ public class GameFormat implements Comparable<GameFormat> {
} }
public static class Reader extends StorageReaderRecursiveFolderWithUserFolder<GameFormat> { public static class Reader extends StorageReaderRecursiveFolderWithUserFolder<GameFormat> {
List<GameFormat> naturallyOrdered = new ArrayList<GameFormat>(); List<GameFormat> naturallyOrdered = new ArrayList<>();
boolean includeHistoric; boolean includeHistoric;
private List<String> coreFormats = new ArrayList<>(); private List<String> coreFormats = new ArrayList<>();
{ {
@@ -484,7 +484,7 @@ public class GameFormat implements Comparable<GameFormat> {
} }
public Set<GameFormat> getAllFormatsOfCard(PaperCard card) { public Set<GameFormat> getAllFormatsOfCard(PaperCard card) {
Set<GameFormat> result = new HashSet<GameFormat>(); Set<GameFormat> result = new HashSet<>();
for (GameFormat gf : naturallyOrdered) { for (GameFormat gf : naturallyOrdered) {
if (gf.getFilterRules().apply(card)) { if (gf.getFilterRules().apply(card)) {
result.add(gf); result.add(gf);
@@ -501,7 +501,7 @@ public class GameFormat implements Comparable<GameFormat> {
} }
public Set<GameFormat> getAllFormatsOfDeck(Deck deck, Boolean exhaustive) { public Set<GameFormat> getAllFormatsOfDeck(Deck deck, Boolean exhaustive) {
SortedSet<GameFormat> result = new TreeSet<GameFormat>(); SortedSet<GameFormat> result = new TreeSet<>();
Set<FormatSubType> coveredTypes = new HashSet<>(); Set<FormatSubType> coveredTypes = new HashSet<>();
CardPool allCards = deck.getAllCardsInASinglePool(); CardPool allCards = deck.getAllCardsInASinglePool();
for(GameFormat gf : reverseDateOrdered) { for(GameFormat gf : reverseDateOrdered) {

View File

@@ -34,7 +34,7 @@ import java.util.Observable;
public class GameLog extends Observable implements Serializable { public class GameLog extends Observable implements Serializable {
private static final long serialVersionUID = 6465283802022948827L; private static final long serialVersionUID = 6465283802022948827L;
private final List<GameLogEntry> log = new ArrayList<GameLogEntry>(); private final List<GameLogEntry> log = new ArrayList<>();
private final transient GameLogFormatter formatter = new GameLogFormatter(this); private final transient GameLogFormatter formatter = new GameLogFormatter(this);
@@ -70,7 +70,7 @@ public class GameLog extends Observable implements Serializable {
* @return the log text * @return the log text
*/ */
public List<GameLogEntry> getLogEntries(final GameLogEntryType logLevel) { // null to fetch all public List<GameLogEntry> getLogEntries(final GameLogEntryType logLevel) { // null to fetch all
final List<GameLogEntry> result = new ArrayList<GameLogEntry>(); final List<GameLogEntry> result = new ArrayList<>();
for (int i = log.size() - 1; i >= 0; i--) { for (int i = log.size() - 1; i >= 0; i--) {
GameLogEntry le = log.get(i); GameLogEntry le = log.get(i);
@@ -82,7 +82,7 @@ public class GameLog extends Observable implements Serializable {
} }
public List<GameLogEntry> getLogEntriesExact(final GameLogEntryType logLevel) { // null to fetch all public List<GameLogEntry> getLogEntriesExact(final GameLogEntryType logLevel) { // null to fetch all
final List<GameLogEntry> result = new ArrayList<GameLogEntry>(); final List<GameLogEntry> result = new ArrayList<>();
for (int i = log.size() - 1; i >= 0; i--) { for (int i = log.size() - 1; i >= 0; i--) {
GameLogEntry le = log.get(i); GameLogEntry le = log.get(i);

View File

@@ -130,7 +130,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
private static GameLogEntry generateSummary(final List<GameOutcome> gamesPlayed) { private static GameLogEntry generateSummary(final List<GameOutcome> gamesPlayed) {
final GameOutcome outcome1 = gamesPlayed.get(0); final GameOutcome outcome1 = gamesPlayed.get(0);
final HashMap<RegisteredPlayer, String> players = outcome1.getPlayerNames(); final HashMap<RegisteredPlayer, String> players = outcome1.getPlayerNames();
final HashMap<RegisteredPlayer, Integer> winCount = new HashMap<RegisteredPlayer, Integer>(); final HashMap<RegisteredPlayer, Integer> winCount = new HashMap<>();
// Calculate total games each player has won. // Calculate total games each player has won.
for (final GameOutcome game : gamesPlayed) { for (final GameOutcome game : gamesPlayed) {

View File

@@ -36,7 +36,7 @@ public abstract class GameObjectMap {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends GameObject> List<T> mapList(final List<T> objects) { public <T extends GameObject> List<T> mapList(final List<T> objects) {
final List<T> result = new ArrayList<T>(); final List<T> result = new ArrayList<>();
for (final T o : objects) { for (final T o : objects) {
result.add((T) map(o)); result.add((T) map(o));
} }

View File

@@ -28,7 +28,7 @@ public class Match {
private final GameRules rules; private final GameRules rules;
private final String title; private final String title;
private final List<GameOutcome> gamesPlayed = new ArrayList<GameOutcome>(); private final List<GameOutcome> gamesPlayed = new ArrayList<>();
private final List<GameOutcome> gamesPlayedRo; private final List<GameOutcome> gamesPlayedRo;
public Match(final GameRules rules0, final List<RegisteredPlayer> players0, final String title) { public Match(final GameRules rules0, final List<RegisteredPlayer> players0, final String title) {
@@ -171,7 +171,7 @@ public class Match {
private static Set<PaperCard> getRemovedAnteCards(Deck toUse) { private static Set<PaperCard> getRemovedAnteCards(Deck toUse) {
final String keywordToRemove = "Remove CARDNAME from your deck before playing if you're not playing for ante."; final String keywordToRemove = "Remove CARDNAME from your deck before playing if you're not playing for ante.";
Set<PaperCard> myRemovedAnteCards = new HashSet<PaperCard>(); Set<PaperCard> myRemovedAnteCards = new HashSet<>();
for (Entry<DeckSection, CardPool> ds : toUse) { for (Entry<DeckSection, CardPool> ds : toUse) {
for (Entry<PaperCard, Integer> cp : ds.getValue()) { for (Entry<PaperCard, Integer> cp : ds.getValue()) {
if (Iterables.contains(cp.getKey().getRules().getMainPart().getKeywords(), keywordToRemove)) { if (Iterables.contains(cp.getKey().getRules().getMainPart().getKeywords(), keywordToRemove)) {
@@ -184,7 +184,7 @@ public class Match {
private static void preparePlayerLibrary(Player player, final ZoneType zoneType, CardPool section, boolean canRandomFoil) { private static void preparePlayerLibrary(Player player, final ZoneType zoneType, CardPool section, boolean canRandomFoil) {
PlayerZone library = player.getZone(zoneType); PlayerZone library = player.getZone(zoneType);
List<Card> newLibrary = new ArrayList<Card>(); List<Card> newLibrary = new ArrayList<>();
for (final Entry<PaperCard, Integer> stackOfCards : section) { for (final Entry<PaperCard, Integer> stackOfCards : section) {
final PaperCard cp = stackOfCards.getKey(); final PaperCard cp = stackOfCards.getKey();
for (int i = 0; i < stackOfCards.getValue(); i++) { for (int i = 0; i < stackOfCards.getValue(); i++) {
@@ -304,7 +304,7 @@ public class Match {
GameOutcome outcome = lastGame.getOutcome(); GameOutcome outcome = lastGame.getOutcome();
// remove all the lost cards from owners' decks // remove all the lost cards from owners' decks
List<PaperCard> losses = new ArrayList<PaperCard>(); List<PaperCard> losses = new ArrayList<>();
int cntPlayers = players.size(); int cntPlayers = players.size();
int iWinner = -1; int iWinner = -1;
for (int i = 0; i < cntPlayers; i++) { for (int i = 0; i < cntPlayers; i++) {

View File

@@ -36,7 +36,7 @@ public enum PlanarDice {
trigRes = Chaos; trigRes = Chaos;
} }
HashMap<String,Object> runParams = new HashMap<String,Object>(); HashMap<String,Object> runParams = new HashMap<>();
runParams.put("Player", roller); runParams.put("Player", roller);
runParams.put("Result", trigRes); runParams.put("Result", trigRes);
roller.getGame().getTriggerHandler().runTrigger(TriggerType.PlanarDice, runParams,false); roller.getGame().getTriggerHandler().runTrigger(TriggerType.PlanarDice, runParams,false);

View File

@@ -166,7 +166,7 @@ public class StaticEffect {
*/ */
public final void addOriginalAbilities(final Card c, final SpellAbility sa) { public final void addOriginalAbilities(final Card c, final SpellAbility sa) {
if (!this.originalAbilities.containsKey(c)) { if (!this.originalAbilities.containsKey(c)) {
final List<SpellAbility> list = new ArrayList<SpellAbility>(); final List<SpellAbility> list = new ArrayList<>();
list.add(sa); list.add(sa);
this.originalAbilities.put(c, list); this.originalAbilities.put(c, list);
} else { } else {
@@ -185,7 +185,7 @@ public class StaticEffect {
* a {@link java.util.List} object. * a {@link java.util.List} object.
*/ */
public final void addOriginalAbilities(final Card c, final List<SpellAbility> s) { public final void addOriginalAbilities(final Card c, final List<SpellAbility> s) {
final List<SpellAbility> list = new ArrayList<SpellAbility>(s); final List<SpellAbility> list = new ArrayList<>(s);
if (!this.originalAbilities.containsKey(c)) { if (!this.originalAbilities.containsKey(c)) {
this.originalAbilities.put(c, list); this.originalAbilities.put(c, list);
} else { } else {
@@ -204,7 +204,7 @@ public class StaticEffect {
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public final List<SpellAbility> getOriginalAbilities(final Card c) { public final List<SpellAbility> getOriginalAbilities(final Card c) {
final List<SpellAbility> returnList = new ArrayList<SpellAbility>(); final List<SpellAbility> returnList = new ArrayList<>();
if (this.originalAbilities.containsKey(c)) { if (this.originalAbilities.containsKey(c)) {
returnList.addAll(this.originalAbilities.get(c)); returnList.addAll(this.originalAbilities.get(c));
} }
@@ -271,7 +271,7 @@ public class StaticEffect {
*/ */
public final void addOriginalKeyword(final Card c, final String s) { public final void addOriginalKeyword(final Card c, final String s) {
if (!this.originalKeywords.containsKey(c)) { if (!this.originalKeywords.containsKey(c)) {
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
list.add(s); list.add(s);
this.originalKeywords.put(c, list); this.originalKeywords.put(c, list);
} else { } else {
@@ -290,7 +290,7 @@ public class StaticEffect {
* a {@link List} object. * a {@link List} object.
*/ */
public final void addOriginalKeywords(final Card c, final List<String> s) { public final void addOriginalKeywords(final Card c, final List<String> s) {
final List<String> list = new ArrayList<String>(s); final List<String> list = new ArrayList<>(s);
if (!this.originalKeywords.containsKey(c)) { if (!this.originalKeywords.containsKey(c)) {
this.originalKeywords.put(c, list); this.originalKeywords.put(c, list);
} else { } else {
@@ -309,7 +309,7 @@ public class StaticEffect {
* @return a {@link List} object. * @return a {@link List} object.
*/ */
public final List<String> getOriginalKeywords(final Card c) { public final List<String> getOriginalKeywords(final Card c) {
final List<String> returnList = new ArrayList<String>(); final List<String> returnList = new ArrayList<>();
if (this.originalKeywords.containsKey(c)) { if (this.originalKeywords.containsKey(c)) {
returnList.addAll(this.originalKeywords.get(c)); returnList.addAll(this.originalKeywords.get(c));
} }
@@ -424,7 +424,7 @@ public class StaticEffect {
*/ */
public final void addOriginalType(final Card c, final String s) { public final void addOriginalType(final Card c, final String s) {
if (!this.originalTypes.containsKey(c)) { if (!this.originalTypes.containsKey(c)) {
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
list.add(s); list.add(s);
this.originalTypes.put(c, list); this.originalTypes.put(c, list);
} else { } else {
@@ -443,7 +443,7 @@ public class StaticEffect {
* a {@link java.util.ArrayList} object. * a {@link java.util.ArrayList} object.
*/ */
public final void addOriginalTypes(final Card c, final List<String> s) { public final void addOriginalTypes(final Card c, final List<String> s) {
final List<String> list = new ArrayList<String>(s); final List<String> list = new ArrayList<>(s);
if (!this.originalTypes.containsKey(c)) { if (!this.originalTypes.containsKey(c)) {
this.originalTypes.put(c, list); this.originalTypes.put(c, list);
} else { } else {
@@ -462,7 +462,7 @@ public class StaticEffect {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final List<String> getOriginalTypes(final Card c) { public final List<String> getOriginalTypes(final Card c) {
final List<String> returnList = new ArrayList<String>(); final List<String> returnList = new ArrayList<>();
if (this.originalTypes.containsKey(c)) { if (this.originalTypes.containsKey(c)) {
returnList.addAll(this.originalTypes.get(c)); returnList.addAll(this.originalTypes.get(c));
} }
@@ -505,7 +505,7 @@ public class StaticEffect {
*/ */
public final void addType(final Card c, final String s) { public final void addType(final Card c, final String s) {
if (!this.types.containsKey(c)) { if (!this.types.containsKey(c)) {
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
list.add(s); list.add(s);
this.types.put(c, list); this.types.put(c, list);
} else { } else {
@@ -523,7 +523,7 @@ public class StaticEffect {
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public final List<String> getTypes(final Card c) { public final List<String> getTypes(final Card c) {
final List<String> returnList = new ArrayList<String>(); final List<String> returnList = new ArrayList<>();
if (this.types.containsKey(c)) { if (this.types.containsKey(c)) {
returnList.addAll(this.types.get(c)); returnList.addAll(this.types.get(c));
} }
@@ -823,7 +823,7 @@ public class StaticEffect {
if (colors.equals("ChosenColor")) { if (colors.equals("ChosenColor")) {
addColors = CardUtil.getShortColorsString(getSource().getChosenColors()); addColors = CardUtil.getShortColorsString(getSource().getChosenColors());
} else { } else {
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(" & ")))); addColors = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(" & "))));
} }
} }
@@ -832,7 +832,7 @@ public class StaticEffect {
if (colors.equals("ChosenColor")) { if (colors.equals("ChosenColor")) {
addColors = CardUtil.getShortColorsString(getSource().getChosenColors()); addColors = CardUtil.getShortColorsString(getSource().getChosenColors());
} else { } else {
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(" & ")))); addColors = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(" & "))));
} }
} }

View File

@@ -432,7 +432,7 @@ public class AbilityUtils {
val = CardFactoryUtil.doXMath(AbilityUtils.calculateAmount(card, l[0], ability), m, card); val = CardFactoryUtil.doXMath(AbilityUtils.calculateAmount(card, l[0], ability), m, card);
} else if (calcX[0].startsWith("PlayerCount")) { } else if (calcX[0].startsWith("PlayerCount")) {
final String hType = calcX[0].substring(11); final String hType = calcX[0].substring(11);
final FCollection<Player> players = new FCollection<Player>(); final FCollection<Player> players = new FCollection<>();
if (hType.equals("Players") || hType.equals("")) { if (hType.equals("Players") || hType.equals("")) {
players.addAll(game.getPlayers()); players.addAll(game.getPlayers());
val = CardFactoryUtil.playerXCount(players, calcX[1], card); val = CardFactoryUtil.playerXCount(players, calcX[1], card);
@@ -577,7 +577,7 @@ public class AbilityUtils {
// Player attribute counting // Player attribute counting
if (calcX[0].startsWith("TargetedPlayer")) { if (calcX[0].startsWith("TargetedPlayer")) {
final List<Player> players = new ArrayList<Player>(); final List<Player> players = new ArrayList<>();
final SpellAbility saTargeting = sa.getSATargetingPlayer(); final SpellAbility saTargeting = sa.getSATargetingPlayer();
if (null != saTargeting) { if (null != saTargeting) {
Iterables.addAll(players, saTargeting.getTargets().getTargetPlayers()); Iterables.addAll(players, saTargeting.getTargets().getTargetPlayers());
@@ -585,12 +585,12 @@ public class AbilityUtils {
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier; return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
} }
if (calcX[0].startsWith("ThisTargetedPlayer")) { if (calcX[0].startsWith("ThisTargetedPlayer")) {
final List<Player> players = new ArrayList<Player>(); final List<Player> players = new ArrayList<>();
Iterables.addAll(players, sa.getTargets().getTargetPlayers()); Iterables.addAll(players, sa.getTargets().getTargetPlayers());
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier; return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
} }
if (calcX[0].startsWith("TargetedObjects")) { if (calcX[0].startsWith("TargetedObjects")) {
final List<GameObject> objects = new ArrayList<GameObject>(); final List<GameObject> objects = new ArrayList<>();
// Make list of all targeted objects starting with the root SpellAbility // Make list of all targeted objects starting with the root SpellAbility
SpellAbility loopSA = sa.getRootAbility(); SpellAbility loopSA = sa.getRootAbility();
while (loopSA != null) { while (loopSA != null) {
@@ -602,7 +602,7 @@ public class AbilityUtils {
return CardFactoryUtil.objectXCount(objects, calcX[1], card) * multiplier; return CardFactoryUtil.objectXCount(objects, calcX[1], card) * multiplier;
} }
if (calcX[0].startsWith("TargetedController")) { if (calcX[0].startsWith("TargetedController")) {
final List<Player> players = new ArrayList<Player>(); final List<Player> players = new ArrayList<>();
final CardCollection list = getDefinedCards(card, "Targeted", sa); final CardCollection list = getDefinedCards(card, "Targeted", sa);
final List<SpellAbility> sas = AbilityUtils.getDefinedSpellAbilities(card, "Targeted", sa); final List<SpellAbility> sas = AbilityUtils.getDefinedSpellAbilities(card, "Targeted", sa);
@@ -641,7 +641,7 @@ public class AbilityUtils {
if (calcX[0].startsWith("TriggeredPlayers")) { if (calcX[0].startsWith("TriggeredPlayers")) {
key = "Triggered" + key.substring(16); key = "Triggered" + key.substring(16);
} }
final List<Player> players = new ArrayList<Player>(); final List<Player> players = new ArrayList<>();
Iterables.addAll(players, getDefinedPlayers(card, key, sa)); Iterables.addAll(players, getDefinedPlayers(card, key, sa));
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier; return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
} }
@@ -751,7 +751,7 @@ public class AbilityUtils {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public static FCollection<GameObject> getDefinedObjects(final Card card, final String def, final SpellAbility sa) { public static FCollection<GameObject> getDefinedObjects(final Card card, final String def, final SpellAbility sa) {
final FCollection<GameObject> objects = new FCollection<GameObject>(); final FCollection<GameObject> objects = new FCollection<>();
final String defined = (def == null) ? "Self" : def; final String defined = (def == null) ? "Self" : def;
objects.addAll(AbilityUtils.getDefinedPlayers(card, defined, sa)); objects.addAll(AbilityUtils.getDefinedPlayers(card, defined, sa));
@@ -1223,7 +1223,7 @@ public class AbilityUtils {
*/ */
public static FCollection<SpellAbility> getDefinedSpellAbilities(final Card card, final String def, public static FCollection<SpellAbility> getDefinedSpellAbilities(final Card card, final String def,
final SpellAbility sa) { final SpellAbility sa) {
final FCollection<SpellAbility> sas = new FCollection<SpellAbility>(); final FCollection<SpellAbility> sas = new FCollection<>();
final String defined = (def == null) ? "Self" : applyAbilityTextChangeEffects(def, sa); // default to Self final String defined = (def == null) ? "Self" : applyAbilityTextChangeEffects(def, sa); // default to Self
final Game game = card.getGame(); final Game game = card.getGame();
@@ -1690,7 +1690,7 @@ public class AbilityUtils {
} }
public static final List<SpellAbility> getBasicSpellsFromPlayEffect(final Card tgtCard, final Player controller) { public static final List<SpellAbility> getBasicSpellsFromPlayEffect(final Card tgtCard, final Player controller) {
List<SpellAbility> sas = new ArrayList<SpellAbility>(); List<SpellAbility> sas = new ArrayList<>();
for (SpellAbility s : tgtCard.getBasicSpells()) { for (SpellAbility s : tgtCard.getBasicSpells()) {
final Spell newSA = (Spell) s.copy(); final Spell newSA = (Spell) s.copy();
newSA.setActivatingPlayer(controller); newSA.setActivatingPlayer(controller);

View File

@@ -186,7 +186,7 @@ public abstract class SpellAbilityEffect {
private static FCollection<Player> getPlayers(final boolean definedFirst, final String definedParam, final SpellAbility sa) { private static FCollection<Player> getPlayers(final boolean definedFirst, final String definedParam, final SpellAbility sa) {
final boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam)); final boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
return useTargets ? new FCollection<Player>(sa.getTargets().getTargetPlayers()) return useTargets ? new FCollection<>(sa.getTargets().getTargetPlayers())
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa); : AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa);
} }

View File

@@ -71,17 +71,17 @@ public class AnimateAllEffect extends AnimateEffectBase {
types.add(host.getChosenType()); types.add(host.getChosenType());
} }
final List<String> keywords = new ArrayList<String>(); final List<String> keywords = new ArrayList<>();
if (sa.hasParam("Keywords")) { if (sa.hasParam("Keywords")) {
keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & "))); keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & ")));
} }
final List<String> removeKeywords = new ArrayList<String>(); final List<String> removeKeywords = new ArrayList<>();
if (sa.hasParam("RemoveKeywords")) { if (sa.hasParam("RemoveKeywords")) {
removeKeywords.addAll(Arrays.asList(sa.getParam("RemoveKeywords").split(" & "))); removeKeywords.addAll(Arrays.asList(sa.getParam("RemoveKeywords").split(" & ")));
} }
final List<String> hiddenKeywords = new ArrayList<String>(); final List<String> hiddenKeywords = new ArrayList<>();
if (sa.hasParam("HiddenKeywords")) { if (sa.hasParam("HiddenKeywords")) {
hiddenKeywords.addAll(Arrays.asList(sa.getParam("HiddenKeywords").split(" & "))); hiddenKeywords.addAll(Arrays.asList(sa.getParam("HiddenKeywords").split(" & ")));
} }
@@ -101,29 +101,29 @@ public class AnimateAllEffect extends AnimateEffectBase {
if (colors.equals("ChosenColor")) { if (colors.equals("ChosenColor")) {
tmpDesc = CardUtil.getShortColorsString(host.getChosenColors()); tmpDesc = CardUtil.getShortColorsString(host.getChosenColors());
} else { } else {
tmpDesc = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(",")))); tmpDesc = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(","))));
} }
} }
final String finalDesc = tmpDesc; final String finalDesc = tmpDesc;
// abilities to add to the animated being // abilities to add to the animated being
final List<String> abilities = new ArrayList<String>(); final List<String> abilities = new ArrayList<>();
if (sa.hasParam("Abilities")) { if (sa.hasParam("Abilities")) {
abilities.addAll(Arrays.asList(sa.getParam("Abilities").split(","))); abilities.addAll(Arrays.asList(sa.getParam("Abilities").split(",")));
} }
// replacement effects to add to the animated being // replacement effects to add to the animated being
final List<String> replacements = new ArrayList<String>(); final List<String> replacements = new ArrayList<>();
if (sa.hasParam("Replacements")) { if (sa.hasParam("Replacements")) {
replacements.addAll(Arrays.asList(sa.getParam("Replacements").split(","))); replacements.addAll(Arrays.asList(sa.getParam("Replacements").split(",")));
} }
// triggers to add to the animated being // triggers to add to the animated being
final List<String> triggers = new ArrayList<String>(); final List<String> triggers = new ArrayList<>();
if (sa.hasParam("Triggers")) { if (sa.hasParam("Triggers")) {
triggers.addAll(Arrays.asList(sa.getParam("Triggers").split(","))); triggers.addAll(Arrays.asList(sa.getParam("Triggers").split(",")));
} }
// sVars to add to the animated being // sVars to add to the animated being
final List<String> sVars = new ArrayList<String>(); final List<String> sVars = new ArrayList<>();
if (sa.hasParam("sVars")) { if (sa.hasParam("sVars")) {
sVars.addAll(Arrays.asList(sa.getParam("sVars").split(","))); sVars.addAll(Arrays.asList(sa.getParam("sVars").split(",")));
} }
@@ -154,7 +154,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
keywords, removeKeywords, hiddenKeywords, timestamp); keywords, removeKeywords, hiddenKeywords, timestamp);
// give abilities // give abilities
final List<SpellAbility> addedAbilities = new ArrayList<SpellAbility>(); final List<SpellAbility> addedAbilities = new ArrayList<>();
if (abilities.size() > 0) { if (abilities.size() > 0) {
for (final String s : abilities) { for (final String s : abilities) {
final String actualAbility = host.getSVar(s); final String actualAbility = host.getSVar(s);
@@ -165,7 +165,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
} }
// remove abilities // remove abilities
final List<SpellAbility> removedAbilities = new ArrayList<SpellAbility>(); final List<SpellAbility> removedAbilities = new ArrayList<>();
if (sa.hasParam("OverwriteAbilities") || removeAll || removeIntrinsic) { if (sa.hasParam("OverwriteAbilities") || removeAll || removeIntrinsic) {
for (final SpellAbility ab : c.getSpellAbilities()) { for (final SpellAbility ab : c.getSpellAbilities()) {
if (ab.isAbility()) { if (ab.isAbility()) {
@@ -178,7 +178,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
} }
} }
// give replacement effects // give replacement effects
final List<ReplacementEffect> addedReplacements = new ArrayList<ReplacementEffect>(); final List<ReplacementEffect> addedReplacements = new ArrayList<>();
if (replacements.size() > 0) { if (replacements.size() > 0) {
for (final String s : replacements) { for (final String s : replacements) {
final String actualReplacement = host.getSVar(s); final String actualReplacement = host.getSVar(s);
@@ -187,7 +187,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
} }
} }
// Grant triggers // Grant triggers
final List<Trigger> addedTriggers = new ArrayList<Trigger>(); final List<Trigger> addedTriggers = new ArrayList<>();
if (triggers.size() > 0) { if (triggers.size() > 0) {
for (final String s : triggers) { for (final String s : triggers) {
final String actualTrigger = host.getSVar(s); final String actualTrigger = host.getSVar(s);
@@ -197,7 +197,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
} }
// suppress triggers from the animated card // suppress triggers from the animated card
final List<Trigger> removedTriggers = new ArrayList<Trigger>(); final List<Trigger> removedTriggers = new ArrayList<>();
if (sa.hasParam("OverwriteTriggers") || removeAll || removeIntrinsic) { if (sa.hasParam("OverwriteTriggers") || removeAll || removeIntrinsic) {
final FCollectionView<Trigger> triggersToRemove = c.getTriggers(); final FCollectionView<Trigger> triggersToRemove = c.getTriggers();
for (final Trigger trigger : triggersToRemove) { for (final Trigger trigger : triggersToRemove) {
@@ -210,7 +210,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
} }
// suppress static abilities from the animated card // suppress static abilities from the animated card
final List<StaticAbility> removedStatics = new ArrayList<StaticAbility>(); final List<StaticAbility> removedStatics = new ArrayList<>();
if (sa.hasParam("OverwriteStatics") || removeAll || removeIntrinsic) { if (sa.hasParam("OverwriteStatics") || removeAll || removeIntrinsic) {
for (final StaticAbility stAb : c.getStaticAbilities()) { for (final StaticAbility stAb : c.getStaticAbilities()) {
if (removeIntrinsic && !stAb.isIntrinsic()) { if (removeIntrinsic && !stAb.isIntrinsic()) {
@@ -222,7 +222,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
} }
// suppress static abilities from the animated card // suppress static abilities from the animated card
final List<ReplacementEffect> removedReplacements = new ArrayList<ReplacementEffect>(); final List<ReplacementEffect> removedReplacements = new ArrayList<>();
if (sa.hasParam("OverwriteReplacements") || removeAll || removeIntrinsic) { if (sa.hasParam("OverwriteReplacements") || removeAll || removeIntrinsic) {
for (final ReplacementEffect re : c.getReplacementEffects()) { for (final ReplacementEffect re : c.getReplacementEffects()) {
if (removeIntrinsic && !re.isIntrinsic()) { if (removeIntrinsic && !re.isIntrinsic()) {

View File

@@ -166,7 +166,7 @@ public class AttachEffect extends SpellAbilityEffect {
Player p = source.getController(); Player p = source.getController();
if (tgt.canTgtPlayer()) { if (tgt.canTgtPlayer()) {
final FCollection<Player> players = new FCollection<Player>(); final FCollection<Player> players = new FCollection<>();
for (Player player : game.getPlayers()) { for (Player player : game.getPlayers()) {
if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source, null)) { if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source, null)) {

View File

@@ -34,7 +34,7 @@ public class BalanceEffect extends SpellAbilityEffect {
int min = Integer.MAX_VALUE; int min = Integer.MAX_VALUE;
final FCollectionView<Player> players = game.getPlayersInTurnOrder(); final FCollectionView<Player> players = game.getPlayersInTurnOrder();
final List<CardCollection> validCards = new ArrayList<CardCollection>(players.size()); final List<CardCollection> validCards = new ArrayList<>(players.size());
for(int i = 0; i < players.size(); i++) { for(int i = 0; i < players.size(); i++) {
// Find the minimum of each Valid per player // Find the minimum of each Valid per player

View File

@@ -22,7 +22,7 @@ public class BidLifeEffect extends SpellAbilityEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard(); final Card host = sa.getHostCard();
final Player activator = sa.getActivatingPlayer(); final Player activator = sa.getActivatingPlayer();
final FCollection<Player> bidPlayers = new FCollection<Player>(); final FCollection<Player> bidPlayers = new FCollection<>();
final int startBidding; final int startBidding;
if (sa.hasParam("StartBidding")) { if (sa.hasParam("StartBidding")) {
String start = sa.getParam("StartBidding"); String start = sa.getParam("StartBidding");

View File

@@ -22,7 +22,7 @@ public class BlockEffect extends SpellAbilityEffect {
final Game game = host.getGame(); final Game game = host.getGame();
final Combat combat = game.getPhaseHandler().getCombat(); final Combat combat = game.getPhaseHandler().getCombat();
List<Card> attackers = new ArrayList<Card>(); List<Card> attackers = new ArrayList<>();
if (sa.hasParam("DefinedAttacker")) { if (sa.hasParam("DefinedAttacker")) {
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) { for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
if (combat.isAttacking(attacker)) if (combat.isAttacking(attacker))
@@ -30,7 +30,7 @@ public class BlockEffect extends SpellAbilityEffect {
} }
} }
List<Card> blockers = new ArrayList<Card>(); List<Card> blockers = new ArrayList<>();
if (sa.hasParam("DefinedBlocker")) { if (sa.hasParam("DefinedBlocker")) {
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) { for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
if (blocker.isCreature() && blocker.isInZone(ZoneType.Battlefield)) if (blocker.isCreature() && blocker.isInZone(ZoneType.Battlefield))
@@ -90,14 +90,14 @@ public class BlockEffect extends SpellAbilityEffect {
// end standard pre- // end standard pre-
List<String> attackers = new ArrayList<String>(); List<String> attackers = new ArrayList<>();
if (sa.hasParam("DefinedAttacker")) { if (sa.hasParam("DefinedAttacker")) {
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) { for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
attackers.add(attacker.toString()); attackers.add(attacker.toString());
} }
} }
List<String> blockers = new ArrayList<String>(); List<String> blockers = new ArrayList<>();
if (sa.hasParam("DefinedBlocker")) { if (sa.hasParam("DefinedBlocker")) {
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) { for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
blockers.add(blocker.toString()); blockers.add(blocker.toString());

View File

@@ -641,7 +641,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
// for things like Gaea's Blessing // for things like Gaea's Blessing
if (destination.equals(ZoneType.Library) && sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle"))) { if (destination.equals(ZoneType.Library) && sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle"))) {
FCollection<Player> pl = new FCollection<Player>(); FCollection<Player> pl = new FCollection<>();
// use defined controller. it does need to work even without Targets. // use defined controller. it does need to work even without Targets.
if (sa.hasParam("TargetsWithDefinedController")) { if (sa.hasParam("TargetsWithDefinedController")) {
pl.addAll(AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("TargetsWithDefinedController"), sa)); pl.addAll(AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("TargetsWithDefinedController"), sa));

View File

@@ -34,7 +34,7 @@ public class ChooseColorEffect extends SpellAbilityEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
List<String> colorChoices = new ArrayList<String>(MagicColor.Constant.ONLY_COLORS); List<String> colorChoices = new ArrayList<>(MagicColor.Constant.ONLY_COLORS);
if (sa.hasParam("Choices")) { if (sa.hasParam("Choices")) {
String[] restrictedChoices = sa.getParam("Choices").split(","); String[] restrictedChoices = sa.getParam("Choices").split(",");
colorChoices = Arrays.asList(restrictedChoices); colorChoices = Arrays.asList(restrictedChoices);

View File

@@ -16,7 +16,7 @@ public class ChooseDirectionEffect extends SpellAbilityEffect {
public void resolve(final SpellAbility sa) { public void resolve(final SpellAbility sa) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final Game game = source.getGame(); final Game game = source.getGame();
final FCollection<Player> left = new FCollection<Player>(game.getPlayers()); final FCollection<Player> left = new FCollection<>(game.getPlayers());
// TODO: We'd better set up turn order UI here // TODO: We'd better set up turn order UI here
final String info = "Left (clockwise): " + left + "\r\nRight (anticlockwise):" + Lists.reverse(left); final String info = "Left (clockwise): " + left + "\r\nRight (anticlockwise):" + Lists.reverse(left);
sa.getActivatingPlayer().getController().notifyOfValue(sa, source, info); sa.getActivatingPlayer().getController().notifyOfValue(sa, source, info);

View File

@@ -29,9 +29,9 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
final String type = sa.getParam("Type"); final String type = sa.getParam("Type");
final List<String> invalidTypes = sa.hasParam("InvalidTypes") ? Arrays.asList(sa.getParam("InvalidTypes").split(",")) : new ArrayList<String>(); final List<String> invalidTypes = sa.hasParam("InvalidTypes") ? Arrays.asList(sa.getParam("InvalidTypes").split(",")) : new ArrayList<>();
final List<String> validTypes = new ArrayList<String>(); final List<String> validTypes = new ArrayList<>();
if (sa.hasParam("ValidTypes")) { if (sa.hasParam("ValidTypes")) {
validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(","))); validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(",")));
} }

View File

@@ -32,7 +32,7 @@ public class ClashEffect extends SpellAbilityEffect {
final boolean victory = clashWithOpponent(sa); final boolean victory = clashWithOpponent(sa);
// Run triggers // Run triggers
final HashMap<String, Object> runParams = new HashMap<String, Object>(); final HashMap<String, Object> runParams = new HashMap<>();
runParams.put("Player", sa.getHostCard().getController()); runParams.put("Player", sa.getHostCard().getController());
if (victory) { if (victory) {

View File

@@ -22,7 +22,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
Card object1 = null; Card object1 = null;
Card object2 = null; Card object2 = null;
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
List<Card> tgts = tgt == null ? new ArrayList<Card>() : Lists.newArrayList(sa.getTargets().getTargetCards()); List<Card> tgts = tgt == null ? new ArrayList<>() : Lists.newArrayList(sa.getTargets().getTargetCards());
if (tgts.size() > 0) { if (tgts.size() > 0) {
object1 = tgts.get(0); object1 = tgts.get(0);
} }
@@ -47,7 +47,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
Card object1 = null; Card object1 = null;
Card object2 = null; Card object2 = null;
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
List<Card> tgts = tgt == null ? new ArrayList<Card>() : Lists.newArrayList(sa.getTargets().getTargetCards()); List<Card> tgts = tgt == null ? new ArrayList<>() : Lists.newArrayList(sa.getTargets().getTargetCards());
if (tgts.size() > 0) { if (tgts.size() > 0) {
object1 = tgts.get(0); object1 = tgts.get(0);
} }

View File

@@ -78,7 +78,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
} }
boolean mayChooseNewTargets = true; boolean mayChooseNewTargets = true;
List<SpellAbility> copies = new ArrayList<SpellAbility>(); List<SpellAbility> copies = new ArrayList<>();
if (sa.hasParam("CopyMultipleSpells")) { if (sa.hasParam("CopyMultipleSpells")) {
final int spellCount = Integer.parseInt(sa.getParam("CopyMultipleSpells")); final int spellCount = Integer.parseInt(sa.getParam("CopyMultipleSpells"));

View File

@@ -69,7 +69,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
int numDam = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa); int numDam = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa);
final List<GameObject> tgts = getTargets(sa); final List<GameObject> tgts = getTargets(sa);
final List<Card> untargetedCards = new ArrayList<Card>(); final List<Card> untargetedCards = new ArrayList<>();
if (sa.hasParam("Radiance") && (sa.usesTargeting())) { if (sa.hasParam("Radiance") && (sa.usesTargeting())) {
Card origin = null; Card origin = null;
@@ -96,12 +96,12 @@ public class DamagePreventEffect extends SpellAbilityEffect {
final Card c = (Card) o; final Card c = (Card) o;
if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) { if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {
if (preventionWithEffect) { if (preventionWithEffect) {
Map<String, String> effectMap = new TreeMap<String, String>(); Map<String, String> effectMap = new TreeMap<>();
effectMap.put("EffectString", sa.getSVar(sa.getParam("PreventionSubAbility"))); effectMap.put("EffectString", sa.getSVar(sa.getParam("PreventionSubAbility")));
effectMap.put("ShieldAmount", String.valueOf(numDam)); effectMap.put("ShieldAmount", String.valueOf(numDam));
if (sa.hasParam("ShieldEffectTarget")) { if (sa.hasParam("ShieldEffectTarget")) {
String effTgtString = ""; String effTgtString = "";
List<GameObject> effTgts = new ArrayList<GameObject>(); List<GameObject> effTgts = new ArrayList<>();
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa); effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
for (final Object effTgt : effTgts) { for (final Object effTgt : effTgts) {
if (effTgt instanceof Card) { if (effTgt instanceof Card) {
@@ -123,12 +123,12 @@ public class DamagePreventEffect extends SpellAbilityEffect {
final Player p = (Player) o; final Player p = (Player) o;
if (!targeted || p.canBeTargetedBy(sa)) { if (!targeted || p.canBeTargetedBy(sa)) {
if (preventionWithEffect) { if (preventionWithEffect) {
Map<String, String> effectMap = new TreeMap<String, String>(); Map<String, String> effectMap = new TreeMap<>();
effectMap.put("EffectString", sa.getSVar(sa.getParam("PreventionSubAbility"))); effectMap.put("EffectString", sa.getSVar(sa.getParam("PreventionSubAbility")));
effectMap.put("ShieldAmount", String.valueOf(numDam)); effectMap.put("ShieldAmount", String.valueOf(numDam));
if (sa.hasParam("ShieldEffectTarget")) { if (sa.hasParam("ShieldEffectTarget")) {
String effTgtString = ""; String effTgtString = "";
List<GameObject> effTgts = new ArrayList<GameObject>(); List<GameObject> effTgts = new ArrayList<>();
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa); effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
for (final Object effTgt : effTgts) { for (final Object effTgt : effTgts) {
if (effTgt instanceof Card) { if (effTgt instanceof Card) {

View File

@@ -264,7 +264,7 @@ public class DigEffect extends SpellAbilityEffect {
if ( p == chooser ) { // the digger can still see all the dug cards when choosing if ( p == chooser ) { // the digger can still see all the dug cards when choosing
chooser.getController().tempShowCards(top); chooser.getController().tempShowCards(top);
} }
List<Card> chosen = new ArrayList<Card>(); List<Card> chosen = new ArrayList<>();
int max = anyNumber ? valid.size() : Math.min(valid.size(),destZone1ChangeNum); int max = anyNumber ? valid.size() : Math.min(valid.size(),destZone1ChangeNum);
int min = (anyNumber || optional) ? 0 : max; int min = (anyNumber || optional) ? 0 : max;

View File

@@ -108,7 +108,7 @@ public class DiscardEffect extends SpellAbilityEffect {
final Game game = source.getGame(); final Game game = source.getGame();
//final boolean anyNumber = sa.hasParam("AnyNumber"); //final boolean anyNumber = sa.hasParam("AnyNumber");
final List<Card> discarded = new ArrayList<Card>(); final List<Card> discarded = new ArrayList<>();
final List<Player> targets = getTargetPlayers(sa), final List<Player> targets = getTargetPlayers(sa),
discarders; discarders;
Player firstTarget = null; Player firstTarget = null;

View File

@@ -27,7 +27,7 @@ public class DrainManaEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
List<Mana> drained = new ArrayList<Mana>(); List<Mana> drained = new ArrayList<>();
for (final Player p : getTargetPlayers(sa)) { for (final Player p : getTargetPlayers(sa)) {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {

View File

@@ -19,7 +19,7 @@ public class LifeSetEffect extends SpellAbilityEffect {
final boolean redistribute = sa.hasParam("Redistribute"); final boolean redistribute = sa.hasParam("Redistribute");
final int lifeAmount = redistribute ? 20 : AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa); final int lifeAmount = redistribute ? 20 : AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa);
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final List<Integer> lifetotals = new ArrayList<Integer>(); final List<Integer> lifetotals = new ArrayList<>();
if (redistribute) { if (redistribute) {
for (final Player p : getTargetPlayers(sa)) { for (final Player p : getTargetPlayers(sa)) {

View File

@@ -23,7 +23,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
if (sa.hasParam("DefinedAttacker")) { if (sa.hasParam("DefinedAttacker")) {
cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa); cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
} else { } else {
cards = new ArrayList<Card>(); cards = new ArrayList<>();
cards.add(host); cards.add(host);
} }

View File

@@ -97,7 +97,7 @@ public class PlayEffect extends SpellAbilityEffect {
cards = Lists.newArrayList(Iterables.filter(cards, cpp)); cards = Lists.newArrayList(Iterables.filter(cards, cpp));
} }
if (sa.hasParam("RandomCopied")) { if (sa.hasParam("RandomCopied")) {
final List<PaperCard> copysource = new ArrayList<PaperCard>(cards); final List<PaperCard> copysource = new ArrayList<>(cards);
final CardCollection choice = new CardCollection(); final CardCollection choice = new CardCollection();
final String num = sa.hasParam("RandomNum") ? sa.getParam("RandomNum") : "1"; final String num = sa.hasParam("RandomNum") ? sa.getParam("RandomNum") : "1";
int ncopied = AbilityUtils.calculateAmount(source, num, sa); int ncopied = AbilityUtils.calculateAmount(source, num, sa);

View File

@@ -48,7 +48,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
final boolean isChoice = sa.getParam("Gains").contains("Choice"); final boolean isChoice = sa.getParam("Gains").contains("Choice");
final List<String> choices = ProtectEffect.getProtectionList(sa); final List<String> choices = ProtectEffect.getProtectionList(sa);
final List<String> gains = new ArrayList<String>(); final List<String> gains = new ArrayList<>();
if (isChoice) { if (isChoice) {
Player choser = sa.getActivatingPlayer(); Player choser = sa.getActivatingPlayer();
final String choice = choser.getController().chooseProtectionType("Choose a protection", sa, choices); final String choice = choser.getController().chooseProtectionType("Choose a protection", sa, choices);

View File

@@ -100,7 +100,7 @@ public class ProtectEffect extends SpellAbilityEffect {
final boolean isChoice = sa.getParam("Gains").contains("Choice"); final boolean isChoice = sa.getParam("Gains").contains("Choice");
final List<String> choices = getProtectionList(sa); final List<String> choices = getProtectionList(sa);
final List<String> gains = new ArrayList<String>(); final List<String> gains = new ArrayList<>();
final List<Card> tgtCards = getTargetCards(sa); final List<Card> tgtCards = getTargetCards(sa);
if (isChoice && !choices.isEmpty()) { if (isChoice && !choices.isEmpty()) {
@@ -128,7 +128,7 @@ public class ProtectEffect extends SpellAbilityEffect {
gainsKWList.add(TextUtil.concatWithSpace("Protection from", color)); gainsKWList.add(TextUtil.concatWithSpace("Protection from", color));
} }
final List<Card> untargetedCards = new ArrayList<Card>(); final List<Card> untargetedCards = new ArrayList<>();
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (sa.hasParam("Radiance") && (tgt != null)) { if (sa.hasParam("Radiance") && (tgt != null)) {
@@ -205,7 +205,7 @@ public class ProtectEffect extends SpellAbilityEffect {
public static List<String> getProtectionList(final SpellAbility sa) { public static List<String> getProtectionList(final SpellAbility sa) {
final List<String> gains = new ArrayList<String>(); final List<String> gains = new ArrayList<>();
final String gainStr = sa.getParam("Gains"); final String gainStr = sa.getParam("Gains");
if (gainStr.equals("Choice")) { if (gainStr.equals("Choice")) {

View File

@@ -29,10 +29,10 @@ public class RestartGameEffect extends SpellAbilityEffect {
final Player activator = sa.getActivatingPlayer(); final Player activator = sa.getActivatingPlayer();
final Game game = activator.getGame(); final Game game = activator.getGame();
FCollectionView<Player> players = game.getPlayers(); FCollectionView<Player> players = game.getPlayers();
Map<Player, List<Card>> playerLibraries = new HashMap<Player, List<Card>>(); Map<Player, List<Card>> playerLibraries = new HashMap<>();
// Don't grab Ante Zones // Don't grab Ante Zones
List<ZoneType> restartZones = new ArrayList<ZoneType>(Arrays.asList(ZoneType.Battlefield, List<ZoneType> restartZones = new ArrayList<>(Arrays.asList(ZoneType.Battlefield,
ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command)); ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command));
ZoneType leaveZone = ZoneType.smartValueOf(sa.hasParam("RestrictFromZone") ? sa.getParam("RestrictFromZone") : null); ZoneType leaveZone = ZoneType.smartValueOf(sa.hasParam("RestrictFromZone") ? sa.getParam("RestrictFromZone") : null);

View File

@@ -20,7 +20,7 @@ public class RunSVarAbilityEffect extends SpellAbilityEffect {
if (sVars == null || cards.isEmpty()) { if (sVars == null || cards.isEmpty()) {
return; return;
} }
List<SpellAbility> validSA = new ArrayList<SpellAbility>(); List<SpellAbility> validSA = new ArrayList<>();
final boolean isTrigger = sa.hasParam("IsTrigger"); final boolean isTrigger = sa.hasParam("IsTrigger");
for (final Card tgtC : cards) { for (final Card tgtC : cards) {
if (!tgtC.hasSVar(sVars)) { if (!tgtC.hasSVar(sVars)) {

View File

@@ -14,8 +14,8 @@ public class StoreMapEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
List<GameEntity> entity = new ArrayList<GameEntity>(); List<GameEntity> entity = new ArrayList<>();
List<Object> objects = new ArrayList<Object>(); List<Object> objects = new ArrayList<>();
if (sa.hasParam("RememberEntity")) { if (sa.hasParam("RememberEntity")) {
entity.addAll(AbilityUtils.getDefinedPlayers(source, sa.getParam("RememberEntity"), sa)); entity.addAll(AbilityUtils.getDefinedPlayers(source, sa.getParam("RememberEntity"), sa));

View File

@@ -56,11 +56,11 @@ public class CardState extends GameObject {
private String baseLoyalty = ""; private String baseLoyalty = "";
private KeywordCollection intrinsicKeywords = new KeywordCollection(); private KeywordCollection intrinsicKeywords = new KeywordCollection();
private final FCollection<SpellAbility> nonManaAbilities = new FCollection<SpellAbility>(); private final FCollection<SpellAbility> nonManaAbilities = new FCollection<>();
private final FCollection<SpellAbility> manaAbilities = new FCollection<SpellAbility>(); private final FCollection<SpellAbility> manaAbilities = new FCollection<>();
private FCollection<Trigger> triggers = new FCollection<Trigger>(); private FCollection<Trigger> triggers = new FCollection<>();
private FCollection<ReplacementEffect> replacementEffects = new FCollection<ReplacementEffect>(); private FCollection<ReplacementEffect> replacementEffects = new FCollection<>();
private FCollection<StaticAbility> staticAbilities = new FCollection<StaticAbility>(); private FCollection<StaticAbility> staticAbilities = new FCollection<>();
private String imageKey = ""; private String imageKey = "";
private Map<String, String> sVars = Maps.newTreeMap(); private Map<String, String> sVars = Maps.newTreeMap();
@@ -257,24 +257,24 @@ public class CardState extends GameObject {
} }
public final FCollectionView<SpellAbility> getSpellAbilities() { public final FCollectionView<SpellAbility> getSpellAbilities() {
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(manaAbilities); FCollection<SpellAbility> newCol = new FCollection<>(manaAbilities);
newCol.addAll(nonManaAbilities); newCol.addAll(nonManaAbilities);
card.updateSpellAbilities(newCol, this, null); card.updateSpellAbilities(newCol, this, null);
return newCol; return newCol;
} }
public final FCollectionView<SpellAbility> getManaAbilities() { public final FCollectionView<SpellAbility> getManaAbilities() {
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(manaAbilities); FCollection<SpellAbility> newCol = new FCollection<>(manaAbilities);
card.updateSpellAbilities(newCol, this, true); card.updateSpellAbilities(newCol, this, true);
return newCol; return newCol;
} }
public final FCollectionView<SpellAbility> getNonManaAbilities() { public final FCollectionView<SpellAbility> getNonManaAbilities() {
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(nonManaAbilities); FCollection<SpellAbility> newCol = new FCollection<>(nonManaAbilities);
card.updateSpellAbilities(newCol, this, false); card.updateSpellAbilities(newCol, this, false);
return newCol; return newCol;
} }
public final FCollectionView<SpellAbility> getIntrinsicSpellAbilities() { public final FCollectionView<SpellAbility> getIntrinsicSpellAbilities() {
return new FCollection<SpellAbility>(Iterables.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic())); return new FCollection<>(Iterables.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic()));
} }
public final boolean hasSpellAbility(final SpellAbility sa) { public final boolean hasSpellAbility(final SpellAbility sa) {
@@ -386,7 +386,7 @@ public class CardState extends GameObject {
return staticAbilities.remove(stab); return staticAbilities.remove(stab);
} }
public final void setStaticAbilities(final Iterable<StaticAbility> staticAbilities0) { public final void setStaticAbilities(final Iterable<StaticAbility> staticAbilities0) {
staticAbilities = new FCollection<StaticAbility>(staticAbilities0); staticAbilities = new FCollection<>(staticAbilities0);
} }
public final void clearStaticAbilities() { public final void clearStaticAbilities() {
staticAbilities.clear(); staticAbilities.clear();

View File

@@ -423,7 +423,7 @@ public final class CardUtil {
colors.add(MagicColor.Constant.COLORLESS); colors.add(MagicColor.Constant.COLORLESS);
} }
} else if (reflectProperty.equals("Produce")) { } else if (reflectProperty.equals("Produce")) {
final FCollection<SpellAbility> abilities = new FCollection<SpellAbility>(); final FCollection<SpellAbility> abilities = new FCollection<>();
for (final Card c : cards) { for (final Card c : cards) {
abilities.addAll(c.getManaAbilities()); abilities.addAll(c.getManaAbilities());
} }

Some files were not shown because too many files have changed in this diff Show More