forked from External/mage
Merge branch 'decouple-client'
Conflicts: Mage/src/mage/cards/repository/CardRepository.java
This commit is contained in:
commit
96ff08dc9a
34 changed files with 626 additions and 242 deletions
|
|
@ -25,22 +25,15 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MageFrame.java
|
||||
*
|
||||
* Created on 15-Dec-2009, 9:11:37 PM
|
||||
*/
|
||||
|
||||
package mage.client;
|
||||
|
||||
import de.schlichtherle.truezip.file.TArchiveDetector;
|
||||
import de.schlichtherle.truezip.file.TConfig;
|
||||
import de.schlichtherle.truezip.fs.FsOutputOption;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.CardScanner;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.components.MageComponents;
|
||||
|
|
@ -67,7 +60,6 @@ import mage.client.util.SettingsManager;
|
|||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.client.util.MusicPlayer;
|
||||
import mage.components.ImagePanel;
|
||||
import mage.interfaces.Action;
|
||||
import mage.interfaces.MageClient;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
|
|
@ -75,7 +67,6 @@ import mage.remote.Connection;
|
|||
import mage.remote.Connection.ProxyType;
|
||||
import mage.remote.Session;
|
||||
import mage.remote.SessionImpl;
|
||||
import mage.server.Main;
|
||||
import mage.utils.MageVersion;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
|
@ -94,8 +85,10 @@ import java.awt.image.BufferedImage;
|
|||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
@ -205,12 +198,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
|
||||
session = new SessionImpl(this);
|
||||
session.setEmbeddedMageServerAction(new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Main.main(new String[]{});
|
||||
}
|
||||
});
|
||||
callbackClient = new CallbackClientImpl(this);
|
||||
connectDialog = new ConnectDialog();
|
||||
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
||||
|
|
@ -480,28 +467,22 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
private void checkForNewImages() {
|
||||
long beforeCall = System.currentTimeMillis();
|
||||
List<CardInfo> cards = CardRepository.instance.getAllCards();
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(new CardCriteria());
|
||||
logger.info("Card pool load time: " + ((System.currentTimeMillis() - beforeCall) / 1000 + " seconds"));
|
||||
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String path = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
|
||||
beforeCall = System.currentTimeMillis();
|
||||
if (DownloadPictures.checkForNewCards(cards, path)) {
|
||||
if (DownloadPictures.checkForNewCards(cards)) {
|
||||
logger.info("Card images checking time: " + ((System.currentTimeMillis() - beforeCall) / 1000 + " seconds"));
|
||||
if (JOptionPane.showConfirmDialog(null, "New cards are available. Do you want to download the images?", "New images available", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
DownloadPictures.startDownload(null, cards, path);
|
||||
DownloadPictures.startDownload(null, cards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void btnImagesActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
List<CardInfo> cards = CardRepository.instance.getAllCards();
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(new CardCriteria());
|
||||
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String path = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
|
||||
DownloadPictures.startDownload(null, cards, path);
|
||||
DownloadPictures.startDownload(null, cards);
|
||||
}
|
||||
|
||||
public void btnSymbolsActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
|
@ -1005,7 +986,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CardScanner.scan();
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith(liteModeArg)) {
|
||||
liteMode = true;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ import mage.constants.CardType;
|
|||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.Mana;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.util.gui.ColorsChooser;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
|
|
@ -28,8 +30,6 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.cards.ExpansionSet;
|
||||
|
||||
/**
|
||||
* Generates random card pool and builds a deck.
|
||||
*
|
||||
|
|
@ -140,7 +140,7 @@ public class DeckGenerator {
|
|||
List<String> setsToUse = ConstructedFormats.getSetsByFormat(format);
|
||||
if (setsToUse.isEmpty()) {
|
||||
// use all
|
||||
setsToUse = CardRepository.instance.getSetCodes();
|
||||
setsToUse = ExpansionRepository.instance.getSetCodes();
|
||||
}
|
||||
|
||||
if (selectedColors.contains("X")) {
|
||||
|
|
@ -226,7 +226,7 @@ public class DeckGenerator {
|
|||
int tries = 0;
|
||||
int count = 0;
|
||||
while (count < cardsCount) {
|
||||
Card card = cardPool.get(random.nextInt(cardPoolCount)).getCard();
|
||||
Card card = cardPool.get(random.nextInt(cardPoolCount)).getMockCard();
|
||||
if (cardFitsChosenColors(card, allowedColors)) {
|
||||
spellCardPool.add(card);
|
||||
count++;
|
||||
|
|
@ -291,7 +291,7 @@ public class DeckGenerator {
|
|||
int tries = 0;
|
||||
int count = 0;
|
||||
while (count < landsCount) {
|
||||
Card card = landCards.get(random.nextInt(allCount)).getCard();
|
||||
Card card = landCards.get(random.nextInt(allCount)).getMockCard();
|
||||
if (cardCardProduceChosenColors(card, allowedColors)) {
|
||||
nonBasicLandCardPool.add(card);
|
||||
count++;
|
||||
|
|
@ -378,7 +378,7 @@ public class DeckGenerator {
|
|||
}
|
||||
|
||||
int randomInt = new Random().nextInt(cards.size());
|
||||
return cards.get(randomInt).getCard();
|
||||
return cards.get(randomInt).getMockCard();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
else {
|
||||
List<CardInfo> foundCards = CardRepository.instance.findCards(buildCriteria());
|
||||
for (CardInfo cardInfo : foundCards) {
|
||||
Card card = cardInfo.getCard();
|
||||
Card card = cardInfo.getMockCard();
|
||||
if (filter.match(card, null)) {
|
||||
filteredCards.add(card);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
}
|
||||
if (card != null) {
|
||||
deck.getCards().add(card);
|
||||
|
|
@ -201,7 +201,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
} else if (event.getEventName().equals("shift-double-click") && mode == DeckEditorMode.Constructed) {
|
||||
SimpleCardView cardView = (SimpleCardView) event.getSource();
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
|
||||
Card card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
if (card != null) {
|
||||
deck.getSideboard().add(CardImpl.createCard(card.getClass()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ package mage.client.deckeditor.collection.viewer;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.MageFrame;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.components.HoverButton;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
|
@ -226,7 +226,7 @@ public class MageBook extends JComponent {
|
|||
Rectangle rectangle = new Rectangle();
|
||||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||
for (int i = 0; i < Math.min(conf.CARDS_PER_PAGE / 2, size); i++) {
|
||||
Card card = CardImpl.createCard(cards.get(i).getClassName());
|
||||
Card card = cards.get(i).getMockCard();
|
||||
addCard(new CardView(card), bigCard, null, rectangle);
|
||||
rectangle = CardPosition.translatePosition(i, rectangle, conf);
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ public class MageBook extends JComponent {
|
|||
|
||||
rectangle.setLocation(second_page_x, OFFSET_Y);
|
||||
for (int i = conf.CARDS_PER_PAGE / 2; i < Math.min(conf.CARDS_PER_PAGE, size); i++) {
|
||||
Card card = CardImpl.createCard(cards.get(i).getClassName());
|
||||
Card card = cards.get(i).getMockCard();
|
||||
addCard(new CardView(card), bigCard, null, rectangle);
|
||||
rectangle = CardPosition.translatePosition(i - conf.CARDS_PER_PAGE / 2, rectangle, conf);
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ public class MageBook extends JComponent {
|
|||
this.setsToDisplay = ConstructedFormats.getSetsByFormat(format);
|
||||
if (this.setsToDisplay.isEmpty()) {
|
||||
// display all
|
||||
this.setsToDisplay = CardRepository.instance.getSetCodes();
|
||||
this.setsToDisplay = ExpansionRepository.instance.getSetCodes();
|
||||
}
|
||||
addSetTabs();
|
||||
tabs.get(0).execute();
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class AddLandDialog extends MageDialog {
|
|||
}
|
||||
|
||||
for (int i = 0; i < number; i++) {
|
||||
Card land = cards.get(random.nextInt(cards.size())).getCard();
|
||||
Card land = cards.get(random.nextInt(cards.size())).getMockCard();
|
||||
deck.getCards().add(land);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
// Avatar
|
||||
Image image = ImageHelper.getImageFromResources(DEFAULT_AVATAR_PATH);
|
||||
|
||||
topCardPanel = Plugins.getInstance().getMageCard(new CardView(CardRepository.instance.findCard("Forest").getCard()), bigCard, topCardDimension, gameId, true);
|
||||
topCardPanel = Plugins.getInstance().getMageCard(new CardView(CardRepository.instance.findCard("Forest").getMockCard()), bigCard, topCardDimension, gameId, true);
|
||||
topCardPanel.setVisible(false);
|
||||
panelBackground.add(topCardPanel);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class CardsViewUtil {
|
|||
|
||||
for (SimpleCardView simple: view.values()) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
||||
Card card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
if (card != null) {
|
||||
cards.put(simple.getId(), new CardView(card, simple.getId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class DeckUtil {
|
|||
Deck deck = new Deck();
|
||||
for (SimpleCardView cardView : view.getCards().values()) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
|
||||
Card card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
if (card != null) {
|
||||
deck.getCards().add(card);
|
||||
} else {
|
||||
|
|
@ -61,7 +61,7 @@ public class DeckUtil {
|
|||
}
|
||||
for (SimpleCardView cardView : view.getSideboard().values()) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
|
||||
Card card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
if (card != null) {
|
||||
deck.getSideboard().add(card);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
|
||||
/**
|
||||
* Utility class for constructed formats (expansions and other editions).
|
||||
|
|
@ -16,35 +15,36 @@ import mage.cards.repository.CardRepository;
|
|||
*/
|
||||
public class ConstructedFormats {
|
||||
|
||||
private static final String[] constructedFormats = {"- All Sets", "- Standard", "- Extended", "- Modern",
|
||||
"Modern Masters",
|
||||
"* Return to Ravnica Block", "Dragon's Maze", "Gatecrash","Return to Ravnica",
|
||||
"Magic 2013", "Planechase 2012",
|
||||
"* Innistrad Block", "Avacyn Restored", "Dark Ascension", "Innistrad",
|
||||
"Magic 2012", "Commander",
|
||||
"* Scars of Mirrodin Block", "New Phyrexia", "Mirrodin Besieged", "Scars of Mirrodin", "Magic 2011",
|
||||
"* Zendikar Block", "Rise of the Eldrazi", "Worldwake", "Zendikar",
|
||||
"Magic 2010", "Planechase",
|
||||
"* Shards of Alara Block", "Alara Reborn", "Conflux", "Shards of Alara",
|
||||
"* Shadowmoor Block", "Shadowmoor", "Eventide",
|
||||
"* Lorwyn Block", "Lorwyn", "Morningtide",
|
||||
"* Time Spiral Block", "Future Sight", "Planar Chaos", "Time Spiral", "Tenth Edition",
|
||||
"* Ravnica Block", "Dissension", "Guildpact", "Ravnica: City of Guilds",
|
||||
"* Kamigawa Block", "Saviors of Kamigawa", "Betrayers of Kamigawa", "Champions of Kamigawa","Ninth Edition",
|
||||
"* Mirrodin Block", "Fifth Dawn", "Darksteel", "Mirrodin",
|
||||
"* Onslaught Block", "Scourge", "Legions", "Onslaught","Eighth Edition",
|
||||
"* Odyssey Block", "Judgment", "Torment", "Odyssey",
|
||||
"* Invasion Block", "Apocalypse", "Planeshift", "Invasion","Seventh Edition",
|
||||
"* Masquerade Block", "Prophecy", "Nemesis", "Mercadian Masques",
|
||||
"* Urza Block", "Urza's Destiny", "Urza's Legacy", "Urza's Saga", "Sixth Edition",
|
||||
"* Tempest Block", "Exodus", "Stronghold", "Tempest",
|
||||
"* Mirage Block", "Weatherlight", "Visions", "Mirage", "Fifth Edition",
|
||||
"* Ice Age Block", "Coldsnap", "Alliances", "Ice Age", "Fourth Edition",
|
||||
"Homelands","Fallen Empires","The Dark","Legends","Antiquities", "Arabian Nights",
|
||||
"Revised Edition", "Unlimited Edition", "Limited Edition Beta", "Limited Edition Alpha",
|
||||
"Guru",
|
||||
"Duel Decks: Elspeth vs. Tezzeret"
|
||||
};
|
||||
private static final String[] constructedFormats = {
|
||||
"- All Sets", "- Standard", "- Extended", "- Modern",
|
||||
"Modern Masters",
|
||||
"* Return to Ravnica Block", "Dragon's Maze", "Gatecrash", "Return to Ravnica",
|
||||
"Magic 2013", "Planechase 2012",
|
||||
"* Innistrad Block", "Avacyn Restored", "Dark Ascension", "Innistrad",
|
||||
"Magic 2012", "Commander",
|
||||
"* Scars of Mirrodin Block", "New Phyrexia", "Mirrodin Besieged", "Scars of Mirrodin", "Magic 2011",
|
||||
"* Zendikar Block", "Rise of the Eldrazi", "Worldwake", "Zendikar",
|
||||
"Magic 2010", "Planechase",
|
||||
"* Shards of Alara Block", "Alara Reborn", "Conflux", "Shards of Alara",
|
||||
"* Shadowmoor Block", "Shadowmoor", "Eventide",
|
||||
"* Lorwyn Block", "Lorwyn", "Morningtide",
|
||||
"* Time Spiral Block", "Future Sight", "Planar Chaos", "Time Spiral", "Tenth Edition",
|
||||
"* Ravnica Block", "Dissension", "Guildpact", "Ravnica: City of Guilds",
|
||||
"* Kamigawa Block", "Saviors of Kamigawa", "Betrayers of Kamigawa", "Champions of Kamigawa", "Ninth Edition",
|
||||
"* Mirrodin Block", "Fifth Dawn", "Darksteel", "Mirrodin",
|
||||
"* Onslaught Block", "Scourge", "Legions", "Onslaught", "Eighth Edition",
|
||||
"* Odyssey Block", "Judgment", "Torment", "Odyssey",
|
||||
"* Invasion Block", "Apocalypse", "Planeshift", "Invasion", "Seventh Edition",
|
||||
"* Masquerade Block", "Prophecy", "Nemesis", "Mercadian Masques",
|
||||
"* Urza Block", "Urza's Destiny", "Urza's Legacy", "Urza's Saga", "Sixth Edition",
|
||||
"* Tempest Block", "Exodus", "Stronghold", "Tempest",
|
||||
"* Mirage Block", "Weatherlight", "Visions", "Mirage", "Fifth Edition",
|
||||
"* Ice Age Block", "Coldsnap", "Alliances", "Ice Age", "Fourth Edition",
|
||||
"Homelands", "Fallen Empires", "The Dark", "Legends", "Antiquities", "Arabian Nights",
|
||||
"Revised Edition", "Unlimited Edition", "Limited Edition Beta", "Limited Edition Alpha",
|
||||
"Guru",
|
||||
"Duel Decks: Elspeth vs. Tezzeret"
|
||||
};
|
||||
|
||||
private ConstructedFormats() {
|
||||
}
|
||||
|
|
@ -379,9 +379,7 @@ public class ConstructedFormats {
|
|||
}
|
||||
|
||||
private static void buildLists() {
|
||||
for (String setCode : CardRepository.instance.getSetCodes()) {
|
||||
ExpansionSet set = Sets.findSet(setCode);
|
||||
|
||||
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
||||
if (set.getReleaseDate().after(standardDate)) {
|
||||
standard.add(set.getCode());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue