Random brawl deck generator working on Desktop

This commit is contained in:
austinio7116
2018-03-28 23:41:57 +01:00
committed by maustin
parent b9aef9b317
commit ed564b904f
7 changed files with 104 additions and 22 deletions

View File

@@ -23,6 +23,9 @@ import java.util.Map;
*/
public class CommanderDeckGenerator extends DeckProxy implements Comparable<CommanderDeckGenerator> {
public static List<DeckProxy> getCommanderDecks(final DeckFormat format, boolean isForAi, boolean isCardGen){
if(format.equals(DeckFormat.Brawl)){
return getBrawlDecks(format, isForAi, isCardGen);
}
ItemPool uniqueCards;
if(isCardGen){
uniqueCards = new ItemPool<PaperCard>(PaperCard.class);
@@ -50,6 +53,31 @@ public class CommanderDeckGenerator extends DeckProxy implements Comparable<Comm
return decks;
}
public static List<DeckProxy> getBrawlDecks(final DeckFormat format, boolean isForAi, boolean isCardGen){
ItemPool uniqueCards;
if(isCardGen){
uniqueCards = new ItemPool<PaperCard>(PaperCard.class);
//TODO: upate to actual Brawl model from real Brawl decks
Iterable<String> legendNames=CardRelationMatrixGenerator.cardPools.get(FModel.getFormats().getStandard().getName()).keySet();
for(String legendName:legendNames) {
uniqueCards.add(FModel.getMagicDb().getCommonCards().getUniqueByName(legendName));
}
}else {
uniqueCards = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class);
}
Predicate<CardRules> canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : DeckGeneratorBase.HUMAN_CAN_PLAY;
@SuppressWarnings("unchecked")
Iterable<PaperCard> legends = Iterables.filter(uniqueCards.toFlatList(), Predicates.and(format.isLegalCardPredicate(),
Predicates.compose(Predicates.and(
CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER,
canPlay), PaperCard.FN_GET_RULES)));
final List<DeckProxy> decks = new ArrayList<DeckProxy>();
for(PaperCard legend: legends) {
decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen));
}
return decks;
}
private final PaperCard legend;
private final int index;
private final DeckFormat format;

View File

@@ -387,7 +387,7 @@ public class DeckProxy implements InventoryItem {
return FModel.getFormats().getStandard().isDeckLegal(input);
}
}, filter);
addDecksRecursivelly("Tiny Leaders", GameType.Brawl, result, "", FModel.getDecks().getBrawl(), filter);
addDecksRecursivelly("Brawl", GameType.Brawl, result, "", FModel.getDecks().getBrawl(), filter);
return result;
}

View File

@@ -542,7 +542,11 @@ public class DeckgenUtil {
PaperCard selectedPartner=null;
if(isCardGen){
List<Map.Entry<PaperCard,Integer>> potentialCards = new ArrayList<>();
potentialCards.addAll(CardRelationMatrixGenerator.cardPools.get(DeckFormat.Commander.toString()).get(commander.getName()));
if(format.equals(DeckFormat.Brawl)){
potentialCards.addAll(CardRelationMatrixGenerator.cardPools.get(FModel.getFormats().getStandard().getName()).get(commander.getName()));
}else {
potentialCards.addAll(CardRelationMatrixGenerator.cardPools.get(DeckFormat.Commander.toString()).get(commander.getName()));
}
Random r = new Random();
//Collections.shuffle(potentialCards, r);
List<PaperCard> preSelectedCards = new ArrayList<>();
@@ -590,9 +594,17 @@ public class DeckgenUtil {
Iterable<PaperCard> colorList = Iterables.filter(format.getCardPool(cardDb).getAllCards(),
Predicates.compose(Predicates.or(new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()),
DeckGeneratorBase.COLORLESS_CARDS), PaperCard.FN_GET_RULES));
if(format.equals(DeckFormat.Brawl)){
Iterable<PaperCard> colorListFiltered = Iterables.filter(colorList,FModel.getFormats().getStandard().getFilterPrinted());
colorList=colorListFiltered;
}
List<PaperCard> cardList = Lists.newArrayList(colorList);
Collections.shuffle(cardList, new Random());
List<PaperCard> shortList = cardList.subList(1, 400);
int shortlistlength=400;
if(cardList.size()<400){
shortlistlength=cardList.size();
}
List<PaperCard> shortList = cardList.subList(1, shortlistlength);
gen = new CardThemedCommanderDeckBuilder(commander, selectedPartner,shortList,forAi,format);
}

View File

@@ -173,6 +173,8 @@ public final class FModel {
formats.add(format);
}
magicDb.setStandardPredicate(formats.getStandard().getFilterPrinted());
blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
questPreferences = new QuestPreferences();
conquestPreferences = new ConquestPreferences();