Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotInPack = errors.New("card picked not in pack") ErrNoPacksLeft = errors.New("no packs left to open") ErrNoPendingPack = errors.New("no packs received from other players") )
Errors that can happen during draft
Functions ¶
This section is empty.
Types ¶
type AlternateProvider ¶
type AlternateProvider struct { Probability float32 Provider CardProvider }
AlternateProvider are Card providers that can replace one or more slots with special cards (foils, ultra rares)
type CardProvider ¶
CardProvider is a function that returns as many cards of a certain types as needed
type GenericCube ¶
GenericCube is a "consumable" set, meaning cards get taken out of the pool as they are put in packs
func (*GenericCube) PackSchema ¶
func (c *GenericCube) PackSchema() PackSchema
PackSchema returns the pack schema from a booster containing all possible cards
func (*GenericCube) RandomProvider ¶
func (c *GenericCube) RandomProvider() CardProvider
RandomProvider returns a provider for random cards from the set
type GenericSet ¶
type GenericSet struct { Cards []Card PackSize int Alternates []AlternateProvider }
GenericSet is an generalized set of a card game Treat this as an example implementation or a starting
Example ¶
ExampleGenericSet is an example usage of the Set APIs to make packs
package main import ( "fmt" "git.fromouter.space/mcg/draft" ) func main() { // Create a set with some items s := &draft.GenericSet{ Cards: []draft.Card{ {ID: "a"}, {ID: "b"}, {ID: "c"}, }, PackSize: 5, } // Create a pack pack := draft.MakePack(s) // Print cards in pack for i, card := range pack { fmt.Printf("Card #%d: %s\n", i, card.ID) } }
Output:
func (*GenericSet) PackSchema ¶
func (g *GenericSet) PackSchema() PackSchema
PackSchema returns the pack schema from a booster containing all possible cards
func (*GenericSet) RandomProvider ¶
func (g *GenericSet) RandomProvider() CardProvider
RandomProvider returns a provider for random cards from the set
type Pack ¶
type Pack []Card
Pack is a collection of cards from a booster pack
func MakePack ¶
MakePack makes a booster pack from a given set It's a shortcut to `MakePackWithSchema(set.PackSchema())`
func MakePackWithSchema ¶
func MakePackWithSchema(schema PackSchema) Pack
MakePackWithSchema makes a booster pack from a given schema
type PackProvider ¶
type PackProvider func() []Pack
PackProvider is a function that returns one or more packs, used for pods
func PacksFromSchema ¶
func PacksFromSchema(count int, schema PackSchema) PackProvider
PacksFromSchema is a PackProvider for a schema
func PacksFromSet ¶
func PacksFromSet(count int, set Set) PackProvider
PacksFromSet is a PackProvider for a set
type PackSchema ¶
type PackSchema struct {
Slots []PackSlot
}
PackSchema is all that's needed to generate a certain type of pack
type PackSlot ¶
type PackSlot struct { Amount int Provider CardProvider Alternate []AlternateProvider }
PackSlot is part of how packs are made, one or more providers provide cards for X cards of the whole pack
type Player ¶
type Player struct { // Packs and picks CurrentPack Pack Packs []Pack Picks []Card // contains filtered or unexported fields }
Player is a single player partecipating in a pod
type Pod ¶
type Pod struct { Players []*Player Direction PodDirection ReadyNextPick chan bool ReadyNextPack chan bool }
Pod is a group of players drafting packs/cubes
func MakePod ¶
func MakePod(playerCount int, provider PackProvider) *Pod
MakePod creates a pod with a specified number of players and a given set of packs
type PodDirection ¶
type PodDirection string
PodDirection is the direction packs are passed between players
var ( PRClockwise PodDirection = "left" PRAnticlockwise PodDirection = "right" )
All rotations
type Set ¶
type Set interface {
PackSchema() PackSchema
}
Set is an interface for all game sets/expansions