Skip to content

Commit

Permalink
general work done
Browse files Browse the repository at this point in the history
  • Loading branch information
GitPaulo committed Aug 10, 2024
1 parent 96abb11 commit c7c4418
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 456 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

TODO

## TODO

- [ ] Finish post processing quest data into the right format
- [ ] Correct checkbox system and progress bar updating
- [ ] Local storage current checkbox data
- [ ] Fancy loading bars magic effect!
- [ ] Quest id link to quest lodestone?
- [ ] Quest descriptions?
- [ ] Quest map viewer!
- [ ] Music?

## Notes

Similar python script:
Expand Down
41 changes: 34 additions & 7 deletions data/prepare_quest_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def convert_expansion_number_to_name(expansion_number):
image_path = data["results"][0]["fields"]["Icon"]["path_hr1"]

# To avoid hitting the API rate limit
time.sleep(0.777)
time.sleep(0.100)

# Create the quest entry
quest = {
Expand All @@ -107,7 +107,39 @@ def convert_expansion_number_to_name(expansion_number):
if previous_quest_number in quests_by_number:
quests_by_number[previous_quest_number]["NextMSQ"] = quest["#"]

# Organize the data into the desired structure
# Identify final quests
final_quests = set()
next_msq_values = set(quest["NextMSQ"] for quest in quests_by_number.values() if quest["NextMSQ"])

# Any quest without a NextMSQ and not in the set of `next_msq_values` is considered a final quest
for quest in quests_by_number.values():
if not quest["NextMSQ"] and quest["#"] not in next_msq_values:
final_quests.add(quest["#"])

# Remove quests that do not have a NextMSQ but are not final quests
quests_by_number = {
quest_id: quest for quest_id, quest in quests_by_number.items()
if quest["NextMSQ"] or quest["#"] in final_quests
}

print(f"After filtering, {len(quests_by_number)} quests remain.")

# Filter out duplicate quests with the same Name, NextMSQ, and StartingLocation
seen_quests = {}
filtered_quests_by_number = {}
for quest_id, quest in quests_by_number.items():
key = (quest["Name"], quest["NextMSQ"], quest["StartingLocation"])
if key not in seen_quests:
seen_quests[key] = quest_id
filtered_quests_by_number[quest_id] = quest

# Update quests_by_number to only include filtered quests
quests_by_number = filtered_quests_by_number

print(f"After removing duplicates, {len(quests_by_number)} quests remain.")


# Organize the data into the desired structure with correct MSQ order
quests_by_expansion = {}

for quest in quests_by_number.values():
Expand All @@ -122,11 +154,6 @@ def convert_expansion_number_to_name(expansion_number):

quests_by_expansion[expansion][starting_location].append(quest)

# Sort quests within each group by their "#"
for expansion in quests_by_expansion:
for location in quests_by_expansion[expansion]:
quests_by_expansion[expansion][location].sort(key=lambda x: x["#"])

# Save the structured data to a JSON file
output_json_path = 'static/Quests.json' # svelte app expects the file to be in the static folder
with open(output_json_path, 'w') as json_file:
Expand Down
3 changes: 2 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@

{#if loading}
<p class="text-center text-gray-600">Loading quests...</p>
<img src="loading.gif" alt="Loading" class="mx-auto mt-4" />
{:else if Object.keys(filteredQuests).length > 0}
{#each Object.keys(filteredQuests) as expansion}
<details class="mb-8" {...openExpansions[expansion] ? { open: true } : {}}>
Expand Down Expand Up @@ -282,7 +283,7 @@
<img
data-src={getImageUrl(quest.Image)}
alt="Quest Icon"
class="mt-4 w-16 h-16 rounded-md border border-gray-300 shadow-sm"
class="mt-4 w-44 h-16 rounded-md border border-gray-300 shadow-sm"
use:lazyLoadImage
/>
</div>
Expand Down
Loading

0 comments on commit c7c4418

Please sign in to comment.