sde

package
v0.0.0-...-fe7b80c Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2015 License: MIT Imports: 22 Imported by: 9

Documentation

Overview

The sde package is a fully functional library for use with the DUST514 Static Data Export. The package automatically can download and manage multiple versions of the SDE and has multiple data structures to manipulate data.

Index

Constants

View Source
const (
	ProtofitsBaseURL = "http://www.protofits.com/fittings/getCLF/"
)

Variables

View Source
var (
	PrintDebug bool
)
View Source
var (
	// Versions is a map of all of the available versions.
	Versions map[string]Version
)
View Source
var WorthyAttributes map[string]AtterSet

Functions

func Debug

func Debug(t time.Time)

func DoRangeFilter

func DoRangeFilter(i interface{}) float64

func DownloadAllVersions

func DownloadAllVersions()

DownloadAllVersions is a function to download every version of the SDE that is available.

func GiveSDE

func GiveSDE(s *SDE)

GiveSDE is used to give the sde package your primary SDE that you've opened We need this for fits to pull the data from the correct database. If you're not using fits don't bother. All of the fit provider functions should warn if it's not set.

func IntervalFilter

func IntervalFilter(i interface{}) float64

func LoadCache

func LoadCache(filename string) error

func PrintWorthyStats

func PrintWorthyStats(t SDEType)

func SaveCache

func SaveCache(filename string) error

Types

type AtterSet

type AtterSet struct {
	SetName          string
	AttributeName    string
	DoRangeFilter    bool
	DoIntervalFilter bool
	ValueFunc        func(t SDEType, val interface{}) interface{}
}

type CLFMetadata

type CLFMetadata struct {
	Title string `json:"title"`
}

CLFMetadata holds the metadata portion of a CLF fit

type CLFModule

type CLFModule struct {
	SDEType  SDEType `json:"-"`
	TypeID   string  `json:"typeid"`
	SlotType string  `json:"slottype"`
	Index    int     `json:"index"`
}

CLFModule holds an individual module in the fit

type CLFPreset

type CLFPreset struct {
	Name    string       `json:"presetname"`
	Modules []*CLFModule `json:"modules"`
}

CLFPreset is an individual preset in a CLF fit

type CLFSuit

type CLFSuit struct {
	TypeID  string   `json:"typeid"`
	SDEType *SDEType `json:"-"`
}

CLFSuit houses the "ship" portion of a CLF fit

type Class

type Class struct {
	TypeID    int
	ClassName string
}

Class is a data structure to represent a Class in a static data export. Currently unused.

type Fit

type Fit struct {
	CLFVersion     int         `json:"clf-version"`
	CLFType        string      `json:"X-clf-type"`
	CLFGeneratedBy string      `json:"X-generatedby"`
	Metadata       CLFMetadata `json:"metadata"`
	Suit           CLFSuit     `json:"ship"`
	Fitting        CLFPreset   `json:"presets"`
}

Fit is a structure representing a CLF fit for DUST514 and internal structures for calculating stats.

func GetFitClipboard

func GetFitClipboard() (*Fit, error)

GetFitClipboard gets a CLF fit from the clipboard.

func GetFitFromFile

func GetFitFromFile(filename string) (*Fit, error)

GetFitFromFile loads a CLF fit from file.

func GetFitProtofits

func GetFitProtofits(id string) (*Fit, error)

GetFitProtoFits gets a CLF fit from Protofits.com You must provide the id of the fit and it must be shared

func (*Fit) ApplySuitBonus

func (f *Fit) ApplySuitBonus(stats *Stats, skill SkillLevel)

ApplySuitBonus applies bonuses for the suit using the skill level provided.

func (*Fit) FillFields

func (s *Fit) FillFields()

FillFields is an internal function used to fill all the extra non-json within the SDEFit structure and sub structures.

func (*Fit) Stats

func (s *Fit) Stats() *Stats

Stats returns a Stats for a fit. Assumes all Lvl5 skills.

type Progress

type Progress struct {
	Percent int
	Current int
	Total   int
}

type SDE

type SDE struct {
	DB      *sql.DB `json:"-"`
	Version string  `json:"version"`
	Cache   bool    `json:"useCache"`
}

