mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
added Friends forever support to regular commander
This commit is contained in:
parent
518458d932
commit
ca189af388
1 changed files with 26 additions and 18 deletions
|
@ -1,9 +1,11 @@
|
|||
package mage.deck;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.CanBeYourCommanderAbility;
|
||||
import mage.abilities.keyword.CompanionAbility;
|
||||
import mage.abilities.keyword.FriendsForeverAbility;
|
||||
import mage.abilities.keyword.PartnerAbility;
|
||||
import mage.abilities.keyword.PartnerWithAbility;
|
||||
import mage.cards.Card;
|
||||
|
@ -14,6 +16,7 @@ import mage.cards.decks.Deck;
|
|||
import mage.cards.decks.DeckValidatorErrorType;
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.FilterMana;
|
||||
import mage.util.CardUtil;
|
||||
import mage.util.ManaUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -183,6 +186,26 @@ public class Commander extends Constructed {
|
|||
for (Card commander : commanders) {
|
||||
commanderNames.add(commander.getName());
|
||||
}
|
||||
if (commanders.size() == 2
|
||||
&& commanders
|
||||
.stream()
|
||||
.map(MageObject::getAbilities)
|
||||
.filter(abilities -> abilities.contains(PartnerAbility.getInstance()))
|
||||
.count() != 2
|
||||
&& commanders
|
||||
.stream()
|
||||
.map(MageObject::getAbilities)
|
||||
.filter(abilities -> abilities.contains(FriendsForeverAbility.getInstance()))
|
||||
.count() != 2
|
||||
&& CardUtil
|
||||
.castStream(commanders.stream().map(MageObject::getAbilities), PartnerWithAbility.class)
|
||||
.map(PartnerWithAbility::getPartnerName)
|
||||
.allMatch(commanderNames::contains)) {
|
||||
for (Card commander : commanders) {
|
||||
addError(DeckValidatorErrorType.PRIMARY, commander.getName(), "Commander with invalid Partner (" + commander.getName() + ')', true);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
for (Card commander : commanders) {
|
||||
if (bannedCommander.contains(commander.getName())) {
|
||||
addError(DeckValidatorErrorType.PRIMARY, commander.getName(), "Commander banned (" + commander.getName() + ')', true);
|
||||
|
@ -193,24 +216,9 @@ public class Commander extends Constructed {
|
|||
addError(DeckValidatorErrorType.PRIMARY, commander.getName(), "Commander invalid (" + commander.getName() + ')', true);
|
||||
valid = false;
|
||||
}
|
||||
if (commanders.size() == 2) {
|
||||
if (commander.getAbilities().contains(PartnerAbility.getInstance())) {
|
||||
if (bannedPartner.contains(commander.getName())) {
|
||||
addError(DeckValidatorErrorType.PRIMARY, commander.getName(), "Commander Partner banned (" + commander.getName() + ')', true);
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
boolean partnersWith = commander.getAbilities()
|
||||
.stream()
|
||||
.filter(PartnerWithAbility.class::isInstance)
|
||||
.map(PartnerWithAbility.class::cast)
|
||||
.map(PartnerWithAbility::getPartnerName)
|
||||
.anyMatch(commanderNames::contains);
|
||||
if (!partnersWith) {
|
||||
addError(DeckValidatorErrorType.PRIMARY, commander.getName(), "Commander without Partner (" + commander.getName() + ')', true);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (commanders.size() == 2 && bannedPartner.contains(commander.getName())) {
|
||||
addError(DeckValidatorErrorType.PRIMARY, commander.getName(), "Commander Partner banned (" + commander.getName() + ')', true);
|
||||
valid = false;
|
||||
}
|
||||
ManaUtil.collectColorIdentity(colorIdentity, commander.getColorIdentity());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue