From a36b2ed13e2a043127a33cf32510401e95deb99e Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Sat, 14 Apr 2018 20:48:57 +0100 Subject: [PATCH] Added some default date handling for gameformats --- forge-game/src/main/java/forge/game/GameFormat.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 68469242033..4acc56dc879 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -61,6 +61,7 @@ public class GameFormat implements Comparable { protected boolean restrictedLegendary = false; private Date effectiveDate; private final static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + private final static String DEFAULTDATE = "1990-01-01"; protected final transient List allowedSetCodes_ro; protected final transient List bannedCardNames_ro; @@ -73,10 +74,10 @@ public class GameFormat implements Comparable { private final int index; public GameFormat(final String fName, final Iterable sets, final List bannedCards) { - this(fName, parseDate("1990-01-01"), sets, bannedCards, null, false, null, null, 0, FormatType.Custom, FormatSubType.Custom); + this(fName, parseDate(DEFAULTDATE), sets, bannedCards, null, false, null, null, 0, FormatType.Custom, FormatSubType.Custom); } - public static final GameFormat NoFormat = new GameFormat("(none)", parseDate("1990-01-01") , null, null, null, false + public static final GameFormat NoFormat = new GameFormat("(none)", parseDate(DEFAULTDATE) , null, null, null, false , null, null, Integer.MAX_VALUE, FormatType.Custom, FormatSubType.Custom); public GameFormat(final String fName, final Date effectiveDate, final Iterable sets, final List bannedCards, @@ -271,7 +272,9 @@ public class GameFormat implements Comparable { } } if (formatType.equals(FormatType.Historic)){ - return effectiveDate.compareTo(other.effectiveDate); + if(effectiveDate!=other.effectiveDate) {//for matching dates or default dates default to name sorting + return effectiveDate.compareTo(other.effectiveDate); + } } return name.compareTo(other.name); //return index - other.index; @@ -313,6 +316,9 @@ public class GameFormat implements Comparable { } Integer idx = section.getInt("order"); Date date = parseDate(section.get("effectivedate")); + if (date == null){ + date = parseDate(DEFAULTDATE); + } String strSets = section.get("sets"); if ( null != strSets ) { sets = Arrays.asList(strSets.split(", "));