Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions forge-gui-mobile/src/forge/adventure/data/SettingData.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public class SettingData {
public boolean useAllCardVariants;
public boolean excludeAlchemyVariants;
public boolean generateLDADecks;
public boolean bindEquipmentLoadoutsToDecks;
}
71 changes: 70 additions & 1 deletion forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
private final ArrayList<ItemData> inventoryItems = new ArrayList<>();
private final Array<Deck> boostersOwned = new Array<>();
private final HashMap<String, Long> equippedItems = new HashMap<>();
private final HashMap<Integer, HashMap<String, Long>> deckLoadouts = new HashMap<>();
private final List<AdventureQuestData> quests = new ArrayList<>();
private final List<AdventureEventData> events = new ArrayList<>();
private final Set<PaperCard> unsupportedCards = new HashSet<>();
Expand Down Expand Up @@ -199,7 +200,39 @@ public void create(String n, Deck startingDeck, boolean male, int race, int avat
}

public void setSelectedDeckSlot(int slot) {
setSelectedDeckSlot(slot, true);
}

public void setSelectedDeckSlot(int slot, boolean switchLoadout) {
if (slot >= 0 && slot < getDeckCount()) {
boolean bindLoadouts = Config.instance().getSettingData().bindEquipmentLoadoutsToDecks;
if (switchLoadout && bindLoadouts && slot != selectedDeckIndex) {
// Save current loadout to old deck
deckLoadouts.put(selectedDeckIndex, new HashMap<>(equippedItems));

// Clear current equipment
for (ItemData item : inventoryItems) {
if (item != null) {
item.isEquipped = false;
}
}
equippedItems.clear();

// Restore loadout for new deck (if any)
if (deckLoadouts.containsKey(slot)) {
HashMap<String, Long> newLoadout = deckLoadouts.get(slot);
for (Map.Entry<String, Long> entry : newLoadout.entrySet()) {
ItemData item = getItemFromInventory(entry.getValue());
if (item != null) {
item.isEquipped = true;
equippedItems.put(entry.getKey(), entry.getValue());
}
}
}

onEquipmentChange.emit();
}

selectedDeckIndex = slot;
deck = decks.get(selectedDeckIndex);
setColorIdentity(DeckProxy.getColorIdentity(deck));
Expand Down Expand Up @@ -630,7 +663,25 @@ public void load(SaveFileData data) {
}
}

setSelectedDeckSlot(data.readInt("selectedDeckIndex"));
// Load deck loadouts (equipment tied to each deck)
for (int i = 0; i < getDeckCount(); i++) {
if (data.containsKey("deckLoadout_slots_" + i) && data.containsKey("deckLoadout_items_" + i)) {
try {
String[] loadoutSlots = (String[]) data.readObject("deckLoadout_slots_" + i);
Long[] loadoutItems = (Long[]) data.readObject("deckLoadout_items_" + i);
if (loadoutSlots.length == loadoutItems.length) {
HashMap<String, Long> loadout = new HashMap<>();
for (int j = 0; j < loadoutSlots.length; j++) {
loadout.put(loadoutSlots[j], loadoutItems[j]);
}
deckLoadouts.put(i, loadout);
}
} catch (Exception ignored) {}
}
}

// Use false to skip loadout switching during load (equippedItems already loaded correctly above)
setSelectedDeckSlot(data.readInt("selectedDeckIndex"), false);
CardPool cardPool = CardPool.fromCardList(Lists.newArrayList((String[]) data.readObject("cards")));
cards.addAll(cardPool.getFilteredPool(isValid));
unsupportedCards.addAll(cardPool.getFilteredPool(isUnsupported).toFlatList());
Expand Down Expand Up @@ -823,6 +874,24 @@ public SaveFileData save() {
if (decks.get(i).get(DeckSection.Commander) != null)
data.storeObject("commanderCards_" + i, decks.get(i).get(DeckSection.Commander).toCardList("\n").split("\n"));
}

// Save deck loadouts (equipment tied to each deck)
// First, save current equipment to current deck's loadout
deckLoadouts.put(selectedDeckIndex, new HashMap<>(equippedItems));
for (int i = 0; i < getDeckCount(); i++) {
if (deckLoadouts.containsKey(i)) {
HashMap<String, Long> loadout = deckLoadouts.get(i);
ArrayList<String> loadoutSlots = new ArrayList<>();
ArrayList<Long> loadoutItems = new ArrayList<>();
for (Map.Entry<String, Long> entry : loadout.entrySet()) {
loadoutSlots.add(entry.getKey());
loadoutItems.add(entry.getValue());
}
data.storeObject("deckLoadout_slots_" + i, loadoutSlots.toArray(new String[0]));
data.storeObject("deckLoadout_items_" + i, loadoutItems.toArray(new Long[0]));
}
}

data.store("selectedDeckIndex", selectedDeckIndex);
data.storeObject("cards", cards.toCardList("\n").split("\n"));

Expand Down
7 changes: 7 additions & 0 deletions forge-gui-mobile/src/forge/adventure/scene/SettingsScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ public void changed(ChangeEvent event, Actor actor) {
Config.instance().saveSettings();
}
});
addSettingField(Forge.getLocalizer().getMessage("lblBindEquipmentLoadoutsToDecks"), Config.instance().getSettingData().bindEquipmentLoadoutsToDecks, new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Config.instance().getSettingData().bindEquipmentLoadoutsToDecks = ((CheckBox) actor).isChecked();
Config.instance().saveSettings();
}
});
addCheckBox(Forge.getLocalizer().getMessage("cbAnte"), ForgePreferences.FPref.UI_ANTE);
addCheckBox(Forge.getLocalizer().getMessage("cbAnteMatchRarity"), ForgePreferences.FPref.UI_ANTE_MATCH_RARITY);
addCheckBox(Forge.getLocalizer().getMessage("lblPromptAutoSell"), ForgePreferences.FPref.PROMPT_FOR_AUTOSELL);
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/de-DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3095,6 +3095,7 @@ lblShowShopOverlay=Shop -Artikelname anzeigen
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=Ausrüstung an Decks binden
lblExitToWoldMap=Zurück zur Weltkarte?
lblStartArena=Willst du in die Arena gehen?
lblWouldYouLikeDestroy=Möchten Sie {0} zerstören?
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3173,6 +3173,7 @@ lblShowShopOverlay=Display Shop Item names
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=Bind equipment loadouts to decks
lblExitToWoldMap=Exit to the World Map?
lblStartArena=Do you want to go into the Arena?
lblWouldYouLikeDestroy=Would you like to destroy {0}?
Expand Down
3 changes: 2 additions & 1 deletion forge-gui/res/languages/es-ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3083,6 +3083,7 @@ lblShowShopOverlay=Nombre del artículo de la tienda de exhibición
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=Vincular equipamiento a mazos
lblExitToWoldMap=Salir al mapa del mundo?
lblStartArena=¿Quieres ir a la arena?
lblWouldYouLikeDestroy=¿Le gustaría destruir {0}?
Expand Down Expand Up @@ -3518,7 +3519,7 @@ lblDeclareBlockersForCard=Declarar bloqueadores para tarjeta
lblBlockWithCard=Bloquear con tarjeta
lblPayManaWithCard=Pagar mana con tarjeta
lblAll=TODO
lblMine=M�o
lblMine=M�o
lblSelectRewards=Seleccionar {0} recompensas
lblDefaultCollection=Colecciones predeterminadas
lblSellable=Vendible
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/fr-FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3077,6 +3077,7 @@ lblShowShopOverlay=Nom de l'article de la boutique d'affichage
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=Lier l'équipement aux decks
lblExitToWoldMap=Sortir sur la carte du monde?
lblStartArena=Voulez-vous entrer dans l'arène?
lblWouldYouLikeDestroy=Souhaitez-vous détruire {0}?
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/it-IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,7 @@ lblShowShopOverlay=Visualizza il nome dell'articolo del negozio
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=Associa equipaggiamento ai mazzi
lblExitToWoldMap=Esci alla mappa del mondo?
lblStartArena=Vuoi andare nell'arena?
lblWouldYouLikeDestroy=Vorresti distruggere {0}?
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/ja-JP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3071,6 +3071,7 @@ lblShowShopOverlay=ショップアイテム名を表示します
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=装備をデッキに紐付ける
lblExitToWoldMap=世界地図に終了しますか?
lblStartArena=アリーナに行きたいですか?
lblWouldYouLikeDestroy={0}を破壊しますか?
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/pt-BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3160,6 +3160,7 @@ lblDisableNotForSaleOverlay=Disable Not For Sale Overlay
lblUseAllCardVariants=Use Card Variants from All Sets (Restart Required)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=Generate Archetype Decks instead of Genetic AI Decks
lblBindEquipmentLoadoutsToDecks=Vincular equipamentos aos decks
lblExitToWoldMap=Sair para o mapa do mundo?
lblStartArena=Você quer entrar na arena?
lblWouldYouLikeDestroy=Você gostaria de destruir {0}?
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/zh-CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,7 @@ lblDisableNotForSaleOverlay=Disable Not For Sale Overlay
lblUseAllCardVariants=使用来自所有系列的牌张重印版(这需要重新启动)
lblExcludeAlchemyVariants=Exclude variants rebalanced for Arena's Alchemy and Historic formats
lblGenerateLDADecks=生成原型套牌而不是由AI生成的套牌
lblBindEquipmentLoadoutsToDecks=将装备配置绑定到套牌
lblExitToWoldMap=退出世界地图?
lblStartArena=您想进入竞技场吗?
lblWouldYouLikeDestroy=您想销毁{0}吗?
Expand Down