mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Integrating Personal Ratings patch by Seravy.
This commit is contained in:
@@ -283,7 +283,14 @@ public enum FSkinProp {
|
||||
IMG_BTN_DISABLED_LEFT (new int[] {80, 200, 40, 40}, PropType.ICON),
|
||||
IMG_BTN_DISABLED_CENTER (new int[] {120, 200, 1, 40}, PropType.ICON),
|
||||
IMG_BTN_DISABLED_RIGHT (new int[] {160, 200, 40, 40}, PropType.ICON),
|
||||
|
||||
|
||||
IMG_FAV1 (new int[] {0, 0, 100, 100}, PropType.FAVICON),
|
||||
IMG_FAV2 (new int[] {100, 0, 100, 100}, PropType.FAVICON),
|
||||
IMG_FAV3 (new int[] {200, 0, 100, 100}, PropType.FAVICON),
|
||||
IMG_FAV4 (new int[] {300, 0, 100, 100}, PropType.FAVICON),
|
||||
IMG_FAV5 (new int[] {400, 0, 100, 100}, PropType.FAVICON),
|
||||
IMG_FAVNONE (new int[] {500, 0, 100, 100}, PropType.FAVICON),
|
||||
|
||||
IMG_QUEST_DRAFT_DECK (new int[] {0, 0, 680, 475}, PropType.IMAGE);
|
||||
|
||||
private int[] coords;
|
||||
@@ -317,6 +324,7 @@ public enum FSkinProp {
|
||||
FOIL,
|
||||
OLD_FOIL,
|
||||
TROPHY,
|
||||
PLANAR_CONQUEST
|
||||
PLANAR_CONQUEST,
|
||||
FAVICON
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,8 @@ package forge.itemmanager;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.StaticData;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.*;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.game.GameFormat;
|
||||
import forge.interfaces.IButton;
|
||||
@@ -17,13 +12,11 @@ import forge.item.PaperCard;
|
||||
import forge.itemmanager.SItemManagerUtil.StatTypes;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.quest.data.StarRating;
|
||||
import forge.util.BinaryUtil;
|
||||
import forge.util.PredicateString.StringOp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Static factory; holds blocks of form elements and predicates
|
||||
@@ -141,9 +134,56 @@ public class SFilterUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static Predicate<PaperCard> buildFoilFilter(Map<SItemManagerUtil.StatTypes, ? extends IButton> buttonMap) {
|
||||
public static Predicate<PaperCard> buildStarRatingFilter(Map<SItemManagerUtil.StatTypes, ? extends IButton> buttonMap, final HashSet<StarRating> QuestRatings) {
|
||||
final Map<SItemManagerUtil.StatTypes, ? extends IButton> buttonMap2 = buttonMap;
|
||||
return new Predicate<PaperCard>() {
|
||||
@Override
|
||||
public boolean apply(PaperCard card) {
|
||||
|
||||
// final Map<StatTypes, ? extends IButton> buttonMap2 =buttonMap;
|
||||
StarRating r = new StarRating();
|
||||
r.Name = card.getName();
|
||||
r.Edition = card.getEdition();
|
||||
int j = 0;
|
||||
for (int i = 1; i < 6; i++) {
|
||||
r.rating = i;
|
||||
if (QuestRatings.contains(r)) {
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
boolean result = true;
|
||||
|
||||
if (j == 0) {
|
||||
if (!buttonMap2.get(StatTypes.RATE_NONE).isSelected()) {
|
||||
result = false;
|
||||
}
|
||||
} else if (j == 1) {
|
||||
if (!buttonMap2.get(StatTypes.RATE_1).isSelected()) {
|
||||
result = false;
|
||||
}
|
||||
} else if (j == 2) {
|
||||
if (!buttonMap2.get(StatTypes.RATE_2).isSelected()) {
|
||||
result = false;
|
||||
}
|
||||
} else if (j == 3) {
|
||||
if (!buttonMap2.get(StatTypes.RATE_3).isSelected()) {
|
||||
result = false;
|
||||
}
|
||||
} else if (j == 4) {
|
||||
if (!buttonMap2.get(StatTypes.RATE_4).isSelected()) {
|
||||
result = false;
|
||||
}
|
||||
} else if (j == 5) {
|
||||
if (!buttonMap2.get(StatTypes.RATE_5).isSelected()) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Predicate<PaperCard> buildFoilFilter(Map<SItemManagerUtil.StatTypes, ? extends IButton> buttonMap) {
|
||||
final int Foil = (((buttonMap.get(StatTypes.FOIL_OLD).isSelected()) ? 1 : 0)
|
||||
+ ((buttonMap.get(StatTypes.FOIL_NEW).isSelected()) ? 2 : 0)
|
||||
+ ((buttonMap.get(StatTypes.FOIL_NONE).isSelected()) ? 4 : 0));
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
package forge.itemmanager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.IHasSkinProp;
|
||||
import forge.card.CardRules;
|
||||
@@ -17,6 +10,12 @@ import forge.interfaces.IComboBox;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.util.ComparableOp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Static methods for working with top-level editor methods,
|
||||
* included but not limited to preferences IO, icon generation,
|
||||
@@ -62,10 +61,17 @@ public final class SItemManagerUtil {
|
||||
DECK_COLORLESS (FSkinProp.IMG_MANA_COLORLESS, null, "Colorless decks"),
|
||||
DECK_MULTICOLOR (FSkinProp.IMG_MULTI, null, "Multicolor decks"),
|
||||
|
||||
FOIL_OLD (FSkinProp.FOIL_11, null, "Old style Foil cards"),
|
||||
FOIL_NEW (FSkinProp.FOIL_01, null, "New style Foil cards"),
|
||||
FOIL_NONE (FSkinProp.ICO_CLOSE, null, "non-Foil cards");
|
||||
|
||||
FOIL_OLD (FSkinProp.FOIL_11, null, "Old style Foil cards"),
|
||||
FOIL_NEW (FSkinProp.FOIL_01, null, "New style Foil cards"),
|
||||
FOIL_NONE (FSkinProp.ICO_CLOSE, null, "Non-Foil cards"),
|
||||
|
||||
RATE_NONE (FSkinProp.IMG_FAVNONE, null, "Unrated cards"),
|
||||
RATE_1 (FSkinProp.IMG_FAV1, null, "1 star cards"),
|
||||
RATE_2 (FSkinProp.IMG_FAV2, null, "2 star cards"),
|
||||
RATE_3 (FSkinProp.IMG_FAV3, null, "3 star cards"),
|
||||
RATE_4 (FSkinProp.IMG_FAV4, null, "4 star cards"),
|
||||
RATE_5 (FSkinProp.IMG_FAV5, null, "5 star cards");
|
||||
|
||||
|
||||
public final FSkinProp skinProp;
|
||||
public final Predicate<CardRules> predicate;
|
||||
|
||||
@@ -92,6 +92,7 @@ public final class ForgeConstants {
|
||||
public static final String SPRITE_OLD_FOILS_FILE = "sprite_old_foils.png";
|
||||
public static final String SPRITE_TROPHIES_FILE = "sprite_trophies.png";
|
||||
public static final String SPRITE_AVATARS_FILE = "sprite_avatars.png";
|
||||
public static final String SPRITE_FAVICONS_FILE = "sprite_favicons.png";
|
||||
public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png";
|
||||
public static final String FONT_FILE = "font1.ttf";
|
||||
public static final String SPLASH_BG_FILE = "bg_splash.png";
|
||||
|
||||
@@ -32,10 +32,7 @@ import forge.properties.ForgeConstants;
|
||||
import forge.quest.bazaar.QuestBazaarManager;
|
||||
import forge.quest.bazaar.QuestItemType;
|
||||
import forge.quest.bazaar.QuestPetStorage;
|
||||
import forge.quest.data.GameFormatQuest;
|
||||
import forge.quest.data.QuestAchievements;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.*;
|
||||
import forge.quest.data.QuestPreferences.DifficultyPrefs;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.io.QuestChallengeReader;
|
||||
@@ -137,6 +134,22 @@ public class QuestController {
|
||||
return this.myCards;
|
||||
}
|
||||
|
||||
// Set the card's custom rating to N stars
|
||||
public void SetRating(String name, String edition, int n) {
|
||||
StarRating r = new StarRating();
|
||||
r.Name = name;
|
||||
r.Edition = edition;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
r.rating = i;
|
||||
model.Ratings.remove(r);
|
||||
}
|
||||
|
||||
r.rating = n;
|
||||
if (n != 0) {
|
||||
model.Ratings.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the my decks.
|
||||
*
|
||||
@@ -427,6 +440,10 @@ public class QuestController {
|
||||
this.duelManager = new QuestEventDuelManager(new File(path));
|
||||
}
|
||||
|
||||
public HashSet<StarRating> GetRating() {
|
||||
return model.Ratings;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Reset the challenges manager.
|
||||
|
||||
@@ -25,6 +25,7 @@ import forge.quest.io.QuestDataIO;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
//when you create QuestDataOld and AFTER you copy the AI decks over
|
||||
@@ -41,7 +42,7 @@ import java.util.Map;
|
||||
*/
|
||||
public final class QuestData {
|
||||
/** Holds the latest version of the Quest Data. */
|
||||
public static final int CURRENT_VERSION_NUMBER = 10;
|
||||
public static final int CURRENT_VERSION_NUMBER = 11;
|
||||
|
||||
// This field places the version number into QD instance,
|
||||
// but only when the object is created through the constructor
|
||||
@@ -65,6 +66,8 @@ public final class QuestData {
|
||||
private final Map<Integer, String> petSlots = new HashMap<>();
|
||||
private int matchLength = 3;
|
||||
|
||||
public HashSet<StarRating> Ratings = new HashSet<StarRating>();
|
||||
|
||||
public QuestData() { //needed for XML serialization
|
||||
}
|
||||
|
||||
|
||||
53
forge-gui/src/main/java/forge/quest/data/StarRating.java
Normal file
53
forge-gui/src/main/java/forge/quest/data/StarRating.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package forge.quest.data;
|
||||
|
||||
public class StarRating {
|
||||
public String Name;
|
||||
public String Edition;
|
||||
public int rating;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((Edition == null) ? 0 : Edition.hashCode());
|
||||
result = prime * result + ((Name == null) ? 0 : Name.hashCode());
|
||||
result = prime * result + rating;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StarRating other = (StarRating) obj;
|
||||
if (Edition == null) {
|
||||
if (other.Edition != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!Edition.equals(other.Edition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Name == null) {
|
||||
if (other.Name != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!Name.equals(other.Name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rating != other.rating) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -50,10 +50,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@@ -199,6 +196,11 @@ public class QuestDataIO {
|
||||
}
|
||||
|
||||
if (saveVersion < 11) {
|
||||
// clear player star ratings on cards - no card has been rated yet
|
||||
QuestDataIO.setFinalField(QuestData.class, "Ratings", newData, new HashSet<StarRating>());
|
||||
newData.Ratings.clear();
|
||||
}
|
||||
if (saveVersion < 12) {
|
||||
// Migrate DraftTournaments to use new Tournament class
|
||||
}
|
||||
|
||||
@@ -378,7 +380,7 @@ public class QuestDataIO {
|
||||
//Copy the save file in case the save fails
|
||||
FileUtil.copyFile(f + ".dat", f + ".dat.bak");
|
||||
QuestDataIO.savePacked(f + ".dat", xStream, qd);
|
||||
// QuestDataIO.saveUnpacked(f + ".xml", xStream, qd);
|
||||
//QuestDataIO.saveUnpacked(f + ".xml", xStream, qd);
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
//BugReporter.reportException(ex, "Error saving Quest Data.");
|
||||
|
||||
Reference in New Issue
Block a user