tw

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidServerKey = errors.New("invalid server key")
	ErrInvalidServerURL = errors.New("invalid server URL")
)
View Source
var ErrBaseURLCantBeNil = errors.New("baseURL can't be nil")

Functions

This section is empty.

Types

type Building added in v0.2.0

type Building struct {
	BuildTime       float64 `xml:"build_time"`
	BuildTimeFactor float64 `xml:"build_time_factor"`
	Iron            int     `xml:"iron"`
	IronFactor      float64 `xml:"iron_factor"`
	MaxLevel        int     `xml:"max_level"`
	MinLevel        int     `xml:"min_level"`
	Pop             int     `xml:"pop"`
	PopFactor       float64 `xml:"pop_factor"`
	Stone           int     `xml:"stone"`
	StoneFactor     float64 `xml:"stone_factor"`
	Wood            int     `xml:"wood"`
	WoodFactor      float64 `xml:"wood_factor"`
}

type BuildingInfo added in v0.2.0

type BuildingInfo struct {
	XMLName    xml.Name `xml:"config"`
	Text       string   `xml:",chardata"`
	Main       Building `xml:"main"`
	Barracks   Building `xml:"barracks"`
	Stable     Building `xml:"stable"`
	Garage     Building `xml:"garage"`
	Watchtower Building `xml:"watchtower"`
	Snob       Building `xml:"snob"`
	Smith      Building `xml:"smith"`
	Place      Building `xml:"place"`
	Statue     Building `xml:"statue"`
	Market     Building `xml:"market"`
	Wood       Building `xml:"wood"`
	Stone      Building `xml:"stone"`
	Iron       Building `xml:"iron"`
	Farm       Building `xml:"farm"`
	Storage    Building `xml:"storage"`
	Hide       Building `xml:"hide"`
	Wall       Building `xml:"wall"`
}

type Client

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

func NewClient

func NewClient(opts ...ClientOption) *Client

func (*Client) GetBuildingInfo

func (c *Client) GetBuildingInfo(ctx context.Context, baseURL *url.URL) (BuildingInfo, error)

func (*Client) GetEnnoblements

func (c *Client) GetEnnoblements(ctx context.Context, baseURL *url.URL, since time.Time) ([]Ennoblement, error)

func (*Client) GetOpenServers

func (c *Client) GetOpenServers(ctx context.Context, baseURL *url.URL) ([]Server, error)

func (*Client) GetPlayers

func (c *Client) GetPlayers(ctx context.Context, baseURL *url.URL) ([]Player, error)

func (*Client) GetServerConfig

func (c *Client) GetServerConfig(ctx context.Context, baseURL *url.URL) (ServerConfig, error)

func (*Client) GetTribes

func (c *Client) GetTribes(ctx context.Context, baseURL *url.URL) ([]Tribe, error)

func (*Client) GetUnitInfo

func (c *Client) GetUnitInfo(ctx context.Context, baseURL *url.URL) (UnitInfo, error)

func (*Client) GetVillages

func (c *Client) GetVillages(ctx context.Context, baseURL *url.URL) ([]Village, error)

type ClientOption

type ClientOption func(c *clientConfig)

func WithEnnoblementsUseInterfaceFunc added in v0.11.2

func WithEnnoblementsUseInterfaceFunc(f EnnoblementsUseInterfaceFunc) ClientOption

WithEnnoblementsUseInterfaceFunc takes a function that will be called on every Client.GetEnnoblements call to determine whether the client should use /interface.php?func=get_conquer_extended or /map/conquer_extended.txt The default function checks whether since is after now() - 23h, if so, it calls /map/conquer_extended.txt, otherwise /interface.php?func=get_conquer_extended.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) ClientOption

func WithUserAgent

func WithUserAgent(ua string) ClientOption

type Ennoblement added in v0.2.0

type Ennoblement struct {
	VillageID  int
	NewOwnerID int
	NewTribeID int
	OldOwnerID int
	OldTribeID int
	Points     int
	CreatedAt  time.Time
}

type EnnoblementsUseInterfaceFunc added in v1.0.0

type EnnoblementsUseInterfaceFunc func(since time.Time) bool

type KnightNewItems added in v0.5.6

type KnightNewItems int

func (KnightNewItems) Int added in v1.0.0

func (k KnightNewItems) Int() int

func (*KnightNewItems) UnmarshalXML added in v0.5.6

func (k *KnightNewItems) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type OpponentsDefeated added in v0.2.0

type OpponentsDefeated struct {
	RankAtt    int
	ScoreAtt   int
	RankDef    int
	ScoreDef   int
	RankSup    int
	ScoreSup   int
	RankTotal  int
	ScoreTotal int
}

type ParseError

type ParseError struct {
	Field string
	Str   string
	Err   error
}

