mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
code to support items in external files
This commit is contained in:
9
.gitattributes
vendored
9
.gitattributes
vendored
@@ -11590,19 +11590,17 @@ src/main/java/forge/quest/data/QuestAchievements.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/QuestDuelDifficulty.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/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/QuestInventory.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/item/QuestItemAbstract.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/QuestItemLuckyCoin.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/item/QuestItemMap.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/QuestItemSleight.java svneol=native#text/plain
|
||||
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
|
||||
@@ -11629,6 +11627,7 @@ src/main/java/forge/util/IItemReader.java -text
|
||||
src/main/java/forge/util/IItemSerializer.java -text
|
||||
src/main/java/forge/util/IStorage.java -text
|
||||
src/main/java/forge/util/IStorageView.java -text
|
||||
src/main/java/forge/util/IgnoringXStream.java -text
|
||||
src/main/java/forge/util/MyRandom.java svneol=native#text/plain
|
||||
src/main/java/forge/util/Predicate.java -text
|
||||
src/main/java/forge/util/PredicateString.java -text
|
||||
|
||||
@@ -38,6 +38,7 @@ import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GamePlayerRating;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.data.item.QuestItemType;
|
||||
/**
|
||||
* <p>
|
||||
* InputMulligan class.
|
||||
@@ -104,7 +105,7 @@ public class InputMulligan extends Input {
|
||||
final int newHand = this.doMulligan(humanPlayer, humanRating);
|
||||
|
||||
final QuestController quest = AllZone.getQuest();
|
||||
if (quest.isLoaded() && quest.getAssets().getInventory().hasItem("Sleight") && (humanRating.getMulliganCount() == 1)) {
|
||||
if (quest.isLoaded() && quest.getAssets().hasItem(QuestItemType.SLEIGHT) && (humanRating.getMulliganCount() == 1)) {
|
||||
AllZone.getHumanPlayer().drawCard();
|
||||
humanRating.notifyOpeningHandSize(newHand + 1);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import forge.quest.data.QuestAchievements;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestMode;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.data.item.QuestItemZeppelin;
|
||||
import forge.quest.data.item.QuestItemType;
|
||||
import forge.quest.data.pet.QuestPetAbstract;
|
||||
|
||||
/**
|
||||
@@ -54,9 +54,9 @@ public class SubmenuQuestUtil {
|
||||
final int challengesPlayed = qData.getAchievements().getChallengesPlayed();
|
||||
|
||||
int mul = 5;
|
||||
if (qData.getAssets().getInventory().hasItem("Zeppelin")) {
|
||||
if (qData.getAssets().hasItem(QuestItemType.ZEPPELIN)) {
|
||||
mul = 3;
|
||||
} else if (qData.getAssets().getInventory().hasItem("Map")) {
|
||||
} else if (qData.getAssets().hasItem(QuestItemType.MAP)) {
|
||||
mul = 4;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SubmenuQuestUtil {
|
||||
|
||||
// Stats panel
|
||||
view.getLblCredits().setText("Credits: " + qS.getCredits());
|
||||
view.getLblLife().setText("Life: " + qS.getLife());
|
||||
view.getLblLife().setText("Life: " + qS.getLife(qData.getMode()));
|
||||
view.getLblWins().setText("Wins: " + qA.getWin());
|
||||
view.getLblLosses().setText("Losses: " + qA.getLost());
|
||||
view.updateCurrentDeckStatus();
|
||||
@@ -133,15 +133,7 @@ public class SubmenuQuestUtil {
|
||||
view.getCbPlant().setSelected(qS.getPetManager().shouldPlantBeUsed());
|
||||
}
|
||||
|
||||
// Zeppelin visibility: everything about the zeppelin is screwy right now
|
||||
// for some reason, needs a large overhaul, disabled for now. 4-03-12
|
||||
if (false) { //view.equals(VSubmenuChallenges.SINGLETON_INSTANCE)) {
|
||||
final QuestItemZeppelin zeppelin = (QuestItemZeppelin) qS.getInventory().getItem("Zeppelin");
|
||||
view.getCbZep().setVisible(zeppelin.isAvailableForPurchase(qS) ? true : false);
|
||||
}
|
||||
else {
|
||||
view.getCbZep().setVisible(false);
|
||||
}
|
||||
view.getCbZep().setVisible(qS.hasItem(QuestItemType.ZEPPELIN));
|
||||
}
|
||||
else {
|
||||
// Classic mode display changes
|
||||
@@ -226,13 +218,12 @@ public class SubmenuQuestUtil {
|
||||
int extraLife = 0;
|
||||
|
||||
// If zeppelin has been purchased, gear will be at level 2.
|
||||
if (event.getEventType().equalsIgnoreCase("challenge")
|
||||
&& !qData.getAssets().getInventory().getItem("Zeppelin").isAvailableForPurchase(qData.getAssets())
|
||||
if ( qData.getAssets().hasItem(QuestItemType.ZEPPELIN)
|
||||
&& VSubmenuChallenges.SINGLETON_INSTANCE.getCbZep().isSelected()) {
|
||||
extraLife = 3;
|
||||
}
|
||||
lifeAI = ((QuestChallenge) event).getAILife();
|
||||
lifeHuman = qData.getAssets().getLife() + extraLife;
|
||||
lifeHuman = qData.getAssets().getLife(qData.getMode()) + extraLife;
|
||||
}
|
||||
|
||||
GameNew.newGame(
|
||||
|
||||
@@ -227,7 +227,7 @@ public enum FSkin {
|
||||
ICO_ZEP (new int[] {0, 480, 80, 80}), /** */
|
||||
ICO_GEAR (new int[] {80, 480, 80, 80}), /** */
|
||||
ICO_GOLD (new int[] {160, 480, 80, 80}), /** */
|
||||
ICO_ELIXER (new int[] {240, 480, 80, 80}), /** */
|
||||
ICO_ELIXIR (new int[] {240, 480, 80, 80}), /** */
|
||||
ICO_BOOK (new int[] {320, 480, 80, 80}), /** */
|
||||
ICO_BOTTLES (new int[] {400, 480, 80, 80}), /** */
|
||||
ICO_BOX (new int[] {480, 480, 80, 80}), /** */
|
||||
|
||||
@@ -34,6 +34,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
@@ -41,12 +42,13 @@ import org.xml.sax.SAXException;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.gui.toolbox.FSkin.QuestIcons;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestStallDefinition;
|
||||
import forge.quest.data.item.IQuestStallPurchasable;
|
||||
import forge.quest.data.item.QuestItemAbstract;
|
||||
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.XmlUtil;
|
||||
|
||||
/**
|
||||
@@ -61,7 +63,6 @@ public class QuestStallManager {
|
||||
private final File xmlFile;
|
||||
|
||||
public QuestStallManager(File xmlFile0) {
|
||||
|
||||
xmlFile = xmlFile0;
|
||||
}
|
||||
|
||||
@@ -71,10 +72,10 @@ public class QuestStallManager {
|
||||
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
final Document document = builder.parse(xmlFile);
|
||||
|
||||
NodeList xmlStalls = document.getElementsByTagName("stalls").item(0).getChildNodes();
|
||||
|
||||
XStream xs = new XStream();
|
||||
XStream xs = new IgnoringXStream();
|
||||
xs.autodetectAnnotations(true);
|
||||
|
||||
NodeList xmlStalls = document.getElementsByTagName("stalls").item(0).getChildNodes();
|
||||
for (int iN = 0; iN < xmlStalls.getLength(); iN++) {
|
||||
Node n = xmlStalls.item(iN);
|
||||
if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }
|
||||
@@ -86,6 +87,22 @@ public class QuestStallManager {
|
||||
stalls.put(stall.getName(), stall);
|
||||
}
|
||||
|
||||
NodeList xmlQuestItems = document.getElementsByTagName("questItems").item(0).getChildNodes();
|
||||
for (int iN = 0; iN < xmlQuestItems.getLength(); iN++) {
|
||||
Node n = xmlQuestItems.item(iN);
|
||||
if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }
|
||||
|
||||
NamedNodeMap attrs = n.getAttributes();
|
||||
String sType = attrs.getNamedItem("itemType").getTextContent();
|
||||
String name = attrs.getNamedItem("name").getTextContent();
|
||||
QuestItemType qType = QuestItemType.smartValueOf(sType);
|
||||
Attr att = document.createAttribute("resolves-to");
|
||||
att.setValue(qType.getBazaarControllerClass().getCanonicalName());
|
||||
attrs.setNamedItem(att);
|
||||
QuestItemPassive ctrl = (QuestItemPassive) xs.fromXML(XmlUtil.nodeToString(n));
|
||||
items.put(name, ctrl);
|
||||
}
|
||||
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
@@ -98,7 +115,8 @@ public class QuestStallManager {
|
||||
/** Constant <code>stalls</code>. */
|
||||
private final Map<String, QuestStallDefinition> stalls = new TreeMap<String, QuestStallDefinition>();
|
||||
/** Constant <code>items</code>. */
|
||||
private final Map<String, SortedSet<IQuestStallPurchasable>> items = new TreeMap<String, SortedSet<IQuestStallPurchasable>>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, SortedSet<IQuestStallPurchasable>> itemsOnStalls = new TreeMap<String, SortedSet<IQuestStallPurchasable>>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, IQuestStallPurchasable> items = new TreeMap<String, IQuestStallPurchasable>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -125,11 +143,10 @@ public class QuestStallManager {
|
||||
final Map<String, IQuestStallPurchasable> itemSet = new HashMap<String, IQuestStallPurchasable>();
|
||||
|
||||
final QuestAssets qA = AllZone.getQuest().getAssets();
|
||||
|
||||
for (QuestItemAbstract i : qA.getInventory().getItems()) { itemSet.put(i.getName(), i); }
|
||||
for (QuestPetAbstract i : qA.getPetManager().getPetsAndPlants()) { itemSet.put(i.getName(), i); }
|
||||
itemSet.putAll(items);
|
||||
|
||||
items.clear();
|
||||
itemsOnStalls.clear();
|
||||
|
||||
for (QuestStallDefinition thisStall : stalls.values()) {
|
||||
TreeSet<IQuestStallPurchasable> set = new TreeSet<IQuestStallPurchasable>();
|
||||
@@ -138,7 +155,7 @@ public class QuestStallManager {
|
||||
IQuestStallPurchasable item = itemSet.get(itemName);
|
||||
set.add(item);
|
||||
}
|
||||
items.put(thisStall.getName(), set);
|
||||
itemsOnStalls.put(thisStall.getName(), set);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +171,7 @@ public class QuestStallManager {
|
||||
final List<IQuestStallPurchasable> ret = new ArrayList<IQuestStallPurchasable>();
|
||||
|
||||
QuestAssets qA = AllZone.getQuest().getAssets();
|
||||
for (final IQuestStallPurchasable purchasable : items.get(stallName)) {
|
||||
for (final IQuestStallPurchasable purchasable : itemsOnStalls.get(stallName)) {
|
||||
if (purchasable.isAvailableForPurchase(qA)) {
|
||||
ret.add(purchasable);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestMode;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.data.item.QuestItemType;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.Predicate;
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
@@ -285,7 +286,7 @@ public final class QuestUtilCards {
|
||||
multi = 0.6;
|
||||
}
|
||||
|
||||
final int lvlEstates = this.qc.getMode() == QuestMode.Fantasy ? this.qa.getInventory().getItemLevel("Estates") : 0;
|
||||
final int lvlEstates = this.qc.getMode() == QuestMode.Fantasy ? this.qa.getItemLevel(QuestItemType.ESTATES) : 0;
|
||||
switch (lvlEstates) {
|
||||
case 1:
|
||||
multi += 0.01;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
@@ -11,7 +13,7 @@ import forge.item.ItemPoolView;
|
||||
import forge.quest.QuestDeckMap;
|
||||
import forge.quest.QuestUtilCards;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.data.item.QuestInventory;
|
||||
import forge.quest.data.item.QuestItemType;
|
||||
import forge.quest.data.pet.QuestPetManager;
|
||||
|
||||
/**
|
||||
@@ -27,10 +29,7 @@ public class QuestAssets {
|
||||
long credits; // this money is good for all modes
|
||||
// game
|
||||
// with
|
||||
/** The inventory. */
|
||||
final QuestInventory inventory = new QuestInventory(); // different
|
||||
/** The life. */
|
||||
int life; // for fantasy mode, how much life bought at shop to start
|
||||
|
||||
// Decks collected by player
|
||||
/** The my decks. */
|
||||
final HashMap<String, Deck> myDecks = new HashMap<String, Deck>();
|
||||
@@ -46,18 +45,42 @@ public class QuestAssets {
|
||||
|
||||
/** The pet manager. */
|
||||
final QuestPetManager petManager = new QuestPetManager(); // pets
|
||||
/**
|
||||
* Adds n life to maximum.
|
||||
*
|
||||
* @param n
|
||||
*   int
|
||||
*/
|
||||
public void addLife(final int n) {
|
||||
this.life += n;
|
||||
}
|
||||
public QuestAssets(QuestMode mode) {
|
||||
this.life = mode.equals(QuestMode.Fantasy) ? 15 : 20;
|
||||
|
||||
|
||||
final Map<QuestItemType, QuestItemCondition> inventoryItems = new EnumMap<QuestItemType, QuestItemCondition>(QuestItemType.class);
|
||||
|
||||
|
||||
public final boolean hasItem(final QuestItemType itemType) {
|
||||
return this.inventoryItems.containsKey(itemType) && (this.inventoryItems.get(itemType).getLevel() > 0);
|
||||
}
|
||||
|
||||
|
||||
public final int getItemLevel(final QuestItemType itemType) {
|
||||
final QuestItemCondition state = this.inventoryItems.get(itemType);
|
||||
return state == null ? 0 : state.getLevel();
|
||||
}
|
||||
|
||||
public final QuestItemCondition getItemCondition(final QuestItemType itemType) {
|
||||
return this.inventoryItems.get(itemType);
|
||||
}
|
||||
|
||||
|
||||
public final void setItemLevel(final QuestItemType itemType, final int level) {
|
||||
QuestItemCondition cond = this.inventoryItems.get(itemType);
|
||||
if( null == cond ) {
|
||||
try { // care to set appropriate state class here
|
||||
cond = (QuestItemCondition) itemType.getModelClass().newInstance();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
e.printStackTrace();
|
||||
cond = new QuestItemCondition();
|
||||
}
|
||||
this.inventoryItems.put(itemType, cond);
|
||||
}
|
||||
cond.setLevel(level);
|
||||
}
|
||||
|
||||
public QuestAssets() {
|
||||
final QuestPreferences prefs = Singletons.getModel().getQuestPreferences();
|
||||
final ItemPoolView<CardPrinted> lands = QuestUtilCards.generateBasicLands(
|
||||
prefs.getPreferenceInt(QPref.STARTING_BASIC_LANDS), prefs.getPreferenceInt(QPref.STARTING_SNOW_LANDS));
|
||||
@@ -72,23 +95,16 @@ public class QuestAssets {
|
||||
public long getCredits() {
|
||||
return this.credits;
|
||||
}
|
||||
// All belongings
|
||||
/**
|
||||
* Gets the inventory.
|
||||
*
|
||||
* @return the inventory
|
||||
*/
|
||||
public QuestInventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
// Life (only fantasy)
|
||||
/**
|
||||
* Gets the life.
|
||||
*
|
||||
* @return the life
|
||||
*/
|
||||
public int getLife() {
|
||||
return this.life;
|
||||
public int getLife(QuestMode mode) {
|
||||
int base = mode.equals(QuestMode.Fantasy) ? 15 : 20;
|
||||
return base + getItemLevel(QuestItemType.ELIXIR_OF_LIFE) - getItemLevel(QuestItemType.POUND_FLESH);
|
||||
}
|
||||
/**
|
||||
* Gets the new card list.
|
||||
@@ -106,15 +122,7 @@ public class QuestAssets {
|
||||
public ItemPool<InventoryItem> getShopList() {
|
||||
return this.shopList;
|
||||
}
|
||||
/**
|
||||
* Removes n life from maximum.
|
||||
*
|
||||
* @param n
|
||||
*   int
|
||||
*/
|
||||
public void removeLife(final int n) {
|
||||
this.life -= n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the credits.
|
||||
*
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class QuestData {
|
||||
|
||||
// This field holds the version of the Quest Data
|
||||
/** Constant <code>CURRENT_VERSION_NUMBER=2</code>. */
|
||||
public static final int CURRENT_VERSION_NUMBER = 3;
|
||||
public static final int CURRENT_VERSION_NUMBER = 4;
|
||||
|
||||
// This field places the version number into QD instance,
|
||||
// but only when the object is created through the constructor
|
||||
@@ -66,7 +66,7 @@ public final class QuestData {
|
||||
|
||||
this.mode = mode2;
|
||||
this.achievements = new QuestAchievements(diff);
|
||||
this.assets = new QuestAssets(mode2);
|
||||
this.assets = new QuestAssets();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
21
src/main/java/forge/quest/data/QuestItemCondition.java
Normal file
21
src/main/java/forge/quest/data/QuestItemCondition.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package forge.quest.data;
|
||||
|
||||
/**
|
||||
* This class should store the quest items' properties that are to be serialized
|
||||
*
|
||||
*/
|
||||
public class QuestItemCondition {
|
||||
private int level;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
import forge.gui.toolbox.FSkin.QuestIcons;
|
||||
import forge.gui.toolbox.FSkin.SkinProp;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface IQuestStallPurchasable extends Comparable<Object> {
|
||||
*
|
||||
* @return an HTML formatted item description
|
||||
*/
|
||||
String getPurchaseDescription();
|
||||
String getPurchaseDescription(QuestAssets qA);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -1,169 +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.item;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestInventory class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestInventory {
|
||||
|
||||
/** The inventory. */
|
||||
private final Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestInventory.
|
||||
* </p>
|
||||
*/
|
||||
public QuestInventory() {
|
||||
final Set<QuestItemAbstract> allItems = QuestInventory.getAllItems();
|
||||
for (final QuestItemAbstract item : allItems) {
|
||||
this.inventory.put(item.getName(), item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* hasItem.
|
||||
* </p>
|
||||
*
|
||||
* @param itemName
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasItem(final String itemName) {
|
||||
return this.inventory.containsKey(itemName) && (this.inventory.get(itemName).getLevel() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* addItem.
|
||||
* </p>
|
||||
*
|
||||
* @param item
|
||||
* a {@link forge.quest.data.item.QuestItemAbstract} object.
|
||||
*/
|
||||
public final void addItem(final QuestItemAbstract item) {
|
||||
this.inventory.put(item.getName(), item);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getItemLevel.
|
||||
* </p>
|
||||
*
|
||||
* @param itemName
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getItemLevel(final String itemName) {
|
||||
final QuestItemAbstract item = this.inventory.get(itemName);
|
||||
if (item == null) {
|
||||
return 0;
|
||||
}
|
||||
return item.getLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setItemLevel.
|
||||
* </p>
|
||||
*
|
||||
* @param itemName
|
||||
* a {@link java.lang.String} object.
|
||||
* @param level
|
||||
* a int.
|
||||
*/
|
||||
public final void setItemLevel(final String itemName, final int level) {
|
||||
this.inventory.get(itemName).setLevel(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getAllItems.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.Set} object.
|
||||
*/
|
||||
private static Set<QuestItemAbstract> getAllItems() {
|
||||
final SortedSet<QuestItemAbstract> set = new TreeSet<QuestItemAbstract>();
|
||||
|
||||
set.add(new QuestItemPoundFlesh());
|
||||
set.add(new QuestItemElixir());
|
||||
set.add(new QuestItemEstates());
|
||||
set.add(new QuestItemLuckyCoin());
|
||||
set.add(new QuestItemMap());
|
||||
set.add(new QuestItemSleight());
|
||||
set.add(new QuestItemZeppelin());
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
// Magic to support added pet types when reading saves.
|
||||
/**
|
||||
* <p>
|
||||
* readResolve.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.Object} object.
|
||||
*/
|
||||
private Object readResolve() {
|
||||
for (final QuestItemAbstract item : QuestInventory.getAllItems()) {
|
||||
if (!this.inventory.containsKey(item.getName())) {
|
||||
this.inventory.put(item.getName(), item);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getItems.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.Collection} object.
|
||||
*/
|
||||
public Collection<QuestItemAbstract> getItems() {
|
||||
return this.inventory.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getItem.
|
||||
* </p>
|
||||
*
|
||||
* @param itemName
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link forge.quest.data.item.QuestItemAbstract} object.
|
||||
*/
|
||||
public QuestItemAbstract getItem(final String itemName) {
|
||||
return this.inventory.get(itemName);
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
package forge.quest.data.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
@@ -28,7 +25,7 @@ import forge.quest.data.QuestAssets;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestItemElixir extends QuestItemAbstract {
|
||||
public class QuestItemElixir extends QuestItemPassive {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -36,50 +33,21 @@ public class QuestItemElixir extends QuestItemAbstract {
|
||||
* </p>
|
||||
*/
|
||||
QuestItemElixir() {
|
||||
super("Elixir of Life", 15); // QuestStallManager.ALCHEMIST,
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "A salty sweet smell rises from the vials bubbling behind the counter.\n"
|
||||
+ "\nEffect: Gives +1 to maximum life."
|
||||
+ "\nFine Print: Loses effectiveness after 15 uses.";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_ELIXER);
|
||||
super(QuestItemType.ELIXIR_OF_LIFE); // QuestStallManager.ALCHEMIST,
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getBuyingPrice(QuestAssets qA) {
|
||||
if (this.getLevel() < 5) {
|
||||
return 250;
|
||||
} else if (this.getLevel() < 10) {
|
||||
return 500;
|
||||
} else if (this.getLevel() <= this.getMaxLevel()) {
|
||||
return 750;
|
||||
int level = qA.getItemLevel(this.getItemType());
|
||||
if ( level < 5) {
|
||||
return super.getBasePrice();
|
||||
} else if (level < 10) {
|
||||
return super.getBasePrice() * 2;
|
||||
} else if (level <= this.getMaxLevel()) {
|
||||
return super.getBasePrice() * 3;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void onPurchase(QuestAssets qA) {
|
||||
super.onPurchase(qA);
|
||||
|
||||
if (this.getLevel() <= this.getMaxLevel()) {
|
||||
qA.addLife(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
package forge.quest.data.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
@@ -30,47 +27,28 @@ import forge.quest.data.QuestAssets;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestItemEstates extends QuestItemAbstract {
|
||||
public class QuestItemEstates extends QuestItemPassive {
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemEstates.
|
||||
* </p>
|
||||
*/
|
||||
QuestItemEstates() {
|
||||
super("Estates", 3); // QuestStallManager.BANKER,
|
||||
super(QuestItemType.ESTATES); // QuestStallManager.BANKER,
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return String.format("Land owners have a strong voice in community matters.\n"
|
||||
+ "\nEffect: Gives a bonus of %d%% to match winnings."
|
||||
+ "\nEffect: Improves sell percentage by %.2f%%.",
|
||||
(10 + (this.getLevel() * 5)),
|
||||
(1 + (this.getLevel() * 0.75)));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_GOLD);
|
||||
public final String getPurchaseDescription(QuestAssets qA) {
|
||||
return String.format(super.getPurchaseDescription(qA),
|
||||
(10 + (qA.getItemLevel(this.getItemType()) * 5)),
|
||||
(1 + (qA.getItemLevel(this.getItemType()) * 0.75)));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getBuyingPrice(QuestAssets qA) {
|
||||
if (this.getLevel() == 0) {
|
||||
return 500;
|
||||
} else if (this.getLevel() == 1) {
|
||||
return 750;
|
||||
} else {
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
return 0;
|
||||
int level = qA.getItemLevel(this.getItemType());
|
||||
return getBasePrice() * (2 + level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +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.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestItemLuckyCoin class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestItemLuckyCoin extends QuestItemAbstract {
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemLuckyCoin.
|
||||
* </p>
|
||||
*/
|
||||
QuestItemLuckyCoin() {
|
||||
super("Lucky Coin"); //, QuestStallManager.BANKER
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "This coin is believed to give good luck to its owner.\n"
|
||||
+ "\nEffect: Improves the chance of getting a random rare after each match by 15%.";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_COIN);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getBuyingPrice(QuestAssets qA) {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +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.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestItemMap class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestItemMap extends QuestItemAbstract {
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemMap.
|
||||
* </p>
|
||||
*/
|
||||
QuestItemMap() {
|
||||
super("Map"); // , QuestStallManager.GEAR
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseName() {
|
||||
return "Adventurer's Map";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "These ancient charts should facilitate navigation during your travels significantly.\n"
|
||||
+ "\nEffect: Quest assignments become available more frequently.";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_MAP);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getBuyingPrice(QuestAssets qA) {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,12 @@ package forge.quest.data.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.FSkin.QuestIcons;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
@@ -29,25 +35,29 @@ import forge.quest.data.QuestAssets;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
private int level = 0;
|
||||
private final String name;
|
||||
public class QuestItemPassive implements IQuestStallPurchasable {
|
||||
|
||||
@XStreamAsAttribute
|
||||
private QuestItemType itemType;
|
||||
public final QuestItemType getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
@XStreamAsAttribute
|
||||
private int maxLevel = 1;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemAbstract.
|
||||
* </p>
|
||||
*
|
||||
* @param name
|
||||
* a {@link java.lang.String} object.
|
||||
* @param shopName
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
protected QuestItemAbstract(final String name) {
|
||||
this.name = name;
|
||||
@XStreamAsAttribute
|
||||
private String purchaseName = "Read this field from XML";
|
||||
private String description = "Read from XML";
|
||||
|
||||
@XStreamAsAttribute
|
||||
private int basePrice = 1000;
|
||||
protected final int getBasePrice() {
|
||||
return basePrice;
|
||||
}
|
||||
|
||||
@XStreamAsAttribute
|
||||
private final QuestIcons icon = null;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemAbstract.
|
||||
@@ -57,12 +67,9 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
* a {@link java.lang.String} object.
|
||||
* @param shopName
|
||||
* a {@link java.lang.String} object.
|
||||
* @param maxLevel
|
||||
* a int.
|
||||
*/
|
||||
protected QuestItemAbstract(final String name, final int maxLevel) {
|
||||
this.name = name;
|
||||
this.maxLevel = maxLevel;
|
||||
protected QuestItemPassive(final QuestItemType type0) {
|
||||
this.itemType = type0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +78,7 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
return this.itemType.getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +88,7 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
*/
|
||||
@Override
|
||||
public String getPurchaseName() {
|
||||
return this.name;
|
||||
return StringUtils.isBlank(this.purchaseName) ? this.getName() : this.purchaseName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +96,8 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
*/
|
||||
@Override
|
||||
public void onPurchase(QuestAssets qA) {
|
||||
final int currentLevel = qA.getInventory().getItemLevel(this.name);
|
||||
qA.getInventory().setItemLevel(this.name, currentLevel + 1);
|
||||
final int currentLevel = qA.getItemLevel(this.itemType);
|
||||
qA.setItemLevel(this.itemType, currentLevel + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,30 +109,7 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
*/
|
||||
@Override
|
||||
public boolean isAvailableForPurchase(QuestAssets qA) {
|
||||
return qA.getInventory().getItemLevel(this.name) < this.maxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>level</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>level</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param level
|
||||
* a int.
|
||||
*/
|
||||
public final void setLevel(final int level) {
|
||||
this.level = level;
|
||||
return qA.getItemLevel(this.itemType) < this.maxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +142,9 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public abstract String getPurchaseDescription();
|
||||
public String getPurchaseDescription(QuestAssets qA) {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -168,16 +154,15 @@ public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public abstract ImageIcon getIcon();
|
||||
public ImageIcon getIcon() { return FSkin.getIcon(icon); }
|
||||
|
||||
/** @return a int. */
|
||||
@Override
|
||||
public abstract int getBuyingPrice(QuestAssets qA);
|
||||
public int getBuyingPrice(QuestAssets qA) { return basePrice; }
|
||||
|
||||
/** @return a int. */
|
||||
@Override
|
||||
public abstract int getSellingPrice(QuestAssets qA);
|
||||
|
||||
public int getSellingPrice(QuestAssets qA) { return 0; }
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int compareTo(final Object o) {
|
||||
@@ -17,11 +17,8 @@
|
||||
*/
|
||||
package forge.quest.data.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestMode;
|
||||
|
||||
/**
|
||||
* This item has special coding.
|
||||
@@ -29,7 +26,7 @@ import forge.quest.data.QuestAssets;
|
||||
* @author Forge
|
||||
* @version $Id: QuestItemElixir.java 13728 2012-02-01 11:13:34Z moomarc $
|
||||
*/
|
||||
public class QuestItemPoundFlesh extends QuestItemAbstract {
|
||||
public class QuestItemPoundFlesh extends QuestItemPassive {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -37,22 +34,13 @@ public class QuestItemPoundFlesh extends QuestItemAbstract {
|
||||
* </p>
|
||||
*/
|
||||
QuestItemPoundFlesh() {
|
||||
super("Pound of Flesh", 29); // QuestStallManager.ALCHEMIST,
|
||||
super(QuestItemType.POUND_FLESH); // QuestStallManager.ALCHEMIST,
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "The Alchemist welcomes contributions to his famous Elixer.\n"
|
||||
+ "But beware, you may build an immunity to its effects...\n"
|
||||
+ "\nEffect: Alchemist gives you " + getSellingPrice(AllZone.getQuest().getAssets()) + " credits."
|
||||
+ "\nEffect: Reduces maximum life by 1.";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_BREW);
|
||||
public final String getPurchaseDescription(QuestAssets qA) {
|
||||
return String.format(super.getPurchaseDescription(qA), getSellingPrice(qA));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -63,23 +51,15 @@ public class QuestItemPoundFlesh extends QuestItemAbstract {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
if (qA.getLife() < 2) {
|
||||
int level = qA.getItemLevel(this.getItemType());
|
||||
if (qA.getLife(QuestMode.Fantasy) < 2) {
|
||||
return 0;
|
||||
} else if (this.getLevel() < 5) {
|
||||
return 250;
|
||||
} else if (this.getLevel() < 10) {
|
||||
return 500;
|
||||
} else if (level < 5) {
|
||||
return this.getBasePrice();
|
||||
} else if (level < 10) {
|
||||
return this.getBasePrice() * 2;
|
||||
} else {
|
||||
return 750;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void onPurchase(QuestAssets qA) {
|
||||
if (qA.getLife() > 1) {
|
||||
super.onPurchase(qA);
|
||||
qA.removeLife(1);
|
||||
return this.getBasePrice() * 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +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.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestItemSleight class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestItemSleight extends QuestItemAbstract {
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemSleight.
|
||||
* </p>
|
||||
*/
|
||||
QuestItemSleight() {
|
||||
super("Sleight"); // , QuestStallManager.BOOKSTORE
|
||||
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_BOOK);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getBuyingPrice(QuestAssets qA) {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseName() {
|
||||
return "Sleight of Hand Vol. I";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "These volumes explain how to perform the most difficult of sleights.\n"
|
||||
+ "\nEffect: Your first mulligan is free.";
|
||||
}
|
||||
}
|
||||
75
src/main/java/forge/quest/data/item/QuestItemType.java
Normal file
75
src/main/java/forge/quest/data/item/QuestItemType.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package forge.quest.data.item;
|
||||
|
||||
import forge.quest.data.QuestItemCondition;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum QuestItemType {
|
||||
|
||||
SLEIGHT("Sleight", QuestItemPassive.class, QuestItemCondition.class),
|
||||
ESTATES("Estates", QuestItemEstates.class, QuestItemCondition.class),
|
||||
LUCKY_COIN("Lucky Coin", QuestItemPassive.class, QuestItemCondition.class),
|
||||
MAP("Map", QuestItemPassive.class, QuestItemCondition.class),
|
||||
ZEPPELIN("Zeppelin", QuestItemZeppelin.class, QuestItemCondition.class),
|
||||
ELIXIR_OF_LIFE("Elixir of Life", QuestItemElixir.class, QuestItemCondition.class),
|
||||
POUND_FLESH("Pound of Flesh", QuestItemPoundFlesh.class, QuestItemCondition.class);
|
||||
|
||||
|
||||
private final String saveFileKey;
|
||||
private final Class<? extends QuestItemPassive> bazaarControllerClass;
|
||||
private final Class<? extends QuestItemCondition> modelClass;
|
||||
|
||||
private QuestItemType(String key, Class<? extends QuestItemPassive> controllerClass0, Class<? extends QuestItemCondition> modelClass0) {
|
||||
saveFileKey = key;
|
||||
bazaarControllerClass = controllerClass0;
|
||||
modelClass = modelClass0;
|
||||
}
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public String getKey() {
|
||||
return saveFileKey;
|
||||
}
|
||||
public Class<? extends QuestItemPassive> getBazaarControllerClass() {
|
||||
return bazaarControllerClass;
|
||||
}
|
||||
public Class<? extends QuestItemCondition> getModelClass() {
|
||||
return modelClass;
|
||||
}
|
||||
|
||||
public static QuestItemType smartValueOf(final String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if ("All".equals(value)) {
|
||||
return null;
|
||||
}
|
||||
final String valToCompate = value.trim();
|
||||
for (final QuestItemType v : QuestItemType.values()) {
|
||||
if (v.name().compareToIgnoreCase(valToCompate) == 0) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No element named " + value + " in enum QuestItemType");
|
||||
}
|
||||
|
||||
|
||||
public static QuestItemType valueFromSaveKey(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String valToCompate = name.trim();
|
||||
for (final QuestItemType v : QuestItemType.values()) {
|
||||
if (v.getKey().compareToIgnoreCase(valToCompate) == 0) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No element keyed " + name + " in enum QuestItemType");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
package forge.quest.data.item;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
/**
|
||||
@@ -30,79 +27,21 @@ import forge.quest.data.QuestAssets;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestItemZeppelin extends QuestItemAbstract {
|
||||
|
||||
/** The zeppelin used. */
|
||||
private boolean zeppelinUsed = false;
|
||||
|
||||
public class QuestItemZeppelin extends QuestItemPassive {
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestItemZeppelin.
|
||||
* </p>
|
||||
*/
|
||||
QuestItemZeppelin() {
|
||||
super("Zeppelin"); // , QuestStallManager.GEAR
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseName() {
|
||||
return "Zeppelin";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "This extremely comfortable airship allows for more efficient and safe travel to faraway destinations.\n"
|
||||
+ "\nEffect: Quest assignments become available more frequently."
|
||||
+ "\nEffect: Adds +3 to max life during quest games."
|
||||
+ "\nEffect: Allows travel to far places, allowing you to see a new set of opponents,";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final ImageIcon getIcon() {
|
||||
return FSkin.getIcon(FSkin.QuestIcons.ICO_ZEP);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getBuyingPrice(QuestAssets qA) {
|
||||
return 5000;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getSellingPrice(QuestAssets qA) {
|
||||
return 0;
|
||||
super(QuestItemType.ZEPPELIN); // , QuestStallManager.GEAR
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final boolean isAvailableForPurchase(QuestAssets qA) {
|
||||
return super.isAvailableForPurchase(qA) && qA.getInventory().hasItem("Map");
|
||||
return super.isAvailableForPurchase(qA) && qA.hasItem(QuestItemType.MAP);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* hasBeenUsed.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasBeenUsed() {
|
||||
return this.zeppelinUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>zeppelinUsed</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param used
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setZeppelinUsed(final boolean used) {
|
||||
this.zeppelinUsed = used;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
public final String getPurchaseDescription(QuestAssets qA) {
|
||||
return this.getDescription()
|
||||
+ "\n\nCurrent stats: " + this.getStats() + "\nUpgraded stats: "
|
||||
+ this.getUpgradedStats();
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@@ -37,6 +37,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
@@ -47,8 +48,6 @@ import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.mapper.MapperWrapper;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.deck.DeckSection;
|
||||
@@ -68,9 +67,9 @@ import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestAchievements;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.QuestMode;
|
||||
import forge.quest.data.item.QuestInventory;
|
||||
import forge.quest.data.item.QuestItemType;
|
||||
import forge.quest.data.pet.QuestPetManager;
|
||||
import forge.util.IgnoringXStream;
|
||||
import forge.util.XmlUtil;
|
||||
|
||||
/**
|
||||
@@ -161,34 +160,39 @@ public class QuestDataIO {
|
||||
final int saveVersion = newData.getVersionNumber();
|
||||
|
||||
if (saveVersion < 3) {
|
||||
// no difference here (used only to set initial lives)
|
||||
setFinalField(QuestData.class, "assets", newData, new QuestAssets(QuestMode.Classic));
|
||||
setFinalField(QuestData.class, "assets", newData, new QuestAssets());
|
||||
|
||||
int diffIdx = Integer.parseInt(document.getElementsByTagName("diffIndex").item(0).getTextContent());
|
||||
setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx));
|
||||
}
|
||||
|
||||
if (saveVersion < 4) {
|
||||
setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(), new EnumMap<QuestItemType, Integer>(QuestItemType.class));
|
||||
}
|
||||
|
||||
QuestAssets qS = newData.getAssets();
|
||||
|
||||
switch (saveVersion) {
|
||||
// There should be a fall-through b/w the cases so that each
|
||||
// version's changes get applied progressively
|
||||
case 0:
|
||||
// First beta release with new file format,
|
||||
// inventory needs to be migrated
|
||||
setFinalField(QuestAssets.class, "inventory", newData.getAssets(), new QuestInventory());
|
||||
setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(), new EnumMap<QuestItemType, Integer>(QuestItemType.class));
|
||||
NodeList elements = document.getElementsByTagName("estatesLevel");
|
||||
newData.getAssets().getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent()));
|
||||
qS.setItemLevel(QuestItemType.ESTATES, Integer.parseInt(elements.item(0).getTextContent()));
|
||||
elements = document.getElementsByTagName("luckyCoinLevel");
|
||||
newData.getAssets().getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent()));
|
||||
qS.setItemLevel(QuestItemType.LUCKY_COIN, Integer.parseInt(elements.item(0).getTextContent()));
|
||||
elements = document.getElementsByTagName("sleightOfHandLevel");
|
||||
newData.getAssets().getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent()));
|
||||
qS.setItemLevel(QuestItemType.SLEIGHT, Integer.parseInt(elements.item(0).getTextContent()));
|
||||
elements = document.getElementsByTagName("gearLevel");
|
||||
|
||||
final int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
|
||||
if (gearLevel >= 1) {
|
||||
newData.getAssets().getInventory().setItemLevel("Map", 1);
|
||||
newData.getAssets().setItemLevel(QuestItemType.MAP, 1);
|
||||
}
|
||||
if (gearLevel == 2) {
|
||||
newData.getAssets().getInventory().setItemLevel("Zeppelin", 1);
|
||||
newData.getAssets().setItemLevel(QuestItemType.ZEPPELIN, 1);
|
||||
}
|
||||
// fall-through
|
||||
case 1:
|
||||
@@ -196,6 +200,7 @@ public class QuestDataIO {
|
||||
// deserializer
|
||||
|
||||
case 2:
|
||||
// questdata was divided into assets and achievements
|
||||
if (StringUtils.isBlank(newData.getName())) {
|
||||
setFinalField(QuestData.class, "name", newData, "questData");
|
||||
}
|
||||
@@ -218,18 +223,45 @@ public class QuestDataIO {
|
||||
completedChallenges.add(Integer.parseInt(n.getTextContent()));
|
||||
}
|
||||
|
||||
QuestAssets qS = newData.getAssets();
|
||||
|
||||
XStream xs = getSerializer(true);
|
||||
|
||||
setFinalField(QuestAssets.class, "credits", qS, Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent()));
|
||||
setFinalField(QuestAssets.class, "life", qS, Integer.parseInt(document.getElementsByTagName("life").item(0).getTextContent()));
|
||||
setFinalField(QuestAssets.class, "cardPool", qS, readAsset(xs, document, "cardPool", ItemPool.class));
|
||||
setFinalField(QuestAssets.class, "inventory", qS, readAsset(xs, document, "inventory", QuestInventory.class));
|
||||
setFinalField(QuestAssets.class, "myDecks", qS, readAsset(xs, document, "myDecks", HashMap.class));
|
||||
setFinalField(QuestAssets.class, "petManager", qS, readAsset(xs, document, "petManager", QuestPetManager.class));
|
||||
setFinalField(QuestAssets.class, "shopList", qS, readAsset(xs, document, "shopList", ItemPool.class));
|
||||
setFinalField(QuestAssets.class, "newCardList", qS, readAsset(xs, document, "newCardList", ItemPool.class));
|
||||
|
||||
case 3:
|
||||
// QuestInventory class no longer exists - KV pairs of QuestItemPair => level moved to assets
|
||||
if (saveVersion > 0)
|
||||
{
|
||||
Node oldInventory = document.getElementsByTagName("inventory").item(1);
|
||||
if ( null != oldInventory ) {
|
||||
for(int iN = 0; iN < oldInventory.getChildNodes().getLength(); iN++ ) {
|
||||
Node _n = oldInventory.getChildNodes().item(iN);
|
||||
if ( _n.getNodeType() != Node.ELEMENT_NODE ) continue;
|
||||
Element n = (Element)_n;
|
||||
String name = n.getElementsByTagName("string").item(0).getTextContent();
|
||||
QuestItemType qType = QuestItemType.valueFromSaveKey(name);
|
||||
int level = 0;
|
||||
for( int iX = 0; iX < n.getChildNodes().getLength(); iX++ ) {
|
||||
Node _x = n.getChildNodes().item(iX);
|
||||
if ( _x.getNodeType() != Node.ELEMENT_NODE ) continue;
|
||||
Element x = (Element)_x;
|
||||
if ( !x.getTagName().startsWith("forge.quest.data.") ) continue;
|
||||
String sLevel = x.getElementsByTagName("level").item(0).getTextContent();
|
||||
if( StringUtils.isNotBlank(sLevel))
|
||||
level = Integer.parseInt(sLevel);
|
||||
}
|
||||
qS.setItemLevel(qType, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case 4:
|
||||
// pet manager will be re-engineered here
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -292,30 +324,6 @@ public class QuestDataIO {
|
||||
boutUnp.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Xstream subclass that ignores fields that are present in the save but not
|
||||
* in the class. This one is intended to skip fields defined in Object class
|
||||
* (but are there any fields?)
|
||||
*/
|
||||
private static class IgnoringXStream extends XStream {
|
||||
private final List<String> ignoredFields = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
protected MapperWrapper wrapMapper(final MapperWrapper next) {
|
||||
return new MapperWrapper(next) {
|
||||
@Override
|
||||
public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") final Class definedIn,
|
||||
final String fieldName) {
|
||||
if (definedIn == Object.class) {
|
||||
IgnoringXStream.this.ignoredFields.add(fieldName);
|
||||
return false;
|
||||
}
|
||||
return super.shouldSerializeMember(definedIn, fieldName);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static class GameTypeToXml implements Converter {
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
@@ -513,3 +521,4 @@ public class QuestDataIO {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
35
src/main/java/forge/util/IgnoringXStream.java
Normal file
35
src/main/java/forge/util/IgnoringXStream.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package forge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.mapper.MapperWrapper;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Xstream subclass that ignores fields that are present in the save but not
|
||||
* in the class. This one is intended to skip fields defined in Object class
|
||||
* (but are there any fields?)
|
||||
*/
|
||||
public class IgnoringXStream extends XStream {
|
||||
private final List<String> ignoredFields = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
protected MapperWrapper wrapMapper(final MapperWrapper next) {
|
||||
return new MapperWrapper(next) {
|
||||
@Override
|
||||
public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") final Class definedIn,
|
||||
final String fieldName) {
|
||||
if (definedIn == Object.class) {
|
||||
IgnoringXStream.this.ignoredFields.add(fieldName);
|
||||
return false;
|
||||
}
|
||||
return super.shouldSerializeMember(definedIn, fieldName);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -47,10 +47,13 @@ public class ViewItem extends FPanel {
|
||||
@Override
|
||||
public void execute() {
|
||||
QuestAssets qA = AllZone.getQuest().getAssets();
|
||||
qA.subtractCredits(getItem().getBuyingPrice(qA));
|
||||
int cost = getItem().getBuyingPrice(qA);
|
||||
if ( qA.getCredits() - cost >= 0 ) {
|
||||
qA.subtractCredits(cost);
|
||||
qA.addCredits(getItem().getSellingPrice(qA));
|
||||
getItem().onPurchase(qA);
|
||||
AllZone.getQuest().save();
|
||||
}
|
||||
Singletons.getView().getViewBazaar().refreshLastInstance();
|
||||
}
|
||||
});
|
||||
@@ -75,7 +78,7 @@ public class ViewItem extends FPanel {
|
||||
lblIcon.setIcon(getItem().getIcon());
|
||||
lblName.setText(getItem().getPurchaseName());
|
||||
lblPrice.setText("Cost: " + String.valueOf(getItem().getBuyingPrice(qA)) + " credits");
|
||||
tarDesc.setText(getItem().getPurchaseDescription());
|
||||
tarDesc.setText(getItem().getPurchaseDescription(qA));
|
||||
|
||||
if (qA.getCredits() < getItem().getBuyingPrice(qA)) {
|
||||
btnPurchase.setEnabled(false);
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.control.bazaar.ControlStall;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FScrollPane;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestStallDefinition;
|
||||
import forge.quest.data.item.IQuestStallPurchasable;
|
||||
@@ -143,13 +144,14 @@ public class ViewStall extends JPanel {
|
||||
* and creates new panels if necessary.
|
||||
*/
|
||||
public void updateStall() {
|
||||
if (AllZone.getQuest().getAssets() == null) { return; }
|
||||
QuestController qData = AllZone.getQuest();
|
||||
if (qData.getAssets() == null) { return; }
|
||||
|
||||
QuestAssets qS = AllZone.getQuest().getAssets();
|
||||
this.lblStats.setText("Credits: " + qS.getCredits() + " Life: " + qS.getLife());
|
||||
|
||||
final List<IQuestStallPurchasable> items =
|
||||
AllZone.getQuest().getBazaar().getItems(stall.getName());
|
||||
QuestAssets qS = qData.getAssets();
|
||||
this.lblStats.setText("Credits: " + qS.getCredits() + " Life: " + qS.getLife(qData.getMode()));
|
||||
|
||||
final List<IQuestStallPurchasable> items = AllZone.getQuest().getBazaar().getItems(stall.getName());
|
||||
|
||||
lblStallName.setText(stall.getDisplayName());
|
||||
tpnFluff.setText(stall.getFluff());
|
||||
|
||||
@@ -58,6 +58,7 @@ import forge.quest.QuestUtil;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestMode;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.data.item.QuestItemType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
/**
|
||||
@@ -119,7 +120,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
int extraLife = 0;
|
||||
|
||||
if (qEvent.getEventType().equals("challenge")) {
|
||||
if (qa.getInventory().hasItem("Zeppelin")) {
|
||||
if (qa.hasItem(QuestItemType.ZEPPELIN)) {
|
||||
extraLife = 3;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +128,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
final CardList humanList = QuestUtil.getHumanStartingCards(qa, qEvent);
|
||||
final CardList computerList = QuestUtil.getComputerStartingCards(qEvent);
|
||||
|
||||
final int humanLife = qa.getLife() + extraLife;
|
||||
final int humanLife = qa.getLife(qData.getMode()) + extraLife;
|
||||
int computerLife = 20;
|
||||
if (qEvent.getEventType().equals("challenge")) {
|
||||
computerLife = ((QuestChallenge) qEvent).getAILife();
|
||||
@@ -424,7 +425,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
// Estates bonus
|
||||
credTotal = credBase + credGameplay + credUndefeated;
|
||||
double estateValue = 0;
|
||||
switch (qData.getAssets().getInventory().getItemLevel("Estates")) {
|
||||
switch (qData.getAssets().getItemLevel(QuestItemType.ESTATES)) {
|
||||
case 1:
|
||||
estateValue = .1;
|
||||
break;
|
||||
@@ -627,7 +628,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean getLuckyCoinResult() {
|
||||
final boolean hasCoin = qData.getAssets().getInventory().getItemLevel("Lucky Coin") >= 1;
|
||||
final boolean hasCoin = qData.getAssets().getItemLevel(QuestItemType.LUCKY_COIN) >= 1;
|
||||
|
||||
return MyRandom.getRandom().nextFloat() <= (hasCoin ? 0.65f : 0.5f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user