Skip to content

Commit

Permalink
Convert rival species, fixes #69
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Nov 26, 2024
1 parent 5b7f4cd commit e8102c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
<MudAutocomplete T="@ComboItem"
Label="Rival Starter"
Variant="@Variant.Outlined"
@bind-Value:get="@(AppService.GetSpeciesComboItem(sav1Rival.RivalStarter))"
@bind-Value:set="@(species => { sav1Rival.RivalStarter = (byte)species.Value; })"
@bind-Value:get="@GetGen1RivalStarter(sav1Rival)"
@bind-Value:set="@(species => SetGen1RivalStarter(sav1Rival, species))"
SearchFunc="@SearchPokemonNames"
ToStringFunc="@(species => species?.Text)" />
</div>
Expand Down
12 changes: 12 additions & 0 deletions Pkmds.Web/Components/MainTabPages/TrainerInfoTab.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,16 @@ private void UpdateHallOfFame()
return;
};
}

private ComboItem GetGen1RivalStarter(SAV1 sav1)
{
var nationalSpeciesId = SpeciesConverter.GetNational1(sav1.RivalStarter);
return AppService.GetSpeciesComboItem(nationalSpeciesId);
}

private void SetGen1RivalStarter(SAV1 sav1, ComboItem species)
{
var internalSpeciesId = SpeciesConverter.GetInternal1((byte)species.Value);
sav1.RivalStarter = internalSpeciesId;
}
}

0 comments on commit e8102c9

Please sign in to comment.