mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Fixed bugs and improved set selection for quest drafts.
This commit is contained in:
@@ -1,20 +1,6 @@
|
||||
package forge.screens.home.quest;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
@@ -32,11 +18,11 @@ import forge.item.BoosterPack;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.DeckManager;
|
||||
import forge.limited.BoosterDraft;
|
||||
import forge.model.CardBlock;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.QuestDraftUtils;
|
||||
import forge.quest.QuestEventDraft;
|
||||
import forge.quest.QuestEventDraft.QuestDraftFormat;
|
||||
import forge.quest.QuestUtil;
|
||||
import forge.quest.data.QuestAchievements;
|
||||
import forge.screens.deckeditor.CDeckEditorUI;
|
||||
@@ -51,6 +37,12 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.JXButtonPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controls the quest draft submenu in the home UI.
|
||||
*
|
||||
@@ -184,7 +176,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
final int totalPacks = prizes.boosterPacks.size();
|
||||
int currentPack = 0;
|
||||
|
||||
while (prizes.boosterPacks.size() > 0) {
|
||||
while (!prizes.boosterPacks.isEmpty()) {
|
||||
|
||||
final BoosterPack pack = prizes.boosterPacks.remove(0);
|
||||
currentPack++;
|
||||
@@ -211,7 +203,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
|
||||
final List<PaperCard> cards = new ArrayList<>();
|
||||
|
||||
while (prizes.boosterPacks.size() > 0) {
|
||||
while (!prizes.boosterPacks.isEmpty()) {
|
||||
final BoosterPack pack = prizes.boosterPacks.remove(0);
|
||||
cards.addAll(pack.getCards());
|
||||
}
|
||||
@@ -306,11 +298,21 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
|
||||
if (achievements != null) {
|
||||
|
||||
final CardBlock block = GuiChoose.oneOrNone("Choose Draft Format", QuestEventDraft.getAvailableBlocks(FModel.getQuest()));
|
||||
List<QuestDraftFormat> formats = QuestEventDraft.getAvailableFormats(FModel.getQuest());
|
||||
|
||||
if (block != null) {
|
||||
if (formats.isEmpty()) {
|
||||
FOptionPane.showErrorDialog(
|
||||
"You do not have any draft-able sets unlocked!\n" +
|
||||
"Come back later when you've unlocked more sets.",
|
||||
"No Available Drafts");
|
||||
return;
|
||||
}
|
||||
|
||||
achievements.spendDraftToken(block);
|
||||
final QuestDraftFormat format = GuiChoose.oneOrNone("Choose Draft Format", formats);
|
||||
|
||||
if (format != null) {
|
||||
|
||||
achievements.spendDraftToken(format);
|
||||
|
||||
update();
|
||||
VSubmenuQuestDraft.SINGLETON_INSTANCE.populate();
|
||||
@@ -516,6 +518,8 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
private void startDraft() {
|
||||
|
||||
if (drafting) {
|
||||
FOptionPane.showErrorDialog("You are currently in a draft.\n" +
|
||||
"You should leave or finish that draft before starting another.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -575,6 +579,12 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QuestDraftUtils.matchInProgress) {
|
||||
FOptionPane.showErrorDialog("There is already a match in progress.\n" +
|
||||
"Please wait for the current round to end before attempting to continue.");
|
||||
return;
|
||||
}
|
||||
|
||||
gui = GuiBase.getInterface().getNewGuiGame();
|
||||
QuestDraftUtils.startNextMatch(gui);
|
||||
|
||||
|
||||
@@ -16,13 +16,10 @@
|
||||
*/
|
||||
package forge.screens.match;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.GameView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.match.NextGameDecision;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestController;
|
||||
@@ -32,6 +29,9 @@ import forge.screens.home.quest.VSubmenuQuestDraft;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestWinLose.
|
||||
@@ -46,9 +46,6 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
|
||||
/**
|
||||
* Instantiates a new quest win lose handler.
|
||||
*
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestDraftWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) {
|
||||
super(view0, game0, matchUI);
|
||||
@@ -71,7 +68,6 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
|
||||
if (lastGame.isMatchOver()) {
|
||||
final String winner = lastGame.getWinningPlayerName();
|
||||
|
||||
quest.getAchievements().getCurrentDraft().setWinner(winner);
|
||||
quest.save();
|
||||
}
|
||||
@@ -107,9 +103,29 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (warningString == null ||
|
||||
FOptionPane.showOptionDialog(warningString, warningCaption, FSkin.getImage(FSkinProp.ICO_WARNING).scale(2), ImmutableList.of("Yes", "No"), 1) == 0) {
|
||||
matchUI.getGameController().nextGameDecision(NextGameDecision.QUIT);
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.continueMatches(matchUI);
|
||||
if (warningString != null) {
|
||||
PlayerView humanPlayer = null;
|
||||
for (PlayerView playerView : matchUI.getLocalPlayers()) {
|
||||
humanPlayer = playerView;
|
||||
}
|
||||
for (PlayerView playerView : lastGame.getPlayers()) {
|
||||
if (humanPlayer == null) {
|
||||
throw new IllegalStateException("Forfeit tournament button was pressed in a match without human players.");
|
||||
}
|
||||
if (playerView != humanPlayer) {
|
||||
quest.getAchievements().getCurrentDraft().setWinner(playerView.getName());
|
||||
quest.save();
|
||||
CSubmenuQuestDraft.SINGLETON_INSTANCE.update();
|
||||
VSubmenuQuestDraft.SINGLETON_INSTANCE.populate();
|
||||
}
|
||||
}
|
||||
//The player is probably not interested in watching more AI matches.
|
||||
QuestDraftUtils.cancelFurtherMatches();
|
||||
} else {
|
||||
matchUI.getGameController().nextGameDecision(NextGameDecision.QUIT);
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.continueMatches(matchUI);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
* 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/>.
|
||||
*/
|
||||
@@ -28,16 +28,15 @@ import forge.screens.home.quest.CSubmenuDuels;
|
||||
* Processes win/lose presentation for Quest events. This presentation is
|
||||
* displayed by WinLoseFrame. Components to be added to pnlCustom in
|
||||
* WinLoseFrame should use MigLayout.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class QuestWinLose extends ControlWinLose {
|
||||
private final QuestWinLoseController controller;
|
||||
|
||||
/**
|
||||
* Instantiates a new quest win lose handler.
|
||||
*
|
||||
*
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) {
|
||||
super(view0, game0, matchUI);
|
||||
@@ -51,7 +50,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* </p>
|
||||
* Checks conditions of win and fires various reward display methods
|
||||
* accordingly.
|
||||
*
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
@@ -66,7 +65,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* </p>
|
||||
* When "quit" button is pressed, this method adjusts quest data as
|
||||
* appropriate and saves.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public final void actionOnQuit() {
|
||||
|
||||
Reference in New Issue
Block a user