MagicTheGathering/mtg-sdk-dotnet

Unable to use card service when the query contains vanguard cards.

Closed this issue · 1 comments

When a query to card service contains any vanguard cards it returns an unsuccessful result. Looks like to be related with the hand and life fields, which have a plus sign as prefix and are mapped as int in the DTO.

Here you have two examples to reproduce this issue:

var serviceProvider = new MtgServiceProvider();
var cardService = serviceProvider.GetCardService();

var result = await cardService.Where(x => x.Name, "archangel")
                              .AllAsync();
var serviceProvider = new MtgServiceProvider();
var cardService = serviceProvider.GetCardService();

var result = await cardService.FindAsync("045387f6-1865-5b75-92b4-af899fb089cf");

The latest one has this exception data:

Message:
MTG Api Error

{
   "card":{
      "name":"Maelstrom Archangel Avatar",
      "cmc":0.0,
      "type":"Vanguard",
      "types":[
         "Vanguard"
      ],
      "rarity":"Rare",
      "set":"PMOA",
      "setName":"Magic Online Avatars",
      "text":"At end of combat, for each creature you controlled at the time it dealt combat damage to a player this turn, copy a random card with the same mana cost as that creature. You may pay {3}. If you do, choose one of those copies. If a copy of a permanent card is chosen, you may create a token that's a copy of that card. If a copy of an instant or sorcery card is chosen, you may cast the copy without paying its mana cost.",
      "artist":"UDON",
      "number":"91",
      "layout":"vanguard",
      "multiverseid":"198628",
      "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=198628&type=card",
      "hand":"+0",
      "life":"+5",
      "printings":[
         "PMOA"
      ],
      "originalText":"At end of combat, for each creature you controlled at the time it dealt combat damage to a player this turn, copy a random card with the same mana cost as that creature. You may pay {3}. If you do, choose one of those copies. If a copy of a permanent card is chosen, you may put a token onto the battlefield that's a copy of that card. If a copy of an instant or sorcery card is chosen, you may cast the copy without paying its mana cost.",
      "originalType":"Vanguard",
      "id":"045387f6-1865-5b75-92b4-af899fb089cf"
   }
}
StackTrace:
   at MtgApiManager.Lib.Service.ServiceBase`1.<CallWebServiceGet>d__20`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at MtgApiManager.Lib.Service.CardService.<FindAsync>d__3.MoveNext()

Hello Korjam, thanks for letting me know. I took a look and can confirm that I'm seeing the exception as well. Will put up a fix