package mage.client.components; import mage.MageObject; import mage.cards.Card; import mage.cards.decks.Deck; import mage.client.util.GUISizeHelper; import org.apache.log4j.Logger; import java.awt.*; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.util.*; import java.util.stream.Stream; /** * Inject bracket level inside validation panel * See more details at wiki *
* Support:
* - [x] game changers
* - [x] infinite combos
* - [x] mass land destruction
* - [x] extra turns
* - [x] tutors
* Features:
* - [x] find possible bracket level of the deck
* - [x] find affected cards by checking group
* - [x] can auto-generate infinite combos list, see verify test downloadAndPrepareCommanderBracketsData
* - [ ] TODO: tests
* - [ ] TODO: table - players brackets level disclose settings
* - [ ] TODO: deck - improve gui to show more levels
* - [ ] TODO: generate - convert card name to xmage format and assert on bad names (ascii only)
*
* @author JayDi85
*/
public class BracketLegalityLabel extends LegalityLabel {
private static final Logger logger = Logger.getLogger(BracketLegalityLabel.class);
private static final String GROUP_GAME_CHANGES = "Game Changers";
private static final String GROUP_INFINITE_COMBOS = "Infinite Combos";
private static final String GROUP_MASS_LAND_DESTRUCTION = "Mass Land Destruction";
private static final String GROUP_EXTRA_TURN = "Extra Turns";
private static final String GROUP_TUTORS = "Tutors";
private static final String RESOURCE_INFINITE_COMBOS = "brackets/infinite-combos.txt";
private final BracketLevel level;
private final List Deck is GOOD for " + this.level + " Deck is BAD for " + this.level + " (click here to select all bad cards)
");
showInfo.add("
");
showInfo.add("" + group + ": " + cards.size() + "");
if (!cards.isEmpty()) {
showInfo.add("");
cards.forEach(s -> showInfo.add(String.format("
");
}
});
String showText = "" + String.join("\n", showInfo) + "";
showState(showColor, showText, false);
}
private void collectAll(Deck deck) {
collectGameChangers(deck);
collectInfiniteCombos(deck);
collectMassLandDestruction(deck);
collectExtraTurn(deck);
collectTutors(deck);
}
private void collectGameChangers(Deck deck) {
this.foundGameChangers.clear();
if (fullGameChanges.isEmpty()) {
// https://mtg.wiki/page/Game_Changers
// TODO: share list with AbstractCommander and edh power level
fullGameChanges.addAll(Arrays.asList(
"Ad Nauseam",
"Ancient Tomb",
"Aura Shards",
"Bolas's Citadel",
"Braids, Cabal Minion",
"Demonic Tutor",
"Drannith Magistrate",
"Chrome Mox",
"Coalition Victory",
"Consecrated Sphinx",
"Crop Rotation",
"Cyclonic Rift",
"Deflecting Swat",
"Enlightened Tutor",
"Expropriate",
"Field of the Dead",
"Fierce Guardianship",
"Food Chain",
"Force of Will",
"Gaea's Cradle",
"Gamble",
"Gifts Ungiven",
"Glacial Chasm",
"Grand Arbiter Augustin IV",
"Grim Monolith",
"Humility",
"Imperial Seal",
"Intuition",
"Jeska's Will",
"Jin-Gitaxias, Core Augur",
"Kinnan, Bonder Prodigy",
"Lion's Eye Diamond",
"Mana Vault",
"Mishra's Workshop",
"Mox Diamond",
"Mystical Tutor",
"Narset, Parter of Veils",
"Natural Order",
"Necropotence",
"Notion Thief",
"Rhystic Study",
"Opposition Agent",
"Orcish Bowmasters",
"Panoptic Mirror",
"Seedborn Muse",
"Serra's Sanctum",
"Smothering Tithe",
"Survival of the Fittest",
"Sway of the Stars",
"Teferi's Protection",
"Tergrid, God of Fright",
"Thassa's Oracle",
"The One Ring",
"The Tabernacle at Pendrell Vale",
"Underworld Breach",
"Urza, Lord High Artificer",
"Vampiric Tutor",
"Vorinclex, Voice of Hunger",
"Yuriko, the Tiger's Shadow",
"Winota, Joiner of Forces",
"Worldly Tutor"
));
}
Stream.concat(deck.getCards().stream(), deck.getSideboard().stream())
.map(MageObject::getName)
.filter(fullGameChanges::contains)
.sorted()
.forEach(this.foundGameChangers::add);
}
private void collectInfiniteCombos(Deck deck) {
this.foundInfiniteCombos.clear();
if (this.fullInfiniteCombos.isEmpty()) {
InputStream in = BracketLegalityLabel.class.getClassLoader().getResourceAsStream(RESOURCE_INFINITE_COMBOS);
if (in == null) {
throw new RuntimeException("Commander brackets: can't load infinite combos list");
}
try (InputStreamReader input = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(input)) {
String line = reader.readLine();
while (line != null) {
try {
line = line.trim();
if (line.startsWith("#")) {
continue;
}
List