tooltip

package
v0.0.182 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEffectByIndex

func GetEffectByIndex(effects map[int]dbc.SpellEffect, index int) *dbc.SpellEffect

Types

type BoolChainTerm

type BoolChainTerm struct {
	Operator string           `parser:"@BOC"`
	Term     *BoolGeneralTerm `parser:"@@"`
}

For boolean chaining with & and |

type BoolCompareBranch

type BoolCompareBranch struct {
	Operator string             `parser:"@BOP"`
	Value    *BoolTerminalValue `parser:"@@"`
}

type BoolExpression

type BoolExpression struct {
	Left  *BoolGeneralTerm `parser:"@@"`
	Right []*BoolChainTerm `parser:"@@*"`
}

Root term for boolean expressions

func (BoolExpression) Eval

func (b BoolExpression) Eval(ctx *TooltipContext) bool

type BoolGeneralTerm

type BoolGeneralTerm struct {
	Left  *BoolTerminalValue   `parser:"@@"`
	Right []*BoolCompareBranch `parser:"@@*"`
}

func (BoolGeneralTerm) Eval

func (b BoolGeneralTerm) Eval(ctx *TooltipContext) bool

type BoolTerminalValue

type BoolTerminalValue struct {
	Negated        *string           `parser:"@NOT?"`
	SpellCondition *SpellCondition   `parser:"@SpellCond"`
	SpellRef       *SimpleSpellValue `parser:"|@@"`
	Number         *float64          `parser:"| @(Float|Int)"`
	Subexpression  *BoolExpression   `parser:"| '(' @@ ')'"`
}

func (BoolTerminalValue) Eval

func (BoolTerminalValue) EvalBool

func (b BoolTerminalValue) EvalBool(ctx *TooltipContext) bool

type ComplexValue

type ComplexValue struct {
	MathExpression     *MathExpression     `parser:"@@"`
	VariableAssignment *VariableAssignment `parser:"|@@"`
	Terniary           *Ternary            `parser:"|'$?'@@"`
	ShortTernary       *ShortTernary       `parser:"|@@"`
	ComputedValue      *ComputedValue      `parser:"|@@"`
	Word               *string             `parser:"|@(Ident|Int|Op|Float)"`
	Punctuation        *string             `parser:"|@Punct"`
	DescriptionRef     *DescriptionRef     `parser:"|DescLookup @@"`
	SpellNameRef       *SpellNameRef       `parser:"|'$@spellname'@@"`
	SpellIconRef       *SpellIconRef       `parser:"|'$@spellicon'@@"`
}

func (ComplexValue) String

func (c ComplexValue) String(ctx *TooltipContext) string

type ComputedValue

type ComputedValue struct {
	Negative      *NegativeComputedValue `parser:"@@"`
	SimpleCompute *SimpleCompute         `parser:"|@@"`
	VariableRef   *VariableRef           `parser:"|@@"`
	Function      *Function              `parser:"|@@"`
	SpellValue    *SimpleSpellValue      `parser:"|@@"`
}

func (ComputedValue) Eval

func (c ComputedValue) Eval(ctx *TooltipContext) float64

func (ComputedValue) String

func (c ComputedValue) String(ctx *TooltipContext) string

type DBCTooltipDataProvider

type DBCTooltipDataProvider struct {
	DBC *dbc.DBC
}

func (DBCTooltipDataProvider) GetAttackPower

func (d DBCTooltipDataProvider) GetAttackPower() float64

GetAttackPower implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetClass

func (d DBCTooltipDataProvider) GetClass(spellId int64) proto.Class

func (DBCTooltipDataProvider) GetDescriptionVariableString

func (d DBCTooltipDataProvider) GetDescriptionVariableString(spellId int64) string

GetDescriptionVariableString implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetEffectAmplitude

func (d DBCTooltipDataProvider) GetEffectAmplitude(spellId int64, effectIdx int64) float64

func (DBCTooltipDataProvider) GetEffectBaseValue

func (d DBCTooltipDataProvider) GetEffectBaseValue(spellId int64, effectIdx int64) float64

GetEffectBaseValue implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetEffectChainAmplitude

func (d DBCTooltipDataProvider) GetEffectChainAmplitude(spellId int64, effectIdx int64) float64

func (DBCTooltipDataProvider) GetEffectEnchantValue

func (d DBCTooltipDataProvider) GetEffectEnchantValue(enchantId int64, effectIdx int64) float64

func (DBCTooltipDataProvider) GetEffectMaxTargets

