diff --git a/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java b/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java index d38eaa1b0b7..67429dd5e8c 100644 --- a/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java +++ b/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java @@ -27,14 +27,17 @@ */ package mage.client.deck.generator; -import java.util.*; - +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; import mage.cards.Card; import mage.cards.decks.Deck; import mage.cards.repository.CardCriteria; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; -import mage.cards.repository.ExpansionInfo; import mage.cards.repository.ExpansionRepository; import mage.client.dialog.PreferencesDialog; import mage.client.util.sets.ConstructedFormats; @@ -43,7 +46,6 @@ import mage.constants.ColoredManaSymbol; import mage.constants.Rarity; import mage.util.TournamentUtil; - /** * Generates random card pool and builds a deck. * @@ -58,6 +60,7 @@ public class DeckGenerator { /** * Builds a deck out of the selected block/set/format. + * * @return a path to the generated deck. */ public static String generateDeck() { @@ -71,7 +74,6 @@ public class DeckGenerator { return PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, null); } - protected static Deck buildDeck() { String selectedColors = genDialog.getSelectedColors(); @@ -101,6 +103,7 @@ public class DeckGenerator { /** * If the user has selected random colors, pick them randomly for the user. + * * @param selectedColors a string of the colors selected. * @return a String representation of the new colors chosen. */ @@ -131,9 +134,10 @@ public class DeckGenerator { } /** - * Generates all the cards to use in the deck. - * Adds creatures, non-creatures, lands (including non-basic). - * Fixes the deck, adjusting for size and color of the cards retrieved. + * Generates all the cards to use in the deck. Adds creatures, + * non-creatures, lands (including non-basic). Fixes the deck, adjusting for + * size and color of the cards retrieved. + * * @param deckSize how big the deck is to generate. * @param allowedColors which colors are allowed in the deck. * @param setsToUse which sets to use to retrieve cards for this deck. @@ -149,16 +153,18 @@ public class DeckGenerator { creatureCriteria.setCodes(sets); creatureCriteria.notTypes(CardType.LAND); creatureCriteria.types(CardType.CREATURE); - if (!(genDialog.useArtifacts())) + if (!(genDialog.useArtifacts())) { creatureCriteria.notTypes(CardType.ARTIFACT); + } // Non-creatures (sorcery, instant, enchantment, artifact etc.) final CardCriteria nonCreatureCriteria = new CardCriteria(); nonCreatureCriteria.setCodes(sets); nonCreatureCriteria.notTypes(CardType.LAND); nonCreatureCriteria.notTypes(CardType.CREATURE); - if (!(genDialog.useArtifacts())) + if (!(genDialog.useArtifacts())) { nonCreatureCriteria.notTypes(CardType.ARTIFACT); + } // Non-basic land final CardCriteria nonBasicLandCriteria = new CardCriteria(); @@ -177,15 +183,18 @@ public class DeckGenerator { return genPool.getDeck(); } - /** - * Generates all spells for the deck. - * Each card is retrieved from the database and checked against the converted mana cost (CMC) needed for the current card pool. - * If a card's CMC matches the CMC range required by the pool, it is added to the deck. - * This ensures that the majority of cards fit a fixed mana curve for the deck, and it is playable. - * Creatures and non-creatures are retrieved separately to ensure the deck contains a reasonable mix of both. + * Generates all spells for the deck. Each card is retrieved from the + * database and checked against the converted mana cost (CMC) needed for the + * current card pool. If a card's CMC matches the CMC range required by the + * pool, it is added to the deck. This ensures that the majority of cards + * fit a fixed mana curve for the deck, and it is playable. Creatures and + * non-creatures are retrieved separately to ensure the deck contains a + * reasonable mix of both. + * * @param criteria the criteria to search for in the database. - * @param spellCount the number of spells that match the criteria needed in the deck. + * @param spellCount the number of spells that match the criteria needed in + * the deck. */ private static void generateSpells(CardCriteria criteria, int spellCount) { List cardPool = CardRepository.instance.findCards(criteria); @@ -212,8 +221,9 @@ public class DeckGenerator { } else { if (reservesAdded < (genPool.getDeckSize() / 2)) { added = genPool.tryAddReserve(card, cardCMC); - if(added) + if (added) { reservesAdded++; + } } } } @@ -231,11 +241,13 @@ public class DeckGenerator { } /** - * Generates all the lands for the deck. - * Generates non-basic if selected by the user and if the deck isn't monocolored. - * Will fetch non-basic lands if required and then fill up the remaining space with basic lands. - * Basic lands are adjusted according to the mana symbols seen in the cards used in this deck. - * Usually the lands will be well balanced relative to the color of cards. + * Generates all the lands for the deck. Generates non-basic if selected by + * the user and if the deck isn't monocolored. Will fetch non-basic lands if + * required and then fill up the remaining space with basic lands. Basic + * lands are adjusted according to the mana symbols seen in the cards used + * in this deck. Usually the lands will be well balanced relative to the + * color of cards. + * * @param criteria the criteria of the lands to search for in the database. * @param landsCount the amount of lands required for this deck. * @param basicLands information about the basic lands from the sets used. @@ -281,6 +293,7 @@ public class DeckGenerator { /** * Returns a map of colored mana symbol to basic land cards of that color. + * * @param setsToUse which sets to retrieve basic lands from. * @return a map of color to basic lands. */ @@ -295,7 +308,7 @@ public class DeckGenerator { Map> basicLandMap = new HashMap<>(); - for(ColoredManaSymbol c: ColoredManaSymbol.values()) { + for (ColoredManaSymbol c : ColoredManaSymbol.values()) { String landName = DeckGeneratorPool.getBasicLandName(c.toString()); criteria.rarities(Rarity.LAND).name(landName); List cards = CardRepository.instance.findCards(criteria); @@ -305,11 +318,14 @@ public class DeckGenerator { } /** - * Once any non-basic lands are added, add basic lands until the deck is filled. + * Once any non-basic lands are added, add basic lands until the deck is + * filled. + * * @param landsNeeded how many remaining lands are needed. * @param percentage the percentage needed for each color in the final deck. * @param count how many of each color can be produced by non-basic lands. - * @param basicLands list of information about basic lands from the database. + * @param basicLands list of information about basic lands from the + * database. */ private static void addBasicLands(int landsNeeded, Map percentage, Map count, Map> basicLands) { int colorTotal = 0; @@ -335,8 +351,9 @@ public class DeckGenerator { int currentCount = count.get(color.toString()); double thisPercentage = 0.0; // Calculate the percentage of lands so far that produce this color - if (currentCount > 0) + if (currentCount > 0) { thisPercentage = (currentCount / (double) colorTotal) * 100.0; + } // Check if the color is the most "needed" (highest percentage) we have seen so far if (neededPercentage - thisPercentage > minPercentage) { // Put this color land forward to be added @@ -344,7 +361,7 @@ public class DeckGenerator { minPercentage = (neededPercentage - thisPercentage); } } - if(colorToAdd != null) { + if (colorToAdd != null) { genPool.addCard(getBasicLand(colorToAdd, basicLands)); count.put(colorToAdd.toString(), count.get(colorToAdd.toString()) + 1); colorTotal++; @@ -355,8 +372,10 @@ public class DeckGenerator { /** * Return a random basic land of the chosen color. + * * @param color the color the basic land should produce. - * @param basicLands list of information about basic lands from the database. + * @param basicLands list of information about basic lands from the + * database. * @return a single basic land that produces the color needed. */ private static Card getBasicLand(ColoredManaSymbol color, Map> basicLands) { @@ -366,5 +385,4 @@ public class DeckGenerator { return basicLandsInfo.get(random.nextInt(basicLandsInfo.size() - 1)).getMockCard().copy(); } - } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/HistoricalStandard.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/HistoricalType2.java similarity index 96% rename from Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/HistoricalStandard.java rename to Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/HistoricalType2.java index 9f15bf867dc..08e2025ddb2 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/HistoricalStandard.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/HistoricalType2.java @@ -23,7 +23,7 @@ import mage.constants.SetType; * * @author Marthinwurer (at gmail.com) */ -public class HistoricalStandard extends Constructed { +public class HistoricalType2 extends Constructed { /* * This array stores the set codes of each standard up to @@ -34,9 +34,9 @@ public class HistoricalStandard extends Constructed { {"DRK", "FEM", "4ED"}, // 2nd standard: 4th, Fallen Empires, Ice Age, Chronicles, Homelands, // Alliances, and Mirage. - {"FEM", "4ED", "ICE", "HML", "ALL", "MIR"}, + {"FEM", "4ED", "ICE", "CHR", "HML", "ALL", "MIR"}, // 3rd standard: 4th, Chronicles, Alliances, Mirage, Visions. - {"4ED", "ALL", "MIR", "VIS"}, + {"4ED", "CHR", "ALL", "MIR", "VIS"}, // 4th Standard: Ice Age, Homelands, Alliances, Mirage, Visions, 5th, // and Weatherlight. {"ICE", "HML", "ALL", "MIR", "VIS", "5ED", "WTH"}, @@ -84,15 +84,17 @@ public class HistoricalStandard extends Constructed { * Constructor. Don't need to mess with any of the sets yet; that will be * done in the overridden validate function. */ - public HistoricalStandard() { - super("Constructed - Historical Standard"); + public HistoricalType2() { + super("Constructed - Historical Type 2"); // banned cards banned.add("Balance"); + banned.add("Earthcraft"); banned.add("Memory Jar"); banned.add("Mind Over Matter"); banned.add("Mind Twist"); banned.add("Skullclamp"); + banned.add("Time Spiral"); banned.add("Tolarian Academy"); banned.add("Yawgmoth's Bargain"); } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/SuperStandard.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/SuperType2.java similarity index 97% rename from Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/SuperStandard.java rename to Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/SuperType2.java index de7ff76aae7..70780d45796 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/SuperStandard.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/SuperType2.java @@ -18,13 +18,13 @@ import mage.constants.SetType; * * This class was originally made to work with the historical standard ruleset. * Data taken from http://thattournament.website/historic-tournament.php (site - * changed, originally thtp://mtgt.nfshost.com/historic-tournament.php) + * changed, originally http://mtgt.nfshost.com/historic-tournament.php) * * If there are any questions or corrections, feel free to contact me. * * @author Marthinwurer (at gmail.com) */ -public class SuperStandard extends Constructed { +public class SuperType2 extends Constructed { /* * This array stores the set codes of each standard up to @@ -60,8 +60,8 @@ public class SuperStandard extends Constructed { * Constructor. Don't need to mess with any of the sets yet; that will be * done in the overridden validate function. */ - public SuperStandard() { - super("Constructed - Super Standard"); + public SuperType2() { + super("Constructed - Super Type 2"); banned.add("Ancient Den"); banned.add("Disciple of the Vault"); diff --git a/Mage.Server/config/config.xml b/Mage.Server/config/config.xml index eb2c57ef452..f043debc6a5 100644 --- a/Mage.Server/config/config.xml +++ b/Mage.Server/config/config.xml @@ -90,8 +90,8 @@ - - + + diff --git a/Mage.Server/release/config/config.xml b/Mage.Server/release/config/config.xml index 77ff19bb4bf..b4d0356c3fc 100644 --- a/Mage.Server/release/config/config.xml +++ b/Mage.Server/release/config/config.xml @@ -69,8 +69,8 @@ - - + +