Skip to content

Commit

Permalink
Make Pokeballs optional for completed hunts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrDew committed Mar 8, 2025
1 parent f7abc1b commit 3f8a8e0
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 123 deletions.
13 changes: 7 additions & 6 deletions Pokedex/Pokedex/Controllers/ShinyHuntController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public IActionResult AddCompletedHunt(string numberOfHunts, AddCompletedShinyHun
AddCompletedShinyHuntViewModel model = new AddCompletedShinyHuntViewModel()
{
AllPokemon = pokemonList,
AllMarks = this.dataService.GetObjects<Mark>("Name"),
AllMarks = this.dataService.GetMarks(shinyHunt.GameId),
DateOfCapture = DateTime.Now.ToLocalTime().Date,
IncrementAmount = 1,
UserId = this.dataService.GetCurrentUser(this.User).Id,
Expand Down Expand Up @@ -307,7 +307,7 @@ public IActionResult ShinyFound(int shinyHuntId)
AllPokemon = pokemonList,
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllGenders = genders,
AllMarks = this.dataService.GetObjects<Mark>("Name"),
AllMarks = this.dataService.GetMarks(shinyHunt.GameId),
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: shinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
AppConfig = this.appConfig,
};
Expand Down Expand Up @@ -354,6 +354,7 @@ public IActionResult ShinyFound(CompleteShinyHuntViewModel shinyHunt)
[Route("found_phase_shiny/{shinyHuntId:int}")]
public IActionResult PhaseShinyFound(int shinyHuntId)
{
TimeZoneInfo localZone = TimeZoneInfo.Local;
ShinyHunt shinyHunt = this.dataService.GetObjectByPropertyValue<ShinyHunt>("Id", shinyHuntId, "Game");
List<Pokemon> pokemonList = this.dataService.GetHuntablePokemon(shinyHunt.GameId);
Pokemon pokemon;
Expand All @@ -378,7 +379,7 @@ public IActionResult PhaseShinyFound(int shinyHuntId)
AllPokemon = pokemonList,
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllGenders = genders,
AllMarks = this.dataService.GetObjects<Mark>("Name"),
AllMarks = this.dataService.GetMarks(shinyHunt.GameId),
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: shinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
AppConfig = this.appConfig,
};
Expand Down Expand Up @@ -436,7 +437,7 @@ public IActionResult EditIncompleteShinyHunt(int shinyHuntId)
{
AllPokemon = this.dataService.GetHuntablePokemon(),
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllMarks = this.dataService.GetObjects<Mark>("Name"),
AllMarks = this.dataService.GetMarks(shinyHunt.GameId),
AllGenders = genders,
AllGames = this.dataService.GetShinyHuntGames(shinyHunt.PokemonId),
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: shinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
Expand Down Expand Up @@ -522,7 +523,7 @@ public IActionResult EditCompleteShinyHunt(int shinyHuntId)
AllGames = gamesList,
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: shinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllMarks = this.dataService.GetObjects<Mark>("Name"),
AllMarks = this.dataService.GetMarks(shinyHunt.GameId),
AllSweets = this.dataService.GetObjects<Sweet>(),
AllGenders = this.dataService.GrabGenders(shinyHunt.PokemonId, "shinyHunt"),
AppConfig = this.appConfig,
Expand Down Expand Up @@ -554,7 +555,7 @@ public IActionResult EditCompleteShinyHunt(EditShinyHuntViewModel shinyHunt)
AllGames = gamesList,
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: oldShinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
AllPokeballs = this.dataService.GetPokeballs(oldShinyHunt.GameId, oldShinyHunt.HuntingMethodId, this.User, this.appConfig),
AllMarks = this.dataService.GetObjects<Mark>("Name"),
AllMarks = this.dataService.GetMarks(oldShinyHunt.GameId),
AllSweets = this.dataService.GetObjects<Sweet>(),
AllGenders = genders,
UserId = this.dataService.GetCurrentUser(this.User).Id,
Expand Down
14 changes: 13 additions & 1 deletion Pokedex/Pokedex/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,18 @@ public List<Pokemon> GetHuntablePokemon(int gameId = 0)
return pokemonList.OrderBy(x => x.PokedexNumber).ThenBy(x => x.Id).ToList();
}

/// <summary>
/// Gets a list of marks.
/// </summary>
/// <param name="gameId">The game's id. Defaults to 0.</param>
/// <returns>A list of marks.</returns>
public List<Mark> GetMarks(int gameId = 0)
{
List<Mark> marks = this.GetObjects<Mark>("Name");

return marks;
}

/// <summary>
/// Gets the list of games possible to shiny hunt in and formats it for the shiny hunt pages.
/// </summary>
Expand Down Expand Up @@ -1280,7 +1292,7 @@ public List<string> GrabGenders(int? pokemonId, string useCase)
}
else
{
genders.Add(string.Empty);
genders.Add("No Specific Gender");
genders.Add("Male");
genders.Add("Female");
}
Expand Down
2 changes: 1 addition & 1 deletion Pokedex/Pokedex/Pokedex.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="StyleCop.Analyzers" Version="*"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.1"/>
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0"/>
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.0"/>
<PackageReference Include="System.Linq.Dynamic.Core" Version="*"/>
<PackageReference Include="morelinq" Version="*"/>
<PackageReference Include="RobotsTxtCore" Version="2.2.0"/>
</ItemGroup>
Expand Down
68 changes: 34 additions & 34 deletions Pokedex/Pokedex/Views/ShinyHunt/AddCompletedHunt.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<div class="form-group row">
@Html.LabelFor(x => x.PokemonId, new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.PokemonId, new SelectList(Model.AllPokemon, "Id", "Name"), string.Empty, new { @class = "form-control col-md-6" })
@Html.DropDownListFor(x => x.PokemonId, new SelectList(Model.AllPokemon, "Id", "Name"), "Select Pokemon", new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.PokemonId)
</div>

