quests need an id

This commit is contained in:
2025-06-18 19:35:11 +02:00
parent 9a2900c50e
commit d7728bd36b
+9 -1
View File
@@ -99,7 +99,7 @@ export async function loadAvailableQuests(): Promise<{ [key: string]: { [key: st
const questRankData = questsData.ranks[questRank];
for (const quest of questRankData) {
const id = quest.id;
const id = hash(JSON.stringify(quest));
const phases = [] as Array<QuestPhase>;
if (Array.isArray(quest?.phases)) {
@@ -171,3 +171,11 @@ export function removeAlreadyHiredAdventurers(
}
return adventurersForHire;
}
function hash(str: string): string {
let hash = 5381;
for (let i = 0; i < str.length; i++) {
hash = (hash * 33) ^ str.charCodeAt(i);
}
return (hash >>> 0).toString(16);
}