mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
move art index tracking from pack superclasses to booster pack classes
This commit is contained in:
1
.project
1
.project
@@ -34,7 +34,6 @@
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
||||
@@ -14,6 +14,7 @@ public class BoosterData extends PackData {
|
||||
private final int nSpecial;
|
||||
private final int nDoubleFaced;
|
||||
private final int foilRate;
|
||||
private final int artIndices;
|
||||
private static final int CARDS_PER_BOOSTER = 15;
|
||||
|
||||
public BoosterData(String edition, String editionLand, int nC, int nU, int nR, int nS, int nDF, int artIndices) {
|
||||
@@ -23,18 +24,15 @@ public class BoosterData extends PackData {
|
||||
(nC + nR + nU + nS + nDF) > 10 ? BoosterData.CARDS_PER_BOOSTER - nC - nR - nU - nS - nDF : 0, 68);
|
||||
}
|
||||
|
||||
public BoosterData(String edition, String editionLand, int nC, int nU, int nR, int nS, int nDF, int artIndices, int nL, int oneFoilPer) {
|
||||
super(edition, editionLand, nL > 0 ? nL : 0, artIndices);
|
||||
public BoosterData(String edition, String editionLand, int nC, int nU, int nR, int nS, int nDF, int artIndices0, int nL, int oneFoilPer) {
|
||||
super(edition, editionLand, nL > 0 ? nL : 0);
|
||||
this.nCommon = nC;
|
||||
this.nUncommon = nU;
|
||||
this.nRare = nR;
|
||||
this.nSpecial = nS;
|
||||
this.nDoubleFaced = nDF;
|
||||
this.foilRate = oneFoilPer;
|
||||
}
|
||||
|
||||
public final int getCommon() {
|
||||
return this.nCommon;
|
||||
artIndices = artIndices0;
|
||||
}
|
||||
|
||||
public final Predicate<CardPrinted> getEditionFilter() {
|
||||
@@ -45,6 +43,10 @@ public class BoosterData extends PackData {
|
||||
return IPaperCard.Predicates.printedInSets(getLandEdition());
|
||||
}
|
||||
|
||||
public final int getCommon() {
|
||||
return this.nCommon;
|
||||
}
|
||||
|
||||
public final int getUncommon() {
|
||||
return this.nUncommon;
|
||||
}
|
||||
@@ -69,6 +71,10 @@ public class BoosterData extends PackData {
|
||||
return this.foilRate;
|
||||
}
|
||||
|
||||
public int getArtIndices() {
|
||||
return artIndices;
|
||||
}
|
||||
|
||||
private void _append(StringBuilder s, int val, String name) {
|
||||
if (0 >= val) {
|
||||
return;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FatPackData extends PackData {
|
||||
|
||||
public FatPackData(String edition0, String landEdition0, int nBoosters, int nBasicLands)
|
||||
{
|
||||
super(edition0, landEdition0, nBasicLands, 1);
|
||||
super(edition0, landEdition0, nBasicLands);
|
||||
cntBoosters = nBoosters;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ public class PackData {
|
||||
private final String edition;
|
||||
private final String landEdition;
|
||||
private final int cntLands;
|
||||
private final int artIndices;
|
||||
|
||||
public final String getEdition() {
|
||||
return edition;
|
||||
@@ -40,17 +39,12 @@ public class PackData {
|
||||
return cntLands;
|
||||
}
|
||||
|
||||
public int getArtIndices() {
|
||||
return artIndices;
|
||||
}
|
||||
|
||||
public PackData(String edition0, String landEdition0, int nBasicLands, int artIndices0)
|
||||
public PackData(String edition0, String landEdition0, int nBasicLands)
|
||||
{
|
||||
if (null == edition0) { throw new NullArgumentException("edition0"); }
|
||||
edition = edition0;
|
||||
landEdition = landEdition0;
|
||||
cntLands = nBasicLands;
|
||||
artIndices = artIndices0;
|
||||
}
|
||||
|
||||
public static final Function<? super PackData, String> FN_GET_CODE = new Function<PackData, String>() {
|
||||
@@ -61,7 +55,7 @@ public class PackData {
|
||||
};
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@@ -76,7 +70,7 @@ public class PackData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
public int hashCode() {
|
||||
return edition.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,12 @@ import com.google.common.base.Function;
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterData;
|
||||
import forge.card.CardEdition;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class BoosterPack extends OpenablePack {
|
||||
private final int artIndex;
|
||||
private final int hash;
|
||||
|
||||
public static final Function<CardEdition, BoosterPack> FN_FROM_SET = new Function<CardEdition, BoosterPack>() {
|
||||
@Override
|
||||
public BoosterPack apply(final CardEdition arg1) {
|
||||
@@ -35,6 +39,12 @@ public class BoosterPack extends OpenablePack {
|
||||
|
||||
public BoosterPack(final String name0, final BoosterData boosterData) {
|
||||
super(name0, boosterData);
|
||||
artIndex = MyRandom.getRandom().nextInt(boosterData.getArtIndices()) + 1;
|
||||
hash = super.hashCode() ^ artIndex;
|
||||
}
|
||||
|
||||
public final int getArtIndex() {
|
||||
return artIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,4 +60,21 @@ public class BoosterPack extends OpenablePack {
|
||||
public BoosterData getBoosterData() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
BoosterPack other = (BoosterPack)obj;
|
||||
return artIndex == other.artIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,10 @@ import forge.card.BoosterData;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
protected final BoosterData contents;
|
||||
protected final String name;
|
||||
private final int artIndex;
|
||||
private final int hash;
|
||||
private List<CardPrinted> cards = null;
|
||||
private BoosterGenerator generator = null;
|
||||
@@ -45,8 +43,7 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
if (null == boosterData) { throw new NullArgumentException("boosterData"); }
|
||||
contents = boosterData;
|
||||
name = name0;
|
||||
artIndex = MyRandom.getRandom().nextInt(boosterData.getArtIndices()) + 1;
|
||||
hash = name.hashCode() ^ getClass().hashCode() ^ contents.hashCode() ^ artIndex;
|
||||
hash = name.hashCode() ^ getClass().hashCode() ^ contents.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,10 +60,6 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
return contents.getEdition();
|
||||
}
|
||||
|
||||
public final int getArtIndex() {
|
||||
return artIndex;
|
||||
}
|
||||
|
||||
public final List<CardPrinted> getCards() {
|
||||
if (null == cards) {
|
||||
cards = generate();
|
||||
@@ -80,7 +73,7 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@@ -91,12 +84,11 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
return false;
|
||||
}
|
||||
OpenablePack other = (OpenablePack)obj;
|
||||
return name.equals(other.name) && contents.equals(other.contents) && artIndex == other.artIndex;
|
||||
return name.equals(other.name) && contents.equals(other.contents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
System.out.println(String.format("returning hash: %d for edition=%s; idx=%d", hash, getEdition(), getArtIndex()));
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user