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 <valeriomaggio@gmail.com>
This commit is contained in:
leriomaggio
2021-10-02 07:38:17 +01:00
parent 65b7df63f7
commit 08ca0bf175

View File

@@ -31,15 +31,16 @@ public enum DeckSection {
// Returns the matching section for "special"/supplementary core types. // Returns the matching section for "special"/supplementary core types.
public static DeckSection matchingSection(PaperCard card){ public static DeckSection matchingSection(PaperCard card){
CardType t = card.getRules().getType(); if (DeckSection.Conspiracy.validate(card))
if (t.isConspiracy())
return Conspiracy; return Conspiracy;
if (t.isScheme()) if (DeckSection.Schemes.validate(card))
return Schemes; return Schemes;
if (t.isVanguard()) if (DeckSection.Avatar.validate(card))
return Avatar; return Avatar;
if (t.isPlane() || t.isPhenomenon() | t.isDungeon()) if (DeckSection.Planes.validate(card))
return Planes; return Planes;
if (DeckSection.Commander.validate(card))
return Commander;
return Main; // default return Main; // default
} }