balance

package
v0.0.0-...-63dc931 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package balance implements parsing of Nox gamedata.bin files.

Index

Constants

View Source
const (
	TagSolo  = "SOLO"  // tag for solo games
	TagArena = "ARENA" // tag for multiplayer games
)
View Source
const (
	// GamedataFile is a default filename for Nox balance file.
	GamedataFile = "gamedata.bin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array []float64

Array value type.

type Config

type Config map[string]Value

Config represents a key-value map used in balance files.

type File

type File struct {
	// Global config values that does not depend on tags.
	Global Config
	// Tags contain config overrides for specific tag values.
	Tags map[Tag]Config
	// Parent is a reference to a parent config.
	// It can be used to overlay values from one config with the other one.
	Parent *File
}

File represents a parsed balance config file.

func ReadBalance

func ReadBalance(path string) (*File, error)

ReadBalance reads a specified balance file. It expects the path to point to gamedata.bin. It will also read gamedata.yml and will use it as an overlay for the base file (if any).

func (*File) Array

func (f *File) Array(tag Tag, k string) []float64

Array returns a float slice value for a given tag and key. If key is not set or has a different type, zero and false is returned.

For lookup rules, see Value.

func (*File) ArrayDef

func (f *File) ArrayDef(tag Tag, k string, def []float64) []float64

ArrayDef returns a float slice value for a given tag and key. If key is not set or has a different type, default value will be used.

For lookup rules, see Value.

func (*File) Float

func (f *File) Float(tag Tag, k string) (float64, bool)

Float returns a float value for a given tag and key. If key is not set or has a different type, zero and false is returned.

For lookup rules, see Value.

func (*File) FloatDef

func (f *File) FloatDef(tag Tag, k string, def float64) float64

FloatDef returns a float value for a given tag and key. If key is not set or has a different type, default value will be used.

For lookup rules, see Value.

func (*File) Value

func (f *File) Value(tag Tag, k string) Value

Value returns a value for a given tag and key.

Tagged values always take precedence, and if it's not set, a Global config will be used.

If current File contains no value for a given key, it will fallback to Parent.

type Float

type Float float64

Float value type.

type Tag

type Tag string

Tag marks the condition for using specific values. It usually switches values based on the game mode.

type Value

type Value interface {
	// contains filtered or unexported methods
}

Value is a union for value types allowed in Config.

Jump to

Keyboard shortcuts

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