mlp

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCardID = errors.New("invalid card id")
	ErrCardNotFound  = errors.New("card not found in their set")
)

Errors involving loading cards

View Source
var (
	ErrSetNotLoaded = errors.New("set not loaded")
)

Errors

View Source
var HTTPClient = http.DefaultClient

HTTPClient is the HTTP client used in LoadSetHTTP

View Source
var HTTPSource = "https://mcg.zyg.ovh/setdata/"

HTTPSource is the base URL for fetching sets remotely via HTTP

Functions

func BlockPacks

func BlockPacks(block BlockID) (draft.PackProvider, error)

BlockPacks returns a pack provider for a block draft

func CleanSetCache

func CleanSetCache()

CleanSetCache removes all loaded sets from memory

func LoadAllSets added in v0.0.4

func LoadAllSets() error

LoadAllSets just loads all sets from the web

func LoadSetData

func LoadSetData(sets map[SetID][]byte) error

LoadSetData loads sets from data

func ToDraft added in v0.0.2

func ToDraft(cards []Card) []draft.Card

ToDraft converts multiple mlp.Card to draft.Card

Types

type BlockID

type BlockID string

BlockID denotes a certain block

const (
	BlockPremiere  BlockID = "PR" // Premiere block - PR/CN/CG/AD
	BlockOdyssey   BlockID = "EO" // Odyssey block - EO/HM/MT
	BlockDefenders BlockID = "DE" // Defenders block - DE/SB/FF
)

All blocks

type Card

type Card struct {
	ID                   string
	Name                 string
	Subname              string
	Element              []string
	Keywords             []string
	Traits               []string
	Requirement          PowerRequirement `json:",omitempty"`
	Cost                 *int             `json:",omitempty"`
	Power                *int             `json:",omitempty"`
	Type                 string
	Text                 string
	Rarity               Rarity
	ProblemBonus         *int             `json:",omitempty"`
	ProblemOpponentPower int              `json:",omitempty"`
	ProblemRequirement   PowerRequirement `json:",omitempty"`
	Boosted              *Card            `json:",omitempty"`
}

Card is a single MLP:CCG card in a set

func LoadCardList added in v0.0.2

func LoadCardList(list []string, fetch bool) (out []Card, err error)

LoadCardList loads cards from sets, fetching them from HTTP if needed/wanted

func (Card) ToDraftCard

func (c Card) ToDraftCard() draft.Card

ToDraftCard converts cards to draft.Card

type I8PCube

type I8PCube struct {
	Main     *I8PSet
	Problems *I8PSet
}

I8PCube is a cube that uses I8Pages' pack schema. I8Pages' cube uses different kinds of packs, so a single schema is not possible. Therefore, I8PCube itself is not a valid set, but contains two valid sets for both types of packs (main deck / problems)

Infos on I8Pages' cube: https://docs.google.com/spreadsheets/d/1Ufz4QLwLCZ1vLemAhE6cuAmu2lq_VAN7RhLO9p1opNQ

func MakeI8PCube

func MakeI8PCube(cards I8PPool, schema I8PSchema, problemPackSize int) *I8PCube

MakeI8PCube takes an organized set of cards and sorts them into a draftable I8PCube

func (*I8PCube) PackProvider

func (c *I8PCube) PackProvider(mainPacks, problemPacks int) draft.PackProvider

PackProvider returns a PackProvider for a given number of main and problem packs

type I8PPool

type I8PPool map[I8PType][]Card

I8PPool is a pool of card divided into categories

type I8PSchema

type I8PSchema []I8PSchemaSlot

I8PSchema is a schema to seed a single I8PCube pack

func DefaultI8PSchema

func DefaultI8PSchema() I8PSchema

DefaultI8PSchema returns I8Pages' schema as specified in his docs

type I8PSchemaSlot

type I8PSchemaSlot struct {
	Amount int
	Type   I8PType
}

I8PSchemaSlot is a single slot of a I8PSchema

type I8PSet

type I8PSet struct {
	Cards  I8PPool
	Schema draft.PackSchema
}

I8PSet is one of the sets of packs contained in a I8PCube

func (*I8PSet) PackSchema

func (s *I8PSet) PackSchema() draft.PackSchema

PackSchema returns the pack schema for building packs from a I8PCube

func (*I8PSet) ProviderByType

func (s *I8PSet) ProviderByType(typ I8PType) draft.CardProvider

ProviderByType provides cards from a specified category

func (*I8PSet) ProviderOther

func (s *I8PSet) ProviderOther() draft.CardProvider

ProviderOther picks a random card for any available set (except Problems)

type I8PType

type I8PType string

I8PType is a category of cards to be seeded into packs

const (
	I8PTypeBlue    I8PType = "blue"
	I8PTypeOrange  I8PType = "orange"
	I8PTypePink    I8PType = "pink"
	I8PTypePurple  I8PType = "purple"
	I8PTypeWhite   I8PType = "white"
	I8PTypeYellow  I8PType = "yellow"
	I8PTypeNone    I8PType = "none"
	I8PTypeMulti   I8PType = "multi"
	I8PTypeEntry   I8PType = "entry"
	I8PTypeProblem I8PType = "problem"

	// Special types
	I8PTypeAll I8PType = "all" // all means "from any other non-problem type"
)

All types used for seeding packs

type PowerRequirement

type PowerRequirement map[string]int

PowerRequirement denotes one or more power requirements, colored or not

type Rarity

type Rarity string

Rarity denotes a card's rarity

const (
	RarityCommon    Rarity = "C"
	RarityUncommon  Rarity = "U"
	RarityRare      Rarity = "R"
	RaritySuperRare Rarity = "SR"
	RarityUltraRare Rarity = "UR"
	RarityRoyalRare Rarity = "RR"
)

All card rarities

type Set

type Set struct {
	ID       SetID
	Name     string
	CardList []draft.Card
	CardData map[string]Card
}

Set is a set/expansion of MLP:CCG

func LoadSetBytes

func LoadSetBytes(id SetID, setdata []byte) (*Set, error)

LoadSetBytes loads a set with a specified ID from JSON

func LoadSetHTTP

func LoadSetHTTP(id SetID) (*Set, error)

LoadSetHTTP loads a set using MCG's remote server

func LoadSetMemory

func LoadSetMemory(id SetID) (*Set, error)

LoadSetMemory loads a set from memory (must have been previously loaded with LoadSetData or other functions)

func (*Set) PackSchema

func (set *Set) PackSchema() draft.PackSchema

PackSchema returns the pack schema from a booster box for a specific set

func (*Set) ProviderByRarity

func (set *Set) ProviderByRarity(rarity Rarity) draft.CardProvider

ProviderByRarity returns a provider for a given rarity level from a given set

type SetID

type SetID string

SetID denotes a card's set

const (
	SetPremiere             SetID = "PR"
	SetCanterlotNights      SetID = "CN"
	SetRockNRave            SetID = "RR"
	SetCelestialSolstice    SetID = "CS"
	SetCrystalGames         SetID = "CG"
	SetAbsoluteDiscord      SetID = "AD"
	SetEquestrialOdysseys   SetID = "EO"
	SetHighMagic            SetID = "HM"
	SetMarksInTime          SetID = "MT"
	SetDefendersOfEquestria SetID = "DE"
	SetSeaquestriaBeyond    SetID = "SB"
	SetFriendsForever       SetID = "FF"
	SetPromo                SetID = "Promo"
)

All sets

Jump to

Keyboard shortcuts

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