Documentation ¶
Overview ¶
Package swgohgg provides several wrappers to fetch and parse https://swgoh.gg/ website data.
Index ¶
- Variables
- func CharSlug(src string) string
- type Ability
- type Char
- type CharacterSkill
- type CharacterStats
- type Client
- func (c *Client) AllyCode() string
- func (c *Client) Arena() (team []*CharacterStats, lastUpdate time.Time, err error)
- func (c *Client) CharacterStats(char string) (*CharacterStats, error)
- func (c *Client) Collection() (collection Collection, err error)
- func (c *Client) Get(url string) (*goquery.Document, error)
- func (c *Client) GuildName() string
- func (c *Client) Login(username, password string) (err error)
- func (c *Client) Mods(filter ModFilter) (mods ModCollection, err error)
- func (c *Client) PlayerName() string
- func (c *Client) Profile(profile string) *Client
- func (c *Client) SetAllyCode(allyCode string) *Client
- func (c *Client) Ships() (ships Ships, err error)
- func (c *Client) UseHTTPClient(hc *http.Client) *Client
- func (c *Client) Zetas() (zetas []Ability, err error)
- type Collection
- type Mod
- type ModCollection
- func (m ModCollection) ByShape(shape string) (filtered ModCollection)
- func (m ModCollection) Filter(filter ModFilter) (filtered ModCollection)
- func (m ModCollection) MinLevel(level int) (filtered ModCollection)
- func (m ModCollection) MinRarity(rarity int) (filtered ModCollection)
- func (m ModCollection) Optimize(stat string, percentIsBetter bool) ModSet
- func (m ModCollection) SetWith(stat string) ModSet
- func (m ModCollection) WithStat(stat string) (filtered ModCollection)
- type ModFilter
- type ModSet
- type ModStat
- type Ship
- type Ships
- type SortByShipStars
- type SortByStars
Constants ¶
This section is empty.
Variables ¶
var ( // ShapeNames is a list of all available mod shapes. ShapeNames = []string{"Transmitter", "Receiver", "Processor", "Holo-Array", "Data-Bus", "Multiplexer"} // StatNames is a list of all available mod stats. StatNames = []string{"Speed", "Critical Chance", "Critical Damage", "Critical Avoidance", "Accuracy", "Potency", "Tenacity", "Offense", "Defense", "Health", "Protection"} )
Functions ¶
Types ¶
type CharacterSkill ¶
CharacterSkill holds basic info about a character skill.
type CharacterStats ¶
type CharacterStats struct { Name string Level int GearLevel int Stars int // Current character gallactic power GalacticPower int // List of skils of this character Skills []CharacterSkill // Basic Stats STR int AGI int INT int StrenghGrowth float64 AgilityGrowth float64 IntelligenceGrowth float64 // General Health int Protection int Speed int CriticalDamage float64 Potency float64 Tenacity float64 HealthSteal float64 PhysicalDamage int PhysicalCritChance float64 SpecialDamage int SpecialCritChance float64 }
CharacterStats contains all detailed character stats, as displayed in the game.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements methods to interact with the https://swgoh.gg/ website.
func NewClient ¶
NewClient initializes a new instance of the client, tied to the specified user profile.
func (*Client) Arena ¶
func (c *Client) Arena() (team []*CharacterStats, lastUpdate time.Time, err error)
Arena returns basic information about the player Arena team. If authorized, attempts to fetch more information from character stats
func (*Client) CharacterStats ¶
func (c *Client) CharacterStats(char string) (*CharacterStats, error)
CharacterStats fetches the character detail page and extracts all stats.
func (*Client) Collection ¶
func (c *Client) Collection() (collection Collection, err error)
Collection parses a player home page and returns the entire collection list.
func (*Client) Mods ¶
func (c *Client) Mods(filter ModFilter) (mods ModCollection, err error)
Mods reutrns a mod collection of mods with the given filter.
func (*Client) PlayerName ¶
PlayerName returns the player nickname
func (*Client) Profile ¶
Profile sets the client profile to a new value. *DEPRECATED*: use SetAllyCode instead.
func (*Client) SetAllyCode ¶
SetAllyCode set's the Ally Code for the client.
func (*Client) UseHTTPClient ¶
UseHTTPClient allows one to overwrite the default HTTP Client. The Client.Jar is replaced before next use.
type Collection ¶
type Collection []*Char
Collection is a list of characters. Usually loaded up by the call to client.Collection().
func (Collection) Contains ¶
func (r Collection) Contains(char string) bool
Contains lookup a character by name and checks if it is present in the collection.
func (Collection) ContainsAll ¶
func (r Collection) ContainsAll(chars ...string) bool
ContainsAll checks if the collection has all the provided items.
func (Collection) MinRarity ¶
func (r Collection) MinRarity(stars int) (filtered Collection)
MinRarity returns a filtered collection containing the required min rarity.
type Mod ¶
type Mod struct { ID string Level int Rarity int Shape string BonusSet string PrimStat ModStat SecStat []ModStat UsingIn string }
Mod represents a player mod with all mod information.
func (*Mod) BonusShortName ¶
BonusShortName returns the bonus set abreviated name.
func (*Mod) Format ¶
Format returns a string representation of the mod, either using Unicode emoji or not.
func (*Mod) GetStat ¶
GetStat returns a stat from the mod. The return is never nil, but a Zero ModStat.
func (*Mod) ShapeEmoji ¶
ShapeEmoji returns an unicode emoji that better represents the mod shape.
type ModCollection ¶
type ModCollection []*Mod
ModCollection is a slice of mods with extra methods for manipulation.
func (ModCollection) ByShape ¶
func (m ModCollection) ByShape(shape string) (filtered ModCollection)
ByShape filter the mod collection by a given shape.
func (ModCollection) Filter ¶
func (m ModCollection) Filter(filter ModFilter) (filtered ModCollection)
Filter applies the provided mod filter and returns a filtered collection that matches it.
func (ModCollection) MinLevel ¶
func (m ModCollection) MinLevel(level int) (filtered ModCollection)
MinLevel filters the mod collection to one that has only the given minimum level.
func (ModCollection) MinRarity ¶
func (m ModCollection) MinRarity(rarity int) (filtered ModCollection)
MinRarity filters the mod collection to one that has the minium rarity.
func (ModCollection) Optimize ¶
func (m ModCollection) Optimize(stat string, percentIsBetter bool) ModSet
Optimize searches over all your mods with level >= 12, rarity >= 4, and outputs a best-value for the given stat, considering bonus sets if the 'percentIsBetter' parameter is true. This is very experimental, CPU intensive and memory intensive!
func (ModCollection) SetWith ¶
func (m ModCollection) SetWith(stat string) ModSet
SetWith suggests a set containing the max values of the provided stat.
func (ModCollection) WithStat ¶
func (m ModCollection) WithStat(stat string) (filtered ModCollection)
WithStat filters a mod collection by a given stat.
type ModFilter ¶
type ModFilter struct {
Char string
}
ModFilter allows to filter mod queries. Currently available filter is by character name.
type ModSet ¶
ModSet is a mod with a set of mods with unique shapes.
func (ModSet) BonusForSet ¶
BonusForSet calculates the bonus set for the given stat. Takes into account mod level.
func (ModSet) StatSummary ¶
StatSummary returns a summary of all mods in the set.
type ModStat ¶
ModStat is a single mod stat value. If a percentage value additive, the IsPercentage attribute will be true.
func (ModStat) IsBetterThan ¶
IsBetterThan attempts to compare two stats with each other.
func (ModStat) IsZero ¶
IsZero checks if the stat object has a value or name, indicating it is not zero value.
func (ModStat) StatShortName ¶
StatShortName returns an abbreviated stat name.
type Ships ¶
type Ships []*Ship
Ships is a slice of ships with methods for manipulation.
func (Ships) ContainsAll ¶
ContainsAll returns true if the ship collection contains all the provided ships.
type SortByShipStars ¶
type SortByShipStars struct {
// contains filtered or unexported fields
}
SortByShipStars is a sorting criteria to sort ship collection by stars.
func ByShipStars ¶
func ByShipStars(ships []*Ship, ascending bool) SortByShipStars
ByShipStars returns a sorting criteria to sort ships by stars.
func (SortByShipStars) Len ¶
func (bs SortByShipStars) Len() int
func (SortByShipStars) Less ¶
func (bs SortByShipStars) Less(i, j int) bool
func (SortByShipStars) Swap ¶
func (bs SortByShipStars) Swap(i, j int)
type SortByStars ¶
type SortByStars struct {
// contains filtered or unexported fields
}
SortByStars is a sorting criteria to sort a character collection by star level.
func ByStars ¶
func ByStars(chars []*Char, ascending bool) SortByStars
ByStars returns a sorting criteria to sort characters by stars.
func (SortByStars) Len ¶
func (bs SortByStars) Len() int
func (SortByStars) Less ¶
func (bs SortByStars) Less(i, j int) bool
func (SortByStars) Swap ¶
func (bs SortByStars) Swap(i, j int)