mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Fixed QuestCommander deck editor, hopefully.
This commit is contained in:
@@ -539,7 +539,12 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
public CardPool getAllCardsInASinglePool() {
|
public CardPool getAllCardsInASinglePool() {
|
||||||
return getAllCardsInASinglePool(true);
|
return getAllCardsInASinglePool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardPool getAllCardsInASinglePool(final boolean includeCommander) {
|
public CardPool getAllCardsInASinglePool(final boolean includeCommander) {
|
||||||
|
return getAllCardsInASinglePool(includeCommander, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardPool getAllCardsInASinglePool(final boolean includeCommander, boolean includeExtras) {
|
||||||
final CardPool allCards = new CardPool(); // will count cards in this pool to enforce restricted
|
final CardPool allCards = new CardPool(); // will count cards in this pool to enforce restricted
|
||||||
allCards.addAll(this.getMain());
|
allCards.addAll(this.getMain());
|
||||||
if (this.has(DeckSection.Sideboard)) {
|
if (this.has(DeckSection.Sideboard)) {
|
||||||
@@ -548,6 +553,11 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
if (includeCommander && this.has(DeckSection.Commander)) {
|
if (includeCommander && this.has(DeckSection.Commander)) {
|
||||||
allCards.addAll(this.get(DeckSection.Commander));
|
allCards.addAll(this.get(DeckSection.Commander));
|
||||||
}
|
}
|
||||||
|
if (includeExtras) {
|
||||||
|
for (DeckSection section : DeckSection.NONTRADITIONAL_SECTIONS)
|
||||||
|
if (this.has(section))
|
||||||
|
allCards.addAll(this.get(section));
|
||||||
|
}
|
||||||
// do not include schemes / avatars and any non-regular cards
|
// do not include schemes / avatars and any non-regular cards
|
||||||
return allCards;
|
return allCards;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ public enum DeckSection {
|
|||||||
Dungeon(0, Validators.DUNGEON_VALIDATOR),
|
Dungeon(0, Validators.DUNGEON_VALIDATOR),
|
||||||
Attractions(0, Validators.ATTRACTION_VALIDATOR);
|
Attractions(0, Validators.ATTRACTION_VALIDATOR);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of DeckSections that contain nontraditional cards.
|
||||||
|
*/
|
||||||
|
public static final DeckSection[] NONTRADITIONAL_SECTIONS = new DeckSection[]{Avatar, Planes, Schemes, Conspiracy, Dungeon, Attractions};
|
||||||
|
|
||||||
private final int typicalSize; // Rules enforcement is done in DeckFormat class, this is for reference only
|
private final int typicalSize; // Rules enforcement is done in DeckFormat class, this is for reference only
|
||||||
private Function<PaperCard, Boolean> fnValidator;
|
private Function<PaperCard, Boolean> fnValidator;
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
|||||||
|
|
||||||
Iterable<Entry<String,Integer>> cardsByName = null;
|
Iterable<Entry<String,Integer>> cardsByName = null;
|
||||||
if (deck != null) {
|
if (deck != null) {
|
||||||
final CardPool allCards = deck.getAllCardsInASinglePool(deck.has(DeckSection.Commander));
|
final CardPool allCards = deck.getAllCardsInASinglePool();
|
||||||
cardsByName = Aggregates.groupSumBy(allCards, pc -> pc.getRules().getNormalizedName());
|
cardsByName = Aggregates.groupSumBy(allCards, pc -> pc.getRules().getNormalizedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -259,11 +259,13 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
return isLandscape ? new DeckEditorPage[] {
|
return isLandscape ? new DeckEditorPage[] {
|
||||||
new CatalogPage(ItemManagerConfig.QUEST_EDITOR_POOL, Forge.getLocalizer().getMessage("lblInventory"), FSkinImage.QUEST_BOX),
|
new CatalogPage(ItemManagerConfig.QUEST_EDITOR_POOL, Forge.getLocalizer().getMessage("lblInventory"), FSkinImage.QUEST_BOX),
|
||||||
new DeckSectionPage(DeckSection.Commander, ItemManagerConfig.COMMANDER_SECTION),
|
new DeckSectionPage(DeckSection.Commander, ItemManagerConfig.COMMANDER_SECTION),
|
||||||
new DeckSectionPage(DeckSection.Main, ItemManagerConfig.QUEST_DECK_EDITOR)
|
new DeckSectionPage(DeckSection.Main, ItemManagerConfig.QUEST_DECK_EDITOR),
|
||||||
|
new DeckSectionPage(DeckSection.Sideboard, ItemManagerConfig.QUEST_DECK_EDITOR)
|
||||||
} : new DeckEditorPage[] {
|
} : new DeckEditorPage[] {
|
||||||
new CatalogPage(ItemManagerConfig.QUEST_EDITOR_POOL, Forge.getLocalizer().getMessage("lblInventory"), FSkinImage.QUEST_BOX),
|
new CatalogPage(ItemManagerConfig.QUEST_EDITOR_POOL, Forge.getLocalizer().getMessage("lblInventory"), FSkinImage.QUEST_BOX),
|
||||||
new DeckSectionPage(DeckSection.Main, ItemManagerConfig.QUEST_DECK_EDITOR),
|
new DeckSectionPage(DeckSection.Main, ItemManagerConfig.QUEST_DECK_EDITOR),
|
||||||
new DeckSectionPage(DeckSection.Commander, ItemManagerConfig.COMMANDER_SECTION)
|
new DeckSectionPage(DeckSection.Commander, ItemManagerConfig.COMMANDER_SECTION),
|
||||||
|
new DeckSectionPage(DeckSection.Sideboard, ItemManagerConfig.QUEST_DECK_EDITOR)
|
||||||
};
|
};
|
||||||
case PlanarConquest:
|
case PlanarConquest:
|
||||||
return isLandscape ? new DeckEditorPage[] {
|
return isLandscape ? new DeckEditorPage[] {
|
||||||
@@ -367,9 +369,6 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
private FDeckEditor(EditorType editorType0, String editDeckName, String editDeckPath, Deck newDeck, boolean showMainDeck,FEventHandler backButton) {
|
private FDeckEditor(EditorType editorType0, String editDeckName, String editDeckPath, Deck newDeck, boolean showMainDeck,FEventHandler backButton) {
|
||||||
super(backButton, getPages(editorType0));
|
super(backButton, getPages(editorType0));
|
||||||
|
|
||||||
if (editorType0 == EditorType.QuestCommander) //fix saving quest commander
|
|
||||||
editorType = EditorType.Quest;
|
|
||||||
else
|
|
||||||
editorType = editorType0;
|
editorType = editorType0;
|
||||||
|
|
||||||
editorType.getController().editor = this;
|
editorType.getController().editor = this;
|
||||||
@@ -486,6 +485,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
defaultLandSet = CardEdition.Predicates.getRandomSetWithAllBasicLands(availableEditionCodes);
|
defaultLandSet = CardEdition.Predicates.getRandomSetWithAllBasicLands(availableEditionCodes);
|
||||||
break;
|
break;
|
||||||
case Quest:
|
case Quest:
|
||||||
|
case QuestCommander:
|
||||||
defaultLandSet = FModel.getQuest().getDefaultLandSet();
|
defaultLandSet = FModel.getQuest().getDefaultLandSet();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1487,7 +1487,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
super.initialize();
|
super.initialize();
|
||||||
cardManager.setCaption(getItemManagerCaption());
|
cardManager.setCaption(getItemManagerCaption());
|
||||||
|
|
||||||
if (!isVisible() && (parentScreen.getEditorType() != EditorType.Quest||parentScreen.getEditorType() != EditorType.QuestCommander)) {
|
if (!isVisible() && (parentScreen.getEditorType() != EditorType.Quest && parentScreen.getEditorType() != EditorType.QuestCommander)) {
|
||||||
//delay refreshing while hidden unless for quest inventory
|
//delay refreshing while hidden unless for quest inventory
|
||||||
needRefreshWhenShown = true;
|
needRefreshWhenShown = true;
|
||||||
//Throw in the all cards that might be requested by other pages.
|
//Throw in the all cards that might be requested by other pages.
|
||||||
@@ -1539,6 +1539,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
public void refresh() {
|
public void refresh() {
|
||||||
Predicate<PaperCard> additionalFilter = null;
|
Predicate<PaperCard> additionalFilter = null;
|
||||||
final EditorType editorType = parentScreen.getEditorType();
|
final EditorType editorType = parentScreen.getEditorType();
|
||||||
|
Deck currentDeck = parentScreen.getDeck();
|
||||||
switch (editorType) {
|
switch (editorType) {
|
||||||
case Archenemy:
|
case Archenemy:
|
||||||
cardManager.setPool(FModel.getArchenemyCards(), true);
|
cardManager.setPool(FModel.getArchenemyCards(), true);
|
||||||
@@ -1547,28 +1548,40 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
cardManager.setPool(FModel.getPlanechaseCards(), true);
|
cardManager.setPool(FModel.getPlanechaseCards(), true);
|
||||||
break;
|
break;
|
||||||
case Quest:
|
case Quest:
|
||||||
final ItemPool<PaperCard> questPool = new ItemPool<>(PaperCard.class);
|
case QuestCommander:
|
||||||
|
ItemPool<PaperCard> questPool = new ItemPool<>(PaperCard.class);
|
||||||
questPool.addAll(FModel.getQuest().getCards().getCardpool());
|
questPool.addAll(FModel.getQuest().getCards().getCardpool());
|
||||||
// remove bottom cards that are in the deck from the card pool
|
// remove cards that are in the deck from the card pool
|
||||||
questPool.removeAll(parentScreen.getDeck().getMain());
|
questPool.removeAll(currentDeck.getAllCardsInASinglePool(true, true));
|
||||||
// remove sideboard cards from the catalog
|
if (editorType == EditorType.QuestCommander) {
|
||||||
questPool.removeAll(parentScreen.getDeck().getOrCreate(DeckSection.Sideboard));
|
List<PaperCard> commanders = currentDeck.getCommanders();
|
||||||
|
Predicate<PaperCard> filter;
|
||||||
|
String label;
|
||||||
|
if (commanders.isEmpty()) {
|
||||||
|
filter = DeckFormat.Commander.isLegalCommanderPredicate();
|
||||||
|
label = "lblCommanders";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filter = DeckFormat.Commander.isLegalCardForCommanderPredicate(commanders);
|
||||||
|
label = "lblCards";
|
||||||
|
}
|
||||||
|
cardManager.setCaption(Forge.getLocalizer().getMessage(label));
|
||||||
|
questPool = editorType.applyCardFilter(questPool, filter);
|
||||||
|
}
|
||||||
cardManager.setPool(questPool);
|
cardManager.setPool(questPool);
|
||||||
break;
|
break;
|
||||||
case PlanarConquest:
|
case PlanarConquest:
|
||||||
cardManager.setPool(ConquestUtil.getAvailablePool(parentScreen.getDeck()));
|
cardManager.setPool(ConquestUtil.getAvailablePool(currentDeck));
|
||||||
break;
|
break;
|
||||||
case QuestCommander:
|
|
||||||
case Commander:
|
case Commander:
|
||||||
case Oathbreaker:
|
case Oathbreaker:
|
||||||
case TinyLeaders:
|
case TinyLeaders:
|
||||||
case Brawl:
|
case Brawl:
|
||||||
final List<PaperCard> commanders = parentScreen.getDeck().getCommanders();
|
final List<PaperCard> commanders = currentDeck.getCommanders();
|
||||||
if (commanders.isEmpty()) {
|
if (commanders.isEmpty()) {
|
||||||
//if no commander set for deck, only show valid commanders
|
//if no commander set for deck, only show valid commanders
|
||||||
switch (editorType) {
|
switch (editorType) {
|
||||||
case Commander:
|
case Commander:
|
||||||
case QuestCommander:
|
|
||||||
additionalFilter = DeckFormat.Commander.isLegalCommanderPredicate();
|
additionalFilter = DeckFormat.Commander.isLegalCommanderPredicate();
|
||||||
cardManager.setCaption(Forge.getLocalizer().getMessage("lblCommanders"));
|
cardManager.setCaption(Forge.getLocalizer().getMessage("lblCommanders"));
|
||||||
break;
|
break;
|
||||||
@@ -1591,7 +1604,6 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
//if a commander has been set, only show cards that match its color identity
|
//if a commander has been set, only show cards that match its color identity
|
||||||
switch (editorType) {
|
switch (editorType) {
|
||||||
case Commander:
|
case Commander:
|
||||||
case QuestCommander:
|
|
||||||
additionalFilter = DeckFormat.Commander.isLegalCardForCommanderPredicate(commanders);
|
additionalFilter = DeckFormat.Commander.isLegalCardForCommanderPredicate(commanders);
|
||||||
break;
|
break;
|
||||||
case Oathbreaker:
|
case Oathbreaker:
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ public class QuestMenu extends FPopupMenu implements IVQuestStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
((DeckController<Deck>)EditorType.Quest.getController()).setRootFolder(FModel.getQuest().getMyDecks());
|
((DeckController<Deck>)EditorType.Quest.getController()).setRootFolder(FModel.getQuest().getMyDecks());
|
||||||
|
((DeckController<Deck>)EditorType.QuestCommander.getController()).setRootFolder(FModel.getQuest().getMyDecks());
|
||||||
((DeckController<DeckGroup>)EditorType.QuestDraft.getController()).setRootFolder(FModel.getQuest().getDraftDecks());
|
((DeckController<DeckGroup>)EditorType.QuestDraft.getController()).setRootFolder(FModel.getQuest().getDraftDecks());
|
||||||
if (reason == LaunchReason.StartQuestMode) {
|
if (reason == LaunchReason.StartQuestMode) {
|
||||||
if (QuestUtil.getCurrentDeck() == null) {
|
if (QuestUtil.getCurrentDeck() == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user