func (d DBCTooltipDataProvider) GetEffectMaxTargets(spellId int64, effectIdx int64) int64

GetEffectMaxTargets implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetEffectPeriod

func (d DBCTooltipDataProvider) GetEffectPeriod(spellId int64, effectIdx int64) time.Duration

GetEffectPeriod implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetEffectPointsPerResource

func (d DBCTooltipDataProvider) GetEffectPointsPerResource(spellId int64, effectIdx int64) float64

func (DBCTooltipDataProvider) GetEffectRadius

func (d DBCTooltipDataProvider) GetEffectRadius(spellId int64, effectIdx int64) float64

GetEffectRadius implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetEffectScaledValue

func (d DBCTooltipDataProvider) GetEffectScaledValue(spellId int64, effectIdx int64) float64

GetEffectBaseDamage implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetMainHandWeapon

func (d DBCTooltipDataProvider) GetMainHandWeapon() *core.Weapon

GetMainHandWeapon implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetOffHandWeapon

func (d DBCTooltipDataProvider) GetOffHandWeapon() *core.Weapon

GetOffHandWeapon implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetPlayerLevel

func (d DBCTooltipDataProvider) GetPlayerLevel() float64

func (DBCTooltipDataProvider) GetSpecNum

func (d DBCTooltipDataProvider) GetSpecNum() int64

func (DBCTooltipDataProvider) GetSpellDescription

func (d DBCTooltipDataProvider) GetSpellDescription(spellId int64) string

func (DBCTooltipDataProvider) GetSpellDuration

func (d DBCTooltipDataProvider) GetSpellDuration(spellId int64) time.Duration

GetSpellDuration implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetSpellIcon

func (d DBCTooltipDataProvider) GetSpellIcon(spellId int64) string

func (DBCTooltipDataProvider) GetSpellMaxTargets

func (d DBCTooltipDataProvider) GetSpellMaxTargets(spellId int64) int64

func (DBCTooltipDataProvider) GetSpellName

func (d DBCTooltipDataProvider) GetSpellName(spellId int64) string

func (DBCTooltipDataProvider) GetSpellPPM

func (d DBCTooltipDataProvider) GetSpellPPM(spellId int64) float64

GetSpellPPM implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetSpellPower

func (d DBCTooltipDataProvider) GetSpellPower() float64

GetSpellPower implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetSpellProcChance

func (d DBCTooltipDataProvider) GetSpellProcChance(spellId int64) float64

GetSpellProcChance implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetSpellProcCooldown

func (d DBCTooltipDataProvider) GetSpellProcCooldown(spellId int64) time.Duration

GetSpellProcCooldown implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetSpellRange

func (d DBCTooltipDataProvider) GetSpellRange(spellId int64) float64

GetSpellRange implements TooltipDataProvider.

func (DBCTooltipDataProvider) GetSpellStacks

func (d DBCTooltipDataProvider) GetSpellStacks(spellId int64) int64

GetStacks implements TooltipDataProvider.

func (DBCTooltipDataProvider) HasAura

func (d DBCTooltipDataProvider) HasAura(auraId int64) bool

HasAura implements TooltipDataProvider.

func (DBCTooltipDataProvider) HasPassive

func (d DBCTooltipDataProvider) HasPassive(auraId int64) bool

HasPassive implements TooltipDataProvider.

func (DBCTooltipDataProvider) IsMaleGender

func (d DBCTooltipDataProvider) IsMaleGender() bool

IsMaleGender implements TooltipDataProvider.

func (DBCTooltipDataProvider) KnowsSpell

func (d DBCTooltipDataProvider) KnowsSpell(spellId int64) bool

KnowsSpell implements TooltipDataProvider.

func (DBCTooltipDataProvider) ShouldUseBaseScaling

func (d DBCTooltipDataProvider) ShouldUseBaseScaling(spellId int64) bool

type DescriptionRef

type DescriptionRef struct {
	SpellId int64 `parser:"@Int"`
}

func (DescriptionRef) String

func (d DescriptionRef) String(ctx *TooltipContext) string

type EffectMap

type EffectMap map[int]dbc.SpellEffect

type Expression

type Expression struct {
	Left  *MathSimpleTerm `parser:"@@"`
	Right []*MathAddTerm  `parser:"@@*"`
}

func (*Expression) Eval

func (e *Expression) Eval(ctx *TooltipContext) float64

type Function

type Function struct {
	Name string        `parser:"'$'@VarName"`
	Args *[]Expression `parser:"'(' @@ (',' @@)* ')'"`
}

Tooltips support functions like clamp / min / max

func (*Function) Eval

func (f *Function) Eval(ctx *TooltipContext) float64

type MathAddTerm

type MathAddTerm struct {
	Operator MathOperator    `parser:"@('+' | '-')"`
	Term     *MathSimpleTerm `parser:"@@"`
}

type MathExpression

type MathExpression struct {
	Expression *Expression `parser:"'${'@@ ')'*'}'"`
	Round      *float64    `parser:"@Float?"`
}

func (MathExpression) Eval

func (m MathExpression) Eval(ctx *TooltipContext) float64

func (MathExpression) GetDecimalPlace

func (m MathExpression) GetDecimalPlace() int64

type MathFactorTerm

type MathFactorTerm struct {
	Base     *MathValue `parser:"@@"`
	Exponent *MathValue `parser:"( '^' @@ )?"`
}

func (*MathFactorTerm) Eval

func (f *MathFactorTerm) Eval(ctx *TooltipContext) float64

type MathMultTerm

type MathMultTerm struct {
	Operator MathOperator    `parser:"@('*' | '/')"`
	Factor   *MathFactorTerm `parser:"@@"`
}

type MathOperator

type MathOperator int
const (
	OpMul MathOperator = iota
	OpDiv
	OpAdd
	OpSub
)

func (*MathOperator) Capture

func (o *MathOperator) Capture(s []string) error

func (MathOperator) Eval

func (o MathOperator) Eval(l, r float64) float64

func (MathOperator) String

func (o MathOperator) String() string

type MathSimpleTerm

type MathSimpleTerm struct {
	Left  *MathFactorTerm `parser:"@@"`
	Right []*MathMultTerm `parser:"@@*"`
}

func (*MathSimpleTerm) Eval

func (t *MathSimpleTerm) Eval(ctx *TooltipContext) float64

type MathValue

type MathValue struct {
	Number        *float64       `parser:"  @('-'? (Float|Int))"`
	Variable      *string        `parser:"| @Ident"`
	ComputedValue *ComputedValue `parser:"| @@"`
	Subexpression *Expression    `parser:"| '(' @@ ')'"`
}

func (*MathValue) Eval

func (v *MathValue) Eval(ctx *TooltipContext) float64

type NegativeComputedValue

type NegativeComputedValue struct {
	Negative *string        `parser:"'-'"`
	Value    *ComputedValue `parser:"@@"`
}

type ShortTernary

type ShortTernary struct {
	Type  string `parser:"@ShortTern"`
	Right string `parser:"@Option';'"`
}

Short ternaryies like $lowner:owners are hard to lex vers $low= So some magic here..

$gmal:female $lsingular:plural <- seems to be based on last compuated element

func (ShortTernary) String

func (s ShortTernary) String(ctx *TooltipContext) string

type SimpleCompute

type SimpleCompute struct {
	Op    string            `parser:"'$'@('/' | '*')"`
	Num   int64             `parser:"@Int"`
	Value *SimpleSpellValue `parser:"';'@@"`
}

func (SimpleCompute) Eval

func (s SimpleCompute) Eval(ctx *TooltipContext) float64

func (SimpleCompute) String

func (s SimpleCompute) String(ctx *TooltipContext) string

type SimpleSpellValue

type SimpleSpellValue struct {
	SpellId  *int64        `parser:"'$'?@Int?"`
	Selector SpellEntryRef `parser:"@SpMod"`
}

Parses values that reference spell params like $m1 or $5565s1 If a spellID is given the lookup is performed on another spell's values

func (SimpleSpellValue) Eval

func (SimpleSpellValue) String

func (s SimpleSpellValue) String(ctx *TooltipContext) string

type SpellCondition

type SpellCondition struct {
	Op      string
	SpellId int64
}

**************************** BOOL HANDLING

Handles spell conditions Those are usually in the form of (a|p|s)SpellID a = HasAura p = HasPassive s = KnowsSpell

There exists one exception of such conditions that is (c)[1-4] c = Current specialization index. It can be 1 to 4, top to bottom in the talent window

func (*SpellCondition) Capture

func (s *SpellCondition) Capture(values []string) error

func (SpellCondition) EvalBool

func (s SpellCondition) EvalBool(ctx *TooltipContext) bool

type SpellEntryRef

type SpellEntryRef struct {
	EffectColumn string
	EffectIndex  int64
}

