Documentation ¶
Index ¶
- func CompareFactors(petOne, petTwo int64) int64
- func ExtractInfoboxData(infobox string) map[string]string
- func FindHeader(data string) string
- func ReplaceInfoboxHeader(data, template string) string
- type APIClient
- type AcceptedNames
- type Cache
- type CacheRaidRepository
- type ConsolePresenter
- type DefaultTimeFormatter
- type DocumentFetcher
- type FetcherCache
- type Gate
- type HTTPDocumentFetcher
- type JSONNameRepository
- type Kiosk
- type KioskCache
- type KioskItem
- type KioskManager
- type Name
- type NameGenerator
- type NameRepository
- type PetAttributes
- type PetCalculator
- type PlayerRanking
- type Presenter
- type Raid
- type RaidMember
- type RaidRepository
- type RaidService
- type Repository
- type TimeFormatter
- type TimeService
- type Tournament
- type URLGenerator
- type URLNameRepository
- type URLParams
- type URLParser
- type WikiResponse
- type WikiService
- type WikiText
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareFactors ¶
CompareFactors compares two factors and returns a result based on a formula.
func ExtractInfoboxData ¶ added in v1.0.4
ExtractInfoboxData extracts key-value pairs from the infobox.
func FindHeader ¶ added in v1.0.4
FindHeader returns the infobox header from the WikiText content.
func ReplaceInfoboxHeader ¶ added in v1.0.4
ReplaceInfoboxHeader removes the infobox header and footer from the WikiText content.
Types ¶
type APIClient ¶ added in v1.0.3
APIClient provides methods for making HTTP requests.
func NewAPIClient ¶ added in v1.0.3
func NewAPIClient() *APIClient
NewAPIClient creates a new instance of APIClient.
type AcceptedNames ¶
type AcceptedNames struct {
Names []string `json:"names"`
}
type Cache ¶ added in v1.0.3
type Cache struct {
// contains filtered or unexported fields
}
Cache represents a cache for storing fetched data.
type CacheRaidRepository ¶ added in v1.0.3
type CacheRaidRepository struct { Repository RaidRepository Cache *Cache }
func (*CacheRaidRepository) GetRaid ¶ added in v1.0.3
func (c *CacheRaidRepository) GetRaid(guildID string) (*Raid, error)
GetRaid retrieves a raid by guild ID from the cache if available; otherwise, it fetches the raid using the wrapped RaidRepository and stores it in the cache.
func (*CacheRaidRepository) SaveRaid ¶ added in v1.0.3
func (c *CacheRaidRepository) SaveRaid(raid *Raid) error
SaveRaid saves a raid using the wrapped RaidRepository and updates the cache accordingly.
type ConsolePresenter ¶ added in v0.0.7
type ConsolePresenter struct{}
ConsolePresenter presents player rankings and tournaments on the console.
func (*ConsolePresenter) PresentRankings ¶ added in v0.0.7
func (p *ConsolePresenter) PresentRankings(rankings []PlayerRanking)
PresentRankings prints the player rankings.
func (*ConsolePresenter) PresentTournaments ¶ added in v0.0.7
func (p *ConsolePresenter) PresentTournaments(tournaments []Tournament)
PresentTournaments prints the tournament information.
type DefaultTimeFormatter ¶ added in v0.0.7
type DefaultTimeFormatter struct {
// contains filtered or unexported fields
}
DefaultTimeFormatter is a default implementation of TimeFormatter.
func NewDefaultTimeFormatter ¶ added in v0.0.7
func NewDefaultTimeFormatter(layout string) *DefaultTimeFormatter
NewDefaultTimeFormatter creates a new instance of DefaultTimeFormatter.
type DocumentFetcher ¶ added in v0.0.7
DocumentFetcher retrieves HTML documents from a source.
type FetcherCache ¶ added in v1.0.3
type FetcherCache struct { DocumentFetcher DocumentFetcher Cache *Cache }
FetcherCache is a wrapper around DocumentFetcher that adds caching functionality.
type Gate ¶
type Gate struct { Status int64 `json:"status"` Date string `json:"date"` Members map[string]*RaidMember `json:"members"` }
Gate represents a gate in a raid.
func (*Gate) GetMember ¶
func (g *Gate) GetMember(userID string) *RaidMember
GetMember retrieves a raid member from the gate based on the user ID.
func (*Gate) RemoveMember ¶
RemoveMember removes a raid member from the gate.
type HTTPDocumentFetcher ¶ added in v0.0.7
type HTTPDocumentFetcher struct {
Client *APIClient
}
HTTPDocumentFetcher provides methods for fetching HTML documents.
func NewHTTPDocumentFetcher ¶ added in v1.0.4
func NewHTTPDocumentFetcher() *HTTPDocumentFetcher
NewHTTPDocumentFetcher creates a new instance of HTTPDocumentFetcher.
type JSONNameRepository ¶ added in v0.0.7
type JSONNameRepository struct {
FilePath string
}
JSONNameRepository is an implementation of the NameRepository using a JSON file.
func (*JSONNameRepository) GetNames ¶ added in v0.0.7
func (r *JSONNameRepository) GetNames() (AcceptedNames, error)
GetNames retrieves the accepted names from a JSON file.
type KioskCache ¶ added in v1.0.3
type KioskCache struct { Manager *KioskManager Cache *Cache }
func NewKioskCache ¶ added in v1.0.3
func NewKioskCache(manager *KioskManager, duration time.Duration) *KioskCache
NewKioskCache creates a new instance of KioskCache.
func (*KioskCache) AddItem ¶ added in v1.0.3
func (kc *KioskCache) AddItem(name, itemType string, item KioskItem)
AddItem adds a new item to the kiosk and updates the cache accordingly.
func (*KioskCache) GetItem ¶ added in v1.0.3
func (kc *KioskCache) GetItem(name string) (KioskItem, error)
GetItem retrieves an item from the kiosk based on its name. It first checks the cache and returns the item if found. If not found in the cache, it retrieves the item from the underlying KioskManager and updates the cache.
func (*KioskCache) GetKiosk ¶ added in v1.0.3
func (kc *KioskCache) GetKiosk() (Kiosk, error)
GetKiosk returns a copy of the kiosk from the cache. If the cache is empty, it retrieves the kiosk from the underlying KioskManager and updates the cache.
func (*KioskCache) GetLastUpdated ¶ added in v1.0.3
func (kc *KioskCache) GetLastUpdated() int64
GetLastUpdated returns the last updated timestamp of the kiosk.
func (*KioskCache) RemoveItem ¶ added in v1.0.3
func (kc *KioskCache) RemoveItem(name, itemType string) error
RemoveItem removes an item from the kiosk based on its name and item type. It updates the cache after removing the item.
type KioskManager ¶ added in v0.0.7
type KioskManager struct {
// contains filtered or unexported fields
}
KioskManager provides methods for managing the kiosk and its items.
func NewKioskManager ¶ added in v0.0.7
func NewKioskManager(id, title string) *KioskManager
NewKioskManager creates a new instance of KioskManager with an empty kiosk.
func (*KioskManager) AddItem ¶ added in v0.0.7
func (km *KioskManager) AddItem(name, itemType string, item KioskItem)
AddItem adds a new item to the kiosk.
func (*KioskManager) GetItem ¶ added in v0.0.7
func (km *KioskManager) GetItem(name string) (KioskItem, error)
GetItem retrieves an item from the kiosk based on its name.
func (*KioskManager) GetKiosk ¶ added in v0.0.7
func (km *KioskManager) GetKiosk() Kiosk
GetKiosk returns a copy of the kiosk.
func (*KioskManager) GetLastUpdated ¶ added in v0.0.7
func (km *KioskManager) GetLastUpdated() int64
GetLastUpdated returns the last updated timestamp of the kiosk.
func (*KioskManager) RemoveItem ¶ added in v0.0.7
func (km *KioskManager) RemoveItem(name, itemType string) error
RemoveItem removes an item from the kiosk based on its name and item type.
type NameGenerator ¶ added in v0.0.7
type NameGenerator struct {
// contains filtered or unexported fields
}
NameGenerator provides methods for generating valid names based on the input and the accepted names list.
func NewNameGenerator ¶ added in v0.0.7
func NewNameGenerator(repo NameRepository) (*NameGenerator, error)
NewNameGenerator creates a new instance of NameGenerator and retrieves the default accepted names from the provided URL.
func (*NameGenerator) GenerateName ¶ added in v0.0.7
func (g *NameGenerator) GenerateName(input string) (string, error)
GenerateName generates a valid name based on the input and the accepted names list.
func (*NameGenerator) GetDefaultNames ¶ added in v1.0.4
func (g *NameGenerator) GetDefaultNames() []string
type NameRepository ¶ added in v0.0.7
type NameRepository interface {
GetNames() (AcceptedNames, error)
}
NameRepository defines the contract for accessing name data.
type PetAttributes ¶
type PetCalculator ¶ added in v0.0.7
type PetCalculator struct{}
PetCalculator provides methods for calculating various attributes based on pet attributes.
func NewPetCalculator ¶ added in v0.0.7
func NewPetCalculator() *PetCalculator
NewPetCalculator creates a new instance of PetCalculator.
func (*PetCalculator) Calculate ¶ added in v0.0.7
func (c *PetCalculator) Calculate(pa *PetAttributes) map[string]map[string]interface{}
Calculate calculates various attributes based on pet attributes.
type PlayerRanking ¶ added in v0.0.6
type PlayerRanking struct { Position string `json:"position"` Name string `json:"name"` Level string `json:"level"` School string `json:"school"` Wins string `json:"wins"` Rating string `json:"rating"` }
PlayerRanking represents the ranking information of a player.
type Presenter ¶ added in v0.0.7
type Presenter interface { PresentRankings(rankings []PlayerRanking) PresentTournaments(tournaments []Tournament) }
Presenter is responsible for presenting data.
type Raid ¶
Raid represents a raid with multiple gates.
type RaidMember ¶
RaidMember represents a member of a raid.
func (*RaidMember) IsBackup ¶
func (r *RaidMember) IsBackup() bool
IsBackup checks if a raid member is a backup.
type RaidRepository ¶ added in v0.0.7
RaidRepository provides methods for accessing raid data.
type RaidService ¶ added in v0.0.7
type RaidService struct {
// contains filtered or unexported fields
}
RaidService provides methods for performing raid-related operations.
func NewRaidService ¶ added in v0.0.7
func NewRaidService(repository RaidRepository) *RaidService
NewRaidService creates a new instance of RaidService.
func (*RaidService) GetRaid ¶ added in v0.0.7
func (s *RaidService) GetRaid(guildID string) (*Raid, error)
GetRaid retrieves a raid by guild ID.
func (*RaidService) SaveRaid ¶ added in v0.0.7
func (s *RaidService) SaveRaid(raid *Raid) error
SaveRaid saves a raid.
type Repository ¶ added in v0.0.7
type Repository struct { DocumentFetcher DocumentFetcher URL string }
Repository retrieves data from a source.
func NewRepository ¶ added in v0.0.7
func NewRepository(fetcher DocumentFetcher, url string) *Repository
NewRepository creates a new instance of Repository.
func (*Repository) FetchRankings ¶ added in v0.0.7
func (r *Repository) FetchRankings() ([]PlayerRanking, error)
FetchRankings retrieves the player rankings.
func (*Repository) FetchTournaments ¶ added in v0.0.7
func (r *Repository) FetchTournaments() ([]Tournament, error)
FetchTournaments retrieves the tournaments.
type TimeFormatter ¶ added in v0.0.7
TimeFormatter provides methods for formatting time.
type TimeService ¶ added in v0.0.7
type TimeService struct {
// contains filtered or unexported fields
}
TimeService provides methods for working with time.
func NewTimeService ¶ added in v0.0.7
func NewTimeService(formatter TimeFormatter) *TimeService
NewTimeService creates a new instance of TimeService.
type Tournament ¶ added in v0.0.4
type Tournament struct { Name string `json:"name"` Levels string `json:"levels"` StartTime string `json:"start_time"` Duration string `json:"duration"` }
Tournament represents the information of a tournament.
type URLGenerator ¶ added in v0.0.7
type URLGenerator struct {
// contains filtered or unexported fields
}
URLGenerator is responsible for generating URLs with parameters.
func NewURLGenerator ¶ added in v0.0.7
func NewURLGenerator(baseURL string) *URLGenerator
NewURLGenerator creates a new instance of URLGenerator.
func (*URLGenerator) GenerateURL ¶ added in v0.0.7
func (g *URLGenerator) GenerateURL() (string, error)
GenerateURL generates a URL with the provided parameters.
func (*URLGenerator) WithParams ¶ added in v0.0.7
func (g *URLGenerator) WithParams(params *URLParams) *URLGenerator
WithParams sets the parameters for the URLGenerator.
type URLNameRepository ¶ added in v0.0.7
type URLNameRepository struct {
URL string
}
URLNameRepository is an implementation of the NameRepository using a remote URL.
func (*URLNameRepository) GetNames ¶ added in v0.0.7
func (r *URLNameRepository) GetNames() (AcceptedNames, error)
GetNames retrieves the accepted names from a remote URL.
type URLParser ¶ added in v0.0.7
type URLParser struct {
// contains filtered or unexported fields
}
URLParser is responsible for parsing URL parameters.
func NewURLParser ¶ added in v0.0.7
NewURLParser creates a new instance of URLParser.
type WikiResponse ¶ added in v1.0.3
type WikiService ¶ added in v1.0.3
type WikiService struct {
Client *APIClient
}
WikiService provides methods for interacting with the Wizard101 Central Wiki.
func NewWikiService ¶ added in v1.0.3
func NewWikiService() *WikiService
NewWikiService creates a new instance of WikiService.
func (*WikiService) GetWikiText ¶ added in v1.0.3
func (s *WikiService) GetWikiText(pageID string) (WikiResponse, error)
GetWikiText returns the WikiText content of the specified page.
func (*WikiService) ParseToJson ¶ added in v1.0.4
func (s *WikiService) ParseToJson(pageID string) ([]byte, error)
ParseToJson converts the infobox in the WikiText content to a JSON string.
func (*WikiService) ParseWikiText ¶ added in v1.0.4
func (s *WikiService) ParseWikiText(body []byte) (*WikiResponse, error)
ParseWikiText parses the response body into a WikiResponse struct.