- Add colorless shards to Statistics view

This commit is contained in:
Sol
2016-02-17 19:27:02 +00:00
parent a06eb0b2ee
commit 8984606931
4 changed files with 20 additions and 6 deletions

View File

@@ -55,4 +55,13 @@ public abstract class ManaAtom {
} }
return 0; // generic return 0; // generic
} }
public static int getIndexOfFirstManaType(final byte color){
for (int i = 0; i < MANATYPES.length; i++) {
if ((color & MANATYPES[i]) != 0) {
return i;
}
}
return -1; // colorless
}
} }

View File

@@ -167,7 +167,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
* @return an array of five integers containing the amount of color shards in the card's mana cost in WUBRG order * @return an array of five integers containing the amount of color shards in the card's mana cost in WUBRG order
*/ */
public int[] getColorShardCounts() { public int[] getColorShardCounts() {
int[] counts = new int[5]; // in WUBRG order int[] counts = new int[6]; // in WUBRGC order
for (int i = 0; i < stringValue.length(); i++) { for (int i = 0; i < stringValue.length(); i++) {
char symbol = stringValue.charAt(i); char symbol = stringValue.charAt(i);
@@ -177,7 +177,8 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
case 'B': case 'B':
case 'R': case 'R':
case 'G': case 'G':
counts[MagicColor.getIndexOfFirstColor(MagicColor.fromName(symbol))]++; case 'C':
counts[ManaAtom.getIndexOfFirstManaType(ManaAtom.fromName(symbol))]++;
break; break;
} }
@@ -313,8 +314,8 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
/** /**
* TODO: Write javadoc for this method. * TODO: Write javadoc for this method.
* @param manaCost * @param a
* @param manaCost2 * @param b
* @return * @return
*/ */
public static ManaCost combine(ManaCost a, ManaCost b) { public static ManaCost combine(ManaCost a, ManaCost b) {

View File

@@ -106,6 +106,7 @@ public enum CStatistics implements ICDoc {
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblBlackShard(), "Shards:", shardCount[2], totShards); setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblBlackShard(), "Shards:", shardCount[2], totShards);
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblRedShard(), "Shards:", shardCount[3], totShards); setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblRedShard(), "Shards:", shardCount[3], totShards);
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblGreenShard(), "Shards:", shardCount[4], totShards); setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblGreenShard(), "Shards:", shardCount[4], totShards);
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblColorlessShard(), "Shards:", shardCount[5], totShards);
int tmc = 0; int tmc = 0;
for (final Entry<PaperCard, Integer> e : deck) { for (final Entry<PaperCard, Integer> e : deck) {
@@ -130,10 +131,10 @@ public enum CStatistics implements ICDoc {
} }
public static int[] calculateShards(final ItemPool<PaperCard> deck) { public static int[] calculateShards(final ItemPool<PaperCard> deck) {
final int[] counts = new int[5]; // in WUBRG order final int[] counts = new int[6]; // in WUBRGC order
for (final PaperCard c : deck.toFlatList()) { for (final PaperCard c : deck.toFlatList()) {
final int[] cShards = c.getRules().getManaCost().getColorShardCounts(); final int[] cShards = c.getRules().getManaCost().getColorShardCounts();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 6; i++) {
counts[i] += cShards[i]; counts[i] += cShards[i];
} }
} }

View File

@@ -62,6 +62,7 @@ public enum VStatistics implements IVDoc<CStatistics> {
private final FLabel lblBlackShard = buildLabel(StatTypes.BLACK, true); private final FLabel lblBlackShard = buildLabel(StatTypes.BLACK, true);
private final FLabel lblRedShard = buildLabel(StatTypes.RED, false); private final FLabel lblRedShard = buildLabel(StatTypes.RED, false);
private final FLabel lblGreenShard = buildLabel(StatTypes.GREEN, false); private final FLabel lblGreenShard = buildLabel(StatTypes.GREEN, false);
private final FLabel lblColorlessShard = buildLabel(StatTypes.COLORLESS, false);
// Card type labels // Card type labels
private final FLabel lblArtifact = buildLabel(StatTypes.ARTIFACT, true); private final FLabel lblArtifact = buildLabel(StatTypes.ARTIFACT, true);
@@ -169,6 +170,7 @@ public enum VStatistics implements IVDoc<CStatistics> {
pnlStats.add(lblBlackShard, constraints); pnlStats.add(lblBlackShard, constraints);
pnlStats.add(lblRedShard, constraints); pnlStats.add(lblRedShard, constraints);
pnlStats.add(lblGreenShard, constraints); pnlStats.add(lblGreenShard, constraints);
pnlStats.add(lblColorlessShard, constraints);
} }
//========== Overridden methods //========== Overridden methods
@@ -249,6 +251,7 @@ public enum VStatistics implements IVDoc<CStatistics> {
public FLabel getLblRedShard() { return lblRedShard; } public FLabel getLblRedShard() { return lblRedShard; }
/** @return {@link forge.toolbox.FLabel} */ /** @return {@link forge.toolbox.FLabel} */
public FLabel getLblWhiteShard() { return lblWhiteShard; } public FLabel getLblWhiteShard() { return lblWhiteShard; }
public FLabel getLblColorlessShard() { return lblColorlessShard; }
/** @return {@link forge.toolbox.FLabel} */ /** @return {@link forge.toolbox.FLabel} */
public FLabel getLblArtifact() { return lblArtifact; } public FLabel getLblArtifact() { return lblArtifact; }