mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Pets and plant are loaded from text files.
Card creation is an issue now.
This commit is contained in:
51
.gitattributes
vendored
51
.gitattributes
vendored
@@ -11678,42 +11678,37 @@ src/main/java/forge/properties/Preferences.java svneol=native#text/plain
|
|||||||
src/main/java/forge/properties/SavePreferencesListener.java svneol=native#text/plain
|
src/main/java/forge/properties/SavePreferencesListener.java svneol=native#text/plain
|
||||||
src/main/java/forge/properties/package-info.java svneol=native#text/plain
|
src/main/java/forge/properties/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/BoosterUtils.java svneol=native#text/plain
|
src/main/java/forge/quest/BoosterUtils.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/QuestChallenge.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/QuestController.java -text
|
src/main/java/forge/quest/QuestController.java -text
|
||||||
src/main/java/forge/quest/QuestDeckMap.java -text
|
src/main/java/forge/quest/QuestDeckMap.java -text
|
||||||
src/main/java/forge/quest/QuestDuel.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/QuestEvent.java -text
|
src/main/java/forge/quest/QuestEvent.java -text
|
||||||
|
src/main/java/forge/quest/QuestEventChallenge.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/QuestEventDifficulty.java -text
|
||||||
|
src/main/java/forge/quest/QuestEventDuel.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/QuestEventManager.java svneol=native#text/plain
|
src/main/java/forge/quest/QuestEventManager.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/QuestStallManager.java svneol=native#text/plain
|
src/main/java/forge/quest/QuestMode.java -text
|
||||||
|
src/main/java/forge/quest/QuestStartPool.java -text
|
||||||
src/main/java/forge/quest/QuestUtil.java svneol=native#text/plain
|
src/main/java/forge/quest/QuestUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/QuestUtilCards.java -text
|
src/main/java/forge/quest/QuestUtilCards.java -text
|
||||||
src/main/java/forge/quest/SellRules.java -text
|
src/main/java/forge/quest/SellRules.java -text
|
||||||
|
src/main/java/forge/quest/bazaar/IQuestBazaarItem.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/QuestBazaarManager.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/QuestItemBasic.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/QuestItemElixir.java -text
|
||||||
|
src/main/java/forge/quest/bazaar/QuestItemEstates.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/QuestItemPoundFlesh.java -text
|
||||||
|
src/main/java/forge/quest/bazaar/QuestItemType.java -text
|
||||||
|
src/main/java/forge/quest/bazaar/QuestItemZeppelin.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/QuestPetController.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/QuestPetStats.java -text
|
||||||
|
src/main/java/forge/quest/bazaar/QuestPetStorage.java -text
|
||||||
|
src/main/java/forge/quest/bazaar/QuestStallDefinition.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/bazaar/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestAchievements.java -text
|
src/main/java/forge/quest/data/QuestAchievements.java -text
|
||||||
src/main/java/forge/quest/data/QuestAssets.java -text
|
src/main/java/forge/quest/data/QuestAssets.java -text
|
||||||
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestDuelDifficulty.java -text
|
|
||||||
src/main/java/forge/quest/data/QuestItemCondition.java -text
|
src/main/java/forge/quest/data/QuestItemCondition.java -text
|
||||||
src/main/java/forge/quest/data/QuestMode.java -text
|
|
||||||
src/main/java/forge/quest/data/QuestPreferences.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestPreferences.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestStallDefinition.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/QuestStartPool.java -text
|
|
||||||
src/main/java/forge/quest/data/item/IQuestStallPurchasable.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/item/QuestItemElixir.java -text
|
|
||||||
src/main/java/forge/quest/data/item/QuestItemEstates.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/item/QuestItemPassive.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/item/QuestItemPoundFlesh.java -text
|
|
||||||
src/main/java/forge/quest/data/item/QuestItemType.java -text
|
|
||||||
src/main/java/forge/quest/data/item/QuestItemZeppelin.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/item/package-info.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/package-info.java svneol=native#text/plain
|
src/main/java/forge/quest/data/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/pet/QuestPetAbstract.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/QuestPetBird.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/QuestPetCrocodile.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/QuestPetHound.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/QuestPetManager.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/QuestPetPlant.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/QuestPetWolf.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/pet/package-info.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/io/PreconReader.java -text
|
src/main/java/forge/quest/io/PreconReader.java -text
|
||||||
src/main/java/forge/quest/io/QuestDataIO.java svneol=native#text/plain
|
src/main/java/forge/quest/io/QuestDataIO.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/io/ReadPriceList.java svneol=native#text/plain
|
src/main/java/forge/quest/io/ReadPriceList.java svneol=native#text/plain
|
||||||
@@ -11731,6 +11726,9 @@ src/main/java/forge/util/IItemSerializer.java -text
|
|||||||
src/main/java/forge/util/IStorage.java -text
|
src/main/java/forge/util/IStorage.java -text
|
||||||
src/main/java/forge/util/IStorageView.java -text
|
src/main/java/forge/util/IStorageView.java -text
|
||||||
src/main/java/forge/util/IgnoringXStream.java -text
|
src/main/java/forge/util/IgnoringXStream.java -text
|
||||||
|
src/main/java/forge/util/Lambda.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/util/Lambda0.java -text
|
||||||
|
src/main/java/forge/util/Lambda1.java svneol=native#text/plain
|
||||||
src/main/java/forge/util/LineReader.java -text
|
src/main/java/forge/util/LineReader.java -text
|
||||||
src/main/java/forge/util/MyRandom.java svneol=native#text/plain
|
src/main/java/forge/util/MyRandom.java svneol=native#text/plain
|
||||||
src/main/java/forge/util/Predicate.java -text
|
src/main/java/forge/util/Predicate.java -text
|
||||||
@@ -11772,13 +11770,6 @@ src/main/java/net/slightlymagic/braids/util/generator/FindNonDirectoriesSkipDotD
|
|||||||
src/main/java/net/slightlymagic/braids/util/generator/GeneratorFromArray.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/generator/GeneratorFromArray.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/generator/GeneratorFunctions.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/generator/GeneratorFunctions.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/generator/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/generator/package-info.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda0.java -text
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda1.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda2.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda3.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Thunk.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/package-info.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/package-info.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.slightlymagic.braids.util.UtilFunctions;
|
import net.slightlymagic.braids.util.UtilFunctions;
|
||||||
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
|
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import com.google.code.jyield.Generator;
|
import com.google.code.jyield.Generator;
|
||||||
|
|
||||||
import forge.card.EditionInfo;
|
import forge.card.EditionInfo;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.StringTokenizer;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
|
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import com.google.code.jyield.Generator;
|
import com.google.code.jyield.Generator;
|
||||||
import com.google.code.jyield.YieldUtils;
|
import com.google.code.jyield.YieldUtils;
|
||||||
@@ -34,6 +33,7 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.error.ErrorViewer;
|
import forge.error.ErrorViewer;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package forge.card;
|
|||||||
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
import forge.util.StorageReaderFile;
|
import forge.util.StorageReaderFile;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class BoosterData.
|
* The Class BoosterData.
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ package forge.card;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
import forge.util.StorageReaderFile;
|
import forge.util.StorageReaderFile;
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package forge.card;
|
package forge.card;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.game.GameFormat;
|
import forge.game.GameFormat;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
import forge.util.StorageReaderFile;
|
import forge.util.StorageReaderFile;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package forge.card;
|
package forge.card;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.StorageReaderFile;
|
import forge.util.StorageReaderFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package forge.card;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -450,20 +450,9 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getCard2.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param cardName
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @param owner
|
|
||||||
* a {@link forge.Player} object.
|
|
||||||
* @return a {@link forge.Card} object.
|
|
||||||
*/
|
|
||||||
protected Card getCard2(final String cardName, final Player owner) {
|
protected Card getCard2(final String cardName, final Player owner) {
|
||||||
// o should be Card object
|
// o should be Card object
|
||||||
final Object o = this.map.get(cardName);
|
final Card o = this.map.get(cardName);
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("CardFactory : getCard() invalid card name - ").append(cardName);
|
sb.append("CardFactory : getCard() invalid card name - ").append(cardName);
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ public interface CardFactoryInterface extends Iterable<Card> {
|
|||||||
* blankCard
|
* blankCard
|
||||||
*/
|
*/
|
||||||
Card getCard(String cardName, Player owner);
|
Card getCard(String cardName, Player owner);
|
||||||
|
//Card getCard2(final String cardName, final Card o, final Player owner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a random combination of cards without any duplicates.
|
* Fetch a random combination of cards without any duplicates.
|
||||||
|
|||||||
@@ -4089,7 +4089,7 @@ public class CardFactoryUtil {
|
|||||||
* a {@link java.lang.Object} object.
|
* a {@link java.lang.Object} object.
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public static Card copyStats(final Object o) {
|
public static Card copyStats(final Card o) {
|
||||||
final Card sim = (Card) o;
|
final Card sim = (Card) o;
|
||||||
final Card c = new Card();
|
final Card c = new Card();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import javax.swing.SwingUtilities;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.quest.QuestStallManager;
|
import forge.quest.bazaar.QuestBazaarManager;
|
||||||
import forge.view.ViewBazaarUI;
|
import forge.view.ViewBazaarUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,14 +19,14 @@ import forge.view.ViewBazaarUI;
|
|||||||
public class ControlBazaarUI {
|
public class ControlBazaarUI {
|
||||||
private final ViewBazaarUI view;
|
private final ViewBazaarUI view;
|
||||||
private final ComponentListener cadResize;
|
private final ComponentListener cadResize;
|
||||||
private final QuestStallManager model;
|
private final QuestBazaarManager model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls top-level instance of bazaar.
|
* Controls top-level instance of bazaar.
|
||||||
* @param v0   {@link forge.view.ViewBazaarUI}
|
* @param v0   {@link forge.view.ViewBazaarUI}
|
||||||
* @param bazaar
|
* @param bazaar
|
||||||
*/
|
*/
|
||||||
public ControlBazaarUI(ViewBazaarUI v0, QuestStallManager bazaar0) {
|
public ControlBazaarUI(ViewBazaarUI v0, QuestBazaarManager bazaar0) {
|
||||||
view = v0;
|
view = v0;
|
||||||
model = bazaar0;
|
model = bazaar0;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import forge.card.abilityfactory.AbilityFactory;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GamePlayerRating;
|
import forge.game.GamePlayerRating;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
import forge.quest.data.item.QuestItemType;
|
import forge.quest.bazaar.QuestItemType;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* InputMulligan class.
|
* InputMulligan class.
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import java.util.Map.Entry;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -39,6 +38,7 @@ import forge.item.CardPrinted;
|
|||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ package forge.deck;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ package forge.game;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import java.util.TreeMap;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.UtilFunctions;
|
import net.slightlymagic.braids.util.UtilFunctions;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
@@ -48,6 +47,7 @@ import forge.properties.ForgeProps;
|
|||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.HttpUtil;
|
import forge.util.HttpUtil;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.util.List;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.UtilFunctions;
|
import net.slightlymagic.braids.util.UtilFunctions;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
@@ -43,6 +42,7 @@ import forge.item.CardDb;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ package forge.gui.deckeditor;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda0;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.deck.DeckBase;
|
import forge.deck.DeckBase;
|
||||||
import forge.util.IStorage;
|
import forge.util.IStorage;
|
||||||
|
import forge.util.Lambda0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import javax.swing.JCheckBox;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda0;
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -51,6 +50,7 @@ import forge.item.CardDb;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
|
import forge.util.Lambda0;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import javax.swing.JCheckBox;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda0;
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckGroup;
|
import forge.deck.DeckGroup;
|
||||||
@@ -49,6 +48,7 @@ import forge.gui.deckeditor.elements.TableView;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.util.IStorage;
|
import forge.util.IStorage;
|
||||||
|
import forge.util.Lambda0;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import java.util.List;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda0;
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -47,6 +46,7 @@ import forge.item.CardPrinted;
|
|||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
|
import forge.util.Lambda0;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
//import forge.quest.data.QuestBoosterPack;
|
//import forge.quest.data.QuestBoosterPack;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package forge.gui.deckeditor;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardColor;
|
import forge.card.CardColor;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
@@ -29,6 +28,7 @@ import forge.card.CardRarity;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.item.InventoryItemFromSet;
|
import forge.item.InventoryItemFromSet;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckBase;
|
import forge.deck.DeckBase;
|
||||||
@@ -55,6 +54,7 @@ import forge.item.PreconDeck;
|
|||||||
import forge.item.TournamentPack;
|
import forge.item.TournamentPack;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
import forge.quest.io.ReadPriceList;
|
import forge.quest.io.ReadPriceList;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import javax.swing.table.TableCellRenderer;
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds single column set up for TableModel. Contains name, width + functions
|
* Holds single column set up for TableModel. Contains name, width + functions
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ package forge.gui.deckeditor.elements;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ import forge.gui.home.EMenuItem;
|
|||||||
import forge.gui.home.ICSubmenu;
|
import forge.gui.home.ICSubmenu;
|
||||||
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.quest.QuestChallenge;
|
import forge.quest.QuestEventChallenge;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
|
import forge.quest.bazaar.QuestPetController;
|
||||||
import forge.view.ViewHomeUI;
|
import forge.view.ViewHomeUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,28 +77,18 @@ public enum CSubmenuChallenges implements ICSubmenu {
|
|||||||
view.getCbPlant().addActionListener(new ActionListener() {
|
view.getCbPlant().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
quest.getAssets().getPetManager().setUsePlant(view.getCbPlant().isSelected());
|
quest.selectPet(0, view.getCbPlant().isSelected() ? "Plant" : null);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.getCbZep().addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
quest.getAssets().getPetManager().setUsePlant(view.getCbZep().isSelected());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.getCbxPet().addActionListener(new ActionListener() {
|
view.getCbxPet().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
final int SLOT = 1;
|
||||||
final int index = view.getCbxPet().getSelectedIndex();
|
final int index = view.getCbxPet().getSelectedIndex();
|
||||||
if (index != -1 && index != 0) {
|
List<QuestPetController> pets = quest.getPetsStorage().getAvaliablePets(SLOT, quest.getAssets());
|
||||||
final String pet = ((String) view.getCbxPet().getSelectedItem());
|
String petName = index <= 0 || index > pets.size() ? null : pets.get(index-1).getName();
|
||||||
quest.getAssets().getPetManager().setSelectedPet(pet.substring(7));
|
quest.selectPet(SLOT, petName);
|
||||||
}
|
|
||||||
else {
|
|
||||||
quest.getAssets().getPetManager().setSelectedPet(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -115,9 +106,9 @@ public enum CSubmenuChallenges implements ICSubmenu {
|
|||||||
view.getLblTitle().setText("Challenges: " + AllZone.getQuest().getRank());
|
view.getLblTitle().setText("Challenges: " + AllZone.getQuest().getRank());
|
||||||
|
|
||||||
view.getPnlChallenges().removeAll();
|
view.getPnlChallenges().removeAll();
|
||||||
final List<QuestChallenge> challenges = AllZone.getQuest().getEventManager().generateChallenges();
|
final List<QuestEventChallenge> challenges = AllZone.getQuest().getEventManager().generateChallenges();
|
||||||
|
|
||||||
for (final QuestChallenge c : challenges) {
|
for (final QuestEventChallenge c : challenges) {
|
||||||
final SelectablePanel temp = new SelectablePanel(c);
|
final SelectablePanel temp = new SelectablePanel(c);
|
||||||
view.getPnlChallenges().add(temp, "w 96%!, h 86px!, gap 2% 0 5px 5px");
|
view.getPnlChallenges().add(temp, "w 96%!, h 86px!, gap 2% 0 5px 5px");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import forge.gui.home.EMenuItem;
|
|||||||
import forge.gui.home.ICSubmenu;
|
import forge.gui.home.ICSubmenu;
|
||||||
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
import forge.quest.QuestDuel;
|
import forge.quest.QuestEventDuel;
|
||||||
|
import forge.quest.bazaar.QuestPetController;
|
||||||
import forge.view.ViewHomeUI;
|
import forge.view.ViewHomeUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,28 +71,18 @@ public enum CSubmenuDuels implements ICSubmenu {
|
|||||||
view.getCbPlant().addActionListener(new ActionListener() {
|
view.getCbPlant().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
quest.getAssets().getPetManager().setUsePlant(view.getCbPlant().isSelected());
|
quest.selectPet(0, view.getCbPlant().isSelected() ? "Plant" : null);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.getCbZep().addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
quest.getAssets().getPetManager().setUsePlant(view.getCbZep().isSelected());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.getCbxPet().addActionListener(new ActionListener() {
|
view.getCbxPet().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
final int SLOT = 1;
|
||||||
final int index = view.getCbxPet().getSelectedIndex();
|
final int index = view.getCbxPet().getSelectedIndex();
|
||||||
if (index != -1 && index != 0) {
|
List<QuestPetController> pets = quest.getPetsStorage().getAvaliablePets(SLOT, quest.getAssets());
|
||||||
final String pet = ((String) view.getCbxPet().getSelectedItem());
|
String petName = index <= 0 || index > pets.size() ? null : pets.get(index-1).getName();
|
||||||
quest.getAssets().getPetManager().setSelectedPet(pet.substring(7));
|
quest.selectPet(SLOT, petName);
|
||||||
}
|
|
||||||
else {
|
|
||||||
quest.getAssets().getPetManager().setSelectedPet(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -109,9 +100,9 @@ public enum CSubmenuDuels implements ICSubmenu {
|
|||||||
view.getLblTitle().setText("Duels: " + AllZone.getQuest().getRank());
|
view.getLblTitle().setText("Duels: " + AllZone.getQuest().getRank());
|
||||||
|
|
||||||
view.getPnlDuels().removeAll();
|
view.getPnlDuels().removeAll();
|
||||||
final List<QuestDuel> duels = AllZone.getQuest().getEventManager().generateDuels();
|
final List<QuestEventDuel> duels = AllZone.getQuest().getEventManager().generateDuels();
|
||||||
|
|
||||||
for (final QuestDuel d : duels) {
|
for (final QuestEventDuel d : duels) {
|
||||||
final SelectablePanel temp = new SelectablePanel(d);
|
final SelectablePanel temp = new SelectablePanel(d);
|
||||||
view.getPnlDuels().add(temp, "w 96%!, h 86px!, gap 2% 0 5px 5px");
|
view.getPnlDuels().add(temp, "w 96%!, h 86px!, gap 2% 0 5px 5px");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import forge.gui.home.ICSubmenu;
|
|||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
|
import forge.quest.QuestMode;
|
||||||
|
import forge.quest.QuestStartPool;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestData;
|
||||||
import forge.quest.data.QuestMode;
|
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.QuestStartPool;
|
|
||||||
import forge.quest.io.QuestDataIO;
|
import forge.quest.io.QuestDataIO;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -21,7 +21,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static forge.quest.data.QuestStartPool.*;
|
import static forge.quest.QuestStartPool.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -16,24 +16,25 @@ import forge.gui.toolbox.FSkin;
|
|||||||
import forge.gui.toolbox.FTextArea;
|
import forge.gui.toolbox.FTextArea;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.QuestChallenge;
|
import forge.quest.QuestEventChallenge;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
import forge.quest.QuestEvent;
|
import forge.quest.QuestEvent;
|
||||||
|
import forge.quest.QuestMode;
|
||||||
import forge.quest.QuestUtil;
|
import forge.quest.QuestUtil;
|
||||||
|
import forge.quest.bazaar.QuestItemType;
|
||||||
|
import forge.quest.bazaar.QuestPetController;
|
||||||
import forge.quest.data.QuestAchievements;
|
import forge.quest.data.QuestAchievements;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestMode;
|
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.item.QuestItemType;
|
|
||||||
import forge.quest.data.pet.QuestPetAbstract;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.List;
|
||||||
|
|
||||||
import static forge.quest.QuestEvent.QuestEventType.CHALLENGE;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.SwingWorker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for the quest submenu, all over the MVC spectrum.
|
* Utilities for the quest submenu, all over the MVC spectrum.
|
||||||
@@ -66,11 +67,47 @@ public class SubmenuQuestUtil {
|
|||||||
return (delta > 0) ? delta : 0;
|
return (delta > 0) ? delta : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updatePlantAndPetForView(final IStatsAndPet view, final QuestController qCtrl) {
|
||||||
|
for( int iSlot = 0; iSlot < QuestController.MAX_PET_SLOTS; iSlot++ ) {
|
||||||
|
final List<QuestPetController> petList = qCtrl.getPetsStorage().getAvaliablePets(iSlot, qCtrl.getAssets());
|
||||||
|
final String currentPetName = qCtrl.getSelectedPet(iSlot);
|
||||||
|
|
||||||
|
if ( iSlot == 0 ) { // Plant visiblity
|
||||||
|
if (petList.isEmpty()) {
|
||||||
|
view.getCbPlant().setVisible(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
view.getCbPlant().setVisible(true);
|
||||||
|
view.getCbPlant().setSelected(qCtrl.getSelectedPet(iSlot) != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( iSlot == 1 ) {
|
||||||
|
view.getCbxPet().removeAllItems();
|
||||||
|
// Pet list visibility
|
||||||
|
if (petList.size() > 0) {
|
||||||
|
view.getCbxPet().setEnabled(true);
|
||||||
|
view.getCbxPet().addItem("Don't summon a pet");
|
||||||
|
|
||||||
|
for (final QuestPetController pet : petList) {
|
||||||
|
String name = "Summon " + pet.getName();
|
||||||
|
view.getCbxPet().addItem(name);
|
||||||
|
if ( pet.getName().equals(currentPetName) )
|
||||||
|
view.getCbxPet().setSelectedItem(name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
view.getCbxPet().setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
view.getCbZep().setVisible(qCtrl.getAssets().hasItem(QuestItemType.ZEPPELIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Updates stats, pets panels for both duels and challenges. */
|
/** Updates stats, pets panels for both duels and challenges. */
|
||||||
public static void updateStatsAndPet() {
|
public static void updateStatsAndPet() {
|
||||||
final QuestController qData = AllZone.getQuest();
|
final QuestController qCtrl = AllZone.getQuest();
|
||||||
final QuestAchievements qA = qData.getAchievements();
|
final QuestAchievements qA = qCtrl.getAchievements();
|
||||||
final QuestAssets qS = qData.getAssets();
|
final QuestAssets qS = qCtrl.getAssets();
|
||||||
|
|
||||||
if (qA == null) { return; }
|
if (qA == null) { return; }
|
||||||
|
|
||||||
@@ -88,7 +125,7 @@ public class SubmenuQuestUtil {
|
|||||||
|
|
||||||
// Stats panel
|
// Stats panel
|
||||||
view.getLblCredits().setText("Credits: " + qS.getCredits());
|
view.getLblCredits().setText("Credits: " + qS.getCredits());
|
||||||
view.getLblLife().setText("Life: " + qS.getLife(qData.getMode()));
|
view.getLblLife().setText("Life: " + qS.getLife(qCtrl.getMode()));
|
||||||
view.getLblWins().setText("Wins: " + qA.getWin());
|
view.getLblWins().setText("Wins: " + qA.getWin());
|
||||||
view.getLblLosses().setText("Losses: " + qA.getLost());
|
view.getLblLosses().setText("Losses: " + qA.getLost());
|
||||||
view.updateCurrentDeckStatus();
|
view.updateCurrentDeckStatus();
|
||||||
@@ -106,34 +143,8 @@ public class SubmenuQuestUtil {
|
|||||||
+ " (Best:" + qA.getWinStreakBest() + ")");
|
+ " (Best:" + qA.getWinStreakBest() + ")");
|
||||||
|
|
||||||
// Start panel: pet, plant, zep.
|
// Start panel: pet, plant, zep.
|
||||||
if (qData.getMode() == QuestMode.Fantasy) {
|
if (qCtrl.getMode() == QuestMode.Fantasy) {
|
||||||
final Set<String> petList = qS.getPetManager().getAvailablePetNames();
|
updatePlantAndPetForView(view, qCtrl);
|
||||||
final QuestPetAbstract currentPet = qS.getPetManager().getSelectedPet();
|
|
||||||
|
|
||||||
view.getCbxPet().removeAllItems();
|
|
||||||
// Pet list visibility
|
|
||||||
if (petList.size() > 0) {
|
|
||||||
view.getCbxPet().setEnabled(true);
|
|
||||||
view.getCbxPet().addItem("Don't summon a pet");
|
|
||||||
for (final String pet : petList) {
|
|
||||||
view.getCbxPet().addItem("Summon " + pet);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentPet != null) { view.getCbxPet().setSelectedItem("Summon " + currentPet.getName()); }
|
|
||||||
} else {
|
|
||||||
view.getCbxPet().setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plant visiblity
|
|
||||||
if (qS.getPetManager().getPlant().getLevel() == 0) {
|
|
||||||
view.getCbPlant().setVisible(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
view.getCbPlant().setVisible(true);
|
|
||||||
view.getCbPlant().setSelected(qS.getPetManager().shouldPlantBeUsed());
|
|
||||||
}
|
|
||||||
|
|
||||||
view.getCbZep().setVisible(qS.hasItem(QuestItemType.ZEPPELIN));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Classic mode display changes
|
// Classic mode display changes
|
||||||
@@ -215,8 +226,8 @@ public class SubmenuQuestUtil {
|
|||||||
int baseLifeHuman = qData.getAssets().getLife(qData.getMode());
|
int baseLifeHuman = qData.getAssets().getLife(qData.getMode());
|
||||||
int extraLifeHuman = 0;
|
int extraLifeHuman = 0;
|
||||||
|
|
||||||
if (selectedOpponent.getEvent().getEventType() == CHALLENGE) {
|
if (selectedOpponent.getEvent() instanceof QuestEventChallenge) {
|
||||||
lifeAI = ((QuestChallenge) event).getAILife();
|
lifeAI = ((QuestEventChallenge) event).getAILife();
|
||||||
|
|
||||||
if (qData.getAssets().hasItem(QuestItemType.ZEPPELIN)
|
if (qData.getAssets().hasItem(QuestItemType.ZEPPELIN)
|
||||||
&& VSubmenuChallenges.SINGLETON_INSTANCE.getCbZep().isSelected()) {
|
&& VSubmenuChallenges.SINGLETON_INSTANCE.getCbZep().isSelected()) {
|
||||||
@@ -227,7 +238,7 @@ public class SubmenuQuestUtil {
|
|||||||
GameNew.newGame(
|
GameNew.newGame(
|
||||||
Constant.Runtime.HUMAN_DECK[0],
|
Constant.Runtime.HUMAN_DECK[0],
|
||||||
Constant.Runtime.COMPUTER_DECK[0],
|
Constant.Runtime.COMPUTER_DECK[0],
|
||||||
QuestUtil.getHumanStartingCards(qData.getAssets(), event),
|
QuestUtil.getHumanStartingCards(qData, event),
|
||||||
QuestUtil.getComputerStartingCards(event),
|
QuestUtil.getComputerStartingCards(event),
|
||||||
baseLifeHuman + extraLifeHuman,
|
baseLifeHuman + extraLifeHuman,
|
||||||
lifeAI,
|
lifeAI,
|
||||||
@@ -295,10 +306,10 @@ public class SubmenuQuestUtil {
|
|||||||
|
|
||||||
// Name
|
// Name
|
||||||
final FLabel lblName = new FLabel.Builder().hoverable(false).build();
|
final FLabel lblName = new FLabel.Builder().hoverable(false).build();
|
||||||
if (event.getEventType() == CHALLENGE) {
|
if (event instanceof QuestEventChallenge) {
|
||||||
lblName.setText(event.getTitle() + ": "
|
lblName.setText(event.getTitle() + ": "
|
||||||
+ StringUtils.capitalize(event.getDifficulty())
|
+ StringUtils.capitalize(event.getDifficulty())
|
||||||
+ (((QuestChallenge) event).isRepeatable() ? ", Repeatable" : ""));
|
+ (((QuestEventChallenge) event).isRepeatable() ? ", Repeatable" : ""));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lblName.setText(event.getTitle() + ": "
|
lblName.setText(event.getTitle() + ": "
|
||||||
|
|||||||
@@ -18,11 +18,11 @@
|
|||||||
package forge.item;
|
package forge.item;
|
||||||
|
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.ImageCache;
|
import forge.ImageCache;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterData;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Write javadoc for this type.
|
* TODO Write javadoc for this type.
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
@@ -35,6 +34,7 @@ import forge.Singletons;
|
|||||||
import forge.card.CardInSet;
|
import forge.card.CardInSet;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.card.MtgDataParser;
|
import forge.card.MtgDataParser;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package forge.item;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
@@ -30,6 +29,7 @@ import forge.CardUtil;
|
|||||||
import forge.Player;
|
import forge.Player;
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
import forge.util.PredicateString;
|
import forge.util.PredicateString;
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ package forge.item;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.ImageCache;
|
import forge.ImageCache;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.FatPackData;
|
import forge.card.FatPackData;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Write javadoc for this type.
|
* TODO Write javadoc for this type.
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import forge.ImageCache;
|
import forge.ImageCache;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
@@ -29,6 +28,7 @@ import forge.deck.Deck;
|
|||||||
import forge.quest.SellRules;
|
import forge.quest.SellRules;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ package forge.item;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
import forge.ImageCache;
|
import forge.ImageCache;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterData;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Write javadoc for this type.
|
* TODO Write javadoc for this type.
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public final class NewConstants {
|
|||||||
/** Constant <code>CARD_PICTURES="card-pictures"</code>. */
|
/** Constant <code>CARD_PICTURES="card-pictures"</code>. */
|
||||||
public static final String CARD_PICTURES = "card-pictures";
|
public static final String CARD_PICTURES = "card-pictures";
|
||||||
/** Constant <code>CARD_PICTURES_A="card-pictures_a"</code>. */
|
/** Constant <code>CARD_PICTURES_A="card-pictures_a"</code>. */
|
||||||
|
|
||||||
|
public static final class CardPicturesByLetter {
|
||||||
public static final String CARD_PICTURES_A = "card-pictures_a";
|
public static final String CARD_PICTURES_A = "card-pictures_a";
|
||||||
/** Constant <code>CARD_PICTURES_B="card-pictures_b"</code>. */
|
/** Constant <code>CARD_PICTURES_B="card-pictures_b"</code>. */
|
||||||
public static final String CARD_PICTURES_B = "card-pictures_b";
|
public static final String CARD_PICTURES_B = "card-pictures_b";
|
||||||
@@ -109,6 +111,7 @@ public final class NewConstants {
|
|||||||
public static final String CARD_PICTURES_Y = "card-pictures_y";
|
public static final String CARD_PICTURES_Y = "card-pictures_y";
|
||||||
/** Constant <code>CARD_PICTURES_Z="card-pictures_z"</code>. */
|
/** Constant <code>CARD_PICTURES_Z="card-pictures_z"</code>. */
|
||||||
public static final String CARD_PICTURES_Z = "card-pictures_z";
|
public static final String CARD_PICTURES_Z = "card-pictures_z";
|
||||||
|
}
|
||||||
/** Constant <code>CARD_PICTURES_OTHER="card-pictures_other"</code>. */
|
/** Constant <code>CARD_PICTURES_OTHER="card-pictures_other"</code>. */
|
||||||
public static final String CARD_PICTURES_OTHER = "card-pictures_other";
|
public static final String CARD_PICTURES_OTHER = "card-pictures_other";
|
||||||
/** Constant <code>CARD_PICTURES_TOKEN_HQ="card-pictures_token_hq"</code>. */
|
/** Constant <code>CARD_PICTURES_TOKEN_HQ="card-pictures_token_hq"</code>. */
|
||||||
@@ -220,6 +223,7 @@ public final class NewConstants {
|
|||||||
public static final String PRECONS = "quest/precons-dir";
|
public static final String PRECONS = "quest/precons-dir";
|
||||||
|
|
||||||
public static final String BAZAAR = "quest/bazaar";
|
public static final String BAZAAR = "quest/bazaar";
|
||||||
|
public static final String BAZAAR_DIR = "quest/bazaar-dir";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
|
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
@@ -29,6 +28,7 @@ import forge.card.CardRules;
|
|||||||
import forge.card.UnOpenedProduct;
|
import forge.card.UnOpenedProduct;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.Lambda1;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
package forge.quest;
|
package forge.quest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -26,12 +28,12 @@ import forge.item.CardPrinted;
|
|||||||
import forge.item.PreconDeck;
|
import forge.item.PreconDeck;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.bazaar.QuestBazaarManager;
|
||||||
|
import forge.quest.bazaar.QuestPetStorage;
|
||||||
import forge.quest.data.QuestAchievements;
|
import forge.quest.data.QuestAchievements;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestData;
|
||||||
import forge.quest.data.QuestMode;
|
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.QuestStartPool;
|
|
||||||
import forge.quest.io.PreconReader;
|
import forge.quest.io.PreconReader;
|
||||||
import forge.util.IStorage;
|
import forge.util.IStorage;
|
||||||
import forge.util.IStorageView;
|
import forge.util.IStorageView;
|
||||||
@@ -70,7 +72,9 @@ public class QuestController {
|
|||||||
|
|
||||||
private QuestEventManager eventManager = null;
|
private QuestEventManager eventManager = null;
|
||||||
|
|
||||||
private QuestStallManager bazaar = null;
|
private QuestBazaarManager bazaar = null;
|
||||||
|
|
||||||
|
private QuestPetStorage pets = null;
|
||||||
|
|
||||||
// This is used by shop. Had no idea where else to place this
|
// This is used by shop. Had no idea where else to place this
|
||||||
private static transient IStorageView<PreconDeck> preconManager = new StorageView<PreconDeck>(new PreconReader(
|
private static transient IStorageView<PreconDeck> preconManager = new StorageView<PreconDeck>(new PreconReader(
|
||||||
@@ -88,6 +92,19 @@ public class QuestController {
|
|||||||
"What Do You Do With The Other Hand?", "Freelance Sorcerer, Works Weekends",
|
"What Do You Do With The Other Hand?", "Freelance Sorcerer, Works Weekends",
|
||||||
"Should We Hire Commentators?", "Saltblasted For Your Talent", "Serra Angel Is Your Girlfriend", };
|
"Should We Hire Commentators?", "Saltblasted For Your Talent", "Serra Angel Is Your Girlfriend", };
|
||||||
|
|
||||||
|
public static final int MAX_PET_SLOTS = 2;
|
||||||
|
|
||||||
|
private Map<Integer, String> selectedPets = new HashMap<Integer, String>();
|
||||||
|
|
||||||
|
public void selectPet(Integer slot, String name) {
|
||||||
|
selectedPets.put(slot, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectedPet(Integer slot) {
|
||||||
|
return selectedPets.get(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Cards - class uses data from here
|
// Cards - class uses data from here
|
||||||
/**
|
/**
|
||||||
* Gets the cards.
|
* Gets the cards.
|
||||||
@@ -288,9 +305,9 @@ public class QuestController {
|
|||||||
*
|
*
|
||||||
* @return the bazaar
|
* @return the bazaar
|
||||||
*/
|
*/
|
||||||
public final QuestStallManager getBazaar() {
|
public final QuestBazaarManager getBazaar() {
|
||||||
if (null == this.bazaar) {
|
if (null == this.bazaar) {
|
||||||
this.bazaar = new QuestStallManager(ForgeProps.getFile(NewConstants.Quest.BAZAAR));
|
this.bazaar = new QuestBazaarManager(ForgeProps.getFile(NewConstants.Quest.BAZAAR));
|
||||||
}
|
}
|
||||||
return this.bazaar;
|
return this.bazaar;
|
||||||
}
|
}
|
||||||
@@ -307,4 +324,12 @@ public class QuestController {
|
|||||||
return this.eventManager;
|
return this.eventManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QuestPetStorage getPetsStorage() {
|
||||||
|
if ( this.pets == null ) {
|
||||||
|
this.pets = new QuestPetStorage(ForgeProps.getFile(NewConstants.Quest.BAZAAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.pets;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,7 @@ import forge.deck.Deck;
|
|||||||
* MODEL - A basic event instance in Quest mode. Can be extended for use in
|
* MODEL - A basic event instance in Quest mode. Can be extended for use in
|
||||||
* unique event types: battles, quests, and others.
|
* unique event types: battles, quests, and others.
|
||||||
*/
|
*/
|
||||||
public class QuestEvent {
|
public abstract class QuestEvent {
|
||||||
/** */
|
|
||||||
public enum QuestEventType { /** */
|
|
||||||
DUEL, /** */
|
|
||||||
CHALLENGE
|
|
||||||
}
|
|
||||||
// Default vals if none provided in the event file.
|
// Default vals if none provided in the event file.
|
||||||
/** The event deck. */
|
/** The event deck. */
|
||||||
private Deck eventDeck = null;
|
private Deck eventDeck = null;
|
||||||
@@ -52,9 +47,6 @@ public class QuestEvent {
|
|||||||
/** The name. */
|
/** The name. */
|
||||||
private String name = "Noname";
|
private String name = "Noname";
|
||||||
|
|
||||||
/** The event type. */
|
|
||||||
private QuestEventType eventType = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getTitle.
|
* getTitle.
|
||||||
@@ -99,17 +91,6 @@ public class QuestEvent {
|
|||||||
return this.eventDeck;
|
return this.eventDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getEventDeck.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return {@link forge.deck.Deck}
|
|
||||||
*/
|
|
||||||
public final QuestEventType getEventType() {
|
|
||||||
return this.eventType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getIconFilename.
|
* getIconFilename.
|
||||||
@@ -132,16 +113,6 @@ public class QuestEvent {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the event type.
|
|
||||||
*
|
|
||||||
* @param eventType0
|
|
||||||
* the eventType to set
|
|
||||||
*/
|
|
||||||
public void setEventType(final QuestEventType eventType0) {
|
|
||||||
this.eventType = eventType0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the name.
|
* Sets the name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import forge.item.CardPrinted;
|
|||||||
* quest-specific properties.
|
* quest-specific properties.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QuestChallenge extends QuestEvent {
|
public class QuestEventChallenge extends QuestEvent {
|
||||||
// ID (default -1, should be explicitly set at later time.)
|
// ID (default -1, should be explicitly set at later time.)
|
||||||
/** The id. */
|
/** The id. */
|
||||||
private int id = -1;
|
private int id = -1;
|
||||||
@@ -66,9 +66,8 @@ public class QuestChallenge extends QuestEvent {
|
|||||||
/**
|
/**
|
||||||
* Instantiates a new quest challenge.
|
* Instantiates a new quest challenge.
|
||||||
*/
|
*/
|
||||||
public QuestChallenge() {
|
public QuestEventChallenge() {
|
||||||
super();
|
super();
|
||||||
this.setEventType(QuestEventType.CHALLENGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package forge.quest.data;
|
package forge.quest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum QuestDuelDifficulty {
|
public enum QuestEventDifficulty {
|
||||||
EASY,
|
EASY,
|
||||||
MEDIUM,
|
MEDIUM,
|
||||||
HARD,
|
HARD,
|
||||||
@@ -25,14 +25,13 @@ package forge.quest;
|
|||||||
* MODEL - A single duel event data instance, including meta and deck.
|
* MODEL - A single duel event data instance, including meta and deck.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QuestDuel extends QuestEvent {
|
public class QuestEventDuel extends QuestEvent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest duel.
|
* Instantiates a new quest duel.
|
||||||
*/
|
*/
|
||||||
public QuestDuel() {
|
public QuestEventDuel() {
|
||||||
super();
|
super();
|
||||||
this.setEventType(QuestEventType.DUEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,6 @@ import forge.Singletons;
|
|||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.io.DeckSerializer;
|
import forge.deck.io.DeckSerializer;
|
||||||
import forge.quest.data.QuestAchievements;
|
import forge.quest.data.QuestAchievements;
|
||||||
import forge.quest.data.QuestDuelDifficulty;
|
|
||||||
import forge.quest.data.QuestPreferences;
|
import forge.quest.data.QuestPreferences;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
@@ -46,12 +45,12 @@ import forge.util.FileUtil;
|
|||||||
*/
|
*/
|
||||||
public class QuestEventManager {
|
public class QuestEventManager {
|
||||||
|
|
||||||
private final Map<QuestDuelDifficulty, List<QuestDuel>> SortedDuels = new EnumMap<QuestDuelDifficulty, List<QuestDuel>>(QuestDuelDifficulty.class);
|
private final Map<QuestEventDifficulty, List<QuestEventDuel>> SortedDuels = new EnumMap<QuestEventDifficulty, List<QuestEventDuel>>(QuestEventDifficulty.class);
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public final List<QuestDuel> ALL_DUELS = new ArrayList<QuestDuel>();
|
public final List<QuestEventDuel> ALL_DUELS = new ArrayList<QuestEventDuel>();
|
||||||
/** */
|
/** */
|
||||||
public final List<QuestChallenge> ALL_CHALLENGES = new ArrayList<QuestChallenge>();
|
public final List<QuestEventChallenge> ALL_CHALLENGES = new ArrayList<QuestEventChallenge>();
|
||||||
|
|
||||||
/** Instantiate all events and difficulty lists. */
|
/** Instantiate all events and difficulty lists. */
|
||||||
public QuestEventManager(File dir) {
|
public QuestEventManager(File dir) {
|
||||||
@@ -64,11 +63,11 @@ public class QuestEventManager {
|
|||||||
|
|
||||||
if (contents.containsKey("quest")) {
|
if (contents.containsKey("quest")) {
|
||||||
tempEvent = readChallenge(contents.get("quest"));
|
tempEvent = readChallenge(contents.get("quest"));
|
||||||
ALL_CHALLENGES.add((QuestChallenge) tempEvent);
|
ALL_CHALLENGES.add((QuestEventChallenge) tempEvent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tempEvent = readDuel(contents.get("metadata"));
|
tempEvent = readDuel(contents.get("metadata"));
|
||||||
ALL_DUELS.add((QuestDuel) tempEvent);
|
ALL_DUELS.add((QuestEventDuel) tempEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assemble metadata (may not be necessary later) and deck object.
|
// Assemble metadata (may not be necessary later) and deck object.
|
||||||
@@ -93,7 +92,7 @@ public class QuestEventManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final QuestChallenge q : ALL_CHALLENGES) {
|
for (final QuestEventChallenge q : ALL_CHALLENGES) {
|
||||||
if (q.getName().equals(s0)) {
|
if (q.getName().equals(s0)) {
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
@@ -106,7 +105,7 @@ public class QuestEventManager {
|
|||||||
*
|
*
|
||||||
* @return an array of {@link java.lang.String} objects.
|
* @return an array of {@link java.lang.String} objects.
|
||||||
*/
|
*/
|
||||||
public final List<QuestDuel> generateDuels() {
|
public final List<QuestEventDuel> generateDuels() {
|
||||||
final QuestPreferences qpref = Singletons.getModel().getQuestPreferences();
|
final QuestPreferences qpref = Singletons.getModel().getQuestPreferences();
|
||||||
if (AllZone.getQuest().getAchievements() == null) {
|
if (AllZone.getQuest().getAchievements() == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -116,36 +115,36 @@ public class QuestEventManager {
|
|||||||
final int cntWins = qCtrl.getAchievements().getWin();
|
final int cntWins = qCtrl.getAchievements().getWin();
|
||||||
|
|
||||||
final int index = qCtrl.getAchievements().getDifficulty();
|
final int index = qCtrl.getAchievements().getDifficulty();
|
||||||
final List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
|
final List<QuestEventDuel> duelOpponents = new ArrayList<QuestEventDuel>();
|
||||||
|
|
||||||
if (cntWins < qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
if (cntWins < qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.EASY).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(1));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.EASY).get(1));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(2));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.EASY).get(2));
|
||||||
} else if (cntWins == qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
} else if (cntWins == qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.EASY).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.MEDIUM).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(1));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.MEDIUM).get(1));
|
||||||
} else if (cntWins < qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
} else if (cntWins < qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.MEDIUM).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(1));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.MEDIUM).get(1));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(2));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.MEDIUM).get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cntWins == qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
else if (cntWins == qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.MEDIUM).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(1));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cntWins < qpref.getPreferenceInt(QPref.WINS_EXPERTAI, index)) {
|
else if (cntWins < qpref.getPreferenceInt(QPref.WINS_EXPERTAI, index)) {
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(1));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(1));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(2));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(2));
|
||||||
} else {
|
} else {
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(0));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(1));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.HARD).get(1));
|
||||||
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EXPERT).get(0));
|
duelOpponents.add(SortedDuels.get(QuestEventDifficulty.EXPERT).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return duelOpponents;
|
return duelOpponents;
|
||||||
@@ -155,8 +154,8 @@ public class QuestEventManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.util.List} object.
|
* @return a {@link java.util.List} object.
|
||||||
*/
|
*/
|
||||||
public final List<QuestChallenge> generateChallenges() {
|
public final List<QuestEventChallenge> generateChallenges() {
|
||||||
final List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>();
|
final List<QuestEventChallenge> challengeOpponents = new ArrayList<QuestEventChallenge>();
|
||||||
final QuestController qCtrl = AllZone.getQuest();
|
final QuestController qCtrl = AllZone.getQuest();
|
||||||
final QuestAchievements qData = qCtrl.getAchievements();
|
final QuestAchievements qData = qCtrl.getAchievements();
|
||||||
|
|
||||||
@@ -171,7 +170,7 @@ public class QuestEventManager {
|
|||||||
final List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
|
final List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
|
||||||
final List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
final List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
||||||
|
|
||||||
for (final QuestChallenge qc : ALL_CHALLENGES) {
|
for (final QuestEventChallenge qc : ALL_CHALLENGES) {
|
||||||
if ((qc.getWinsReqd() <= qData.getWin())
|
if ((qc.getWinsReqd() <= qData.getWin())
|
||||||
&& !qData.getCompletedChallenges().contains(qc.getId())) {
|
&& !qData.getCompletedChallenges().contains(qc.getId())) {
|
||||||
unlockedChallengeIds.add(qc.getId());
|
unlockedChallengeIds.add(qc.getId());
|
||||||
@@ -207,8 +206,8 @@ public class QuestEventManager {
|
|||||||
* @param contents
|
* @param contents
|
||||||
* @param qd
|
* @param qd
|
||||||
*/
|
*/
|
||||||
private QuestDuel readDuel(final List<String> contents) {
|
private QuestEventDuel readDuel(final List<String> contents) {
|
||||||
final QuestDuel qd = new QuestDuel();
|
final QuestEventDuel qd = new QuestEventDuel();
|
||||||
int eqpos;
|
int eqpos;
|
||||||
String key, value;
|
String key, value;
|
||||||
|
|
||||||
@@ -240,11 +239,11 @@ public class QuestEventManager {
|
|||||||
* @param contents
|
* @param contents
|
||||||
* @param qc
|
* @param qc
|
||||||
*/
|
*/
|
||||||
private QuestChallenge readChallenge(final List<String> contents) {
|
private QuestEventChallenge readChallenge(final List<String> contents) {
|
||||||
int eqpos;
|
int eqpos;
|
||||||
String key, value;
|
String key, value;
|
||||||
|
|
||||||
final QuestChallenge qc = new QuestChallenge();
|
final QuestEventChallenge qc = new QuestEventChallenge();
|
||||||
// Unique properties
|
// Unique properties
|
||||||
for (final String s : contents) {
|
for (final String s : contents) {
|
||||||
if (StringUtils.isBlank(s)) {
|
if (StringUtils.isBlank(s)) {
|
||||||
@@ -346,23 +345,23 @@ public class QuestEventManager {
|
|||||||
*/
|
*/
|
||||||
private void assembleDuelDifficultyLists() {
|
private void assembleDuelDifficultyLists() {
|
||||||
SortedDuels.clear();
|
SortedDuels.clear();
|
||||||
SortedDuels.put(QuestDuelDifficulty.EASY, new ArrayList<QuestDuel>());
|
SortedDuels.put(QuestEventDifficulty.EASY, new ArrayList<QuestEventDuel>());
|
||||||
SortedDuels.put(QuestDuelDifficulty.MEDIUM, new ArrayList<QuestDuel>());
|
SortedDuels.put(QuestEventDifficulty.MEDIUM, new ArrayList<QuestEventDuel>());
|
||||||
SortedDuels.put(QuestDuelDifficulty.HARD, new ArrayList<QuestDuel>());
|
SortedDuels.put(QuestEventDifficulty.HARD, new ArrayList<QuestEventDuel>());
|
||||||
SortedDuels.put(QuestDuelDifficulty.EXPERT, new ArrayList<QuestDuel>());
|
SortedDuels.put(QuestEventDifficulty.EXPERT, new ArrayList<QuestEventDuel>());
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
for (final QuestDuel qd : ALL_DUELS) {
|
for (final QuestEventDuel qd : ALL_DUELS) {
|
||||||
s = qd.getDifficulty();
|
s = qd.getDifficulty();
|
||||||
if (s.equalsIgnoreCase("easy")) {
|
if (s.equalsIgnoreCase("easy")) {
|
||||||
SortedDuels.get(QuestDuelDifficulty.EASY).add(qd);
|
SortedDuels.get(QuestEventDifficulty.EASY).add(qd);
|
||||||
} else if (s.equalsIgnoreCase("medium")) {
|
} else if (s.equalsIgnoreCase("medium")) {
|
||||||
SortedDuels.get(QuestDuelDifficulty.MEDIUM).add(qd);
|
SortedDuels.get(QuestEventDifficulty.MEDIUM).add(qd);
|
||||||
} else if (s.equalsIgnoreCase("hard")) {
|
} else if (s.equalsIgnoreCase("hard")) {
|
||||||
SortedDuels.get(QuestDuelDifficulty.HARD).add(qd);
|
SortedDuels.get(QuestEventDifficulty.HARD).add(qd);
|
||||||
} else if (s.equalsIgnoreCase("very hard")) {
|
} else if (s.equalsIgnoreCase("very hard")) {
|
||||||
SortedDuels.get(QuestDuelDifficulty.EXPERT).add(qd);
|
SortedDuels.get(QuestEventDifficulty.EXPERT).add(qd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,10 +369,10 @@ public class QuestEventManager {
|
|||||||
public void randomizeOpponents() {
|
public void randomizeOpponents() {
|
||||||
long seed = new Random().nextLong();
|
long seed = new Random().nextLong();
|
||||||
Random r = new Random(seed);
|
Random r = new Random(seed);
|
||||||
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.EASY), r);
|
Collections.shuffle(SortedDuels.get(QuestEventDifficulty.EASY), r);
|
||||||
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.MEDIUM), r);
|
Collections.shuffle(SortedDuels.get(QuestEventDifficulty.MEDIUM), r);
|
||||||
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.HARD), r);
|
Collections.shuffle(SortedDuels.get(QuestEventDifficulty.HARD), r);
|
||||||
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.EXPERT), r);
|
Collections.shuffle(SortedDuels.get(QuestEventDifficulty.EXPERT), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,8 +385,8 @@ public class QuestEventManager {
|
|||||||
* @param n
|
* @param n
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private QuestChallenge getChallengeEventByNumber(final int n) {
|
private QuestEventChallenge getChallengeEventByNumber(final int n) {
|
||||||
for (final QuestChallenge qc : ALL_CHALLENGES) {
|
for (final QuestEventChallenge qc : ALL_CHALLENGES) {
|
||||||
if (qc.getId() == n) {
|
if (qc.getId() == n) {
|
||||||
return qc;
|
return qc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package forge.quest.data;
|
package forge.quest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package forge.quest.data;
|
package forge.quest;
|
||||||
|
|
||||||
public enum QuestStartPool {
|
public enum QuestStartPool {
|
||||||
Complete,
|
Complete,
|
||||||
@@ -22,12 +22,10 @@ import forge.Card;
|
|||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Player;
|
import forge.Player;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.bazaar.QuestPetController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static forge.quest.QuestEvent.QuestEventType.CHALLENGE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* QuestUtil class.
|
* QuestUtil class.
|
||||||
@@ -66,8 +64,8 @@ public class QuestUtil {
|
|||||||
public static CardList getComputerStartingCards(final QuestEvent qe) {
|
public static CardList getComputerStartingCards(final QuestEvent qe) {
|
||||||
final CardList list = new CardList();
|
final CardList list = new CardList();
|
||||||
|
|
||||||
if (qe.getEventType() == CHALLENGE) {
|
if (qe instanceof QuestEventChallenge) {
|
||||||
final List<String> extras = ((QuestChallenge) qe).getAIExtraCards();
|
final List<String> extras = ((QuestEventChallenge) qe).getAIExtraCards();
|
||||||
|
|
||||||
for (final String s : extras) {
|
for (final String s : extras) {
|
||||||
list.add(QuestUtil.readExtraCard(s, AllZone.getComputerPlayer()));
|
list.add(QuestUtil.readExtraCard(s, AllZone.getComputerPlayer()));
|
||||||
@@ -87,15 +85,22 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.data.QuestData} object.
|
* a {@link forge.quest.data.QuestData} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static CardList getHumanStartingCards(final QuestAssets qd) {
|
public static CardList getHumanStartingCards(final QuestController qc) {
|
||||||
final CardList list = new CardList();
|
final CardList list = new CardList();
|
||||||
|
|
||||||
if (qd.getPetManager().shouldPetBeUsed()) {
|
for( int iSlot = 0; iSlot < QuestController.MAX_PET_SLOTS; iSlot++ )
|
||||||
list.add(qd.getPetManager().getSelectedPet().getPetCard());
|
{
|
||||||
|
String petName = qc.getSelectedPet(iSlot);
|
||||||
|
QuestPetController pet = qc.getPetsStorage().getPet(petName);
|
||||||
|
if (pet != null) {
|
||||||
|
Card c = pet.getPetCard(qc.getAssets());
|
||||||
|
if ( c != null ){
|
||||||
|
Card petCard = AllZone.getCardFactory().copyCard(c);
|
||||||
|
petCard.addController(AllZone.getHumanPlayer());
|
||||||
|
petCard.setToken(true);
|
||||||
|
list.add(petCard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qd.getPetManager().shouldPlantBeUsed()) {
|
|
||||||
list.add(qd.getPetManager().getPlant().getPetCard());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -114,11 +119,11 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.QuestEvent} object.
|
* a {@link forge.quest.QuestEvent} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static CardList getHumanStartingCards(final QuestAssets qa, final QuestEvent qe) {
|
public static CardList getHumanStartingCards(final QuestController qc, final QuestEvent qe) {
|
||||||
final CardList list = QuestUtil.getHumanStartingCards(qa);
|
final CardList list = QuestUtil.getHumanStartingCards(qc);
|
||||||
|
|
||||||
if (qe.getEventType() == CHALLENGE) {
|
if (qe instanceof QuestEventChallenge) {
|
||||||
final List<String> extras = ((QuestChallenge) qe).getHumanExtraCards();
|
final List<String> extras = ((QuestEventChallenge) qe).getHumanExtraCards();
|
||||||
|
|
||||||
for (final String s : extras) {
|
for (final String s : extras) {
|
||||||
list.add(QuestUtil.readExtraCard(s, AllZone.getHumanPlayer()));
|
list.add(QuestUtil.readExtraCard(s, AllZone.getHumanPlayer()));
|
||||||
|
|||||||
@@ -23,14 +23,13 @@ import forge.card.CardEdition;
|
|||||||
import forge.card.FormatCollection;
|
import forge.card.FormatCollection;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.item.*;
|
import forge.item.*;
|
||||||
|
import forge.quest.bazaar.QuestItemType;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestMode;
|
|
||||||
import forge.quest.data.QuestPreferences;
|
import forge.quest.data.QuestPreferences;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.item.QuestItemType;
|
import forge.util.Lambda1;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ import forge.quest.data.QuestAssets;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public interface IQuestStallPurchasable extends Comparable<Object> {
|
public interface IQuestBazaarItem extends Comparable<Object> {
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getPurchaseName.
|
* getPurchaseName.
|
||||||
@@ -53,7 +53,7 @@ public interface IQuestStallPurchasable extends Comparable<Object> {
|
|||||||
*
|
*
|
||||||
* @return the name of the image that is displayed in the bazaar
|
* @return the name of the image that is displayed in the bazaar
|
||||||
*/
|
*/
|
||||||
ImageIcon getIcon();
|
ImageIcon getIcon(QuestAssets qA);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -42,12 +42,8 @@ import org.xml.sax.SAXException;
|
|||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
|
import forge.quest.QuestController;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestStallDefinition;
|
|
||||||
import forge.quest.data.item.IQuestStallPurchasable;
|
|
||||||
import forge.quest.data.item.QuestItemPassive;
|
|
||||||
import forge.quest.data.item.QuestItemType;
|
|
||||||
import forge.quest.data.pet.QuestPetAbstract;
|
|
||||||
import forge.util.IgnoringXStream;
|
import forge.util.IgnoringXStream;
|
||||||
import forge.util.XmlUtil;
|
import forge.util.XmlUtil;
|
||||||
|
|
||||||
@@ -59,10 +55,10 @@ import forge.util.XmlUtil;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QuestStallManager {
|
public class QuestBazaarManager {
|
||||||
private final File xmlFile;
|
private final File xmlFile;
|
||||||
|
|
||||||
public QuestStallManager(File xmlFile0) {
|
public QuestBazaarManager(File xmlFile0) {
|
||||||
xmlFile = xmlFile0;
|
xmlFile = xmlFile0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +95,7 @@ public class QuestStallManager {
|
|||||||
Attr att = document.createAttribute("resolves-to");
|
Attr att = document.createAttribute("resolves-to");
|
||||||
att.setValue(qType.getBazaarControllerClass().getCanonicalName());
|
att.setValue(qType.getBazaarControllerClass().getCanonicalName());
|
||||||
attrs.setNamedItem(att);
|
attrs.setNamedItem(att);
|
||||||
QuestItemPassive ctrl = (QuestItemPassive) xs.fromXML(XmlUtil.nodeToString(n));
|
QuestItemBasic ctrl = (QuestItemBasic) xs.fromXML(XmlUtil.nodeToString(n));
|
||||||
items.put(name, ctrl);
|
items.put(name, ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +111,8 @@ public class QuestStallManager {
|
|||||||
/** Constant <code>stalls</code>. */
|
/** Constant <code>stalls</code>. */
|
||||||
private final Map<String, QuestStallDefinition> stalls = new TreeMap<String, QuestStallDefinition>();
|
private final Map<String, QuestStallDefinition> stalls = new TreeMap<String, QuestStallDefinition>();
|
||||||
/** Constant <code>items</code>. */
|
/** Constant <code>items</code>. */
|
||||||
private final Map<String, SortedSet<IQuestStallPurchasable>> itemsOnStalls = new TreeMap<String, SortedSet<IQuestStallPurchasable>>(String.CASE_INSENSITIVE_ORDER);
|
private final Map<String, SortedSet<IQuestBazaarItem>> itemsOnStalls = new TreeMap<String, SortedSet<IQuestBazaarItem>>(String.CASE_INSENSITIVE_ORDER);
|
||||||
private final Map<String, IQuestStallPurchasable> items = new TreeMap<String, IQuestStallPurchasable>();
|
private final Map<String, IQuestBazaarItem> items = new TreeMap<String, IQuestBazaarItem>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -125,7 +121,7 @@ public class QuestStallManager {
|
|||||||
*
|
*
|
||||||
* @param stallName
|
* @param stallName
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.quest.data.QuestStallDefinition} object.
|
* @return a {@link forge.quest.bazaar.QuestStallDefinition} object.
|
||||||
*/
|
*/
|
||||||
public QuestStallDefinition getStall(final String stallName) {
|
public QuestStallDefinition getStall(final String stallName) {
|
||||||
if (stalls.isEmpty()) {
|
if (stalls.isEmpty()) {
|
||||||
@@ -140,19 +136,27 @@ public class QuestStallManager {
|
|||||||
* and maps to appropriate merchant.
|
* and maps to appropriate merchant.
|
||||||
*/
|
*/
|
||||||
public void buildItems() {
|
public void buildItems() {
|
||||||
final Map<String, IQuestStallPurchasable> itemSet = new HashMap<String, IQuestStallPurchasable>();
|
final Map<String, IQuestBazaarItem> itemSet = new HashMap<String, IQuestBazaarItem>();
|
||||||
|
|
||||||
|
final QuestController qCtrl = AllZone.getQuest();
|
||||||
|
for ( int iSlot = 0; iSlot < QuestController.MAX_PET_SLOTS; iSlot++)
|
||||||
|
{
|
||||||
|
for( QuestPetController pet : qCtrl.getPetsStorage().getAllPets(iSlot)) {
|
||||||
|
//System.out.println("Pet: " + pet.getName());
|
||||||
|
itemSet.put(pet.getName(), pet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final QuestAssets qA = AllZone.getQuest().getAssets();
|
|
||||||
for (QuestPetAbstract i : qA.getPetManager().getPetsAndPlants()) { itemSet.put(i.getName(), i); }
|
|
||||||
itemSet.putAll(items);
|
itemSet.putAll(items);
|
||||||
|
|
||||||
itemsOnStalls.clear();
|
itemsOnStalls.clear();
|
||||||
|
|
||||||
for (QuestStallDefinition thisStall : stalls.values()) {
|
for (QuestStallDefinition thisStall : stalls.values()) {
|
||||||
TreeSet<IQuestStallPurchasable> set = new TreeSet<IQuestStallPurchasable>();
|
TreeSet<IQuestBazaarItem> set = new TreeSet<IQuestBazaarItem>();
|
||||||
|
|
||||||
for (String itemName : thisStall.getItems()) {
|
for (String itemName : thisStall.getItems()) {
|
||||||
IQuestStallPurchasable item = itemSet.get(itemName);
|
IQuestBazaarItem item = itemSet.get(itemName);
|
||||||
|
//System.out.println(itemName);
|
||||||
set.add(item);
|
set.add(item);
|
||||||
}
|
}
|
||||||
itemsOnStalls.put(thisStall.getName(), set);
|
itemsOnStalls.put(thisStall.getName(), set);
|
||||||
@@ -165,13 +169,13 @@ public class QuestStallManager {
|
|||||||
* @param stallName   {@link java.lang.String}
|
* @param stallName   {@link java.lang.String}
|
||||||
* @return {@link java.util.List}.
|
* @return {@link java.util.List}.
|
||||||
*/
|
*/
|
||||||
public List<IQuestStallPurchasable> getItems(final String stallName) {
|
public List<IQuestBazaarItem> getItems(final String stallName) {
|
||||||
buildItems();
|
buildItems();
|
||||||
|
|
||||||
final List<IQuestStallPurchasable> ret = new ArrayList<IQuestStallPurchasable>();
|
final List<IQuestBazaarItem> ret = new ArrayList<IQuestBazaarItem>();
|
||||||
|
|
||||||
QuestAssets qA = AllZone.getQuest().getAssets();
|
QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
for (final IQuestStallPurchasable purchasable : itemsOnStalls.get(stallName)) {
|
for (final IQuestBazaarItem purchasable : itemsOnStalls.get(stallName)) {
|
||||||
if (purchasable.isAvailableForPurchase(qA)) {
|
if (purchasable.isAvailableForPurchase(qA)) {
|
||||||
ret.add(purchasable);
|
ret.add(purchasable);
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
@@ -35,10 +35,10 @@ import forge.quest.data.QuestAssets;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QuestItemPassive implements IQuestStallPurchasable {
|
public class QuestItemBasic implements IQuestBazaarItem {
|
||||||
|
|
||||||
@XStreamAsAttribute
|
@XStreamAsAttribute
|
||||||
private final QuestItemType itemType;
|
private QuestItemType itemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item type.
|
* Gets the item type.
|
||||||
@@ -50,14 +50,15 @@ public class QuestItemPassive implements IQuestStallPurchasable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@XStreamAsAttribute
|
@XStreamAsAttribute
|
||||||
private final int maxLevel = 1;
|
private int maxLevel = 1;
|
||||||
|
|
||||||
@XStreamAsAttribute
|
@XStreamAsAttribute
|
||||||
private final String purchaseName = "Read this field from XML";
|
private String purchaseName = null;
|
||||||
private final String description = "Read from XML";
|
|
||||||
|
private String description = "Read from XML";
|
||||||
|
|
||||||
@XStreamAsAttribute
|
@XStreamAsAttribute
|
||||||
private final int basePrice = 1000;
|
private int basePrice = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the base price.
|
* Gets the base price.
|
||||||
@@ -78,7 +79,7 @@ public class QuestItemPassive implements IQuestStallPurchasable {
|
|||||||
*
|
*
|
||||||
* @param type0 the type0
|
* @param type0 the type0
|
||||||
*/
|
*/
|
||||||
protected QuestItemPassive(final QuestItemType type0) {
|
protected QuestItemBasic(final QuestItemType type0) {
|
||||||
this.itemType = type0;
|
this.itemType = type0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ public class QuestItemPassive implements IQuestStallPurchasable {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ImageIcon getIcon() {
|
public ImageIcon getIcon(QuestAssets qA) {
|
||||||
return FSkin.getIcon(this.icon);
|
return FSkin.getIcon(this.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +198,7 @@ public class QuestItemPassive implements IQuestStallPurchasable {
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int compareTo(final Object o) {
|
public final int compareTo(final Object o) {
|
||||||
final IQuestStallPurchasable q = (IQuestStallPurchasable) o;
|
final IQuestBazaarItem q = (IQuestBazaarItem) o;
|
||||||
return this.getPurchaseName().compareTo(q.getPurchaseName());
|
return this.getPurchaseName().compareTo(q.getPurchaseName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ import forge.quest.data.QuestAssets;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QuestItemElixir extends QuestItemPassive {
|
public class QuestItemElixir extends QuestItemBasic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ import forge.quest.data.QuestAssets;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QuestItemEstates extends QuestItemPassive {
|
public class QuestItemEstates extends QuestItemBasic {
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Constructor for QuestItemEstates.
|
* Constructor for QuestItemEstates.
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
|
import forge.quest.QuestMode;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This item has special coding.
|
* This item has special coding.
|
||||||
@@ -26,7 +26,7 @@ import forge.quest.data.QuestMode;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id: QuestItemElixir.java 13728 2012-02-01 11:13:34Z moomarc $
|
* @version $Id: QuestItemElixir.java 13728 2012-02-01 11:13:34Z moomarc $
|
||||||
*/
|
*/
|
||||||
public class QuestItemPoundFlesh extends QuestItemPassive {
|
public class QuestItemPoundFlesh extends QuestItemBasic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import forge.quest.data.QuestItemCondition;
|
import forge.quest.data.QuestItemCondition;
|
||||||
|
|
||||||
@@ -26,14 +26,14 @@ import forge.quest.data.QuestItemCondition;
|
|||||||
public enum QuestItemType {
|
public enum QuestItemType {
|
||||||
|
|
||||||
/** The SLEIGHT. */
|
/** The SLEIGHT. */
|
||||||
SLEIGHT("Sleight", QuestItemPassive.class, QuestItemCondition.class), /** The ESTATES. */
|
SLEIGHT("Sleight", QuestItemBasic.class, QuestItemCondition.class), /** The ESTATES. */
|
||||||
ESTATES("Estates", QuestItemEstates.class,
|
ESTATES("Estates", QuestItemEstates.class,
|
||||||
QuestItemCondition.class),
|
QuestItemCondition.class),
|
||||||
/** The LUCK y_ coin. */
|
/** The LUCK y_ coin. */
|
||||||
LUCKY_COIN("Lucky Coin", QuestItemPassive.class, QuestItemCondition.class),
|
LUCKY_COIN("Lucky Coin", QuestItemBasic.class, QuestItemCondition.class),
|
||||||
/** The MAP. */
|
/** The MAP. */
|
||||||
MAP(
|
MAP(
|
||||||
"Map", QuestItemPassive.class, QuestItemCondition.class),
|
"Map", QuestItemBasic.class, QuestItemCondition.class),
|
||||||
/** The ZEPPELIN. */
|
/** The ZEPPELIN. */
|
||||||
ZEPPELIN("Zeppelin", QuestItemZeppelin.class,
|
ZEPPELIN("Zeppelin", QuestItemZeppelin.class,
|
||||||
QuestItemCondition.class),
|
QuestItemCondition.class),
|
||||||
@@ -44,10 +44,10 @@ public enum QuestItemType {
|
|||||||
"Pound of Flesh", QuestItemPoundFlesh.class, QuestItemCondition.class);
|
"Pound of Flesh", QuestItemPoundFlesh.class, QuestItemCondition.class);
|
||||||
|
|
||||||
private final String saveFileKey;
|
private final String saveFileKey;
|
||||||
private final Class<? extends QuestItemPassive> bazaarControllerClass;
|
private final Class<? extends QuestItemBasic> bazaarControllerClass;
|
||||||
private final Class<? extends QuestItemCondition> modelClass;
|
private final Class<? extends QuestItemCondition> modelClass;
|
||||||
|
|
||||||
private QuestItemType(final String key, final Class<? extends QuestItemPassive> controllerClass0,
|
private QuestItemType(final String key, final Class<? extends QuestItemBasic> controllerClass0,
|
||||||
final Class<? extends QuestItemCondition> modelClass0) {
|
final Class<? extends QuestItemCondition> modelClass0) {
|
||||||
this.saveFileKey = key;
|
this.saveFileKey = key;
|
||||||
this.bazaarControllerClass = controllerClass0;
|
this.bazaarControllerClass = controllerClass0;
|
||||||
@@ -68,7 +68,7 @@ public enum QuestItemType {
|
|||||||
*
|
*
|
||||||
* @return the bazaar controller class
|
* @return the bazaar controller class
|
||||||
*/
|
*/
|
||||||
public Class<? extends QuestItemPassive> getBazaarControllerClass() {
|
public Class<? extends QuestItemBasic> getBazaarControllerClass() {
|
||||||
return this.bazaarControllerClass;
|
return this.bazaarControllerClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.item;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ import forge.quest.data.QuestAssets;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QuestItemZeppelin extends QuestItemPassive {
|
public class QuestItemZeppelin extends QuestItemBasic {
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Constructor for QuestItemZeppelin.
|
* Constructor for QuestItemZeppelin.
|
||||||
@@ -15,30 +15,52 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data.pet;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.item.IQuestStallPurchasable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Abstract QuestPetAbstract class.
|
* Abstract QuestPetAbstract class.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
* It's not good to store in a single class pets properties and bazaar sellable - such is a tradeoff for speed of development
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
public class QuestPetController implements IQuestBazaarItem {
|
||||||
|
|
||||||
/** The level. */
|
/** The level. */
|
||||||
private int level;
|
@XStreamAsAttribute()
|
||||||
private final int maxLevel;
|
private int maxLevel;
|
||||||
// transient here ?
|
|
||||||
|
private final List<QuestPetStats> levels = new ArrayList<QuestPetStats>();
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
@XStreamAlias(value="desc")
|
||||||
private final String description;
|
private final String description;
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
private final String saveFileKey;
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
private int slot;
|
||||||
|
|
||||||
|
protected int getPetLevel(QuestAssets qA) {
|
||||||
|
int level = qA.getPetLevel(saveFileKey);
|
||||||
|
return level < 0 ? 0 : level > maxLevel ? maxLevel : level;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -47,16 +69,11 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public abstract Card getPetCard();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
public Card getPetCard(QuestAssets qA) {
|
||||||
* getAllUpgradePrices.
|
return this.levels.get(getPetLevel(qA)).getCard();
|
||||||
* </p>
|
}
|
||||||
*
|
|
||||||
* @return an array of int.
|
|
||||||
*/
|
|
||||||
public abstract int[] getAllUpgradePrices();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -67,24 +84,18 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice(QuestAssets qA) {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return this.getAllUpgradePrices()[this.level];
|
int level = getPetLevel(qA);
|
||||||
|
// we'll buy next level
|
||||||
|
return level >= maxLevel ? -1 /* cannot buy */ : this.levels.get(level + 1).getCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice(QuestAssets qA) {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getAllUpgradeDescriptions.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return an array of {@link java.lang.String} objects.
|
|
||||||
*/
|
|
||||||
public abstract String[] getAllUpgradeDescriptions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getUpgradeDescription.
|
* getUpgradeDescription.
|
||||||
@@ -92,19 +103,10 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public final String getUpgradeDescription() {
|
public final String getUpgradeDescription(QuestAssets qA) {
|
||||||
return this.getAllUpgradeDescriptions()[this.level];
|
return this.levels.get(getPetLevel(qA)).getNextLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getAllImageNames.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return an array of {@link java.lang.String} objects.
|
|
||||||
*/
|
|
||||||
public abstract ImageIcon[] getAllIcons();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getIcon.
|
* getIcon.
|
||||||
@@ -113,19 +115,12 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final ImageIcon getIcon() {
|
public final ImageIcon getIcon(QuestAssets qA) {
|
||||||
return this.getAllIcons()[this.level];
|
String path = ForgeProps.getFile(NewConstants.IMAGE_TOKEN).getAbsolutePath() + File.separator;
|
||||||
|
int level = getPetLevel(qA);
|
||||||
|
return new ImageIcon( path + levels.get(level < maxLevel ? level + 1 : level ).getPicture() + ".jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getAllStats.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return an array of {@link java.lang.String} objects.
|
|
||||||
*/
|
|
||||||
public abstract String[] getAllStats();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getStats.
|
* getStats.
|
||||||
@@ -133,8 +128,8 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public final String getStats() {
|
public final String getStats(QuestAssets qA) {
|
||||||
return this.getAllStats()[this.level];
|
return this.levels.get(getPetLevel(qA)).getStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,30 +139,9 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public final String getUpgradedStats() {
|
public final String getUpgradedStats(QuestAssets qA) {
|
||||||
return this.getAllStats()[this.level + 1];
|
int level = getPetLevel(qA);
|
||||||
}
|
return level >= maxLevel ? "N/A" : this.levels.get(level+1).getStats();
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Getter for the field <code>level</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a int.
|
|
||||||
*/
|
|
||||||
public final int getLevel() {
|
|
||||||
return this.level;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* incrementLevel.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public final void incrementLevel() {
|
|
||||||
if (this.level < this.maxLevel) {
|
|
||||||
this.level++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,35 +155,14 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
return this.maxLevel;
|
return this.maxLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Never to be called, instances will be read from xml
|
||||||
* <p>
|
private QuestPetController() {
|
||||||
* Constructor for QuestPetAbstract.
|
this.description = null;
|
||||||
* </p>
|
this.name = null;
|
||||||
*
|
this.maxLevel = 0;
|
||||||
* @param name
|
this.saveFileKey = null;
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @param description
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @param maxLevel
|
|
||||||
* a int.
|
|
||||||
*/
|
|
||||||
protected QuestPetAbstract(final String name, final String description, final int maxLevel) {
|
|
||||||
this.description = description;
|
|
||||||
this.name = name;
|
|
||||||
this.maxLevel = maxLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Setter for the field <code>level</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param level
|
|
||||||
* a int.
|
|
||||||
*/
|
|
||||||
public final void setLevel(final int level) {
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -221,8 +174,8 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
@Override
|
@Override
|
||||||
public final String getPurchaseDescription(QuestAssets qA) {
|
public final String getPurchaseDescription(QuestAssets qA) {
|
||||||
return this.getDescription()
|
return this.getDescription()
|
||||||
+ "\n\nCurrent stats: " + this.getStats() + "\nUpgraded stats: "
|
+ "\n\nCurrent stats: " + this.getStats(qA) + "\nUpgraded stats: "
|
||||||
+ this.getUpgradedStats();
|
+ this.getUpgradedStats(qA);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,11 +240,7 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailableForPurchase(QuestAssets qA) {
|
public boolean isAvailableForPurchase(QuestAssets qA) {
|
||||||
final QuestPetAbstract pet = qA.getPetManager().getPet(this.name);
|
return getPetLevel(qA) < getMaxLevel();
|
||||||
if (pet == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return pet.level < pet.getMaxLevel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,6 +250,18 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPurchase(QuestAssets qA) {
|
public void onPurchase(QuestAssets qA) {
|
||||||
qA.getPetManager().addPetLevel(this.name);
|
qA.setPetLevel(saveFileKey, getPetLevel(qA) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSaveFileKey() {
|
||||||
|
return saveFileKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getSlot() {
|
||||||
|
return slot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
84
src/main/java/forge/quest/bazaar/QuestPetStats.java
Normal file
84
src/main/java/forge/quest/bazaar/QuestPetStats.java
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardReader;
|
||||||
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants;
|
||||||
|
import forge.util.FileUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XStreamAlias(value="level")
|
||||||
|
public class QuestPetStats {
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
@XStreamAlias(value = "value")
|
||||||
|
private int levelValue;
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
@XStreamAlias(value = "pic")
|
||||||
|
private final String picture;
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
private final String stats;
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
private final String cardFile;
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
private int cost;
|
||||||
|
|
||||||
|
@XStreamAsAttribute()
|
||||||
|
private final String nextLevel;
|
||||||
|
|
||||||
|
private transient Card petCard;
|
||||||
|
|
||||||
|
public QuestPetStats()
|
||||||
|
{
|
||||||
|
picture = null;
|
||||||
|
stats = null;
|
||||||
|
cardFile = null;
|
||||||
|
nextLevel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getLevelValue() {
|
||||||
|
return levelValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getPicture() {
|
||||||
|
return picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getStats() {
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Card getCard() {
|
||||||
|
if ( petCard == null ) {
|
||||||
|
List<String> cardLines = FileUtil.readFile(new File(ForgeProps.getFile(NewConstants.Quest.BAZAAR_DIR), cardFile));
|
||||||
|
petCard = CardReader.readCard(cardLines);
|
||||||
|
petCard.setImageFilename(picture);
|
||||||
|
petCard.setToken(true);
|
||||||
|
petCard.setOwner(AllZone.getHumanPlayer());
|
||||||
|
}
|
||||||
|
return petCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getCost() {
|
||||||
|
return cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getNextLevel() {
|
||||||
|
return nextLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
114
src/main/java/forge/quest/bazaar/QuestPetStorage.java
Normal file
114
src/main/java/forge/quest/bazaar/QuestPetStorage.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.XStream;
|
||||||
|
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
|
import forge.util.IgnoringXStream;
|
||||||
|
import forge.util.XmlUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class QuestPetStorage {
|
||||||
|
|
||||||
|
Map<Integer, List<QuestPetController>> petsBySlot = new HashMap<Integer, List<QuestPetController>>();
|
||||||
|
Map<String, QuestPetController> petsByName = new HashMap<String, QuestPetController>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for Constructor.
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
public QuestPetStorage(File file) {
|
||||||
|
DocumentBuilder builder;
|
||||||
|
try {
|
||||||
|
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
final Document document = builder.parse(file);
|
||||||
|
|
||||||
|
XStream xs = new IgnoringXStream();
|
||||||
|
xs.autodetectAnnotations(true);
|
||||||
|
|
||||||
|
NodeList xmlPets = document.getElementsByTagName("pets").item(0).getChildNodes();
|
||||||
|
for (int iN = 0; iN < xmlPets.getLength(); iN++) {
|
||||||
|
Node n = xmlPets.item(iN);
|
||||||
|
if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }
|
||||||
|
|
||||||
|
Attr att = document.createAttribute("resolves-to");
|
||||||
|
att.setValue(QuestPetController.class.getCanonicalName());
|
||||||
|
n.getAttributes().setNamedItem(att);
|
||||||
|
String sXml = XmlUtil.nodeToString(n);
|
||||||
|
QuestPetController petCtrl = (QuestPetController) xs.fromXML(sXml);
|
||||||
|
addToMap(petCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SAXException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param petCtrl
|
||||||
|
*/
|
||||||
|
private void addToMap(QuestPetController petCtrl) {
|
||||||
|
int iSlot = petCtrl.getSlot();
|
||||||
|
List<QuestPetController> list = petsBySlot.get(Integer.valueOf(iSlot));
|
||||||
|
if ( null == list ) {
|
||||||
|
list = new ArrayList<QuestPetController>();
|
||||||
|
petsBySlot.put(Integer.valueOf(iSlot), list);
|
||||||
|
}
|
||||||
|
petsByName.put(petCtrl.getName(), petCtrl);
|
||||||
|
list.add(petCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param petName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QuestPetController getPet(String petName) {
|
||||||
|
return petsByName.get(petName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param i
|
||||||
|
* @param qA
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<QuestPetController> getAvaliablePets(int iSlot, QuestAssets qA) {
|
||||||
|
List<QuestPetController> result = new ArrayList<QuestPetController>();
|
||||||
|
List<QuestPetController> allPossible = petsBySlot.get(Integer.valueOf(iSlot));
|
||||||
|
if ( null != allPossible ) for(QuestPetController c : allPossible) if( qA.getPetLevel(c.getSaveFileKey()) > 0 ) result.add(c);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<QuestPetController> getAllPets(int iSlot) {
|
||||||
|
List<QuestPetController> result = new ArrayList<QuestPetController>();
|
||||||
|
List<QuestPetController> allPossible = petsBySlot.get(Integer.valueOf(iSlot));
|
||||||
|
if ( null != allPossible ) for(QuestPetController c : allPossible) result.add(c);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package forge.quest.data;
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
3
src/main/java/forge/quest/bazaar/package-info.java
Normal file
3
src/main/java/forge/quest/bazaar/package-info.java
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/** Forge Card Game. */
|
||||||
|
package forge.quest.bazaar;
|
||||||
|
|
||||||
@@ -28,10 +28,10 @@ import forge.item.InventoryItem;
|
|||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
import forge.quest.QuestDeckMap;
|
import forge.quest.QuestDeckMap;
|
||||||
|
import forge.quest.QuestMode;
|
||||||
import forge.quest.QuestUtilCards;
|
import forge.quest.QuestUtilCards;
|
||||||
|
import forge.quest.bazaar.QuestItemType;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.item.QuestItemType;
|
|
||||||
import forge.quest.data.pet.QuestPetManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -60,13 +60,12 @@ public class QuestAssets {
|
|||||||
final ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the
|
final ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the
|
||||||
// gadgets
|
// gadgets
|
||||||
|
|
||||||
/** The pet manager. */
|
|
||||||
final QuestPetManager petManager = new QuestPetManager(); // pets
|
|
||||||
|
|
||||||
/** The inventory items. */
|
/** The inventory items. */
|
||||||
final Map<QuestItemType, QuestItemCondition> inventoryItems = new EnumMap<QuestItemType, QuestItemCondition>(
|
final Map<QuestItemType, QuestItemCondition> inventoryItems = new EnumMap<QuestItemType, QuestItemCondition>(
|
||||||
QuestItemType.class);
|
QuestItemType.class);
|
||||||
|
|
||||||
|
// Much the same like other map, but keyed by string (to support a lot of custom pets)
|
||||||
|
final Map<String, QuestItemCondition> combatPets = new HashMap<String, QuestItemCondition>();
|
||||||
/**
|
/**
|
||||||
* Checks for item.
|
* Checks for item.
|
||||||
*
|
*
|
||||||
@@ -98,6 +97,7 @@ public class QuestAssets {
|
|||||||
return this.inventoryItems.get(itemType);
|
return this.inventoryItems.get(itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the item level.
|
* Sets the item level.
|
||||||
*
|
*
|
||||||
@@ -120,6 +120,24 @@ public class QuestAssets {
|
|||||||
cond.setLevel(level);
|
cond.setLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final int getPetLevel(final String name) {
|
||||||
|
final QuestItemCondition state = this.combatPets.get(name);
|
||||||
|
return state == null ? 0 : state.getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final QuestItemCondition getPetCondition(final String name) {
|
||||||
|
return this.combatPets.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setPetLevel(final String name, final int level) {
|
||||||
|
QuestItemCondition cond = this.combatPets.get(name);
|
||||||
|
if (null == cond) {
|
||||||
|
cond = new QuestItemCondition(); // pets have only level that should be serialized for now
|
||||||
|
this.combatPets.put(name, cond);
|
||||||
|
}
|
||||||
|
cond.setLevel(level);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest assets.
|
* Instantiates a new quest assets.
|
||||||
*/
|
*/
|
||||||
@@ -179,14 +197,7 @@ public class QuestAssets {
|
|||||||
this.credits = credits0;
|
this.credits = credits0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the pet manager.
|
|
||||||
*
|
|
||||||
* @return the pet manager
|
|
||||||
*/
|
|
||||||
public QuestPetManager getPetManager() {
|
|
||||||
return this.petManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Credits
|
// Credits
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package forge.quest.data;
|
package forge.quest.data;
|
||||||
|
|
||||||
|
import forge.quest.QuestMode;
|
||||||
import forge.quest.io.QuestDataIO;
|
import forge.quest.io.QuestDataIO;
|
||||||
|
|
||||||
//when you create QuestDataOld and AFTER you copy the AI decks over
|
//when you create QuestDataOld and AFTER you copy the AI decks over
|
||||||
@@ -33,9 +34,8 @@ import forge.quest.io.QuestDataIO;
|
|||||||
*/
|
*/
|
||||||
public final class QuestData {
|
public final class QuestData {
|
||||||
|
|
||||||
// This field holds the version of the Quest Data
|
/** Holds the latest version of the Quest Data */
|
||||||
/** Constant <code>CURRENT_VERSION_NUMBER=2</code>. */
|
public static final int CURRENT_VERSION_NUMBER = 5;
|
||||||
public static final int CURRENT_VERSION_NUMBER = 4;
|
|
||||||
|
|
||||||
// This field places the version number into QD instance,
|
// This field places the version number into QD instance,
|
||||||
// but only when the object is created through the constructor
|
// but only when the object is created through the constructor
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
/** Forge Card Game. */
|
|
||||||
package forge.quest.data.item;
|
|
||||||
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* QuestPetBird class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class QuestPetBird extends QuestPetAbstract {
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final Card getPetCard() {
|
|
||||||
final Card petCard = new Card();
|
|
||||||
|
|
||||||
petCard.setName("Bird Pet");
|
|
||||||
petCard.addController(AllZone.getHumanPlayer());
|
|
||||||
petCard.setOwner(AllZone.getHumanPlayer());
|
|
||||||
|
|
||||||
petCard.addColor("W");
|
|
||||||
petCard.setToken(true);
|
|
||||||
|
|
||||||
petCard.addType("Creature");
|
|
||||||
petCard.addType("Bird");
|
|
||||||
petCard.addType("Pet");
|
|
||||||
|
|
||||||
petCard.addIntrinsicKeyword("Flying");
|
|
||||||
|
|
||||||
if (this.getLevel() == 1) {
|
|
||||||
petCard.setImageName("W 0 1 Bird Pet");
|
|
||||||
petCard.setBaseAttack(0);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 2) {
|
|
||||||
petCard.setImageName("W 1 1 Bird Pet");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 3) {
|
|
||||||
petCard.setImageName("W 2 1 Bird Pet");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 4) {
|
|
||||||
petCard.setImageName("W 2 1 Bird Pet First Strike");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
petCard.addIntrinsicKeyword("First Strike");
|
|
||||||
}
|
|
||||||
|
|
||||||
return petCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestPetBird.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public QuestPetBird() {
|
|
||||||
super("Bird", "Unmatched in speed, agility and awareness, this trained hawk makes a fantastic hunter.", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final int[] getAllUpgradePrices() {
|
|
||||||
return new int[] { 200, 300, 450, 400 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllUpgradeDescriptions() {
|
|
||||||
return new String[] { "Purchase Bird", "Improve the attack power of your bird.",
|
|
||||||
"Improve the attack power of your bird.", "Give First Strike to your bird.",
|
|
||||||
"You cannot train your bird any further" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllStats() {
|
|
||||||
return new String[] { "You do not own a bird", "0/1, W, Flying", "1/1, W, Flying", "2/1, W, Flying",
|
|
||||||
"2/1, W, Flying, First Strike" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final ImageIcon[] getAllIcons() {
|
|
||||||
final String address = ForgeProps.getFile(NewConstants.IMAGE_TOKEN).getAbsolutePath() + File.separator;
|
|
||||||
|
|
||||||
return new ImageIcon[] {
|
|
||||||
new ImageIcon(address + "w_0_1_bird_pet.jpg"),
|
|
||||||
new ImageIcon(address + "w_1_1_bird_pet.jpg"),
|
|
||||||
new ImageIcon(address + "w_2_1_bird_pet.jpg"),
|
|
||||||
new ImageIcon(address + "w_2_1_bird_pet_first_strike.jpg") };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* QuestPetCrocodile class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class QuestPetCrocodile extends QuestPetAbstract {
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final Card getPetCard() {
|
|
||||||
final Card petCard = new Card();
|
|
||||||
petCard.setName("Crocodile Pet");
|
|
||||||
petCard.addController(AllZone.getHumanPlayer());
|
|
||||||
petCard.setOwner(AllZone.getHumanPlayer());
|
|
||||||
|
|
||||||
petCard.addColor("B");
|
|
||||||
petCard.setToken(true);
|
|
||||||
|
|
||||||
petCard.addType("Creature");
|
|
||||||
petCard.addType("Crocodile");
|
|
||||||
petCard.addType("Pet");
|
|
||||||
|
|
||||||
if (this.getLevel() == 1) {
|
|
||||||
petCard.setImageName("B 1 1 Crocodile Pet");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 2) {
|
|
||||||
petCard.setImageName("B 2 1 Crocodile Pet");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 3) {
|
|
||||||
petCard.setImageName("B 3 1 Crocodile Pet");
|
|
||||||
petCard.setBaseAttack(3);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 4) {
|
|
||||||
petCard.setImageName("B 3 1 Crocodile Pet Swampwalk");
|
|
||||||
petCard.setBaseAttack(3);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
petCard.addIntrinsicKeyword("Swampwalk");
|
|
||||||
}
|
|
||||||
|
|
||||||
return petCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestPetCrocodile.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public QuestPetCrocodile() {
|
|
||||||
super("Crocodile", "With its razor sharp teeth, this swamp-dwelling monster is extremely dangerous.", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final int[] getAllUpgradePrices() {
|
|
||||||
return new int[] { 250, 300, 450, 600 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllUpgradeDescriptions() {
|
|
||||||
return new String[] { "Purchase Crocodile", "Improve the attack power of your crocodile.",
|
|
||||||
"Improve the attack power of your crocodile.", "Give Swampwalking to your crocodile.",
|
|
||||||
"You cannot train your crocodile any further" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllStats() {
|
|
||||||
return new String[] { "You do not own a crocodile", "1/1, B", "2/1, B", "3/1, B", "3/1, B, Swampwalking" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final ImageIcon[] getAllIcons() {
|
|
||||||
final String address = ForgeProps.getFile(NewConstants.IMAGE_TOKEN).getAbsolutePath() + File.separator;
|
|
||||||
|
|
||||||
return new ImageIcon[] {
|
|
||||||
new ImageIcon(address + "b_1_1_crocodile_pet.jpg"),
|
|
||||||
new ImageIcon(address + "b_2_1_crocodile_pet.jpg"),
|
|
||||||
new ImageIcon(address + "b_3_1_crocodile_pet.jpg"),
|
|
||||||
new ImageIcon(address + "b_3_1_crocodile_pet_swampwalk.jpg") };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.card.abilityfactory.AbilityFactory;
|
|
||||||
import forge.card.trigger.Trigger;
|
|
||||||
import forge.card.trigger.TriggerHandler;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* QuestPetHound class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class QuestPetHound extends QuestPetAbstract {
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestPetHound.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public QuestPetHound() {
|
|
||||||
super("Hound", "Dogs are said to be man's best friend. Definitely not this one.", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final Card getPetCard() {
|
|
||||||
final Card petCard = new Card();
|
|
||||||
|
|
||||||
petCard.setName("Hound Pet");
|
|
||||||
petCard.addController(AllZone.getHumanPlayer());
|
|
||||||
petCard.setOwner(AllZone.getHumanPlayer());
|
|
||||||
|
|
||||||
petCard.addColor("R");
|
|
||||||
petCard.setToken(true);
|
|
||||||
|
|
||||||
petCard.addType("Creature");
|
|
||||||
petCard.addType("Hound");
|
|
||||||
petCard.addType("Pet");
|
|
||||||
|
|
||||||
if (this.getLevel() == 1) {
|
|
||||||
petCard.setImageName("R 1 1 Hound Pet");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 2) {
|
|
||||||
petCard.setImageName("R 1 1 Hound Pet Haste");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
petCard.addIntrinsicKeyword("Haste");
|
|
||||||
} else if (this.getLevel() == 3) {
|
|
||||||
petCard.setImageName("R 2 1 Hound Pet");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
petCard.addIntrinsicKeyword("Haste");
|
|
||||||
|
|
||||||
} else if (this.getLevel() == 4) {
|
|
||||||
petCard.setImageName("R 2 1 Hound Pet Alone");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
petCard.addIntrinsicKeyword("Haste");
|
|
||||||
|
|
||||||
final Trigger myTrigger = TriggerHandler
|
|
||||||
.parseTrigger(
|
|
||||||
"Mode$ Attacks | ValidCard$ Card.Self | Alone$ True | TriggerDescription$ Whenever CARDNAME attacks alone, it gets +2/+0 until end of turn.",
|
|
||||||
petCard, true);
|
|
||||||
final AbilityFactory af = new AbilityFactory();
|
|
||||||
myTrigger.setOverridingAbility(af.getAbility("AB$Pump | Cost$ 0 | Defined$ Self | NumAtt$ 2", petCard));
|
|
||||||
petCard.addTrigger(myTrigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
return petCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final int[] getAllUpgradePrices() {
|
|
||||||
return new int[] { 200, 350, 450, 750 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllUpgradeDescriptions() {
|
|
||||||
return new String[] { "Purchase hound", "Give Haste to your hound.", "Improve the attack power of your hound.",
|
|
||||||
"Greatly improves your hound's attack power if it attacks alone.",
|
|
||||||
"You cannot train your hound any further" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllStats() {
|
|
||||||
return new String[] { "You do not own a hound", "1/1, R", "1/1, R, Haste", "2/1, R, Haste",
|
|
||||||
"2/1, R, Haste, Whenever this creature attacks alone, it gets +2/+0 until end of turn." };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final ImageIcon[] getAllIcons() {
|
|
||||||
final String address = ForgeProps.getFile(NewConstants.IMAGE_TOKEN).getAbsolutePath() + File.separator;
|
|
||||||
|
|
||||||
return new ImageIcon[] {
|
|
||||||
new ImageIcon(address + "r_1_1_hound_pet.jpg"),
|
|
||||||
new ImageIcon(address + "r_1_1_hound_pet_haste.jpg"),
|
|
||||||
new ImageIcon(address + "r_2_1_hound_pet.jpg"),
|
|
||||||
new ImageIcon(address + "r_2_1_hound_pet_alone.jpg") };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,264 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* QuestPetManager class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class QuestPetManager {
|
|
||||||
|
|
||||||
/** The pets. */
|
|
||||||
private final Map<String, QuestPetAbstract> pets = new HashMap<String, QuestPetAbstract>();
|
|
||||||
|
|
||||||
/** The selected pet. */
|
|
||||||
private QuestPetAbstract selectedPet;
|
|
||||||
|
|
||||||
/** The plant. */
|
|
||||||
private QuestPetAbstract plant;
|
|
||||||
|
|
||||||
/** The use plant. */
|
|
||||||
private boolean usePlant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestPetManager.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public QuestPetManager() {
|
|
||||||
this.plant = new QuestPetPlant();
|
|
||||||
for (final QuestPetAbstract pet : QuestPetManager.getAllPets()) {
|
|
||||||
this.addPet(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Setter for the field <code>selectedPet</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param pet
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
*/
|
|
||||||
public final void setSelectedPet(final String pet) {
|
|
||||||
this.selectedPet = (pet == null) ? null : this.getPet(pet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Getter for the field <code>selectedPet</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link forge.quest.data.pet.QuestPetAbstract} object.
|
|
||||||
*/
|
|
||||||
public final QuestPetAbstract getSelectedPet() {
|
|
||||||
return this.selectedPet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Getter for the field <code>plant</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link forge.quest.data.pet.QuestPetAbstract} object.
|
|
||||||
*/
|
|
||||||
public final QuestPetAbstract getPlant() {
|
|
||||||
return this.plant;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* addPlantLevel.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public final void addPlantLevel() {
|
|
||||||
if (this.plant == null) {
|
|
||||||
this.plant = new QuestPetPlant();
|
|
||||||
} else {
|
|
||||||
this.plant.incrementLevel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getPet.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param petName
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @return a {@link forge.quest.data.pet.QuestPetAbstract} object.
|
|
||||||
*/
|
|
||||||
public final QuestPetAbstract getPet(final String petName) {
|
|
||||||
|
|
||||||
return this.pets.get(petName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* addPet.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param newPet
|
|
||||||
* a {@link forge.quest.data.pet.QuestPetAbstract} object.
|
|
||||||
*/
|
|
||||||
public final void addPet(final QuestPetAbstract newPet) {
|
|
||||||
this.pets.put(newPet.getName(), newPet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getPetNames.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link java.util.Set} object.
|
|
||||||
*/
|
|
||||||
public final Set<String> getPetNames() {
|
|
||||||
return this.pets.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* addPetLevel.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param s
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
*/
|
|
||||||
public final void addPetLevel(final String s) {
|
|
||||||
this.pets.get(s).incrementLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* shouldPlantBeUsed.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean shouldPlantBeUsed() {
|
|
||||||
return this.isUsePlant();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* shouldPetBeUsed.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean shouldPetBeUsed() {
|
|
||||||
return this.selectedPet != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getAllPets.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link java.util.Set} object.
|
|
||||||
*/
|
|
||||||
private static Set<QuestPetAbstract> getAllPets() {
|
|
||||||
final SortedSet<QuestPetAbstract> set = new TreeSet<QuestPetAbstract>();
|
|
||||||
|
|
||||||
set.add(new QuestPetBird());
|
|
||||||
set.add(new QuestPetCrocodile());
|
|
||||||
set.add(new QuestPetHound());
|
|
||||||
set.add(new QuestPetWolf());
|
|
||||||
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getAvailablePetNames.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link java.util.Set} object.
|
|
||||||
*/
|
|
||||||
public final Set<String> getAvailablePetNames() {
|
|
||||||
final SortedSet<String> set = new TreeSet<String>();
|
|
||||||
for (final Map.Entry<String, QuestPetAbstract> pet : this.pets.entrySet()) {
|
|
||||||
if (pet.getValue().getLevel() > 0) {
|
|
||||||
set.add(pet.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getPetsAndPlants.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link java.util.Collection} object.
|
|
||||||
*/
|
|
||||||
public final Collection<QuestPetAbstract> getPetsAndPlants() {
|
|
||||||
final Set<QuestPetAbstract> petsAndPlants = new HashSet<QuestPetAbstract>(this.pets.values());
|
|
||||||
petsAndPlants.add(this.plant);
|
|
||||||
|
|
||||||
return petsAndPlants;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Magic to support added pet types when reading saves.
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* readResolve.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a {@link java.lang.Object} object.
|
|
||||||
*/
|
|
||||||
private Object readResolve() {
|
|
||||||
for (final QuestPetAbstract pet : QuestPetManager.getAllPets()) {
|
|
||||||
if (!this.pets.containsKey(pet.getName())) {
|
|
||||||
this.addPet(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is use plant.
|
|
||||||
*
|
|
||||||
* @return the usePlant
|
|
||||||
*/
|
|
||||||
public boolean isUsePlant() {
|
|
||||||
return this.usePlant;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the use plant.
|
|
||||||
*
|
|
||||||
* @param usePlant0
|
|
||||||
* the usePlant to set
|
|
||||||
*/
|
|
||||||
public void setUsePlant(final boolean usePlant0) {
|
|
||||||
this.usePlant = usePlant0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.Constant;
|
|
||||||
import forge.Singletons;
|
|
||||||
import forge.card.cost.Cost;
|
|
||||||
import forge.card.spellability.AbilityActivated;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
import forge.quest.data.QuestAssets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* QuestPetPlant class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class QuestPetPlant extends QuestPetAbstract {
|
|
||||||
/**
|
|
||||||
* QuestPetPlant.
|
|
||||||
*
|
|
||||||
* @return Card
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public final Card getPetCard() {
|
|
||||||
final Card petCard = new Card();
|
|
||||||
|
|
||||||
petCard.setName("Plant Wall");
|
|
||||||
|
|
||||||
petCard.addController(AllZone.getHumanPlayer());
|
|
||||||
petCard.setOwner(AllZone.getHumanPlayer());
|
|
||||||
|
|
||||||
petCard.addColor("G");
|
|
||||||
petCard.setToken(true);
|
|
||||||
|
|
||||||
petCard.addType("Creature");
|
|
||||||
petCard.addType("Plant");
|
|
||||||
petCard.addType("Wall");
|
|
||||||
|
|
||||||
petCard.addIntrinsicKeyword("Defender");
|
|
||||||
|
|
||||||
if (this.getLevel() == 1) {
|
|
||||||
petCard.setImageName("G 0 1 Plant Wall");
|
|
||||||
petCard.setBaseAttack(0);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 2) {
|
|
||||||
petCard.setImageName("G 0 2 Plant Wall");
|
|
||||||
petCard.setBaseAttack(0);
|
|
||||||
petCard.setBaseDefense(2);
|
|
||||||
} else if (this.getLevel() == 3) {
|
|
||||||
petCard.setImageName("G 0 3 Plant Wall");
|
|
||||||
petCard.setBaseAttack(0);
|
|
||||||
petCard.setBaseDefense(3);
|
|
||||||
} else if (this.getLevel() == 4) {
|
|
||||||
petCard.setImageName("G 1 3 Plant Wall");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(3);
|
|
||||||
// petCard.addIntrinsicKeyword("First Strike");
|
|
||||||
} else if (this.getLevel() == 5) {
|
|
||||||
petCard.setImageName("G 1 3 Plant Wall Deathtouch");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(3);
|
|
||||||
petCard.addIntrinsicKeyword("Deathtouch");
|
|
||||||
} else if (this.getLevel() == 6) {
|
|
||||||
petCard.setImageName("G 1 4 Plant Wall");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(4);
|
|
||||||
petCard.addIntrinsicKeyword("Deathtouch");
|
|
||||||
|
|
||||||
// A:AB$ GainLife | Cost$ T | LifeAmount$ 1 | SpellDescription$ You gain 1 life.
|
|
||||||
final Cost abCost = new Cost("T", petCard.getName(), true);
|
|
||||||
final SpellAbility ability = new AbilityActivated(petCard, abCost, null) {
|
|
||||||
private static final long serialVersionUID = 7546242087593613719L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayAI() {
|
|
||||||
return Singletons.getModel().getGameState().getPhaseHandler().getPhase().equals(Constant.Phase.MAIN2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resolve() {
|
|
||||||
petCard.getController().gainLife(1, petCard);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
petCard.addSpellAbility(ability);
|
|
||||||
ability.setDescription("tap: You gain 1 life.");
|
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("Plant Wall - ").append(petCard.getController()).append(" gains 1 life.");
|
|
||||||
ability.setStackDescription(sb.toString());
|
|
||||||
|
|
||||||
petCard.setText("tap: You gain 1 life.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return petCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestPetPlant.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public QuestPetPlant() {
|
|
||||||
super("Plant", "Start each of your battles with this lush, verdant plant on your side."
|
|
||||||
+ "\nExcellent at blocking the nastiest of critters!", 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final int[] getAllUpgradePrices() {
|
|
||||||
return new int[] { 100, 150, 200, 300, 750, 1000 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllUpgradeDescriptions() {
|
|
||||||
return new String[] { "Purchase Plant", "Improve the defense power of your plant.",
|
|
||||||
"Improve the defense power of your plant.", "Improve the defense power of your plant.",
|
|
||||||
"Grow venomous thorns on your plant.",
|
|
||||||
"Improve the defense power of your plant and your plant will have healing properties",
|
|
||||||
"You cannot train your plant any further" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllStats() {
|
|
||||||
return new String[] { "You do not own a plant", "0/1, G, Defender", "0/2, G, Defender", "0/3, G, Defender",
|
|
||||||
"1/3, G, Defender", "1/3, G, Defender, Deathtouch", "1/4, G, Defender, Deathtouch, T: Gain 1 life" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final ImageIcon[] getAllIcons() {
|
|
||||||
final String address = ForgeProps.getFile(NewConstants.IMAGE_TOKEN).getAbsolutePath() + File.separator;
|
|
||||||
return new ImageIcon[] {
|
|
||||||
new ImageIcon(address + "g_0_1_plant_wall.jpg"),
|
|
||||||
new ImageIcon(address + "g_0_2_plant_wall.jpg"),
|
|
||||||
new ImageIcon(address + "g_0_3_plant_wall.jpg"),
|
|
||||||
new ImageIcon(address + "g_1_3_plant_wall.jpg"),
|
|
||||||
new ImageIcon(address + "g_1_3_plant_wall_deathtouch.jpg"),
|
|
||||||
new ImageIcon(address + "g_1_4_plant_wall.jpg") };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
// @Override
|
|
||||||
// public final String getStallName() {
|
|
||||||
// return QuestStallManager.NURSERY;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final void onPurchase(QuestAssets qA) {
|
|
||||||
qA.getPetManager().addPlantLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final boolean isAvailableForPurchase(QuestAssets qA) {
|
|
||||||
final QuestPetPlant plant = (QuestPetPlant) qA.getPetManager().getPlant();
|
|
||||||
|
|
||||||
return (plant == null) || (plant.getLevel() < plant.getMaxLevel());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* QuestPetWolf class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class QuestPetWolf extends QuestPetAbstract {
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final Card getPetCard() {
|
|
||||||
final Card petCard = new Card();
|
|
||||||
|
|
||||||
petCard.setName("Wolf Pet");
|
|
||||||
petCard.addController(AllZone.getHumanPlayer());
|
|
||||||
petCard.setOwner(AllZone.getHumanPlayer());
|
|
||||||
|
|
||||||
petCard.addColor("G");
|
|
||||||
petCard.setToken(true);
|
|
||||||
|
|
||||||
petCard.addType("Creature");
|
|
||||||
petCard.addType("Wolf");
|
|
||||||
petCard.addType("Pet");
|
|
||||||
|
|
||||||
if (this.getLevel() == 1) {
|
|
||||||
petCard.setImageName("G 1 1 Wolf Pet");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(1);
|
|
||||||
} else if (this.getLevel() == 2) {
|
|
||||||
petCard.setImageName("G 1 2 Wolf Pet");
|
|
||||||
petCard.setBaseAttack(1);
|
|
||||||
petCard.setBaseDefense(2);
|
|
||||||
} else if (this.getLevel() == 3) {
|
|
||||||
petCard.setImageName("G 2 2 Wolf Pet");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(2);
|
|
||||||
} else if (this.getLevel() == 4) {
|
|
||||||
petCard.setImageName("G 2 2 Wolf Pet Flanking");
|
|
||||||
petCard.setBaseAttack(2);
|
|
||||||
petCard.setBaseDefense(2);
|
|
||||||
petCard.addIntrinsicKeyword("Flanking");
|
|
||||||
}
|
|
||||||
|
|
||||||
return petCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestPetWolf.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public QuestPetWolf() {
|
|
||||||
super("Wolf", "This ferocious animal may have been raised in captivity, but it has been trained to kill.", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final int[] getAllUpgradePrices() {
|
|
||||||
return new int[] { 250, 250, 500, 550 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllUpgradeDescriptions() {
|
|
||||||
return new String[] { "Purchase Wolf", "Improve the attack power of your wolf.",
|
|
||||||
"Improve the defense power of your wolf.", "Give Flanking to your wolf.",
|
|
||||||
"You cannot train your wolf any further" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final String[] getAllStats() {
|
|
||||||
return new String[] { "You do not own a wolf", "1/1, G", "1/2, G", "2/2, G", "2/2, G, Flanking" };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public final ImageIcon[] getAllIcons() {
|
|
||||||
final String address = ForgeProps.getFile(NewConstants.IMAGE_TOKEN).getAbsolutePath() + File.separator;
|
|
||||||
|
|
||||||
return new ImageIcon[] {
|
|
||||||
new ImageIcon(address + "g_1_1_wolf_pet.jpg"),
|
|
||||||
new ImageIcon(address + "g_1_2_wolf_pet.jpg"),
|
|
||||||
new ImageIcon(address + "g_2_2_wolf_pet.jpg"),
|
|
||||||
new ImageIcon(address + "g_2_2_wolf_pet_flanking.jpg") };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/** Forge Card Game. */
|
|
||||||
package forge.quest.data.pet;
|
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ import java.util.zip.GZIPOutputStream;
|
|||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.w3c.dom.Attr;
|
import org.w3c.dom.Attr;
|
||||||
@@ -42,6 +43,7 @@ import org.w3c.dom.Element;
|
|||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
import com.thoughtworks.xstream.converters.Converter;
|
import com.thoughtworks.xstream.converters.Converter;
|
||||||
@@ -66,11 +68,11 @@ import forge.item.TournamentPack;
|
|||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
|
import forge.quest.bazaar.QuestItemType;
|
||||||
import forge.quest.data.QuestAchievements;
|
import forge.quest.data.QuestAchievements;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestData;
|
||||||
import forge.quest.data.item.QuestItemType;
|
import forge.quest.data.QuestItemCondition;
|
||||||
import forge.quest.data.pet.QuestPetManager;
|
|
||||||
import forge.util.IgnoringXStream;
|
import forge.util.IgnoringXStream;
|
||||||
import forge.util.XmlUtil;
|
import forge.util.XmlUtil;
|
||||||
|
|
||||||
@@ -131,7 +133,11 @@ public class QuestDataIO {
|
|||||||
data = (QuestData) QuestDataIO.getSerializer(true).fromXML(xml.toString());
|
data = (QuestData) QuestDataIO.getSerializer(true).fromXML(xml.toString());
|
||||||
|
|
||||||
if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
|
if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
|
||||||
|
try {
|
||||||
QuestDataIO.updateSaveFile(data, xml.toString());
|
QuestDataIO.updateSaveFile(data, xml.toString());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
forge.error.ErrorViewer.showError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@@ -158,9 +164,14 @@ public class QuestDataIO {
|
|||||||
* a {@link forge.quest.data.QuestData} object.
|
* a {@link forge.quest.data.QuestData} object.
|
||||||
* @param input
|
* @param input
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
|
* @throws ParserConfigurationException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws SAXException
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws IllegalAccessException
|
||||||
*/
|
*/
|
||||||
private static void updateSaveFile(final QuestData newData, final String input) {
|
private static void updateSaveFile(final QuestData newData, final String input) throws ParserConfigurationException, SAXException, IOException, IllegalAccessException, NoSuchFieldException {
|
||||||
try {
|
|
||||||
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
final InputSource is = new InputSource();
|
final InputSource is = new InputSource();
|
||||||
is.setCharacterStream(new StringReader(input));
|
is.setCharacterStream(new StringReader(input));
|
||||||
@@ -171,14 +182,16 @@ public class QuestDataIO {
|
|||||||
if (saveVersion < 3) {
|
if (saveVersion < 3) {
|
||||||
QuestDataIO.setFinalField(QuestData.class, "assets", newData, new QuestAssets());
|
QuestDataIO.setFinalField(QuestData.class, "assets", newData, new QuestAssets());
|
||||||
|
|
||||||
final int diffIdx = Integer.parseInt(document.getElementsByTagName("diffIndex").item(0)
|
final int diffIdx = Integer.parseInt(document.getElementsByTagName("diffIndex").item(0).getTextContent());
|
||||||
.getTextContent());
|
|
||||||
QuestDataIO.setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx));
|
QuestDataIO.setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveVersion < 4) {
|
if (saveVersion < 4) {
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(),
|
QuestDataIO.setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(), new EnumMap<QuestItemType, Integer>(QuestItemType.class));
|
||||||
new EnumMap<QuestItemType, Integer>(QuestItemType.class));
|
}
|
||||||
|
|
||||||
|
if (saveVersion < 5) {
|
||||||
|
QuestDataIO.setFinalField(QuestAssets.class, "combatPets", newData.getAssets(), new HashMap<String, QuestItemCondition>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
final QuestAssets qS = newData.getAssets();
|
final QuestAssets qS = newData.getAssets();
|
||||||
@@ -189,17 +202,12 @@ public class QuestDataIO {
|
|||||||
case 0:
|
case 0:
|
||||||
// First beta release with new file format,
|
// First beta release with new file format,
|
||||||
// inventory needs to be migrated
|
// inventory needs to be migrated
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(),
|
QuestDataIO.setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(), new EnumMap<QuestItemType, Integer>(QuestItemType.class));
|
||||||
new EnumMap<QuestItemType, Integer>(QuestItemType.class));
|
qS.setItemLevel(QuestItemType.ESTATES, Integer.parseInt(document.getElementsByTagName("estatesLevel").item(0).getTextContent()));
|
||||||
NodeList elements = document.getElementsByTagName("estatesLevel");
|
qS.setItemLevel(QuestItemType.LUCKY_COIN, Integer.parseInt(document.getElementsByTagName("luckyCoinLevel").item(0).getTextContent()));
|
||||||
qS.setItemLevel(QuestItemType.ESTATES, Integer.parseInt(elements.item(0).getTextContent()));
|
qS.setItemLevel(QuestItemType.SLEIGHT, Integer.parseInt(document.getElementsByTagName("sleightOfHandLevel").item(0).getTextContent()));
|
||||||
elements = document.getElementsByTagName("luckyCoinLevel");
|
|
||||||
qS.setItemLevel(QuestItemType.LUCKY_COIN, Integer.parseInt(elements.item(0).getTextContent()));
|
|
||||||
elements = document.getElementsByTagName("sleightOfHandLevel");
|
|
||||||
qS.setItemLevel(QuestItemType.SLEIGHT, Integer.parseInt(elements.item(0).getTextContent()));
|
|
||||||
elements = document.getElementsByTagName("gearLevel");
|
|
||||||
|
|
||||||
final int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
|
final int gearLevel = Integer.parseInt(document.getElementsByTagName("gearLevel").item(0).getTextContent());
|
||||||
if (gearLevel >= 1) {
|
if (gearLevel >= 1) {
|
||||||
newData.getAssets().setItemLevel(QuestItemType.MAP, 1);
|
newData.getAssets().setItemLevel(QuestItemType.MAP, 1);
|
||||||
}
|
}
|
||||||
@@ -218,16 +226,11 @@ public class QuestDataIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final QuestAchievements qA = newData.getAchievements();
|
final QuestAchievements qA = newData.getAchievements();
|
||||||
QuestDataIO.setFinalField(QuestAchievements.class, "win", qA,
|
QuestDataIO.setFinalField(QuestAchievements.class, "win", qA, Integer.parseInt(document.getElementsByTagName("win").item(0).getTextContent()));
|
||||||
Integer.parseInt(document.getElementsByTagName("win").item(0).getTextContent()));
|
QuestDataIO.setFinalField(QuestAchievements.class, "lost", qA, Integer.parseInt(document.getElementsByTagName("lost").item(0).getTextContent()));
|
||||||
QuestDataIO.setFinalField(QuestAchievements.class, "lost", qA,
|
QuestDataIO.setFinalField(QuestAchievements.class, "winstreakBest", qA, Integer.parseInt(document.getElementsByTagName("winstreakBest").item(0).getTextContent()));
|
||||||
Integer.parseInt(document.getElementsByTagName("lost").item(0).getTextContent()));
|
QuestDataIO.setFinalField(QuestAchievements.class, "winstreakCurrent", qA, Integer.parseInt(document.getElementsByTagName("winstreakCurrent").item(0).getTextContent()));
|
||||||
QuestDataIO.setFinalField(QuestAchievements.class, "winstreakBest", qA,
|
QuestDataIO.setFinalField(QuestAchievements.class, "challengesPlayed", qA, Integer.parseInt(document.getElementsByTagName("challengesPlayed").item(0).getTextContent()));
|
||||||
Integer.parseInt(document.getElementsByTagName("winstreakBest").item(0).getTextContent()));
|
|
||||||
QuestDataIO.setFinalField(QuestAchievements.class, "winstreakCurrent", qA,
|
|
||||||
Integer.parseInt(document.getElementsByTagName("winstreakCurrent").item(0).getTextContent()));
|
|
||||||
QuestDataIO.setFinalField(QuestAchievements.class, "challengesPlayed", qA,
|
|
||||||
Integer.parseInt(document.getElementsByTagName("challengesPlayed").item(0).getTextContent()));
|
|
||||||
|
|
||||||
final ArrayList<Integer> completedChallenges = new ArrayList<Integer>();
|
final ArrayList<Integer> completedChallenges = new ArrayList<Integer>();
|
||||||
QuestDataIO.setFinalField(QuestAchievements.class, "completedChallenges", qA, completedChallenges);
|
QuestDataIO.setFinalField(QuestAchievements.class, "completedChallenges", qA, completedChallenges);
|
||||||
@@ -242,24 +245,16 @@ public class QuestDataIO {
|
|||||||
|
|
||||||
final XStream xs = QuestDataIO.getSerializer(true);
|
final XStream xs = QuestDataIO.getSerializer(true);
|
||||||
|
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "credits", qS,
|
QuestDataIO.setFinalField(QuestAssets.class, "credits", qS, Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent()));
|
||||||
Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent()));
|
QuestDataIO.setFinalField(QuestAssets.class, "cardPool", qS, QuestDataIO.readAsset(xs, document, "cardPool", ItemPool.class));
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "cardPool", qS,
|
QuestDataIO.setFinalField(QuestAssets.class, "myDecks", qS, QuestDataIO.readAsset(xs, document, "myDecks", HashMap.class));
|
||||||
QuestDataIO.readAsset(xs, document, "cardPool", ItemPool.class));
|
QuestDataIO.setFinalField(QuestAssets.class, "shopList", qS, QuestDataIO.readAsset(xs, document, "shopList", ItemPool.class));
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "myDecks", qS,
|
QuestDataIO.setFinalField(QuestAssets.class, "newCardList", qS, QuestDataIO.readAsset(xs, document, "newCardList", ItemPool.class));
|
||||||
QuestDataIO.readAsset(xs, document, "myDecks", HashMap.class));
|
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "petManager", qS,
|
|
||||||
QuestDataIO.readAsset(xs, document, "petManager", QuestPetManager.class));
|
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "shopList", qS,
|
|
||||||
QuestDataIO.readAsset(xs, document, "shopList", ItemPool.class));
|
|
||||||
QuestDataIO.setFinalField(QuestAssets.class, "newCardList", qS,
|
|
||||||
QuestDataIO.readAsset(xs, document, "newCardList", ItemPool.class));
|
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// QuestInventory class no longer exists - KV pairs of
|
// QuestInventory class no longer exists - KV pairs of
|
||||||
// QuestItemPair => level moved to assets
|
// QuestItemPair => level moved to assets
|
||||||
if (saveVersion > 0) {
|
final Node oldInventory = saveVersion > 0 ? document.getElementsByTagName("inventory").item(1) : null;
|
||||||
final Node oldInventory = document.getElementsByTagName("inventory").item(1);
|
|
||||||
if ( null != oldInventory) {
|
if ( null != oldInventory) {
|
||||||
for (int iN = 0; iN < oldInventory.getChildNodes().getLength(); iN++) {
|
for (int iN = 0; iN < oldInventory.getChildNodes().getLength(); iN++) {
|
||||||
final Node _n = oldInventory.getChildNodes().item(iN);
|
final Node _n = oldInventory.getChildNodes().item(iN);
|
||||||
@@ -287,9 +282,20 @@ public class QuestDataIO {
|
|||||||
qS.setItemLevel(qType, level);
|
qS.setItemLevel(qType, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
if (saveVersion > 0 ) {
|
||||||
|
NodeList pets = document.getElementsByTagName("pets").item(0).getChildNodes();
|
||||||
|
for (int i = 0; i < pets.getLength(); i++) {
|
||||||
|
if ( pets.item(i).getNodeType() != Node.ELEMENT_NODE ) continue;
|
||||||
|
final Element entry = (Element) pets.item(i);
|
||||||
|
String name = entry.getElementsByTagName("string").item(0).getTextContent();
|
||||||
|
String sLevel = entry.getElementsByTagName("level").item(0).getTextContent();
|
||||||
|
qS.setPetLevel(name, Integer.parseInt(sLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// pet manager will be re-engineered here
|
// pet manager will be re-engineered here
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -299,9 +305,7 @@ public class QuestDataIO {
|
|||||||
// mark the QD as the latest version
|
// mark the QD as the latest version
|
||||||
newData.setVersionNumber(QuestData.CURRENT_VERSION_NUMBER);
|
newData.setVersionNumber(QuestData.CURRENT_VERSION_NUMBER);
|
||||||
|
|
||||||
} catch (final Exception e) {
|
|
||||||
forge.error.ErrorViewer.showError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
* limitations under the Apache License.
|
* limitations under the Apache License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package net.slightlymagic.braids.util.lambda;
|
package forge.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface Lambda.
|
* The Interface Lambda.
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
* limitations under the Apache License.
|
* limitations under the Apache License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package net.slightlymagic.braids.util.lambda;
|
package forge.util;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class Lambda1.
|
* The Class Lambda1.
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
* limitations under the Apache License.
|
* limitations under the Apache License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package net.slightlymagic.braids.util.lambda;
|
package forge.util;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class Lambda1.
|
* The Class Lambda1.
|
||||||
@@ -22,7 +22,6 @@ import java.util.Hashtable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predicate class allows to select items or type <U>, which are or contain an
|
* Predicate class allows to select items or type <U>, which are or contain an
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import forge.control.ControlBazaarUI;
|
|||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FPanel;
|
import forge.gui.toolbox.FPanel;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.quest.QuestStallManager;
|
import forge.quest.bazaar.QuestBazaarManager;
|
||||||
import forge.view.bazaar.ViewStall;
|
import forge.view.bazaar.ViewStall;
|
||||||
|
|
||||||
|
|
||||||
@@ -22,12 +22,12 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
private final ViewStall pnlSingleStall;
|
private final ViewStall pnlSingleStall;
|
||||||
private final ControlBazaarUI control;
|
private final ControlBazaarUI control;
|
||||||
private FLabel previousSelected;
|
private FLabel previousSelected;
|
||||||
private final QuestStallManager bazaar;
|
private final QuestBazaarManager bazaar;
|
||||||
|
|
||||||
/** Lays out containers and borders for resizeable layout and
|
/** Lays out containers and borders for resizeable layout and
|
||||||
* instantiates top-level controller for bazaar UI.
|
* instantiates top-level controller for bazaar UI.
|
||||||
* @param bazaar0 */
|
* @param bazaar0 */
|
||||||
public ViewBazaarUI(QuestStallManager bazaar0) {
|
public ViewBazaarUI(QuestBazaarManager bazaar0) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Final inits
|
// Final inits
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ import forge.gui.toolbox.FLabel;
|
|||||||
import forge.gui.toolbox.FPanel;
|
import forge.gui.toolbox.FPanel;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.gui.toolbox.FTextArea;
|
import forge.gui.toolbox.FTextArea;
|
||||||
|
import forge.quest.bazaar.IQuestBazaarItem;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.item.IQuestStallPurchasable;
|
|
||||||
|
|
||||||
/** An update-able panel instance representing a single item. */
|
/** An update-able panel instance representing a single item. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ViewItem extends FPanel {
|
public class ViewItem extends FPanel {
|
||||||
private final FLabel lblIcon, lblName, lblPrice, btnPurchase;
|
private final FLabel lblIcon, lblName, lblPrice, btnPurchase;
|
||||||
private final FTextArea tarDesc;
|
private final FTextArea tarDesc;
|
||||||
private IQuestStallPurchasable item;
|
private IQuestBazaarItem item;
|
||||||
|
|
||||||
/** An update-able panel instance representing a single item. */
|
/** An update-able panel instance representing a single item. */
|
||||||
public ViewItem() {
|
public ViewItem() {
|
||||||
@@ -48,7 +48,7 @@ public class ViewItem extends FPanel {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
final QuestAssets qA = AllZone.getQuest().getAssets();
|
final QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
final int cost = ViewItem.this.getItem().getBuyingPrice(qA);
|
final int cost = ViewItem.this.getItem().getBuyingPrice(qA);
|
||||||
if ((qA.getCredits() - cost) >= 0) {
|
if ( cost >= 0 && (qA.getCredits() - cost) >= 0) {
|
||||||
qA.subtractCredits(cost);
|
qA.subtractCredits(cost);
|
||||||
qA.addCredits(ViewItem.this.getItem().getSellingPrice(qA));
|
qA.addCredits(ViewItem.this.getItem().getSellingPrice(qA));
|
||||||
ViewItem.this.getItem().onPurchase(qA);
|
ViewItem.this.getItem().onPurchase(qA);
|
||||||
@@ -61,14 +61,14 @@ public class ViewItem extends FPanel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param i0
|
* @param i0
|
||||||
*   {@link forge.quest.data.item.IQuestStallPurchasable}
|
*   {@link forge.quest.bazaar.IQuestBazaarItem}
|
||||||
*/
|
*/
|
||||||
public void setItem(final IQuestStallPurchasable i0) {
|
public void setItem(final IQuestBazaarItem i0) {
|
||||||
this.item = i0;
|
this.item = i0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.quest.data.item.IQuestStallPurchasable} */
|
/** @return {@link forge.quest.bazaar.IQuestBazaarItem} */
|
||||||
public IQuestStallPurchasable getItem() {
|
public IQuestBazaarItem getItem() {
|
||||||
return this.item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,13 +78,15 @@ public class ViewItem extends FPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final QuestAssets qA = AllZone.getQuest().getAssets();
|
final QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
ViewItem.this.lblIcon.setIcon(ViewItem.this.getItem().getIcon());
|
IQuestBazaarItem bazaarItem = ViewItem.this.getItem();
|
||||||
ViewItem.this.lblName.setText(ViewItem.this.getItem().getPurchaseName());
|
|
||||||
ViewItem.this.lblPrice.setText("Cost: " + String.valueOf(ViewItem.this.getItem().getBuyingPrice(qA))
|
|
||||||
+ " credits");
|
|
||||||
ViewItem.this.tarDesc.setText(ViewItem.this.getItem().getPurchaseDescription(qA));
|
|
||||||
|
|
||||||
if (qA.getCredits() < ViewItem.this.getItem().getBuyingPrice(qA)) {
|
ViewItem.this.lblIcon.setIcon(bazaarItem.getIcon(qA));
|
||||||
|
ViewItem.this.lblName.setText(bazaarItem.getPurchaseName());
|
||||||
|
ViewItem.this.lblPrice.setText("Cost: " + String.valueOf(bazaarItem.getBuyingPrice(qA)) + " credits");
|
||||||
|
String desc = bazaarItem.getPurchaseDescription(qA);
|
||||||
|
ViewItem.this.tarDesc.setText(desc);
|
||||||
|
|
||||||
|
if (qA.getCredits() < bazaarItem.getBuyingPrice(qA)) {
|
||||||
ViewItem.this.btnPurchase.setEnabled(false);
|
ViewItem.this.btnPurchase.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ import forge.gui.toolbox.FLabel;
|
|||||||
import forge.gui.toolbox.FScrollPane;
|
import forge.gui.toolbox.FScrollPane;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
|
import forge.quest.bazaar.IQuestBazaarItem;
|
||||||
|
import forge.quest.bazaar.QuestStallDefinition;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestStallDefinition;
|
|
||||||
import forge.quest.data.item.IQuestStallPurchasable;
|
|
||||||
import forge.view.ViewBazaarUI;
|
import forge.view.ViewBazaarUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,7 +137,7 @@ public class ViewStall extends JPanel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param q0
|
* @param q0
|
||||||
*   {@link forge.quest.data.QuestStallDefinition}
|
*   {@link forge.quest.bazaar.QuestStallDefinition}
|
||||||
*/
|
*/
|
||||||
public void setStall(final QuestStallDefinition q0) {
|
public void setStall(final QuestStallDefinition q0) {
|
||||||
this.stall = q0;
|
this.stall = q0;
|
||||||
@@ -156,7 +156,7 @@ public class ViewStall extends JPanel {
|
|||||||
final QuestAssets qS = qData.getAssets();
|
final QuestAssets qS = qData.getAssets();
|
||||||
this.lblStats.setText("Credits: " + qS.getCredits() + " Life: " + qS.getLife(qData.getMode()));
|
this.lblStats.setText("Credits: " + qS.getCredits() + " Life: " + qS.getLife(qData.getMode()));
|
||||||
|
|
||||||
final List<IQuestStallPurchasable> items = AllZone.getQuest().getBazaar().getItems(this.stall.getName());
|
final List<IQuestBazaarItem> items = AllZone.getQuest().getBazaar().getItems(this.stall.getName());
|
||||||
|
|
||||||
this.lblStallName.setText(this.stall.getDisplayName());
|
this.lblStallName.setText(this.stall.getDisplayName());
|
||||||
this.tpnFluff.setText(this.stall.getFluff());
|
this.tpnFluff.setText(this.stall.getFluff());
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ import forge.gui.toolbox.FSkin;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.model.FMatchState;
|
import forge.model.FMatchState;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.quest.QuestChallenge;
|
import forge.quest.QuestEventChallenge;
|
||||||
import forge.quest.QuestController;
|
import forge.quest.QuestController;
|
||||||
import forge.quest.QuestEvent;
|
import forge.quest.QuestEvent;
|
||||||
|
import forge.quest.QuestMode;
|
||||||
import forge.quest.QuestUtil;
|
import forge.quest.QuestUtil;
|
||||||
|
import forge.quest.bazaar.QuestItemType;
|
||||||
import forge.quest.data.QuestAssets;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestMode;
|
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.item.QuestItemType;
|
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import net.slightlymagic.braids.util.UtilFunctions;
|
import net.slightlymagic.braids.util.UtilFunctions;
|
||||||
|
|
||||||
@@ -48,8 +48,6 @@ import java.awt.Dimension;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static forge.quest.QuestEvent.QuestEventType.CHALLENGE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* QuestWinLoseHandler.
|
* QuestWinLoseHandler.
|
||||||
@@ -108,19 +106,19 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
if (qData.getMode() == QuestMode.Fantasy) {
|
if (qData.getMode() == QuestMode.Fantasy) {
|
||||||
int extraLife = 0;
|
int extraLife = 0;
|
||||||
|
|
||||||
if (qEvent.getEventType() == CHALLENGE) {
|
if (qEvent instanceof QuestEventChallenge ) {
|
||||||
if (qa.hasItem(QuestItemType.ZEPPELIN)) {
|
if (qa.hasItem(QuestItemType.ZEPPELIN)) {
|
||||||
extraLife = 3;
|
extraLife = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CardList humanList = QuestUtil.getHumanStartingCards(qa, qEvent);
|
final CardList humanList = QuestUtil.getHumanStartingCards(qData, qEvent);
|
||||||
final CardList computerList = QuestUtil.getComputerStartingCards(qEvent);
|
final CardList computerList = QuestUtil.getComputerStartingCards(qEvent);
|
||||||
|
|
||||||
final int humanLife = qa.getLife(qData.getMode()) + extraLife;
|
final int humanLife = qa.getLife(qData.getMode()) + extraLife;
|
||||||
int computerLife = 20;
|
int computerLife = 20;
|
||||||
if (qEvent.getEventType() == CHALLENGE) {
|
if (qEvent instanceof QuestEventChallenge) {
|
||||||
computerLife = ((QuestChallenge) qEvent).getAILife();
|
computerLife = ((QuestEventChallenge) qEvent).getAILife();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
||||||
@@ -182,7 +180,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
this.awardEventCredits();
|
this.awardEventCredits();
|
||||||
|
|
||||||
// Challenge reward credits
|
// Challenge reward credits
|
||||||
if (qEvent.getEventType() == CHALLENGE) {
|
if (qEvent instanceof QuestEventChallenge) {
|
||||||
this.awardChallengeWin();
|
this.awardChallengeWin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,8 +275,8 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
|
|
||||||
qData.getCards().clearShopList();
|
qData.getCards().clearShopList();
|
||||||
|
|
||||||
if (qEvent.getEventType() == CHALLENGE && !((QuestChallenge) qEvent).isRepeatable()) {
|
if (qEvent instanceof QuestEventChallenge && !((QuestEventChallenge) qEvent).isRepeatable()) {
|
||||||
qData.getAchievements().addCompletedChallenge(((QuestChallenge) qEvent).getId());
|
qData.getAchievements().addCompletedChallenge(((QuestEventChallenge) qEvent).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qData.getAvailableChallenges() != null) {
|
if (qData.getAvailableChallenges() != null) {
|
||||||
@@ -560,8 +558,8 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
// used for "wins before next challenge"
|
// used for "wins before next challenge"
|
||||||
qData.getAchievements().addChallengesPlayed();
|
qData.getAchievements().addChallengesPlayed();
|
||||||
|
|
||||||
final List<CardPrinted> cardsWon = ((QuestChallenge) qEvent).getCardRewardList();
|
final List<CardPrinted> cardsWon = ((QuestEventChallenge) qEvent).getCardRewardList();
|
||||||
final long questRewardCredits = ((QuestChallenge) qEvent).getCreditsReward();
|
final long questRewardCredits = ((QuestEventChallenge) qEvent).getCreditsReward();
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("<html>Challenge completed.<br><br>");
|
sb.append("<html>Challenge completed.<br><br>");
|
||||||
@@ -571,7 +569,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
|
|
||||||
// Generate Swing components and attach.
|
// Generate Swing components and attach.
|
||||||
this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_BOX), 0.5);
|
this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_BOX), 0.5);
|
||||||
this.lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) qEvent).getTitle()
|
this.lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestEventChallenge) qEvent).getTitle()
|
||||||
+ "\"");
|
+ "\"");
|
||||||
|
|
||||||
this.lblTemp2 = new JLabel(sb.toString());
|
this.lblTemp2 = new JLabel(sb.toString());
|
||||||
|
|||||||
@@ -23,12 +23,13 @@ package net.slightlymagic.braids.util.generator;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
|
||||||
|
|
||||||
import com.google.code.jyield.Generator;
|
import com.google.code.jyield.Generator;
|
||||||
import com.google.code.jyield.YieldUtils;
|
import com.google.code.jyield.YieldUtils;
|
||||||
import com.google.code.jyield.Yieldable;
|
import com.google.code.jyield.Yieldable;
|
||||||
|
|
||||||
|
import forge.util.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For documentation on Java-Yield and its generators, see.
|
* For documentation on Java-Yield and its generators, see.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* The files in the directory "net/slightlymagic/braids" and in all subdirectories of it (the "Files") are
|
|
||||||
* Copyright 2011 Braids Cabal-Conjurer. They are available under either Forge's
|
|
||||||
* main license (the GNU Public License; see LICENSE.txt in Forge's top directory)
|
|
||||||
* or under the Apache License, as explained below.
|
|
||||||
*
|
|
||||||
* The Files are additionally licensed under the Apache License, Version 2.0 (the
|
|
||||||
* "Apache License"); you may not use the files in this directory except in
|
|
||||||
* compliance with one of its two licenses. You may obtain a copy of the Apache
|
|
||||||
* License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the Apache License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the Apache License for the specific language governing permissions and
|
|
||||||
* limitations under the Apache License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package net.slightlymagic.braids.util.lambda;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class Lambda2.
|
|
||||||
*
|
|
||||||
* @param <R>
|
|
||||||
* the generic type
|
|
||||||
* @param <A1>
|
|
||||||
* the generic type
|
|
||||||
* @param <A2>
|
|
||||||
* the generic type
|
|
||||||
*/
|
|
||||||
public abstract class Lambda2<R, A1, A2> implements Lambda<R> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply.
|
|
||||||
*
|
|
||||||
* @param arg1
|
|
||||||
* the arg1
|
|
||||||
* @param arg2
|
|
||||||
* the arg2
|
|
||||||
* @return the r
|
|
||||||
*/
|
|
||||||
public abstract R apply(A1 arg1, A2 arg2);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* net.slightlymagic.braids.util.lambda.Lambda#apply(java.lang.Object[])
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO @Override
|
|
||||||
/**
|
|
||||||
* Apply.
|
|
||||||
*
|
|
||||||
* @param args Object[]
|
|
||||||
* @return R
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public final R apply(final Object[] args) {
|
|
||||||
return apply((A1) args[0], (A2) args[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* The files in the directory "net/slightlymagic/braids" and in all subdirectories of it (the "Files") are
|
|
||||||
* Copyright 2011 Braids Cabal-Conjurer. They are available under either Forge's
|
|
||||||
* main license (the GNU Public License; see LICENSE.txt in Forge's top directory)
|
|
||||||
* or under the Apache License, as explained below.
|
|
||||||
*
|
|
||||||
* The Files are additionally licensed under the Apache License, Version 2.0 (the
|
|
||||||
* "Apache License"); you may not use the files in this directory except in
|
|
||||||
* compliance with one of its two licenses. You may obtain a copy of the Apache
|
|
||||||
* License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the Apache License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the Apache License for the specific language governing permissions and
|
|
||||||
* limitations under the Apache License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package net.slightlymagic.braids.util.lambda;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class Lambda3.
|
|
||||||
*
|
|
||||||
* @param <R>
|
|
||||||
* the generic type
|
|
||||||
* @param <A1>
|
|
||||||
* the generic type
|
|
||||||
* @param <A2>
|
|
||||||
* the generic type
|
|
||||||
* @param <A3>
|
|
||||||
* the generic type
|
|
||||||
*/
|
|
||||||
public abstract class Lambda3<R, A1, A2, A3> implements Lambda<R> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply.
|
|
||||||
*
|
|
||||||
* @param arg1
|
|
||||||
* the arg1
|
|
||||||
* @param arg2
|
|
||||||
* the arg2
|
|
||||||
* @param arg3
|
|
||||||
* the arg3
|
|
||||||
* @return the r
|
|
||||||
*/
|
|
||||||
public abstract R apply(A1 arg1, A2 arg2, A3 arg3);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* net.slightlymagic.braids.util.lambda.Lambda#apply(java.lang.Object[])
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO @Override
|
|
||||||
/**
|
|
||||||
* Apply.
|
|
||||||
*
|
|
||||||
* @param args Object[]
|
|
||||||
* @return R
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public final R apply(final Object[] args) {
|
|
||||||
return apply((A1) args[0], (A2) args[1], (A3) args[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* The files in the directory "net/slightlymagic/braids" and in all subdirectories of it (the "Files") are
|
|
||||||
* Copyright 2011 Braids Cabal-Conjurer. They are available under either Forge's
|
|
||||||
* main license (the GNU Public License; see LICENSE.txt in Forge's top directory)
|
|
||||||
* or under the Apache License, as explained below.
|
|
||||||
*
|
|
||||||
* The Files are additionally licensed under the Apache License, Version 2.0 (the
|
|
||||||
* "Apache License"); you may not use the files in this directory except in
|
|
||||||
* compliance with one of its two licenses. You may obtain a copy of the Apache
|
|
||||||
* License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the Apache License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the Apache License for the specific language governing permissions and
|
|
||||||
* limitations under the Apache License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package net.slightlymagic.braids.util.lambda;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Interface Thunk.
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* the generic type
|
|
||||||
*/
|
|
||||||
public interface Thunk<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply.
|
|
||||||
*
|
|
||||||
* @return the t
|
|
||||||
*/
|
|
||||||
T apply();
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/** Forge Card Game. */
|
|
||||||
package net.slightlymagic.braids.util.lambda;
|
|
||||||
Reference in New Issue
Block a user