Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give setting a proper default #3928

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 13 additions & 1 deletion 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,6 +942,13 @@ 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;
Expand Down Expand Up @@ -1339,6 +1347,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,7 +1408,10 @@ export class Player<SpecType extends Spec> {
this.setChannelClipDelay(eventID, proto.channelClipDelayMs);
this.setInFrontOfTarget(eventID, proto.inFrontOfTarget);
this.setDistanceFromTarget(eventID, proto.distanceFromTarget);
this.setNibelungAverageCasts(eventID, proto.nibelungAverageCasts);
this.setNibelungAverageCastsSet(eventID, proto.nibelungAverageCastsSet);
if (this.nibelungAverageCastsSet) {
this.setNibelungAverageCasts(eventID, proto.nibelungAverageCasts);
}
this.setHealingModel(eventID, proto.healingModel || HealingModel.create());
this.setSpecOptions(eventID, this.specTypeFunctions.optionsFromPlayer(proto));

Expand Down
Loading