coc

package
v0.0.0-...-ed9cc5f Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClanNotFound = errors.New("clan not found")
	ErrNotInWar     = errors.New("clan is not in a war")
	ErrTagMissing   = errors.New("no tag provided")
)

Functions

func SetToken

func SetToken(t string)

SetToken sets the token to be used on requests sent to Clash of Clans

Types

type BadgeUrls

type BadgeUrls struct {
	Small  string `json:"small"`
	Large  string `json:"large"`
	Medium string `json:"medium"`
}

BadgeUrls are the URLs for badges

func (BadgeUrls) String

func (urls BadgeUrls) String() string

String returns a string representation of a label

type Clan

type Clan struct {
	BadgeUrls        BadgeUrls     `json:"badgeUrls"`
	ClanLevel        int           `json:"clanLevel"`
	ClanPoints       int           `json:"clanPoints"`
	ClanVersusPoints int           `json:"clanVersusPoints"`
	Description      string        `json:"description"`
	IsWarLogPublic   bool          `json:"isWarLogPublic"`
	Labels           []Label       `json:"labels"`
	Location         Location      `json:"location"`
	Members          int           `json:"members"`
	Name             string        `json:"name"`
	RequiredTrophies int           `json:"requiredTrophies"`
	Tag              string        `json:"tag"`
	Type             string        `json:"type"`
	WarFrequency     string        `json:"warFrequency"`
	WarLeague        ClanWarLeague `json:"warLeague"`
	WarLosses        int           `json:"warLosses"`
	WarTies          int           `json:"warTies"`
	WarWins          int           `json:"warWins"`
	WarWinStreak     int           `json:"warWinStreak"`
}

Clan is a clan in Clash of Clans.

func GetClan

func GetClan(tag string) (*Clan, error)

GetClan retrieves information about a clan with the given tag

func GetClans

func GetClans(name string, qparms rest.QParms) ([]Clan, error)

GetClans returns information about all clans that match the query parameters

func (Clan) String

func (c Clan) String() string

String returns a string representation of a clan

type ClanMember

type ClanMember struct {
	ClanRank          int    `json:"clanRank"`
	Donations         int    `json:"donations"`
	DonationsReceived int    `json:"donationsReceived"`
	ExpLevel          int    `json:"expLevel"`
	League            League `json:"league"`
	Name              string `json:"name"`
	PreviousClanRank  int    `json:"previousClanRank"`
	Role              string `json:"role"`
	Tag               string `json:"tag"`
	Trophies          int    `json:"trophies"`
	VersusTrophies    int    `json:"versusTrophies"`
}

ClanMember is a member of a given clan.

func GetClanMembers

func GetClanMembers(clanTag string, qparms rest.QParms) ([]ClanMember, error)

GetClanMembers gets information about members of a given clan

func (ClanMember) String

func (m ClanMember) String() string

String returns a string representation of a clan member

type ClanRanking

type ClanRanking struct {
	BadgeUrls    BadgeUrls `json:"badgeUrls"`
	ClanLevel    int       `json:"clanLevel"`
	ClanPoints   int       `json:"clanPoints"`
	Location     Location  `json:"location"`
	Members      int       `json:"members"`
	Name         string    `json:"name"`
	PreviousRank int       `json:"previousRank"`
	Rank         int       `json:"rank"`
	Tag          string    `json:"tag"`
}

ClanRanking is the clan ranking for a specific location.

func GetClanRankings

func GetClanRankings(locationID string, qparms rest.QParms) ([]ClanRanking, error)

GetClan Rankings gets clan rankings for a specific location

func (ClanRanking) String

func (l ClanRanking) String() string

String returns a string representation of a clan ranking

type ClanReference

type ClanReference struct {
	BadgeUrls BadgeUrls `json:"badgeUrls"`
	ClanLevel int       `json:"clanLevel"`
	Name      string    `json:"name"`
	Tag       string    `json:"tag"`
}

ClanReference provides a reference to a given clan

func (ClanReference) String

func (r ClanReference) String() string

String returns a string representation of a clan member

type ClanVersusRanking

type ClanVersusRanking struct {
	ClanVersusPoints int `json:"clanVersusPoints"`
	ClanPoints       int `json:"clanPoints"`
}

ClanVersusRanking is the clan versus ranking for a specific location

func GetClanVersusRankings

func GetClanVersusRankings(locationID string, qparms rest.QParms) ([]ClanVersusRanking, error)