func (ParseError) Error

func (e ParseError) Error() string

func (ParseError) Unwrap

func (e ParseError) Unwrap() error

type Player added in v0.2.0

type Player struct {
	OpponentsDefeated

	ID          int
	Name        string
	NumVillages int
	Points      int
	Rank        int
	TribeID     int
	ProfileURL  *url.URL
}

type Server added in v0.2.0

type Server struct {
	Key string
	URL *url.URL
}

type ServerConfig added in v0.2.0

type ServerConfig struct {
	XMLName   xml.Name              `xml:"config"`
	Speed     float64               `xml:"speed"`
	UnitSpeed float64               `xml:"unit_speed"`
	Moral     int                   `xml:"moral"`
	Build     ServerConfigBuild     `xml:"build"`
	Misc      ServerConfigMisc      `xml:"misc"`
	Commands  ServerConfigCommands  `xml:"commands"`
	Newbie    ServerConfigNewbie    `xml:"newbie"`
	Game      ServerConfigGame      `xml:"game"`
	Buildings ServerConfigBuildings `xml:"buildings"`
	Snob      ServerConfigSnob      `xml:"snob"`
	Ally      ServerConfigAlly      `xml:"ally"`
	Coord     ServerConfigCoord     `xml:"coord"`
	Sitter    ServerConfigSitter    `xml:"sitter"`
	Sleep     ServerConfigSleep     `xml:"sleep"`
	Night     ServerConfigNight     `xml:"night"`
	Win       ServerConfigWin       `xml:"win"`
}

type ServerConfigAlly added in v0.2.0

type ServerConfigAlly struct {
	AllytimeSupport       int    `xml:"allytime_support"`
	FixedAllies           int    `xml:"fixed_allies"`
	Levels                int    `xml:"levels"`
	Limit                 int    `xml:"limit"`
	NoHarm                int    `xml:"no_harm"`
	NoJoin                int    `xml:"no_join"`
	NoLeave               int    `xml:"no_leave"`
	NoOtherSupport        int    `xml:"no_other_support"`
	NoOtherSupportType    int    `xml:"no_other_support_type"`
	PointsMemberCount     int    `xml:"points_member_count"`
	WarsAutoacceptDays    int    `xml:"wars_autoaccept_days"`
	WarsMemberRequirement int    `xml:"wars_member_requirement"`
	WarsPointsRequirement int    `xml:"wars_points_requirement"`
	XpRequirements        string `xml:"xp_requirements"`
}

type ServerConfigBuild added in v0.2.0

type ServerConfigBuild struct {
	Destroy int `xml:"destroy"`
}

type ServerConfigBuildings added in v0.2.0

type ServerConfigBuildings struct {
	CustomBarracks   int `xml:"custom_barracks"`
	CustomChurch     int `xml:"custom_church"`
	CustomFarm       int `xml:"custom_farm"`
	CustomGarage     int `xml:"custom_garage"`
	CustomHide       int `xml:"custom_hide"`
	CustomIron       int `xml:"custom_iron"`
	CustomMain       int `xml:"custom_main"`
	CustomMarket     int `xml:"custom_market"`
	CustomPlace      int `xml:"custom_place"`
	CustomSmith      int `xml:"custom_smith"`
	CustomSnob       int `xml:"custom_snob"`
	CustomStable     int `xml:"custom_stable"`
	CustomStatue     int `xml:"custom_statue"`
	CustomStone      int `xml:"custom_stone"`
	CustomStorage    int `xml:"custom_storage"`
	CustomWall       int `xml:"custom_wall"`
	CustomWatchtower int `xml:"custom_watchtower"`
	CustomWood       int `xml:"custom_wood"`
}

type ServerConfigCommands added in v0.2.0

type ServerConfigCommands struct {
	CommandCancelTime int `xml:"command_cancel_time"`
	MillisArrival     int `xml:"millis_arrival"`
}

type ServerConfigCoord added in v0.2.0

type ServerConfigCoord struct {
	BonusNew        int `xml:"bonus_new"`
	BonusVillages   int `xml:"bonus_villages"`
	EmptyVillages   int `xml:"empty_villages"`
	Func            int `xml:"func"`
	Inner           int `xml:"inner"`
	MapSize         int `xml:"map_size"`
	NobleRestart    int `xml:"noble_restart"`
	SelectStart     int `xml:"select_start"`
	StartVillages   int `xml:"start_villages"`
	VillageMoveWait int `xml:"village_move_wait"`
}

type ServerConfigGame added in v0.2.0

