mirror of
https://github.com/YouHaveTrouble/GuildMaster.git
synced 2026-05-12 06:26:59 +00:00
move quests to a single file
This commit is contained in:
+22
-17
@@ -68,26 +68,31 @@ export async function loadAvailableQuests(): Promise<{ [key: string]: { [key: st
|
||||
F: {} as { [key: string]: Quest },
|
||||
} as { [key: string]: { [key: string]: Quest } };
|
||||
|
||||
for (const rank in quests) {
|
||||
const response = await fetch(`data/quests/Rank${rank}.json`);
|
||||
if (response.status !== 200) {
|
||||
console.error("Failed to load quests");
|
||||
alert("Failed to load quests. Please try refreshing the page.");
|
||||
return quests;
|
||||
}
|
||||
const questData = await response.json();
|
||||
const questsResponse = await fetch(`data/quests.json`);
|
||||
|
||||
let id = 0;
|
||||
for (const quest of questData) {
|
||||
id++;
|
||||
quests[rank.toString()][id] = new Quest(
|
||||
id.toString(),
|
||||
getFromString(rank as QuestRank),
|
||||
if (questsResponse.status !== 200) {
|
||||
console.error("Failed to load quests");
|
||||
alert("Failed to load quests. Please try refreshing the page.");
|
||||
return quests;
|
||||
}
|
||||
|
||||
const questsData = await questsResponse.json();
|
||||
|
||||
for (const rank of Object.keys(questsData.ranks)) {
|
||||
const questRank = getFromString(rank as keyof typeof QuestRank);
|
||||
if (!questRank) {
|
||||
console.error(`Invalid quest rank: ${rank}`);
|
||||
continue;
|
||||
}
|
||||
const questRankData = questsData.ranks[questRank];
|
||||
|
||||
for (const quest of questRankData) {
|
||||
const id = quest.id;
|
||||
quests[questRank][id] = new Quest(
|
||||
id,
|
||||
questRank,
|
||||
quest.title,
|
||||
quest.text,
|
||||
1,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ export class Quest {
|
||||
rank: QuestRank,
|
||||
title: string,
|
||||
text: string,
|
||||
maxProgress: number,
|
||||
expReward: number,
|
||||
goldReward: number,
|
||||
maxProgress: number = 1,
|
||||
expReward: number = 0,
|
||||
goldReward: number = 0,
|
||||
maxAdventurers: number = 1
|
||||
) {
|
||||
this.id = id;
|
||||
|
||||
Reference in New Issue
Block a user