|
|
|
|
@@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.Array;
|
|
|
|
|
import com.badlogic.gdx.utils.Null;
|
|
|
|
|
import com.github.tommyettinger.textra.TextraLabel;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
|
|
import forge.Forge;
|
|
|
|
|
import forge.adventure.data.*;
|
|
|
|
|
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
|
|
|
|
@@ -130,7 +131,6 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
AdventureQuestController.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public AdventurePlayer current() {
|
|
|
|
|
return WorldSave.getCurrentSave().getPlayer();
|
|
|
|
|
}
|
|
|
|
|
@@ -151,7 +151,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
cards.addAllFlat(deck.getAllCardsInASinglePool().toFlatList());
|
|
|
|
|
|
|
|
|
|
this.difficultyData.startingLife = difficultyData.startingLife;
|
|
|
|
|
this.difficultyData.staringMoney = difficultyData.staringMoney;
|
|
|
|
|
this.difficultyData.startingMoney = difficultyData.startingMoney;
|
|
|
|
|
this.difficultyData.startingDifficulty = difficultyData.startingDifficulty;
|
|
|
|
|
this.difficultyData.name = difficultyData.name;
|
|
|
|
|
this.difficultyData.spawnRank = difficultyData.spawnRank;
|
|
|
|
|
@@ -161,7 +161,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
this.difficultyData.goldLoss = difficultyData.goldLoss;
|
|
|
|
|
this.difficultyData.lifeLoss = difficultyData.lifeLoss;
|
|
|
|
|
|
|
|
|
|
gold = difficultyData.staringMoney;
|
|
|
|
|
gold = difficultyData.startingMoney;
|
|
|
|
|
name = n;
|
|
|
|
|
heroRace = race;
|
|
|
|
|
avatarIndex = avatar;
|
|
|
|
|
@@ -190,7 +190,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
maxLife = diff.startingLife;
|
|
|
|
|
this.difficultyData.startingShards = diff.startingShards;
|
|
|
|
|
this.difficultyData.startingLife = diff.startingLife;
|
|
|
|
|
this.difficultyData.staringMoney = diff.staringMoney;
|
|
|
|
|
this.difficultyData.startingMoney = diff.startingMoney;
|
|
|
|
|
this.difficultyData.startingDifficulty = diff.startingDifficulty;
|
|
|
|
|
this.difficultyData.name = diff.name;
|
|
|
|
|
this.difficultyData.spawnRank = diff.spawnRank;
|
|
|
|
|
@@ -303,7 +303,12 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
clear(); // Reset player data.
|
|
|
|
|
this.statistic.load(data.readSubData("statistic"));
|
|
|
|
|
this.difficultyData.startingLife = data.readInt("startingLife");
|
|
|
|
|
this.difficultyData.staringMoney = data.readInt("staringMoney");
|
|
|
|
|
// Support for old typo
|
|
|
|
|
if (data.containsKey("staringMoney")) {
|
|
|
|
|
this.difficultyData.startingMoney = data.readInt("staringMoney");
|
|
|
|
|
} else {
|
|
|
|
|
this.difficultyData.startingMoney = data.readInt("startingMoney");
|
|
|
|
|
}
|
|
|
|
|
this.difficultyData.startingDifficulty = data.readBool("startingDifficulty");
|
|
|
|
|
this.difficultyData.name = data.readString("difficultyName");
|
|
|
|
|
this.difficultyData.enemyLifeFactor = data.readFloat("enemyLifeFactor");
|
|
|
|
|
@@ -379,7 +384,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
else {
|
|
|
|
|
System.err.printf("Cannot find item name %s\n", i);
|
|
|
|
|
// Allow official© permission for the player to get a refund. We will allow it this time.
|
|
|
|
|
//TODoooo: Divine retribution if the player refunds too much. Use the orbital laser cannon.
|
|
|
|
|
// TODO: Divine retribution if the player refunds too much. Use the orbital laser cannon.
|
|
|
|
|
System.out.println("Developers have blessed you! You are allowed to cheat the cost of the item back!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -389,7 +394,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
String[] items = (String[]) data.readObject("equippedItems");
|
|
|
|
|
|
|
|
|
|
assert (slots.length == items.length);
|
|
|
|
|
//Like above, prevent items with wrong names. If it triggered in inventory it'll trigger here as well.
|
|
|
|
|
// Prevent items with wrong names. If it triggered in inventory, it'll trigger here as well.
|
|
|
|
|
for (int i = 0; i < slots.length; i++) {
|
|
|
|
|
if (ItemData.getItem(items[i]) != null)
|
|
|
|
|
equippedItems.put(slots[i], items[i]);
|
|
|
|
|
@@ -454,15 +459,15 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load decks
|
|
|
|
|
// check if this save has dynamic deck count, use set-count load if not
|
|
|
|
|
// Load decks
|
|
|
|
|
// Check if this save has dynamic deck count, use set-count load if not
|
|
|
|
|
boolean hasDynamicDeckCount = data.containsKey("deckCount");
|
|
|
|
|
if (hasDynamicDeckCount) {
|
|
|
|
|
int dynamicDeckCount = data.readInt("deckCount");
|
|
|
|
|
// in case the save had previously saved more decks than the current version allows (in case of the max being lowered)
|
|
|
|
|
// In case the save had previously saved more decks than the current version allows (in case of the max being lowered)
|
|
|
|
|
dynamicDeckCount = Math.min(MAX_DECK_COUNT, dynamicDeckCount);
|
|
|
|
|
for (int i = 0; i < dynamicDeckCount; i++){
|
|
|
|
|
// the first x elements are pre-created
|
|
|
|
|
// The first x elements are pre-created
|
|
|
|
|
if (i < MIN_DECK_COUNT) {
|
|
|
|
|
decks.set(i, new Deck(data.readString("deck_name_" + i)));
|
|
|
|
|
}
|
|
|
|
|
@@ -473,11 +478,11 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
if (data.containsKey("sideBoardCards_" + i))
|
|
|
|
|
decks.get(i).getOrCreate(DeckSection.Sideboard).addAll(CardPool.fromCardList(Lists.newArrayList((String[]) data.readObject("sideBoardCards_" + i))));
|
|
|
|
|
}
|
|
|
|
|
// in case we allow removing decks from the deck selection GUI, populate up to the minimum
|
|
|
|
|
// In case we allow removing decks from the deck selection GUI, populate up to the minimum
|
|
|
|
|
for (int i = dynamicDeckCount++; i < MIN_DECK_COUNT; i++) {
|
|
|
|
|
decks.set(i, new Deck(Forge.getLocalizer().getMessage("lblEmptyDeck")));
|
|
|
|
|
}
|
|
|
|
|
// legacy load
|
|
|
|
|
// Legacy load
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < MIN_DECK_COUNT; i++) {
|
|
|
|
|
if (!data.containsKey("deck_name_" + i)) {
|
|
|
|
|
@@ -565,7 +570,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|
|
|
|
|
|
|
|
|
data.store("statistic", this.statistic.save());
|
|
|
|
|
data.store("startingLife", this.difficultyData.startingLife);
|
|
|
|
|
data.store("staringMoney", this.difficultyData.staringMoney);
|
|
|
|
|
data.store("startingMoney", this.difficultyData.startingMoney);
|
|
|
|
|
data.store("startingDifficulty", this.difficultyData.startingDifficulty);
|
|
|
|
|
data.store("difficultyName", this.difficultyData.name);
|
|
|
|
|
data.store("enemyLifeFactor", this.difficultyData.enemyLifeFactor);
|
|
|
|
|
|