type ServerConfigGame struct {
	Archer             int            `xml:"archer"`
	BarbarianMaxPoints int            `xml:"barbarian_max_points"`
	BarbarianRise      float64        `xml:"barbarian_rise"`
	BarbarianShrink    int            `xml:"barbarian_shrink"`
	BaseProduction     int            `xml:"base_production"`
	BuildtimeFormula   int            `xml:"buildtime_formula"`
	Church             int            `xml:"church"`
	Event              int            `xml:"event"`
	FakeLimit          float64        `xml:"fake_limit"`
	FarmLimit          int            `xml:"farm_limit"`
	Hauls              int            `xml:"hauls"`
	HaulsBase          int            `xml:"hauls_base"`
	HaulsMax           int            `xml:"hauls_max"`
	Knight             int            `xml:"knight"`
	KnightNewItems     KnightNewItems `xml:"knight_new_items"`
	Scavenging         int            `xml:"scavenging"`
	Stronghold         int            `xml:"stronghold"`
	SuppressEvents     int            `xml:"suppress_events"`
	Tech               int            `xml:"tech"`
	Watchtower         int            `xml:"watchtower"`
}

type ServerConfigMisc added in v0.2.0

type ServerConfigMisc struct {
	KillRanking     int `xml:"kill_ranking"`
	TradeCancelTime int `xml:"trade_cancel_time"`
	Tutorial        int `xml:"tutorial"`
}

type ServerConfigNewbie added in v0.2.0

type ServerConfigNewbie struct {
	Days                 int `xml:"days"`
	Ratio                int `xml:"ratio"`
	RatioDays            int `xml:"ratio_days"`
	RemoveNewbieVillages int `xml:"removeNewbieVillages"`
}

type ServerConfigNight added in v0.2.0

type ServerConfigNight struct {
	Active    int     `xml:"active"`
	DefFactor float64 `xml:"def_factor"`
	Duration  int     `xml:"duration"`
	EndHour   int     `xml:"end_hour"`
	StartHour int     `xml:"start_hour"`
}

type ServerConfigSitter added in v0.2.0

type ServerConfigSitter struct {
	Allow int `xml:"allow"`
}

type ServerConfigSleep added in v0.2.0

type ServerConfigSleep struct {
	Active   int `xml:"active"`
	Delay    int `xml:"delay"`
	Max      int `xml:"max"`
	MaxAwake int `xml:"max_awake"`
	Min      int `xml:"min"`
	MinAwake int `xml:"min_awake"`
	WarnTime int `xml:"warn_time"`
}

type ServerConfigSnob added in v0.2.0

type ServerConfigSnob struct {
	CheapRebuild  int     `xml:"cheap_rebuild"`
	CoinIron      int     `xml:"coin_iron"`
	CoinStone     int     `xml:"coin_stone"`
	CoinWood      int     `xml:"coin_wood"`
	Factor        float64 `xml:"factor"`
	Gold          int     `xml:"gold"`
	MaxDist       int     `xml:"max_dist"`
	NoBarbConquer int     `xml:"no_barb_conquer"`
	Rise          int     `xml:"rise"`
}

type ServerConfigWin added in v0.2.0

type ServerConfigWin struct {
	Check int `xml:"check"`
}

type Tribe added in v0.2.0

type Tribe struct {
	OpponentsDefeated

	ID          int
	Name        string
	Tag         string
	NumMembers  int
	NumVillages int
	Points      int
	AllPoints   int
	Rank        int
	ProfileURL  *url.URL
}

type Unit added in v0.2.0

type Unit struct {
	Attack         int     `xml:"attack"`
	BuildTime      float64 `xml:"build_time"`
	Carry          int     `xml:"carry"`
	Defense        int     `xml:"defense"`
	DefenseArcher  int     `xml:"defense_archer"`
	DefenseCavalry int     `xml:"defense_cavalry"`
	Pop            int     `xml:"pop"`
	Speed          float64 `xml:"speed"`
}

type UnitInfo added in v0.2.0

type UnitInfo struct {
	XMLName  xml.Name `xml:"config"`
	Text     string   `xml:",chardata"`
	Spear    Unit     `xml:"spear"`
	Sword    Unit     `xml:"sword"`
	Axe      Unit     `xml:"axe"`
	Archer   Unit     `xml:"archer"`
	Spy      Unit     `xml:"spy"`
	Light    Unit     `xml:"light"`
	Marcher  Unit     `xml:"marcher"`
	Heavy    Unit     `xml:"heavy"`
	Ram      Unit     `xml:"ram"`
	Catapult Unit     `xml:"catapult"`
	Knight   Unit     `xml:"knight"`
	Snob     Unit     `xml:"snob"`
	Militia  Unit     `xml:"militia"`
}

type Village added in v0.2.0

type Village struct {
	ID         int
	Name       string
	Points     int
	X          int
	Y          int
	Continent  string
	Bonus      int
	PlayerID   int
	ProfileURL *url.URL
}

Jump to

Keyboard shortcuts

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