mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Support displaying tournaments
Make display of credits number consistent
This commit is contained in:
10
forge-gui/src/main/java/forge/quest/IQuestEvent.java
Normal file
10
forge-gui/src/main/java/forge/quest/IQuestEvent.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package forge.quest;
|
||||
|
||||
import forge.game.player.IHasIcon;
|
||||
|
||||
public interface IQuestEvent extends IHasIcon {
|
||||
String getFullTitle();
|
||||
String getDescription();
|
||||
void select();
|
||||
boolean hasImage();
|
||||
}
|
||||
@@ -20,7 +20,6 @@ package forge.quest;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.deck.Deck;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.item.InventoryItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,7 +34,7 @@ import java.util.List;
|
||||
* MODEL - A basic event instance in Quest mode. Can be extended for use in
|
||||
* unique event types: battles, quests, and others.
|
||||
*/
|
||||
public abstract class QuestEvent implements IHasIcon {
|
||||
public abstract class QuestEvent implements IQuestEvent {
|
||||
// Default vals if none provided in the event file.
|
||||
private Deck eventDeck = null;
|
||||
private String title = "Mystery Event";
|
||||
@@ -53,7 +52,7 @@ public abstract class QuestEvent implements IHasIcon {
|
||||
};
|
||||
|
||||
public final String getTitle() {
|
||||
return this.title;
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,57 +63,57 @@ public abstract class QuestEvent implements IHasIcon {
|
||||
}
|
||||
|
||||
public final QuestEventDifficulty getDifficulty() {
|
||||
return this.difficulty;
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public final String getDescription() {
|
||||
return this.description;
|
||||
return description;
|
||||
}
|
||||
|
||||
public final Deck getEventDeck() {
|
||||
return this.eventDeck;
|
||||
return eventDeck;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getIconImageKey() {
|
||||
return this.imageKey;
|
||||
return imageKey;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
return name;
|
||||
}
|
||||
|
||||
public final String getProfile() {
|
||||
return this.profile;
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(final String profi) {
|
||||
this.profile = profi;
|
||||
public void setProfile(final String profile0) {
|
||||
profile = profile0;
|
||||
}
|
||||
|
||||
public void setName(final String name0) {
|
||||
this.name = name0;
|
||||
name = name0;
|
||||
}
|
||||
|
||||
public void setTitle(final String title0) {
|
||||
this.title = title0;
|
||||
title = title0;
|
||||
}
|
||||
|
||||
public void setDifficulty(final QuestEventDifficulty difficulty0) {
|
||||
this.difficulty = difficulty0;
|
||||
difficulty = difficulty0;
|
||||
}
|
||||
|
||||
public void setDescription(final String description0) {
|
||||
this.description = description0;
|
||||
description = description0;
|
||||
}
|
||||
|
||||
public void setEventDeck(final Deck eventDeck0) {
|
||||
this.eventDeck = eventDeck0;
|
||||
eventDeck = eventDeck0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIconImageKey(final String s0) {
|
||||
this.imageKey = s0;
|
||||
imageKey = s0;
|
||||
}
|
||||
|
||||
public final List<InventoryItem> getCardRewardList() {
|
||||
@@ -122,13 +121,13 @@ public abstract class QuestEvent implements IHasIcon {
|
||||
return null;
|
||||
}
|
||||
if (cardRewardList == null) {
|
||||
this.cardRewardList = new ArrayList<InventoryItem>(BoosterUtils.generateCardRewardList(cardReward));
|
||||
cardRewardList = new ArrayList<InventoryItem>(BoosterUtils.generateCardRewardList(cardReward));
|
||||
}
|
||||
return this.cardRewardList;
|
||||
return cardRewardList;
|
||||
}
|
||||
|
||||
public void setCardReward(final String cardReward0) {
|
||||
this.cardReward = cardReward0;
|
||||
cardReward = cardReward0;
|
||||
}
|
||||
|
||||
public List<String> getHumanExtraCards() {
|
||||
@@ -138,4 +137,19 @@ public abstract class QuestEvent implements IHasIcon {
|
||||
public List<String> getAiExtraCards() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getFullTitle() {
|
||||
return title + " (" + difficulty.getTitle() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select() {
|
||||
QuestUtil.setEvent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasImage() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.*;
|
||||
* MODEL - A basic event instance in Quest mode. Can be extended for use in
|
||||
* unique event types: battles, quests, and others.
|
||||
*/
|
||||
public class QuestEventDraft {
|
||||
public class QuestEventDraft implements IQuestEvent {
|
||||
|
||||
public static class QuestDraftPrizes {
|
||||
|
||||
@@ -1097,4 +1097,45 @@ public class QuestEventDraft {
|
||||
|
||||
return bracket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getFullTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getBoosterList() {
|
||||
String boosterList = "";
|
||||
String[] boosterArray = boosterConfiguration.split("/");
|
||||
for (int i = 0; i < boosterArray.length; i++) {
|
||||
boosterList += FModel.getMagicDb().getEditions().get(boosterArray[i]).getName();
|
||||
if (i != boosterArray.length - 1) {
|
||||
boosterList += " | ";
|
||||
}
|
||||
}
|
||||
return boosterList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getBoosterList() + "\n" + QuestUtil.formatCredits(entryFee) + " Credit Entry Fee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select() {
|
||||
QuestUtil.setDraftEvent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconImageKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIconImageKey(String iconImageKey) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasImage() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class QuestTournamentController {
|
||||
final QuestEventDraft.QuestDraftPrizes prizes = draft.collectPrizes();
|
||||
|
||||
if (prizes.hasCredits()) {
|
||||
SOptionPane.showMessageDialog("For placing " + placement + ", you have been awarded " + prizes.credits + " credits!", "Credits Awarded", FSkinProp.ICO_QUEST_GOLD);
|
||||
SOptionPane.showMessageDialog("For placing " + placement + ", you have been awarded " + QuestUtil.formatCredits(prizes.credits) + " credits!", "Credits Awarded", FSkinProp.ICO_QUEST_GOLD);
|
||||
}
|
||||
|
||||
if (prizes.hasIndividualCards()) {
|
||||
@@ -230,7 +230,7 @@ public class QuestTournamentController {
|
||||
}
|
||||
|
||||
private void updateSelectTournament() {
|
||||
view.getLblCredits().setText("Credits: " + FModel.getQuest().getAssets().getCredits());
|
||||
view.getLblCredits().setText("Credits: " + QuestUtil.formatCredits(FModel.getQuest().getAssets().getCredits()));
|
||||
|
||||
final QuestAchievements achievements = FModel.getQuest().getAchievements();
|
||||
achievements.generateDrafts();
|
||||
@@ -390,11 +390,11 @@ public class QuestTournamentController {
|
||||
|
||||
final long creditsAvailable = FModel.getQuest().getAssets().getCredits();
|
||||
if (draftEvent.canEnter()) {
|
||||
SOptionPane.showMessageDialog("You need " + (draftEvent.getEntryFee() - creditsAvailable) + " more credits to enter this tournament.", "Not Enough Credits", SOptionPane.WARNING_ICON);
|
||||
SOptionPane.showMessageDialog("You need " + QuestUtil.formatCredits(draftEvent.getEntryFee() - creditsAvailable) + " more credits to enter this tournament.", "Not Enough Credits", SOptionPane.WARNING_ICON);
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean okayToEnter = SOptionPane.showOptionDialog("This tournament costs " + draftEvent.getEntryFee() + " credits to enter.\nAre you sure you wish to enter?", "Enter Draft Tournament?", FSkinProp.ICO_QUEST_GOLD, ImmutableList.of("Yes", "No"), 1) == 0;
|
||||
final boolean okayToEnter = SOptionPane.showOptionDialog("This tournament costs " + QuestUtil.formatCredits(draftEvent.getEntryFee()) + " credits to enter.\nAre you sure you wish to enter?", "Enter Draft Tournament?", FSkinProp.ICO_QUEST_GOLD, ImmutableList.of("Yes", "No"), 1) == 0;
|
||||
|
||||
if (!okayToEnter) {
|
||||
return;
|
||||
|
||||
@@ -49,6 +49,7 @@ import forge.util.gui.SOptionPane;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -62,6 +63,10 @@ import java.util.List;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestUtil {
|
||||
private static final DecimalFormat CREDITS_FORMATTER = new DecimalFormat("#,###");
|
||||
public static String formatCredits(long credits) {
|
||||
return CREDITS_FORMATTER.format(credits);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -368,7 +373,7 @@ public class QuestUtil {
|
||||
view0.getLblLife().setVisible(true);
|
||||
|
||||
// Stats panel
|
||||
view0.getLblCredits().setText("Credits: " + qS.getCredits());
|
||||
view0.getLblCredits().setText("Credits: " + QuestUtil.formatCredits(qS.getCredits()));
|
||||
view0.getLblLife().setText("Life: " + qS.getLife(qCtrl.getMode()));
|
||||
view0.getLblWins().setText("Wins: " + qA.getWin());
|
||||
view0.getLblLosses().setText("Losses: " + qA.getLost());
|
||||
|
||||
Reference in New Issue
Block a user