Clone the preset data prior to pushing into reward away - prevents preset being later modified

This commit is contained in:
Dev 2023-12-17 22:42:26 +00:00
parent 9e95e1bbac
commit 799690d2a6

View File

@ -916,7 +916,7 @@ export class RepeatableQuestGenerator
{ {
// Add a random default preset weapon as reward // Add a random default preset weapon as reward
const defaultPresets = Object.values(this.presetHelper.getDefaultPresets()); const defaultPresets = Object.values(this.presetHelper.getDefaultPresets());
const defaultPreset = this.randomUtil.getArrayValue(defaultPresets); const defaultPreset = this.jsonUtil.clone(this.randomUtil.getArrayValue(defaultPresets));
// use _encyclopedia as its always the base items _tpl, items[0] isnt guaranteed to be base item // use _encyclopedia as its always the base items _tpl, items[0] isnt guaranteed to be base item
rewards.Success.push(this.generateRewardItem(defaultPreset._encyclopedia, 1, rewardIndex, defaultPreset._items)); rewards.Success.push(this.generateRewardItem(defaultPreset._encyclopedia, 1, rewardIndex, defaultPreset._items));