mirror of
https://github.com/YouHaveTrouble/GuildMaster.git
synced 2026-05-11 22:16:59 +00:00
fix creating missives
This commit is contained in:
+1
-1
@@ -200,7 +200,7 @@ export default defineComponent({
|
||||
return getQuestWithRewards(questsForRank[randomIdString], this.guild.expModifier.getModifier(), this.guild.goldModifier.getModifier());
|
||||
},
|
||||
createMissive(questToAdd: Quest) {
|
||||
const quest = JSON.parse(JSON.stringify(questToAdd));
|
||||
const quest = Quest.deserialize(questToAdd.serialize());
|
||||
quest.id = Math.random().toString(16).slice(2).toString();
|
||||
this.missives.push(quest);
|
||||
},
|
||||
|
||||
@@ -69,6 +69,38 @@ export class Quest {
|
||||
return progressPoints;
|
||||
}
|
||||
|
||||
serialize(): {[key: string]: any} {
|
||||
return {
|
||||
id: this.id,
|
||||
rank: this.rank,
|
||||
title: this.title,
|
||||
text: this.text,
|
||||
phases: this.phases.map(phase => phase.serialize()),
|
||||
expReward: this.expReward,
|
||||
goldReward: this.goldReward,
|
||||
maxAdventurers: this.maxAdventurers,
|
||||
};
|
||||
}
|
||||
|
||||
static deserialize(data: {[key: string]: any}): Quest {
|
||||
if (!data || typeof data !== 'object') {
|
||||
throw new Error("Invalid data for Quest deserialization");
|
||||
}
|
||||
|
||||
const phases = (data.phases || []).map((phaseData: any) => QuestPhase.deserialize(phaseData));
|
||||
|
||||
return new Quest(
|
||||
data.id,
|
||||
data.rank,
|
||||
data.title,
|
||||
data.text,
|
||||
phases,
|
||||
data.expReward || 0,
|
||||
data.goldReward || 0,
|
||||
data.maxAdventurers || 1
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user