plugins

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBackKey = "default"

DefaultBackKey if the key use for the default card back in Plugin.AvailableBacks.

Variables

This section is empty.

Functions

func CapitalizeString

func CapitalizeString(s string) string

CapitalizeString puts the first letter of a string in uppercase.

func CapitalizeStrings

func CapitalizeStrings(s []string) []string

CapitalizeStrings puts the first letter of each string in a slice in uppercase.

func CheckInvalidFolderName

func CheckInvalidFolderName(folderPath string) bool

CheckInvalidFolderName checks whether the given path can be safely created on all platforms. Since the Tabletop Simulator save files can be shared with Steam Cloud on Windows, make sure that even the folders created on Linux or OS X are also valid on Windows.

func IndexOf

func IndexOf(element string, data []string) int

IndexOf returns the index of a string in a string slice, or -1 if not found.

func UncapitalizeString

func UncapitalizeString(s string) string

UncapitalizeString puts the first letter of a string in lowercase.

Types

type Back

type Back struct {
	// URL of the card back.
	URL string
	// Description of the card back.
	Description string
}

Back represents the back of a card.

type CardInfo

type CardInfo struct {
	// Name of the card
	Name string
	// Description of the card
	Description string
	// ImageURL is the URL of the card image
	ImageURL string
	// Count is the amount of this card in the current deck
	Count int
	// AlternativeState is used for double-faced cards (transforms and melds
	// in Magic). The back of the card will be represented as a second state
	// of the card object.
	AlternativeState *CardInfo
	// Oversized card
	// Used for plane, scheme or meld results in MTG
	Oversized bool
}

CardInfo contains the information about a card used to build a TTS deck.

type CardSize

type CardSize int

CardSize is the size format of a card

const (
	// CardSizeStandard is the size of a Magic or Pokémon card (Poker size)
	CardSizeStandard CardSize = iota
	// CardSizeSmall is the size of a Yu-Gi-Oh or Cardfight!! Vanguard card
	CardSizeSmall
)

type Deck

type Deck struct {
	Name         string
	Cards        []CardInfo
	BackURL      string
	TemplateInfo *TemplateInfo
	CardSize     CardSize
	Rounded      bool
	ThumbnailURL string
}

Deck contains the information about a deck used to build it in TTS.

type DeckType

type DeckType struct {
	FileHandler FileHandler
	Example     string
}

DeckType contains a file handler and an example for a deck type.

type FileHandler

type FileHandler func(io.Reader, string, map[string]string) ([]*Deck, error)

FileHandler is a function used to parse a deck file for a specific file extension.

type Option

type Option struct {
	// Type of the option.
	Type OptionType
	// Description of the option.
	Description string
	// DefaultValue is the value the option is set to if no value is provided
	// by the user.
	DefaultValue interface{}
	// AllowedValues should only be set when Type is OptionTypeEnum
	AllowedValues []string
}

Option of a deckconverter plugin.

type OptionType

type OptionType int

OptionType is the type of a plugin option.

const (
	// OptionTypeEnum represents an option which has a list of possible values.
	OptionTypeEnum OptionType = iota
	// OptionTypeBool represents a boolean option.
	OptionTypeBool
	// OptionTypeInt represents an integer option.
	OptionTypeInt
)

func (OptionType) String

func (ot OptionType) String() string

String representation of an OptionType.

type Options

type Options map[string]Option

Options is a map of option IDs to option.

func (Options) ValidateNormalize

func (o Options) ValidateNormalize(options map[string]string) (map[string]interface{}, error)

ValidateNormalize validates plugin options entered by the user and normalizes their values.

type Plugin

type Plugin interface {
	// PluginID returns the ID of the plugin.
	PluginID() string
	// PluginName returns the name of the plugin.
	PluginName() string
	// URLHandlers returns the list of URLs supported by the plugin and their
	// parsing functions.
	URLHandlers() []URLHandler
	// FileExtHandlers returns the list of file extensions supported by the
	// plugins and their parsing functions.
	FileExtHandlers() map[string]FileHandler
	// FileExtHandlers returns the list of deck formats supported by the
	// plugins and their parsing functions.
	DeckTypeHandlers() map[string]DeckType
	// GenericFileHandler returns the default file handler for the plugin.
	GenericFileHandler() DeckType
	// AvailableOptions returns the list of options that can be set for the
	// plugin.
	AvailableOptions() Options
	// AvailableBacks lists the default card backs available for the plugin.
	AvailableBacks() map[string]Back
}

Plugin represents a deckconverted plugin.

type Template

type Template struct {
	URL     string
	NumCols int
	NumRows int
}

Template represents a TTS file template. See https://berserk-games.com/knowledgebase/custom-decks/.

type TemplateInfo

type TemplateInfo struct {
	// ImageURLCardIDMap is a map between card image URLs and card IDs.
	ImageURLCardIDMap map[string]int
	// Templates is a map of template ID to template.
	Templates map[int]*Template
}

TemplateInfo maps card image URLs to templates.

func (*TemplateInfo) GetAssociatedTemplate

func (t *TemplateInfo) GetAssociatedTemplate(cardID int) (*Template, int, error)

GetAssociatedTemplate returns the template containing the image of the supplied card ID.

type URLHandler

type URLHandler struct {
	// BasePath is the main page of the supported website.
	BasePath string
	// Regex used to recognize supported URLs.
	Regex *regexp.Regexp
	// Handler function used to parse the deck.
	Handler func(string, map[string]string) ([]*Deck, error)
}

URLHandler contains the information and function used for parsing a deck located at an URL.

Directories

Path Synopsis
ygo
api

Jump to

Keyboard shortcuts

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