SDE is a struct containing the database object, the version of the SDE and many methods for working with the SDE.

var (
	PrimarySDE *SDE
)

func Open

func Open(Version string) (SDE, error)

Open will open our SDE of the version specified.

func (*SDE) Dump

func (s *SDE) Dump() error

Dump attemps to dump all relevent types to a file. Uses lots of memory. Be careful.

func (*SDE) GetType

func (s *SDE) GetType(id int) (SDEType, error)

GetType returns an SDEType of the given TypeID

func (*SDE) GetTypeByName

func (s *SDE) GetTypeByName(name string) (SDEType, error)

func (*SDE) GetTypeNoAttr

func (s *SDE) GetTypeNoAttr(id int) (SDEType, error)

GetType returns an SDEType of the given TypeID

func (*SDE) GetTypeQ

func (s *SDE) GetTypeQ(id int) (SDEType, error)

GetType returns an SDEType of the given TypeID

func (*SDE) GetTypeWhereNameContains

func (s *SDE) GetTypeWhereNameContains(name string) ([]*SDEType, error)

GetTypeWhereNameContains should be thought of as a search function that checks the display name.

func (*SDE) GetTypesByClassName

func (s *SDE) GetTypesByClassName(name string) (map[int]*SDEType, string)

func (*SDE) GetTypesWithTag

func (s *SDE) GetTypesWithTag(tag int) []*SDEType

func (*SDE) GobDump

func (s *SDE) GobDump() chan Progress

GobDump attempts to cache all types

func (*SDE) IterFunc

func (s *SDE) IterFunc(f func(TypeID int) bool) error

func (*SDE) Search

func (s *SDE) Search(search string) ([]*SDEType, error)

Search returns a slice of *SDEType where the given string is either in the TypeID, TypeName or mDisplayName attribute. It starts by checking the mDisplayName first, than TypeName and ID if all else fails.

type SDECache

type SDECache struct {
	Types   map[int]*SDEType
	Version string
}
var Cache SDECache

func (*SDECache) GetType

func (s *SDECache) GetType(id int) (SDEType, bool)

func (*SDECache) Search

func (s *SDECache) Search(name string) []SDEType

type SDEType

type SDEType struct {
	TypeID     int                    `json:"typeId"`
	TypeName   string                 `json:"typeName"`
	Attributes map[string]interface{} `json:"attributes"`
	FromCache  bool                   `json:"fromCache"`
	// contains filtered or unexported fields
}

SDEType holds hopefully all of the information you will need about a type. The interface in the Attributes map will always be either a float64, int or a string. If the value is always going to a whole number pull an int out otherwise assume it's a float

func (*SDEType) ESBA

func (s *SDEType) ESBA()

Not documented for a reason. Don't ask. Pretend this doesn't exist

func (*SDEType) GetAttribute

func (s *SDEType) GetAttribute(attributeName string) error

func (*SDEType) GetAttributes

func (s *SDEType) GetAttributes() error

GetAttributes grabs the attributes for the type and applied them. This is used to speed up querries for simple lookups.

func (*SDEType) GetAttributesLike

func (s *SDEType) GetAttributesLike(attributeName string) error

func (*SDEType) GetDPS

func (s *SDEType) GetDPS() float64

GetDPS returns the DPS of a type, if it can. Notice: CCP has some all kinds of fucked up shit with bursts and intervals don't expect these numbers to be accurate until I can finally fix all of it.

func (SDEType) GetEquipmentSlots

func (s SDEType) GetEquipmentSlots() int

func (SDEType) GetGrenadeSlots

func (s SDEType) GetGrenadeSlots() int

func (SDEType) GetHeavySlots

func (s SDEType) GetHeavySlots() int

func (SDEType) GetHighSlots

func (s SDEType) GetHighSlots() int

func (SDEType) GetLowSlots

func (s SDEType) GetLowSlots() int

func (SDEType) GetName

func (s SDEType) GetName() string

GetName returns the display name of a type.

func (SDEType) GetPrimarySlots

func (s SDEType) GetPrimarySlots() int

