mtg-genetic-deckbuilding

Generating and improving Magic: The Gathering decks using a genetic algorithm
git clone https://kevincorvisier.fr/git/mtg-genetic-deckbuilding.git
Log | Files | Refs | LICENSE

commit 009c051bee2c3ba6ceb665d69a91074009a81aab
parent 032283fa94afa387bfba3aaf150ff4e769a695f4
Author: Kevin Corvisier <git@kevincorvisier.fr>
Date:   Fri,  8 Nov 2024 18:07:47 +0900

Add "PreMiddleSchool" format as the intersection of Premodern and MiddleSchool formats

Diffstat:
Mpom.xml | 6++++++
Msrc/main/java/fr/kevincorvisier/mtg/gdb/ApplicationConfig.java | 23+++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml @@ -63,6 +63,12 @@ </dependency> <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>4.5.0-M2</version> + </dependency> + + <dependency> <groupId>dev.dirs</groupId> <artifactId>directories</artifactId> <version>26</version> diff --git a/src/main/java/fr/kevincorvisier/mtg/gdb/ApplicationConfig.java b/src/main/java/fr/kevincorvisier/mtg/gdb/ApplicationConfig.java @@ -5,6 +5,7 @@ import java.util.GregorianCalendar; import java.util.List; import java.util.Set; +import org.apache.commons.collections4.ListUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -40,9 +41,27 @@ public class ApplicationConfig public GameFormat format(@Value("${format}") final String formatName) { if ("MiddleSchool".equals(formatName)) - return new GameFormat("MiddleSchool", MIDDLE_SCHOOL_EFFECTIVE_DATE, MIDDLE_SCHOOL_SETS, MIDDLE_SCHOOL_BANNED_CARDS, null, false, - MIDDLE_SCHOOL_ADDITIONAL_CARDS, null, 0, FormatType.CUSTOM, FormatSubType.CUSTOM); + return getMiddleSchool(); + + else if ("PreMiddleSchool".equals(formatName)) + { + final GameFormat middleSchool = getMiddleSchool(); + final GameFormat premodern = FModel.getFormats().get("Premodern"); + + final Iterable<String> sets = ListUtils.intersection(middleSchool.getAllowedSetCodes(), premodern.getAllowedSetCodes()); + final List<String> bannedCards = ListUtils.union(middleSchool.getBannedCardNames(), premodern.getBannedCardNames()); + final List<String> additionalCards = ListUtils.intersection(middleSchool.getAdditionalCards(), premodern.getAdditionalCards()); + + return new GameFormat("PreMiddleSchool", MIDDLE_SCHOOL_EFFECTIVE_DATE, sets, bannedCards, null, false, additionalCards, null, 0, FormatType.CUSTOM, + FormatSubType.CUSTOM); + } else return FModel.getFormats().get(formatName); } + + private GameFormat getMiddleSchool() + { + return new GameFormat("MiddleSchool", MIDDLE_SCHOOL_EFFECTIVE_DATE, MIDDLE_SCHOOL_SETS, MIDDLE_SCHOOL_BANNED_CARDS, null, false, + MIDDLE_SCHOOL_ADDITIONAL_CARDS, null, 0, FormatType.CUSTOM, FormatSubType.CUSTOM); + } }