d2calculation

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

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

type Calculation interface {
	fmt.Stringer
	Eval() int
}

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

type PropertyReferenceCalculation struct {
	Type      string
	Name      string
	Qualifier string
}

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.

Jump to

Keyboard shortcuts

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