-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start work on #67, move PokeRus logic to own component
- Loading branch information
1 parent
d9b4d95
commit 73306ad
Showing
3 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@if (Pokemon is { } pokemon) | ||
{ | ||
<MudCheckBox Label="Infected" | ||
@bind-Value:get="@pokemon.IsPokerusInfected" | ||
@bind-Value:set="@((bool infected) => SetPokerusInfected(infected))" | ||
For="@(() => pokemon.IsPokerusInfected)" /> | ||
|
||
<MudCheckBox Label="Cured" | ||
@bind-Value:get="@pokemon.IsPokerusCured" | ||
@bind-Value:set="@((bool cured) => SetPokerusCured(cured))" | ||
For="@(() => pokemon.IsPokerusCured)" /> | ||
|
||
@if (pokemon.IsPokerusInfected) | ||
{ | ||
<MudSelect Label="Strain" | ||
@bind-Value:get="@pokemon.PokerusStrain" | ||
@bind-Value:set="@((int strain) => SetPokerusStrain(strain))"> | ||
@for (var i = 0; i < 16; i++) | ||
{ | ||
<MudSelectItem Value="@i" | ||
@key="@i"> | ||
@i | ||
</MudSelectItem> | ||
} | ||
</MudSelect> | ||
|
||
@if (!pokemon.IsPokerusCured) | ||
{ | ||
<MudSelect Label="Days" | ||
@bind-Value:get="@pokemon.PokerusDays" | ||
@bind-Value:set="@((int days) => SetPokerusDays(days))"> | ||
@for (var i = 0; i < 3; i++) | ||
{ | ||
<MudSelectItem Value="@i" | ||
@key="@i"> | ||
@i | ||
</MudSelectItem> | ||
} | ||
</MudSelect> | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Pkmds.Web/Components/EditForms/Tabs/PokerusComponent.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace Pkmds.Web.Components.EditForms.Tabs; | ||
|
||
public partial class PokerusComponent | ||
{ | ||
[Parameter, EditorRequired] | ||
public PKM? Pokemon { get; set; } | ||
|
||
private void SetPokerusInfected(bool infected) | ||
{ | ||
if (Pokemon is null) | ||
{ | ||
return; | ||
} | ||
|
||
Pokemon.IsPokerusInfected = infected; | ||
} | ||
|
||
private void SetPokerusCured(bool cured) | ||
{ | ||
if (Pokemon is null) | ||
{ | ||
return; | ||
} | ||
|
||
Pokemon.IsPokerusCured = cured; | ||
} | ||
|
||
private void SetPokerusStrain(int strain) | ||
{ | ||
if (Pokemon is null) | ||
{ | ||
return; | ||
} | ||
Pokemon.PokerusStrain = strain; | ||
} | ||
|
||
private void SetPokerusDays(int days) | ||
{ | ||
if (Pokemon is null) | ||
{ | ||
return; | ||
} | ||
Pokemon.PokerusDays = days; | ||
} | ||
} | ||
|