Skip to content

Commit

Permalink
give setting a proper default
Browse files Browse the repository at this point in the history
  • Loading branch information
lime-green committed Oct 20, 2023
1 parent 0921081 commit 90c9e8f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions proto/ui.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions ui/core/components/other_inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const nibelungAverageCasts = {
changedEvent: (player: Player<any>) => player.changeEmitter,
getValue: (player: Player<any>) => player.getNibelungAverageCasts(),
setValue: (eventID: EventID, player: Player<any>, newValue: number) => {
player.setNibelungAverageCastsSet(eventID, true);
player.setNibelungAverageCasts(eventID, newValue);
},
showWhen: (player: Player<any>) => [49992, 50648].includes(player.getEquippedItem(ItemSlot.ItemSlotMainHand)?.id || 0)
Expand Down
14 changes: 14 additions & 0 deletions ui/core/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export class Player<SpecType extends Spec> {
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;

Expand Down Expand Up @@ -941,10 +942,21 @@ export class Player<SpecType extends Spec> {
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);
}
Expand Down Expand Up @@ -1339,6 +1351,7 @@ export class Player<SpecType extends Spec> {
healingModel: this.getHealingModel(),
database: forExport ? SimDatabase.create() : this.toDatabase(),
nibelungAverageCasts: this.getNibelungAverageCasts(),
nibelungAverageCastsSet: this.nibelungAverageCastsSet,
}),
(aplIsLaunched || (forSimming && aplRotation.type == APLRotationType.TypeAPL))
? this.specTypeFunctions.rotationCreate()
Expand Down Expand Up @@ -1399,6 +1412,7 @@ export class Player<SpecType extends Spec> {
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));
Expand Down

0 comments on commit 90c9e8f

Please sign in to comment.