Skip to content

Commit

Permalink
Upgrade package, reimplement markings
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Jan 18, 2024
1 parent 0a78f65 commit 3c8bf62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Pkmds.Web/Extensions/PKMExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,25 @@ public static (byte Type1, byte Type2) GetGenerationTypes(this PKM pkm)

static byte ConvertGenerationType(byte type, int generation) => (byte)((MoveType)type).GetMoveTypeGeneration(generation);
}

public static int GetMarking(this PKM pokemon, int index)
{
if (pokemon is not IAppliedMarkings appliedMarkings)
{
throw new ArgumentException("Pokemon does not implement IAppliedMarkings", nameof(pokemon));
}

if ((uint)index >= appliedMarkings.MarkingCount)
{
throw new ArgumentOutOfRangeException(nameof(index));
}

return pokemon switch
{
IAppliedMarkings7 markings7 => (int)markings7.GetMarking(index),
IAppliedMarkings4 markings4 => markings4.GetMarking(index) ? 0 : 1,
IAppliedMarkings3 markings3 => markings3.GetMarking(index) ? 0 : 1,
_ => throw new ArgumentException("Pokemon does not implement IAppliedMarkings", nameof(pokemon)),
};
}
}
2 changes: 1 addition & 1 deletion Pkmds.Web/Pkmds.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" PrivateAssets="all" />
<PackageReference Include="MudBlazor" Version="6.12.0" />
<PackageReference Include="PKHeX.Core" Version="23.12.22" />
<PackageReference Include="PKHeX.Core" Version="24.1.12" />
<PackageReference Include="KristofferStrube.Blazor.FileSystemAccess" Version="3.2.2" />
</ItemGroup>

Expand Down

0 comments on commit 3c8bf62

Please sign in to comment.