Commit ad502a85 authored by AnimeGitB's avatar AnimeGitB
Browse files

Finally enforce deprecation of ancient Banners.json fields

Also add costItemId10 column so people know it exists, and removeC6FromPool column because it's a cool setting nobody knows about.
parent f6c84fdf
...@@ -14,7 +14,7 @@ public class GachaBanner { ...@@ -14,7 +14,7 @@ public class GachaBanner {
@Getter private int gachaType; @Getter private int gachaType;
@Getter private int scheduleId; @Getter private int scheduleId;
@Getter private String prefabPath; @Getter private String prefabPath;
private String previewPrefabPath; @Getter private String previewPrefabPath;
@Getter private String titlePath; @Getter private String titlePath;
private int costItemId = 0; private int costItemId = 0;
private int costItemAmount = 1; private int costItemAmount = 1;
...@@ -24,8 +24,8 @@ public class GachaBanner { ...@@ -24,8 +24,8 @@ public class GachaBanner {
@Getter private int endTime; @Getter private int endTime;
@Getter private int sortId; @Getter private int sortId;
@Getter private int gachaTimesLimit = Integer.MAX_VALUE; @Getter private int gachaTimesLimit = Integer.MAX_VALUE;
private int[] rateUpItems4 = {}; @Getter private int[] rateUpItems4 = {};
private int[] rateUpItems5 = {}; @Getter private int[] rateUpItems5 = {};
@Getter private int[] fallbackItems3 = {11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302, 15304}; @Getter private int[] fallbackItems3 = {11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302, 15304};
@Getter private int[] fallbackItems4Pool1 = {1014, 1020, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1059, 1064, 1065, 1067, 1068, 1072}; @Getter private int[] fallbackItems4Pool1 = {1014, 1020, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1059, 1064, 1065, 1067, 1068, 1072};
@Getter private int[] fallbackItems4Pool2 = {11401, 11402, 11403, 11405, 12401, 12402, 12403, 12405, 13401, 13407, 14401, 14402, 14403, 14409, 15401, 15402, 15403, 15405}; @Getter private int[] fallbackItems4Pool2 = {11401, 11402, 11403, 11405, 12401, 12402, 12403, 12405, 13401, 13407, 14401, 14402, 14403, 14409, 15401, 15402, 15403, 15405};
...@@ -52,9 +52,11 @@ public class GachaBanner { ...@@ -52,9 +52,11 @@ public class GachaBanner {
@Deprecated private int hardPity = -1; @Deprecated private int hardPity = -1;
@Deprecated private int minItemType = -1; @Deprecated private int minItemType = -1;
@Deprecated private int maxItemType = -1; @Deprecated private int maxItemType = -1;
@Getter private boolean deprecated = false;
private static void warnDeprecated(String name, String replacement) { private void warnDeprecated(String name, String replacement) {
Grasscutter.getLogger().error("Deprecated field found in Banners.json: "+name+" was replaced back in early May 2022, use "+replacement+" instead. If you do not remove this key from your config, it will refuse to load in a future Grasscutter version."); Grasscutter.getLogger().error("Deprecated field found in Banners config: "+name+" was replaced back in early May 2022, use "+replacement+" instead. You MUST remove this field from your config.");
this.deprecated = true;
} }
public void onLoad() { public void onLoad() {
if (eventChance != -1) if (eventChance != -1)
...@@ -73,30 +75,24 @@ public class GachaBanner { ...@@ -73,30 +75,24 @@ public class GachaBanner {
warnDeprecated("rateUpItems1", "rateUpItems5"); warnDeprecated("rateUpItems1", "rateUpItems5");
if (rateUpItems2.length > 0) if (rateUpItems2.length > 0)
warnDeprecated("rateUpItems2", "rateUpItems4"); warnDeprecated("rateUpItems2", "rateUpItems4");
} if (this.previewPrefabPath != null && this.previewPrefabPath.equals("UI_Tab_" + this.prefabPath))
Grasscutter.getLogger().error("Redundant field found in Banners config: previewPrefabPath does not need to be specified if it is identical to prefabPath prefixed with \"UI_Tab_\".");
public String getPreviewPrefabPath() { if (this.previewPrefabPath == null || this.previewPrefabPath.isEmpty())
if (this.previewPrefabPath != null && !this.previewPrefabPath.isEmpty()) this.previewPrefabPath = "UI_Tab_" + this.prefabPath;
return this.previewPrefabPath; if (this.costItemId10 == 0)
return "UI_Tab_" + this.prefabPath; this.costItemId10 = this.costItemId;
} }
public ItemParamData getCost(int numRolls) { public ItemParamData getCost(int numRolls) {
return switch (numRolls) { return switch (numRolls) {
case 10 -> new ItemParamData((costItemId10 > 0) ? costItemId10 : getCostItem(), costItemAmount10); case 10 -> new ItemParamData(costItemId10, costItemAmount10);
default -> new ItemParamData(getCostItem(), costItemAmount * numRolls); default -> new ItemParamData(costItemId, costItemAmount * numRolls);
}; };
} }
@Deprecated
public int getCostItem() { public int getCostItem() {
return (costItem > 0) ? costItem : costItemId; return costItemId;
}
public int[] getRateUpItems4() {
return (rateUpItems2.length > 0) ? rateUpItems2 : rateUpItems4;
}
public int[] getRateUpItems5() {
return (rateUpItems1.length > 0) ? rateUpItems1 : rateUpItems5;
} }
public boolean hasEpitomized() { public boolean hasEpitomized() {
...@@ -120,7 +116,7 @@ public class GachaBanner { ...@@ -120,7 +116,7 @@ public class GachaBanner {
public int getEventChance(int rarity) { public int getEventChance(int rarity) {
return switch (rarity) { return switch (rarity) {
case 4 -> eventChance4; case 4 -> eventChance4;
default -> (eventChance > -1) ? eventChance : eventChance5; default -> eventChance5;
}; };
} }
...@@ -138,8 +134,6 @@ public class GachaBanner { ...@@ -138,8 +134,6 @@ public class GachaBanner {
+ "/gacha/details?s=" + sessionKey + "&scheduleId=" + scheduleId; + "/gacha/details?s=" + sessionKey + "&scheduleId=" + scheduleId;
// Grasscutter.getLogger().info("record = " + record); // Grasscutter.getLogger().info("record = " + record);
ItemParamData costItem1 = this.getCost(1);
ItemParamData costItem10 = this.getCost(10);
PlayerGachaBannerInfo gachaInfo = player.getGachaInfo().getBannerInfo(this); PlayerGachaBannerInfo gachaInfo = player.getGachaInfo().getBannerInfo(this);
int leftGachaTimes = switch (gachaTimesLimit) { int leftGachaTimes = switch (gachaTimesLimit) {
case Integer.MAX_VALUE -> Integer.MAX_VALUE; case Integer.MAX_VALUE -> Integer.MAX_VALUE;
...@@ -150,10 +144,10 @@ public class GachaBanner { ...@@ -150,10 +144,10 @@ public class GachaBanner {
.setScheduleId(this.getScheduleId()) .setScheduleId(this.getScheduleId())
.setBeginTime(this.getBeginTime()) .setBeginTime(this.getBeginTime())
.setEndTime(this.getEndTime()) .setEndTime(this.getEndTime())
.setCostItemId(costItem1.getId()) .setCostItemId(this.costItemId)
.setCostItemNum(costItem1.getCount()) .setCostItemNum(this.costItemAmount)
.setTenCostItemId(costItem10.getId()) .setTenCostItemId(this.costItemId10)
.setTenCostItemNum(costItem10.getCount()) .setTenCostItemNum(this.costItemAmount10)
.setGachaPrefabPath(this.getPrefabPath()) .setGachaPrefabPath(this.getPrefabPath())
.setGachaPreviewPrefabPath(this.getPreviewPrefabPath()) .setGachaPreviewPrefabPath(this.getPreviewPrefabPath())
.setGachaProbUrl(details) .setGachaProbUrl(details)
......
...@@ -74,7 +74,11 @@ public class GachaSystem extends BaseGameSystem { ...@@ -74,7 +74,11 @@ public class GachaSystem extends BaseGameSystem {
if (banners.size() > 0) { if (banners.size() > 0) {
for (GachaBanner banner : banners) { for (GachaBanner banner : banners) {
banner.onLoad(); banner.onLoad();
getGachaBanners().put(banner.getScheduleId(), banner); if (banner.isDeprecated()) {
Grasscutter.getLogger().error("A Banner has not been loaded because it contains one or more deprecated fields. Remove the fields mentioned above and reload.");
} else {
getGachaBanners().put(banner.getScheduleId(), banner);
}
} }
Grasscutter.getLogger().debug("Banners successfully loaded."); Grasscutter.getLogger().debug("Banners successfully loaded.");
} else { } else {
......
comment gachaType scheduleId bannerType prefabPath titlePath costItemId beginTime endTime sortId rateUpItems5 rateUpItems4 weights5 weights4 fallbackItems5Pool2 fallbackItems5Pool1 fallbackItems4Pool1 eventChance4 eventChance5 costItemAmount10 gachaTimesLimit comment gachaType scheduleId bannerType prefabPath titlePath costItemId beginTime endTime sortId rateUpItems5 rateUpItems4 weights5 weights4 fallbackItems5Pool2 fallbackItems5Pool1 fallbackItems4Pool1 eventChance4 eventChance5 costItemId10 costItemAmount10 gachaTimesLimit removeC6FromPool
Beginner's Banner. Do not change for no reason. 100 803 EVENT GachaShowPanel_A016 UI_GACHA_SHOW_PANEL_A016_TITLE 224 1924992000 9999 [1034] 8 20 Beginner's Banner. Do not change for no reason. 100 803 EVENT GachaShowPanel_A016 UI_GACHA_SHOW_PANEL_A016_TITLE 224 1924992000 9999 [1034] 8 20
Standard 200 893 STANDARD GachaShowPanel_A022 UI_GACHA_SHOW_PANEL_A022_TITLE 224 1924992000 1000 [[1, 75], [73, 150], [90, 10000]] [1006, 1014, 1015, 1020, 1021, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1059, 1064, 1065, 1067, 1068, 1072] Standard 200 893 STANDARD GachaShowPanel_A022 UI_GACHA_SHOW_PANEL_A022_TITLE 224 1924992000 1000 [[1, 75], [73, 150], [90, 10000]] [1006, 1014, 1015, 1020, 1021, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1059, 1064, 1065, 1067, 1068, 1072]
Character Event Banner 1 301 903 EVENT GachaShowPanel_A106 UI_GACHA_SHOW_PANEL_A071_TITLE 223 1924992000 9998 [1058] [1050, 1059, 1074] [[1, 80], [73, 80], [90, 10000]] [] Character Event Banner 1 301 903 EVENT GachaShowPanel_A106 UI_GACHA_SHOW_PANEL_A071_TITLE 223 1924992000 9998 [1058] [1050, 1059, 1074] [[1, 80], [73, 80], [90, 10000]] []
Character Event Banner 2 400 923 EVENT GachaShowPanel_A107 UI_GACHA_SHOW_PANEL_A037_TITLE 223 1924992000 9998 [1033] [1050, 1059, 1074] [[1, 80], [73, 80], [90, 10000]] [] Character Event Banner 2 400 923 EVENT GachaShowPanel_A107 UI_GACHA_SHOW_PANEL_A037_TITLE 223 1924992000 9998 [1033] [1050, 1059, 1074] [[1, 80], [73, 80], [90, 10000]] []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment