card

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEntryNotFound = errors.New("entry not found")

Functions

This section is empty.

Types

type Card

type Card struct {
	ID          PrimaryID
	CardSetCode string
	Name        string
	Number      string
	Border      string // ENUM
	Rarity      string // ENUM
	Layout      string // ENUM
	Faces       []*Face
}

Card A complete card including all faces (sides) and translations. The number of a card is unique per set.

func (*Card) Diff added in v0.2.0

func (c *Card) Diff(other *Card) *diff.Changeset

type CharacteristicDao

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

func (*CharacteristicDao) AssignToFace added in v0.2.0

func (d *CharacteristicDao) AssignToFace(faceID int64, typeID int64) error

func (*CharacteristicDao) Create

func (d *CharacteristicDao) Create(name string) (*CharacteristicType, error)

func (*CharacteristicDao) DeleteAllAssignments added in v0.3.2

func (d *CharacteristicDao) DeleteAllAssignments(faceID int64) error

func (*CharacteristicDao) DeleteAssignments

func (d *CharacteristicDao) DeleteAssignments(faceID int64, typeIDs ...int64) error

func (*CharacteristicDao) Find

func (d *CharacteristicDao) Find(names ...string) ([]*CharacteristicType, error)

func (*CharacteristicDao) FindAssignments

func (d *CharacteristicDao) FindAssignments(faceID int64) ([]*CharacteristicType, error)

type CharacteristicType

type CharacteristicType struct {
	ID   PrimaryID
	Name string
}

CharacteristicType A type of card. Can be a Cardtype, Subtype or Superype. Cardtype: Creature, Artifact, Instant, Enchantment ... . Subtype: Archer, Shaman, Nomad, Nymph ... . Supertype: Basic, Host, Legendary, Ongoing, Snow, World.

type Colors added in v0.3.0

type Colors struct {
	sql.NullString
}

func NewColors added in v0.3.0

func NewColors(colors []string) Colors

func (*Colors) UnmarshalJSON added in v0.3.0

func (v *Colors) UnmarshalJSON(data []byte) error

UnmarshalJSON Unmarshal string into colors struct. Required for the card page query.

type Face added in v0.2.0

type Face struct {
	ID                PrimaryID
	Name              string
	Text              string
	FlavorText        string
	TypeLine          string
	MultiverseID      int32
	Artist            string
	ConvertedManaCost float64
	Colors            Colors
	HandModifier      string
	LifeModifier      string
	Loyalty           string
	ManaCost          string
	Power             string
	Toughness         string
	Cardtypes         []string // A list of all card types of the card
	Supertypes        []string // A list of card supertypes found before em-dash.
	Subtypes          []string // A list of card subtypes found after em-dash.
	Translations      []Translation
}

Face The face data of a card.

func (Face) Diff added in v0.2.0

func (f Face) Diff(other *Face) *diff.Changeset

Diff Compares the faces and returns all differences.

type Image added in v0.3.2

type Image struct {
	ID        PrimaryID
	Lang      string
	CardID    PrimaryID
	FaceID    PrimaryID
	ImagePath string
	MimeType  fetch.MimeType
}

func (*Image) BuildFilename added in v0.3.2

func (img *Image) BuildFilename() (string, error)

BuildFilename Returns file name based on the image mime type.

type PostgresCardDao

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

func NewDao

func (*PostgresCardDao) AddFace added in v0.2.0

func (d *PostgresCardDao) AddFace(cardID int64, f *Face) error

AddFace Creates a new card face with a reference to the given card ID.

func (*PostgresCardDao) AddImage added in v0.3.0

func (d *PostgresCardDao) AddImage(img *Image) error

AddImage Creates a new card image.

func (*PostgresCardDao) AddTranslation added in v0.2.0

func (d *PostgresCardDao) AddTranslation(faceID int64, t *Translation) error

AddTranslation Creates a new translation with a reference to the given face ID.

func (*PostgresCardDao) Count

func (d *PostgresCardDao) Count() (int, error)

Count Returns the amount of all cards.

func (*PostgresCardDao) CountImages added in v0.3.0

func (d *PostgresCardDao) CountImages() (int, error)

CountImages Returns the amount of all card images.

func (*PostgresCardDao) CreateCard

func (d *PostgresCardDao) CreateCard(c *Card) error

CreateCard Creates a new card. Will return an error if the card already exists.

func (*PostgresCardDao) DeleteFace added in v0.2.0

func (d *PostgresCardDao) DeleteFace(faceID int64) error

DeleteFace Deletes the face with the given face ID and all references to it.

func (*PostgresCardDao) DeleteTranslation

func (d *PostgresCardDao) DeleteTranslation(faceID int64, lang string) error

DeleteTranslation Deletes a language specific face translation.

func (*PostgresCardDao) FindAssignedCardTypes added in v0.2.0

func (d *PostgresCardDao) FindAssignedCardTypes(faceID int64) ([]string, error)

FindAssignedCardTypes Returns all cardtype that refer to the given face ID.

func (*PostgresCardDao) FindAssignedFaces added in v0.2.0

func (d *PostgresCardDao) FindAssignedFaces(cardID int64) ([]*Face, error)

FindAssignedFaces Returns all card faces for the given card ID.

func (*PostgresCardDao) FindAssignedSubTypes added in v0.2.0

func (d *PostgresCardDao) FindAssignedSubTypes(faceID int64) ([]string, error)

FindAssignedSubTypes Returns all subtypes that refer to the given face ID.

func (*PostgresCardDao) FindAssignedSuperTypes added in v0.2.0

func (d *PostgresCardDao) FindAssignedSuperTypes(faceID int64) ([]string, error)

FindAssignedSuperTypes Returns all supertypes that refer to the given face ID.

func (*PostgresCardDao) FindTranslations

func (d *PostgresCardDao) FindTranslations(faceID int64) ([]*Translation, error)

FindTranslations Returns all translations for the given face ID.

func (*PostgresCardDao) FindUniqueCard

func (d *PostgresCardDao) FindUniqueCard(set string, number string) (*Card, error)

FindUniqueCard Finds the card with the specified set code and number. If no result is found a nil is returned.

func (*PostgresCardDao) IsImagePresent added in v0.3.0

func (d *PostgresCardDao) IsImagePresent(cardID int64, lang string) (bool, error)

IsImagePresent Checks if the card image with the specified card id and language exist.

func (*PostgresCardDao) Paged added in v0.3.0

func (d *PostgresCardDao) Paged(page int, size int) ([]*Card, error)

Paged Returns cards limited by the given size for the given page. The page parameter is one based.

func (*PostgresCardDao) UpdateCard

func (d *PostgresCardDao) UpdateCard(c *Card) error

UpdateCard Updates an exist card with the given data.

func (*PostgresCardDao) UpdateFace added in v0.2.0

func (d *PostgresCardDao) UpdateFace(f *Face) error

UpdateFace Updates an exist card face with the given data.

func (*PostgresCardDao) UpdateTranslation

func (d *PostgresCardDao) UpdateTranslation(faceID int64, t *Translation) error

UpdateTranslation Updates an exist face translation with the given data.

type PrimaryID added in v0.3.2

type PrimaryID struct {
	sql.NullInt64
}

func NewPrimaryID added in v0.3.2

func NewPrimaryID(id int64) PrimaryID

func (PrimaryID) Get added in v0.3.2

func (v PrimaryID) Get() int64

func (*PrimaryID) MarshalJSON added in v0.3.2

func (v *PrimaryID) MarshalJSON() ([]byte, error)

func (*PrimaryID) UnmarshalJSON added in v0.3.2

func (v *PrimaryID) UnmarshalJSON(data []byte) error

type Service

type Service interface {
	Import(card *Card) error
	Count() (int, error)
}

func NewService

func NewService(dao *PostgresCardDao) Service

type Translation

type Translation struct {
	Name         string
	Text         string
	FlavorText   string
	TypeLine     string
	MultiverseID int32
	Lang         string
}

Translation The translation of the card. Does not include english (the default language).

func (Translation) Diff added in v0.2.0

func (t Translation) Diff(other *Translation) *diff.Changeset

Diff Compares the translations and returns all differences.

type TypeDao

type TypeDao interface {
	Create(name string) (*CharacteristicType, error)
	Find(names ...string) ([]*CharacteristicType, error)
	AssignToFace(faceID int64, typeID int64) error
	FindAssignments(faceID int64) ([]*CharacteristicType, error)
	DeleteAssignments(faceID int64, subTypeIDs ...int64) error
	DeleteAllAssignments(faceID int64) error
}

func NewCardTypeDao

func NewCardTypeDao(db *postgres.DBConnection) TypeDao

func NewSubTypeDao

func NewSubTypeDao(db *postgres.DBConnection) TypeDao

func NewSuperTypeDao

func NewSuperTypeDao(db *postgres.DBConnection) TypeDao

Jump to

Keyboard shortcuts

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