gdq

package module
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 15 Imported by: 0

README

🏃 GDQ 🎮

A Go library and CLI for Games Done Quick

Build Status Coverage Status Go report card GoDoc

Games Done Quick (GDQ) is a regular speedrunning event that collects money for charity. The event is incredibly fun, especially if you enjoy seeing your favourite games torn to shreds by amazing runners and supported with great commentary and prizes to win.

This repo contains a Go library and CLI for working with the GDQ schedule. It uses the Tracker API to retrieve the data.

There is also a companion Matrix bot over at GDQBot.

Installation

CLI

There are prebuilt binaries available for every release from v1.0.0 onwards. You can find them over here.

Platform Architecture Binary
Windows amd64
macOS amd64
macOS arm64/M1
Linux amd64
Linux arm64
Linux armv7/amrhf
Linux armv6/arm

Library

$ go get github.com/daenney/gdq/v2

Building

You can go get the library, or git clone and then run a go build followed by a go test ./... to ensure everything is OK.

You can build the CLI using go build -trimpath -o gdqctl cmd/gdqcli/*.go or install it directly using go install github.com/daenney/gdq/v2/cmd/gdqcli. See go help install for where the binaries will end up.

To embed the version, commit and date at build time you'll need to add -X main.version=VERSION -X main.commit=SHA -X main.date=DATE and compute the right values yourself.

Contributing

PRs welcome! Fork+clone the repo and send me a patch. Please ensure that:

  • Make small commits that encapsulate one functional change at a time (implementation change, the associated tests and any doc changes)
  • Every commit explains what it's trying to achieve and why
  • The tests pass

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SGDQ2012          = Event{ID: 1, Short: "SGDQ2012", Name: sgdq, Year: 2012}
	AGDQ2012          = Event{ID: 2, Short: "SGDQ2012", Name: agdq, Year: 2012}
	SGDQ2011          = Event{ID: 3, Short: "SGDQ2011", Name: sgdq, Year: 2011}
	JRDQ              = Event{ID: 4, Short: "JRDQ", Name: "Japan Relief Done Quick", Year: 2011}
	AGDQ2011          = Event{ID: 5, Short: "AGDQ2011", Name: agdq, Year: 2011}
	CGDQ              = Event{ID: 6, Short: "CGDQ", Name: "Classic Games Done Quick", Year: 2010}
	AGDQ2013          = Event{ID: 7, Short: "AGDQ2013", Name: agdq, Year: 2013}
	SGDQ2013          = Event{ID: 8, Short: "SGDQ2013", Name: sgdq, Year: 2013}
	AGDQ2014          = Event{ID: 9, Short: "AGDQ2014", Name: agdq, Year: 2014}
	SGDQ2014          = Event{ID: 10, Short: "SGDQ2014", Name: sgdq, Year: 2014}
	AGDQ2015          = Event{ID: 12, Short: "AGDQ2015", Name: agdq, Year: 2015}
	SPOOK             = Event{ID: 13, Short: "SPOOK", Name: "Speedrun Spooktacular", Year: 2012}
	SGDQ2015          = Event{ID: 16, Short: "SGDQ2015", Name: sgdq, Year: 2015}
	AGDQ2016          = Event{ID: 17, Short: "AGDQ2016", Name: agdq, Year: 2016}
	SGDQ2016          = Event{ID: 18, Short: "SGDQ2016", Name: sgdq, Year: 2016}
	AGDQ2017          = Event{ID: 19, Short: "AGDQ2017", Name: agdq, Year: 2017}
	SGDQ2017          = Event{ID: 20, Short: "SGDQ2017", Name: sgdq, Year: 2017}
	HRDQ              = Event{ID: 21, Short: "HRDQ", Name: "Harvey Relief Done Quick", Year: 2017}
	AGDQ2018          = Event{ID: 22, Short: "AGDQ2018", Name: agdq, Year: 2018}
	SGDQ2018          = Event{ID: 23, Short: "SGDQ2018", Name: sgdq, Year: 2018}
	GDQX2018          = Event{ID: 24, Short: "GDQX2018", Name: "Games Done Quick Express", Year: 2018}
	AGDQ2019          = Event{ID: 25, Short: "AGDQ2019", Name: agdq, Year: 2019}
	SGDQ2019          = Event{ID: 26, Short: "SGDQ2019", Name: sgdq, Year: 2019}
	GDQX2019          = Event{ID: 27, Short: "GDQX2019", Name: "Games Done Quick Express", Year: 2019}
	AGDQ2020          = Event{ID: 28, Short: "AGDQ2020", Name: agdq, Year: 2020}
	FrostFatales2020  = Event{ID: 29, Short: "FrostFatales2020", Name: "Frost Fatales", Year: 2020}
	SGDQ2020          = Event{ID: 30, Short: "SGDQ2020", Name: sgdq, Year: 2020}
	CRDQ              = Event{ID: 31, Short: "CRDQ", Name: "Corona Relief Done Quick", Year: 2020}
	THPSLaunch        = Event{ID: 32, Short: "THPSLaunch", Name: "Tony Hawk's Pro Skater 1 + 2 Launch Celebration", Year: 2020}
	FleetFatales2020  = Event{ID: 33, Short: "FleetFatales2020", Name: "Fleet Fatales", Year: 2020}
	AGDQ2021          = Event{ID: 34, Short: "AGDQ2021", Name: agdq + " Online", Year: 2021}
	SGDQ2021          = Event{ID: 35, Short: "SGDQ2021", Name: sgdq + " Online", Year: 2021}
	FlamesFatales2021 = Event{ID: 36, Short: "FlamesFatales2021", Name: "Flames Fatales", Year: 2021}
	AGDQ2022          = Event{ID: 37, Short: "AGDQ2022", Name: agdq + " Online", Year: 2022}
	FrostFatales2022  = Event{ID: 38, Short: "FrostFatales2022", Name: "Frost Fatales", Year: 2022}
	SGDQ2022          = Event{ID: 39, Short: "SGDQ2022", Name: sgdq, Year: 2022}
	FlamesFatales2022 = Event{ID: 40, Short: "FlamesFatales2022", Name: "Flames Fatales", Year: 2022}
	AGDQ2023          = Event{ID: 41, Short: "AGDQ2023", Name: sgdq, Year: 2023}
)

All the GDQ events, sorted by Event.ID

Functions

This section is empty.

Types

type Client

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

Client is a GDQ API client

func New

func New(ctx context.Context, client *http.Client) *Client

New creates a new GDQ API client

func (*Client) Donations added in v2.1.0

func (c *Client) Donations(ev *Event) (*Donations, error)

Donations returns donations for an event

func (*Client) Latest

func (c *Client) Latest() (*Event, error)

Latest returns the latest event

func (*Client) Schedule added in v2.1.0

func (c *Client) Schedule(ev *Event) (*Schedule, error)

Schedule returns the Schedule for a GDQ event

type Donations added in v2.1.0

type Donations struct {
	Total   float64 `json:"total"`
	Max     float64 `json:"max"`
	Count   uint    `json:"count"`
	Average float64 `json:"average"`
}

Donations is the donation summary of a GDQ event

type Duration

type Duration struct {
	time.Duration
}

Duration represents a interval of time

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() (b []byte, err error)

MarshalJSON marshals a Duration to JSON

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a duration like thing from JSON

type Event

type Event struct {
	ID        uint      `json:"id"`
	Short     string    `json:"short"`
	Name      string    `json:"name"`
	Year      int       `json:"year"`
	Donations Donations `json:"donations"`
}

Event is the schedule ID of a GDQ event

func GetEventByID

func GetEventByID(id uint) (ev *Event, found bool)

GetEventByID fetches the event by ID

func GetEventByName

func GetEventByName(input string) (ev *Event, found bool)

GetEventByName tries to find an event matching the input

func (Event) String

func (e Event) String() string

type Run

type Run struct {
	Title    string    `json:"title"`
	Start    time.Time `json:"start"`
	Estimate Duration  `json:"estimate"`
	Runners  Runners   `json:"runners"`
	Hosts    []string  `json:"hosts"`
	Category string    `json:"category"`
	Console  string    `json:"console"`
}

Run represents a single event at a GDQ

type Runner

type Runner struct {
	Handle string `json:"handle"`
	Social social `json:"social"`
}

Runner represents a person running a game

type Runners

type Runners []Runner

Runners is a list of Runner

func (Runners) String

func (r Runners) String() string

type Schedule

type Schedule struct {
	Runs []*Run
	// contains filtered or unexported fields
}

Schedule represents the runs occurring at a GDQ event

func NewSchedule

func NewSchedule() *Schedule

NewSchedule returns an empty Schedule

func NewScheduleFrom

func NewScheduleFrom(runs []*Run) *Schedule

NewScheduleFrom returns a scheduled filled with the runs

func (*Schedule) ForHost

func (s *Schedule) ForHost(name string) *Schedule

ForHost returns a new schedule with runs only matching this host

The host's name is matched using a string submatch. This means that if you call somtething like schedule.ForHust("b") you can get a schedule with runs for multiple hosts.

The match is case insensitive.

func (*Schedule) ForRunner

func (s *Schedule) ForRunner(name string) *Schedule

ForRunner returns a new schedule with runs only matching this runner

The runner's name is matched using a string submatch. This means that if you call somtething like schedule.ForRunner("b") you can get a schedule with runs for multiple runners.

The match is case insensitive.

func (*Schedule) ForTitle

func (s *Schedule) ForTitle(title string) *Schedule

ForTitle returns a new schedule with runs only matching this runs title

The title is matched using a string submatch. This means that if you call somtething like schedule.ForTitle("b") you can get a schedule with multiple runs.

The match is case insensitive.

func (*Schedule) NextRun

func (s *Schedule) NextRun() *Run

NextRun returns the next/upcoming run in the schedule

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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