mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- CheckStyle.
This commit is contained in:
@@ -54,7 +54,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
public CardEdition(final int index, final String name, final String code, final String code2) {
|
||||
this(index, name, code, code2, null);
|
||||
}
|
||||
|
||||
|
||||
public CardEdition(final int index, final String name, final String code, final String code2, final String alias0) {
|
||||
this.code = code;
|
||||
this.code2 = code2;
|
||||
@@ -180,7 +180,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
* The Class Predicates.
|
||||
*/
|
||||
public abstract static class Predicates {
|
||||
|
||||
|
||||
/** The Constant canMakeBooster. */
|
||||
public static final Predicate<CardEdition> CAN_MAKE_BOOSTER = new CanMakeBooster();
|
||||
|
||||
@@ -190,7 +190,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
return Singletons.getModel().getBoosters().contains(subject.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final Predicate<CardEdition> HAS_TOURNAMENT_PACK = new CanMakeStarter();
|
||||
private static class CanMakeStarter extends Predicate<CardEdition> {
|
||||
@Override
|
||||
@@ -198,14 +198,15 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
return Singletons.getModel().getTournamentPacks().contains(subject.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final Predicate<CardEdition> HAS_FAT_PACK = new CanMakeFatPack();
|
||||
private static class CanMakeFatPack extends Predicate<CardEdition> {
|
||||
@Override
|
||||
public boolean isTrue(final CardEdition subject) {
|
||||
return Singletons.getModel().getFatPacks().contains(subject.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is legal in format.
|
||||
*
|
||||
@@ -229,7 +230,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Reader extends StorageReaderFile<CardEdition> {
|
||||
|
||||
public Reader(String pathname) {
|
||||
@@ -250,6 +251,6 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
|
||||
return new CardEdition(index, name, code, code2, alias);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ import forge.util.StorageReaderFile;
|
||||
*
|
||||
*/
|
||||
public class FatPackData {
|
||||
private final String edition;
|
||||
private final String edition;
|
||||
public final String getEdition() {
|
||||
return edition;
|
||||
}
|
||||
|
||||
private final String landsEdition;
|
||||
private final String landsEdition;
|
||||
public final String getLandsEdition() {
|
||||
return landsEdition == null ? edition : landsEdition;
|
||||
}
|
||||
|
||||
|
||||
public int getCntBoosters() {
|
||||
return cntBoosters;
|
||||
}
|
||||
@@ -29,23 +29,23 @@ public class FatPackData {
|
||||
|
||||
private final int cntBoosters;
|
||||
private final int cntLands;
|
||||
|
||||
public FatPackData(String edition0, String landsEdition0, int nBoosters, int nBasicLands )
|
||||
|
||||
public FatPackData(String edition0, String landsEdition0, int nBoosters, int nBasicLands)
|
||||
{
|
||||
cntBoosters = nBoosters;
|
||||
cntLands = nBasicLands;
|
||||
edition = edition0;
|
||||
landsEdition = landsEdition0;
|
||||
}
|
||||
|
||||
|
||||
public static final Lambda1<String, FatPackData> FN_GET_CODE = new Lambda1<String, FatPackData>() {
|
||||
|
||||
|
||||
@Override
|
||||
public String apply(FatPackData arg1) {
|
||||
return arg1.edition;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
public static final class Reader extends StorageReaderFile<FatPackData> {
|
||||
|
||||
public Reader(String pathname) {
|
||||
@@ -62,5 +62,5 @@ public class FatPackData {
|
||||
int nLand = section.getInt("BasicLands", 0);
|
||||
return new FatPackData(section.get("Set"), section.get("LandSet"), nBoosters, nLand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,18 +70,18 @@ public class DeckGroup extends DeckBase {
|
||||
public final void setHumanDeck(final Deck humanDeck) {
|
||||
this.humanDeck = humanDeck;
|
||||
}
|
||||
|
||||
|
||||
protected void cloneFieldsTo(final DeckBase clone) {
|
||||
super.cloneFieldsTo(clone);
|
||||
|
||||
|
||||
DeckGroup myClone = (DeckGroup) clone;
|
||||
myClone.setHumanDeck((Deck)this.getHumanDeck().copyTo(this.getHumanDeck().getName()));
|
||||
|
||||
for(int i = 0; i < this.getAiDecks().size(); i++) {
|
||||
myClone.setHumanDeck((Deck) this.getHumanDeck().copyTo(this.getHumanDeck().getName()));
|
||||
|
||||
for (int i = 0; i < this.getAiDecks().size(); i++) {
|
||||
Deck src = this.getAiDecks().get(i);
|
||||
myClone.addAiDeck((Deck)src.copyTo(src.getName()));
|
||||
myClone.addAiDeck((Deck) src.copyTo(src.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the ai deck.
|
||||
|
||||
@@ -157,8 +157,9 @@ public class DeckController<T extends DeckBase> implements IDeckController<T> {
|
||||
@Override
|
||||
public void load(final String name) {
|
||||
T newModel = this.folder.get(name);
|
||||
if (null != newModel)
|
||||
this.setModel((T)newModel.copyTo(name), true);
|
||||
if (null != newModel) {
|
||||
this.setModel((T) newModel.copyTo(name), true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -325,7 +325,7 @@ public class DraftingProcess extends DeckEditorBase<CardPrinted, DeckGroup> {
|
||||
final Deck[] computer = this.boosterDraft.getDecks();
|
||||
|
||||
final DeckGroup finishedDraft = new DeckGroup("Draft " + s);
|
||||
finishedDraft.setHumanDeck((Deck)this.getPlayersDeck().copyTo(s));
|
||||
finishedDraft.setHumanDeck((Deck) this.getPlayersDeck().copyTo(s));
|
||||
finishedDraft.addAiDecks(computer);
|
||||
|
||||
// DeckManager deckManager = new
|
||||
|
||||
@@ -334,9 +334,9 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, Object> {
|
||||
this.getBottomTableWithCards().addCard(card);
|
||||
this.questData.getCards().buyCard(card, value);
|
||||
|
||||
} else if (item instanceof OpenablePack) {
|
||||
} else if (item instanceof OpenablePack) {
|
||||
this.getTopTableWithCards().removeCard(item);
|
||||
|
||||
|
||||
OpenablePack booster = null;
|
||||
if (item instanceof BoosterPack) {
|
||||
booster = (BoosterPack) ((BoosterPack) item).clone();
|
||||
|
||||
@@ -80,7 +80,7 @@ public class BoosterPack extends OpenablePack {
|
||||
*/
|
||||
@Override
|
||||
public final Object clone() {
|
||||
return new BoosterPack(name, contents);
|
||||
return new BoosterPack(name, contents);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class FatPack extends OpenablePack {
|
||||
return new FatPack(arg1.getName(), d);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final FatPackData fpData;
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ public class FatPack extends OpenablePack {
|
||||
* the set
|
||||
*/
|
||||
public FatPack(final String name0, final FatPackData fpData0) {
|
||||
super(name0, Singletons.getModel().getBoosters().get(fpData0.getEdition()));
|
||||
super(name0, Singletons.getModel().getBoosters().get(fpData0.getEdition()));
|
||||
fpData = fpData0;
|
||||
}
|
||||
|
||||
@@ -67,12 +67,12 @@ public class FatPack extends OpenablePack {
|
||||
|
||||
protected List<CardPrinted> generate() {
|
||||
List<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||
for( int i = 0; i < fpData.getCntBoosters(); i++ ) {
|
||||
for (int i = 0; i < fpData.getCntBoosters(); i++) {
|
||||
result.addAll(super.generate());
|
||||
}
|
||||
CardEdition landEdition = Singletons.getModel().getEditions().get(fpData.getLandsEdition());
|
||||
result.addAll(getRandomBasicLands(landEdition, fpData.getCntLands()));
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -89,9 +89,9 @@ public class FatPack extends OpenablePack {
|
||||
public final Object clone() {
|
||||
return new FatPack(name, fpData);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getTotalCards(){
|
||||
public int getTotalCards() {
|
||||
return super.getTotalCards() * fpData.getCntBoosters() + fpData.getCntLands();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,25 +19,24 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
protected final BoosterData contents;
|
||||
protected final String name;
|
||||
private List<CardPrinted> cards = null;
|
||||
|
||||
private BoosterGenerator generator = null;
|
||||
|
||||
private BoosterGenerator generator = null;
|
||||
|
||||
public OpenablePack(final String name0, final BoosterData boosterData) {
|
||||
this.contents = boosterData;
|
||||
this.name = name0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return this.name + " " + this.getType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getEdition() {
|
||||
return this.contents.getEdition();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cards.
|
||||
*
|
||||
@@ -48,8 +47,8 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
cards = this.generate();
|
||||
}
|
||||
return this.cards;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getTotalCards() {
|
||||
return contents.getTotal();
|
||||
@@ -104,11 +103,11 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
|
||||
|
||||
protected List<CardPrinted> generate() {
|
||||
if ( null == generator ) {
|
||||
if (null == generator) {
|
||||
generator = new BoosterGenerator(this.contents.getEditionFilter());
|
||||
}
|
||||
List<CardPrinted> myCards = generator.getBoosterPack(this.contents);
|
||||
|
||||
|
||||
final int cntLands = this.contents.getLand();
|
||||
if (cntLands > 0) {
|
||||
myCards.add(this.getLandFromNearestSet());
|
||||
@@ -131,14 +130,14 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
}
|
||||
|
||||
|
||||
protected CardPrinted getRandomBasicLand(final CardEdition set) {
|
||||
protected CardPrinted getRandomBasicLand(final CardEdition set) {
|
||||
return getRandomBasicLands(set, 1).get(0);
|
||||
}
|
||||
|
||||
|
||||
protected List<CardPrinted> getRandomBasicLands(final CardEdition set, int count) {
|
||||
return Predicate.and(CardPrinted.Predicates.printedInSets(set.getCode()),
|
||||
CardRules.Predicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES)
|
||||
.random(CardDb.instance().getAllCards(), count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TournamentPack extends OpenablePack {
|
||||
* the set
|
||||
*/
|
||||
public TournamentPack(final String name0, final BoosterData boosterData) {
|
||||
super(name0, boosterData);
|
||||
super(name0, boosterData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -307,15 +307,15 @@ public class QuestDataIO {
|
||||
writer.addAttribute("s", fatpack.getEdition());
|
||||
writer.addAttribute("n", count.toString());
|
||||
writer.endNode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void write(final TournamentPack booster, final Integer count, final HierarchicalStreamWriter writer) {
|
||||
writer.startNode("tpack");
|
||||
writer.addAttribute("s", booster.getEdition());
|
||||
writer.addAttribute("n", count.toString());
|
||||
writer.endNode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void write(final PreconDeck deck, final Integer count, final HierarchicalStreamWriter writer) {
|
||||
writer.startNode("precon");
|
||||
writer.addAttribute("name", deck.getName());
|
||||
@@ -335,9 +335,9 @@ public class QuestDataIO {
|
||||
} else if (item instanceof BoosterPack) {
|
||||
this.write((BoosterPack) item, count, writer);
|
||||
} else if (item instanceof TournamentPack) {
|
||||
this.write((TournamentPack) item, count, writer);
|
||||
this.write((TournamentPack) item, count, writer);
|
||||
} else if (item instanceof FatPack) {
|
||||
this.write((FatPack) item, count, writer);
|
||||
this.write((FatPack) item, count, writer);
|
||||
} else if (item instanceof PreconDeck) {
|
||||
this.write((PreconDeck) item, count, writer);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,6 @@ public final class QuestUtilCards {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Buy precon deck.
|
||||
*
|
||||
@@ -358,12 +357,12 @@ public final class QuestUtilCards {
|
||||
*/
|
||||
public void generateTournamentsInShop(final int count) {
|
||||
Predicate<CardEdition> hasTournament = CardEdition.Predicates.HAS_TOURNAMENT_PACK;
|
||||
this.q.getShopList().addAllFlat( hasTournament.random(Singletons.getModel().getEditions(), count, TournamentPack.FN_FROM_SET));
|
||||
this.q.getShopList().addAllFlat(hasTournament.random(Singletons.getModel().getEditions(), count, TournamentPack.FN_FROM_SET));
|
||||
}
|
||||
|
||||
public void generateFatPacksInShop(final int count) {
|
||||
Predicate<CardEdition> hasPack = CardEdition.Predicates.HAS_FAT_PACK;
|
||||
this.q.getShopList().addAllFlat( hasPack.random(Singletons.getModel().getEditions(), count, FatPack.FN_FROM_SET));
|
||||
this.q.getShopList().addAllFlat(hasPack.random(Singletons.getModel().getEditions(), count, FatPack.FN_FROM_SET));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user