Skip to content

Commit

Permalink
Added Shiny Hunt Phases page
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrDew committed Feb 9, 2024
1 parent 52cf6c8 commit c61782f
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 2 deletions.
23 changes: 23 additions & 0 deletions Pokedex/Pokedex/Controllers/ShinyHuntController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,28 @@ public IActionResult EditCompleteShinyHunt(EditShinyHuntViewModel shinyHunt)

return this.RedirectToAction("ShinyHunts", "User");
}

/// <summary>
/// Grabs all of the prior phases for a shiny hunt.
/// </summary>
/// <param name="shinyHuntId">The shiny hunt.</param>
/// <returns>The shiny hunt phases page.</returns>
[HttpGet]
[Route("shiny_hunt_phases/{shinyHuntId:int}")]
public IActionResult ShinyHuntPhases(int shinyHuntId)
{
List<ShinyHunt> shinyHunts = this.dataService.GetObjects<ShinyHunt>(includes: "Pokemon, Mark, Pokeball, Sweet, Game, HuntingMethod");

ShinyHuntsViewModel model = new ShinyHuntsViewModel()
{
AllShinyHunts = shinyHunts.Where(x => x.PhaseOfHuntId == shinyHuntId).ToList(),
ShinyHunt = shinyHunts.Find(x => x.Id == shinyHuntId),
IsShared = true,
AppConfig = this.appConfig,
};

this.dataService.AddPageView("Shiny Hunt Phases Page", this.User.IsInRole("Owner"));
return this.View("ShinyHuntPhases", model);
}
}
}
4 changes: 4 additions & 0 deletions Pokedex/Pokedex/Views/Shared/_FillCompletedShinyHunt.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
<div class="huntCapturedButtons">
<a class="btn orangeButton" href="@this.Url.Action("EditCompleteShinyHunt", "ShinyHunt", new { shinyHuntId = @Model.ShinyHunt.Id })" role="button">Modify Shiny</a>
<button class="btn btn-danger abandonHunt" onclick="abandonHunt(@Model.ShinyHunt.Id, '@Model.ShinyHunt.Pokemon.Name')">Delete Hunt</button>
@if (@Model.AllShinyHunts.Where(x => x.PhaseOfHuntId == Model.ShinyHunt.Id).Count() > 0)
{
<a class="btn btn-success phasesButton" href="@this.Url.Action("ShinyHuntPhases", "ShinyHunt", new { shinyHuntId = @Model.ShinyHunt.Id })" role="button">View Prior Phases</a>
}
</div>
}
</div>
111 changes: 111 additions & 0 deletions Pokedex/Pokedex/Views/ShinyHunt/ShinyHuntPhases.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
@model Pokedex.Models.ShinyHuntsViewModel;
@using System;
@{
ViewBag.Title = "Shiny Hunts";
ViewBag.Description = "Keep track of all of you current and successful shiny hunts!";
}

@section styles
{
<link href="~/css/shinyHunts.css" rel="stylesheet" asp-append-version="true" />
}

<h3>Phases for @Model.ShinyHunt.Pokemon.Name@(!string.IsNullOrEmpty(Model.ShinyHunt.Pokemon.Nickname) ? string.Concat("(", Model.ShinyHunt.Pokemon.Nickname, ")"))</h3>

