Search in sources :

Example 11 with FilterMana

use of mage.filter.FilterMana in project mage by magefree.

the class CommanderIdentityManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl();
        choice.setMessage("Pick a mana color");
        for (UUID commanderId : game.getCommandersIds(controller, CommanderCardType.COMMANDER_OR_OATHBREAKER, false)) {
            Card commander = game.getCard(commanderId);
            if (commander != null) {
                FilterMana commanderMana = commander.getColorIdentity();
                if (commanderMana.isWhite()) {
                    choice.getChoices().add("White");
                }
                if (commanderMana.isBlue()) {
                    choice.getChoices().add("Blue");
                }
                if (commanderMana.isBlack()) {
                    choice.getChoices().add("Black");
                }
                if (commanderMana.isRed()) {
                    choice.getChoices().add("Red");
                }
                if (commanderMana.isGreen()) {
                    choice.getChoices().add("Green");
                }
            }
        }
        if (!choice.getChoices().isEmpty()) {
            if (choice.getChoices().size() == 1) {
                choice.setChoice(choice.getChoices().iterator().next());
            } else {
                if (!controller.choose(outcome, choice, game)) {
                    return mana;
                }
            }
            switch(choice.getChoice()) {
                case "Black":
                    mana.setBlack(1);
                    break;
                case "Blue":
                    mana.setBlue(1);
                    break;
                case "Red":
                    mana.setRed(1);
                    break;
                case "Green":
                    mana.setGreen(1);
                    break;
                case "White":
                    mana.setWhite(1);
                    break;
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) FilterMana(mage.filter.FilterMana) Choice(mage.choices.Choice) FilterMana(mage.filter.FilterMana) ChoiceImpl(mage.choices.ChoiceImpl) UUID(java.util.UUID) Card(mage.cards.Card)

Example 12 with FilterMana

use of mage.filter.FilterMana in project mage by magefree.

the class ManaTest method shouldReturnCount.

@Test
public void shouldReturnCount() {
    // given
    Mana mana = new Mana(4, 3, 5, 1, 2, 6, 7, 0);
    FilterMana filter = new FilterMana();
    filter.setBlack(true);
    // when
    int totalCount = mana.count();
    int coloredCount = mana.countColored();
    int filteredMana = mana.count(filter);
    // then
    assertEquals(28, totalCount);
    assertEquals(22, coloredCount);
    assertEquals(5, filteredMana);
}
Also used : FilterMana(mage.filter.FilterMana) FilterMana(mage.filter.FilterMana) Test(org.junit.Test)

Example 13 with FilterMana

use of mage.filter.FilterMana in project mage by magefree.

the class ManaPool method getMana.

public Mana getMana(FilterMana filter) {
    if (filter == null) {
        return getMana();
    }
    Mana test = getMana();
    Mana m = new Mana();
    if (filter.isBlack()) {
        m.setBlack(test.getBlack());
    }
    if (filter.isBlue()) {
        m.setBlue(test.getBlue());
    }
    if (filter.isGreen()) {
        m.setGreen(test.getGreen());
    }
    if (filter.isRed()) {
        m.setRed(test.getRed());
    }
    if (filter.isWhite()) {
        m.setWhite(test.getWhite());
    }
    if (filter.isColorless()) {
        m.setColorless(test.getColorless());
    }
    if (filter.isGeneric()) {
        m.setGeneric(test.getGeneric());
    }
    return m;
}
Also used : ConditionalMana(mage.ConditionalMana) Mana(mage.Mana) FilterMana(mage.filter.FilterMana)

Example 14 with FilterMana

use of mage.filter.FilterMana in project mage by magefree.

the class Brawl method validate.

@Override
public boolean validate(Deck deck) {
    boolean valid = true;
    errorsList.clear();
    Card brawler = null;
    Card companion = null;
    FilterMana colorIdentity = new FilterMana();
    if (deck.getSideboard().size() == 1) {
        for (Card card : deck.getSideboard()) {
            brawler = card;
        }
    } else if (deck.getSideboard().size() == 2) {
        Iterator<Card> iter = deck.getSideboard().iterator();
        Card card1 = iter.next();
        Card card2 = iter.next();
        if (card1.getAbilities().stream().anyMatch(ability -> ability instanceof CompanionAbility)) {
            companion = card1;
            brawler = card2;
        } else if (card2.getAbilities().stream().anyMatch(ability -> ability instanceof CompanionAbility)) {
            companion = card2;
            brawler = card1;
        } else {
            addError(DeckValidatorErrorType.PRIMARY, "Brawl", "Sideboard must contain only the brawler and up to 1 companion");
            valid = false;
        }
    } else {
        addError(DeckValidatorErrorType.PRIMARY, "Brawl", "Sideboard must contain only the brawler and up to 1 companion");
        valid = false;
    }
    if (brawler != null) {
        ManaUtil.collectColorIdentity(colorIdentity, brawler.getColorIdentity());
        if (bannedCommander.contains(brawler.getName())) {
            addError(DeckValidatorErrorType.PRIMARY, brawler.getName(), "Brawler banned (" + brawler.getName() + ')', true);
            valid = false;
        }
        if (!((brawler.hasCardTypeForDeckbuilding(CardType.CREATURE) && brawler.isLegendary()) || brawler.hasCardTypeForDeckbuilding(CardType.PLANESWALKER) || brawler.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
            addError(DeckValidatorErrorType.PRIMARY, brawler.getName(), "Brawler Invalid (" + brawler.getName() + ')', true);
            valid = false;
        }
    }
    if (companion != null && deck.getCards().size() + deck.getSideboard().size() != getDeckMinSize() + 1) {
        addError(DeckValidatorErrorType.DECK_SIZE, "Deck", "Must contain " + (getDeckMinSize() + 1) + " cards (companion doesn't count in deck size requirement): has " + (deck.getCards().size() + deck.getSideboard().size()) + " cards");
        valid = false;
    } else if (companion == null && deck.getCards().size() + deck.getSideboard().size() != getDeckMinSize()) {
        addError(DeckValidatorErrorType.DECK_SIZE, "Deck", "Must contain " + getDeckMinSize() + " cards: has " + (deck.getCards().size() + deck.getSideboard().size()) + " cards");
        valid = false;
    }
    Map<String, Integer> counts = new HashMap<>();
    countCards(counts, deck.getCards());
    countCards(counts, deck.getSideboard());
    valid = checkCounts(1, counts) && valid;
    for (String bannedCard : banned) {
        if (counts.containsKey(bannedCard)) {
            addError(DeckValidatorErrorType.BANNED, bannedCard, "Banned", true);
            valid = false;
        }
    }
    Set<String> basicsInDeck = new HashSet<>();
    if (colorIdentity.isColorless()) {
        for (Card card : deck.getCards()) {
            if (basicLandNames.contains(card.getName())) {
                basicsInDeck.add(card.getName());
            }
        }
    }
    for (Card card : deck.getCards()) {
        if (!ManaUtil.isColorIdentityCompatible(colorIdentity, card.getColorIdentity()) && !(colorIdentity.isColorless() && basicsInDeck.size() == 1 && basicsInDeck.contains(card.getName()))) {
            addError(DeckValidatorErrorType.OTHER, card.getName(), "Invalid color (" + colorIdentity.toString() + ')', true);
            valid = false;
        }
    }
    for (Card card : deck.getSideboard()) {
        if (!ManaUtil.isColorIdentityCompatible(colorIdentity, card.getColorIdentity()) && !(colorIdentity.isColorless() && basicsInDeck.size() == 1 && basicsInDeck.contains(card.getName()))) {
            addError(DeckValidatorErrorType.OTHER, card.getName(), "Invalid color (" + colorIdentity.toString() + ')', true);
            valid = false;
        }
    }
    for (Card card : deck.getCards()) {
        if (!isSetAllowed(card.getExpansionSetCode())) {
            if (!legalSets(card)) {
                addError(DeckValidatorErrorType.WRONG_SET, card.getName(), "Not allowed Set: " + card.getExpansionSetCode(), true);
                valid = false;
            }
        }
    }
    for (Card card : deck.getSideboard()) {
        if (!isSetAllowed(card.getExpansionSetCode())) {
            if (!legalSets(card)) {
                addError(DeckValidatorErrorType.WRONG_SET, card.getName(), "Not allowed Set: " + card.getExpansionSetCode(), true);
                valid = false;
            }
        }
    }
    // Check for companion legality
    if (companion != null) {
        Set<Card> cards = new HashSet<>(deck.getCards());
        cards.add(brawler);
        for (Ability ability : companion.getAbilities()) {
            if (ability instanceof CompanionAbility) {
                CompanionAbility companionAbility = (CompanionAbility) ability;
                if (!companionAbility.isLegal(cards, getDeckMinSize())) {
                    addError(DeckValidatorErrorType.PRIMARY, companion.getName(), "Brawl Companion Invalid", true);
                    valid = false;
                }
                break;
            }
        }
    }
    return valid;
}
Also used : java.util(java.util) DeckValidatorErrorType(mage.cards.decks.DeckValidatorErrorType) CardType(mage.constants.CardType) CompanionAbility(mage.abilities.keyword.CompanionAbility) Deck(mage.cards.decks.Deck) CanBeYourCommanderAbility(mage.abilities.common.CanBeYourCommanderAbility) Card(mage.cards.Card) Constructed(mage.cards.decks.Constructed) ManaUtil(mage.util.ManaUtil) Ability(mage.abilities.Ability) FilterMana(mage.filter.FilterMana) CompanionAbility(mage.abilities.keyword.CompanionAbility) CanBeYourCommanderAbility(mage.abilities.common.CanBeYourCommanderAbility) Ability(mage.abilities.Ability) FilterMana(mage.filter.FilterMana) CompanionAbility(mage.abilities.keyword.CompanionAbility) Card(mage.cards.Card)

Example 15 with FilterMana

use of mage.filter.FilterMana in project mage by magefree.

the class Commander method getEdhPowerLevel.

@Override
public int getEdhPowerLevel(Deck deck) {
    if (deck == null) {
        return 0;
    }
    int edhPowerLevel = 0;
    int commanderColors = 0;
    int numberInfinitePieces = 0;
    for (Card card : deck.getCards()) {
        int thisMaxPower = 0;
        // Examine rules to work out most egregious functions in edh
        boolean anyNumberOfTarget = false;
        boolean annihilator = false;
        boolean buyback = false;
        boolean cascade = false;
        boolean cantBe = false;
        boolean cantUntap = false;
        boolean copy = false;
        boolean costLessEach = false;
        boolean createToken = false;
        boolean dredge = false;
        boolean exile = false;
        boolean exileAll = false;
        boolean counter = false;
        boolean destroy = false;
        boolean destroyAll = false;
        boolean each = false;
        boolean exalted = false;
        boolean doesntUntap = false;
        boolean drawCards = false;
        boolean evoke = false;
        boolean extraTurns = false;
        boolean flash = false;
        boolean flashback = false;
        boolean flicker = false;
        boolean gainControl = false;
        boolean hexproof = false;
        boolean infect = false;
        boolean lifeTotalBecomes = false;
        boolean mayCastForFree = false;
        boolean menace = false;
        boolean miracle = false;
        boolean overload = false;
        boolean persist = false;
        boolean preventDamage = false;
        boolean proliferate = false;
        boolean protection = false;
        boolean putUnderYourControl = false;
        boolean retrace = false;
        boolean returnFromYourGY = false;
        boolean sacrifice = false;
        boolean shroud = false;
        boolean skip = false;
        boolean sliver = false;
        boolean storm = false;
        boolean trample = false;
        boolean tutor = false;
        boolean tutorBasic = false;
        boolean twiceAs = false;
        boolean unblockable = false;
        boolean undying = false;
        boolean untapTarget = false;
        boolean wheneverEnters = false;
        boolean whenCounterThatSpell = false;
        boolean xCost = false;
        boolean youControlTarget = false;
        boolean yourOpponentsControl = false;
        boolean whenYouCast = false;
        for (String str : card.getRules()) {
            String s = str.toLowerCase(Locale.ENGLISH);
            annihilator |= s.contains("annihilator");
            anyNumberOfTarget |= s.contains("any number");
            buyback |= s.contains("buyback");
            cantUntap |= s.contains("can't untap") || s.contains("don't untap");
            cantBe |= s.contains("can't be");
            cascade |= s.contains("cascade");
            copy |= s.contains("copy");
            costLessEach |= s.contains("cost") || s.contains("less") || s.contains("each");
            counter |= s.contains("counter") && s.contains("target");
            createToken |= s.contains("create") && s.contains("token");
            destroy |= s.contains("destroy");
            destroyAll |= s.contains("destroy all");
            doesntUntap |= s.contains("doesn't untap");
            doesntUntap |= s.contains("don't untap");
            drawCards |= s.contains("draw cards");
            dredge |= s.contains("dredge");
            each |= s.contains("each");
            evoke |= s.contains("evoke");
            exalted |= s.contains("exalted");
            exile |= s.contains("exile");
            exileAll |= s.contains("exile") && s.contains(" all ");
            extraTurns |= s.contains("extra turn");
            flicker |= s.contains("exile") && s.contains("return") && s.contains("to the battlefield under");
            flash |= s.contains("flash");
            flashback |= s.contains("flashback");
            gainControl |= s.contains("gain control");
            hexproof |= s.contains("hexproof");
            infect |= s.contains("infect");
            lifeTotalBecomes |= s.contains("life total becomes");
            mayCastForFree |= s.contains("may cast") && s.contains("without paying");
            menace |= s.contains("menace");
            miracle |= s.contains("miracle");
            overload |= s.contains("overload");
            persist |= s.contains("persist");
            preventDamage |= s.contains("prevent") && s.contains("all") && s.contains("damage");
            proliferate |= s.contains("proliferate");
            protection |= s.contains("protection");
            putUnderYourControl |= s.contains("put") && s.contains("under your control");
            retrace |= s.contains("retrace");
            returnFromYourGY |= s.contains("return") && s.contains("from your graveyard");
            sacrifice |= s.contains("sacrifice");
            shroud |= s.contains("shroud");
            skip |= s.contains("skip");
            sliver |= s.contains("sliver");
            storm |= s.contains("storm");
            trample |= s.contains("trample");
            tutor |= s.contains("search your library") && !s.contains("basic land");
            tutorBasic |= s.contains("search your library") && s.contains("basic land");
            twiceAs |= s.contains("twice that many") || s.contains("twice as much");
            unblockable |= s.contains("can't be blocked");
            undying |= s.contains("undying");
            untapTarget |= s.contains("untap target");
            whenCounterThatSpell |= s.contains("when") && s.contains("counter that spell");
            wheneverEnters |= s.contains("when") && s.contains("another") && s.contains("enters");
            youControlTarget |= s.contains("you control target");
            yourOpponentsControl |= s.contains("your opponents control");
            whenYouCast |= s.contains("when you cast") || s.contains("whenever you cast");
        }
        for (String s : card.getManaCostSymbols()) {
            if (s.contains("X")) {
                xCost = true;
            }
        }
        for (Ability a : card.getAbilities()) {
            for (String s : a.getManaCostSymbols()) {
                if (s.contains("X")) {
                    xCost = true;
                }
            }
        }
        if (extraTurns) {
            thisMaxPower = Math.max(thisMaxPower, 7);
        }
        if (buyback) {
            thisMaxPower = Math.max(thisMaxPower, 6);
        }
        if (tutor) {
            thisMaxPower = Math.max(thisMaxPower, 6);
        }
        if (annihilator) {
            thisMaxPower = Math.max(thisMaxPower, 5);
        }
        if (cantUntap) {
            thisMaxPower = Math.max(thisMaxPower, 5);
        }
        if (costLessEach) {
            thisMaxPower = Math.max(thisMaxPower, 5);
        }
        if (infect) {
            thisMaxPower = Math.max(thisMaxPower, 5);
        }
        if (overload) {
            thisMaxPower = Math.max(thisMaxPower, 5);
        }
        if (twiceAs) {
            thisMaxPower = Math.max(thisMaxPower, 5);
        }
        if (cascade) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (doesntUntap) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (each) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (exileAll) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (flash) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (flashback) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (flicker) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (gainControl) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (lifeTotalBecomes) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (mayCastForFree) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (preventDamage) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (proliferate) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (protection) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (putUnderYourControl) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (returnFromYourGY) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (sacrifice) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (skip) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (storm) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (unblockable) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (whenCounterThatSpell) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (wheneverEnters) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (xCost) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (youControlTarget) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (yourOpponentsControl) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (whenYouCast) {
            thisMaxPower = Math.max(thisMaxPower, 4);
        }
        if (anyNumberOfTarget) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (createToken) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (destroyAll) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (dredge) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (hexproof) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (shroud) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (undying) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (persist) {
            thisMaxPower = Math.max(thisMaxPower, 3);
        }
        if (cantBe) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (evoke) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (exile) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (menace) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (miracle) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (sliver) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (untapTarget) {
            thisMaxPower = Math.max(thisMaxPower, 2);
        }
        if (copy) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (counter) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (destroy) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (drawCards) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (exalted) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (retrace) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (trample) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (tutorBasic) {
            thisMaxPower = Math.max(thisMaxPower, 1);
        }
        if (card.isPlaneswalker()) {
            thisMaxPower = Math.max(thisMaxPower, 6);
        }
        String cn = card.getName().toLowerCase(Locale.ENGLISH);
        if (cn.equals("ancient tomb") || cn.equals("anafenza, the foremost") || cn.equals("arcum dagsson") || cn.equals("armageddon") || cn.equals("aura shards") || cn.equals("azami, lady of scrolls") || cn.equals("azusa, lost but seeking") || cn.equals("back to basics") || cn.equals("bane of progress") || cn.equals("basalt monolith") || cn.equals("blightsteel collossus") || cn.equals("blood moon") || cn.equals("braids, cabal minion") || cn.equals("cabal coffers") || cn.equals("captain sisay") || cn.equals("celestial dawn") || cn.equals("child of alara") || cn.equals("coalition relic") || cn.equals("craterhoof behemoth") || cn.equals("deepglow skate") || cn.equals("derevi, empyrial tactician") || cn.equals("dig through time") || cn.equals("edric, spymaster of trest") || cn.equals("elesh norn, grand cenobite") || cn.equals("entomb") || cn.equals("force of will") || cn.equals("food chain") || cn.equals("gaddock teeg") || cn.equals("gaea's cradle") || cn.equals("grand arbiter augustin iv") || cn.equals("grim monolith") || cn.equals("hermit druid") || cn.equals("hokori, dust drinker") || cn.equals("humility") || cn.equals("imperial seal") || cn.equals("iona, shield of emeria") || cn.equals("jin-gitaxias, core augur") || cn.equals("karador, ghost chieftain") || cn.equals("karakas") || cn.equals("kataki, war's wage") || cn.equals("knowledge pool") || cn.equals("linvala, keeper of silence") || cn.equals("living death") || cn.equals("llawan, cephalid empress") || cn.equals("loyal retainers") || cn.equals("maelstrom wanderer") || cn.equals("malfegor") || cn.equals("master of cruelties") || cn.equals("mana crypt") || cn.equals("mana drain") || cn.equals("mana vault") || cn.equals("michiko konda, truth seeker") || cn.equals("nath of the gilt-leaf") || cn.equals("natural order") || cn.equals("necrotic ooze") || cn.equals("nicol bolas") || cn.equals("numot, the devastator") || cn.equals("oath of druids") || cn.equals("pattern of rebirth") || cn.equals("protean hulk") || cn.equals("purphoros, god of the forge") || cn.equals("ravages of war") || cn.equals("reclamation sage") || cn.equals("sen triplets") || cn.equals("serra's sanctum") || cn.equals("sheoldred, whispering one") || cn.equals("sol ring") || cn.equals("spore frog") || cn.equals("stasis") || cn.equals("strip mine") || cn.equals("the tabernacle at pendrell vale") || cn.equals("tinker") || cn.equals("treasure cruise") || cn.equals("urabrask the hidden") || cn.equals("vorinclex, voice of hunger") || cn.equals("winter orb") || cn.equals("zur the enchanter")) {
            thisMaxPower = Math.max(thisMaxPower, 12);
        }
        // Parts of infinite combos
        if (cn.equals("animate artifact") || cn.equals("animar, soul of element") || cn.equals("archaeomancer") || cn.equals("ashnod's altar") || cn.equals("azami, lady of scrolls") || cn.equals("aura flux") || cn.equals("basalt monolith") || cn.equals("brago, king eternal") || cn.equals("candelabra of tawnos") || cn.equals("cephalid aristocrat") || cn.equals("cephalid illusionist") || cn.equals("changeling berserker") || cn.equals("consecrated sphinx") || cn.equals("cyclonic rift") || cn.equals("the chain veil") || cn.equals("cinderhaze wretch") || cn.equals("cryptic gateway") || cn.equals("deadeye navigator") || cn.equals("derevi, empyrial tactician") || cn.equals("doubling season") || cn.equals("dross scorpion") || cn.equals("earthcraft") || cn.equals("erratic portal") || cn.equals("enter the infinite") || cn.equals("omniscience") || cn.equals("exquisite blood") || cn.equals("future sight") || cn.equals("genesis chamber") || cn.equals("ghave, guru of spores") || cn.equals("grave pact") || cn.equals("grave titan") || cn.equals("great whale") || cn.equals("grim monolith") || cn.equals("gush") || cn.equals("hellkite charger") || cn.equals("intruder alarm") || cn.equals("helm of obedience") || cn.equals("hermit druid") || cn.equals("humility") || cn.equals("iona, shield of emeria") || cn.equals("karn, silver golem") || cn.equals("kiki-jiki, mirror breaker") || cn.equals("krark-clan ironworks") || cn.equals("krenko, mob boss") || cn.equals("krosan restorer") || cn.equals("laboratory maniac") || cn.equals("leonin relic-warder") || cn.equals("leyline of the void") || cn.equals("memnarch") || cn.equals("meren of clan nel toth") || cn.equals("mikaeus, the unhallowed") || cn.equals("mindcrank") || cn.equals("mindslaver") || cn.equals("minion reflector") || cn.equals("mycosynth lattice") || cn.equals("myr turbine") || cn.equals("narset, enlightened master") || cn.equals("nekusar, the mindrazer") || cn.equals("norin the wary") || cn.equals("notion thief") || cn.equals("opalescence") || cn.equals("ornithopter") || cn.equals("paradox engine") || cn.equals("purphoros, god of the forge") || cn.equals("peregrine drake") || cn.equals("palinchron") || cn.equals("planar portal") || cn.equals("power artifact") || cn.equals("rings of brighthearth") || cn.equals("rite of replication") || cn.equals("sanguine bond") || cn.equals("sensei's divining top") || cn.equals("splinter twin") || cn.equals("stony silence") || cn.equals("sunder") || cn.equals("storm cauldron") || cn.equals("teferi's puzzle box") || cn.equals("tangle wire") || cn.equals("teferi, mage of zhalfir") || cn.equals("tezzeret the seeker") || cn.equals("time stretch") || cn.equals("time warp") || cn.equals("training grounds") || cn.equals("triskelavus") || cn.equals("triskelion") || cn.equals("turnabout") || cn.equals("umbral mantle") || cn.equals("uyo, silent prophet") || cn.equals("voltaic key") || cn.equals("workhorse") || cn.equals("worldgorger dragon") || cn.equals("worthy cause") || cn.equals("yawgmoth's will") || cn.equals("zealous conscripts")) {
            thisMaxPower = Math.max(thisMaxPower, 15);
            numberInfinitePieces++;
        }
        // Saltiest cards (edhrec)
        if (cn.equals("acid rain") || cn.equals("agent of treachery") || cn.equals("apocalypse") || cn.equals("armageddon") || cn.equals("atraxa, praetors' voice") || cn.equals("aura shards") || cn.equals("avacyn, angel of hope") || cn.equals("back to basics") || cn.equals("bend or break") || cn.equals("blightsteel colossus") || cn.equals("blood moon") || cn.equals("boil") || cn.equals("boiling seas") || cn.equals("bribery") || cn.equals("burning sands") || cn.equals("card view") || cn.equals("cataclysm") || cn.equals("catastrophe") || cn.equals("chulane, teller of tales") || cn.equals("confusion in the ranks") || cn.equals("consecrated sphinx") || cn.equals("contamination") || cn.equals("craterhoof behemoth") || cn.equals("cyclonic rift") || cn.equals("death cloud") || cn.equals("decree of annihilation") || cn.equals("decree of silence") || cn.equals("demonic consultation") || cn.equals("derevi, empyrial tactician") || cn.equals("devastation") || cn.equals("divine intervention") || cn.equals("dockside extortionist") || cn.equals("doomsday") || cn.equals("doubling season") || cn.equals("drannith magistrate") || cn.equals("elesh norn, grand cenobite") || cn.equals("embargo") || cn.equals("emrakul, the promised end") || cn.equals("epicenter") || cn.equals("expropriate") || cn.equals("fall of the thran") || cn.equals("fierce guardianship") || cn.equals("food chain") || cn.equals("force of negation") || cn.equals("force of will") || cn.equals("gaddock teeg") || cn.equals("gaea's cradle") || cn.equals("gilded drake") || cn.equals("glenn, the voice of calm") || cn.equals("global ruin") || cn.equals("golos, tireless pilgrim") || cn.equals("grand arbiter augustin iv") || cn.equals("grip of chaos") || cn.equals("hokori, dust drinker") || cn.equals("humility") || cn.equals("impending disaster") || cn.equals("invoke prejudice") || cn.equals("iona, shield of emeria") || cn.equals("jin-gitaxias, core augur") || cn.equals("jokulhaups") || cn.equals("keldon firebombers") || cn.equals("kinnan, bonder prodigy") || cn.equals("kozilek, butcher of truth") || cn.equals("land equilibrium") || cn.equals("linvala, keeper of silence") || cn.equals("magister sphinx") || cn.equals("mana breach") || cn.equals("mana crypt") || cn.equals("mana drain") || cn.equals("mana vortex") || cn.equals("mindslaver") || cn.equals("narset, enlightened master") || cn.equals("narset, parter of veils") || cn.equals("negan, the cold-blooded") || cn.equals("nether void") || cn.equals("nexus of fate") || cn.equals("notion thief") || cn.equals("obliterate") || cn.equals("oko, thief of crowns") || cn.equals("oloro, ageless ascetic") || cn.equals("omniscience") || cn.equals("opposition agent") || cn.equals("oppression") || cn.equals("overwhelming splendor") || cn.equals("palinchron") || cn.equals("paradox engine") || cn.equals("possessed portal") || cn.equals("price of glory") || cn.equals("protean hulk") || cn.equals("ravages of war") || cn.equals("rhystic study") || cn.equals("rick, steadfast leader") || cn.equals("rising waters") || cn.equals("ruination") || cn.equals("scrambleverse") || cn.equals("seedborn muse") || cn.equals("sen triplets") || cn.equals("sire of insanity") || cn.equals("skithiryx, the blight dragon") || cn.equals("smokestack") || cn.equals("smothering tithe") || cn.equals("sorin markov") || cn.equals("stasis") || cn.equals("static orb") || cn.equals("storage matrix") || cn.equals("sunder") || cn.equals("survival of the fittest") || cn.equals("table view") || cn.equals("tainted aether") || cn.equals("tectonic break") || cn.equals("teferi's protection") || cn.equals("teferi, master of time") || cn.equals("teferi, time raveler") || cn.equals("temporal manipulation") || cn.equals("tergrid, god of fright") || cn.equals("text view") || cn.equals("thassa's oracle") || cn.equals("the tabernacle at pendrell vale") || cn.equals("thieves' auction") || cn.equals("thoughts of ruin") || cn.equals("thrasios, triton hero") || cn.equals("time stretch") || cn.equals("time warp") || cn.equals("tooth and nail") || cn.equals("torment of hailfire") || cn.equals("torpor orb") || cn.equals("triumph of the hordes") || cn.equals("ugin, the spirit dragon") || cn.equals("ulamog, the ceaseless hunger") || cn.equals("ulamog, the infinite gyre") || cn.equals("urza, lord high artificer") || cn.equals("void winnower") || cn.equals("vorinclex, voice of hunger") || cn.equals("wake of destruction") || cn.equals("warp world") || cn.equals("winter orb") || cn.equals("xanathar, guild kingpin") || cn.equals("zur the enchanter")) {
            thisMaxPower = Math.max(thisMaxPower, 15);
        }
        edhPowerLevel += thisMaxPower;
    }
    ObjectColor color = null;
    for (Card commander : deck.getSideboard()) {
        int thisMaxPower = 0;
        String cn = commander.getName().toLowerCase(Locale.ENGLISH);
        if (color == null) {
            color = commander.getColor(null);
        } else {
            color = color.union(commander.getColor(null));
        }
        FilterMana commanderColor = commander.getColorIdentity();
        if (commanderColor.isWhite()) {
            color.setWhite(true);
        }
        if (commanderColor.isBlue()) {
            color.setBlue(true);
        }
        if (commanderColor.isBlack()) {
            color.setBlack(true);
        }
        if (commanderColor.isRed()) {
            color.setRed(true);
        }
        if (commanderColor.isGreen()) {
            color.setGreen(true);
        }
        // Least fun commanders
        if (cn.equals("animar, soul of element") || cn.equals("anafenza, the foremost") || cn.equals("arcum dagsson") || cn.equals("azami, lady of scrolls") || cn.equals("azusa, lost but seeking") || cn.equals("brago, king eternal") || cn.equals("braids, cabal minion") || cn.equals("captain sisay") || cn.equals("child of alara") || cn.equals("derevi, empyrial tactician") || cn.equals("edric, spymaster of trest") || cn.equals("elesh norn, grand cenobite") || cn.equals("gaddock teeg") || cn.equals("grand arbiter augustin iv") || cn.equals("hokori, dust drinker") || cn.equals("iona, shield of emeria") || cn.equals("jin-gitaxias, core augur") || cn.equals("kaalia of the vast") || cn.equals("karador, ghost chieftain") || cn.equals("leovold, emissary of trest") || cn.equals("linvala, keeper of silence") || cn.equals("llawan, cephalid empress") || cn.equals("maelstrom wanderer") || cn.equals("malfegor") || cn.equals("memnarch") || cn.equals("meren of clan nel toth") || cn.equals("michiko konda, truth seeker") || cn.equals("mikaeus the unhallowed") || cn.equals("narset, enlightened master") || cn.equals("nath of the gilt-leaf") || cn.equals("nekusar, the mindrazer") || cn.equals("norin the wary") || cn.equals("numot, the devastator") || cn.equals("prossh, skyraider of kher") || cn.equals("purphoros, god of the forge") || cn.equals("sen triplets") || cn.equals("sheoldred, whispering one") || cn.equals("teferi, mage of zhalfir") || cn.equals("urabrask the hidden") || cn.equals("vorinclex, voice of hunger") || cn.equals("zur the enchanter")) {
            thisMaxPower = Math.max(thisMaxPower, 25);
        }
        // Saltiest commanders
        if (cn.equals("atraxa, praetors' voice") || cn.equals("avacyn, angel of hope") || cn.equals("chulane, teller of tales") || cn.equals("derevi, empyrial tactician") || cn.equals("elesh norn, grand cenobite") || cn.equals("emrakul, the promised end") || cn.equals("gaddock teeg") || cn.equals("glenn, the voice of calm") || cn.equals("golos, tireless pilgrim") || cn.equals("grand arbiter augustin iv") || cn.equals("hokori, dust drinker") || cn.equals("iona, shield of emeria") || cn.equals("jin-gitaxias, core augur") || cn.equals("kinnan, bonder prodigy") || cn.equals("kozilek, butcher of truth") || cn.equals("linvala, keeper of silence") || cn.equals("narset, enlightened master") || cn.equals("negan, the cold-blooded") || cn.equals("oko, thief of crowns") || cn.equals("oloro, ageless ascetic") || cn.equals("rick, steadfast leader") || cn.equals("sen triplets") || cn.equals("skithiryx, the blight dragon") || cn.equals("teferi, master of time") || cn.equals("teferi, time raveler") || cn.equals("thrasios, triton hero") || cn.equals("ulamog, the ceaseless hunger") || cn.equals("ulamog, the infinite gyre") || cn.equals("urza, lord high artificer") || cn.equals("vorinclex, voice of hunger") || cn.equals("xanathar, guild kingpin") || cn.equals("zur the enchanter")) {
            thisMaxPower = Math.max(thisMaxPower, 20);
        }
        edhPowerLevel += thisMaxPower;
    }
    edhPowerLevel += numberInfinitePieces * 18;
    edhPowerLevel = Math.round(edhPowerLevel / 10);
    if (edhPowerLevel >= 100) {
        edhPowerLevel = 99;
    }
    if (color != null) {
        edhPowerLevel += (color.isWhite() ? 10000000 : 0);
        edhPowerLevel += (color.isBlue() ? 1000000 : 0);
        edhPowerLevel += (color.isBlack() ? 100000 : 0);
        edhPowerLevel += (color.isRed() ? 10000 : 0);
        edhPowerLevel += (color.isGreen() ? 1000 : 0);
    }
    return edhPowerLevel;
}
Also used : PartnerAbility(mage.abilities.keyword.PartnerAbility) FriendsForeverAbility(mage.abilities.keyword.FriendsForeverAbility) PartnerWithAbility(mage.abilities.keyword.PartnerWithAbility) CanBeYourCommanderAbility(mage.abilities.common.CanBeYourCommanderAbility) CompanionAbility(mage.abilities.keyword.CompanionAbility) Ability(mage.abilities.Ability) FilterMana(mage.filter.FilterMana) ObjectColor(mage.ObjectColor) Card(mage.cards.Card)

Aggregations

FilterMana (mage.filter.FilterMana)17 Card (mage.cards.Card)10 Ability (mage.abilities.Ability)6 Mana (mage.Mana)5 CompanionAbility (mage.abilities.keyword.CompanionAbility)5 PartnerAbility (mage.abilities.keyword.PartnerAbility)5 PartnerWithAbility (mage.abilities.keyword.PartnerWithAbility)5 java.util (java.util)4 ObjectColor (mage.ObjectColor)4 CanBeYourCommanderAbility (mage.abilities.common.CanBeYourCommanderAbility)4 Constructed (mage.cards.decks.Constructed)4 Deck (mage.cards.decks.Deck)4 DeckValidatorErrorType (mage.cards.decks.DeckValidatorErrorType)4 CardType (mage.constants.CardType)4 Player (mage.players.Player)4 ManaUtil (mage.util.ManaUtil)4 UUID (java.util.UUID)3 ExpansionSet (mage.cards.ExpansionSet)3 Sets (mage.cards.Sets)3 FriendsForeverAbility (mage.abilities.keyword.FriendsForeverAbility)2