Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make random commander decks able to use different-color partners #4338

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions forge-gui/src/main/java/forge/deck/DeckgenUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,28 @@ else if (commander.getRules().canBePartnerCommander()) {
}else{
cardDb = FModel.getMagicDb().getCommonCards();
//shuffle first 400 random cards
Iterable<PaperCard> colorList = Iterables.filter(format.getCardPool(cardDb).getAllCards(),
Iterable<PaperCard> baseList = Iterables.filter(format.getCardPool(cardDb).getAllCards(),
format.isLegalCardPredicate());
ColorSet colorIdentity = commander.getRules().getColorIdentity();
if (!(format == DeckFormat.Brawl || format == DeckFormat.Oathbreaker)) {
if (commander.getRules().canBePartnerCommander()) {
//check for partner commanders
List<PaperCard> partners = new ArrayList<>();
for (PaperCard c : baseList) {
if (c.getRules().canBePartnerCommanders(commander.getRules())) {
partners.add(c);
}
}

if (partners.size() > 0) {
selectedPartner = partners.get(MyRandom.getRandom().nextInt(partners.size()));
colorIdentity = ColorSet.fromMask(colorIdentity.getColor() | selectedPartner.getRules().getColorIdentity().getColor());
}
}
}
Iterable<PaperCard> colorList = Iterables.filter(baseList,
Predicates.and(format.isLegalCardPredicate(),Predicates.compose(Predicates.or(
new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()),
new CardThemedDeckBuilder.MatchColorIdentity(colorIdentity),
DeckGeneratorBase.COLORLESS_CARDS), PaperCard.FN_GET_RULES)));
switch (format) {
case Brawl: //for Brawl - add additional filterprinted rule to remove old reprints for a consistent look
Expand All @@ -786,19 +805,6 @@ else if (commander.getRules().canBePartnerCommander()) {
}
break;
default:
if (commander.getRules().canBePartnerCommander()) {
//check for partner commanders
List<PaperCard> partners = new ArrayList<>();
for (PaperCard c : colorList) {
if (c.getRules().canBePartnerCommanders(commander.getRules())) {
partners.add(c);
}
}

if (partners.size() > 0) {
selectedPartner = partners.get(MyRandom.getRandom().nextInt(partners.size()));
}
}
break;
}
List<PaperCard> cardList = Lists.newArrayList(colorList);
Expand Down