datasheet

package
v0.0.0-...-5107381 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package datasheet provides a way to get additional context when processing network data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses the CSV-encoded datasheet and stores the result in the slice of structs pointed to by v. It works very similarly to to json.Unmarshal.

If v is nil or not a pointer to a slice of structs, Unmarshal returns an InvalidUnmarshalError. If the data is invalid CSV data, it returns a error from ParseRawCSV. If Unmarshal is unable to assign to a field of v the data, it returns an UnmarshalTypeError.

func UnmarshalReader

func UnmarshalReader(dataReader io.Reader, v interface{}) error

UnmarshalReader is a convenience wrapper around reading bytes from an io.Reader and storing the parsed data into the slice of structs pointed to by v.

Types

type Action

type Action struct {
	Key           uint32 `datasheet:"key"`
	Name          string `datasheet:"Name"`
	Range         int8   `datasheet:"Range"`
	TargetArea    bool   `datasheet:"TargetArea"`
	CastType      byte   `datasheet:"CastType"`
	EffectRange   byte   `datasheet:"EffectRange"`
	XAxisModifier byte   `datasheet:"XAxisModifier"`
	OmenID        uint16 `datasheet:"Omen"`
	Omen          string
}

Action stores the data for a game Action

type ActionStore

type ActionStore struct {
	Actions      map[uint32]Action
	Omens        map[uint16]Omen
	CraftActions map[uint32]CraftAction
}

ActionStore stores all of the Action data. Note that querying actions directly on the map will result in an empty Omen field. You should use GetAction in order to have an action with a correctly populated field.

func (*ActionStore) GetAction

func (a *ActionStore) GetAction(key uint32) Action

GetAction returns the Action associated with the action key. It will also populate the Omen field on the action. If the action is not found in the standard Action store, it will attempt to return an action from the CraftAction store.

func (*ActionStore) PopulateActions

func (a *ActionStore) PopulateActions(dataReader io.Reader) error

PopulateActions will populate the ActionStore with Action data provided a path to the data sheet for Actions.

func (*ActionStore) PopulateCraftActions

func (a *ActionStore) PopulateCraftActions(dataReader io.Reader) error

PopulateCraftActions will populate the ActionStore with CraftAction data provided a path to the data sheet for CraftActions

func (*ActionStore) PopulateOmens

func (a *ActionStore) PopulateOmens(dataReader io.Reader) error

PopulateOmens will populate the ActionStore with Omen data provided a path to the data sheet for Omens

type BNPCBase

type BNPCBase struct {
	Key   uint32  `datasheet:"key"`
	Scale float32 `datasheet:"Scale"`
}

BNPCBase stores information about the scale of the monster

type BNPCInfo

type BNPCInfo struct {
	Name  string
	Size  float32
	Error byte
}

BNPCInfo stores information about a game monster

type BNPCName

type BNPCName struct {
	Key  uint32 `datasheet:"key"`
	Name string `datasheet:"Singular"`
}

BNPCName stores information about the name of the NPC

type BNPCStore

type BNPCStore struct {
	BNPCNames      map[uint32]BNPCName
	BNPCBases      map[uint32]BNPCBase
	ModelCharas    map[uint32]ModelChara
	ModelSkeletons map[uint32]ModelSkeleton
}

BNPCStore stores information about all monsters

func (*BNPCStore) GetBNPCInfo

func (b *BNPCStore) GetBNPCInfo(bNPCNameID, bNPCBaseID, modelCharaID uint32) *BNPCInfo

GetBNPCInfo returns a BNPCInfo object matching the provided parameters If the entry is not found, it returns nil

func (*BNPCStore) PopulateBNPCBases

func (b *BNPCStore) PopulateBNPCBases(dataReader io.Reader) error

PopulateBNPCBases will populate the BNPCStore with BNPC data provided a path to the data sheet for BNPCBases

func (*BNPCStore) PopulateBNPCNames

func (b *BNPCStore) PopulateBNPCNames(dataReader io.Reader) error

PopulateBNPCNames will populate the BNPCStore with BNPC data provided a path to the data sheet for BNPCNames

func (*BNPCStore) PopulateModelCharas

func (b *BNPCStore) PopulateModelCharas(dataReader io.Reader) error

PopulateModelCharas will populate the BNPCStore with BNPC data provided a path to the data sheet for ModelCharas

func (*BNPCStore) PopulateModelSkeletons

func (b *BNPCStore) PopulateModelSkeletons(dataReader io.Reader) error

PopulateModelSkeletons will populate the BNPCStore with BNPC data provided a path to the data sheet for ModelSkeletons

type ClassJob

type ClassJob struct {
	Key          byte   `datasheet:"key"`
	Name         string `datasheet:"Name"`
	Abbreviation string `datasheet:"Abbreviation"`
}

ClassJob stores the data for a game ClassJob

type ClassJobStore

type ClassJobStore map[byte]ClassJob

ClassJobStore stores all of the ClassJob data.

func (*ClassJobStore) PopulateClassJobs

func (c *ClassJobStore) PopulateClassJobs(dataReader io.Reader) error

PopulateClassJobs will populate the ClassJobStore with ClassJob data provided a path to the data sheet for ClassJobs.

type Collection

type Collection struct {
	MapData      MapStore
	BNPCData     BNPCStore
	ActionData   ActionStore
	StatusData   StatusStore
	ClassJobData ClassJobStore
	RecipeData   RecipeStore
	WorldData    WorldStore
}

Collection encapsulates a collection of datasheets

func (*Collection) Populate

func (c *Collection) Populate(dataPath string) error

type CraftAction

type CraftAction struct {
	Key  uint32 `datasheet:"key"`
	Name string `datasheet:"Name"`
}

CraftAction stores the data for a game crafting Action

type DataEntry

type DataEntry map[string]string

DataEntry is an internal structure for holding a single CSV record

type Datasheet

type Datasheet []DataEntry

Datasheet is an internal structure for holding a set of CSV records

func ParseRawCSV

func ParseRawCSV(dataReader io.Reader) (Datasheet, error)

ParseRawCSV returns a raw Datasheet that represents the CSV data after parsing the table headers.

type FileReader

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

FileReader handles reading files and errors if they don't exist

func (*FileReader) Error

func (f *FileReader) Error() error

func (*FileReader) ReadFile

func (f *FileReader) ReadFile(fileName string, cb fileReaderCallback)

ReadFile reads the file provided and calls the callback function with the io.Reader. It won't do anything if a previous ReadFile has encountered an error.

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

InvalidUnmarshalError describes an error returned when an invalid argument is passed to Unmarshal

func (*InvalidUnmarshalError) Error

func (e *InvalidUnmarshalError) Error() string

Error returns a formatted error message for the InvalidUnmarshalError

type Item

type Item struct {
	Key  uint32 `datasheet:"key"`
	Name string `datasheet:"Name"`
}

Item maps the ID of the item with the name

type MapInfo

type MapInfo struct {
	Key           uint16 `datasheet:"key"`
	ID            string `datasheet:"Id"`
	SizeFactor    uint16 `datasheet:"SizeFactor"`
	OffsetX       int16  `datasheet:"Offset{X}"`
	OffsetY       int16  `datasheet:"Offset{Y}"`
	PlaceName     uint16 `datasheet:"PlaceName"`
	PlaceNameSub  uint16 `datasheet:"PlaceName{Sub}"`
	TerritoryType uint16 `datasheet:"TerritoryType"`
}

MapInfo stores the information for a game Map

type MapStore

type MapStore struct {
	Maps        map[uint16]MapInfo
	Territories map[uint16]TerritoryInfo
	PlaceNames  map[uint16]PlaceName
	// contains filtered or unexported fields
}

MapStore stores information about all maps and territories

func (*MapStore) GetMap

func (m *MapStore) GetMap(key uint16) models.MapInfo

GetMap returns the models.MapInfo associated with the Map key. It returns an empty models.MapInfo if no entry is found.

func (*MapStore) GetMaps

func (m *MapStore) GetMaps(territoryID uint16) []models.MapInfo

GetMaps returns all Maps associated with the territory ID. If no entry is found, it returns nil

func (*MapStore) PopulateMaps

func (m *MapStore) PopulateMaps(dataReader io.Reader) error

PopulateMaps will populate the MapStore with map data provided a path to the data sheet for Maps

func (*MapStore) PopulatePlaceNames

func (m *MapStore) PopulatePlaceNames(dataReader io.Reader) error

PopulatePlaceNames will populate the MapStore with place name data provided a path to the data sheet for PlaceNames

func (*MapStore) PopulateTerritories

func (m *MapStore) PopulateTerritories(dataReader io.Reader) error

PopulateTerritories will populate the MapStore with territory data provided a path to the data sheet

type ModelChara

type ModelChara struct {
	Key   uint32 `datasheet:"key"`
	Model uint32 `datasheet:"Model"`
}

ModelChara stores information about the models used for the character

type ModelSkeleton

type ModelSkeleton struct {
	Key    uint32  `datasheet:"key"`
	Radius float32 `datasheet:"Radius"`
}

ModelSkeleton stores information about the base size of the model

type Omen

type Omen struct {
	Key  uint16 `datasheet:"key"`
	Name string `datasheet:"Path"`
}

Omen stores the data for a game action Omen

type PlaceName

type PlaceName struct {
	Key  uint16 `datasheet:"key"`
	Name string `datasheet:"Name"`
}

PlaceName stores information about the name of the region

type Recipe

type Recipe struct {
	Key              uint32 `datasheet:"key"`
	RecipeLevel      uint16 `datasheet:"RecipeLevelTable"`
	ItemID           uint32 `datasheet:"Item{Result}"`
	RecipeElement    byte   `datasheet:"RecipeElement"`
	DifficultyFactor uint16 `datasheet:"DifficultyFactor"`
	QualityFactor    uint16 `datasheet:"QualityFactor"`
	DurabilityFactor uint16 `datasheet:"DurabilityFactor"`
	CanHQ            bool   `datasheet:"CanHq"`
}

Recipe stores some of the data for a game Recipe

type RecipeLevel

type RecipeLevel struct {
	Key        uint16 `datasheet:"key"`
	Difficulty uint16 `datasheet:"Difficulty"`
	Quality    uint16 `datasheet:"Quality"`
	Durability uint16 `datasheet:"Durability"`
}

RecipeLevel stores information about the difficulty of the recipe to improve quality and and increase progress

type RecipeStore

type RecipeStore struct {
	Recipes          map[uint32]Recipe
	RecipeLevelTable map[uint16]RecipeLevel
	Items            map[uint32]Item
}

RecipeStore stores all of the Recipe data.

func (*RecipeStore) GetInfo

func (r *RecipeStore) GetInfo(key uint32) *models.RecipeInfo

GetInfo returns the normalized information about the recipe

func (*RecipeStore) PopulateItems

func (r *RecipeStore) PopulateItems(dataReader io.Reader) error

PopulateItems will populate the RecipeStore with Item data provided a path to the data sheet for Items.

func (*RecipeStore) PopulateRecipeLevelTable

func (r *RecipeStore) PopulateRecipeLevelTable(dataReader io.Reader) error

PopulateRecipeLevelTable will populate the RecipeStore with RecipeLevel data provided a path to the data sheet for RecipeLevelTable.

func (*RecipeStore) PopulateRecipes

func (r *RecipeStore) PopulateRecipes(dataReader io.Reader) error

PopulateRecipes will populate the RecipeStore with Recipe data provided a path to the data sheet for Recipes.

type RepeatStructTagError

type RepeatStructTagError struct {
	Field string
	Tag   string
}

RepeatStructTagError describes an error returned when a repeat struct tag is encountered

func (*RepeatStructTagError) Error

func (e *RepeatStructTagError) Error() string

Error returns a formatted error message for the RepeatStructTagError

type Status

type Status struct {
	Key         uint32 `datasheet:"key"`
	Name        string `datasheet:"Name"`
	Description string `datasheet:"Description"`
}

Status stores the data for a game Status

type StatusStore

type StatusStore map[uint32]Status

StatusStore stores all of the Status data.

func (*StatusStore) PopulateStatuses

func (s *StatusStore) PopulateStatuses(dataReader io.Reader) error

PopulateStatuses will populate the StatusStore with Status data provided a path to the data sheet for Statuses.

type TerritoryInfo

type TerritoryInfo struct {
	Key  uint16 `datasheet:"key"`
	Name string `datasheet:"Name"`
	Map  uint16 `datasheet:"Map"`
}

TerritoryInfo stores information about the territory

type UnmarshalTypeError

type UnmarshalTypeError struct {
	Value  string
	Type   reflect.Type
	Row    int
	Struct string
	Field  string
}

UnmarshalTypeError describes an error returned when the data could not be assigned to a specific Go type

func (*UnmarshalTypeError) Error

func (e *UnmarshalTypeError) Error() string

type World

type World struct {
	Key  uint32 `datasheet:"key"`
	Name string `datasheet:"Name"`
}

World stores the data for a game World

type WorldStore

type WorldStore map[uint32]World

WorldStore stores all of the World data.

func (*WorldStore) Lookup

func (w *WorldStore) Lookup(worldID int) *models.World

func (*WorldStore) PopulateWorlds

func (w *WorldStore) PopulateWorlds(dataReader io.Reader) error

PopulateWorlds will populate the WorldStore with World data provided a path to the data sheet for Worlds.

Jump to

Keyboard shortcuts

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