diff --git a/proto/api.proto b/proto/api.proto index 2e25b41fb6..1be1bf8877 100644 --- a/proto/api.proto +++ b/proto/api.proto @@ -73,6 +73,8 @@ message Player { SimDatabase database = 35; double nibelung_average_casts = 43; + // hack to set a proper default value + bool nibelung_average_casts_set = 44; } message Party { diff --git a/proto/ui.proto b/proto/ui.proto index 8f97299c41..d636b6279e 100644 --- a/proto/ui.proto +++ b/proto/ui.proto @@ -300,6 +300,8 @@ message SavedSettings { double distance_from_target = 12; HealingModel healing_model = 13; double nibelung_average_casts = 15; + // hack to set a proper default value + bool nibelung_average_casts_set = 16; } message SavedTalents { diff --git a/ui/core/components/other_inputs.ts b/ui/core/components/other_inputs.ts index 4a7ef8687e..fcac703cd2 100644 --- a/ui/core/components/other_inputs.ts +++ b/ui/core/components/other_inputs.ts @@ -133,6 +133,7 @@ export const nibelungAverageCasts = { changedEvent: (player: Player) => player.changeEmitter, getValue: (player: Player) => player.getNibelungAverageCasts(), setValue: (eventID: EventID, player: Player, newValue: number) => { + player.setNibelungAverageCastsSet(eventID, true); player.setNibelungAverageCasts(eventID, newValue); }, showWhen: (player: Player) => [49992, 50648].includes(player.getEquippedItem(ItemSlot.ItemSlotMainHand)?.id || 0) diff --git a/ui/core/player.ts b/ui/core/player.ts index 9630b94820..fbfd40c894 100644 --- a/ui/core/player.ts +++ b/ui/core/player.ts @@ -237,6 +237,7 @@ export class Player { private inFrontOfTarget: boolean = false; private distanceFromTarget: number = 0; private nibelungAverageCasts: number = 11; + private nibelungAverageCastsSet: boolean = false; private healingModel: HealingModel = HealingModel.create(); private healingEnabled: boolean = false; @@ -941,10 +942,21 @@ export class Player { return this.nibelungAverageCasts; } + setNibelungAverageCastsSet(eventID: EventID, newnibelungAverageCastsSet: boolean) { + if (newnibelungAverageCastsSet == this.nibelungAverageCastsSet) + return; + + this.nibelungAverageCastsSet = newnibelungAverageCastsSet; + } + setNibelungAverageCasts(eventID: EventID, newnibelungAverageCasts: number) { if (newnibelungAverageCasts == this.nibelungAverageCasts) return; + // only set if nibelungAverageCastsSet is true (via UI). Allows us to give a default other than 0 + if (!this.nibelungAverageCastsSet) + return; + this.nibelungAverageCasts = Math.min(newnibelungAverageCasts, 16); this.miscOptionsChangeEmitter.emit(eventID); } @@ -1339,6 +1351,7 @@ export class Player { healingModel: this.getHealingModel(), database: forExport ? SimDatabase.create() : this.toDatabase(), nibelungAverageCasts: this.getNibelungAverageCasts(), + nibelungAverageCastsSet: this.nibelungAverageCastsSet, }), (aplIsLaunched || (forSimming && aplRotation.type == APLRotationType.TypeAPL)) ? this.specTypeFunctions.rotationCreate() @@ -1399,6 +1412,7 @@ export class Player { this.setChannelClipDelay(eventID, proto.channelClipDelayMs); this.setInFrontOfTarget(eventID, proto.inFrontOfTarget); this.setDistanceFromTarget(eventID, proto.distanceFromTarget); + this.setNibelungAverageCastsSet(eventID, proto.nibelungAverageCastsSet); this.setNibelungAverageCasts(eventID, proto.nibelungAverageCasts); this.setHealingModel(eventID, proto.healingModel || HealingModel.create()); this.setSpecOptions(eventID, this.specTypeFunctions.optionsFromPlayer(proto));