From 08ca0bf175514d424b619793b4b04cf9d87196a7 Mon Sep 17 00:00:00 2001 From: leriomaggio Date: Sat, 2 Oct 2021 07:38:17 +0100 Subject: [PATCH] Improved implementation of DeckSection Matching Previous implementation was lacking to check for commander section, plus re-used the code of validators. This one is a refined and refactored implementation. Note: as default, the method will always return Main, as there is no possibility, in general, to say whether Sideboard should be preferred instead - without any other knowledge about the deck. Signed-off-by: leriomaggio --- forge-core/src/main/java/forge/deck/DeckSection.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/forge-core/src/main/java/forge/deck/DeckSection.java b/forge-core/src/main/java/forge/deck/DeckSection.java index c908299db3b..07dd0bc693b 100644 --- a/forge-core/src/main/java/forge/deck/DeckSection.java +++ b/forge-core/src/main/java/forge/deck/DeckSection.java @@ -31,15 +31,16 @@ public enum DeckSection { // Returns the matching section for "special"/supplementary core types. public static DeckSection matchingSection(PaperCard card){ - CardType t = card.getRules().getType(); - if (t.isConspiracy()) + if (DeckSection.Conspiracy.validate(card)) return Conspiracy; - if (t.isScheme()) + if (DeckSection.Schemes.validate(card)) return Schemes; - if (t.isVanguard()) + if (DeckSection.Avatar.validate(card)) return Avatar; - if (t.isPlane() || t.isPhenomenon() | t.isDungeon()) + if (DeckSection.Planes.validate(card)) return Planes; + if (DeckSection.Commander.validate(card)) + return Commander; return Main; // default }