mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
fixed Issue 76
This commit is contained in:
parent
04120e4ee3
commit
da316cc345
6 changed files with 35 additions and 16 deletions
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.sets.Sets;
|
||||
|
||||
|
|
@ -50,10 +51,11 @@ public class DecDeckImporter extends DeckImporterImpl {
|
|||
String lineName = line.substring(delim).trim();
|
||||
try {
|
||||
int num = Integer.parseInt(lineNum);
|
||||
String cardName = Sets.findCard(lineName).getClass().getCanonicalName();
|
||||
if (cardName == null)
|
||||
Card card = Sets.findCard(lineName);
|
||||
if (card == null)
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
|
||||
else {
|
||||
String cardName = card.getClass().getCanonicalName();
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (!sideboard)
|
||||
deckList.getCards().add(cardName);
|
||||
|
|
|
|||
|
|
@ -612,7 +612,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
refreshDeck();
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastImportFolder", file.getCanonicalPath());
|
||||
if (file != null)
|
||||
MageFrame.getPreferences().put("lastImportFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcImportDeck.setSelectedFile(null);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ public abstract class DeckImporterImpl implements DeckImporter {
|
|||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), sbMessage.toString(), "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally {
|
||||
scanner.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.MageFrame;
|
||||
import mage.sets.Sets;
|
||||
|
||||
/**
|
||||
|
|
@ -48,23 +51,30 @@ public class MWSDeckImporter extends DeckImporterImpl {
|
|||
}
|
||||
int delim = line.indexOf(' ');
|
||||
String lineNum = line.substring(0, delim).trim();
|
||||
int setStart = line.indexOf('[') + 1;
|
||||
int setEnd = line.indexOf(']');
|
||||
String setCode = line.substring(setStart, setEnd).trim();
|
||||
String lineName = line.substring(setEnd + 1).trim();
|
||||
String setCode = "";
|
||||
if (line.indexOf('[') != -1 ) {
|
||||
int setStart = line.indexOf('[') + 1;
|
||||
int setEnd = line.indexOf(']');
|
||||
setCode = line.substring(setStart, setEnd).trim();
|
||||
delim = setEnd;
|
||||
}
|
||||
String lineName = line.substring(delim + 1).trim();
|
||||
try {
|
||||
int num = Integer.parseInt(lineNum);
|
||||
ExpansionSet set = Sets.findSet(setCode);
|
||||
String cardName;
|
||||
ExpansionSet set = null;
|
||||
if (setCode.length() > 0)
|
||||
set = Sets.findSet(setCode);
|
||||
Card card;
|
||||
if (set != null) {
|
||||
cardName = set.findCard(lineName).getClass().getCanonicalName();
|
||||
card = set.findCard(lineName);
|
||||
}
|
||||
else {
|
||||
cardName = Sets.findCard(lineName).getClass().getCanonicalName();
|
||||
card = Sets.findCard(lineName);
|
||||
}
|
||||
if (cardName == null)
|
||||
if (card == null)
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
|
||||
else {
|
||||
String cardName = card.getClass().getCanonicalName();
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (!sideboard)
|
||||
deckList.getCards().add(cardName);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.sets.Sets;
|
||||
|
||||
|
|
@ -51,10 +52,11 @@ public class TxtDeckImporter extends DeckImporterImpl {
|
|||
String lineName = line.substring(delim).trim();
|
||||
try {
|
||||
int num = Integer.parseInt(lineNum);
|
||||
String cardName = Sets.findCard(lineName).getClass().getCanonicalName();
|
||||
if (cardName == null)
|
||||
Card card = Sets.findCard(lineName);
|
||||
if (card == null)
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
|
||||
else {
|
||||
String cardName = card.getClass().getCanonicalName();
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (!sideboard)
|
||||
deckList.getCards().add(cardName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue