tw

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 13 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")
)

Functions

This section is empty.

Types

type Building added in v0.2.0

type Building struct {
	MaxLevel        int8    `xml:"max_level"`
	MinLevel        int8    `xml:"min_level"`
	Wood            int32   `xml:"wood"`
	Stone           int32   `xml:"stone"`
	Iron            int32   `xml:"iron"`
	Pop             int16   `xml:"pop"`
	WoodFactor      float64 `xml:"wood_factor"`
	StoneFactor     float64 `xml:"stone_factor"`
	IronFactor      float64 `xml:"iron_factor"`
	PopFactor       float64 `xml:"pop_factor"`
	BuildTime       float64 `xml:"build_time"`
	BuildTimeFactor float64 `xml:"build_time_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, baseURLRaw string) (BuildingInfo, error)

func (*Client) GetEnnoblements

func (c *Client) GetEnnoblements(ctx context.Context, baseURLRaw string, since time.Time) ([]Ennoblement, error)

func (*Client) GetOpenServers

func (c *Client) GetOpenServers(ctx context.Context, baseURLRaw string) ([]Server, error)

func (*Client) GetPlayers

func (c *Client) GetPlayers(ctx context.Context, baseURLRaw string) ([]Player, error)

func (*Client) GetServerConfig

func (c *Client) GetServerConfig(ctx context.Context, baseURLRaw string) (ServerConfig, error)

func (*Client) GetTribes

func (c *Client) GetTribes(ctx context.Context, baseURLRaw string) ([]Tribe, error)

func (*Client) GetUnitInfo

func (c *Client) GetUnitInfo(ctx context.Context, baseURLRaw string) (UnitInfo, error)

func (*Client) GetVillages

func (c *Client) GetVillages(ctx context.Context, baseURLRaw string) ([]Village, error)

type ClientOption

type ClientOption func(c *clientConfig)

func WithEnnoblementsUseInterfaceFunc added in v0.11.2

func WithEnnoblementsUseInterfaceFunc(f func(since time.Time) bool) 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 A default function checks whether since is after now - 23h.

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  int64
	NewOwnerID int64
	NewTribeID int64
	OldOwnerID int64
	OldTribeID int64
	Points     int64
	CreatedAt  time.Time
}

type KnightNewItems added in v0.5.6

type KnightNewItems int8

func (KnightNewItems) Int8 added in v0.5.6

func (k KnightNewItems) Int8() int8

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    int64
	ScoreAtt   int64
	RankDef    int64
	ScoreDef   int64
	RankSup    int64
	ScoreSup   int64
	RankTotal  int64
	ScoreTotal int64
}

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          int64
	Name        string
	NumVillages int64
	Points      int64
	Rank        int64
	TribeID     int64
	ProfileURL  string
}

type Server added in v0.2.0

type Server struct {
	Key string
	URL string
}

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     int16                 `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 {
	NoHarm                int8   `xml:"no_harm"`
	NoOtherSupport        int8   `xml:"no_other_support"`
	NoOtherSupportType    int8   `xml:"no_other_support_type"`
	AllytimeSupport       int32  `xml:"allytime_support"`
	NoLeave               int8   `xml:"no_leave"`
	NoJoin                int8   `xml:"no_join"`
	Limit                 int16  `xml:"limit"`
	FixedAllies           int8   `xml:"fixed_allies"`
	PointsMemberCount     int32  `xml:"points_member_count"`
	WarsMemberRequirement int16  `xml:"wars_member_requirement"`
	WarsPointsRequirement int32  `xml:"wars_points_requirement"`
	WarsAutoacceptDays    int16  `xml:"wars_autoaccept_days"`
	Levels                int8   `xml:"levels"`
	XpRequirements        string `xml:"xp_requirements"`
}

type ServerConfigBuild added in v0.2.0

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

type ServerConfigBuildings added in v0.2.0

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

type ServerConfigCommands added in v0.2.0

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

type ServerConfigCoord added in v0.2.0

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

type ServerConfigGame added in v0.2.0

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

type ServerConfigMisc added in v0.2.0

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

type ServerConfigNewbie added in v0.2.0

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

type ServerConfigNight added in v0.2.0

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

type ServerConfigSitter added in v0.2.0

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

type ServerConfigSleep added in v0.2.0

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

type ServerConfigSnob added in v0.2.0

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

type ServerConfigWin added in v0.2.0

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

type Tribe added in v0.2.0

type Tribe struct {
	OpponentsDefeated

	ID          int64
	Name        string
	Tag         string
	NumMembers  int64
	NumVillages int64
	Points      int64
	AllPoints   int64
	Rank        int64
	ProfileURL  string
}

type Unit added in v0.2.0

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

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         int64
	Name       string
	Points     int64
	X          int64
	Y          int64
	Continent  string
	Bonus      int64
	PlayerID   int64
	ProfileURL string
}

Jump to

Keyboard shortcuts

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