api

package
v0.0.0-...-a2814e5 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ability

type Ability struct {
	BaseID string `json:"base_id"`
	Name   string `json:"name"`
	Image  string `json:"image"`
	URL    string `json:"url"`

	TierMax int  `json:"tier_max"`
	IsZeta  bool `json:"is_zeta"`
	IsOmega bool `json:"is_omega"`

	Type            int    `json:"type"`
	CombatType      int    `json:"combat_type"`
	CharacterBaseID string `json:"character_base_id"`
}

Ability contains information about each character or ship abilities in the game.

type Character

type Character struct {
	Name        string `json:"name"`
	Description string `json:"description"`

	BaseID string `json:"base_id"`
	PK     int    `json:"pk"`

	URL   string `json:"url"`
	Image string `json:"image"`

	Power      int      `json:"power"`
	CombatType int      `json:"combat_type"`
	Alignment  string   `json:"alignment"`
	Categories []string `json:"categories"`
	Role       string   `json:"role"`

	AbilityClasses []string    `json:"ability_classes"`
	GearLevels     []GearLevel `json:"gear_levels"`
}

Character represents a character unit in the game.

type Characters

type Characters []Character

Characters is a character slice with helper methods

func (Characters) FromBaseID

func (l Characters) FromBaseID(baseID string) *Character

FromBaseID search for a character using it's Base ID as criteria. Returns nil if the BaseID is not found.

type Client

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

Client implements the API methods described by https://swgoh.gg/api/.

This client wraps the default http.Client and exposes the API methods to make them easy to use, with some extra goodies. Data types returned can be easily manipulated and are designed to make coding with the API quick and easy tasks.

func NewClient

func NewClient(c context.Context) *Client

NewClient initializes a new API client. This is required in order to prepare the internal client state, including the http.Client, context, logging and debuging.

func (*Client) Abilities

func (c *Client) Abilities() (abilities []Ability, err error)

Abilities list all available game abilities

func (*Client) Characters

func (c *Client) Characters() (chars Characters, err error)

Characters returns a list of all game characters. Use this method to retrieve a list of characters and to use the resulting list in lookups and the like.

func (*Client) Debug

func (c *Client) Debug(debug bool) *Client

Debug enables debug info to stdout. This makes the cliente *very* verbose.

func (*Client) Player

func (c *Client) Player(allyCode string) (player *Player, err error)

Player returns the player detailed profile information including all player units.

type EquipedGear

type EquipedGear struct {
	Slot       int    `json:"slot"`
	IsObtained bool   `json:"is_obtained"`
	BaseID     string `json:"base_id"`
}

EquipedGear represents unit equped gear details.

type GearLevel

type GearLevel struct {
	Tier    int      `json:"tier"`
	GearIDs []string `json:"gear"`
}

GearLevel represents a character gear level item list.

type Player

type Player struct {
	PlayerProfile `json:"data"`
	Units         []Unit `json:"units"`
}

Player represents the player profile data from the website and game.

type PlayerProfile

type PlayerProfile struct {
	Name  string `json:"name"`
	Level int    `json:"level"`

	ArenaRank         int    `json:"arena_rank"`
	ArenaLeaderBaseID string `json:"arena_leader_base_id"`

	AllyCode    int `json:"ally_code"`
	GP          int `json:"galactic_power"`
	ShipGP      int `json:"ship_galactic_power"`
	CharacterGP int `json:"character_galactic_power"`
}

PlayerProfile details the player profile information.

type StatName

type StatName string

StatName is a helper Enum to recover data from UnitStats

const (
	Strength StatName = "2"
	Agility  StatName = "3"
	Tatics   StatName = "4"

	Health         StatName = "1"
	Protection     StatName = "28"
	Speed          StatName = "5"
	CriticalDamage StatName = "16"
	Potency        StatName = "17"
	Tenaticy       StatName = "18"
	HealthSteal    StatName = "27"

	PhysicalDamage         StatName = "6"
	PhysicalCriticalChange StatName = "14"
	ArmorPenetration       StatName = "10"
	PhysicalAccuracy       StatName = "37"

	Armor                     StatName = "8"
	DodgeChance               StatName = "12"
	PhysicalCriticalAvoidance StatName = "39"

	SpecialDamage         StatName = "7"
	SpecialCriticalChance StatName = "15"
	ResistancePenetration StatName = "11"
	SpecialAccuracy       StatName = "38"

	Resistance               StatName = "9"
	DeflectionChance         StatName = "13"
	SpecialCriticalAvoidance StatName = "40"
)

Enumerated list of stats

type Unit

type Unit struct {
	UnitData `json:"data"`
}

Unit is a player unit detailed info.

type UnitData

type UnitData struct {
	BaseID    string `json:"base_id"`
	Power     int    `json:"power"`
	Level     int    `json:"level"`
	GearLevel int    `json:"gear_level"`
	Rarity    int    `json:"rarity"`
	URL       string `json:"url"`

	ZetaAbilities []string  `json:"zeta_abilities"`
	Stats         UnitStats `json:"stats"`
	Gear          []EquipedGear
}

UnitData holds character data for each player unit.

type UnitStats

type UnitStats map[StatName]float64

UnitStats contains a map of unit statistics

func (UnitStats) String

func (u UnitStats) String() string

Jump to

Keyboard shortcuts

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