Skip to content

Commit

Permalink
further refactor and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
GitPaulo committed Aug 11, 2024
1 parent 3e11cd7 commit 66de6a6
Show file tree
Hide file tree
Showing 8 changed files with 1,129 additions and 1,090 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# FFXIV-Journey
# FFXIV Journey

Track your main story quest journey with the utmost ease.
![Title](image.png)

Sveltekit static site for tracking FFXIV MSQ quest progress.

The goal is to provide a **simple but well designed** way to track your progress whilst being **self-updating from open source datamining** sources.

## TODO

Expand Down
7 changes: 4 additions & 3 deletions data/prepare_quest_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import requests
import time

from tqdm import tqdm
from io import StringIO

Expand Down Expand Up @@ -81,7 +82,7 @@ def convert_expansion_number_to_name(expansion_number):
"#": row["#"],
"Id": row["Id"],
"Name": row["Name"],
"Expansion": expansion_name,
"ExpansionName": expansion_name,
"EventIconType": row["EventIconType"],
"PreviousQuests": [row[col] for col in ["PreviousQuest[0]", "PreviousQuest[1]", "PreviousQuest[2]", "PreviousQuest[3]"] if not pd.isna(row[col])],
"NextMSQ": None, # Initialize as None, to be filled later
Expand Down Expand Up @@ -161,7 +162,7 @@ def convert_expansion_number_to_name(expansion_number):
quests_by_expansion = {}

for quest in quests_by_number.values():
expansion = quest["Expansion"]
expansion = quest["ExpansionName"]
starting_location = quest["StartingLocation"] if quest["StartingLocation"] else "Main Quest Line"

if expansion not in quests_by_expansion:
Expand All @@ -173,7 +174,7 @@ def convert_expansion_number_to_name(expansion_number):
quests_by_expansion[expansion][starting_location].append(quest)

# Extract A Realm Reborn quests
arr_quests = [quest for quest in quests_by_number.values() if quest["Expansion"] == "A Realm Reborn"]
arr_quests = [quest for quest in quests_by_number.values() if quest["ExpansionName"] == "A Realm Reborn"]

# Function to order quests based on the NextMSQ path, considering StartingLocation
def order_quests_by_next_msq(quests, location=None):
Expand Down
Binary file added image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/lib/index.ts

This file was deleted.

28 changes: 15 additions & 13 deletions src/lib/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
*/

export type Quest = {
"#": number; // Unique identifier for the quest
Id: string; // Quest identifier string
Name: string; // Name of the quest
Expansion: "A Realm Reborn" | "Heavensward" | "Stormblood" | "Shadowbringers" | "Endwalker" | "Dawntrail"; // Expansion name
EventIconType: number; // Event icon type, representing the type of quest (3 for MSQ)
PreviousQuests: number[]; // Array containing up to 4 previous quest IDs
NextMSQ: number | null; // ID of the next MSQ quest or null if none
StartingLocation: "Gridania" | "Limsa Lominsa" | "Ul'dah" | null; // Starting location or null if not applicable
Image: string | null; // Path to the quest image or null if not available
"#": number; // Unique identifier for the quest
Id: string; // Quest identifier string
Name: string; // Name of the quest
ExpansionName: string; // Expansion name
EventIconType: number; // Event icon type, representing the type of quest (3 for MSQ)
PreviousQuests: number[]; // Array containing up to 4 previous quest IDs
NextMSQ: number | null; // ID of the next MSQ quest or null if none
StartingLocation: string | null; // Starting location or null if not applicable
Image: string | null; // Path to the quest image or null if not available
};

export type Quests = {
[group: string]: Quest[];
};

export type Expansion = {
name: string;
quests: {
[location: string]: Quest[];
};
quests: Quests;
}

export type Quests = Array<Expansion>;
export type ExpansionsQuests = Array<Expansion>;

22 changes: 13 additions & 9 deletions src/lib/stores/questsStore.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { writable, get } from "svelte/store";
import type { Quests, Quest } from "$lib/model";
import type { ExpansionsQuests, Quest } from "$lib/model";

const LOCAL_STORAGE_KEY = "ffxiv-journey:completed";

// Types
export type ExpansionProgress = { percent: number; completed: number; total: number }

// Store for quests
export const quests = writable<Quests>([]);
export const filteredQuests = writable<Quests>([]);
export const quests = writable<ExpansionsQuests>([]);
export const filteredQuests = writable<ExpansionsQuests>([]);
export const completedQuests = writable<Record<number, boolean>>(
JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY) || "{}")
);
export const progress = writable<Record<string, { percent: number; completed: number; total: number }>>({});
export const progress = writable<Record<string, ExpansionProgress>>({});
export const loading = writable<boolean>(true);
export const currentExpansion = writable<string>("");

export function saveCompletedQuests() {
export function storeCompletedQuests() {
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(get(completedQuests)));
}

export function calculateProgress(expansionName: string) {
export function CalculateExpansionProgress(expansionName: string) {
const $quests = get(quests);
const expansion = $quests.find((exp) => exp.name === expansionName);
if (!expansion) return { percent: 0, completed: 0, total: 0 };
Expand All @@ -42,10 +45,10 @@ export function calculateProgress(expansionName: string) {

export function calculateAllProgress() {
const $quests = get(quests);
const newProgress: Record<string, { percent: number; completed: number; total: number }> = {};
const newProgress: Record<string, ExpansionProgress> = {};

for (const expansion of $quests) {
newProgress[expansion.name] = calculateProgress(expansion.name);
newProgress[expansion.name] = CalculateExpansionProgress(expansion.name);
}

progress.set(newProgress);
Expand Down Expand Up @@ -87,8 +90,9 @@ export function toggleQuestCompletion(quest: Quest, isChecked: boolean) {
});
}

saveCompletedQuests();
storeCompletedQuests();
calculateAllProgress();
updateCurrentExpansion();
}

export function updateCurrentExpansion() {
Expand Down
Loading

0 comments on commit 66de6a6

Please sign in to comment.