-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3873 from wowsims/apl
Add PresetUtils file to reduce preset boilerplate
- Loading branch information
Showing
31 changed files
with
340 additions
and
705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
APLRotation, | ||
APLRotation_Type as APLRotationType, | ||
} from './proto/apl'; | ||
import { | ||
EquipmentSpec, | ||
Spec, | ||
} from './proto/common'; | ||
import { | ||
SavedRotation, | ||
} from './proto/ui'; | ||
|
||
import { Player } from './player'; | ||
import { | ||
SpecRotation, | ||
specTypeFunctions, | ||
} from './proto_utils/utils'; | ||
|
||
export interface PresetGear { | ||
name: string; | ||
gear: EquipmentSpec; | ||
tooltip?: string; | ||
enableWhen?: (obj: Player<any>) => boolean; | ||
} | ||
|
||
export interface PresetRotation { | ||
name: string; | ||
rotation: SavedRotation; | ||
tooltip?: string; | ||
enableWhen?: (obj: Player<any>) => boolean; | ||
} | ||
|
||
export interface PresetRotationOptions { | ||
talentTree?: number, | ||
} | ||
|
||
export function makePresetAPLRotation(name: string, rotationJson: any, options?: PresetRotationOptions): PresetRotation { | ||
const rotation = SavedRotation.create({ | ||
specRotationOptionsJson: '{}', | ||
rotation: APLRotation.fromJsonString(JSON.stringify(rotationJson)), | ||
}); | ||
return makePresetRotationHelper(name, rotation, options); | ||
} | ||
|
||
export function makePresetSimpleRotation<SpecType extends Spec>(name: string, spec: SpecType, simpleRotation: SpecRotation<SpecType>, options?: PresetRotationOptions): PresetRotation { | ||
const rotation = SavedRotation.create({ | ||
rotation: { | ||
type: APLRotationType.TypeSimple, | ||
simple: { | ||
specRotationJson: JSON.stringify(specTypeFunctions[spec].rotationToJson(simpleRotation)), | ||
}, | ||
}, | ||
}); | ||
return makePresetRotationHelper(name, rotation, options); | ||
} | ||
|
||
export function makePresetLegacyRotation<SpecType extends Spec>(name: string, spec: SpecType, simpleRotation: SpecRotation<SpecType>, options?: PresetRotationOptions): PresetRotation { | ||
const rotation = SavedRotation.create({ | ||
specRotationOptionsJson: JSON.stringify(specTypeFunctions[spec].rotationToJson(simpleRotation)), | ||
}); | ||
return makePresetRotationHelper(name, rotation, options); | ||
} | ||
|
||
function makePresetRotationHelper(name: string, rotation: SavedRotation, options?: PresetRotationOptions): PresetRotation { | ||
return { | ||
name: name, | ||
enableWhen: options?.talentTree == undefined ? undefined : (player: Player<any>) => player.getTalentTree() == options.talentTree, | ||
rotation: rotation, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.