func (*SpellEntryRef) Capture

func (s *SpellEntryRef) Capture(values []string) error

Due to some complications the the lexing context and many inconsistencies on blizzards side We need to manually capture the effect column and index

type SpellIconRef

type SpellIconRef struct {
	SpellId int64 `parser:"@Int"`
}

func (SpellIconRef) String

func (s SpellIconRef) String(ctx *TooltipContext) string

type SpellNameRef

type SpellNameRef struct {
	SpellId int64 `parser:"@Int"`
}

func (SpellNameRef) String

func (s SpellNameRef) String(ctx *TooltipContext) string

type Ternary

type Ternary struct {
	BoolExpr    *BoolExpression   `parser:"@@"`
	FirstValue  *TooltipAST       `parser:"'['@@(']'|']?')"`
	SecondValue *TernaryRightSide `parser:"@@"`
}

func (Ternary) String

func (t Ternary) String(ctx *TooltipContext) string

type TernaryRightSide

type TernaryRightSide struct {
	SecondValue *TooltipAST `parser:"'['@@']'"`
	Chained     *Ternary    `parser:"|@@"`
}

type Tooltip

type Tooltip struct {
	Context *TooltipContext
	AST     *TooltipAST
}

func ParseTooltip

func ParseTooltip(tooltip string, dataProvider TooltipDataProvider, spellId int64) (*Tooltip, error)

func (Tooltip) String

func (t Tooltip) String() string

type TooltipAST

type TooltipAST struct {
	Values *[]ComplexValue `parser:"@@*"`
}

func (TooltipAST) String

func (t TooltipAST) String(ctx *TooltipContext) string

type TooltipContext

type TooltipContext struct {
	DataProvider TooltipDataProvider
	Variables    map[string]float64
	LastEval     float64
	SpellId      int64
}

type TooltipDataProvider

type TooltipDataProvider interface {
	GetAttackPower() float64
	GetDescriptionVariableString(spellId int64) string
	GetEffectAmplitude(spellId int64, effectIdx int64) float64
	GetEffectScaledValue(spellId int64, effectIdx int64) float64
	GetEffectBaseValue(spellId int64, effectIdx int64) float64 // basePoints + ?
	GetEffectChainAmplitude(spellId int64, effectidx int64) float64
	GetEffectMaxTargets(spellId int64, effectIdx int64) int64
	GetEffectPeriod(spellId int64, effectIdx int64) time.Duration
	GetEffectPointsPerResource(spellId int64, effectIdx int64) float64
	GetEffectRadius(spellId int64, effectIdx int64) float64
	GetEffectEnchantValue(enchantId int64, effectidx int64) float64
	GetMainHandWeapon() *core.Weapon
	GetOffHandWeapon() *core.Weapon
	GetPlayerLevel() float64
	GetSpecNum() int64 // The spec index for the class. Basically left to right in the talent window. i.E. Balance = 0, Guardian = 1, Feral = 2, Restoration = 4
	GetSpellDescription(spellId int64) string
	GetSpellDuration(spellId int64) time.Duration
	GetSpellIcon(spellId int64) string
	GetSpellMaxTargets(spellId int64) int64
	GetSpellName(spellid int64) string
	GetSpellPower() float64
	GetSpellPPM(spellId int64) float64
	GetSpellProcChance(spellId int64) float64
	GetSpellProcCooldown(spellId int64) time.Duration
	GetSpellRange(spellId int64) float64
	GetSpellStacks(spellId int64) int64 // Should return SpellAuraOptions ProcCharges or CumulativeAura
	HasAura(auraId int64) bool
	HasPassive(auraId int64) bool
	IsMaleGender() bool
	KnowsSpell(spellId int64) bool
}

type VariableAssignment

type VariableAssignment struct {
	VariableName string        `parser:"'$'@VarName'='"`
	Value        *ComplexValue `parser:"@@"`
}

type VariableRef

type VariableRef struct {
	DynamicVarName string `parser:"'$<'@VarRefName'>'"`
	StaticVarName  string `parser:"|'$'@VarName (?!'(')"`
}

External lookups and references Usually $<varname> variables are dynamically computed through SpellXSpellDescription references While $[a-zA-Z]{2,} variables are typically statically provided to the tooltip rendering context They reference character stats and static spell values like proc chance and RPPM

func (VariableRef) String

func (v VariableRef) String(ctx *TooltipContext) string

type Word

type Word struct {
	Word string `parser:"@Ident"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL