mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Fix so adding and removing cards from deck works properly in quest deck editor
This commit is contained in:
@@ -582,13 +582,13 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
Deck deck = parentScreen.getDeck();
|
Deck deck = parentScreen.getDeck();
|
||||||
|
|
||||||
for (Entry<PaperCard, Integer> itemEntry : itemsToAdd) {
|
for (Entry<PaperCard, Integer> itemEntry : itemsToAdd) {
|
||||||
PaperCard item = itemEntry.getKey();
|
PaperCard card = itemEntry.getKey();
|
||||||
PaperCard card = item instanceof PaperCard ? (PaperCard)item : null;
|
|
||||||
int qty = itemEntry.getValue();
|
|
||||||
|
|
||||||
int max;
|
int max;
|
||||||
if (deck == null || card == null || card.getRules().getType().isBasic() ||
|
if (deck == null || card == null) {
|
||||||
limit == CardLimit.None || limitExceptions.contains(card.getName())) {
|
max = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
else if (limit == CardLimit.None || card.getRules().getType().isBasic() || limitExceptions.contains(card.getName())) {
|
||||||
max = Integer.MAX_VALUE;
|
max = Integer.MAX_VALUE;
|
||||||
if (parentScreen.isLimitedEditor() && !isAddSource) {
|
if (parentScreen.isLimitedEditor() && !isAddSource) {
|
||||||
//prevent adding more than is in other pool when editing limited decks
|
//prevent adding more than is in other pool when editing limited decks
|
||||||
@@ -616,16 +616,24 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
max -= deck.get(DeckSection.Schemes).count(card);
|
max -= deck.get(DeckSection.Schemes).count(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int qty;
|
||||||
if (isAddSource) {
|
if (isAddSource) {
|
||||||
|
qty = itemEntry.getValue();
|
||||||
|
}
|
||||||
|
else if (parentScreen.getEditorType() == EditorType.Quest) {
|
||||||
|
//prevent adding more than is in quest inventory
|
||||||
|
qty = parentScreen.getCatalogPage().cardManager.getItemCount(card);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//if not source of items being added, use max directly if unlimited pool
|
||||||
|
qty = max;
|
||||||
|
}
|
||||||
if (qty > max) {
|
if (qty > max) {
|
||||||
qty = max;
|
qty = max;
|
||||||
}
|
}
|
||||||
if (qty > 0) {
|
if (qty > 0) {
|
||||||
additions.add(item, qty);
|
additions.add(card, qty);
|
||||||
}
|
|
||||||
}
|
|
||||||
else { //if not source of items being added, use max directly
|
|
||||||
additions.add(item, max);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -987,6 +995,9 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
if (parentScreen.isLimitedEditor()) { //ensure card removed from sideboard before adding to main
|
if (parentScreen.isLimitedEditor()) { //ensure card removed from sideboard before adding to main
|
||||||
parentScreen.getSideboardPage().removeCard(card, result);
|
parentScreen.getSideboardPage().removeCard(card, result);
|
||||||
}
|
}
|
||||||
|
else if (parentScreen.getEditorType() == EditorType.Quest) {
|
||||||
|
parentScreen.getCatalogPage().removeCard(card, result);
|
||||||
|
}
|
||||||
addCard(card, result);
|
addCard(card, result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1022,6 +1033,9 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
if (parentScreen.isLimitedEditor()) { //ensure card removed from main deck before adding to sideboard
|
if (parentScreen.isLimitedEditor()) { //ensure card removed from main deck before adding to sideboard
|
||||||
parentScreen.getMainDeckPage().removeCard(card, result);
|
parentScreen.getMainDeckPage().removeCard(card, result);
|
||||||
}
|
}
|
||||||
|
else if (parentScreen.getEditorType() == EditorType.Quest) {
|
||||||
|
parentScreen.getCatalogPage().removeCard(card, result);
|
||||||
|
}
|
||||||
addCard(card, result);
|
addCard(card, result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user