<div class="grid-container">
@foreach (var shinyHunt in Model.AllShinyHunts)
{
<div class="Hunt@(shinyHunt.Id) HuntGame@(shinyHunt.GameId) shadowed @shinyHunt.Pokemon.Name">
<div class="pokemonDetails">
<div class="pokemonImages">
<div class="bonusImages">
@if (shinyHunt.HasShinyCharm)
{
<img loading="lazy" class="shinyCharm pokemonListPicture" title="Shiny Charm Used" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.GeneralImageUrl, "shinyCharm.png"))">
}
@if (shinyHunt.Mark != null)
{
<img loading="lazy" class="pokemonMark pokemonListPicture" title="@shinyHunt.Mark.Name Mark" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.OfficialMarkImageUrl, @shinyHunt.Mark.Id, ".png"))">
}
@if (shinyHunt.IsAlpha)
{
<img loading="lazy" class="pokemonAlpha pokemonListPicture" title="Alpha" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.OfficialMarkImageUrl, "alpha.png"))">
}
@if (shinyHunt.Pokeball != null)
{
<img loading="lazy" class="pokeball pokemonListPicture" title="@shinyHunt.Pokeball.Name" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.OfficialPokeballImageUrl, @shinyHunt.Pokeball.Id, ".png"))">
}
@if (shinyHunt.Gender == "Male" || shinyHunt.Gender == "Female")
{
<img loading="lazy" class="gender pokemonListPicture" title="@shinyHunt.Gender" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.GeneralImageUrl, @shinyHunt.Gender.ToLower(), ".png"))">
}
@if (shinyHunt.DirectHOMETransfer)
{
<img loading="lazy" class="directHOMETransfer pokemonListPicture" title="Transferred Directly Into Pokémon HOME" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.GeneralImageUrl, "directHOMETransfer.png"))">
}
@if (shinyHunt.Sweet != null)
{
<img loading="lazy" class="pokemonSweet pokemonListPicture" title="@shinyHunt.Sweet.Name Sweet" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.OfficialSweetImageUrl, @shinyHunt.Sweet.Id, ".png"))">
}
</div>
<a href="@this.Url.Action("PokemonWithOnlyId", "Home", new { pokemonId = @shinyHunt.Pokemon.Id, generationId = @shinyHunt.Game.GenerationId })" target="_blank">
@if (shinyHunt.Pokemon.HasGenderDifference)
{
<img loading="lazy" class="pokemonListPicture pokemonShinyHuntPokemon" title="Pokémon: @shinyHunt.Pokemon.Name@((shinyHunt.Nickname != null) ? string.Concat(" (", shinyHunt.Nickname, ")") : "")" alt="@shinyHunt.Pokemon.Name Shiny Image" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.GenderDifferenceShinyGridImageUrl, shinyHunt.Pokemon.Id, "-", shinyHunt.Gender.ToLower()[0], ".png"))" onerror = "this.src = '@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.ShinyGridImageUrl, shinyHunt.Pokemon.Id, ".png"))'; this.onerror = null;" />
}
else
{
<img loading="lazy" class="pokemonListPicture pokemonShinyHuntPokemon" title="Pokémon: @shinyHunt.Pokemon.Name@((shinyHunt.Nickname != null) ? string.Concat(" (", shinyHunt.Nickname, ")") : "")" alt="@shinyHunt.Pokemon.Name Shiny Image" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.ShinyGridImageUrl, shinyHunt.Pokemon.Id, ".png"))" onerror = "this.src = '@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.GridImageUrl, shinyHunt.Pokemon.Id, ".png"))'; this.onerror = null;" />
}
</a>
</div>
<div class="description">
<p>
<b>@shinyHunt.Pokemon.Name</b>
@if (shinyHunt.Nickname != null)
{
@string.Concat(" (", shinyHunt.Nickname, ")")
}
</p>
<p class="gameHuntedIn"><b>Game: </b>@shinyHunt.Game.Name</p>
<p><b>Hunting Method: </b>@shinyHunt.HuntingMethod.Name</p>
@if (@shinyHunt.TotalEncounters > 0)
{
@if (@shinyHunt.CurrentPhaseEncounters > 0 && @shinyHunt.CurrentPhaseEncounters != @shinyHunt.TotalEncounters)
{
if (@shinyHunt.HuntingMethodId == 4 || @shinyHunt.HuntingMethodId == 5)
{
<p><b>Last Phase Eggs: </b>@shinyHunt.CurrentPhaseEncounters</p>
}
else
{
<p><b>Last Phase Encounters: </b>@shinyHunt.CurrentPhaseEncounters</p>
}
}
if (@shinyHunt.HuntingMethodId == 4 || @shinyHunt.HuntingMethodId == 5 )
{
<p><b>Total Eggs: </b>@shinyHunt.TotalEncounters</p>
}
else
{
<p><b>Total Encounters: </b>@shinyHunt.TotalEncounters</p>
}
}
@if (@shinyHunt.Phases > 1)
{
<p><b>Total Phases: </b>@shinyHunt.Phases</p>
}
<p><b>Date of Capture: </b>@shinyHunt.DateOfCapture.ToString("MMMM d, yyyy")</p>
@if (@shinyHunt.SparklingPowerLevel > 0)
{
<p><b>Sparkling Power Level: </b>@shinyHunt.SparklingPowerLevel</p>
}
@if (@shinyHunt.PhaseOfHunt != null)
{
<p><b>Found While Hunting: </b>@shinyHunt.PhaseOfHunt.Pokemon.Name</p>
}
</div>
</div>
</div>
}
</div>
9 changes: 8 additions & 1 deletion Pokedex/Pokedex/Views/User/ShinyHunts.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@
}
</div>
<a href="@this.Url.Action("PokemonWithOnlyId", "Home", new { pokemonId = @s.Pokemon.Id, generationId = @s.Game.GenerationId })" target="_blank">
<img loading="lazy" class="pokemonListPicture pokemonShinyHuntPokemon" title="Pokémon: @s.Pokemon.Name@((s.Nickname != null) ? string.Concat(" (", s.Nickname, ")") : "")" alt="@s.Pokemon.Name Shiny Image" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.ShinyGridImageUrl, s.Pokemon.Id, ".png"))" />
@if (Model.IsShared)
{
<img loading="lazy" class="pokemonListPicture pokemonShinyHuntPokemon" title="Pokémon: @s.Pokemon.Name@((s.Nickname != null) ? string.Concat(" (", s.Nickname, ")") : "")" alt="@s.Pokemon.Name Shiny Image" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.ShinyPokemonImageUrl, s.Pokemon.Id, ".png"))" />
}
else
{
<img loading="lazy" class="pokemonListPicture pokemonShinyHuntPokemon" title="Pokémon: @s.Pokemon.Name@((s.Nickname != null) ? string.Concat(" (", s.Nickname, ")") : "")" alt="@s.Pokemon.Name Shiny Image" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.ShinyGridImageUrl, s.Pokemon.Id, ".png"))" />
}
</a>
</div>
<div class="description">
Expand Down
7 changes: 6 additions & 1 deletion Pokedex/Pokedex/wwwroot/css/shinyHunts.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@
.shinyFoundButtons a,
.huntUncapturedButtons a,
.huntUncapturedButtons button,
.huntCapturedButtons a,
.huntCapturedButtons a:not(.phasesButton),
.huntCapturedButtons button,
.encounterButtons button {
width: 49%;
}

.phasesButton {
margin-top: 5px;
width: 99%;
}

.shinyHuntButtons a {
margin-bottom: 5px;
}
Expand Down

0 comments on commit c61782f

Please sign in to comment.