mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix mana cost rendering in table
Start favorites column
This commit is contained in:
34
forge-core/src/main/java/forge/card/CardPreferences.java
Normal file
34
forge-core/src/main/java/forge/card/CardPreferences.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Preferences associated with individual cards
|
||||
*
|
||||
*/
|
||||
public class CardPreferences {
|
||||
private static Map<String, CardPreferences> allPrefs = new HashMap<String, CardPreferences>();
|
||||
|
||||
public static CardPreferences getPrefs(String key) {
|
||||
CardPreferences prefs = allPrefs.get(key);
|
||||
if (prefs == null) {
|
||||
prefs = new CardPreferences();
|
||||
allPrefs.put(key, prefs);
|
||||
}
|
||||
return prefs;
|
||||
}
|
||||
|
||||
private int starCount;
|
||||
|
||||
private CardPreferences() {
|
||||
}
|
||||
|
||||
public int getStarCount() {
|
||||
return this.starCount;
|
||||
}
|
||||
|
||||
public void setStarCount(int starCount0) {
|
||||
this.starCount = starCount0;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
//import forge.Card;
|
||||
import forge.card.CardPreferences;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
import forge.util.PredicateString;
|
||||
@@ -149,7 +149,6 @@ public interface IPaperCard extends InventoryItem {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract String getName();
|
||||
public abstract String getEdition();
|
||||
public abstract int getArtIndex();
|
||||
@@ -157,7 +156,6 @@ public interface IPaperCard extends InventoryItem {
|
||||
public abstract boolean isToken();
|
||||
public abstract CardRules getRules();
|
||||
public abstract CardRarity getRarity();
|
||||
|
||||
public abstract CardPreferences getPrefs();
|
||||
public abstract String getItemType();
|
||||
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package forge.item;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.card.CardPreferences;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
|
||||
@@ -188,4 +189,9 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
||||
// TODO compare sets properly
|
||||
return this.edition.compareTo(o.getEdition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardPreferences getPrefs() {
|
||||
return CardPreferences.getPrefs(this.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.item;
|
||||
import java.util.Locale;
|
||||
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardPreferences;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
|
||||
@@ -31,34 +32,65 @@ public class PaperToken implements InventoryItemFromSet, IPaperCard {
|
||||
public static String makeTokenFileName(String colors, int power, int toughness, String name) {
|
||||
return makeTokenFileName(colors, String.valueOf(power), String.valueOf(toughness), name);
|
||||
}
|
||||
|
||||
|
||||
public static String makeTokenFileName(String colors, String power, String toughness, String name) {
|
||||
StringBuilder fileName = new StringBuilder();
|
||||
fileName.append(colors).append('_').append(power).append('_').append(toughness).append('_').append(name);
|
||||
return makeTokenFileName(fileName.toString());
|
||||
}
|
||||
|
||||
|
||||
public PaperToken(final CardRules c, CardEdition edition0, final String imageFileName) {
|
||||
this.card = c;
|
||||
this.name = c.getName();
|
||||
this.edition = edition0;
|
||||
this.imageFileName = String.format("%s%s", null == edition || CardEdition.UNKNOWN == edition ? "" : edition.getCode(), imageFileName);
|
||||
}
|
||||
|
||||
@Override public String getName() { return name; }
|
||||
|
||||
@Override public String getEdition() { return edition.getCode(); }
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override public int getArtIndex() { return 0; } // This might change however
|
||||
@Override public boolean isFoil() { return false; }
|
||||
@Override public CardRules getRules() { return card; }
|
||||
@Override
|
||||
public String getEdition() {
|
||||
return edition.getCode();
|
||||
}
|
||||
|
||||
@Override public CardRarity getRarity() { return CardRarity.Common; } // They don't have rarity though!
|
||||
@Override
|
||||
public int getArtIndex() {
|
||||
return 0; // This might change however
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardRules getRules() {
|
||||
return card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardRarity getRarity() {
|
||||
return CardRarity.Common; // They don't have rarity though!
|
||||
}
|
||||
|
||||
// Unfortunately this is a property of token, cannot move it outside of class
|
||||
public String getImageFilename() { return imageFileName; }
|
||||
|
||||
@Override public String getItemType() { return "Token"; }
|
||||
@Override
|
||||
public String getItemType() {
|
||||
return "Token";
|
||||
}
|
||||
|
||||
@Override public boolean isToken() { return true; }
|
||||
@Override
|
||||
public boolean isToken() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardPreferences getPrefs() {
|
||||
return CardPreferences.getPrefs(this.imageFileName); //use generated image file name as key
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user