Commit 79e0bff4 authored by ElderLich's avatar ElderLich

Bug Fix: Genesys points show as 0 when offline

In Deck Editor, Genesys card points and total deck GP only load correctly when connected to the internet. Offline/local play shows all cards as 0, even though local Genesys data exists and should be used.
parent 236be64a
...@@ -28,22 +28,24 @@ namespace MDPro3.Net ...@@ -28,22 +28,24 @@ namespace MDPro3.Net
private static async UniTask InitializeGenesysLflist() private static async UniTask InitializeGenesysLflist()
{ {
// Load cached/local genesys data immediately so Deck Editor works offline.
ParseGenesysLflist();
var eTag = await GetETagAsync(URL_GENESYS_LFLIST); var eTag = await GetETagAsync(URL_GENESYS_LFLIST);
if (!string.IsNullOrEmpty(eTag)) if (string.IsNullOrEmpty(eTag))
{ return;
var configTag = Config.Get(GetLocalETagKey(URL_GENESYS_LFLIST), Config.EMPTY_STRING); var configTag = Config.Get(GetLocalETagKey(URL_GENESYS_LFLIST), Config.EMPTY_STRING);
if(!string.Equals(eTag, configTag, StringComparison.Ordinal)) if(!string.Equals(eTag, configTag, StringComparison.Ordinal))
{ {
Program.Debug("Update Genesys Lflist."); Program.Debug("Update Genesys Lflist.");
await DownloadGenesysLflist(eTag); await DownloadGenesysLflist(eTag);
ParseGenesysLflist();
} }
else else
Program.Debug("Genesys Lflist do not need update."); Program.Debug("Genesys Lflist do not need update.");
} }
ParseGenesysLflist();
}
private static bool GenesysRequiresDownload() private static bool GenesysRequiresDownload()
{ {
if (!File.Exists(PATH_GENESYS_LFLIST)) if (!File.Exists(PATH_GENESYS_LFLIST))
...@@ -74,6 +76,10 @@ namespace MDPro3.Net ...@@ -74,6 +76,10 @@ namespace MDPro3.Net
private static void ParseGenesysLflist() private static void ParseGenesysLflist()
{ {
genesysBannedCards.Clear();
genesysPoints.Clear();
officialGenesysLimit = 100;
if (!File.Exists(PATH_GENESYS_LFLIST)) if (!File.Exists(PATH_GENESYS_LFLIST))
return; return;
...@@ -88,6 +94,13 @@ namespace MDPro3.Net ...@@ -88,6 +94,13 @@ namespace MDPro3.Net
if(string.IsNullOrEmpty(line) || line.StartsWith("#")) continue; if(string.IsNullOrEmpty(line) || line.StartsWith("#")) continue;
if (line.StartsWith("$")) if (line.StartsWith("$"))
{ {
// e.g. "$genesys 100"
if (line.StartsWith("$genesys", StringComparison.OrdinalIgnoreCase))
{
var limitParts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (limitParts.Length >= 2 && int.TryParse(limitParts[1], out var limit))
officialGenesysLimit = limit;
}
currentType = line; currentType = line;
continue; continue;
} }
...@@ -242,6 +255,7 @@ namespace MDPro3.Net ...@@ -242,6 +255,7 @@ namespace MDPro3.Net
public static async UniTask<string> GetETagAsync(string url) public static async UniTask<string> GetETagAsync(string url)
{ {
using var headRequest = UnityWebRequest.Head(url); using var headRequest = UnityWebRequest.Head(url);
headRequest.timeout = 8;
await headRequest.SendWebRequest(); await headRequest.SendWebRequest();
if(headRequest.result != UnityWebRequest.Result.Success) if(headRequest.result != UnityWebRequest.Result.Success)
......
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