bggtools

package module
v0.0.0-...-276bf52 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 10 Imported by: 0

README

Building a bunch of little scripts to help me turn my ranking of my favorite solo games into a BGG list as part of the yearly 1 Player Guild vote.

The latest list can be found here: https://boardgamegeek.com/geeklist/327213

Documentation

Index

Constants

View Source
const (
	// CollectionTypeOwn is the owned items
	CollectionTypeOwn gobgg.CollectionType = "own"
	// CollectionTypeRated is rated items
	CollectionTypeRated gobgg.CollectionType = "rated"
	// CollectionTypePlayed is played items
	CollectionTypePlayed gobgg.CollectionType = "played"
	// CollectionTypeComment is commented items
	CollectionTypeComment gobgg.CollectionType = "comment"
	// CollectionTypeTrade is in trade list item
	CollectionTypeTrade gobgg.CollectionType = "trade"
	// CollectionTypeWant is in want list item
	CollectionTypeWant gobgg.CollectionType = "want"
	// CollectionTypeWishList is the wishlist items
	CollectionTypeWishList gobgg.CollectionType = "wishlist"
	// CollectionTypePreorder is the pre orders item
	CollectionTypePreorder gobgg.CollectionType = "preorder"
	// CollectionTypeWantToPlay is want to play items
	CollectionTypeWantToPlay gobgg.CollectionType = "wanttoplay"
	// CollectionTypeWantToBuy is want to buy items
	CollectionTypeWantToBuy gobgg.CollectionType = "wanttobuy"
	// CollectionTypePrevOwned is previously owned items
	CollectionTypePrevOwned gobgg.CollectionType = "prevowned"
	// CollectionTypeHasParts has parts item
	CollectionTypeHasParts gobgg.CollectionType = "hasparts"
	// CollectionTypeWantParts want parts item
	CollectionTypeWantParts gobgg.CollectionType = "wantparts"
)
View Source
const (
	// WishListPriorityMustHave BGA definition
	WishListPriorityMustHave = iota + 1
	// WishListPriorityLoveToHave BGA definition
	WishListPriorityLoveToHave
	// WishListPriorityLikeToHave BGA definition
	WishListPriorityLikeToHave
	// WishListPriorityThinkingAboutIt BGA definition
	WishListPriorityThinkingAboutIt
	// WishListPriorityDoNotBuy BGA definition
	WishListPriorityDoNotBuy
)
View Source
const BGG_PRIVATE_API_BASE_URL = "https://api.geekdo.com/api"

Variables

View Source
var Top200ListsByYear = map[int]string{
	2014: "182648",
	2015: "200265",
	2016: "217988",
	2017: "233582",
	2018: "248275",
	2019: "264253",
	2020: "277814",
	2021: "291071",
	2022: "306154",
	2023: "324731",
	2024: "345687",
}

Functions

func CollectionBGGRating

func CollectionBGGRating(rate int) gobgg.CollectionOptionSetter

SetBGGRating is the exact bgg rating for this item

func CollectionCollID

func CollectionCollID(collID int64) gobgg.CollectionOptionSetter

func CollectionExcludeSubtype

func CollectionExcludeSubtype(subType ItemType) gobgg.CollectionOptionSetter

SetExcludeSubtype Specifies which subtype you want to exclude from the results.

func CollectionIDs

func CollectionIDs(ids ...int64) gobgg.CollectionOptionSetter

func CollectionMaxPlays

func CollectionMaxPlays(plays int) gobgg.CollectionOptionSetter

SetMaxPlays show games with max plays

func CollectionMinBGGRating

func CollectionMinBGGRating(rate int) gobgg.CollectionOptionSetter

SetMinBGGRating is the minimum bgg rating for this item

func CollectionMinPlays

func CollectionMinPlays(plays int) gobgg.CollectionOptionSetter

SetMinPlays show games with min plays

func CollectionMinRating

func CollectionMinRating(rate int) gobgg.CollectionOptionSetter

SetMinRating is the minimum personal rating for this item for this user

func CollectionModifiedSince

func CollectionModifiedSince(t time.Time) gobgg.CollectionOptionSetter

SetModifiedSince to set the modified since flag

func CollectionRating

func CollectionRating(rate int) gobgg.CollectionOptionSetter

SetRating is the exact personal rating for this item for this user

func CollectionSubType

func CollectionSubType(subType ItemType) gobgg.CollectionOptionSetter

SetSubType Specifies which collection you want to retrieve. TYPE may be boardgame, boardgameexpansion, boardgameaccessory, rpgitem, rpgissue, or videogame; the default is boardgame

func CollectionTypes

func CollectionTypes(typ ...gobgg.CollectionType) gobgg.CollectionOptionSetter

SetCollectionTypes returns the collection types

func CollectionVersion

func CollectionVersion(version bool) gobgg.CollectionOptionSetter

SetVersion Returns version info for each item in your collection.

func GetFromCacheOrBgg

func GetFromCacheOrBgg[T any](cacheFilename string, retriever func(context.Context, *gobgg.BGG) ([]T, error)) ([]T, error)

func GetThingIDs

func GetThingIDs(ids ...int64) gobgg.GetOptionSetter

func PlaysDateRangeMax

func PlaysDateRangeMax(max time.Time) gobgg.PlaysOptionSetter

PlaysDateRangeMax set the min date

func PlaysDateRangeMin

