- Adding Amulet of Vim to allow 1 game matches to be played in quest mode

This commit is contained in:
Sol
2015-10-13 22:32:02 +00:00
parent f011fa8143
commit e80d30ba5c
15 changed files with 122 additions and 60 deletions

1
.gitattributes vendored
View File

@@ -18277,6 +18277,7 @@ forge-gui/src/main/java/forge/quest/bazaar/IQuestBazaarItem.java svneol=native#t
forge-gui/src/main/java/forge/quest/bazaar/QuestBazaarManager.java svneol=native#text/plain
forge-gui/src/main/java/forge/quest/bazaar/QuestItemBasic.java svneol=native#text/plain
forge-gui/src/main/java/forge/quest/bazaar/QuestItemCharmOfVigor.java -text
forge-gui/src/main/java/forge/quest/bazaar/QuestItemCharmOfVim.java -text
forge-gui/src/main/java/forge/quest/bazaar/QuestItemElixir.java -text
forge-gui/src/main/java/forge/quest/bazaar/QuestItemEstates.java svneol=native#text/plain
forge-gui/src/main/java/forge/quest/bazaar/QuestItemMembership.java -text

View File

@@ -103,11 +103,14 @@ public enum CSubmenuChallenges implements ICDoc {
}
});
view.getCbCharm().addActionListener(new ActionListener() {
view.getCbxMatchLength().addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
quest.setCharmState(view.getCbCharm().isSelected());
quest.save();
String match = view.getCbxMatchLength().getSelectedItem();
if (match != null) {
quest.setMatchLength(match.substring(match.length() - 1));
quest.save();
}
}
});
}
@@ -154,6 +157,10 @@ public enum CSubmenuChallenges implements ICDoc {
final JXButtonPanel grpPanel = new JXButtonPanel();
StringBuilder sb = new StringBuilder();
sb.append("Match - Best of ").append(FModel.getQuest().getMatchLength());
view.getCbxMatchLength().setSelectedItem(sb.toString());
boolean haveAnyChallenges = true;
for (final QuestEventChallenge qc : challenges) {
final PnlEvent temp = new PnlEvent(qc);

View File

@@ -71,11 +71,14 @@ public enum CSubmenuDuels implements ICDoc {
}
});
view.getCbCharm().addActionListener(new ActionListener() {
view.getCbxMatchLength().addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
quest.setCharmState(view.getCbCharm().isSelected());
quest.save();
String match = view.getCbxMatchLength().getSelectedItem();
if (match != null) {
quest.setMatchLength(match.substring(match.length() - 1));
quest.save();
}
}
});
@@ -153,6 +156,10 @@ public enum CSubmenuDuels implements ICDoc {
grpPanel.add(temp, rad, "w 100%!, h 135px!, gapy 15px");
}
view.getPnlDuels().add(grpPanel, "w 100%!");
StringBuilder sb = new StringBuilder();
sb.append("Match - Best of ").append(FModel.getQuest().getMatchLength());
view.getCbxMatchLength().setSelectedItem(sb.toString());
}
}

View File

