Merge branch 'paco_adddeckaicolumn' into 'master'

Add AI column to deck editor

See merge request core-developers/forge!6044
This commit is contained in:
Michael Kamensky
2022-01-16 17:46:20 +00:00
4 changed files with 47 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ public class DeckProxy implements InventoryItem {
// cached values
protected ColorSet color;
protected ColorSet colorIdentity;
protected Boolean ai;
protected Set<GameFormat> formats;
protected Set<GameFormat> exhaustiveFormats;
private Integer mainSize = null;
@@ -140,6 +141,7 @@ public class DeckProxy implements InventoryItem {
edition = null;
mainSize = null;
sbSize = null;
ai = null;
}
public ColorSet getColor() {
@@ -211,6 +213,35 @@ public class DeckProxy implements InventoryItem {
return colorIdentity;
}
public boolean getAI() {
if (ai == null) {
boolean hasAi = true;
for (final Entry<DeckSection, CardPool> deckEntry : getDeck()) {
switch (deckEntry.getKey()) {
case Main:
case Commander:
for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) {
CardAiHints ai = poolEntry.getKey().getRules().getAiHints();
if (ai.getRemAIDecks()) {
hasAi = false;
break;
}
}
break;
case Sideboard: // Let's pretend the sideboard doesn't matter
default:
break; //ignore other sections
}
if (hasAi == false) {
break;
}
}
ai = hasAi;
}
return ai;
}
public CardRarity getHighestRarity() {
if (highestRarity == null) {
highestRarity = CardRarity.Common;

View File

@@ -249,7 +249,7 @@ public enum ColumnDef {
IPaperCard cp = (IPaperCard) i;
CardAiHints ai = cp.getRules().getAiHints();
return ai.getRemAIDecks() ? (ai.getRemRandomDecks() ? "AI ?" : "AI")
return ai.getRemAIDecks() ? (ai.getRemRandomDecks() ? "X?" : "X")
: (ai.getRemRandomDecks() ? "?" : "");
}
}),
@@ -459,6 +459,19 @@ public enum ColumnDef {
return null;
}
}),
DECK_AI("lblAI", "lblAIStatus", 38, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toDeck(from.getKey()).getAI() ? Integer.valueOf(1) : Integer.valueOf(-1);
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()).getAI()? "" : "X";
}
}),
/**
* The main library size column.
*/

View File

@@ -220,6 +220,7 @@ public final class SColumnUtil {
colDefs.add(ColumnDef.DECK_EDITION);
colDefs.add(ColumnDef.DECK_MAIN);
colDefs.add(ColumnDef.DECK_SIDE);
colDefs.add(ColumnDef.DECK_AI);
Map<ColumnDef, ItemColumnConfig> columns = getColumns(colDefs);
columns.get(ColumnDef.DECK_FAVORITE).setSortPriority(1);

View File

@@ -172,7 +172,7 @@ public final class SItemManagerUtil {
ColumnDef.SET, ColumnDef.COLLECTOR_ORDER};
private static final ColumnDef[] DECK_PILEBY_OPTIONS = {ColumnDef.DECK_COLOR, ColumnDef.DECK_FOLDER,
ColumnDef.NAME, ColumnDef.DECK_FORMAT,
ColumnDef.DECK_EDITION};
ColumnDef.DECK_EDITION, ColumnDef.DECK_AI};
public static void populateImageViewOptions(final IItemManager<?> itemManager, final IComboBox<Object> cbGroupByOptions, final IComboBox<Object> cbPileByOptions) {
final boolean isDeckManager = itemManager.getGenericType().equals(DeckProxy.class);