Skip to content

Commit

Permalink
Razer Promotion and Show Unobtained Only setting (kevinclement#665)
Browse files Browse the repository at this point in the history
* Promotional stuff

* Show Unobtained Only setting
  • Loading branch information
SolestialDev authored Dec 10, 2024
1 parent dde278b commit 8c7f28f
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 44 deletions.
9 changes: 7 additions & 2 deletions src/api/_collectables.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getShowHiddenSetting } from "../util/utils"
import { getShowHiddenSetting, getShowUnobtainedSetting } from "../util/utils"

function getHigherQualityBattlePet(currentPet, newPet) {
function getPetsQuality(type) {
Expand Down Expand Up @@ -26,6 +26,7 @@ export async function parseCollectablesObject(categories, profile, collected_dat
var totalPossible = 0;

var showHiddenItems = getShowHiddenSetting();
var showUnobtainedOnly = getShowUnobtainedSetting();

// Build up lookup for items that character has
collected_data[collectedProperty].forEach((item) => {
Expand Down Expand Up @@ -147,6 +148,10 @@ export async function parseCollectablesObject(categories, profile, collected_dat
showthis = false;
}

if(hasthis && showUnobtainedOnly == "true") {
showthis = false;
}

if (item.allowableRaces && item.allowableRaces.length > 0)
{
var foundRace = false;
Expand Down Expand Up @@ -180,9 +185,9 @@ export async function parseCollectablesObject(categories, profile, collected_dat
if (hasthis) {
totalCollected++;
}

totalPossible++;
}

});

if (subCat.items.length > 0) {
Expand Down
17 changes: 13 additions & 4 deletions src/api/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getProfile } from '$api/profile'
import { getJsonDb } from '$api/_db'
import settings from '$util/settings'
import Cache from '$api/_cache'
import { getShowHiddenSetting, getShowHiddenFeatSetting } from '../util/utils'
import { getShowHiddenSetting, getShowHiddenFeatSetting, getShowUnobtainedSetting } from '../util/utils'

let _cache;
export async function getAchievements(region, realm, character) {
Expand Down Expand Up @@ -40,6 +40,7 @@ function parseAchievementObject(db, earned, character, faction) {
console.log(`Parsing achievements.json...`)
var showHiddenItems = getShowHiddenSetting();
var showHiddenFeats = getShowHiddenFeatSetting();
var showOnlyUnobtained = getShowUnobtainedSetting();

let obj = {}
, completed = {}
Expand Down Expand Up @@ -120,8 +121,10 @@ function parseAchievementObject(db, earned, character, faction) {

// Always add it if we've completed it, it should show up regardless if its available
if (myAchievement.completed) {
added = true;
mySubCat.achievements.push(myAchievement);
if(showOnlyUnobtained == "false") {
added = true;
mySubCat.achievements.push(myAchievement);
}

// if this is feats of strength then I want to keep a seperate count for that
// since its not a percentage thing
Expand Down Expand Up @@ -163,7 +166,13 @@ function parseAchievementObject(db, earned, character, faction) {
// if we haven't already added it, then this is one that should show up in the page of achievements
// so add it
if (!added) {
mySubCat.achievements.push(myAchievement);
if(showOnlyUnobtained == "true") {
if(!myAchievement.completed) {
mySubCat.achievements.push(myAchievement);
}
} else {
mySubCat.achievements.push(myAchievement);
}
}
}
})
Expand Down
7 changes: 6 additions & 1 deletion src/api/titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getData } from '$api/_blizzard'
import { getProfile } from '$api/profile'
import { getJsonDb } from '$api/_db'
import Cache from '$api/_cache'
import { getShowHiddenSetting } from '../util/utils'
import { getShowHiddenSetting, getShowUnobtainedSetting } from '../util/utils'

let _cache;
export async function getTitles(region, realm, character) {
Expand Down Expand Up @@ -45,6 +45,7 @@ function parseTitlesObject(db, profile, earned) {
var totalPossible = 0;

var showHiddenItems = getShowHiddenSetting();
var showUnobtainedOnly = getShowUnobtainedSetting();

// Build up lookup for titles that character has
earned.forEach((title) => {
Expand Down Expand Up @@ -80,6 +81,10 @@ function parseTitlesObject(db, profile, earned) {
showthis = false;
}

if(hasthis && showUnobtainedOnly == "true") {
showthis = false;
}

if (item.gender && item.gender !== profile.genderMapped) {
showthis = false;
}
Expand Down
13 changes: 13 additions & 0 deletions src/pages/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
localStorage.setItem('showHiddenFeat', $preferences.showHiddenFeat);
}
const toggleShowUnobtained = (e) => {
e.preventDefault();
$preferences.showUnobtainedOnly = $preferences.showUnobtainedOnly == "false" ? "true" : "false";
localStorage.setItem('showHiddenUpdated',Date.now());
localStorage.setItem('showUnobtainedOnly', $preferences.showUnobtainedOnly);
}
function setLocale(e, wowhead_url) {
e.preventDefault();
Expand Down Expand Up @@ -119,6 +127,11 @@
>{$preferences.showHiddenFeat === "hidden" ? "Show Obtainable Feat of Strengths" : "Hide Obtainable Feat of Strengths"}
</div>

<div>
<a href="#/" on:click={toggleShowUnobtained}
>{$preferences.showUnobtainedOnly === "false" ? "Show Only Unobtained" : "Show Obtained and Unobtained"}
</div>

<div>
Locale
<select
Expand Down
1 change: 1 addition & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
$preferences.itemSkin = localStorage.getItem('itemSkin') ?? 'new';
$preferences.showHidden = localStorage.getItem('showHidden') ?? "hidden";
$preferences.showHiddenFeat = localStorage.getItem('showHiddenFeat') ?? "hidden";
$preferences.showUnobtainedOnly = localStorage.getItem('showUnobtainedOnly') ?? "false";
})
function getCharInfoFromURL() {
Expand Down
4 changes: 4 additions & 0 deletions src/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export function getShowHiddenFeatSetting() {
return(localStorage.getItem("showHiddenFeat"));
}

export function getShowUnobtainedSetting() {
return(localStorage.getItem("showUnobtainedOnly"));
}

export function getShowHiddenUpdated() {
return(localStorage.getItem("showHiddenUpdated"));
}
Expand Down
16 changes: 7 additions & 9 deletions static/data/mounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@
"itemId": 211087,
"name": "Hateforged Blazecycle",
"spellid": 428067
},
{
"ID": 1579,
"icon": "inv_sharkraymount_4",
"itemId": 190539,
"name": "Coral-Stalker Waveray",
"spellid": 367620
}
],
"name": "Promotions"
Expand Down Expand Up @@ -9129,15 +9136,6 @@
"notReleased": true,
"spellid": 213349
},
{
"ID": 1579,
"icon": "inv_sharkraymount_4",
"itemId": 190539,
"name": "Coral-Stalker Waveray",
"notObtainable": true,
"notReleased": true,
"spellid": 367620
},
{
"ID": 2145,
"icon": "inv_goblinsurfboardmount_blue",
Expand Down
39 changes: 11 additions & 28 deletions static/data/pets.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,15 @@
"itemId": 228765,
"name": "Gummi",
"spellid": 463148
}
],
"name": "Trolli Promotion"
},
{
"items": [
},
{
"ID": 4595,
"creatureId": 225354,
"icon": "inv_pitlordpet_fire",
"itemId": 224576,
"name": "Lil' Flameo",
"spellid": 453266
}
],
"name": "SteelSeries Promotion"
},
{
"items": [
},
{
"ID": 4617,
"creatureId": 229890,
Expand All @@ -332,9 +322,17 @@
"itemId": 228793,
"name": "Chillbot 9000",
"spellid": 463251
},
{
"ID": 4690,
"creatureId": 233481,
"icon": "inv_babynaga2_purple",
"itemId": 232519,
"name": "Razeshi B.",
"spellid": 470914
}
],
"name": "Mountain Dew Promotion"
"name": "Promotions"
},
{
"items": [
Expand Down Expand Up @@ -12313,21 +12311,6 @@
}
],
"name": "BMAH"
},
{
"items": [
{
"ID": 4690,
"creatureId": 233481,
"icon": "inv_babynaga2_purple",
"itemId": 232519,
"name": "Razeshi B.",
"notObtainable": true,
"notReleased": true,
"spellid": 470914
}
],
"name": "Unknown"
}
]
}
Expand Down

0 comments on commit 8c7f28f

Please sign in to comment.