Merge branch 'sorting' into 'master'

Update item manager groupings

See merge request core-developers/forge!1035
This commit is contained in:
Michael Kamensky
2018-10-23 05:03:50 +00:00
2 changed files with 55 additions and 19 deletions

View File

@@ -74,12 +74,12 @@ public enum GroupDef {
return -1; return -1;
} }
}), }),
DEFAULT("Default", DEFAULT("Default", //Beginning in DDU, "Artifacts" category is added at top of list
new String[] { "Creatures", "Spells", "Lands" }, new String[] { "Artifacts", "Creatures", "Other Spells", "Lands" },
new Function<Integer, ColumnDef>() { new Function<Integer, ColumnDef>() {
@Override @Override
public ColumnDef apply(final Integer groupIndex) { public ColumnDef apply(final Integer groupIndex) {
if (groupIndex == 2) { if (groupIndex == 3) {
return ColumnDef.NAME; //pile lands by name regardless return ColumnDef.NAME; //pile lands by name regardless
} }
return null; return null;
@@ -90,21 +90,24 @@ public enum GroupDef {
public Integer apply(final InventoryItem item) { public Integer apply(final InventoryItem item) {
if (item instanceof PaperCard) { if (item instanceof PaperCard) {
CardType type = ((PaperCard) item).getRules().getType(); CardType type = ((PaperCard) item).getRules().getType();
if (type.isCreature()) { if (type.isArtifact()) { //artifact lands/creatures, too
return 0; return 0;
} }
if (type.isLand()) { //make Artifact Lands appear in Lands group if (type.isCreature()) {
return 2;
}
if (type.isArtifact() || type.isEnchantment() || type.isPlaneswalker() || type.isInstant() || type.isSorcery()) {
return 1; return 1;
} }
if (type.isLand()) {
return 3;
}
if (type.isEnchantment() || type.isPlaneswalker() || type.isInstant() || type.isSorcery()) {
return 2;
}
} }
return -1; return -1;
} }
}), }),
CARD_TYPE("Type", CARD_TYPE("Type",
new String[] { "Creatures", "Artifacts", "Enchantments", "Planeswalkers", "Instants", "Sorceries", "Lands" }, new String[] { "Planeswalker", "Creature", "Sorcery", "Instant", "Artifact", "Enchantment", "Land", "Tribal instant" },
new Function<Integer, ColumnDef>() { new Function<Integer, ColumnDef>() {
@Override @Override
public ColumnDef apply(final Integer groupIndex) { public ColumnDef apply(final Integer groupIndex) {
@@ -119,27 +122,60 @@ public enum GroupDef {
public Integer apply(final InventoryItem item) { public Integer apply(final InventoryItem item) {
if (item instanceof PaperCard) { if (item instanceof PaperCard) {
CardType type = ((PaperCard) item).getRules().getType(); CardType type = ((PaperCard) item).getRules().getType();
if (type.isCreature()) { //make Artifact and Land Creatures appear in Creatures group if (type.isPlaneswalker()) {
return 0; return 0;
} }
if (type.isLand()) { //make Artifact Lands appear in Lands group if (type.isCreature()) {
return 6;
}
if (type.isArtifact()) {
return 1; return 1;
} }
if (type.isEnchantment()) { if (type.isSorcery()) {
return 2; return 2;
} }
if (type.isPlaneswalker()) { if (type.isTribal() && type.isInstant()) {
return 3; return 7;
} }
if (type.isInstant()) { if (type.isInstant()) {
return 3;
}
if (type.isArtifact()) {
return 4; return 4;
} }
if (type.isSorcery()) { if (type.isEnchantment()) {
return 5; return 5;
} }
if (type.isLand()) {
return 6;
}
}
return -1;
}
}),
PW_DECK_SORT("Planeswalker Deck Sort",
new String[] { "Planeswalker", "Rares", "Creature", "Land", "Other Spells" },
new Function<Integer, ColumnDef>() {
@Override
public ColumnDef apply(final Integer groupIndex) {
return null;
}
},
new Function<InventoryItem, Integer>() {
@Override
public Integer apply(final InventoryItem item) {
if (item instanceof PaperCard) {
CardType type = ((PaperCard) item).getRules().getType();
if (type.isPlaneswalker()){
return 0;
}
if (((PaperCard) item).getRarity().toString() == "R"){
return 1;
}
if (type.isCreature()){
return 2;
}
if (type.isLand()){
return 3;
}
return 4;
} }
return -1; return -1;
} }

View File

@@ -157,7 +157,7 @@ public final class SItemManagerUtil {
return builder.toString(); return builder.toString();
} }
private static final GroupDef[] CARD_GROUPBY_OPTIONS = { GroupDef.DEFAULT, GroupDef.CARD_TYPE, GroupDef.COLOR, GroupDef.COLOR_IDENTITY, GroupDef.SET, GroupDef.CARD_RARITY }; private static final GroupDef[] CARD_GROUPBY_OPTIONS = { GroupDef.DEFAULT, GroupDef.CARD_TYPE, GroupDef.COLOR, GroupDef.COLOR_IDENTITY, GroupDef.SET, GroupDef.CARD_RARITY, GroupDef.PW_DECK_SORT };
private static final GroupDef[] DECK_GROUPBY_OPTIONS = { GroupDef.COLOR, GroupDef.COLOR_IDENTITY, GroupDef.SET }; private static final GroupDef[] DECK_GROUPBY_OPTIONS = { GroupDef.COLOR, GroupDef.COLOR_IDENTITY, GroupDef.SET };
private static final ColumnDef[] CARD_PILEBY_OPTIONS = { ColumnDef.CMC, ColumnDef.COLOR, ColumnDef.NAME, ColumnDef.COST, ColumnDef.TYPE, ColumnDef.RARITY, ColumnDef.SET }; private static final ColumnDef[] CARD_PILEBY_OPTIONS = { ColumnDef.CMC, ColumnDef.COLOR, ColumnDef.NAME, ColumnDef.COST, ColumnDef.TYPE, ColumnDef.RARITY, ColumnDef.SET };
private static final ColumnDef[] DECK_PILEBY_OPTIONS = { ColumnDef.DECK_COLOR, ColumnDef.DECK_FOLDER, ColumnDef.NAME, ColumnDef.DECK_FORMAT, ColumnDef.DECK_EDITION }; private static final ColumnDef[] DECK_PILEBY_OPTIONS = { ColumnDef.DECK_COLOR, ColumnDef.DECK_FOLDER, ColumnDef.NAME, ColumnDef.DECK_FORMAT, ColumnDef.DECK_EDITION };