mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
* TXT deck importer - Changes to recognize sideboard starting and split cards in txt files from MTGO.
This commit is contained in:
parent
61dff9e3c2
commit
80f56dfb42
3 changed files with 16 additions and 3 deletions
|
|
@ -105,7 +105,7 @@ public abstract class SplitCard extends CardImpl {
|
|||
|
||||
@Override
|
||||
public Abilities<Ability> getAbilities(){
|
||||
Abilities<Ability> allAbilites = new AbilitiesImpl<Ability>();
|
||||
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
|
||||
for (Ability ability : super.getAbilities()) {
|
||||
if (ability instanceof SpellAbility && !((SpellAbility)ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) {
|
||||
allAbilites.add(ability);
|
||||
|
|
|
|||
|
|
@ -48,16 +48,26 @@ import mage.cards.repository.ExpansionRepository;
|
|||
public class TxtDeckImporter extends DeckImporter {
|
||||
|
||||
public static final String[] SET_VALUES = new String[] { "lands", "creatures", "planeswalkers","other spells","sideboard cards" };
|
||||
public static final Set<String> IGNORE_NAMES = new HashSet<String>(Arrays.asList(SET_VALUES));
|
||||
public static final Set<String> IGNORE_NAMES = new HashSet<>(Arrays.asList(SET_VALUES));
|
||||
|
||||
private boolean sideboard = false;
|
||||
private int emptyLinesInARow = 0;
|
||||
|
||||
|
||||
@Override
|
||||
protected void readLine(String line, DeckCardLists deckList) {
|
||||
if (line.length() == 0 || line.startsWith("//")) {
|
||||
if (line.startsWith("//")) {
|
||||
return;
|
||||
}
|
||||
if (line.length() == 0) {
|
||||
emptyLinesInARow++;
|
||||
if (emptyLinesInARow > 1) {
|
||||
sideboard = true;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
emptyLinesInARow = 0;
|
||||
}
|
||||
|
||||
if (line.toLowerCase().startsWith("sideboard")) {
|
||||
sideboard = true;
|
||||
|
|
@ -70,6 +80,7 @@ public class TxtDeckImporter extends DeckImporter {
|
|||
}
|
||||
String lineNum = line.substring(0, delim).trim();
|
||||
String lineName = line.substring(delim).replace("’","\'").trim();
|
||||
lineName = lineName.replace("&","//");
|
||||
if (IGNORE_NAMES.contains(lineName)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue