mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Big Cleanup
This commit is contained in:
@@ -81,7 +81,7 @@ public class AiAttackController {
|
||||
this.defendingOpponent = choosePreferredDefenderPlayer();
|
||||
this.oppList = getOpponentCreatures(this.defendingOpponent);
|
||||
this.myList = ai.getCreaturesInPlay();
|
||||
this.attackers = new ArrayList<Card>();
|
||||
this.attackers = new ArrayList<>();
|
||||
for (Card c : myList) {
|
||||
if (CombatUtil.canAttack(c, this.defendingOpponent)) {
|
||||
attackers.add(c);
|
||||
@@ -95,7 +95,7 @@ public class AiAttackController {
|
||||
this.defendingOpponent = choosePreferredDefenderPlayer();
|
||||
this.oppList = getOpponentCreatures(this.defendingOpponent);
|
||||
this.myList = ai.getCreaturesInPlay();
|
||||
this.attackers = new ArrayList<Card>();
|
||||
this.attackers = new ArrayList<>();
|
||||
if (CombatUtil.canAttack(attacker, this.defendingOpponent)) {
|
||||
attackers.add(attacker);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class AiAttackController {
|
||||
} // overloaded constructor to evaluate single specified attacker
|
||||
|
||||
public static List<Card> getOpponentCreatures(final Player defender) {
|
||||
List<Card> defenders = new ArrayList<Card>();
|
||||
List<Card> defenders = new ArrayList<>();
|
||||
defenders.addAll(defender.getCreaturesInPlay());
|
||||
Predicate<Card> canAnimate = new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -151,7 +151,7 @@ public class AiAttackController {
|
||||
*
|
||||
*/
|
||||
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)
|
||||
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) {
|
||||
List<Card> possibleBlockers = new ArrayList<Card>(blockers);
|
||||
List<Card> possibleBlockers = new ArrayList<>(blockers);
|
||||
possibleBlockers = CardLists.filter(possibleBlockers, new Predicate<Card>() {
|
||||
@Override
|
||||
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) {
|
||||
final List<Card> attackerList = new ArrayList<Card>(attackers);
|
||||
final List<Card> attackerList = new ArrayList<>(attackers);
|
||||
if (!c.isCreature()) {
|
||||
return false;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public class AiAttackController {
|
||||
}
|
||||
|
||||
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()) {
|
||||
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 method is used by getAttackers()
|
||||
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;
|
||||
final List<Card> vigilantes = new ArrayList<Card>();
|
||||
final List<Card> vigilantes = new ArrayList<>();
|
||||
//check for time walks
|
||||
if (ai.getGame().getPhaseHandler().getNextTurn().equals(ai)) {
|
||||
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>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -681,7 +681,7 @@ public class AiAttackController {
|
||||
|
||||
// Determine who will be attacked
|
||||
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?
|
||||
GlobalAttackRestrictions restrict = GlobalAttackRestrictions.getGlobalRestrictions(ai, combat.getDefenders());
|
||||
@@ -821,12 +821,12 @@ public class AiAttackController {
|
||||
int humanForcesForAttritionalAttack = 0;
|
||||
|
||||
// examine the potential forces
|
||||
final List<Card> nextTurnAttackers = new ArrayList<Card>();
|
||||
final List<Card> nextTurnAttackers = new ArrayList<>();
|
||||
int candidateCounterAttackDamage = 0;
|
||||
|
||||
final Player opp = this.defendingOpponent;
|
||||
// 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;
|
||||
for (final Card pCard : this.myList) {
|
||||
// if the creature can attack then it's a potential attacker this
|
||||
@@ -908,7 +908,7 @@ public class AiAttackController {
|
||||
// get player life total
|
||||
int humanLife = opp.getLife();
|
||||
// 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++) {
|
||||
attritionalAttackers.add(this.attackers.get(x));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.Map;
|
||||
* @version $Id: AIProfile.java 20169 2013-03-08 08:24:17Z Agetian $
|
||||
*/
|
||||
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 final String AI_PROFILE_EXT = ".ai";
|
||||
@@ -74,7 +74,7 @@ public class AiProfileUtil {
|
||||
* @param profileName a profile to load.
|
||||
*/
|
||||
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));
|
||||
for (String line : lines) {
|
||||
@@ -122,7 +122,7 @@ public class AiProfileUtil {
|
||||
*/
|
||||
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 String[] children = dir.list();
|
||||
@@ -146,7 +146,7 @@ public class AiProfileUtil {
|
||||
* available profiles including special random profile tags.
|
||||
*/
|
||||
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_DUEL);
|
||||
availableProfiles.addAll(getAvailableProfiles());
|
||||
|
||||
@@ -1514,7 +1514,7 @@ public class ComputerUtil {
|
||||
*/
|
||||
public static List<GameObject> predictThreatenedObjects(final Player ai, final SpellAbility sa, boolean top) {
|
||||
final Game game = ai.getGame();
|
||||
final List<GameObject> objects = new ArrayList<GameObject>();
|
||||
final List<GameObject> objects = new ArrayList<>();
|
||||
if (game.getStack().isEmpty()) {
|
||||
return objects;
|
||||
}
|
||||
@@ -1543,8 +1543,8 @@ public class ComputerUtil {
|
||||
|
||||
private static Iterable<? extends GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour,
|
||||
final SpellAbility topStack) {
|
||||
Iterable<? extends GameObject> objects = new ArrayList<GameObject>();
|
||||
final List<GameObject> threatened = new ArrayList<GameObject>();
|
||||
Iterable<? extends GameObject> objects = new ArrayList<>();
|
||||
final List<GameObject> threatened = new ArrayList<>();
|
||||
ApiType saviourApi = saviour == null ? null : saviour.getApi();
|
||||
int toughness = 0;
|
||||
boolean grantIndestructible = false;
|
||||
@@ -1574,7 +1574,7 @@ public class ComputerUtil {
|
||||
}
|
||||
} else {
|
||||
objects = topStack.getTargets().getTargets();
|
||||
final List<GameObject> canBeTargeted = new ArrayList<GameObject>();
|
||||
final List<GameObject> canBeTargeted = new ArrayList<>();
|
||||
for (Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
@@ -1597,7 +1597,7 @@ public class ComputerUtil {
|
||||
toughness = saviorWithSubs.hasParam("NumDef") ?
|
||||
AbilityUtils.calculateAmount(saviorWithSubs.getHostCard(), saviorWithSubs.getParam("NumDef"), saviour) : 0;
|
||||
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")) {
|
||||
grantIndestructible = true;
|
||||
}
|
||||
@@ -1630,7 +1630,7 @@ public class ComputerUtil {
|
||||
final SpellAbility sub = topStack.getSubAbility();
|
||||
boolean noRegen = false;
|
||||
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) {
|
||||
if (kw.contains("can't be regenerated")) {
|
||||
noRegen = true;
|
||||
@@ -2053,7 +2053,7 @@ public class ComputerUtil {
|
||||
//Too many lands!
|
||||
//Init
|
||||
int cntColors = MagicColor.WUBRG.length;
|
||||
List<CardCollection> numProducers = new ArrayList<CardCollection>(cntColors);
|
||||
List<CardCollection> numProducers = new ArrayList<>(cntColors);
|
||||
for (byte col : MagicColor.WUBRG) {
|
||||
numProducers.add(col, new CardCollection());
|
||||
}
|
||||
@@ -2283,7 +2283,7 @@ public class ComputerUtil {
|
||||
chosen = ComputerUtilCard.getMostProminentType(list, valid);
|
||||
} else if (logic.equals("MostNeededType")) {
|
||||
// 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);
|
||||
CardCollectionView presentCards = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
|
||||
CardCollectionView possibleCards = ai.getAllCards();
|
||||
@@ -2588,7 +2588,7 @@ public class ComputerUtil {
|
||||
int damage = 0;
|
||||
final Game game = player.getGame();
|
||||
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)) {
|
||||
theTriggers.addAll(c.getTriggers());
|
||||
@@ -2680,7 +2680,7 @@ public class ComputerUtil {
|
||||
public static int getDamageFromETB(final Player player, final Card permanent) {
|
||||
int damage = 0;
|
||||
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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
|
||||
@@ -564,7 +564,7 @@ public class ComputerUtilCard {
|
||||
AiBlockController aiBlk = new AiBlockController(ai);
|
||||
Combat combat = new Combat(ai);
|
||||
combat.addAttacker(attacker, ai);
|
||||
final List<Card> attackers = new ArrayList<Card>();
|
||||
final List<Card> attackers = new ArrayList<>();
|
||||
attackers.add(attacker);
|
||||
aiBlk.assignBlockersGivenAttackers(combat, attackers);
|
||||
return ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, combat);
|
||||
@@ -788,7 +788,7 @@ public class ComputerUtilCard {
|
||||
|
||||
public static List<String> getColorByProminence(final List<Card> list) {
|
||||
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++) {
|
||||
map.add(MutablePair.of(MagicColor.WUBRG[i], 0));
|
||||
}
|
||||
@@ -810,7 +810,7 @@ public class ComputerUtilCard {
|
||||
});
|
||||
|
||||
// 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
|
||||
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) {
|
||||
List<String> chosen = new ArrayList<String>();
|
||||
List<String> chosen = new ArrayList<>();
|
||||
Player ai = sa.getActivatingPlayer();
|
||||
final Game game = ai.getGame();
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
@@ -1572,7 +1572,7 @@ public class ComputerUtilCard {
|
||||
Card pumped = CardFactory.copyCard(c, true);
|
||||
pumped.setSickness(c.hasSickness());
|
||||
final long timestamp = c.getGame().getNextTimestamp();
|
||||
final List<String> kws = new ArrayList<String>();
|
||||
final List<String> kws = new ArrayList<>();
|
||||
for (String kw : keywords) {
|
||||
if (kw.startsWith("HIDDEN")) {
|
||||
pumped.addHiddenExtrinsicKeyword(kw);
|
||||
|
||||
@@ -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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
@@ -1100,7 +1100,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
@@ -1284,7 +1284,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
@@ -1505,7 +1505,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
@@ -1726,7 +1726,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
@@ -2006,7 +2006,7 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
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)) {
|
||||
theTriggers.addAll(card.getTriggers());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
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();
|
||||
int testEnergyPool = ai.getCounters(CounterType.ENERGY);
|
||||
|
||||
@@ -1359,7 +1359,7 @@ public class ComputerUtilMana {
|
||||
final ListMultimap<Integer, SpellAbility> manaMap = ArrayListMultimap.create();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
List<ReplacementEffect> replacementEffects = new ArrayList<ReplacementEffect>();
|
||||
List<ReplacementEffect> replacementEffects = new ArrayList<>();
|
||||
for (final Player p : game.getPlayers()) {
|
||||
for (final Card crd : p.getAllCards()) {
|
||||
for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) {
|
||||
@@ -1565,7 +1565,7 @@ public class ComputerUtilMana {
|
||||
* @return map between creatures and shards to convoke
|
||||
*/
|
||||
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;
|
||||
if (!improvise) {
|
||||
for (ManaCostShard toPay : cost) {
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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 {
|
||||
ZONES.put(ZoneType.Battlefield, "battlefield");
|
||||
ZONES.put(ZoneType.Hand, "hand");
|
||||
@@ -66,8 +66,8 @@ public abstract class GameState {
|
||||
|
||||
private boolean puzzleCreatorState = false;
|
||||
|
||||
private final Map<ZoneType, String> humanCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||
private final Map<ZoneType, String> aiCardTexts = 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.class);
|
||||
|
||||
private final Map<Integer, Card> idToCard = new HashMap<>();
|
||||
private final Map<Card, Integer> cardToAttachId = new HashMap<>();
|
||||
@@ -1078,7 +1078,7 @@ public abstract class GameState {
|
||||
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()) {
|
||||
String value = kv.getValue();
|
||||
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()) {
|
||||
PlayerZone zone = p.getZone(kv.getKey());
|
||||
if (kv.getKey() == ZoneType.Battlefield) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (final Card c : kv.getValue()) {
|
||||
if (c.isToken()) {
|
||||
cards.add(c);
|
||||
|
||||
@@ -168,8 +168,8 @@ public class PlayerControllerAi extends PlayerController {
|
||||
if (delayedReveal != null) {
|
||||
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix());
|
||||
}
|
||||
FCollection<T> remaining = new FCollection<T>(optionList);
|
||||
List<T> selecteds = new ArrayList<T>();
|
||||
FCollection<T> remaining = new FCollection<>(optionList);
|
||||
List<T> selecteds = new ArrayList<>();
|
||||
T selected;
|
||||
do {
|
||||
selected = chooseSingleEntityForEffect(remaining, null, sa, title, selecteds.size()>=min, targetedPlayer);
|
||||
@@ -1072,7 +1072,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return new HashMap<Card, ManaCostShard>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -451,7 +451,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
*/
|
||||
private static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
List<Player> targetable = new ArrayList<Player>();
|
||||
List<Player> targetable = new ArrayList<>();
|
||||
for (final Player player : aiPlayer.getGame().getPlayers()) {
|
||||
if (sa.canTarget(player)) {
|
||||
targetable.add(player);
|
||||
@@ -855,7 +855,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
int totToughness = 0;
|
||||
int totPower = 0;
|
||||
final List<String> keywords = new ArrayList<String>();
|
||||
final List<String> keywords = new ArrayList<>();
|
||||
|
||||
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
||||
final Map<String, String> stabMap = stAbility.getMapParams();
|
||||
@@ -906,7 +906,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
Card c = null;
|
||||
if (prefList == null || prefList.isEmpty()) {
|
||||
prefList = new ArrayList<Card>(list);
|
||||
prefList = new ArrayList<>(list);
|
||||
} else {
|
||||
c = ComputerUtilCard.getBestAI(prefList);
|
||||
if (c != null) {
|
||||
@@ -960,7 +960,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
final Card card = sa.getHostCard();
|
||||
// Check if there are any valid targets
|
||||
List<GameObject> targets = new ArrayList<GameObject>();
|
||||
List<GameObject> targets = new ArrayList<>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt == null) {
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
@@ -1150,7 +1150,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
int totToughness = 0;
|
||||
int totPower = 0;
|
||||
final List<String> keywords = new ArrayList<String>();
|
||||
final List<String> keywords = new ArrayList<>();
|
||||
boolean grantingAbilities = false;
|
||||
|
||||
for (final StaticAbility stAbility : attachSource.getStaticAbilities()) {
|
||||
|
||||
@@ -482,7 +482,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
List<ZoneType> origin = new ArrayList<ZoneType>();
|
||||
List<ZoneType> origin = new ArrayList<>();
|
||||
if (sa.hasParam("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
|
||||
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?
|
||||
for (final String name : MagicColor.Constant.BASIC_LANDS) {
|
||||
@@ -1281,7 +1281,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
final List<GameObject> objects = ComputerUtil
|
||||
.predictThreatenedObjects(ai, sa);
|
||||
|
||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||
final List<Card> threatenedTargets = new ArrayList<>();
|
||||
|
||||
for (final Card c : aiPermanents) {
|
||||
if (objects.contains(c)) {
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ChooseGenericEffectAi extends SpellAbilityAi {
|
||||
Cost unless = new Cost(unlessCost, false);
|
||||
SpellAbility paycost = new SpellAbility.EmptySa(sa.getHostCard(), player);
|
||||
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)) {
|
||||
return sp;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
tcs.add(ai);
|
||||
chance = true;
|
||||
}
|
||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||
final List<Card> threatenedTargets = new ArrayList<>();
|
||||
// filter AIs battlefield by what I can target
|
||||
List<Card> targetables = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, hostCard, sa);
|
||||
targetables = CardLists.getTargetableCards(targetables, sa);
|
||||
|
||||
@@ -266,7 +266,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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 (mandatory) {
|
||||
|
||||
@@ -182,7 +182,7 @@ public class LifeLoseAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// For cards like Foul Imp, ETB you lose life
|
||||
|
||||
@@ -30,7 +30,7 @@ import forge.util.MyRandom;
|
||||
|
||||
public class ProtectAi extends SpellAbilityAi {
|
||||
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
|
||||
if (!onlyColors.contains(color)) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class PumpAllAi extends PumpAiBase {
|
||||
|
||||
final int power = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), 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();
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
||||
// control
|
||||
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) {
|
||||
if (objects.contains(c) && c.getShieldCount() == 0 && !ComputerUtil.canRegenerate(ai, c)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class StoreSVarAi extends SpellAbilityAi {
|
||||
possibleBlockers = CardLists.filter(possibleBlockers, Presets.UNTAPPED);
|
||||
int oppLife = opp.getLife();
|
||||
int potentialDmg = 0;
|
||||
List<Card> currentAttackers = new ArrayList<Card>();
|
||||
List<Card> currentAttackers = new ArrayList<>();
|
||||
|
||||
if (possibleBlockers.size() == 0) { return false; }
|
||||
|
||||
|
||||
@@ -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("")) {
|
||||
imageNames.add(PaperToken.makeTokenFileName(TextUtil.fastReplace(colorDesc, " ", ""), tokenPower, tokenToughness, tokenName));
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TwoPilesAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
final Player p = tgtPlayers.get(0);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class UnattachAllAi extends SpellAbilityAi {
|
||||
final Card card = sa.getHostCard();
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
// Check if there are any valid targets
|
||||
List<GameObject> targets = new ArrayList<GameObject>();
|
||||
List<GameObject> targets = new ArrayList<>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt == null) {
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class GameSimulator {
|
||||
aiPlayer = (Player) copier.find(origAiPlayer);
|
||||
eval = new GameStateEvaluator();
|
||||
|
||||
origLines = new ArrayList<String>();
|
||||
origLines = new ArrayList<>();
|
||||
debugLines = origLines;
|
||||
|
||||
debugPrint = false;
|
||||
@@ -52,7 +52,7 @@ public class GameSimulator {
|
||||
// first and get the updated eval score, since this is what we'll
|
||||
// want to compare to the eval score after simulating.
|
||||
if (COPY_STACK && !origGame.getStackZone().isEmpty()) {
|
||||
origLines = new ArrayList<String>();
|
||||
origLines = new ArrayList<>();
|
||||
debugLines = origLines;
|
||||
Game copyOrigGame = copier.makeCopy();
|
||||
Player copyOrigAiPlayer = copyOrigGame.getPlayers().get(1);
|
||||
@@ -66,12 +66,12 @@ public class GameSimulator {
|
||||
|
||||
private void ensureGameCopyScoreMatches(Game origGame, Player origAiPlayer) {
|
||||
eval.setDebugging(true);
|
||||
List<String> simLines = new ArrayList<String>();
|
||||
List<String> simLines = new ArrayList<>();
|
||||
debugLines = simLines;
|
||||
Score simScore = eval.getScoreForGameState(simGame, aiPlayer);
|
||||
if (!simScore.equals(origScore)) {
|
||||
// Re-eval orig with debug printing.
|
||||
origLines = new ArrayList<String>();
|
||||
origLines = new ArrayList<>();
|
||||
debugLines = origLines;
|
||||
eval.getScoreForGameState(origGame, origAiPlayer);
|
||||
// Print debug info.
|
||||
@@ -216,7 +216,7 @@ public class GameSimulator {
|
||||
List<String> simLines = null;
|
||||
if (debugPrint) {
|
||||
debugPrint("SimGame:");
|
||||
simLines = new ArrayList<String>();
|
||||
simLines = new ArrayList<>();
|
||||
debugLines = simLines;
|
||||
debugPrint = false;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class GameSimulator {
|
||||
opponent.runWithController(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Set<Card> allAffectedCards = new HashSet<Card>();
|
||||
final Set<Card> allAffectedCards = new HashSet<>();
|
||||
game.getAction().checkStateEffects(false, allAffectedCards);
|
||||
game.getStack().addAllTriggeredAbilitiesToStack();
|
||||
while (!game.getStack().isEmpty() && !game.isGameOver()) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PossibleTargetSelector {
|
||||
this.sa = sa;
|
||||
this.targetingSa = targetingSa;
|
||||
this.targetingSaIndex = targetingSaIndex;
|
||||
this.validTargets = new ArrayList<GameObject>();
|
||||
this.validTargets = new ArrayList<>();
|
||||
generateValidTargets(sa.getHostCard().getController());
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class PossibleTargetSelector {
|
||||
|
||||
private static class SimilarTargetSkipper {
|
||||
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 int getCreatureScore(Card c) {
|
||||
@@ -91,7 +91,7 @@ public class PossibleTargetSelector {
|
||||
return score;
|
||||
}
|
||||
} else {
|
||||
creatureScores = new HashMap<Card, Integer>();
|
||||
creatureScores = new HashMap<>();
|
||||
}
|
||||
|
||||
int score = ComputerUtilCard.evaluateCreature(c);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SimulationController {
|
||||
private List<GameSimulator> simulatorStack;
|
||||
private Plan.Decision bestSequence; // last action of sequence
|
||||
private Score bestScore;
|
||||
private List<CachedEffect> effectCache = new ArrayList<CachedEffect>();
|
||||
private List<CachedEffect> effectCache = new ArrayList<>();
|
||||
private GameObject[] currentHostAndTarget;
|
||||
|
||||
private static class CachedEffect {
|
||||
@@ -39,10 +39,10 @@ public class SimulationController {
|
||||
|
||||
public SimulationController(Score score) {
|
||||
bestScore = score;
|
||||
scoreStack = new ArrayList<Score>();
|
||||
scoreStack = new ArrayList<>();
|
||||
scoreStack.add(score);
|
||||
simulatorStack = new ArrayList<GameSimulator>();
|
||||
currentStack = new ArrayList<Plan.Decision>();
|
||||
simulatorStack = new ArrayList<>();
|
||||
currentStack = new ArrayList<>();
|
||||
}
|
||||
|
||||
private int getRecursionDepth() {
|
||||
@@ -97,7 +97,7 @@ public class SimulationController {
|
||||
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;
|
||||
while (current != null) {
|
||||
sequence.add(current);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SpellAbilityChoicesIterator {
|
||||
}
|
||||
ChoicePoint cp = choicePoints.get(cpIndex);
|
||||
// Prune duplicates.
|
||||
HashSet<String> uniqueCards = new HashSet<String>();
|
||||
HashSet<String> uniqueCards = new HashSet<>();
|
||||
for (int i = 0; i < fetchList.size(); i++) {
|
||||
Card card = fetchList.get(i);
|
||||
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) {
|
||||
ArrayList<AbilitySub> modes = new ArrayList<AbilitySub>();
|
||||
ArrayList<AbilitySub> modes = new ArrayList<>();
|
||||
for (int modeIndex : modeIndexes) {
|
||||
modes.add(choices.get(modeIndex));
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SpellAbilityPicker {
|
||||
List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, player);
|
||||
CardCollection landsToPlay = ComputerUtilAbility.getAvailableLandsToPlay(game, player);
|
||||
if (landsToPlay != null) {
|
||||
HashMap<String, Card> landsDeDupe = new HashMap<String, Card>();
|
||||
HashMap<String, Card> landsDeDupe = new HashMap<>();
|
||||
for (Card land : landsToPlay) {
|
||||
Card previousLand = landsDeDupe.get(land.getName());
|
||||
// Skip identical lands.
|
||||
@@ -165,7 +165,7 @@ public class SpellAbilityPicker {
|
||||
|
||||
PhaseType currentPhase = game.getPhaseHandler().getPhase();
|
||||
if (currentPhase.isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)) {
|
||||
List<SpellAbility> candidateSAs2 = new ArrayList<SpellAbility>();
|
||||
List<SpellAbility> candidateSAs2 = new ArrayList<>();
|
||||
for (SpellAbility sa : candidateSAs) {
|
||||
if (!isSorcerySpeed(sa, player)) {
|
||||
System.err.println("Not sorcery: " + sa);
|
||||
|
||||
@@ -175,7 +175,7 @@ public class CardStorageReader {
|
||||
}
|
||||
|
||||
if (zipEntriesMap == null) {
|
||||
zipEntriesMap = new HashMap<String, ZipEntry>();
|
||||
zipEntriesMap = new HashMap<>();
|
||||
for (ZipEntry entry : getZipEntries()) {
|
||||
zipEntriesMap.put(entry.getName(), entry);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class CardStorageReader {
|
||||
return result;
|
||||
}
|
||||
|
||||
final List<File> allFiles = collectCardFiles(new ArrayList<File>(), this.cardsfolder);
|
||||
final List<File> allFiles = collectCardFiles(new ArrayList<>(), this.cardsfolder);
|
||||
if (!allFiles.isEmpty()) {
|
||||
int fileParts = zip == null ? NUMBER_OF_PARTS : 1 + NUMBER_OF_PARTS / 3;
|
||||
if (allFiles.size() < fileParts * 100) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Map;
|
||||
|
||||
public class FTrace {
|
||||
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() {
|
||||
appStartTime = new Date().getTime();
|
||||
|
||||
@@ -110,7 +110,7 @@ public class StaticData {
|
||||
private List<CardEdition> sortedEditions;
|
||||
public final List<CardEdition> getSortedEditions() {
|
||||
if (sortedEditions == null) {
|
||||
sortedEditions = new ArrayList<CardEdition>();
|
||||
sortedEditions = new ArrayList<>();
|
||||
for (CardEdition set : editions) {
|
||||
sortedEditions.add(set);
|
||||
}
|
||||
|
||||
@@ -41,16 +41,16 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
public final static char NameSetSeparator = '|';
|
||||
|
||||
// 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, CardRules> rulesByName;
|
||||
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, 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 CardEdition.Collection editions;
|
||||
|
||||
@@ -166,8 +166,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
public void initialize(boolean logMissingPerEdition, boolean logMissingSummary) {
|
||||
Set<String> allMissingCards = new LinkedHashSet<String>();
|
||||
List<String> missingCards = new ArrayList<String>();
|
||||
Set<String> allMissingCards = new LinkedHashSet<>();
|
||||
List<String> missingCards = new ArrayList<>();
|
||||
CardEdition upcomingSet = null;
|
||||
Date today = new Date();
|
||||
|
||||
@@ -342,10 +342,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
if (request.artIndex <= 0) { // this stands for 'random art'
|
||||
Collection<PaperCard> candidates;
|
||||
if (reqEdition == null) {
|
||||
candidates = new ArrayList<PaperCard>(cards);
|
||||
candidates = new ArrayList<>(cards);
|
||||
}
|
||||
else {
|
||||
candidates = new ArrayList<PaperCard>();
|
||||
candidates = new ArrayList<>();
|
||||
for (PaperCard pc : cards) {
|
||||
if (pc.getEdition().equalsIgnoreCase(reqEdition)) {
|
||||
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
|
||||
}
|
||||
if (cardsListReadOnly) { //ensure we don't modify a cached collection
|
||||
cards = new ArrayList<PaperCard>(cards);
|
||||
cards = new ArrayList<>(cards);
|
||||
cardsListReadOnly = false;
|
||||
}
|
||||
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);
|
||||
|
||||
// 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()) {
|
||||
for (CardEdition e : editions.getOrderedEditions()) {
|
||||
int artIdx = 1;
|
||||
|
||||
@@ -24,8 +24,8 @@ final class CardFace implements ICardFace {
|
||||
}
|
||||
|
||||
|
||||
private final static List<String> emptyList = Collections.unmodifiableList(new ArrayList<String>());
|
||||
private final static Map<String, String> emptyMap = Collections.unmodifiableMap(new TreeMap<String, String>());
|
||||
private final static List<String> emptyList = Collections.unmodifiableList(new ArrayList<>());
|
||||
private final static Map<String, String> emptyMap = Collections.unmodifiableMap(new TreeMap<>());
|
||||
|
||||
private final String name;
|
||||
private String altName = null;
|
||||
@@ -112,12 +112,12 @@ final class CardFace implements ICardFace {
|
||||
|
||||
// Raw fields used for Card creation
|
||||
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 addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<String>(); } this.abilities.add(value);}
|
||||
void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<String>(); } this.triggers.add(value);}
|
||||
void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<String>(); } this.staticAbilities.add(value);}
|
||||
void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<String>(); } 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 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<>(); } this.abilities.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<>(); } this.staticAbilities.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.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); }
|
||||
|
||||
|
||||
void assignMissingFields() { // Most scripts do not specify color explicitly
|
||||
|
||||
@@ -627,7 +627,7 @@ public final class CardRulesPredicates {
|
||||
public static final Predicate<CardRules> IS_MONOCOLOR = CardRulesPredicates.hasCntColors((byte) 1);
|
||||
|
||||
/** The Constant colors. */
|
||||
public static final List<Predicate<CardRules>> COLORS = new ArrayList<Predicate<CardRules>>();
|
||||
public static final List<Predicate<CardRules>> COLORS = new ArrayList<>();
|
||||
static {
|
||||
Presets.COLORS.add(Presets.IS_WHITE);
|
||||
Presets.COLORS.add(Presets.IS_BLUE);
|
||||
|
||||
@@ -320,7 +320,7 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
||||
if (isColorless()) {
|
||||
return EnumSet.of(Color.COLORLESS);
|
||||
}
|
||||
List<Color> list = new ArrayList<Color>();
|
||||
List<Color> list = new ArrayList<>();
|
||||
for (Color c : Color.values()) {
|
||||
if (hasAnyColor(c.getColormask())) {
|
||||
list.add(c);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PrintSheet {
|
||||
number -= uniqueCards;
|
||||
}
|
||||
|
||||
List<PaperCard> uniques = wantUnique ? new ArrayList<PaperCard>() : null;
|
||||
List<PaperCard> uniques = wantUnique ? new ArrayList<>() : null;
|
||||
for(int iC = 0; iC < number; iC++) {
|
||||
int index = MyRandom.getRandom().nextInt(totalWeight);
|
||||
PaperCard toAdd = fetchRoulette(0, index, wantUnique ? uniques : null);
|
||||
|
||||
@@ -39,8 +39,8 @@ import java.util.Map.Entry;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPool>> {
|
||||
private final Map<DeckSection, CardPool> parts = new EnumMap<DeckSection, CardPool>(DeckSection.class);
|
||||
private final Set<String> tags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<DeckSection, CardPool> parts = new EnumMap<>(DeckSection.class);
|
||||
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
|
||||
// the lazy card load feature to ensure we don't need to load all cards on start up.
|
||||
private Map<String, List<String>> deferredSections;
|
||||
|
||||
@@ -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<>();
|
||||
for (final Entry<PaperCard, Integer> cp : deck.get(DeckSection.Main)) {
|
||||
@@ -306,7 +306,7 @@ public enum DeckFormat {
|
||||
}
|
||||
|
||||
if (cardPoolFilter != null) {
|
||||
final List<PaperCard> erroneousCI = new ArrayList<PaperCard>();
|
||||
final List<PaperCard> erroneousCI = new ArrayList<>();
|
||||
for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) {
|
||||
if (!cardPoolFilter.apply(cp.getKey().getRules())) {
|
||||
erroneousCI.add(cp.getKey());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DeckGroup extends DeckBase {
|
||||
|
||||
private static final long serialVersionUID = -1628725522049635829L;
|
||||
private Deck humanDeck;
|
||||
private List<Deck> aiDecks = new ArrayList<Deck>();
|
||||
private List<Deck> aiDecks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Gets the human deck.
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
|
||||
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() {
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public abstract class DeckGeneratorBase {
|
||||
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 boolean useArtifacts = true;
|
||||
protected String basicLandEdition = null;
|
||||
@@ -299,7 +299,7 @@ public abstract class DeckGeneratorBase {
|
||||
protected static Map<String, Integer> countLands(ItemPool<PaperCard> outList) {
|
||||
// attempt to optimize basic land counts according
|
||||
// to color representation
|
||||
Map<String, Integer> res = new TreeMap<String, Integer>();
|
||||
Map<String, Integer> res = new TreeMap<>();
|
||||
// count each card color using mana costs
|
||||
// TODO: count hybrid mana differently?
|
||||
for (Entry<PaperCard, Integer> cpe : outList) {
|
||||
@@ -418,7 +418,7 @@ public abstract class DeckGeneratorBase {
|
||||
}
|
||||
|
||||
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);
|
||||
for (PaperCard card:landCards){
|
||||
if (card.getRules().getAiHints().getRemAIDecks()) {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DeckFileHeader {
|
||||
this.deckType = DeckFormat.smartValueOf(kvPairs.get(DeckFileHeader.DECK_TYPE), DeckFormat.Constructed);
|
||||
this.customPool = kvPairs.getBoolean(DeckFileHeader.CSTM_POOL);
|
||||
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);
|
||||
if( StringUtils.isNotBlank(rawTags) ) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DeckSerializer {
|
||||
}
|
||||
|
||||
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.concatNoSpace(DeckFileHeader.NAME,"=", d.getName().replaceAll("\n", "")));
|
||||
|
||||
@@ -93,7 +93,7 @@ public class BoosterBox extends BoxedProduct {
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
int nBoosters = 6;
|
||||
|
||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||
List<Pair<String, Integer>> slots = new ArrayList<>();
|
||||
for(String slotDesc : data) {
|
||||
String[] kv = TextUtil.split(slotDesc, ' ', 2);
|
||||
if (kv[1].startsWith("Booster"))
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class BoxedProduct extends SealedProduct {
|
||||
}
|
||||
|
||||
public List<PaperCard> getExtraCards() {
|
||||
return new ArrayList<PaperCard>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -111,7 +111,7 @@ public class FatPack extends BoxedProduct {
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
int nBoosters = 6;
|
||||
|
||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||
List<Pair<String, Integer>> slots = new ArrayList<>();
|
||||
for(String slotDesc : data) {
|
||||
String[] kv = TextUtil.split(slotDesc, ' ', 2);
|
||||
if (kv[1].startsWith("Booster"))
|
||||
|
||||
@@ -124,7 +124,7 @@ public class Aggregates {
|
||||
}
|
||||
|
||||
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) {
|
||||
// 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
|
||||
final Map<K, U> uniques = new Hashtable<K, U>();
|
||||
final Map<K, U> uniques = new Hashtable<>();
|
||||
for (final U c : source) {
|
||||
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) {
|
||||
Map<U, Integer> result = new HashMap<U, Integer>();
|
||||
Map<U, Integer> result = new HashMap<>();
|
||||
for (Entry<T, Integer> kv : source) {
|
||||
U k = fnGetField.apply(kv.getKey());
|
||||
Integer v = kv.getValue();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class FileSection {
|
||||
* Instantiates a new file section.
|
||||
*/
|
||||
protected FileSection() {
|
||||
this(new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER));
|
||||
this(new TreeMap<>(String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
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) {
|
||||
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)) {
|
||||
final String[] pairs = line.split(Pattern.quote(pairSeparator));
|
||||
final Pattern splitter = Pattern.compile(Pattern.quote(kvSeparator));
|
||||
@@ -211,7 +211,7 @@ public class FileSection {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
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 = "";
|
||||
List<String> currentList = null;
|
||||
|
||||
@@ -234,7 +234,7 @@ public class FileSection {
|
||||
currentList = null;
|
||||
} else {
|
||||
if (currentList == null) {
|
||||
currentList = new ArrayList<String>();
|
||||
currentList = new ArrayList<>();
|
||||
}
|
||||
currentList.add(st);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class FileUtil {
|
||||
public static List<String> readFile(final File file) {
|
||||
try {
|
||||
if ((file == null) || !file.exists()) {
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return FileUtil.readAllLines(new FileReader(file), false);
|
||||
} catch (final Exception ex) {
|
||||
@@ -222,7 +222,7 @@ public final class FileUtil {
|
||||
* @return list of strings
|
||||
*/
|
||||
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 {
|
||||
final BufferedReader in = new BufferedReader(reader);
|
||||
String line;
|
||||
@@ -244,7 +244,7 @@ public final class FileUtil {
|
||||
Pattern lineSplitter = Pattern.compile(Pattern.quote(" "));
|
||||
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)) {
|
||||
if (StringUtils.isBlank(line) || line.startsWith("#")) {
|
||||
@@ -271,7 +271,7 @@ public final class FileUtil {
|
||||
}
|
||||
|
||||
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>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
|
||||
@@ -60,12 +60,12 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
};
|
||||
|
||||
public ItemPool(final Class<T> cls) {
|
||||
this(new LinkedHashMap<T, Integer>(), cls);
|
||||
this(new LinkedHashMap<>(), cls);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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) {
|
||||
for (final Entry<Tin, Integer> e : from) {
|
||||
final Tin srcKey = e.getKey();
|
||||
@@ -79,7 +79,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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) {
|
||||
for (final Tin srcKey : from) {
|
||||
if (clsHint.isInstance(srcKey)) {
|
||||
@@ -95,7 +95,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
items = items0;
|
||||
}
|
||||
else {
|
||||
items = new HashMap<T, Integer>(); //prevent items being null
|
||||
items = new HashMap<>(); //prevent items being null
|
||||
}
|
||||
myClass = cls;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
}
|
||||
|
||||
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 (int i = 0; i < e.getValue(); i++) {
|
||||
result.add(e.getKey());
|
||||
@@ -171,7 +171,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
}
|
||||
|
||||
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) {
|
||||
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() {
|
||||
return new ItemPool<T>(Collections.unmodifiableMap(items), getMyClass());
|
||||
return new ItemPool<>(Collections.unmodifiableMap(items), getMyClass());
|
||||
}
|
||||
|
||||
public void add(final T item) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemPoolSorter<T> implements Comparator<Entry<T, Integer>> {
|
||||
}
|
||||
|
||||
/** 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<?>>() {
|
||||
@Override
|
||||
public Comparable<?> apply(final Entry<PaperCard, Integer> from) {
|
||||
|
||||
@@ -195,7 +195,7 @@ public final class NameGenerator {
|
||||
"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 String[] sourceList;
|
||||
|
||||
@@ -239,8 +239,8 @@ public final class NameGenerator {
|
||||
break;
|
||||
|
||||
default:
|
||||
List<String> all = new ArrayList<String>(
|
||||
genericMales.length + fantasyMales.length + genericFemales.length + fantasyFemales.length);
|
||||
List<String> all = new ArrayList<>(
|
||||
genericMales.length + fantasyMales.length + genericFemales.length + fantasyFemales.length);
|
||||
Collections.addAll(all, genericMales);
|
||||
Collections.addAll(all, fantasyMales);
|
||||
Collections.addAll(all, genericFemales);
|
||||
@@ -272,7 +272,7 @@ public final class NameGenerator {
|
||||
/** Generates a specified number of random names. */
|
||||
public static List<String> getRandomNames(final int generateAmount, final List<String> 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++) {
|
||||
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. */
|
||||
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);
|
||||
return getRandomName(gender, type, exclude);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TextUtil {
|
||||
* 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) {
|
||||
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
|
||||
boolean trimParenthesis = openPar == closePar && openPar > 0;
|
||||
int nPar = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Set;
|
||||
public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>, Cloneable, Serializable {
|
||||
private static final long serialVersionUID = -1664555336364294106L;
|
||||
|
||||
private static final FCollection<?> EMPTY = new EmptyFCollection<Object>();
|
||||
private static final FCollection<?> EMPTY = new EmptyFCollection<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> FCollection<T> getEmpty() {
|
||||
@@ -527,7 +527,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
|
||||
@Override
|
||||
public Iterable<T> threadSafeIterable() {
|
||||
//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
|
||||
|
||||
@@ -6,7 +6,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
|
||||
private static final long serialVersionUID = 1438913784333297606L;
|
||||
|
||||
public static <T> LinkedHashMapToAmount<T> emptyMap() {
|
||||
return new LinkedHashMapToAmount<T>(0);
|
||||
return new LinkedHashMapToAmount<>(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,11 +59,11 @@ public final class MapToAmountUtil {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (map.isEmpty()) {
|
||||
return new FCollection<T>();
|
||||
return new FCollection<>();
|
||||
}
|
||||
|
||||
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()) {
|
||||
if (entry.getValue().intValue() == max) {
|
||||
set.add(entry.getKey());
|
||||
@@ -114,11 +114,11 @@ public final class MapToAmountUtil {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (map.isEmpty()) {
|
||||
return new FCollection<T>();
|
||||
return new FCollection<>();
|
||||
}
|
||||
|
||||
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()) {
|
||||
if (entry.getValue().intValue() == min) {
|
||||
set.add(entry.getKey());
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.*;
|
||||
public class StorageBase<T> implements IStorage<T> {
|
||||
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 StorageBase(final String name0, final IItemReader<T> io) {
|
||||
@@ -55,7 +55,7 @@ public class StorageBase<T> implements IStorage<T> {
|
||||
|
||||
@Override
|
||||
public final Collection<String> getItemNames() {
|
||||
return new ArrayList<String>(map.keySet());
|
||||
return new ArrayList<>(map.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
||||
private final Function<File, IStorage<T>> nestedFactory = new Function<File, IStorage<T>>() {
|
||||
@Override
|
||||
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) {
|
||||
super(name, 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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,7 +9,7 @@ public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
|
||||
private final File thisFolder;
|
||||
|
||||
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;
|
||||
for (File sf : subfolders) {
|
||||
IStorage<T> newUnit = factory.apply(sf);
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class StorageReaderFile<T> extends StorageReaderBase<T> {
|
||||
|
||||
@Override
|
||||
public Map<String, T> readAll() {
|
||||
final Map<String, T> result = new TreeMap<String, T>();
|
||||
final Map<String, T> result = new TreeMap<>();
|
||||
|
||||
int idx = 0;
|
||||
for (String line : FileUtil.readFile(file)) {
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
|
||||
}
|
||||
|
||||
protected Map<String, T> createMap() {
|
||||
return new TreeMap<String, T>();
|
||||
return new TreeMap<>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -66,7 +66,7 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
|
||||
int idx = 0;
|
||||
Iterable<String> contents = FileUtil.readFile(file);
|
||||
|
||||
List<String> accumulator = new ArrayList<String>();
|
||||
List<String> accumulator = new ArrayList<>();
|
||||
String header = null;
|
||||
|
||||
for (final String s : contents) {
|
||||
|
||||
@@ -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)
|
||||
* @see forge.util.IItemReader#readAll()
|
||||
*/
|
||||
@Override
|
||||
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());
|
||||
for (final File file : files) {
|
||||
|
||||
@@ -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)
|
||||
* @see forge.util.IItemReader#readAll()
|
||||
*/
|
||||
@Override
|
||||
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> customFormats = listFileTree(userDirectory);
|
||||
@@ -115,7 +115,7 @@ public abstract class StorageReaderRecursiveFolderWithUserFolder<T> extends Stor
|
||||
}
|
||||
|
||||
private Collection<File> listFileTree(File dir) {
|
||||
Set<File> fileTree = new HashSet<File>();
|
||||
Set<File> fileTree = new HashSet<>();
|
||||
if(dir==null||dir.listFiles(getFileFilter())==null){
|
||||
return fileTree;
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ public class Game {
|
||||
ingamePlayers.remove(p);
|
||||
lostPlayers.add(p);
|
||||
|
||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||
final Map<String, Object> runParams = new TreeMap<>();
|
||||
runParams.put("Player", p);
|
||||
getTriggerHandler().runTrigger(TriggerType.LosesGame, runParams, false);
|
||||
}
|
||||
|
||||
@@ -787,7 +787,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
// search for cards with static abilities
|
||||
final FCollection<StaticAbility> staticAbilities = new FCollection<StaticAbility>();
|
||||
final FCollection<StaticAbility> staticAbilities = new FCollection<>();
|
||||
final CardCollection staticList = new CardCollection();
|
||||
|
||||
game.forEachCardInGame(new Visitor<Card>() {
|
||||
@@ -880,6 +880,10 @@ public class GameAction {
|
||||
c.getStaticCommandList().removeAll(toRemove);
|
||||
}
|
||||
// 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();
|
||||
while (it.hasNext()) {
|
||||
Card c = it.next();
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
import forge.trackable.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) {
|
||||
entityCache.put(id, entity);
|
||||
@@ -33,7 +33,7 @@ public class GameEntityCache<Entity extends IIdentifiable, View extends Trackabl
|
||||
}
|
||||
|
||||
public List<Entity> getList(Iterable<View> views) {
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
List<Entity> list = new ArrayList<>();
|
||||
addToList(views, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class GameEntityView extends TrackableObject {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
TrackableCollection<GameEntityView> collection = new TrackableCollection<GameEntityView>();
|
||||
TrackableCollection<GameEntityView> collection = new TrackableCollection<>();
|
||||
for (GameEntity e : entities) {
|
||||
collection.add(e.getView());
|
||||
}
|
||||
|
||||
@@ -101,14 +101,14 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
allowedSetCodes = Lists.newArrayList(parsedSets);
|
||||
}else{
|
||||
allowedSetCodes = new ArrayList<String>();
|
||||
allowedSetCodes = new ArrayList<>();
|
||||
}
|
||||
|
||||
bannedCardNames = bannedCards == null ? new ArrayList<String>() : Lists.newArrayList(bannedCards);
|
||||
restrictedCardNames = restrictedCards == null ? new ArrayList<String>() : Lists.newArrayList(restrictedCards);
|
||||
allowedRarities = rarities == null ? new ArrayList<CardRarity>() : rarities;
|
||||
bannedCardNames = bannedCards == null ? new ArrayList<>() : Lists.newArrayList(bannedCards);
|
||||
restrictedCardNames = restrictedCards == null ? new ArrayList<>() : Lists.newArrayList(restrictedCards);
|
||||
allowedRarities = rarities == null ? new ArrayList<>() : rarities;
|
||||
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.bannedCardNames_ro = Collections.unmodifiableList(bannedCardNames);
|
||||
@@ -195,7 +195,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public List<PaperCard> getAllCards() {
|
||||
List<PaperCard> cards = new ArrayList<PaperCard>();
|
||||
List<PaperCard> cards = new ArrayList<>();
|
||||
CardDb commonCards = StaticData.instance().getCommonCards();
|
||||
for (String setCode : allowedSetCodes_ro) {
|
||||
CardEdition edition = StaticData.instance().getEditions().get(setCode);
|
||||
@@ -285,7 +285,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public static class Reader extends StorageReaderRecursiveFolderWithUserFolder<GameFormat> {
|
||||
List<GameFormat> naturallyOrdered = new ArrayList<GameFormat>();
|
||||
List<GameFormat> naturallyOrdered = new ArrayList<>();
|
||||
boolean includeHistoric;
|
||||
private List<String> coreFormats = new ArrayList<>();
|
||||
{
|
||||
@@ -484,7 +484,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public Set<GameFormat> getAllFormatsOfCard(PaperCard card) {
|
||||
Set<GameFormat> result = new HashSet<GameFormat>();
|
||||
Set<GameFormat> result = new HashSet<>();
|
||||
for (GameFormat gf : naturallyOrdered) {
|
||||
if (gf.getFilterRules().apply(card)) {
|
||||
result.add(gf);
|
||||
@@ -501,7 +501,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public Set<GameFormat> getAllFormatsOfDeck(Deck deck, Boolean exhaustive) {
|
||||
SortedSet<GameFormat> result = new TreeSet<GameFormat>();
|
||||
SortedSet<GameFormat> result = new TreeSet<>();
|
||||
Set<FormatSubType> coveredTypes = new HashSet<>();
|
||||
CardPool allCards = deck.getAllCardsInASinglePool();
|
||||
for(GameFormat gf : reverseDateOrdered) {
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.Observable;
|
||||
public class GameLog extends Observable implements Serializable {
|
||||
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);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class GameLog extends Observable implements Serializable {
|
||||
* @return the log text
|
||||
*/
|
||||
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--) {
|
||||
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
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
final List<GameLogEntry> result = new ArrayList<>();
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
|
||||
@@ -130,7 +130,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
private static GameLogEntry generateSummary(final List<GameOutcome> gamesPlayed) {
|
||||
final GameOutcome outcome1 = gamesPlayed.get(0);
|
||||
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.
|
||||
for (final GameOutcome game : gamesPlayed) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public abstract class GameObjectMap {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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) {
|
||||
result.add((T) map(o));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Match {
|
||||
private final GameRules rules;
|
||||
private final String title;
|
||||
|
||||
private final List<GameOutcome> gamesPlayed = new ArrayList<GameOutcome>();
|
||||
private final List<GameOutcome> gamesPlayed = new ArrayList<>();
|
||||
private final List<GameOutcome> gamesPlayedRo;
|
||||
|
||||
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) {
|
||||
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<PaperCard, Integer> cp : ds.getValue()) {
|
||||
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) {
|
||||
PlayerZone library = player.getZone(zoneType);
|
||||
List<Card> newLibrary = new ArrayList<Card>();
|
||||
List<Card> newLibrary = new ArrayList<>();
|
||||
for (final Entry<PaperCard, Integer> stackOfCards : section) {
|
||||
final PaperCard cp = stackOfCards.getKey();
|
||||
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
||||
@@ -304,7 +304,7 @@ public class Match {
|
||||
GameOutcome outcome = lastGame.getOutcome();
|
||||
|
||||
// remove all the lost cards from owners' decks
|
||||
List<PaperCard> losses = new ArrayList<PaperCard>();
|
||||
List<PaperCard> losses = new ArrayList<>();
|
||||
int cntPlayers = players.size();
|
||||
int iWinner = -1;
|
||||
for (int i = 0; i < cntPlayers; i++) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum PlanarDice {
|
||||
trigRes = Chaos;
|
||||
}
|
||||
|
||||
HashMap<String,Object> runParams = new HashMap<String,Object>();
|
||||
HashMap<String,Object> runParams = new HashMap<>();
|
||||
runParams.put("Player", roller);
|
||||
runParams.put("Result", trigRes);
|
||||
roller.getGame().getTriggerHandler().runTrigger(TriggerType.PlanarDice, runParams,false);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addOriginalAbilities(final Card c, final SpellAbility sa) {
|
||||
if (!this.originalAbilities.containsKey(c)) {
|
||||
final List<SpellAbility> list = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> list = new ArrayList<>();
|
||||
list.add(sa);
|
||||
this.originalAbilities.put(c, list);
|
||||
} else {
|
||||
@@ -185,7 +185,7 @@ public class StaticEffect {
|
||||
* a {@link java.util.List} object.
|
||||
*/
|
||||
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)) {
|
||||
this.originalAbilities.put(c, list);
|
||||
} else {
|
||||
@@ -204,7 +204,7 @@ public class StaticEffect {
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
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)) {
|
||||
returnList.addAll(this.originalAbilities.get(c));
|
||||
}
|
||||
@@ -271,7 +271,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addOriginalKeyword(final Card c, final String s) {
|
||||
if (!this.originalKeywords.containsKey(c)) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
this.originalKeywords.put(c, list);
|
||||
} else {
|
||||
@@ -290,7 +290,7 @@ public class StaticEffect {
|
||||
* a {@link List} object.
|
||||
*/
|
||||
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)) {
|
||||
this.originalKeywords.put(c, list);
|
||||
} else {
|
||||
@@ -309,7 +309,7 @@ public class StaticEffect {
|
||||
* @return a {@link List} object.
|
||||
*/
|
||||
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)) {
|
||||
returnList.addAll(this.originalKeywords.get(c));
|
||||
}
|
||||
@@ -424,7 +424,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addOriginalType(final Card c, final String s) {
|
||||
if (!this.originalTypes.containsKey(c)) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
this.originalTypes.put(c, list);
|
||||
} else {
|
||||
@@ -443,7 +443,7 @@ public class StaticEffect {
|
||||
* a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
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)) {
|
||||
this.originalTypes.put(c, list);
|
||||
} else {
|
||||
@@ -462,7 +462,7 @@ public class StaticEffect {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
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)) {
|
||||
returnList.addAll(this.originalTypes.get(c));
|
||||
}
|
||||
@@ -505,7 +505,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addType(final Card c, final String s) {
|
||||
if (!this.types.containsKey(c)) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
this.types.put(c, list);
|
||||
} else {
|
||||
@@ -523,7 +523,7 @@ public class StaticEffect {
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
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)) {
|
||||
returnList.addAll(this.types.get(c));
|
||||
}
|
||||
@@ -823,7 +823,7 @@ public class StaticEffect {
|
||||
if (colors.equals("ChosenColor")) {
|
||||
addColors = CardUtil.getShortColorsString(getSource().getChosenColors());
|
||||
} 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")) {
|
||||
addColors = CardUtil.getShortColorsString(getSource().getChosenColors());
|
||||
} else {
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(" & "))));
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(" & "))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@ public class AbilityUtils {
|
||||
val = CardFactoryUtil.doXMath(AbilityUtils.calculateAmount(card, l[0], ability), m, card);
|
||||
} else if (calcX[0].startsWith("PlayerCount")) {
|
||||
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("")) {
|
||||
players.addAll(game.getPlayers());
|
||||
val = CardFactoryUtil.playerXCount(players, calcX[1], card);
|
||||
@@ -577,7 +577,7 @@ public class AbilityUtils {
|
||||
|
||||
// Player attribute counting
|
||||
if (calcX[0].startsWith("TargetedPlayer")) {
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final List<Player> players = new ArrayList<>();
|
||||
final SpellAbility saTargeting = sa.getSATargetingPlayer();
|
||||
if (null != saTargeting) {
|
||||
Iterables.addAll(players, saTargeting.getTargets().getTargetPlayers());
|
||||
@@ -585,12 +585,12 @@ public class AbilityUtils {
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
if (calcX[0].startsWith("ThisTargetedPlayer")) {
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final List<Player> players = new ArrayList<>();
|
||||
Iterables.addAll(players, sa.getTargets().getTargetPlayers());
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
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
|
||||
SpellAbility loopSA = sa.getRootAbility();
|
||||
while (loopSA != null) {
|
||||
@@ -602,7 +602,7 @@ public class AbilityUtils {
|
||||
return CardFactoryUtil.objectXCount(objects, calcX[1], card) * multiplier;
|
||||
}
|
||||
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 List<SpellAbility> sas = AbilityUtils.getDefinedSpellAbilities(card, "Targeted", sa);
|
||||
|
||||
@@ -641,7 +641,7 @@ public class AbilityUtils {
|
||||
if (calcX[0].startsWith("TriggeredPlayers")) {
|
||||
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));
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
@@ -751,7 +751,7 @@ public class AbilityUtils {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
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;
|
||||
|
||||
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,
|
||||
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 Game game = card.getGame();
|
||||
|
||||
@@ -1690,7 +1690,7 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
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()) {
|
||||
final Spell newSA = (Spell) s.copy();
|
||||
newSA.setActivatingPlayer(controller);
|
||||
|
||||
@@ -186,7 +186,7 @@ public abstract class SpellAbilityEffect {
|
||||
|
||||
private static FCollection<Player> getPlayers(final boolean definedFirst, final String definedParam, final SpellAbility sa) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,17 +71,17 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
types.add(host.getChosenType());
|
||||
}
|
||||
|
||||
final List<String> keywords = new ArrayList<String>();
|
||||
final List<String> keywords = new ArrayList<>();
|
||||
if (sa.hasParam("Keywords")) {
|
||||
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")) {
|
||||
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")) {
|
||||
hiddenKeywords.addAll(Arrays.asList(sa.getParam("HiddenKeywords").split(" & ")));
|
||||
}
|
||||
@@ -101,29 +101,29 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
if (colors.equals("ChosenColor")) {
|
||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColors());
|
||||
} else {
|
||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(","))));
|
||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(","))));
|
||||
}
|
||||
}
|
||||
final String finalDesc = tmpDesc;
|
||||
|
||||
// abilities to add to the animated being
|
||||
final List<String> abilities = new ArrayList<String>();
|
||||
final List<String> abilities = new ArrayList<>();
|
||||
if (sa.hasParam("Abilities")) {
|
||||
abilities.addAll(Arrays.asList(sa.getParam("Abilities").split(",")));
|
||||
}
|
||||
// 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")) {
|
||||
replacements.addAll(Arrays.asList(sa.getParam("Replacements").split(",")));
|
||||
}
|
||||
// triggers to add to the animated being
|
||||
final List<String> triggers = new ArrayList<String>();
|
||||
final List<String> triggers = new ArrayList<>();
|
||||
if (sa.hasParam("Triggers")) {
|
||||
triggers.addAll(Arrays.asList(sa.getParam("Triggers").split(",")));
|
||||
}
|
||||
|
||||
// sVars to add to the animated being
|
||||
final List<String> sVars = new ArrayList<String>();
|
||||
final List<String> sVars = new ArrayList<>();
|
||||
if (sa.hasParam("sVars")) {
|
||||
sVars.addAll(Arrays.asList(sa.getParam("sVars").split(",")));
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
keywords, removeKeywords, hiddenKeywords, timestamp);
|
||||
|
||||
// give abilities
|
||||
final List<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> addedAbilities = new ArrayList<>();
|
||||
if (abilities.size() > 0) {
|
||||
for (final String s : abilities) {
|
||||
final String actualAbility = host.getSVar(s);
|
||||
@@ -165,7 +165,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// remove abilities
|
||||
final List<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> removedAbilities = new ArrayList<>();
|
||||
if (sa.hasParam("OverwriteAbilities") || removeAll || removeIntrinsic) {
|
||||
for (final SpellAbility ab : c.getSpellAbilities()) {
|
||||
if (ab.isAbility()) {
|
||||
@@ -178,7 +178,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
}
|
||||
// give replacement effects
|
||||
final List<ReplacementEffect> addedReplacements = new ArrayList<ReplacementEffect>();
|
||||
final List<ReplacementEffect> addedReplacements = new ArrayList<>();
|
||||
if (replacements.size() > 0) {
|
||||
for (final String s : replacements) {
|
||||
final String actualReplacement = host.getSVar(s);
|
||||
@@ -187,7 +187,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
}
|
||||
// Grant triggers
|
||||
final List<Trigger> addedTriggers = new ArrayList<Trigger>();
|
||||
final List<Trigger> addedTriggers = new ArrayList<>();
|
||||
if (triggers.size() > 0) {
|
||||
for (final String s : triggers) {
|
||||
final String actualTrigger = host.getSVar(s);
|
||||
@@ -197,7 +197,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
final FCollectionView<Trigger> triggersToRemove = c.getTriggers();
|
||||
for (final Trigger trigger : triggersToRemove) {
|
||||
@@ -210,7 +210,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
for (final StaticAbility stAb : c.getStaticAbilities()) {
|
||||
if (removeIntrinsic && !stAb.isIntrinsic()) {
|
||||
@@ -222,7 +222,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
for (final ReplacementEffect re : c.getReplacementEffects()) {
|
||||
if (removeIntrinsic && !re.isIntrinsic()) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
|
||||
Player p = source.getController();
|
||||
if (tgt.canTgtPlayer()) {
|
||||
final FCollection<Player> players = new FCollection<Player>();
|
||||
final FCollection<Player> players = new FCollection<>();
|
||||
|
||||
for (Player player : game.getPlayers()) {
|
||||
if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source, null)) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BalanceEffect extends SpellAbilityEffect {
|
||||
int min = Integer.MAX_VALUE;
|
||||
|
||||
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++) {
|
||||
// Find the minimum of each Valid per player
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BidLifeEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
final FCollection<Player> bidPlayers = new FCollection<Player>();
|
||||
final FCollection<Player> bidPlayers = new FCollection<>();
|
||||
final int startBidding;
|
||||
if (sa.hasParam("StartBidding")) {
|
||||
String start = sa.getParam("StartBidding");
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BlockEffect extends SpellAbilityEffect {
|
||||
final Game game = host.getGame();
|
||||
final Combat combat = game.getPhaseHandler().getCombat();
|
||||
|
||||
List<Card> attackers = new ArrayList<Card>();
|
||||
List<Card> attackers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
|
||||
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")) {
|
||||
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
|
||||
if (blocker.isCreature() && blocker.isInZone(ZoneType.Battlefield))
|
||||
@@ -90,14 +90,14 @@ public class BlockEffect extends SpellAbilityEffect {
|
||||
|
||||
// end standard pre-
|
||||
|
||||
List<String> attackers = new ArrayList<String>();
|
||||
List<String> attackers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
|
||||
attackers.add(attacker.toString());
|
||||
}
|
||||
}
|
||||
|
||||
List<String> blockers = new ArrayList<String>();
|
||||
List<String> blockers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedBlocker")) {
|
||||
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
|
||||
blockers.add(blocker.toString());
|
||||
|
||||
@@ -641,7 +641,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
|
||||
// for things like Gaea's Blessing
|
||||
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.
|
||||
if (sa.hasParam("TargetsWithDefinedController")) {
|
||||
pl.addAll(AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("TargetsWithDefinedController"), sa));
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ChooseColorEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
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")) {
|
||||
String[] restrictedChoices = sa.getParam("Choices").split(",");
|
||||
colorChoices = Arrays.asList(restrictedChoices);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ChooseDirectionEffect extends SpellAbilityEffect {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
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
|
||||
final String info = "Left (clockwise): " + left + "\r\nRight (anticlockwise):" + Lists.reverse(left);
|
||||
sa.getActivatingPlayer().getController().notifyOfValue(sa, source, info);
|
||||
|
||||
@@ -29,9 +29,9 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getHostCard();
|
||||
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")) {
|
||||
validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(",")));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
final boolean victory = clashWithOpponent(sa);
|
||||
|
||||
// Run triggers
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> runParams = new HashMap<>();
|
||||
runParams.put("Player", sa.getHostCard().getController());
|
||||
|
||||
if (victory) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
|
||||
Card object1 = null;
|
||||
Card object2 = null;
|
||||
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) {
|
||||
object1 = tgts.get(0);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
|
||||
Card object1 = null;
|
||||
Card object2 = null;
|
||||
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) {
|
||||
object1 = tgts.get(0);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
boolean mayChooseNewTargets = true;
|
||||
List<SpellAbility> copies = new ArrayList<SpellAbility>();
|
||||
List<SpellAbility> copies = new ArrayList<>();
|
||||
|
||||
if (sa.hasParam("CopyMultipleSpells")) {
|
||||
final int spellCount = Integer.parseInt(sa.getParam("CopyMultipleSpells"));
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
int numDam = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), 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())) {
|
||||
Card origin = null;
|
||||
@@ -96,12 +96,12 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
final Card c = (Card) o;
|
||||
if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {
|
||||
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("ShieldAmount", String.valueOf(numDam));
|
||||
if (sa.hasParam("ShieldEffectTarget")) {
|
||||
String effTgtString = "";
|
||||
List<GameObject> effTgts = new ArrayList<GameObject>();
|
||||
List<GameObject> effTgts = new ArrayList<>();
|
||||
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
||||
for (final Object effTgt : effTgts) {
|
||||
if (effTgt instanceof Card) {
|
||||
@@ -123,12 +123,12 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
final Player p = (Player) o;
|
||||
if (!targeted || p.canBeTargetedBy(sa)) {
|
||||
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("ShieldAmount", String.valueOf(numDam));
|
||||
if (sa.hasParam("ShieldEffectTarget")) {
|
||||
String effTgtString = "";
|
||||
List<GameObject> effTgts = new ArrayList<GameObject>();
|
||||
List<GameObject> effTgts = new ArrayList<>();
|
||||
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
||||
for (final Object effTgt : effTgts) {
|
||||
if (effTgt instanceof Card) {
|
||||
|
||||
@@ -264,7 +264,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
if ( p == chooser ) { // the digger can still see all the dug cards when choosing
|
||||
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 min = (anyNumber || optional) ? 0 : max;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class DiscardEffect extends SpellAbilityEffect {
|
||||
final Game game = source.getGame();
|
||||
//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),
|
||||
discarders;
|
||||
Player firstTarget = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DrainManaEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
List<Mana> drained = new ArrayList<Mana>();
|
||||
List<Mana> drained = new ArrayList<>();
|
||||
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LifeSetEffect extends SpellAbilityEffect {
|
||||
final boolean redistribute = sa.hasParam("Redistribute");
|
||||
final int lifeAmount = redistribute ? 20 : AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa);
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final List<Integer> lifetotals = new ArrayList<Integer>();
|
||||
final List<Integer> lifetotals = new ArrayList<>();
|
||||
|
||||
if (redistribute) {
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
|
||||
} else {
|
||||
cards = new ArrayList<Card>();
|
||||
cards = new ArrayList<>();
|
||||
cards.add(host);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
}
|
||||
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 String num = sa.hasParam("RandomNum") ? sa.getParam("RandomNum") : "1";
|
||||
int ncopied = AbilityUtils.calculateAmount(source, num, sa);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
||||
|
||||
final boolean isChoice = sa.getParam("Gains").contains("Choice");
|
||||
final List<String> choices = ProtectEffect.getProtectionList(sa);
|
||||
final List<String> gains = new ArrayList<String>();
|
||||
final List<String> gains = new ArrayList<>();
|
||||
if (isChoice) {
|
||||
Player choser = sa.getActivatingPlayer();
|
||||
final String choice = choser.getController().chooseProtectionType("Choose a protection", sa, choices);
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
|
||||
final boolean isChoice = sa.getParam("Gains").contains("Choice");
|
||||
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);
|
||||
|
||||
if (isChoice && !choices.isEmpty()) {
|
||||
@@ -128,7 +128,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
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();
|
||||
|
||||
if (sa.hasParam("Radiance") && (tgt != null)) {
|
||||
@@ -205,7 +205,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
|
||||
|
||||
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");
|
||||
if (gainStr.equals("Choice")) {
|
||||
|
||||
@@ -29,10 +29,10 @@ public class RestartGameEffect extends SpellAbilityEffect {
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
final Game game = activator.getGame();
|
||||
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
|
||||
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 leaveZone = ZoneType.smartValueOf(sa.hasParam("RestrictFromZone") ? sa.getParam("RestrictFromZone") : null);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class RunSVarAbilityEffect extends SpellAbilityEffect {
|
||||
if (sVars == null || cards.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<SpellAbility> validSA = new ArrayList<SpellAbility>();
|
||||
List<SpellAbility> validSA = new ArrayList<>();
|
||||
final boolean isTrigger = sa.hasParam("IsTrigger");
|
||||
for (final Card tgtC : cards) {
|
||||
if (!tgtC.hasSVar(sVars)) {
|
||||
|
||||
@@ -14,8 +14,8 @@ public class StoreMapEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
List<GameEntity> entity = new ArrayList<GameEntity>();
|
||||
List<Object> objects = new ArrayList<Object>();
|
||||
List<GameEntity> entity = new ArrayList<>();
|
||||
List<Object> objects = new ArrayList<>();
|
||||
|
||||
if (sa.hasParam("RememberEntity")) {
|
||||
entity.addAll(AbilityUtils.getDefinedPlayers(source, sa.getParam("RememberEntity"), sa));
|
||||
|
||||
@@ -56,11 +56,11 @@ public class CardState extends GameObject {
|
||||
private String baseLoyalty = "";
|
||||
private KeywordCollection intrinsicKeywords = new KeywordCollection();
|
||||
|
||||
private final FCollection<SpellAbility> nonManaAbilities = new FCollection<SpellAbility>();
|
||||
private final FCollection<SpellAbility> manaAbilities = new FCollection<SpellAbility>();
|
||||
private FCollection<Trigger> triggers = new FCollection<Trigger>();
|
||||
private FCollection<ReplacementEffect> replacementEffects = new FCollection<ReplacementEffect>();
|
||||
private FCollection<StaticAbility> staticAbilities = new FCollection<StaticAbility>();
|
||||
private final FCollection<SpellAbility> nonManaAbilities = new FCollection<>();
|
||||
private final FCollection<SpellAbility> manaAbilities = new FCollection<>();
|
||||
private FCollection<Trigger> triggers = new FCollection<>();
|
||||
private FCollection<ReplacementEffect> replacementEffects = new FCollection<>();
|
||||
private FCollection<StaticAbility> staticAbilities = new FCollection<>();
|
||||
private String imageKey = "";
|
||||
private Map<String, String> sVars = Maps.newTreeMap();
|
||||
|
||||
@@ -257,24 +257,24 @@ public class CardState extends GameObject {
|
||||
}
|
||||
|
||||
public final FCollectionView<SpellAbility> getSpellAbilities() {
|
||||
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(manaAbilities);
|
||||
FCollection<SpellAbility> newCol = new FCollection<>(manaAbilities);
|
||||
newCol.addAll(nonManaAbilities);
|
||||
card.updateSpellAbilities(newCol, this, null);
|
||||
return newCol;
|
||||
}
|
||||
public final FCollectionView<SpellAbility> getManaAbilities() {
|
||||
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(manaAbilities);
|
||||
FCollection<SpellAbility> newCol = new FCollection<>(manaAbilities);
|
||||
card.updateSpellAbilities(newCol, this, true);
|
||||
return newCol;
|
||||
}
|
||||
public final FCollectionView<SpellAbility> getNonManaAbilities() {
|
||||
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(nonManaAbilities);
|
||||
FCollection<SpellAbility> newCol = new FCollection<>(nonManaAbilities);
|
||||
card.updateSpellAbilities(newCol, this, false);
|
||||
return newCol;
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -386,7 +386,7 @@ public class CardState extends GameObject {
|
||||
return staticAbilities.remove(stab);
|
||||
}
|
||||
public final void setStaticAbilities(final Iterable<StaticAbility> staticAbilities0) {
|
||||
staticAbilities = new FCollection<StaticAbility>(staticAbilities0);
|
||||
staticAbilities = new FCollection<>(staticAbilities0);
|
||||
}
|
||||
public final void clearStaticAbilities() {
|
||||
staticAbilities.clear();
|
||||
|
||||
@@ -423,7 +423,7 @@ public final class CardUtil {
|
||||
colors.add(MagicColor.Constant.COLORLESS);
|
||||
}
|
||||
} else if (reflectProperty.equals("Produce")) {
|
||||
final FCollection<SpellAbility> abilities = new FCollection<SpellAbility>();
|
||||
final FCollection<SpellAbility> abilities = new FCollection<>();
|
||||
for (final Card c : cards) {
|
||||
abilities.addAll(c.getManaAbilities());
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user