zzstat

package module
v0.0.0-...-a9e1e78 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PhaseAdditive       = 0
	PhaseMultiplicative = 1
	PhaseFinal          = 2
)

Phases and rules mapping

View Source
const (
	RuleOverride       = 0
	RuleAdditive       = 1
	RuleMultiplicative = 2
	RuleMin            = 3
	RuleMax            = 4
	RuleMinMax         = 5
)

Variables

This section is empty.

Functions

func EvaluateCombat

func EvaluateCombat(formulaJSON string, attacker *Resolver, attackerCtx *Context, defender *Resolver, defenderCtx *Context, rng func() float64) (float64, error)

func EvaluateCombatEx

func EvaluateCombatEx(formulaJSON string, attacker *Resolver, attackerCtx *Context, defender *Resolver, defenderCtx *Context, rng func() float64) (value float64, isHit bool, isCrit bool, err error)

EvaluateCombatEx evaluates a combat formula and also returns the "hit" and "crit" flags set by Flag nodes in the formula. rng supplies the random draws (0..1) the formula consumes, in evaluation order.

func LoadLibrary

func LoadLibrary(libPath string) error

LoadLibrary allows manually specifying the library path.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context wrapper

func NewContext

func NewContext() *Context

func (*Context) Free

func (c *Context) Free()

func (*Context) GetBool

func (c *Context) GetBool(key string, defaultVal bool) bool

func (*Context) GetFloat

func (c *Context) GetFloat(key string, defaultVal float64) float64

func (*Context) SetBool

func (c *Context) SetBool(key string, val bool)

func (*Context) SetFloat

func (c *Context) SetFloat(key string, val float64)

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver wrapper

func NewResolver

func NewResolver() *Resolver

func (*Resolver) Free

func (r *Resolver) Free()

func (*Resolver) Invalidate

func (r *Resolver) Invalidate(statID string)

func (*Resolver) InvalidateAll

func (r *Resolver) InvalidateAll()

func (*Resolver) RegisterAdditiveTransform

func (r *Resolver) RegisterAdditiveTransform(statID string, phase byte, rule byte, value float64)

func (*Resolver) RegisterClampTransform

func (r *Resolver) RegisterClampTransform(statID string, phase byte, rule byte, hasMin bool, minVal float64, hasMax bool, maxVal float64)

func (*Resolver) RegisterConditionalAdditiveTransform

func (r *Resolver) RegisterConditionalAdditiveTransform(
	statID string,
	phase byte,
	rule byte,
	condition func(ctx *Context) bool,
	bonus float64,
	description string,
)

func (*Resolver) RegisterConditionalMultiplicativeTransform

func (r *Resolver) RegisterConditionalMultiplicativeTransform(
	statID string,
	phase byte,
	rule byte,
	condition func(ctx *Context) bool,
	multiplier float64,
	description string,
)

func (*Resolver) RegisterConstantSource

func (r *Resolver) RegisterConstantSource(statID string, value float64)

func (*Resolver) RegisterMapSource

func (r *Resolver) RegisterMapSource(source map[string]float64)

func (*Resolver) RegisterMultiplicativeTransform

func (r *Resolver) RegisterMultiplicativeTransform(statID string, phase byte, rule byte, value float64)

func (*Resolver) RegisterScalingTransform

func (r *Resolver) RegisterScalingTransform(statID string, phase byte, rule byte, dependency string, scaleFactor float64)

func (*Resolver) Resolve

func (r *Resolver) Resolve(statID string, ctx *Context) (float64, error)

Jump to

Keyboard shortcuts

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