GetClanRankings gets clan versus rankings for a specific location

func (ClanVersusRanking) String

func (l ClanVersusRanking) String() string

String returns a string representation of a clan versus ranking

type ClanWar

type ClanWar struct {
	State                string      `json:"state,omitempty"`
	TeamSize             int         `json:"teamSize"`
	PreparationStartTime CoCTime     `json:"preparationStartTime,omitempty"`
	StartTime            CoCTime     `json:"startTime,omitempty"`
	EndTime              CoCTime     `json:"endTime,omitempty"`
	Result               string      `json:"result,omitempty"`
	Clan                 ClanWarTeam `json:"clan"`
	Opponent             ClanWarTeam `json:"opponent"`
}

ClanWar is a given war in a clan's war log.

func GetClanWars

func GetClanWars(clanTag string, qparms rest.QParms) ([]ClanWar, error)

GetClanWars returns a list of wars a clan has particiapted in

func GetCurrentWar

func GetCurrentWar(clanTag string) (*ClanWar, error)

GetCurrentWar returns information about the current war a clan is participating in

func (ClanWar) String

func (cw ClanWar) String() string

String returns a string representation of a clan war

type ClanWarAttack

type ClanWarAttack struct {
	Order                 int    `json:"order"`
	AttackerTag           string `json:"attackerTag"`
	DefenderTag           string `json:"defenderTag"`
	Stars                 int    `json:"stars"`
	DestructionPercentage int    `json:"destructionPercentage"`
}

ClanWarAttack is an attack made in a clan war.

func (ClanWarAttack) String

func (cwa ClanWarAttack) String() string

String returns a string representation of a clan war atack

type ClanWarLeague

type ClanWarLeague struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

ClanWarLeague is a reference to a given clan war league

func (ClanWarLeague) String

func (wl ClanWarLeague) String() string

String returns a string representation of a clan war league

type ClanWarLeagueGroup

type ClanWarLeagueGroup struct {
	Clans []struct {
		BadgeUrls BadgeUrls `json:"badgeUrls"`
		ClanLevel int       `json:"clanLevel"`
		Members   []struct {
			Name          string `json:"name"`
			Tag           string `json:"tag"`
			TownHallLevel int    `json:"townHallLevel"`
		} `json:"members"`
		Name string `json:"name"`
		Tag  string `json:"tag"`
	} `json:"clans"`
	Rounds []struct {
		WarTags []string `json:"warTags"`
	} `json:"rounds"`
	Season string `json:"season"`
	State  string `json:"state"`
	Tag    string `json:"tag"`
}

ClanWarLeagueGroup is a clan's current clan war league group.

func GetClanWarLeagueGroup

func GetClanWarLeagueGroup(clanTag string) (*ClanWarLeagueGroup, error)

GetClanWarLeagueGroup retrieves information about clan's current clan war league group

func (ClanWarLeagueGroup) String

func (lg ClanWarLeagueGroup) String() string

String returns a string representation of a clan war league group

type ClanWarLeagueWar

type ClanWarLeagueWar struct {
	Clan                 ClanWarTeam `json:"clan"`
	EndTime              string      `json:"endTime"`
	Opponent             ClanWarTeam `json:"opponent"`
	PreparationStartTime string      `json:"preparationStartTime"`
	StartTime            string      `json:"startTime"`
	State                string      `json:"state"`
	TeamSize             int         `json:"teamSize"`
	WarStartTime         string      `json:"warStartTime"`
}

ClanWarLeagueWar is information about an individual clan war league war

func GetClanWarLeagueWar

func GetClanWarLeagueWar(clanTag string) (*ClanWarLeagueWar, error)

GetClanWarLeagueWar retrieves information about individual clan war league war

func (ClanWarLeagueWar) String

func (lw ClanWarLeagueWar) String() string

String returns a string representation of a clan war league war

type ClanWarMember

type ClanWarMember struct {
	Attacks            []ClanWarAttack `json:"attacks,omitempty"`
	BestOpponentAttack ClanWarAttack   `json:"bestOpponentAttack,omitempty"`
	MapPosition        int             `json:"mapPosition"`
	Name               string          `json:"name"`
	OpponentAttacks    int             `json:"opponentAttacks"`
	Tag                string          `json:"tag"`
	TownhallLevel      int             `json:"townhallLevel"`
}

ClanWarMember is a member who participated in a clan war.

func (ClanWarMember) String

func (cwm ClanWarMember) String() string

String returns a string representation of a clan war member

type ClanWarTeam

type ClanWarTeam struct {
	Attacks               int             `json:"attacks"`
	BadgeUrls             BadgeUrls       `json:"badgeUrls"`
	ClanLevel             int             `json:"clanLevel"`
	DestructionPercentage float32         `json:"destructionPercentage"`
	ExpEarned             int             `json:"expEarned"`
	Members               []ClanWarMember `json:"members,omitempty"`
	Name                  string          `json:"name"`
	Stars                 int             `json:"stars"`
	Tag                   string          `json:"tag"`
}

ClanWarTeam is the clan that is participating in the clan war.

func (ClanWarTeam) String

func (cwt ClanWarTeam) String() string

String returns a string representation of a clan war team

type CoCTime

type CoCTime time.Time

CoCTime is a redefinition of the Time structure. This allows for unmarshalling of the time format used by Clash of Clans.

func (CoCTime) Format

func (ct CoCTime) Format(s string) string

Format prints the date

func (CoCTime) MarshalJSON

func (ct CoCTime) MarshalJSON() ([]byte, error)

MarshalJSON converts a CoCTime into a JSON string

func (CoCTime) String

func (ct CoCTime) String() string

String converts the date to a string

func (*CoCTime) UnmarshalJSON

func (ct *CoCTime) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a JSON string into a CocTime structure

type IconUrls

type IconUrls struct {
	Small  string `json:"small"`
	Medium string `json:"medium"`
}

IconUrls are the URLs for icons

func (IconUrls) String

func (urls IconUrls) String() string

String returns a string representation of a label

type Label

type Label struct {
	Name     string   `json:"name"`
	ID       int      `json:"id"`
	IconUrls IconUrls `json:"iconUrls"`
}

Label is a label for a clan or player.

func GetClanLabels

func GetClanLabels(qparms rest.QParms) ([]Label, error)

GetClanLabels lists clan labels

func GetPlayerLabels

func GetPlayerLabels(qparms rest.QParms) ([]Label, error)

GetPlayerLabels lists player labels

func (Label) String

func (l Label) String() string

String returns a string representation of a label

type League

type League struct {
	IconUrls IconUrls `json:"iconUrls"`
	ID       int      `json:"id"`
	Name     string   `json:"name"`
}

League lists leagues

func GetLeague

func GetLeague(leagueID string) (*League, error)

GetLeague gets the league information

func GetLeagues

func GetLeagues(qparms rest.QParms) ([]League, error)

GetLeagues lists the leagues

func (League) String

func (l League) String() string

String returns a string representation of a league

type LeagueSeason

type LeagueSeason struct {
	ID string `json:"id"`
}

LeagueSeason is a league season.

func GetLeagueSeasons

func GetLeagueSeasons(leagueID string) ([]LeagueSeason, error)

GetLeagueSeasons gets the league seasons

func (LeagueSeason) String

func (ls LeagueSeason) String() string

String returns a string representation of a league season

type LeagueSeasonRanking

type LeagueSeasonRanking struct {
	AttackWins   int           `json:"attackWins"`
	Clan         ClanReference `json:"clan"`
	DefenseWins  int           `json:"defenseWins"`
	ExpLevel     int           `json:"expLevel"`
	League       League        `json:"league"`
	Name         string        `json:"name"`
	PreviousRank int           `json:"previousRank"`
	Rank         int           `json:"rank"`
	Tag          string        `json:"tag"`
	Trophies     int           `json:"trophies"`
}

LeagueSeasonRanking is the league season ranking.

func GetLeagueSeasonRankings

func GetLeagueSeasonRankings(leagueID string) ([]LeagueSeasonRanking, error)

GetLeagueSeasonRankings gets the league season rankings for Legend League

func (LeagueSeasonRanking) String

func (lsr LeagueSeasonRanking) String() string

String returns a string representation of a league season

type Location

type Location struct {
	CountryCode   string `json:"countryCode"`
	ID            int    `json:"id"`
	IsCountry     bool   `json:"isCountry"`
	LocalizedName string `json:"localizedName"`
	Name          string `json:"name"`
}

Location is information about a location

func GetLocation

func GetLocation(id string) (*Location, error)

GetLocation gets the location information

func GetLocations

func GetLocations(qparms rest.QParms) ([]Location, error)

GetLocations lists locations

func (Location) String

func (l Location) String() string

String returns a string representation of a location

type Player

type Player struct {
	Achievements         []PlayerAchievement `json:"achievements"`
	AttackWins           int                 `json:"attackWins"`
	BestTrophies         int                 `json:"bestTrophies"`
	BestVersusTrophies   int                 `json:"bestVersusTrophies"`
	BuilderHallLevel     int                 `json:"builderHallLevel"`
	Clan                 ClanReference       `json:"clan"`
	DefenseWins          int                 `json:"defenseWins"`
	Donations            int                 `json:"donations"`
	DonationsReceived    int                 `json:"donationsReceived"`
	ExpLevel             int                 `json:"expLevel"`
	Heroes               []Troop             `json:"heroes"`
	Labels               []Label             `json:"labels"`
	League               League              `json:"league"`
	Name                 string              `json:"name"`
	Role                 string              `json:"role"`
	Spells               []Troop             `json:"spells"`
	Tag                  string              `json:"tag"`
	TownHallLevel        int                 `json:"townHallLevel"`
	Troops               []Troop             `json:"troops"`
	Trophies             int                 `json:"trophies"`
	VersusBattleWinCount int                 `json:"versusBattleWinCount"`
	VersusBattleWins     int                 `json:"versusBattleWins"`
	VersusTrophies       int                 `json:"versusTrophies"`
	WarStars             int                 `json:"warStars"`
}

Player is a single player in Clash of Clans.

func GetPlayer

func GetPlayer(tag string) (*Player, error)

GetPlayer retrieves information about a given player

func (Player) String

func (p Player) String() string

String returns a string representation of a player

type PlayerAchievement

type PlayerAchievement struct {
	CompletionInfo string `json:"completionInfo"`
	Info           string `json:"info"`
	Name           string `json:"name"`
	Stars          int    `json:"stars"`
	Target         int    `json:"target"`
	Value          int    `json:"value"`
	Village        string `json:"village"`
}

func (PlayerAchievement) String

func (a PlayerAchievement) String() string

String returns a string representation of a player achievement

type PlayerRanking

type PlayerRanking struct {
	Clan         ClanReference `json:"clan"`
	League       League        `json:"league"`
	AttackWins   int           `json:"attackWins"`
	DefenseWins  int           `json:"defenseWins"`
	Tag          string        `json:"tag"`
	Name         string        `json:"name"`
	ExpLevel     int           `json:"expLevel"`
	Rank         int           `json:"rank"`
	PreviousRank int           `json:"previousRank"`
	Trophies     int           `json:"trophies"`
}

PlayerRanking is the ranking of a player for specific location.

func GetPlayerRankings

func GetPlayerRankings(locationID string, qparms rest.QParms) ([]PlayerRanking, error)

GetPlayerRankings gets player rankings for a specific location

func (PlayerRanking) String

func (l PlayerRanking) String() string

String returns a string representation of a location player ranking

type PlayerVersusRanking

type PlayerVersusRanking struct {
	Clan             ClanReference `json:"clan"`
	VersusBattleWins int           `json:"versusBattleWins"`
	Tag              string        `json:"tag"`
	Name             string        `json:"name"`
	ExpLevel         int           `json:"expLevel"`
	Rank             int           `json:"rank"`
	PreviousRank     int           `json:"previousRank"`
	VersusTrophies   int           `json:"versusTrophies"`
}

PlayerVersusRanking is the player ranking for a specific location

func GetPlayerVersusRankings

func GetPlayerVersusRankings(locationID string, qparms rest.QParms) ([]PlayerVersusRanking, error)

GetPlayerRankings gets clan versus rankings for a specific location

func (PlayerVersusRanking) String

func (l PlayerVersusRanking) String() string

String returns a string representation of a player-versus ranking for a location

type Troop

type Troop struct {
	Level    int    `json:"level"`
	MaxLevel int    `json:"maxLevel"`
	Name     string `json:"name"`
	Village  string `json:"village"`
}

Troop represents a troop, hero or spell in Clash of Clans

func (Troop) String

func (t Troop) String() string

String returns a string representation of a troop

type WarLeague

type WarLeague struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

WarLeague is information about a war league.

func GetWarLeague

func GetWarLeague(leagueID string) (*WarLeague, error)

GetLWareague gets the war league information

func GetWarLeagues

func GetWarLeagues(qparms rest.QParms) ([]WarLeague, error)

GetWarLeagues lists the war leagues

func (WarLeague) String

func (wl WarLeague) String() string

String returns a string representation of a war league

Jump to

Keyboard shortcuts

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