mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
res/deck/cube dir is for decks that are intended to be cubes.
One can read values from KeyValue lines via FileSection class (it parses by itself and provides a default value for bad parses) CustomLimited is more related to limited games and its moved to game.limited package
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -11214,7 +11214,6 @@ src/main/java/forge/control/match/ControlWinLose.java -text
|
|||||||
src/main/java/forge/control/match/package-info.java -text
|
src/main/java/forge/control/match/package-info.java -text
|
||||||
src/main/java/forge/control/package-info.java -text
|
src/main/java/forge/control/package-info.java -text
|
||||||
src/main/java/forge/deck/CardCollections.java -text
|
src/main/java/forge/deck/CardCollections.java -text
|
||||||
src/main/java/forge/deck/CustomLimited.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/deck/Deck.java svneol=native#text/plain
|
src/main/java/forge/deck/Deck.java svneol=native#text/plain
|
||||||
src/main/java/forge/deck/DeckBase.java -text
|
src/main/java/forge/deck/DeckBase.java -text
|
||||||
src/main/java/forge/deck/DeckRecognizer.java -text
|
src/main/java/forge/deck/DeckRecognizer.java -text
|
||||||
@@ -11229,7 +11228,6 @@ src/main/java/forge/deck/generate/GenerateConstructedMultiColorDeck.java svneol=
|
|||||||
src/main/java/forge/deck/generate/GenerateDeckUtil.java -text
|
src/main/java/forge/deck/generate/GenerateDeckUtil.java -text
|
||||||
src/main/java/forge/deck/generate/GenerateThemeDeck.java svneol=native#text/plain
|
src/main/java/forge/deck/generate/GenerateThemeDeck.java svneol=native#text/plain
|
||||||
src/main/java/forge/deck/generate/package-info.java svneol=native#text/plain
|
src/main/java/forge/deck/generate/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/deck/io/CubeSerializer.java -text
|
|
||||||
src/main/java/forge/deck/io/DeckFileHeader.java -text
|
src/main/java/forge/deck/io/DeckFileHeader.java -text
|
||||||
src/main/java/forge/deck/io/DeckSerializer.java -text
|
src/main/java/forge/deck/io/DeckSerializer.java -text
|
||||||
src/main/java/forge/deck/io/DeckSerializerBase.java -text
|
src/main/java/forge/deck/io/DeckSerializerBase.java -text
|
||||||
@@ -11251,6 +11249,7 @@ src/main/java/forge/game/limited/BoosterDraftAI.java svneol=native#text/plain
|
|||||||
src/main/java/forge/game/limited/CCnt.java svneol=native#text/plain
|
src/main/java/forge/game/limited/CCnt.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/CardPoolLimitation.java -text
|
src/main/java/forge/game/limited/CardPoolLimitation.java -text
|
||||||
src/main/java/forge/game/limited/CardRatings.java -text
|
src/main/java/forge/game/limited/CardRatings.java -text
|
||||||
|
src/main/java/forge/game/limited/CustomLimited.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain
|
src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/IBoosterDraft.java svneol=native#text/plain
|
src/main/java/forge/game/limited/IBoosterDraft.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/SealedDeck.java svneol=native#text/plain
|
src/main/java/forge/game/limited/SealedDeck.java svneol=native#text/plain
|
||||||
@@ -11360,6 +11359,7 @@ src/main/java/forge/quest/package-info.java svneol=native#text/plain
|
|||||||
src/main/java/forge/util/Base64Coder.java svneol=native#text/plain
|
src/main/java/forge/util/Base64Coder.java svneol=native#text/plain
|
||||||
src/main/java/forge/util/CopyFiles.java svneol=native#text/plain
|
src/main/java/forge/util/CopyFiles.java svneol=native#text/plain
|
||||||
src/main/java/forge/util/FileFinder.java svneol=native#text/plain
|
src/main/java/forge/util/FileFinder.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/util/FileSection.java -text
|
||||||
src/main/java/forge/util/FileUtil.java svneol=native#text/plain
|
src/main/java/forge/util/FileUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/util/FolderMap.java svneol=native#text/plain
|
src/main/java/forge/util/FolderMap.java svneol=native#text/plain
|
||||||
src/main/java/forge/util/FolderMapView.java -text
|
src/main/java/forge/util/FolderMapView.java -text
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.security.InvalidParameterException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
@@ -233,6 +234,14 @@ public class BoosterGenerator {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final List<CardPrinted> getBoosterPack(final Map<CardRarity, Integer> numbers,
|
||||||
|
final int nRareSlots, final int nDoubls, final int nAnyCard) {
|
||||||
|
return getBoosterPack( numbers.get(CardRarity.Common), numbers.get(CardRarity.Uncommon), nRareSlots,
|
||||||
|
numbers.get(CardRarity.Rare), numbers.get(CardRarity.MythicRare), numbers.get(CardRarity.Special),
|
||||||
|
nDoubls, nAnyCard, numbers.get(CardRarity.BasicLand) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* So many parameters are needed for custom limited cardpools,.
|
* So many parameters are needed for custom limited cardpools,.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package forge.deck;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import forge.deck.io.CubeSerializer;
|
|
||||||
import forge.deck.io.DeckSerializer;
|
import forge.deck.io.DeckSerializer;
|
||||||
import forge.deck.io.DeckSetSerializer;
|
import forge.deck.io.DeckSetSerializer;
|
||||||
import forge.deck.io.OldDeckParser;
|
import forge.deck.io.OldDeckParser;
|
||||||
@@ -18,7 +17,7 @@ public class CardCollections {
|
|||||||
private final IFolderMap<Deck> constructed;
|
private final IFolderMap<Deck> constructed;
|
||||||
private final IFolderMap<DeckSet> draft;
|
private final IFolderMap<DeckSet> draft;
|
||||||
private final IFolderMap<DeckSet> sealed;
|
private final IFolderMap<DeckSet> sealed;
|
||||||
private final IFolderMap<CustomLimited> cube;
|
private final IFolderMap<Deck> cube;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
@@ -28,7 +27,7 @@ public class CardCollections {
|
|||||||
constructed = new FolderMap<Deck>(new DeckSerializer(new File(file, "constructed")));
|
constructed = new FolderMap<Deck>(new DeckSerializer(new File(file, "constructed")));
|
||||||
draft = new FolderMap<DeckSet>(new DeckSetSerializer(new File(file, "draft")));
|
draft = new FolderMap<DeckSet>(new DeckSetSerializer(new File(file, "draft")));
|
||||||
sealed = new FolderMap<DeckSet>(new DeckSetSerializer(new File(file, "sealed")));
|
sealed = new FolderMap<DeckSet>(new DeckSetSerializer(new File(file, "sealed")));
|
||||||
cube = new FolderMap<CustomLimited>(new CubeSerializer(new File(file, "cube")));
|
cube = new FolderMap<Deck>(new DeckSerializer(new File(file, "cube")));
|
||||||
|
|
||||||
// remove this after most people have been switched to new layout
|
// remove this after most people have been switched to new layout
|
||||||
OldDeckParser oldParser = new OldDeckParser(file, constructed, draft, sealed, cube);
|
OldDeckParser oldParser = new OldDeckParser(file, constructed, draft, sealed, cube);
|
||||||
@@ -43,7 +42,7 @@ public class CardCollections {
|
|||||||
return draft;
|
return draft;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IFolderMap<CustomLimited> getCubes() {
|
public final IFolderMap<Deck> getCubes() {
|
||||||
return cube;
|
return cube;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,400 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Forge Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
package forge.deck;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.item.CardPrinted;
|
|
||||||
import forge.item.ItemPoolView;
|
|
||||||
import forge.util.SectionUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* CustomDraft class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class CustomLimited extends DeckBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for Constructor.
|
|
||||||
* @param name0
|
|
||||||
*/
|
|
||||||
public CustomLimited(String name0) {
|
|
||||||
super(name0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 7435640939026612173L;
|
|
||||||
|
|
||||||
/** The Type. */
|
|
||||||
// private String type;
|
|
||||||
|
|
||||||
/** The Deck file. */
|
|
||||||
private String deckFile;
|
|
||||||
|
|
||||||
/** The Ignore rarity. */
|
|
||||||
private Boolean ignoreRarity;
|
|
||||||
|
|
||||||
/** The Singleton. */
|
|
||||||
private Boolean singleton = false;
|
|
||||||
|
|
||||||
/** The Num cards. */
|
|
||||||
private int numCards = 15;
|
|
||||||
|
|
||||||
/** The Num specials. */
|
|
||||||
private int numSpecials = 0;
|
|
||||||
|
|
||||||
/** The Num mythics. */
|
|
||||||
private int numMythics = 1;
|
|
||||||
|
|
||||||
/** The Num rares. */
|
|
||||||
private int numRares = 1;
|
|
||||||
|
|
||||||
/** The Num uncommons. */
|
|
||||||
private int numUncommons = 3;
|
|
||||||
|
|
||||||
/** The Num commons. */
|
|
||||||
private int numCommons = 11;
|
|
||||||
|
|
||||||
/** The Num double faced. */
|
|
||||||
private int numDoubleFaced = 0;
|
|
||||||
|
|
||||||
/** The Num packs. */
|
|
||||||
private int numPacks = 3;
|
|
||||||
|
|
||||||
private DeckSection cardPool;
|
|
||||||
|
|
||||||
/** The Land set code. */
|
|
||||||
private String landSetCode = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer())
|
|
||||||
.getMostRecentSet();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the.
|
|
||||||
*
|
|
||||||
* @param dfData
|
|
||||||
* the df data
|
|
||||||
* @return the custom limited
|
|
||||||
*/
|
|
||||||
public static CustomLimited parse(final List<String> dfData) {
|
|
||||||
|
|
||||||
Map<String, String> data = SectionUtil.parseKvPairs(dfData, ":");
|
|
||||||
|
|
||||||
final CustomLimited cd = new CustomLimited(data.get("Name"));
|
|
||||||
cd.setIgnoreRarity("True".equalsIgnoreCase(data.get("IgnoreRarity")));
|
|
||||||
cd.setSingleton("True".equalsIgnoreCase(data.get("Singleton")));
|
|
||||||
|
|
||||||
|
|
||||||
for (final String dd : dfData) {
|
|
||||||
final String[] v = dd.split(":", 2);
|
|
||||||
final String key = v[0];
|
|
||||||
final String value = v.length > 1 ? v[1].trim() : "";
|
|
||||||
|
|
||||||
|
|
||||||
if (key.equalsIgnoreCase("LandSetCode")) {
|
|
||||||
cd.setLandSetCode(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key.equalsIgnoreCase("NumCards")) {
|
|
||||||
cd.setNumCards(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumDoubleFaced")) {
|
|
||||||
cd.setNumDoubleFaced(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumSpecials")) {
|
|
||||||
cd.setNumSpecials(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumMythics")) {
|
|
||||||
cd.setNumMythics(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumRares")) {
|
|
||||||
cd.setNumRares(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumUncommons")) {
|
|
||||||
cd.setNumUncommons(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumCommons")) {
|
|
||||||
cd.setNumCommons(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("NumPacks")) {
|
|
||||||
cd.setNumPacks(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num cards.
|
|
||||||
*
|
|
||||||
* @return the numCards
|
|
||||||
*/
|
|
||||||
public int getNumCards() {
|
|
||||||
return this.numCards;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num cards.
|
|
||||||
*
|
|
||||||
* @param numCardsIn
|
|
||||||
* the numCards to set
|
|
||||||
*/
|
|
||||||
public void setNumCards(final int numCardsIn) {
|
|
||||||
this.numCards = numCardsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num packs.
|
|
||||||
*
|
|
||||||
* @return the numPacks
|
|
||||||
*/
|
|
||||||
public int getNumPacks() {
|
|
||||||
return this.numPacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num packs.
|
|
||||||
*
|
|
||||||
* @param numPacksIn
|
|
||||||
* the numPacks to set
|
|
||||||
*/
|
|
||||||
public void setNumPacks(final int numPacksIn) {
|
|
||||||
this.numPacks = numPacksIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num specials.
|
|
||||||
*
|
|
||||||
* @return the numSpecials
|
|
||||||
*/
|
|
||||||
public int getNumSpecials() {
|
|
||||||
return this.numSpecials;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num specials.
|
|
||||||
*
|
|
||||||
* @param numSpecialsIn
|
|
||||||
* the numSpecials to set
|
|
||||||
*/
|
|
||||||
public void setNumSpecials(final int numSpecialsIn) {
|
|
||||||
this.numSpecials = numSpecialsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the singleton.
|
|
||||||
*
|
|
||||||
* @return the singleton
|
|
||||||
*/
|
|
||||||
public Boolean getSingleton() {
|
|
||||||
return this.singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the singleton.
|
|
||||||
*
|
|
||||||
* @param singletonIn
|
|
||||||
* the singleton to set
|
|
||||||
*/
|
|
||||||
public void setSingleton(final Boolean singletonIn) {
|
|
||||||
this.singleton = singletonIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ignore rarity.
|
|
||||||
*
|
|
||||||
* @return the ignoreRarity
|
|
||||||
*/
|
|
||||||
public Boolean getIgnoreRarity() {
|
|
||||||
return this.ignoreRarity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the ignore rarity.
|
|
||||||
*
|
|
||||||
* @param ignoreRarityIn
|
|
||||||
* the ignoreRarity to set
|
|
||||||
*/
|
|
||||||
public void setIgnoreRarity(final Boolean ignoreRarityIn) {
|
|
||||||
this.ignoreRarity = ignoreRarityIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num uncommons.
|
|
||||||
*
|
|
||||||
* @return the numUncommons
|
|
||||||
*/
|
|
||||||
public int getNumUncommons() {
|
|
||||||
return this.numUncommons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num uncommons.
|
|
||||||
*
|
|
||||||
* @param numUncommonsIn
|
|
||||||
* the numUncommons to set
|
|
||||||
*/
|
|
||||||
public void setNumUncommons(final int numUncommonsIn) {
|
|
||||||
this.numUncommons = numUncommonsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num commons.
|
|
||||||
*
|
|
||||||
* @return the numCommons
|
|
||||||
*/
|
|
||||||
public int getNumCommons() {
|
|
||||||
return this.numCommons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num commons.
|
|
||||||
*
|
|
||||||
* @param numCommonsIn
|
|
||||||
* the numCommons to set
|
|
||||||
*/
|
|
||||||
public void setNumCommons(final int numCommonsIn) {
|
|
||||||
this.numCommons = numCommonsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num rares.
|
|
||||||
*
|
|
||||||
* @return the numRares
|
|
||||||
*/
|
|
||||||
public int getNumRares() {
|
|
||||||
return this.numRares;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num rares.
|
|
||||||
*
|
|
||||||
* @param numRaresIn
|
|
||||||
* the numRares to set
|
|
||||||
*/
|
|
||||||
public void setNumRares(final int numRaresIn) {
|
|
||||||
this.numRares = numRaresIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num mythics.
|
|
||||||
*
|
|
||||||
* @return the numMythics
|
|
||||||
*/
|
|
||||||
public int getNumMythics() {
|
|
||||||
return this.numMythics;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num mythics.
|
|
||||||
*
|
|
||||||
* @param numMythicsIn
|
|
||||||
* the numMythics to set
|
|
||||||
*/
|
|
||||||
public void setNumMythics(final int numMythicsIn) {
|
|
||||||
this.numMythics = numMythicsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the deck file.
|
|
||||||
*
|
|
||||||
* @return the deckFile
|
|
||||||
*/
|
|
||||||
public String getDeckFile() {
|
|
||||||
return this.deckFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the deck file.
|
|
||||||
*
|
|
||||||
* @param deckFileIn
|
|
||||||
* the deckFile to set
|
|
||||||
*/
|
|
||||||
public void setDeckFile(final String deckFileIn) {
|
|
||||||
this.deckFile = deckFileIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the land set code.
|
|
||||||
*
|
|
||||||
* @return the landSetCode
|
|
||||||
*/
|
|
||||||
public String getLandSetCode() {
|
|
||||||
return this.landSetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the land set code.
|
|
||||||
*
|
|
||||||
* @param landSetCodeIn
|
|
||||||
* the landSetCode to set
|
|
||||||
*/
|
|
||||||
public void setLandSetCode(final String landSetCodeIn) {
|
|
||||||
this.landSetCode = landSetCodeIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num double faced.
|
|
||||||
*
|
|
||||||
* @return the numDoubleFaced
|
|
||||||
*/
|
|
||||||
public int getNumDoubleFaced() {
|
|
||||||
return this.numDoubleFaced;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num double faced.
|
|
||||||
*
|
|
||||||
* @param numDoubleFacedIn
|
|
||||||
* the numDoubleFaced to set
|
|
||||||
*/
|
|
||||||
public void setNumDoubleFaced(final int numDoubleFacedIn) {
|
|
||||||
this.numDoubleFaced = numDoubleFacedIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.item.CardCollectionBase#getCardPool()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ItemPoolView<CardPrinted> getCardPool() {
|
|
||||||
return cardPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.deck.DeckBase#getInstance(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected DeckBase newInstance(String name0) {
|
|
||||||
return new CustomLimited(name0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -153,6 +153,8 @@ public class Deck extends DeckBase implements Serializable, IHasName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
|
DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
|
||||||
|
if ( dh == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
final Deck d = new Deck(dh.getName());
|
final Deck d = new Deck(dh.getName());
|
||||||
d.setComment(dh.getComment());
|
d.setComment(dh.getComment());
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Forge: Play Magic: the Gathering.
|
|
||||||
* Copyright (C) 2011 Nate
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
package forge.deck.io;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FilenameFilter;
|
|
||||||
|
|
||||||
import forge.deck.CustomLimited;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CubeSerializer extends DeckSerializerBase<CustomLimited> {
|
|
||||||
|
|
||||||
public CubeSerializer(File deckDir0) {
|
|
||||||
super(deckDir0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.deck.IDeckSerializer#save(forge.item.CardCollectionBase, java.io.File)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void save(CustomLimited unit) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.deck.IDeckSerializer#erase(forge.item.CardCollectionBase, java.io.File)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void erase(CustomLimited unit) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Make file name.
|
|
||||||
*
|
|
||||||
* @param deckName
|
|
||||||
* @param deckType
|
|
||||||
* a GameType
|
|
||||||
* @return a File
|
|
||||||
*/
|
|
||||||
public File makeFileFor(final CustomLimited deck) {
|
|
||||||
return new File(getDirectory(), deriveFileName(cleanDeckName(deck.getName())) + ".cub");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.deck.io.DeckSerializerBase#read(java.io.File)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected CustomLimited read(File file) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.deck.io.DeckSerializerBase#getFileFilter()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected FilenameFilter getFileFilter() {
|
|
||||||
return new FilenameFilter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return dir.getPath().endsWith(".cub");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package forge.deck.io;
|
package forge.deck.io;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import forge.PlayerType;
|
import forge.PlayerType;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
|
import forge.util.FileSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -30,11 +29,11 @@ public class DeckFileHeader {
|
|||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
* @param parseKvPairs
|
* @param parseKvPairs
|
||||||
*/
|
*/
|
||||||
public DeckFileHeader(Map<String, String> kvPairs) {
|
public DeckFileHeader(FileSection kvPairs) {
|
||||||
name = kvPairs.get(NAME);
|
name = kvPairs.get(NAME);
|
||||||
comment = kvPairs.get(COMMENT);
|
comment = kvPairs.get(COMMENT);
|
||||||
deckType = GameType.smartValueOf(kvPairs.get(DECK_TYPE), GameType.Constructed);
|
deckType = GameType.smartValueOf(kvPairs.get(DECK_TYPE), GameType.Constructed);
|
||||||
customPool = "true".equalsIgnoreCase(kvPairs.get(CSTM_POOL));
|
customPool = kvPairs.getBoolean(CSTM_POOL);
|
||||||
playerType = "computer".equalsIgnoreCase(kvPairs.get(PLAYER)) || "ai".equalsIgnoreCase(kvPairs.get(PLAYER_TYPE)) ? PlayerType.COMPUTER : PlayerType.HUMAN;
|
playerType = "computer".equalsIgnoreCase(kvPairs.get(PLAYER)) || "ai".equalsIgnoreCase(kvPairs.get(PLAYER_TYPE)) ? PlayerType.COMPUTER : PlayerType.HUMAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import javax.swing.filechooser.FileFilter;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.FileSection;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.SectionUtil;
|
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.DefaultObjectWrapper;
|
import freemarker.template.DefaultObjectWrapper;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
@@ -248,7 +248,7 @@ public class DeckSerializer extends DeckSerializerBase<Deck> {
|
|||||||
if ( map == null ) { return null; }
|
if ( map == null ) { return null; }
|
||||||
List<String> lines = map.get("metadata");
|
List<String> lines = map.get("metadata");
|
||||||
if (lines == null) { return null; }
|
if (lines == null) { return null; }
|
||||||
DeckFileHeader d = new DeckFileHeader(SectionUtil.parseKvPairs(lines, "="));
|
DeckFileHeader d = new DeckFileHeader(FileSection.parse(lines, "="));
|
||||||
|
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.apache.commons.lang3.tuple.MutablePair;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import forge.PlayerType;
|
import forge.PlayerType;
|
||||||
import forge.deck.CustomLimited;
|
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckSet;
|
import forge.deck.DeckSet;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
@@ -44,7 +43,7 @@ public class OldDeckParser {
|
|||||||
* @param cube2
|
* @param cube2
|
||||||
*/
|
*/
|
||||||
public OldDeckParser(File file, IFolderMap<Deck> constructed2, IFolderMap<DeckSet> draft2,
|
public OldDeckParser(File file, IFolderMap<Deck> constructed2, IFolderMap<DeckSet> draft2,
|
||||||
IFolderMap<DeckSet> sealed2, IFolderMap<CustomLimited> cube2) {
|
IFolderMap<DeckSet> sealed2, IFolderMap<Deck> cube2) {
|
||||||
deckDir = file;
|
deckDir = file;
|
||||||
sealed = sealed2;
|
sealed = sealed2;
|
||||||
constructed = constructed2;
|
constructed = constructed2;
|
||||||
@@ -61,7 +60,7 @@ public class OldDeckParser {
|
|||||||
protected final IFolderMap<DeckSet> getDraft() {
|
protected final IFolderMap<DeckSet> getDraft() {
|
||||||
return draft;
|
return draft;
|
||||||
}
|
}
|
||||||
protected final IFolderMap<CustomLimited> getCube() {
|
protected final IFolderMap<Deck> getCube() {
|
||||||
return cube;
|
return cube;
|
||||||
}
|
}
|
||||||
protected final File getDeckDir() {
|
protected final File getDeckDir() {
|
||||||
@@ -71,7 +70,7 @@ public class OldDeckParser {
|
|||||||
private final IFolderMap<DeckSet> sealed;
|
private final IFolderMap<DeckSet> sealed;
|
||||||
private final IFolderMap<Deck> constructed;
|
private final IFolderMap<Deck> constructed;
|
||||||
private final IFolderMap<DeckSet> draft;
|
private final IFolderMap<DeckSet> draft;
|
||||||
private final IFolderMap<CustomLimited> cube;
|
private final IFolderMap<Deck> cube;
|
||||||
private final File deckDir;
|
private final File deckDir;
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
@@ -127,9 +126,22 @@ public class OldDeckParser {
|
|||||||
Map<String, List<String>> sections = SectionUtil.parseSections(fileLines);
|
Map<String, List<String>> sections = SectionUtil.parseSections(fileLines);
|
||||||
DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
|
DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
|
||||||
String name = dh.getName();
|
String name = dh.getName();
|
||||||
|
|
||||||
if (dh.isCustomPool()) {
|
if (dh.isCustomPool()) {
|
||||||
continue;
|
try {
|
||||||
|
cube.add(Deck.fromLines(fileLines));
|
||||||
|
importedOk = true;
|
||||||
|
} catch (NoSuchElementException ex) {
|
||||||
|
if (!allowDeleteUnsupportedConstructed) {
|
||||||
|
String msg = String.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?", name, ex.getMessage());
|
||||||
|
allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (importedOk || allowDeleteUnsupportedConstructed) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch(dh.getDeckType()) {
|
switch(dh.getDeckType()) {
|
||||||
case Constructed:
|
case Constructed:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import javax.swing.JOptionPane;
|
|||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
import net.slightlymagic.maxmtg.Closure1;
|
import net.slightlymagic.maxmtg.Closure1;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
@@ -38,7 +39,6 @@ import forge.SetUtils;
|
|||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardSet;
|
import forge.card.CardSet;
|
||||||
import forge.deck.CustomLimited;
|
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -143,7 +143,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
case Custom:
|
case Custom:
|
||||||
final List<CustomLimited> myDrafts = this.loadCustomDrafts("res/draft/", ".draft");
|
final List<CustomLimited> myDrafts = this.loadCustomDrafts("res/draft/", ".draft");
|
||||||
|
|
||||||
if (myDrafts.size() < 1) {
|
if (myDrafts.isEmpty()) {
|
||||||
JOptionPane
|
JOptionPane
|
||||||
.showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
.showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
@@ -162,7 +162,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
private void setupCustomDraft(final CustomLimited draft) {
|
private void setupCustomDraft(final CustomLimited draft) {
|
||||||
final ItemPoolView<CardPrinted> dPool = draft.getCardPool();
|
final ItemPoolView<CardPrinted> dPool = draft.getCardPool();
|
||||||
if (dPool == null) {
|
if (dPool == null) {
|
||||||
throw new RuntimeException("BoosterGenerator : deck not found - " + draft.getDeckFile());
|
throw new RuntimeException("BoosterGenerator : deck not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
final BoosterGenerator bpCustom = new BoosterGenerator(dPool);
|
final BoosterGenerator bpCustom = new BoosterGenerator(dPool);
|
||||||
@@ -176,8 +176,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
return pack.getSingletonBoosterPack(draft.getNumCards());
|
return pack.getSingletonBoosterPack(draft.getNumCards());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pack.getBoosterPack(draft.getNumCommons(), draft.getNumUncommons(), 0, draft.getNumRares(),
|
return pack.getBoosterPack(draft.getNumRarity(), 0, 0, 0);
|
||||||
draft.getNumMythics(), draft.getNumSpecials(), 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -210,7 +209,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
for (final String element : dList) {
|
for (final String element : dList) {
|
||||||
if (element.endsWith(fileExtension)) {
|
if (element.endsWith(fileExtension)) {
|
||||||
final List<String> dfData = FileUtil.readFile(lookupFolder + element);
|
final List<String> dfData = FileUtil.readFile(lookupFolder + element);
|
||||||
customs.add(CustomLimited.parse(dfData));
|
customs.add(CustomLimited.parse(dfData, AllZone.getDecks().getCubes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return customs;
|
return customs;
|
||||||
|
|||||||
240
src/main/java/forge/game/limited/CustomLimited.java
Normal file
240
src/main/java/forge/game/limited/CustomLimited.java
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
/*
|
||||||
|
* Forge: Play Magic: the Gathering.
|
||||||
|
* Copyright (C) 2011 Forge Team
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
package forge.game.limited;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.card.CardRarity;
|
||||||
|
import forge.deck.Deck;
|
||||||
|
import forge.deck.DeckBase;
|
||||||
|
import forge.item.CardDb;
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
import forge.item.ItemPool;
|
||||||
|
import forge.item.ItemPoolView;
|
||||||
|
import forge.util.FileSection;
|
||||||
|
import forge.util.IFolderMapView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* CustomDraft class.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Forge
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class CustomLimited extends DeckBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for Constructor.
|
||||||
|
* @param name0
|
||||||
|
*/
|
||||||
|
public CustomLimited(String name0) {
|
||||||
|
super(name0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7435640939026612173L;
|
||||||
|
|
||||||
|
/** The Ignore rarity. */
|
||||||
|
private Boolean ignoreRarity;
|
||||||
|
|
||||||
|
/** The Singleton. */
|
||||||
|
private Boolean singleton = false;
|
||||||
|
|
||||||
|
/** The Num cards. */
|
||||||
|
private int numCards = 15;
|
||||||
|
|
||||||
|
|
||||||
|
private final Map<CardRarity, Integer> numRarity = new EnumMap<CardRarity, Integer>(CardRarity.class);
|
||||||
|
|
||||||
|
/** The Num packs. */
|
||||||
|
private int numPacks = 3;
|
||||||
|
|
||||||
|
private transient ItemPoolView<CardPrinted> cardPool;
|
||||||
|
|
||||||
|
/** The Land set code. */
|
||||||
|
private String landSetCode = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer())
|
||||||
|
.getMostRecentSet();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the.
|
||||||
|
*
|
||||||
|
* @param dfData
|
||||||
|
* the df data
|
||||||
|
* @return the custom limited
|
||||||
|
*/
|
||||||
|
public static CustomLimited parse(final List<String> dfData, IFolderMapView<Deck> cubes) {
|
||||||
|
|
||||||
|
FileSection data = FileSection.parse(dfData, ":");
|
||||||
|
|
||||||
|
final CustomLimited cd = new CustomLimited(data.get("Name"));
|
||||||
|
cd.setIgnoreRarity(data.getBoolean("IgnoreRarity"));
|
||||||
|
cd.setSingleton(data.getBoolean("Singleton"));
|
||||||
|
cd.setLandSetCode(data.get("LandSetCode"));
|
||||||
|
cd.numCards = data.getInt("NumCards", 15);
|
||||||
|
|
||||||
|
cd.numRarity.put(CardRarity.BasicLand, data.getInt("NumBasicLands", 1));
|
||||||
|
cd.numRarity.put(CardRarity.Special, data.getInt("NumSpecials"));
|
||||||
|
cd.numRarity.put(CardRarity.Rare, data.getInt("NumRares", 1));
|
||||||
|
cd.numRarity.put(CardRarity.MythicRare, data.getInt("NumMythics"));
|
||||||
|
cd.numRarity.put(CardRarity.Uncommon, data.getInt("NumUncommons", 3));
|
||||||
|
cd.numRarity.put(CardRarity.Common, data.getInt("NumCommons", 10));
|
||||||
|
|
||||||
|
cd.numPacks = data.getInt("NumPacks");
|
||||||
|
|
||||||
|
String deckName = data.get("DeckFile");
|
||||||
|
Deck deckCube = cubes.get(deckName);
|
||||||
|
cd.cardPool = deckCube == null ? ItemPool.createFrom(CardDb.instance().getAllUniqueCards(), CardPrinted.class) : deckCube.getMain();
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the num cards.
|
||||||
|
*
|
||||||
|
* @return the numCards
|
||||||
|
*/
|
||||||
|
public int getNumCards() {
|
||||||
|
return this.numCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the num cards.
|
||||||
|
*
|
||||||
|
* @param numCardsIn
|
||||||
|
* the numCards to set
|
||||||
|
*/
|
||||||
|
public void setNumCards(final int numCardsIn) {
|
||||||
|
this.numCards = numCardsIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the num packs.
|
||||||
|
*
|
||||||
|
* @return the numPacks
|
||||||
|
*/
|
||||||
|
public int getNumPacks() {
|
||||||
|
return this.numPacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the num packs.
|
||||||
|
*
|
||||||
|
* @param numPacksIn
|
||||||
|
* the numPacks to set
|
||||||
|
*/
|
||||||
|
public void setNumPacks(final int numPacksIn) {
|
||||||
|
this.numPacks = numPacksIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the singleton.
|
||||||
|
*
|
||||||
|
* @return the singleton
|
||||||
|
*/
|
||||||
|
public Boolean getSingleton() {
|
||||||
|
return this.singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the singleton.
|
||||||
|
*
|
||||||
|
* @param singletonIn
|
||||||
|
* the singleton to set
|
||||||
|
*/
|
||||||
|
public void setSingleton(final Boolean singletonIn) {
|
||||||
|
this.singleton = singletonIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ignore rarity.
|
||||||
|
*
|
||||||
|
* @return the ignoreRarity
|
||||||
|
*/
|
||||||
|
public Boolean getIgnoreRarity() {
|
||||||
|
return this.ignoreRarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ignore rarity.
|
||||||
|
*
|
||||||
|
* @param ignoreRarityIn
|
||||||
|
* the ignoreRarity to set
|
||||||
|
*/
|
||||||
|
public void setIgnoreRarity(final Boolean ignoreRarityIn) {
|
||||||
|
this.ignoreRarity = ignoreRarityIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the land set code.
|
||||||
|
*
|
||||||
|
* @return the landSetCode
|
||||||
|
*/
|
||||||
|
public String getLandSetCode() {
|
||||||
|
return this.landSetCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the land set code.
|
||||||
|
*
|
||||||
|
* @param landSetCodeIn
|
||||||
|
* the landSetCode to set
|
||||||
|
*/
|
||||||
|
public void setLandSetCode(final String landSetCodeIn) {
|
||||||
|
this.landSetCode = landSetCodeIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.item.CardCollectionBase#getCardPool()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemPoolView<CardPrinted> getCardPool() {
|
||||||
|
return cardPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.deck.DeckBase#getInstance(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected DeckBase newInstance(String name0) {
|
||||||
|
return new CustomLimited(name0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<CardRarity, Integer> getNumRarity() {
|
||||||
|
return numRarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -36,7 +36,6 @@ import forge.card.BoosterGenerator;
|
|||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardSet;
|
import forge.card.CardSet;
|
||||||
import forge.card.spellability.AbilityMana;
|
import forge.card.spellability.AbilityMana;
|
||||||
import forge.deck.CustomLimited;
|
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -140,7 +139,7 @@ public class SealedDeck {
|
|||||||
for (final String element : dList) {
|
for (final String element : dList) {
|
||||||
if (element.endsWith(".sealed")) {
|
if (element.endsWith(".sealed")) {
|
||||||
final ArrayList<String> dfData = FileUtil.readFile("res/sealed/" + element);
|
final ArrayList<String> dfData = FileUtil.readFile("res/sealed/" + element);
|
||||||
final CustomLimited cs = CustomLimited.parse(dfData);
|
final CustomLimited cs = CustomLimited.parse(dfData, AllZone.getDecks().getCubes());
|
||||||
customs.add(cs);
|
customs.add(cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,9 +163,7 @@ public class SealedDeck {
|
|||||||
return pack.getSingletonBoosterPack(draft.getNumCards());
|
return pack.getSingletonBoosterPack(draft.getNumCards());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pack.getBoosterPack(draft.getNumCommons(), draft.getNumUncommons(), 0,
|
return pack.getBoosterPack(draft.getNumRarity(), 0, 0, 0);
|
||||||
draft.getNumRares(), draft.getNumMythics(), draft.getNumSpecials(),
|
|
||||||
draft.getNumDoubleFaced(), 0, 0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
|||||||
import forge.SetUtils;
|
import forge.SetUtils;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.quest.SellRules;
|
import forge.quest.SellRules;
|
||||||
|
import forge.util.FileSection;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.SectionUtil;
|
import forge.util.SectionUtil;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ public class PreconDeck implements InventoryItemFromSet {
|
|||||||
|
|
||||||
String setProxy = "n/a";
|
String setProxy = "n/a";
|
||||||
|
|
||||||
Map<String,String> kv = SectionUtil.parseKvPairs(sections.get("metadata"), "=");
|
FileSection kv = FileSection.parse(sections.get("metadata"), "=");
|
||||||
|
|
||||||
imageFilename = kv.get("Image");
|
imageFilename = kv.get("Image");
|
||||||
description = kv.get("Description");
|
description = kv.get("Description");
|
||||||
|
|||||||
48
src/main/java/forge/util/FileSection.java
Normal file
48
src/main/java/forge/util/FileSection.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package forge.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileSection {
|
||||||
|
|
||||||
|
private final Map<String, String> lines = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
|
private FileSection() {}
|
||||||
|
|
||||||
|
public static FileSection parse(Iterable<String> lines, String kvSeparator) {
|
||||||
|
FileSection result = new FileSection();
|
||||||
|
|
||||||
|
for (final String dd : lines) {
|
||||||
|
final String[] v = dd.split(kvSeparator, 2);
|
||||||
|
result.lines.put(v[0], v.length > 1 ? v[1].trim() : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String fieldName) {
|
||||||
|
return lines.get(fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(String fieldName) { return getInt(fieldName, 0); }
|
||||||
|
public int getInt(String fieldName, int defaultValue) {
|
||||||
|
try{
|
||||||
|
return Integer.parseInt(get(fieldName));
|
||||||
|
} catch( NumberFormatException ex ) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean(String fieldName) { return getBoolean(fieldName, false); }
|
||||||
|
public boolean getBoolean(String fieldName, boolean defaultValue) {
|
||||||
|
String s = get(fieldName);
|
||||||
|
if ( s == null ) return defaultValue;
|
||||||
|
return "true".equalsIgnoreCase(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Divides file into sections and joins them back to stringlist to save.
|
* Divides file into sections and joins them back to stringlist to save.
|
||||||
@@ -79,23 +78,4 @@ public class SectionUtil {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the kv pairs.
|
|
||||||
*
|
|
||||||
* @param lines the lines
|
|
||||||
* @return the map
|
|
||||||
*/
|
|
||||||
public static Map<String, String> parseKvPairs(final List<String> lines, String separator ) {
|
|
||||||
if ( null == lines )
|
|
||||||
return null;
|
|
||||||
|
|
||||||
final Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
|
||||||
|
|
||||||
for (final String dd : lines) {
|
|
||||||
final String[] v = dd.split(separator, 2);
|
|
||||||
result.put(v[0], v.length > 1 ? v[1].trim() : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user