func (*SDEType) GetRoF

func (s *SDEType) GetRoF() int

GetRoF gets the ROF of any weapon in rounds per minute. Must vall GetAttributes first

func (*SDEType) GetSharedTagTypes

func (s *SDEType) GetSharedTagTypes() ([]*SDEType, error)

GetSharedTagTypes returns a slice of SDETypes that share the 'main' tag of a type.

func (SDEType) GetSidearmSlots

func (s SDEType) GetSidearmSlots() int

func (*SDEType) HasTag

func (s *SDEType) HasTag(tag int) bool

func (*SDEType) IsAurum

func (s *SDEType) IsAurum() bool

IsAurum returns if the item is puchased with aurum. Be the soldiar of tomorrow, today with Aurum(C)(TM)(LOLCCP) Will also return true if it's a pack item or special edition. The only special edition suits that aren't filtered are unique.

func (*SDEType) IsFaction

func (s *SDEType) IsFaction() bool

func (*SDEType) IsObtainable

func (s *SDEType) IsObtainable() bool

IsObtainable returns True if the item is consumable. The name is misleading but it should be used to check if an item is obtainable by a player.

func (*SDEType) IsWeapon

func (s *SDEType) IsWeapon() bool

IsWeapon returns true if a type has a weapon tag.

func (*SDEType) Lookup

func (s *SDEType) Lookup(depth int)

Lookup goes through our attributes in search of attributes that may be a TypeID and change it's value to an *SDEType.

func (*SDEType) ParentSDE

func (s *SDEType) ParentSDE() *SDE

func (*SDEType) PrintTags

func (s *SDEType) PrintTags()

PrintTags is a function to pretty print tags related to a type.

func (*SDEType) ToJSON

func (s *SDEType) ToJSON() (string, error)

ToJSON returns a Marshaled and indented version of our SDEType.

type SkillLevel

type SkillLevel uint8

SkillLevel is a type for each skill level available

const (
	// SkillLevels
	LevelZero SkillLevel = iota
	LevelOne
	LevelTwo
	LevelThree
	LevelFour
	LevelFive
)

type Stats

type Stats struct {
	HealArmorRate       int64   `sde:"mVICProp.healArmorRate"                       json:"repairRate"`
	Shields             int64   `sde:"mVICProp.maxShield"                           json:"shield"`
	Armor               int64   `sde:"mVICProp.maxArmor"                            json:"armor"`
	HealShieldRate      int64   `sde:"mVICProp.healShieldRate"                      json:"shieldRecharge"`
	ShieldDepletedDelay int64   `sde:"mVICProp.shieldRechargePauseOnShieldDepleted" json:"depletedDelay"`
	CPU                 int64   `sde:"mVICProp.maxPowerReserve"                     json:"cpu"`
	CPUUsed             int64   `json:"cpuUsed`
	CPUPercent          int     `json:"cpuPercent"`
	PG                  int64   `sde:"mVICProp.maxPowerReserve"                     json:"pg"`
	PGUsed              int64   `json:"pgUsed"`
	PGPercent           int     `json:"pgPercent"`
	Stamina             float64 `sde:"mCharProp.maxStamina"                         json:"stamina"`
	StaminaRecovery     float64 `sde:"mCharProp.staminaRecoveryPerSecond"           json:"staminaRecovery"`
	ScanPrecision       int64   `sde:"mVICProp.signatureScanPrecision"              json:"scanPrecision"`
	ScanProfile         int64   `sde:"mVICProp.signatureScanProfile"                json:"scanProfile"`
	ScanRadius          int64   `sde:"mVICProp.signatureScanRadius"                 json:"scanRadius"`
	MetaLevel           int64   `sde:"metaLevel"                                    json:"metaLevel"`
}

Stats is a general structure to output all of the stats of a fit. Fields values are automatically inserted via ApplySuitBonuses. This structure is ready to be exported via JSON.

func (*Stats) ToJSON

func (s *Stats) ToJSON() string

ToJSON returns an indented marshaled JSON string of our Stats object.

type Version

type Version struct {
	URL    string
	Zipped bool
}

Jump to

Keyboard shortcuts

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