Expand All @@ -42,6 +42,12 @@
@Html.DropDownListFor(x => x.GameId, Enumerable.Empty<SelectListItem>(), new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.GameId)
</div>

<div class="form-group row hide">
@Html.LabelFor(x => x.CurrentPhaseEncounters, new { @class = "col-md-4" })
@Html.EditorFor(x => x.CurrentPhaseEncounters, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6" } })
@Html.ValidationMessageFor(x => x.CurrentPhaseEncounters)
</div>

<div class="form-group row hide">
@Html.LabelFor(x => x.Nickname, "Nickname", new { @class = "col-md-4" })
Expand All @@ -50,21 +56,27 @@
</div>

<div class="form-group row hide">
@Html.LabelFor(x => x.PokeballId, "Pokeball", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.PokeballId, Enumerable.Empty<SelectListItem>(), new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.PokeballId)
@Html.LabelFor(x => x.DateOfCapture, "Date of Encounter", new { @class = "col-md-4" })
@Html.EditorFor(x => x.DateOfCapture, new { htmlAttributes = new { @class = "form-control col-md-6" } })
@Html.ValidationMessageFor(x => x.DateOfCapture)
</div>

<div class="form-group row hide">
@Html.LabelFor(x => x.HuntingMethodId, new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.HuntingMethodId, Enumerable.Empty<SelectListItem>(), new { @class = "form-control col-md-6" })
@Html.DropDownListFor(x => x.HuntingMethodId, Enumerable.Empty<SelectListItem>(), "Random Encounter", new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.HuntingMethodId)
</div>

<div class="form-group row hide">
@Html.LabelFor(x => x.DateOfCapture, "Date of Encounter", new { @class = "col-md-4" })
@Html.EditorFor(x => x.DateOfCapture, new { htmlAttributes = new { @class = "form-control col-md-6" } })
@Html.ValidationMessageFor(x => x.DateOfCapture)
@Html.LabelFor(x => x.PokeballId, "Pokeball", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.PokeballId, Enumerable.Empty<SelectListItem>(), "No Specified Pokeball", new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.PokeballId)
</div>

<div class="form-group row gameSpecific marks hide">
@Html.LabelFor(x => x.MarkId, "Mark", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.MarkId, Enumerable.Empty<SelectListItem>(), "No Mark", new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.MarkId)
</div>

<div class="form-group row hide">
Expand All @@ -78,35 +90,17 @@
@Html.DropDownListFor(x => x.SweetId, Enumerable.Empty<SelectListItem>(), new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.Sweet)
</div>

<div class="form-group row hide">
@Html.LabelFor(x => x.CurrentPhaseEncounters, new { @class = "col-md-4" })
@Html.EditorFor(x => x.CurrentPhaseEncounters, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6" } })
@Html.ValidationMessageFor(x => x.CurrentPhaseEncounters)
</div>

<div class="form-group row gameSpecific lureCheckbox hide">
@Html.LabelFor(x => x.UsingLures, new { @class = "col-md-4" })
@Html.EditorFor(x => x.UsingLures, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.UsingLures)
</div>

<div class="form-group row gameSpecific alphaCheckbox hide">
@Html.LabelFor(x => x.IsAlpha, "Found as Alpha", new { @class = "col-md-4" })
@Html.EditorFor(x => x.IsAlpha, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.IsAlpha)
</div>

<div class="form-group row gameSpecific sparklingPower hide">
@Html.LabelFor(x => x.SparklingPowerLevel, new { @class = "col-md-4" })
@Html.EditorFor(x => x.SparklingPowerLevel, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6", @min="0", @max="3", @value="0" } })
@Html.ValidationMessageFor(x => x.SparklingPowerLevel)
</div>

<div class="form-group row gameSpecific marks hide">
@Html.LabelFor(x => x.MarkId, "Mark", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.MarkId, Enumerable.Empty<SelectListItem>(), new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.MarkId)
<div class="form-group row gameSpecific shinyCharmCheckbox hide">
@Html.LabelFor(x => x.HasShinyCharm, new { @class = "col-md-4" })
@Html.EditorFor(x => x.HasShinyCharm, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.HasShinyCharm)
</div>

<div class="form-group row hide">
Expand All @@ -115,10 +109,16 @@
@Html.ValidationMessageFor(x => x.ExcludeFromShinyDex)
</div>

<div class="form-group row gameSpecific shinyCharmCheckbox hide">
@Html.LabelFor(x => x.HasShinyCharm, new { @class = "col-md-4" })
@Html.EditorFor(x => x.HasShinyCharm, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.HasShinyCharm)
<div class="form-group row gameSpecific lureCheckbox hide">
@Html.LabelFor(x => x.UsingLures, new { @class = "col-md-4" })
@Html.EditorFor(x => x.UsingLures, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.UsingLures)
</div>

<div class="form-group row gameSpecific alphaCheckbox hide">
@Html.LabelFor(x => x.IsAlpha, "Found as Alpha", new { @class = "col-md-4" })
@Html.EditorFor(x => x.IsAlpha, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.IsAlpha)
</div>

<p class="submitButtons">
Expand Down
52 changes: 26 additions & 26 deletions Pokedex/Pokedex/Views/ShinyHunt/EditCompleteShinyHunt.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@
@Html.ValidationMessageFor(x => x.PokemonId)
</div>

<div class="form-group row">
@Html.LabelFor(x => x.CurrentPhaseEncounters, "Phase Encounters", new { @class = "col-md-4" })
@Html.EditorFor(x => x.CurrentPhaseEncounters, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6", @min="0" } })
@Html.ValidationMessageFor(x => x.CurrentPhaseEncounters)
</div>

<div class="form-group row isCaptured@(Model.PhaseOfHuntId == null ? " hide" : "")">
@Html.LabelFor(x => x.IsCaptured, "Phase Shiny Captured", new { @class = "col-md-4" })
@Html.EditorFor(x => x.IsCaptured, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6" }})
@Html.ValidationMessageFor(x => x.IsCaptured)
</div>

<div class="form-group row">
@Html.LabelFor(x => x.GameId, "Game", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.GameId, new SelectList(Model.AllGames, "Id", "Name"), new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.GameId)
</div>

<div class="form-group row">
@Html.LabelFor(x => x.CurrentPhaseEncounters, "Phase Encounters", new { @class = "col-md-4" })
@Html.EditorFor(x => x.CurrentPhaseEncounters, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6", @min="0" } })
@Html.ValidationMessageFor(x => x.CurrentPhaseEncounters)
</div>

<div class="form-group row captureRequired">
@Html.LabelFor(x => x.Nickname, "Nickname", new { @class = "col-md-4" })
Expand All @@ -77,13 +71,13 @@

<div class="form-group row captureRequired">
@Html.LabelFor(x => x.PokeballId, "Pokeball", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.PokeballId, new SelectList(Model.AllPokeballs, "Id", "Name"), string.Empty, new { @class = "form-control col-md-6" })
@Html.DropDownListFor(x => x.PokeballId, new SelectList(Model.AllPokeballs, "Id", "Name"), "No Specific Pokeball", new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.PokeballId)
</div>

<div class="form-group row gameSpecific captureRequired marks hide">
@Html.LabelFor(x => x.MarkId, "Mark", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.MarkId, new SelectList(Model.AllMarks, "Id", "Name"), string.Empty, new { @class = "form-control col-md-6" })
@Html.DropDownListFor(x => x.MarkId, new SelectList(Model.AllMarks, "Id", "Name"), "No Mark", new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.MarkId)
</div>

Expand All @@ -99,12 +93,30 @@
@Html.ValidationMessageFor(x => x.SweetId)
</div>

<div class="form-group row gameSpecific sparklingPower hide">
@Html.LabelFor(x => x.SparklingPowerLevel, "Sparkling Sandwich Power Level", new { @class = "col-md-4" })
@Html.EditorFor(x => x.SparklingPowerLevel, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6", @min="0", @max="3", @value="0" } })
@Html.ValidationMessageFor(x => x.SparklingPowerLevel)
</div>

<div class="form-group row isCaptured@(Model.PhaseOfHuntId == null ? " hide" : "")">
@Html.LabelFor(x => x.IsCaptured, "Phase Shiny Captured", new { @class = "col-md-4" })
@Html.EditorFor(x => x.IsCaptured, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.IsCaptured)
</div>

<div class="form-group row">
@Html.LabelFor(x => x.ExcludeFromShinyDex, new { @class = "col-md-4" })
@Html.EditorFor(x => x.ExcludeFromShinyDex, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.ExcludeFromShinyDex)
</div>

<div class="form-group row gameSpecific shinyCharmCheckbox hide">
@Html.LabelFor(x => x.HasShinyCharm, "Have the Shiny Charm", new { @class = "col-md-4" })
@Html.EditorFor(x => x.HasShinyCharm, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.HasShinyCharm)
</div>

<div class="form-group row gameSpecific lureCheckbox hide">
@Html.LabelFor(x => x.UsingLures, new { @class = "col-md-4" })
@Html.EditorFor(x => x.UsingLures, new { @class = "form-control col-md-6" })
Expand All @@ -117,18 +129,6 @@
@Html.ValidationMessageFor(x => x.IsAlpha)
</div>

<div class="form-group row gameSpecific sparklingPower hide">
@Html.LabelFor(x => x.SparklingPowerLevel, "Sparkling Sandwich Power Level", new { @class = "col-md-4" })
@Html.EditorFor(x => x.SparklingPowerLevel, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6", @min="0", @max="3", @value="0" } })
@Html.ValidationMessageFor(x => x.SparklingPowerLevel)
</div>

<div class="form-group row gameSpecific shinyCharmCheckbox hide">
@Html.LabelFor(x => x.HasShinyCharm, "Have the Shiny Charm", new { @class = "col-md-4" })
@Html.EditorFor(x => x.HasShinyCharm, new { @class = "form-control col-md-6" })
@Html.ValidationMessageFor(x => x.HasShinyCharm)
</div>

<p>
<button type="submit" class="btn btn-primary" role="button">Save Changes</button>
</p>
Expand Down
Loading

0 comments on commit 3f8a8e0

Please sign in to comment.