Skip to content

Commit

Permalink
Add support for MKM art variation cards with † in collector numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
madelson committed Aug 15, 2024
1 parent 55c2852 commit 9efb7c3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>net461</TargetFramework>
<LangVersion>8.0</LangVersion>
<AssemblyName>TabletopMTGImporter</AssemblyName>
<AssemblyVersion>0.8.2.0</AssemblyVersion>
<FileVersion>0.8.2.0</FileVersion>
<AssemblyVersion>0.8.3.0</AssemblyVersion>
<FileVersion>0.8.3.0</FileVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion TabletopMtgImporter.Core/DeckParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static bool TryParse(TextReader reader, out List<DeckCard> cards, out Lis
# card name. Disallow characters used to delimit the following sections as well as trailing whitespace
\s+(?<name>[^\s\(`^]+(\s+[^\s\(`^]+)*)
# set and optionally collector number
(\s+\((?<set>\w+)\)(\s(?<collectorNumber>(\w+\-)?\d+[a-zA-Z]?))?)?
(\s+\((?<set>\w+)\)(\s(?<collectorNumber>(\w+\-)?\d+[a-zA-Z]?))?)?
# optional foil marker
(\s+\*F\*)?
# category [x{a}{b}...,] (new format) or `x` (old format).
Expand Down
7 changes: 6 additions & 1 deletion TabletopMtgImporter.Core/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ async Task<bool> TryImportAsync()

if (info != null)
{
await UwcProvider.UpdateAsync(info, deckInput);
try { await UwcProvider.UpdateAsync(info, deckInput); }
catch (Exception ex)
{
this._logger.Error($"Failed to update UWC cards. Detailed information: {ex}");
throw;
}

cardInfo[card] = info;
foreach (var relatedCard in (info.RelatedCards ?? Enumerable.Empty<ScryfallCard.RelatedCard>())
Expand Down
3 changes: 2 additions & 1 deletion TabletopMtgImporter.Core/ScryfallClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ internal class ScryfallClient
DefaultRequestHeaders =
{
Accept = { new("application/json") },
UserAgent = { new("TabletopSimulatorMtgImporter", Assembly.GetEntryAssembly().GetName().Version.ToString()) }
// Assembly.GetEntryAssembly() can return null when running via tests
UserAgent = { new("TabletopSimulatorMtgImporter", Assembly.GetEntryAssembly()?.GetName().Version.ToString() ?? "1.0") }
}
};

Expand Down
11 changes: 11 additions & 0 deletions TabletopMtgImporter.Tests/EndToEndTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ public async Task TestSetNumbersWithDash()
mainDeck.ContainedObjects.Select(o => o.Nickname));
}

[Test]
public async Task TestMkmArtVariationCollectorNumber()
{
var cards = new[] { "1x Wojek Investigator (mkm) 36† [Draw]" };
var deck = await this.ImportDeckAsync(cards);
var mainDeck = deck.ObjectStates[0];
CollectionAssert.AreEquivalent(
new[] { "Wojek Investigator" },
mainDeck.ContainedObjects.Select(o => o.Nickname));
}

private Task<TabletopDeckObject> ImportDeckAsync(params string[] cards) => this.ImportDeckAsync(cards.AsEnumerable());

private async Task<TabletopDeckObject> ImportDeckAsync(IEnumerable<string> cards, bool require100Cards = false)
Expand Down
4 changes: 2 additions & 2 deletions TabletopMtgImporter.Wpf/TabletopMtgImporter.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<AssemblyName>TabletopMTGImporterGUI</AssemblyName>
<AssemblyVersion>0.8.2.0</AssemblyVersion>
<FileVersion>0.8.2.0</FileVersion>
<AssemblyVersion>0.8.3.0</AssemblyVersion>
<FileVersion>0.8.3.0</FileVersion>
<TargetFramework>net48</TargetFramework>
<UseWPF>true</UseWPF>
<LangVersion>8.0</LangVersion>
Expand Down

0 comments on commit 9efb7c3

Please sign in to comment.