Documentation ¶
Overview ¶
Package d2calculation contains code for calculation nodes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryCalculation ¶
type BinaryCalculation struct { // Left is the left operand. Left Calculation // Right is the right operand. Right Calculation // Op is the actual operation. Op func(v1, v2 int) int }
BinaryCalculation is a calculation with a binary function or operator.
func (*BinaryCalculation) Eval ¶
func (node *BinaryCalculation) Eval() int
Eval evaluates the calculation.
func (*BinaryCalculation) String ¶
func (node *BinaryCalculation) String() string
type CalcString ¶
type CalcString string
CalcString is a type of string often used in datafiles to specify a value that is calculated dynamically based on the stats of the relevant source, for instance a missile might have a movement speed of lvl*2
type Calculation ¶
Calculation is the interface of every evaluatable calculation.
type ConstantCalculation ¶
type ConstantCalculation struct { // Value is the constant value. Value int }
ConstantCalculation is a constant value.
func (*ConstantCalculation) Eval ¶
func (node *ConstantCalculation) Eval() int
Eval evaluates the calculation.
func (*ConstantCalculation) String ¶
func (node *ConstantCalculation) String() string
type PropertyReferenceCalculation ¶
PropertyReferenceCalculation is the calculation representing a property.
func (*PropertyReferenceCalculation) Eval ¶
func (node *PropertyReferenceCalculation) Eval() int
Eval evaluates the calculation.
func (*PropertyReferenceCalculation) String ¶
func (node *PropertyReferenceCalculation) String() string
type TernaryCalculation ¶
type TernaryCalculation struct { // Left is the left operand. Left Calculation // Middle is the middle operand. Middle Calculation // Right is the right operand. Right Calculation Op func(v1, v2, v3 int) int }
TernaryCalculation is a calculation with a ternary function or operator.
func (*TernaryCalculation) Eval ¶
func (node *TernaryCalculation) Eval() int
Eval evaluates the calculation.
func (*TernaryCalculation) String ¶
func (node *TernaryCalculation) String() string
type UnaryCalculation ¶
type UnaryCalculation struct { // Child is the operand. Child Calculation // Op is the operation. Op func(v int) int }
UnaryCalculation is a calculation with a unary function or operator.
func (*UnaryCalculation) Eval ¶
func (node *UnaryCalculation) Eval() int
Eval evaluates the calculation.
func (*UnaryCalculation) String ¶
func (node *UnaryCalculation) String() string
Directories ¶
Path | Synopsis |
---|---|
Package d2lexer contains the code for tokenizing calculation strings.
|
Package d2lexer contains the code for tokenizing calculation strings. |
Package d2parser contains the code for parsing calculation strings.
|
Package d2parser contains the code for parsing calculation strings. |