- 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

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

@@ -116,17 +116,17 @@ public class QuestController {
this.model.getPetSlots().put(slot, name);
}
}
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();
}
/**
*
* @param slot &emsp; int

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();