mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Add colorless shards to Statistics view
This commit is contained in:
@@ -55,4 +55,13 @@ public abstract class ManaAtom {
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
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++) {
|
||||
char symbol = stringValue.charAt(i);
|
||||
@@ -177,7 +177,8 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
|
||||
case 'B':
|
||||
case 'R':
|
||||
case 'G':
|
||||
counts[MagicColor.getIndexOfFirstColor(MagicColor.fromName(symbol))]++;
|
||||
case 'C':
|
||||
counts[ManaAtom.getIndexOfFirstManaType(ManaAtom.fromName(symbol))]++;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -313,8 +314,8 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param manaCost
|
||||
* @param manaCost2
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
public static ManaCost combine(ManaCost a, ManaCost b) {
|
||||
|
||||
@@ -106,6 +106,7 @@ public enum CStatistics implements ICDoc {
|
||||
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblBlackShard(), "Shards:", shardCount[2], totShards);
|
||||
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblRedShard(), "Shards:", shardCount[3], totShards);
|
||||
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblGreenShard(), "Shards:", shardCount[4], totShards);
|
||||
setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblColorlessShard(), "Shards:", shardCount[5], totShards);
|
||||
|
||||
int tmc = 0;
|
||||
for (final Entry<PaperCard, Integer> e : deck) {
|
||||
@@ -130,10 +131,10 @@ public enum CStatistics implements ICDoc {
|
||||
}
|
||||
|
||||
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()) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public enum VStatistics implements IVDoc<CStatistics> {
|
||||
private final FLabel lblBlackShard = buildLabel(StatTypes.BLACK, true);
|
||||
private final FLabel lblRedShard = buildLabel(StatTypes.RED, false);
|
||||
private final FLabel lblGreenShard = buildLabel(StatTypes.GREEN, false);
|
||||
private final FLabel lblColorlessShard = buildLabel(StatTypes.COLORLESS, false);
|
||||
|
||||
// Card type labels
|
||||
private final FLabel lblArtifact = buildLabel(StatTypes.ARTIFACT, true);
|
||||
@@ -169,6 +170,7 @@ public enum VStatistics implements IVDoc<CStatistics> {
|
||||
pnlStats.add(lblBlackShard, constraints);
|
||||
pnlStats.add(lblRedShard, constraints);
|
||||
pnlStats.add(lblGreenShard, constraints);
|
||||
pnlStats.add(lblColorlessShard, constraints);
|
||||
}
|
||||
|
||||
//========== Overridden methods
|
||||
@@ -249,6 +251,7 @@ public enum VStatistics implements IVDoc<CStatistics> {
|
||||
public FLabel getLblRedShard() { return lblRedShard; }
|
||||
/** @return {@link forge.toolbox.FLabel} */
|
||||
public FLabel getLblWhiteShard() { return lblWhiteShard; }
|
||||
public FLabel getLblColorlessShard() { return lblColorlessShard; }
|
||||
|
||||
/** @return {@link forge.toolbox.FLabel} */
|
||||
public FLabel getLblArtifact() { return lblArtifact; }
|
||||
|
||||
Reference in New Issue
Block a user