Documentation ¶
Overview ¶
Package csv provides csv-parser for game parameter names. The parser read csv file and store internal data.
Index ¶
- Constants
- func CloneInt64(data []int64) []int64
- func CloneStr(data []string) []string
- func FileExists(file string) bool
- func InRangeInt64(data []int64, index int) bool
- func InRangeStr(data []string, index int) bool
- func ReadFileFunc(file string, f func([]string) error) error
- func ReadFunc(r io.Reader, f func([]string) error) error
- type CharaInfo
- type Character
- type Config
- type Constant
- type CsvManager
- func (cm *CsvManager) BuildIntUserVars(where VarScope) map[string][]int64
- func (cm *CsvManager) BuildStrUserVars(where VarScope) map[string][]string
- func (csv *CsvManager) Const(vname string) (Constant, error)
- func (csv *CsvManager) Constants() map[string]Constant
- func (cm *CsvManager) Initialize(config Config) (err error)
- func (csv *CsvManager) MustConst(vname string) Constant
- func (csv *CsvManager) NameIndexOf(group, name string) int
- type GameBase
- type NameIndex
- type Names
- type NumberConstants
- type Parameter
- type VarScope
Constants ¶
const ( // BuiltinXXXName is builtin variable names which always exist in system. // User can modify its size only, and not use these names to user defined variable name. // // These names must exist in CsvManager, // but its size is unstable. BuiltinTrainName = "Train" // Scope CSV BuiltinSourceName = "Source" // Scope CSV BuiltinExName = "Ex" // Scope CSV BuiltinParamName = "Param" // Scope Chara BuiltinJuelName = "Juel" // Scope Chara BuiltinAblName = "Abl" // Scope Chara BuiltinTalentName = "Talent" // Scope Chara BuiltinMarkName = "Mark" // Scope Chara BuiltinExpName = "Exp" // Scope Chara BuiltinItemStockName = "ItemStock" // Scope System // it shares csv defined Item-Names with but separated as variable data. BuiltinItemName = "Item" // Scope System BuiltinItemPriceName = "ItemPrice" // Scope CSV )
const ( // System variables is system-wide global variables. ScopeSystem = VarScope(scopeSystem) ScopeShare = VarScope(scopeShare) // Chara variables is character specific variables. ScopeChara = VarScope(scopeChara) )
const ( // Configures of reading CSV files. // TODO: make it configurable? Separator = "," Comment = ";" )
const IndexNotFound int = -1
IndexNotFound is a value implying the index is not found.
Variables ¶
This section is empty.
Functions ¶
func CloneInt64 ¶
it returns new data conserving contents pf given data.
func FileExists ¶
check whether file exists. It wraps util.FileExists() so that user need not to import util package explicitly.
func InRangeInt64 ¶
check wheather index is in valid range?
func InRangeStr ¶
check wheather index is in valid range?
func ReadFileFunc ¶
ReadFileFunc reads csv file formatted by the era manner. Each records in the csv file processed by the user function. It returns error with at which line occurs.
Types ¶
type Constant ¶
Constant is a constant data set defined by a csv file. it contains constant key names Names, and indexes of key in Names, NameIndex.
type CsvManager ¶
type CsvManager struct { // the exceptional constants for reading csv file. Item Constant ItemPrices []int64 // default definition of the characters. // These are defined by "Chara/*.csv". // Each chara is identified by chara No. CharaMap map[int64]*Character // _GameBase.csv GameBase // _Replace.csv NumberConstants // contains filtered or unexported fields }
CSV Manager manages CSV variables.
To use this, first initialize.:
csv := &CsvManager{} err := csv.Initialize(Config{})
func NewCsvManager ¶
func NewCsvManager() *CsvManager
return empty CsvManager same as &CsvManager{} .
func (*CsvManager) BuildIntUserVars ¶
func (cm *CsvManager) BuildIntUserVars(where VarScope) map[string][]int64
return variable maps, which type are DataType int64 and scope where, where = {System, Share}. It allocates new valiables every call.
func (*CsvManager) BuildStrUserVars ¶
func (cm *CsvManager) BuildStrUserVars(where VarScope) map[string][]string
return variable maps, which type are DataType string and scope where, where = {System, Share}. It allocates new valiables every call.
func (*CsvManager) Const ¶
func (csv *CsvManager) Const(vname string) (Constant, error)
get a Constant by a variable name. return Constant and not found error.
func (*CsvManager) Constants ¶
func (csv *CsvManager) Constants() map[string]Constant
get constant variables map. modifying that map breaks constant.
func (*CsvManager) Initialize ¶
func (cm *CsvManager) Initialize(config Config) (err error)
initialize by reading csv files.
func (*CsvManager) MustConst ¶
func (csv *CsvManager) MustConst(vname string) Constant
get a Constant by a variable name. if vname is not found, it will panic.
func (*CsvManager) NameIndexOf ¶
func (csv *CsvManager) NameIndexOf(group, name string) int
get index using group name: BASE, ABL ... , and param name: 体力 ... , if not found returns -1
type GameBase ¶
type GameBase struct { Code string Version int32 Title string Author string Develop string AllowDiffVer bool AdditionalInfo string }
Base information for the Game
type NameIndex ¶
NameIndex holds indexes corresponding to each Name defined in CSV.
type NumberConstants ¶ added in v0.3.0
Number constants excepted from CSV names.