...cleanup

This commit is contained in:
2026-06-17 23:51:28 -04:00
parent c6b5f8b205
commit ee204dde46
27 changed files with 65978 additions and 45921 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\Model\Model.csproj"/>
</ItemGroup>
</Project>
+15 -9
View File
@@ -53,10 +53,12 @@ foreach (var file in mdFiles)
Set = StripWikiLink(yaml.GetValueOrDefault("set")),
Speed = StripWikiLink(yaml.GetValueOrDefault("speed")),
Archetypes = ParseList(yaml, "archetypes").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
ImmortalizeTo = yaml.ContainsKey("immortalizeTo") ? ParseListOrScalar(yaml, "immortalizeTo").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList() : null,
ImmortalizeTo = yaml.ContainsKey("immortalizeTo")
? ParseListOrScalar(yaml, "immortalizeTo").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList()
: null,
ImmortalizeFrom = StripWikiLink(yaml.GetValueOrDefault("immortalizeFrom")),
ImmortalizeWhen = NullIfNa(StripWikiLinks(yaml.GetValueOrDefault("immortalizeWhen"))),
ImageFile = imageFile,
ImageFile = imageFile
};
cards.Add(card);
@@ -71,7 +73,7 @@ foreach (var card in cards)
var src = Path.Combine(docsDir, card.ImageFile);
var dst = Path.Combine(cardsDir, card.ImageFile);
if (File.Exists(src))
File.Copy(src, dst, overwrite: true);
File.Copy(src, dst, true);
}
// Generate C# source file
@@ -87,7 +89,7 @@ writer.WriteLine("{");
writer.WriteLine(" public static readonly System.Collections.Generic.List<CardData> Cards =");
writer.WriteLine(" [");
for (int i = 0; i < cards.Count; i++)
for (var i = 0; i < cards.Count; i++)
{
var c = cards[i];
writer.WriteLine(" new()");
@@ -138,7 +140,10 @@ static string? StripWikiLinks(string? s)
return Regex.Replace(s.Trim('"'), @"\[\[([^\]]*)\]\]", "$1").Trim();
}
static string? NullIfNa(string? s) => s is "N/A" or null ? null : s.Trim('"');
static string? NullIfNa(string? s)
{
return s is "N/A" or null ? null : s.Trim('"');
}
static List<string> ParseList(Dictionary<string, string> yaml, string key)
{
@@ -149,6 +154,7 @@ static List<string> ParseList(Dictionary<string, string> yaml, string key)
var trimmed = item.TrimStart('-', ' ').Trim(' ', '"');
if (trimmed.Length > 0) result.Add(trimmed);
}
return result;
}
@@ -165,6 +171,7 @@ static List<string> ParseListOrScalar(Dictionary<string, string> yaml, string ke
var trimmed = item.TrimStart('-', ' ').Trim(' ', '"');
if (trimmed.Length > 0) result.Add(trimmed);
}
return result;
}
@@ -240,8 +247,7 @@ static string ToLiteral(string? s)
if (s == null) return "null";
var sb = new StringBuilder();
sb.Append('"');
foreach (char c in s)
{
foreach (var c in s)
switch (c)
{
case '"': sb.Append("\\\""); break;
@@ -252,7 +258,7 @@ static string ToLiteral(string? s)
case '\0': sb.Append("\\0"); break;
default: sb.Append(c); break;
}
}
sb.Append('"');
return sb.ToString();
}
}