func PlaysDateRangeMin(min time.Time) gobgg.PlaysOptionSetter

PlaysDateRangeMin set the min date

func PlaysGameID

func PlaysGameID(id int) gobgg.PlaysOptionSetter

PlaysGameID to set the game id

func PlaysPageNumber

func PlaysPageNumber(page int) gobgg.PlaysOptionSetter

PlaysPageNumber set the current page

func PlaysUserName

func PlaysUserName(name string) gobgg.PlaysOptionSetter

PlaysUserName for the plays

func WriteGeeklistToDir

func WriteGeeklistToDir(gl Geeklist, dest string) error

Types

type CollectionItem

type CollectionItem gobgg.CollectionItem

func GetCachedCollection

func GetCachedCollection(cacheFilename, username string, options ...gobgg.CollectionOptionSetter) ([]CollectionItem, error)

type Geeklist

type Geeklist struct {
	Type                   string    `json:"type"`
	ID                     string    `json:"id"`
	Name                   string    `json:"name"`
	Creator                int       `json:"creator"`
	Href                   string    `json:"href"`
	Postdate               time.Time `json:"postdate"`
	Editdate               time.Time `json:"editdate"`
	Body                   string    `json:"body"`
	BodyXML                string    `json:"bodyXml"`
	Private                bool      `json:"private"`
	PublicAdditionsAllowed bool      `json:"publicAdditionsAllowed"`
	CommentsAllowed        bool      `json:"commentsAllowed"`
	Trade                  bool      `json:"trade"`
	OrdinalDirection       string    `json:"ordinalDirection"`
	Submitted              bool      `json:"submitted"`
	SortType               string    `json:"sortType"`
	Domains                []string  `json:"domains"`
	CanonicalLink          string    `json:"canonical_link"`
	Links                  []struct {
		Rel string `json:"rel"`
		URI string `json:"uri"`
	} `json:"links"`
	Items GeeklistItems
}

func GetGeeklistByID

func GetGeeklistByID(listid string) (Geeklist, error)

func GetGeeklistFromBGG

func GetGeeklistFromBGG(listid string) (Geeklist, error)

func ReadGeeklistFromFile

func ReadGeeklistFromFile(path string) (Geeklist, error)

func (Geeklist) Year

func (gl Geeklist) Year() int

type GeeklistItems

type GeeklistItems struct {
	Data       []ItemData `json:"data"`
	Pagination struct {
		Pageid  int `json:"pageid"`
		PerPage int `json:"perPage"`
		Total   int `json:"total"`
	} `json:"pagination"`
}

type ItemData

type ItemData struct {
	Type   string `json:"type"`
	ID     string `json:"id"`
	Listid string `json:"listid"`
	Item   struct {
		Type           string `json:"type"`
		ID             string `json:"id"`
		Name           string `json:"name"`
		Href           string `json:"href"`
		Label          string `json:"label"`
		Labelpl        string `json:"labelpl"`
		HasAngularLink bool   `json:"hasAngularLink"`
		Descriptors    []struct {
			Name         string `json:"name"`
			DisplayValue string `json:"displayValue"`
		} `json:"descriptors"`
		Breadcrumbs []any `json:"breadcrumbs"`
		ImageSets   struct {
			Square100 struct {
				Src   string `json:"src"`
				Src2X string `json:"src@2x"`
			} `json:"square100"`
			Mediacard100 struct {
				Src   string `json:"src"`
				Src2X string `json:"src@2x"`
			} `json:"mediacard100"`
			Mediacard struct {
				Src   string `json:"src"`
				Src2X string `json:"src@2x"`
			} `json:"mediacard"`
		} `json:"imageSets"`
		Imageid       int `json:"imageid"`
		NameSortIndex int `json:"nameSortIndex"`
	} `json:"item"`
	Postdate        time.Time `json:"postdate"`
	Editdate        time.Time `json:"editdate"`
	Body            string    `json:"body"`
	BodyXML         string    `json:"bodyXml"`
	Author          int       `json:"author"`
	Href            string    `json:"href"`
	Imageid         int       `json:"imageid"`
	ImageOverridden bool      `json:"imageOverridden"`
	LinkedImage     struct {
		Href  string `json:"href"`
		Alt   string `json:"alt"`
		Image struct {
			Src   string `json:"src"`
			Src2X string `json:"src@2x"`
		} `json:"image"`
		BlocksAds bool `json:"blocks_ads"`
	} `json:"linkedImage"`
	RollsEnabled bool `json:"rollsEnabled"`
	Links        []struct {
		Rel string `json:"rel"`
		URI string `json:"uri"`
	} `json:"links"`
	RollsCount int `json:"rollsCount"`
	Stats      struct {
		Average float64 `json:"average"`
		Rank    int     `json:"rank"`
	} `json:"stats"`
}

func MyTop20Rankings

func MyTop20Rankings(gl Geeklist) []ItemData

type ItemType

type ItemType gobgg.ItemType

type Play

type Play gobgg.Play

func GetCachedPlays

func GetCachedPlays(cacheFilename string, setters ...gobgg.PlaysOptionSetter) ([]Play, error)

type Player

type Player gobgg.Player

type Thing

type Thing gobgg.ThingResult

func GetCachedThings

func GetCachedThings(cacheFilename string, setters ...gobgg.GetOptionSetter) ([]Thing, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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