Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions Model/NaviDeckList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@
{
public class NaviDeckList
{
[JsonPropertyName("title")]
public required string Title { get; set; }
[JsonPropertyName("name")]
public required string Name { get; set; }

[JsonPropertyName("game_title_id")]
public required int GameId { get; set; }
[JsonPropertyName("deckCode")]
public required string DeckCode { get; set; }

[JsonPropertyName("deck_id")]
public required string DeckId { get; set; }

[JsonPropertyName("list")]
[JsonPropertyName("mainCards")]
public NaviCard[] MainDeck { get; set; }

Check warning on line 14 in Model/NaviDeckList.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'MainDeck' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("sub_list")]
[JsonPropertyName("evolveCards")]
public NaviCard[] EvolveDeck { get; set; }

Check warning on line 17 in Model/NaviDeckList.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'EvolveDeck' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("p_list")]
public NaviCard[] LeaderDeck { get; set; }
[JsonPropertyName("leaderCard")]
public NaviCard LeaderCard { get; set; }

Check warning on line 20 in Model/NaviDeckList.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LeaderCard' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}
}
24 changes: 11 additions & 13 deletions Services/DeckService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@ public class DeckService(IOptionsMonitor<CardListOptions> cardList, IHttpClientF

if (JsonSerializer.Deserialize(responseJson, typeof(NaviDeckList)) is NaviDeckList naviDeck)
{
if (naviDeck.GameId != ShadowverseEvolveGameId)
{
throw new ArgumentException("Deck retrieved was not a valid Shadowverse: Evolve deck.");
}
// They removed this field - what do we do here? - Matt J.
//if (naviDeck.GameId != ShadowverseEvolveGameId)
//{
// throw new ArgumentException("Deck retrieved was not a valid Shadowverse: Evolve deck.");
//}

Card leaderCard = null!;
List<Card> mainCardResults = [];
List<Card> evolveCardResults = [];
var cards = _monitor.CurrentValue.Cards;

foreach (var lc in naviDeck.LeaderDeck)
var matching = cards.Where(c => c.CardId.Equals(naviDeck.LeaderCard.CardNumber, StringComparison.InvariantCultureIgnoreCase));
if (matching.Any())
{
var matching = cards.Where(c => c.CardId.Equals(lc.CardNumber, StringComparison.InvariantCultureIgnoreCase));
if (matching.Any())
{
leaderCard = matching.First();
}
leaderCard = matching.First();
}

foreach (var mc in naviDeck.MainDeck)
Expand Down Expand Up @@ -70,7 +68,7 @@ public class DeckService(IOptionsMonitor<CardListOptions> cardList, IHttpClientF

return new DeckList
{
Name = naviDeck.Title,
Name = naviDeck.Name,
DeckCode = code,
LeaderCard = leaderCard,
MainCards = mainCardResults,
Expand Down Expand Up @@ -113,8 +111,8 @@ public class DeckService(IOptionsMonitor<CardListOptions> cardList, IHttpClientF
var distinctMain = list.MainCards.DistinctBy(card => card.CardId);
var textMain = distinctMain.Select(card =>
{
return new TextualCard
{
return new TextualCard
{
CardText = $"{card.Name} ({card.CardId}) x{list.MainCards.Count(c => c.CardId == card.CardId)}"
};
});
Expand Down
Loading