Skip to content

Commit

Permalink
Limited what actions done by SignalR happen to non shared shiny hunt …
Browse files Browse the repository at this point in the history
…pages
  • Loading branch information
TheMrDew committed Feb 27, 2024
1 parent cbb523c commit 8a10eba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Pokedex/Pokedex/Views/User/ShinyHunts.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
@section scripts
{
<script src="~/js/pageLookup.js" asp-append-version="true"></script>
<script src="~/js/shinyHunts.js" asp-append-version="true"></script>
<script src="~/js/shinyHunts.js" isShared="@Html.Raw(Model.IsShared)" asp-append-version="true"></script>
<script>
checkIfShared("@Html.Raw(Model.IsShared)")
$(document).on("keyup", function (e) {
if (!$(".incompletedHunts").hasClass("hide")) {
var key = e.which - 49;
Expand Down
37 changes: 22 additions & 15 deletions Pokedex/Pokedex/wwwroot/js/shinyHunts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var adjustIncrements = function (shinyHuntId) {
var isShared, adjustIncrements = function (shinyHuntId) {
var currentIncrements = $('.Hunt' + shinyHuntId + ' .increments').html();
var increments = prompt("Increment Amount", currentIncrements);
if ($.isNumeric(increments)) {
Expand Down Expand Up @@ -91,23 +91,25 @@ connection.start().catch(function (err) {
});

connection.on("SendHuntAttributes", function (shinyHuntId, encounters, phases, increments) {
if (encounters != -1) {
$('.Hunt' + shinyHuntId + ' .encounters').html(encounters);
}
if (isShared == "True") {
if (encounters != -1) {
$('.Hunt' + shinyHuntId + ' .encounters').html(encounters);
}

if (phases != -1) {
$('.Hunt' + shinyHuntId + ' .phases').html(phases);
if (phases == 1) {
$('.Hunt' + shinyHuntId + ' .currentEncounters b').html('Encounters: ')
$('.Hunt' + shinyHuntId + ' .phaseCounter').addClass('hide');
} else {
$('.Hunt' + shinyHuntId + ' .currentEncounters b').html('Current Phase Encounters: ')
$('.Hunt' + shinyHuntId + ' .phaseCounter').removeClass('hide');
if (phases != -1) {
$('.Hunt' + shinyHuntId + ' .phases').html(phases);
if (phases == 1) {
$('.Hunt' + shinyHuntId + ' .currentEncounters b').html('Encounters: ')
$('.Hunt' + shinyHuntId + ' .phaseCounter').addClass('hide');
} else {
$('.Hunt' + shinyHuntId + ' .currentEncounters b').html('Current Phase Encounters: ')
$('.Hunt' + shinyHuntId + ' .phaseCounter').removeClass('hide');
}
}
}

if (increments != -1) {
$('.Hunt' + shinyHuntId + ' .increments').html(increments);
if (increments != -1) {
$('.Hunt' + shinyHuntId + ' .increments').html(increments);
}
}
});

Expand Down Expand Up @@ -177,6 +179,10 @@ function lookupHuntsInGame(element, gameId) {
}
}

function checkIfShared(sharedBool) {
isShared = sharedBool;
}

function incrementEncounter(shinyHuntId) {
var currentEncounters = parseInt($('.Hunt' + shinyHuntId + ' .encounters').html());
var incrementAmount = parseInt($('.Hunt' + shinyHuntId + ' .increments').html());
Expand Down Expand Up @@ -392,6 +398,7 @@ function togglePin(shinyHuntId) {
data: { "shinyHuntId": shinyHuntId }
})
.done(function (data) {
updatePinStatus(shinyHuntId, !($('.Hunt' + shinyHuntId).hasClass("HuntGamePin")));
connection.invoke("UpdatePinStatus", parseInt(shinyHuntId), Boolean(data)).catch(function (err) {
return console.error(err.toString());
});
Expand Down

0 comments on commit 8a10eba

Please sign in to comment.