Skip to content

Commit

Permalink
Merge pull request #2 from BigBang1112/dev
Browse files Browse the repository at this point in the history
Add platform skillpoints
  • Loading branch information
BigBang1112 authored Aug 24, 2024
2 parents 25fc60a + e36b1c8 commit c67d997
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/{map:nonfile?}/{zone?}"
@using System.Globalization
@rendermode InteractiveWebAssembly

@inject HttpClient Http
Expand Down Expand Up @@ -122,7 +123,7 @@
</MudStack>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="Platform (rank)">
<TemplateColumn Title="Platform (rank) (SP)">
<CellTemplate>
<MudStack AlignItems="AlignItems.Center" Row>
@switch (context.Item.Record.Platform)
Expand All @@ -143,7 +144,7 @@
</MudTooltip>
break;
}
<MudText Typo="Typo.body2">(@context.Item.Record.PlatformRank)</MudText>
<MudText Typo="Typo.body2">(@context.Item.Record.PlatformRank) (@context.Item.Record.GetSkillpoints(PlatformResponses[context.Item.Record.Platform.ToString()].Count.GetValueOrDefault()).ToString("n", thousands))</MudText>
</MudStack>
</CellTemplate>
</TemplateColumn>
Expand Down Expand Up @@ -254,6 +255,8 @@

private CancellationTokenSource? recordRequestTokenSource;

private NumberFormatInfo thousands = new() { NumberGroupSeparator = " ", NumberDecimalDigits = 0 };

private async Task<IEnumerable<string>> SearchZonesAsync(string value)
{
Zones ??= await Http.GetFromJsonAsync<Dictionary<string, Zone>>("api/v1/zones") ?? [];
Expand Down
5 changes: 5 additions & 0 deletions TMTurboRecords/TMTurboRecords.Shared/Models/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ namespace TMTurboRecords.Shared.Models;

public readonly record struct Record(int PlatformRank, TimeInt32? Time, int Count, Platform Platform) : IComparable<Record>
{
public int GetSkillpoints(int totalRecordCount)
{
return (totalRecordCount - (PlatformRank + Count - 1)) * 100 / (PlatformRank + Count - 1);
}

public int CompareTo(Record other)
{
if (Time == other.Time)
Expand Down

0 comments on commit c67d997

Please sign in to comment.