multiverse

package
v0.0.0-...-abe374c Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2017 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BorderColors = struct {
	White, Black, Silver BorderColor
}{1, 2, 3}

The borders that cards have.

View Source
var Formats = struct {
	Standard, Extended, Modern, Vintage, Legacy, Un *Format

	List []*Format
}{
	&Format{standardSetLegal, "standard"},
	&Format{extendedSetLegal, "extended"},
	&Format{modernSetLegal, "modern"},
	&Format{vintageSetLegal, "vintage"},
	&Format{legacySetLegal, "legacy"},
	&Format{unSet, "un"},

	nil,
}

The deck formats we know about. (Standard, Extended, Modern, etc.)

View Source
var ManaColors = struct {
	Colorless, White, Blue, Black, Red, Green ManaColor
}{0, 1, 2, 4, 8, 16}

The colors of mana that exist in the Multiverse.

View Source
var Rarities = struct {
	Common, Uncommon, Rare, Mythic, Basic, Special Rarity
}{1, 2, 3, 4, 5, 6}

Rarities of cards.

View Source
var SetTypes = struct {
	Core, Expansion, Reprint, Box, Un, FromTheVault, PremiumDeck, DuelDeck, Starter, Commander, Planechase, Archenemy SetType
}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}

Set types.

View Source
var Sorts = struct {
	Name, Cmc Comparison
}{
	nameSort,
	cmcSort,
}

Sorts are built-in sorts available for use.

View Source
var SuperTypes = struct {
	Basic, Elite, Legendary, Ongoing, Snow, World SuperType
}{32, 16, 8, 4, 2, 1}

SuperType values.

View Source
var Types = struct {
	Artifact, Creature, Enchantment, Instant, Land, Planeswalker, Sorcery, Tribal Type
}{128, 64, 32, 16, 8, 4, 2, 1}

Type values.

Functions

This section is empty.

Types

type And

type And []Filter

And allows us to search for multiple conditions that must be true.

func (And) Ok

func (a And) Ok(c *Card) (bool, error)

Ok makes And usable as a Filter.

type BorderColor

type BorderColor byte

BorderColor indicates the color of card borders within a Set.

type Card

type Card struct {
	Name string

	Cmc    float32
	Cost   string
	Colors ManaColor

	Supertypes SuperType
	Types      Type
	Subtypes   []string

	Text   string
	Flavor string

	Artist string
	Number string

	Power, Toughness usuallyNumeric
	Loyalty          int

	Rulings []Ruling

	Printings []Printing `json:"-"`

	Restricted, Banned []*Format
	// contains filtered or unexported fields
}

Card is a Magic: The Gathering card, such as Ætherling or Blightning.

func (*Card) Is

func (c *Card) Is(f Filter) bool

func (Card) String

func (c Card) String() string

type CardList

type CardList []*Card

func (CardList) Len

func (c CardList) Len() int

func (*CardList) Sort

func (c *CardList) Sort(f Comparison)

Sort the results based on the given comparison.

type Comparison

type Comparison func(*Card, *Card) bool

Comparison takes two cards and determines which is less than the other. See: sort.Interface.Less.

func (Comparison) Asc

func (c Comparison) Asc(a, b *Card) bool

Asc is a generated method that allows explicit specification that a sort will be ascending. It will follow the same sorting method as the base function.

func (Comparison) Desc

func (c Comparison) Desc(a, b *Card) bool

Desc is a generated method that allows a sort to be reversed without needing to write a wrapper.

type Cond

type Cond map[string]interface{}

Cond provides a way to search for non-builtin properties without resorting to a custom type.

func (Cond) Ok

func (c Cond) Ok(card *Card) (bool, error)

Ok makes Cond usable as a Filter.

type Filter

type Filter interface {
	Ok(*Card) (bool, error)
}

Filter is a way to search through cards.

type Format

type Format struct {
	SetOk func(*Set) bool
	Name  string
}

Format represents a sanctioned Magic the Gathering format.

func (*Format) GobDecode

func (f *Format) GobDecode(name []byte) error

GobDecode allows a Format to be restored using the encoding/gob package.

func (*Format) GobEncode

func (f *Format) GobEncode() ([]byte, error)

GobEncode allows a Format to be saveed using the encoding/gob package.

func (*Format) MarshalJSON

func (f *Format) MarshalJSON() ([]byte, error)

JsonEncode allows a Format to be saveed using the encoding/json package.

func (Format) Ok

