Documentation ¶
Index ¶
- Constants
- Variables
- func NewLeaderboardViewport(content, title string)
- func NewPuzzleViewport(puzzle *Puzzle)
- type Day
- type Leaderboard
- type LeaderboardModel
- type LoadUserModel
- type Placing
- type Puzzle
- func (p *Puzzle) Display()
- func (p *Puzzle) GetBucketName() string
- func (p *Puzzle) GetID() string
- func (p *Puzzle) GetPrettyPageData() []string
- func (p *Puzzle) GetUserInput() ([]byte, error)
- func (p *Puzzle) MarshalData() ([]byte, error)
- func (p *Puzzle) ReloadPuzzleData() error
- func (p *Puzzle) SaveResource()
- func (p *Puzzle) SubmitAnswer(answer string, part int) (int, string)
- type PuzzleModel
- type Submission
- type User
- type Value
- type ViewableLB
- type Year
Constants ¶
const ( IncorrectAnswer int = iota CorrectAnswer WarningAnswer // Not submitted, but weird behavior NeutralAnswer // Not submitted, but no warning )
Answer Response types
const PUZZLE_URL = "https://adventofcode.com/%v/day/%v"
Base URL for a single day's puzzle
Variables ¶
var UseHighPerformanceRenderer = false
var ViewportWidth = 80
Functions ¶
func NewLeaderboardViewport ¶
func NewLeaderboardViewport(content, title string)
func NewPuzzleViewport ¶
func NewPuzzleViewport(puzzle *Puzzle)
Types ¶
type Leaderboard ¶ added in v1.2.0
type Leaderboard struct { Year int Day int FirstHundred []*Placing SecondHundred []*Placing BucketName string }
Leaderboard is a wrapper for either a yearly or daily leaderboard
func LoadOrCreateLeaderboard ¶ added in v1.2.0
func LoadOrCreateLeaderboard(year, day int) *Leaderboard
LoadOrCreateLeaderboard will create a leaderboard object based on the parameters. If you want to create a leaderboard for an entire year, pass in 0 for day
func (*Leaderboard) GetBucketName ¶ added in v1.2.0
func (lb *Leaderboard) GetBucketName() string
func (*Leaderboard) GetContent ¶ added in v1.2.0
func (lb *Leaderboard) GetContent() string
GetContent will get the lb content in a printable format
func (*Leaderboard) GetID ¶ added in v1.2.0
func (lb *Leaderboard) GetID() string
func (*Leaderboard) GetTitle ¶ added in v1.2.0
func (lb *Leaderboard) GetTitle() string
GetTitle will get the appropriate viewport title for the leaderboard
func (*Leaderboard) LoadPlacings ¶ added in v1.2.0
func (lb *Leaderboard) LoadPlacings()
LoadPlacings will load all of the placings for a given year or date
func (*Leaderboard) MarshalData ¶ added in v1.2.0
func (lb *Leaderboard) MarshalData() ([]byte, error)
func (*Leaderboard) SaveResource ¶ added in v1.2.0
func (lb *Leaderboard) SaveResource()
type LeaderboardModel ¶
type LeaderboardModel struct {
// contains filtered or unexported fields
}
func (LeaderboardModel) Init ¶
func (m LeaderboardModel) Init() tea.Cmd
func (LeaderboardModel) View ¶
func (m LeaderboardModel) View() string
type LoadUserModel ¶
type LoadUserModel struct {
// contains filtered or unexported fields
}
LoadUserModel is the BubbleTea model for loading and displaying a user's information
func (LoadUserModel) Init ¶
func (m LoadUserModel) Init() tea.Cmd
func (LoadUserModel) View ¶
func (m LoadUserModel) View() string
type Placing ¶
type Placing struct { DisplayName string UserID string Position int IsSupporter bool // UserLink is the link for the username UserLink string // SponsorLink is the link for the user's associated sponsor SponsorLink string // FinishTime is only used for daily leaderboards FinishTime string // Score is only used for yearly leaderboards Score int }
Placing represents a single placing on a leaderboard
type Puzzle ¶
type Puzzle struct { SessionToken string Day int Year int BucketID string URL string Title string ArticleOne []string AnswerOne string ArticleTwo []string AnswerTwo string UserInput []byte Submissions map[int][]*Submission LockoutEnd time.Time }
Puzzle represents a single day's puzzle. Consists of user info as well as page display info.
func LoadOrCreatePuzzle ¶
LoadOrCreatePuzzle attempts to load the requested puzzle from storage. If it's unable to be loaded, it will attempt to be created, loading the information from the website.
func (*Puzzle) GetBucketName ¶
func (*Puzzle) GetPrettyPageData ¶
GetPrettyPageData parses the puzzle's stored information and displays it in a visually pleasing way.
func (*Puzzle) GetUserInput ¶
GetUserInput returns the input for the associated puzzle.
func (*Puzzle) MarshalData ¶
func (*Puzzle) ReloadPuzzleData ¶
Reloads puzzle information from the server
func (*Puzzle) SaveResource ¶
func (p *Puzzle) SaveResource()
type PuzzleModel ¶
type PuzzleModel struct {
// contains filtered or unexported fields
}
func (PuzzleModel) Init ¶
func (m PuzzleModel) Init() tea.Cmd
func (PuzzleModel) View ¶
func (m PuzzleModel) View() string
type Submission ¶
type Submission struct {
// contains filtered or unexported fields
}
func NewSubmission ¶
func NewSubmission(data *http.Response, answer string) (*Submission, error)
type User ¶
User represents a session token and accompanying puzzles.
func NewUser ¶
Creates a new user based on a provided session token. If none is provided, it'll be loaded from environment variable or from config file.
func (*User) LoadDisplayName ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Possible submission value for a puzzle