@@ -48,7 +48,9 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
private final StartButton btnStart = new StartButton();
private final FComboBoxWrapper<String> cbxPet = new FComboBoxWrapper<String>();
private final FCheckBox cbPlant = new FCheckBox("Summon Plant");
private final FCheckBox cbCharm = new FCheckBox("Use Charm of Vigor");
private final FComboBoxWrapper<String> cbxMatchLength = new FComboBoxWrapper<String>();
private final FLabel lblZep = new FLabel.Builder().text("<html>Launch<br>Zeppelin</html>")
.hoverable(true).icon(FSkin.getIcon(FSkinProp.ICO_QUEST_ZEP))
.fontSize(16).build();
@@ -106,7 +108,7 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
pnlStats.add(lblLife, constraints);
pnlStats.add(lblWorld, constraints);
pnlStats.add(cbPlant, constraints);
pnlStats.add(cbCharm, constraints);
cbxMatchLength.addTo(pnlStats, constraints);
cbxPet.addTo(pnlStats, constraints);
pnlStats.add(lblZep, "w 130px!, h 60px!, gap 0 0 0 5px");
pnlStats.setOpaque(false);
@@ -292,12 +294,9 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
return parentCell;
}
/**
* @return the cbCharm
*/
@Override
public FCheckBox getCbCharm() {
return cbCharm;
public FComboBoxWrapper<String> getCbxMatchLength() {
return cbxMatchLength;
}
@Override

View File

@@ -46,7 +46,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
private final StartButton btnStart = new StartButton();
private final FComboBoxWrapper<String> cbxPet = new FComboBoxWrapper<String>();
private final FCheckBox cbCharm = new FCheckBox("Use Charm of Vigor");
private final FComboBoxWrapper<String> cbxMatchLength = new FComboBoxWrapper<String>();
private final FCheckBox cbPlant = new FCheckBox("Summon Plant");
private final FLabel lblZep = new FLabel.Builder().text("Launch Zeppelin").fontSize(14).build();
@@ -107,7 +107,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
pnlStats.add(lblLife, constraints);
pnlStats.add(lblWorld, constraints);
pnlStats.add(cbPlant, constraints);
pnlStats.add(cbCharm, constraints);
cbxMatchLength.addTo(pnlStats, constraints);
cbxPet.addTo(pnlStats, constraints);
pnlStats.setOpaque(false);
@@ -297,12 +297,9 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
return parentCell;
}
/**
* @return the cbCharm
*/
@Override
public FCheckBox getCbCharm() {
return cbCharm;
public FComboBoxWrapper<String> getCbxMatchLength() {
return cbxMatchLength;
}
@Override

View File

@@ -304,8 +304,8 @@ public class QuestMenu extends FPopupMenu implements IVQuestStats {
}
@Override
public ICheckBox getCbCharm() {
return statsScreen.getCbCharm();
public IComboBox<String> getCbxMatchLength() {
return statsScreen.getCbxMatchLength();
}
@Override

View File

@@ -60,7 +60,7 @@ public class QuestStatsScreen extends FScreen {
.icon(FSkinImage.QUEST_MAP)
.font(FSkinFont.get(16)).iconScaleFactor(1).build());
private final FComboBox<String> cbxPet = scroller.add(new FComboBox<String>());
private final FCheckBox cbCharm = scroller.add(new FCheckBox("Use Charm of Vigor"));
private final FComboBox<String> cbxMatchLength = new FComboBox<String>();
private final FCheckBox cbPlant = scroller.add(new FCheckBox("Summon Plant"));
private final FLabel lblZep = scroller.add(new FLabel.Builder().text("Launch Zeppelin").icon(FSkinImage.QUEST_ZEP).font(FSkinFont.get(16)).opaque().build());
@@ -88,8 +88,8 @@ public class QuestStatsScreen extends FScreen {
public ICheckBox getCbPlant() {
return cbPlant;
}
public ICheckBox getCbCharm() {
return cbCharm;
public IComboBox<String> getCbxMatchLength() {
return cbxMatchLength;
}
public IButton getLblZep() {
return lblZep;
@@ -110,13 +110,18 @@ public class QuestStatsScreen extends FScreen {
FModel.getQuest().save();
}
});
cbCharm.setCommand(new FEventHandler() {
cbxMatchLength.setDropDownChangeHandler(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
FModel.getQuest().setCharmState(cbCharm.isSelected());
FModel.getQuest().save();
String match = cbxMatchLength.getSelectedItem();
if (match != null) {
FModel.getQuest().setMatchLength(match.substring(match.length() - 1));
FModel.getQuest().save();
}
}
});
cbPlant.setCommand(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {

View File

@@ -32,6 +32,7 @@
<string>Map</string>
<string>Zeppelin</string>
<string>Charm of Vigor</string>
<string>Charm of Vim</string>
</items>
</stall>
<stall name="Nursery" displayName="Force of Nature Nursery" icon="ICO_QUEST_LEAF">
@@ -92,6 +93,12 @@ Effect: Reduces maximum life by 1.</description>
Effect: Gives +1 to maximum life.
Fine Print: Loses effectiveness after 15 uses.</description>
</item>
<item name="Charm of Vim" maxLevel="1" basePrice="1000"
itemType="CHARM_VIM" icon="ICO_QUEST_CHARM">
<description>A charm fills you with energy, speeding your movements.
Effect: You may have each match be best of 1 instead of 3.</description>
</item>
<item name="Charm of Vigor" maxLevel="1" basePrice="1000"
itemType="CHARM" icon="ICO_QUEST_CHARM">

View File

@@ -23,8 +23,8 @@ public interface IVQuestStats {
IButton getLblWinStreak();
IComboBox<String> getCbxPet();
IComboBox<String> getCbxMatchLength();
ICheckBox getCbPlant();
ICheckBox getCbCharm();
IButton getLblZep();

View File

@@ -117,14 +117,14 @@ public class QuestController {
}
}
public void setCharmState(boolean active) {
if (this.model != null) {
this.model.setCharmActive(active);
}
public void setMatchLength(String len) {
if (this.model != null) {
this.model.setMatchLength(Integer.parseInt(len));
}
}
public boolean getCharmState() {
return this.model == null ? false : this.model.isCharmActive();
public int getMatchLength() {
return this.model == null ? 3 : this.model.getMatchLength();
}
/**

View File

@@ -311,12 +311,21 @@ public class QuestUtil {
}
}
view.getCbxMatchLength().removeAllItems();
boolean activeCharms = false;
StringBuilder matchLength = new StringBuilder();
matchLength.append("Match - Best of ").append(qCtrl.getMatchLength());
if (qCtrl.getAssets().hasItem(QuestItemType.CHARM_VIM)) {
view.getCbxMatchLength().addItem("Match - Best of 1");
activeCharms = true;
}
view.getCbxMatchLength().addItem("Match - Best of 3");
if (qCtrl.getAssets().hasItem(QuestItemType.CHARM)) {
view.getCbCharm().setVisible(true);
}
else {
view.getCbCharm().setVisible(false);
view.getCbxMatchLength().addItem("Match - Best of 5");
activeCharms = true;
}
view.getCbxMatchLength().setSelectedItem(matchLength.toString());
view.getCbxMatchLength().setVisible(activeCharms);
if (view.isChallengesView()) {
view.getLblZep().setVisible(qCtrl.getAssets().hasItem(QuestItemType.ZEPPELIN));
@@ -413,7 +422,7 @@ public class QuestUtil {
// Classic mode display changes
view0.getCbxPet().setVisible(false);
view0.getCbPlant().setVisible(false);
view0.getCbCharm().setVisible(false);
view0.getCbxMatchLength().setVisible(false);
view0.getLblZep().setVisible(false);
view0.getLblNextChallengeInWins().setVisible(false);
view0.getBtnBazaar().setVisible(false);
@@ -563,7 +572,7 @@ public class QuestUtil {
final GameRules rules = new GameRules(GameType.Quest);
rules.setPlayForAnte(useAnte);
rules.setMatchAnteRarity(matchAnteRarity);
rules.setGamesPerMatch(qData.getCharmState() ? 5 : 3);
rules.setGamesPerMatch(qData.getMatchLength());
rules.setManaBurn(FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN));
rules.setCanCloneUseTargetsImage(FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE));
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();

View File

@@ -0,0 +1,35 @@
/*
* 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.bazaar;
import forge.quest.QuestController;
import forge.quest.data.QuestAssets;
public class QuestItemCharmOfVim extends QuestItemBasic {
QuestItemCharmOfVim() {
super(QuestItemType.CHARM_VIM); // , QuestStallManager.GEAR
}
/** {@inheritDoc} */
@Override
public final boolean isAvailableForPurchase(QuestAssets qA, QuestController qCtrl) {
return super.isAvailableForPurchase(qA, qCtrl);
}
}

View File

@@ -43,6 +43,7 @@ public enum QuestItemType {
POUND_FLESH("Pound of Flesh", QuestItemPoundFlesh.class, QuestItemCondition.class),
/** The AMULET. */
CHARM("Charm of Vigor", QuestItemCharmOfVigor.class, QuestItemCondition.class),
CHARM_VIM("Charm of Vim", QuestItemCharmOfVim.class, QuestItemCondition.class),
CASH_STAKES("Cash Stakes", QuestItemBasic.class, QuestItemCondition.class),

View File

@@ -41,7 +41,7 @@ import java.util.Map;
*/
public final class QuestData {
/** Holds the latest version of the Quest Data. */
public static final int CURRENT_VERSION_NUMBER = 9;
public static final int CURRENT_VERSION_NUMBER = 10;
// This field places the version number into QD instance,
// but only when the object is created through the constructor
@@ -63,7 +63,7 @@ public final class QuestData {
private QuestAssets assets;
private QuestAchievements achievements;
private final Map<Integer, String> petSlots = new HashMap<>();
private boolean isCharmActive = false;
private int matchLength = 3;
public QuestData() { //needed for XML serialization
}
@@ -210,17 +210,6 @@ public final class QuestData {
worldId = newId;
}
/**
* @return the isCharmActive
*/
public boolean isCharmActive() {
return isCharmActive;
}
/**
* @param isCharmActive the isCharmActive to set
*/
public void setCharmActive(boolean isCharmActive) {
this.isCharmActive = isCharmActive;
}
public void setMatchLength(int len) { matchLength = len; }
public int getMatchLength() { return matchLength; }
}

View File

@@ -190,7 +190,12 @@ public class QuestDataIO {
}
if (saveVersion < 8) {
QuestDataIO.setFinalField(QuestData.class, "isCharmActive", newData, false);
// Active Charm replaced by matchLength field
//QuestDataIO.setFinalField(QuestData.class, "isCharmActive", newData, false);
}
if (saveVersion < 10) {
QuestDataIO.setFinalField(QuestData.class, "matchLength", newData, 3);
}
final QuestAssets qS = newData.getAssets();