func (f Format) Ok(c *Card) (bool, error)

Ok allows Formats to also act as a Filter for searching.

func (*Format) UnmarshalJSON

func (f *Format) UnmarshalJSON(name []byte) error

JsonDecode allows a Format to be restored using the encoding/json package.

type Func

type Func func(*Card) bool

Func is a generic type that allows a client to pass in any function that makes a boolean decision based on a card.

func (Func) Ok

func (f Func) Ok(c *Card) (bool, error)

Ok makes a Func usable as a Filter.

type ManaColor

type ManaColor byte

ManaColor is a bitmask of possible Mana Colors.

func (ManaColor) Ok

func (m ManaColor) Ok(c *Card) (bool, error)

Ok makes ManaColor usable as a Filter.

func (ManaColor) String

func (m ManaColor) String() string

type ManaCost

type ManaCost []ManaType

func ParseCost

func ParseCost(s string) (ManaCost, error)

func (ManaCost) Cmc

func (m ManaCost) Cmc() float32

func (ManaCost) String

func (m ManaCost) String() string

type ManaType

type ManaType interface {
	Cmc() float32
	Color() ManaColor
	String() string
}

ManaType represents a single circle within a manacost. The MSB represents Phyrexian mana,

type Multiverse

type Multiverse struct {
	Sets     []Set
	Cards    []Card
	Modified time.Time
}

Multiverse is an entire Magic: The Gathering multiverse. It contains the available cards, sets, formats, and legality information, as well as ways to interpret, manipulate, and filter that data.

func Read

func Read(r io.Reader) (m Multiverse, err error)

Read the multiverse from the provided reader.

func (Multiverse) FuzzyNameSearch

func (m Multiverse) FuzzyNameSearch(searchPhrase string, count int) CardList

FuzzyNameSearch searches for a card with a similar name to the searchPhrase, and returns count or less of the most likely results.

func (Multiverse) Loaded

func (m Multiverse) Loaded() bool

func (Multiverse) Search

func (m Multiverse) Search(f Filter) (CardList, error)

Search for cards that match the given conditions.

func (Multiverse) Write

func (m Multiverse) Write(w io.Writer) error

Write the multiverse to the provided writer.

func (Multiverse) WriteCompressLevel

func (m Multiverse) WriteCompressLevel(w io.Writer, compressionLevel int) error

WriteCompressLevel writes the multiverse to the provided writer with the given level of compression.

type MultiverseID

type MultiverseID int32

MultiverseID is a unique ID for a single printing of a card.

func (MultiverseID) Ok

func (m MultiverseID) Ok(c *Card) (bool, error)

Ok makes MultiverseID usable as a filter.

type Not

type Not struct {
	Filter
}

Not allows us to search for exclusive conditions.

func (Not) Ok

func (n Not) Ok(c *Card) (bool, error)

Ok makes Not usable as a Filter.

type Or

type Or []Filter

Or allows us to search for multiple conditions that at least one of must be true. Performs short-circuit evaluation.

func (Or) Ok

func (o Or) Ok(c *Card) (bool, error)

Ok makes Or usable as a Filter.

type Printing

type Printing struct {
	ID     MultiverseID
	Set    *Set
	Rarity Rarity
}

Printing represents a specific printing of a card, Cancel from M10 is different from Cancel from M11.

type Rarity

type Rarity byte

Rarity of a card for a specific printing.

func (Rarity) Ok

func (r Rarity) Ok(c *Card) (bool, error)

Ok makes Rarity usable as a Filter.

type Ruling

type Ruling struct {
	Date time.Time
	Text string
}

Ruling is a ruling made by a judge that can clarify difficult situations that may arise.

type Set

type Set struct {
	Name     string
	Code     string
	Released time.Time
	Border   BorderColor
	Type     SetType
	Block    string
	Cards    []MultiverseID
	// contains filtered or unexported fields
}

Set is a Magic: The Gathering set, such as Innistrad or Zendikar.

type SetType

type SetType byte

SetType indicates the various set types.

type SuperType

type SuperType byte

SuperType indicates the various SuperTypes.

func (SuperType) Ok

func (s SuperType) Ok(c *Card) (bool, error)

Ok makes SuperType useable as a Filter.

func (SuperType) String

func (s SuperType) String() string

type Type

type Type byte

Type indicates the various Types.

func (Type) Ok

func (t Type) Ok(c *Card) (bool, error)

Ok makes Type usable as a filter.

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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