skirmish

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2018 License: GPL-3.0 Imports: 19 Imported by: 1

README

skirmish

GoDoc Build Status Coverage Status Go Report Card

import "github.com/sbrow/skirmish"

Overview

Package skirmish contains code for production of the Dreamkeepers: Skirmish battle card game.

More specifically, it provides an interface between the SQL database that contains card data, Photoshop, and the user (via CLI).

TODO(sbrow): Cameo card flavor text.

Installation

$ go get -u github.com/sbrow/skirmish

TODO

sbrow: Figure out how to handle id.

sbrow: here

sbrow: change Dump() to support path instead of dir

sbrow: change Recover() to support path instead of dir

sbrow: Return error when not found.

sbrow: Cameo card flavor text.

sbrow: Make getters/setters for NonDeckCard

sbrow: UE COST BROKEN

sbrow: Fix UECardJSON

sbrow: define elsewhere.

sbrow: Move these vars to appropriate places.

Documentation

For full Documentation please visit https://godoc.org/github.com/sbrow/skirmish


Generated by godoc2md

Documentation

Overview

Package skirmish contains code for production of the Dreamkeepers: Skirmish battle card game.

More specifically, it provides an interface between the SQL database that contains card data, Photoshop, and the user (via CLI).

TODO(sbrow): Cameo card flavor text.

Index

Constants

This section is empty.

Variables

View Source
var DataDir = filepath.Join(os.Getenv("SK_SQL"))

TODO(sbrow): Move these vars to appropriate places.

View Source
var DefaultImage = filepath.Join(ImageDir, "ImageNotFound.png")
View Source
var Delim = ","
View Source
var ImageDir = filepath.Join(os.Getenv("SK_PS"), "Images")

TODO(sbrow): define elsewhere.

View Source
var Leaders leaders

Functions

func Connect

func Connect(host string, port int, dbname, user, sslmode string) error

Connect connects to a postgreSQL database with the given options: host is the ip of the server, port is the server port, dbname is the name of the database, user is the username, and sslmode declares which ssl mode to use.

See github.com/lib/pq for more information on sslmode.

func Dump

func Dump(dir string)

Dump runs pg_dump, saving the contents of the standard database to a SQL file (skirmish_db.sql) in the given directory.

TODO(sbrow): change Dump() to support path instead of dir

func Query

func Query(query string, args ...interface{}) (*sql.Rows, error)

Query returns the results of a query to the standard database.

func Recover

func Recover(dir string)

Recover runs pg_recover on the database, loading data from the SQL file in the given directory.

TODO(sbrow): change Recover() to support path instead of dir

Types

type Card

type Card interface {
	Card() card
	Faction() string
	Name() string
	FullType() string
	Resolve() string
	STypes() []string
	Speed() int
	Type() string

	SetDamage(*int)
	SetFlavor(*string)
	SetLeader(*string)
	SetLife(*int)
	SetLong(*string)
	SetName(*string)
	SetRegexp(*string)
	SetResolve(*string)
	SetShort(*string)
	SetSpeed(*int)
	SetSTypes([]string)
	SetType(*string)

	Damage() int
	Leader() string
	Life() int
	Short() string
	Regexp() string
	Long() string
	Flavor() string
	Labels() []string
	String() string
	Images() ([]string, error)
	Bold() ([][]int, error)
	UEJSON(ident bool) ([]byte, error)
	CSV(bool) [][]string
	XML() ([]byte, error)
}

Card is an interface shared by DeckCards and NonDeckCards.

It is important to note that each Card object can represent more than one card.

  • DeckCards can hold multiple cards with unique art.
  • NonDeckCards can hold their frontside Card and rearside Card.

Setters

The Set methods accept pointers because SQL queries return pointer values. Passing nil to a set value will generally result in no change to the Card.

TODO(sbrow): Figure out how to handle id.

func Load

func Load(name string) (Card, error)

Load queries the standard database for a card with the given name, and returns the result as a Card object.

func LoadMany

func LoadMany(cond string) ([]Card, error)

LoadMany queries the standard database for all cards that match the given condition and returns them as a slice of Card objects.

func NewCard

func NewCard() Card

NewCard returns a new, empty Card object.

type CardXML

type CardXML struct {
	XMLName xml.Name `xml:"card"`
	Name    string   `xml:"name"`
	Set     string   `xml:"set"`
	Type    string   `xml:"type"`
	PT      string   `xml:"pt,omitempty"`
	Row     uint8    `xml:"row"`
	Text    string   `xml:"text,omitempty"`
}

type Config

type Config struct {
	PS struct {
		Dir     string // The directory of the Photoshop files.
		Deck    string // The name of the Deck Card Photoshop template file.
		NonDeck string `yaml:"non_deck"` // The name of the Non-Deck Card Photoshop template file.
	} `yaml:"photoshop"`
	DB struct {
		Dir  string // The default directory to call Load() and Recover() in.
		Host string // The server ip address.
		Port int    // the server port.
		Name string // The name of the database.
		User string // The user name to login as.
		SSL  bool   // Whether or not to use SSL.
	} `yaml:"database"`
}
var Cfg *Config

Cfg holds the currently loaded configuration settings.

func DefaultCfg

func DefaultCfg() *Config

func (Config) DBArgs

func (c Config) DBArgs() (host string, port int, dbname, user, sslmode string)

func (*Config) Load

func (c *Config) Load(path string) error

func (*Config) Save

func (c *Config) Save(path string) error

type DeckCard

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

func NewDeckCard

func NewDeckCard() *DeckCard

func (*DeckCard) Bold

func (c *DeckCard) Bold() ([][]int, error)

func (*DeckCard) CSV

func (d *DeckCard) CSV(lbls bool) [][]string

func (*DeckCard) Card

func (c *DeckCard) Card() card

func (*DeckCard) Copies

func (d *DeckCard) Copies() int

Copies returns the number of copies that appear in this card's deck.

func (*DeckCard) Cost

func (d *DeckCard) Cost() (string, error)

func (*DeckCard) Damage

func (c *DeckCard) Damage() int

func (*DeckCard) Faction

func (c *DeckCard) Faction() string

func (*DeckCard) Flavor

func (c *DeckCard) Flavor() string

func (*DeckCard) FullType

func (c *DeckCard) FullType() string

func (*DeckCard) ID

func (c *DeckCard) ID(ver int) string

ID returns an id unique to the card.

Cards with only one art will have identical ID and Name. Cards with more than one art will have an ID containing their name and which version of art they use.

func (*DeckCard) Images

func (d *DeckCard) Images() (paths []string, err error)

TODO(sbrow): Return error when not found.

func (*DeckCard) JSON

func (c *DeckCard) JSON() ([]byte, error)

func (*DeckCard) Labels

func (d *DeckCard) Labels() []string

func (*DeckCard) Leader

func (c *DeckCard) Leader() string

func (*DeckCard) Life

func (c *DeckCard) Life() int

func (*DeckCard) Long

func (c *DeckCard) Long() string

func (*DeckCard) MarshalXML

func (c *DeckCard) MarshalXML() ([]byte, error)

func (*DeckCard) Name

func (c *DeckCard) Name() string

func (*DeckCard) NormalBorder

func (d *DeckCard) NormalBorder() bool

func (*DeckCard) Rarity

func (d *DeckCard) Rarity() string

func (*DeckCard) Regexp

func (c *DeckCard) Regexp() string

func (*DeckCard) Resolve

func (c *DeckCard) Resolve() string

func (*DeckCard) STypes

func (c *DeckCard) STypes() []string

func (*DeckCard) SetCard

func (d *DeckCard) SetCard(c Card)

SetCard makes c the DeckCard's base card.

func (*DeckCard) SetCost

func (d *DeckCard) SetCost(c string)

func (*DeckCard) SetDamage

func (c *DeckCard) SetDamage(d *int)

func (*DeckCard) SetFlavor

func (c *DeckCard) SetFlavor(s *string)

func (*DeckCard) SetLeader

func (c *DeckCard) SetLeader(l *string)

func (*DeckCard) SetLife

func (c *DeckCard) SetLife(l *int)

func (*DeckCard) SetLong

func (c *DeckCard) SetLong(s *string)

func (*DeckCard) SetName

func (c *DeckCard) SetName(name *string)

func (*DeckCard) SetRarity

func (d *DeckCard) SetRarity(r *int)

func (*DeckCard) SetRegexp

func (c *DeckCard) SetRegexp(reg *string)

func (*DeckCard) SetResolve

func (c *DeckCard) SetResolve(r *string)

func (*DeckCard) SetSTypes

func (c *DeckCard) SetSTypes(t []string)

func (*DeckCard) SetShort

func (c *DeckCard) SetShort(s *string)

func (*DeckCard) SetSpeed

func (c *DeckCard) SetSpeed(s *int)

func (*DeckCard) SetType

func (c *DeckCard) SetType(t *string)

func (*DeckCard) Short

func (c *DeckCard) Short() string

func (*DeckCard) Speed

func (c *DeckCard) Speed() int

func (*DeckCard) String

func (d *DeckCard) String() string

func (*DeckCard) Type

func (d *DeckCard) Type() string

func (DeckCard) UEJSON

func (d DeckCard) UEJSON(ident bool) ([]byte, error)

func (*DeckCard) XML

func (c *DeckCard) XML() ([]byte, error)

type NonDeckCard

type NonDeckCard struct {
	SpeedB   *int
	ResolveB *string
	DamageB  *int
	LifeB    *string
	ShortB   *string
	LongB    *string
	FlavorB  *string
	// contains filtered or unexported fields
}

TODO(sbrow): Make getters/setters for NonDeckCard

func (*NonDeckCard) Bold

func (c *NonDeckCard) Bold() ([][]int, error)

func (*NonDeckCard) CSV

func (n *NonDeckCard) CSV(lbls bool) [][]string

func (*NonDeckCard) Card

func (c *NonDeckCard) Card() card

func (*NonDeckCard) Damage

func (c *NonDeckCard) Damage() int

func (*NonDeckCard) Faction

func (n *NonDeckCard) Faction() string

func (*NonDeckCard) Flavor

func (c *NonDeckCard) Flavor() string

func (*NonDeckCard) FullType

func (c *NonDeckCard) FullType() string

func (*NonDeckCard) ID

func (c *NonDeckCard) ID(ver int) string

ID returns an id unique to the card.

Cards with only one art will have identical ID and Name. Cards with more than one art will have an ID containing their name and which version of art they use.

func (*NonDeckCard) Images

func (n *NonDeckCard) Images() (paths []string, err error)

func (*NonDeckCard) JSON

func (c *NonDeckCard) JSON() ([]byte, error)

func (*NonDeckCard) Labels

func (n *NonDeckCard) Labels() []string

func (*NonDeckCard) Leader

func (c *NonDeckCard) Leader() string

func (*NonDeckCard) Life

func (c *NonDeckCard) Life() int

func (*NonDeckCard) Long

func (c *NonDeckCard) Long() string

func (*NonDeckCard) MarshalXML

func (c *NonDeckCard) MarshalXML() ([]byte, error)

func (*NonDeckCard) Name

func (c *NonDeckCard) Name() string

func (*NonDeckCard) Regexp

func (c *NonDeckCard) Regexp() string

func (*NonDeckCard) Resolve

func (c *NonDeckCard) Resolve() string

func (*NonDeckCard) STypes

func (c *NonDeckCard) STypes() []string

func (*NonDeckCard) SetCard

func (n *NonDeckCard) SetCard(c Card)

SetCard makes c the DeckCard's base card.

func (*NonDeckCard) SetDamage

func (c *NonDeckCard) SetDamage(d *int)

func (*NonDeckCard) SetDamageB

func (n *NonDeckCard) SetDamageB(d *int)

func (*NonDeckCard) SetFaction

func (n *NonDeckCard) SetFaction(faction *string)

func (*NonDeckCard) SetFlavor

func (c *NonDeckCard) SetFlavor(s *string)

func (*NonDeckCard) SetFlavorB

func (n *NonDeckCard) SetFlavorB(f *string)

func (*NonDeckCard) SetLeader

func (c *NonDeckCard) SetLeader(l *string)

func (*NonDeckCard) SetLife

func (c *NonDeckCard) SetLife(l *int)

func (*NonDeckCard) SetLifeB

func (n *NonDeckCard) SetLifeB(l *string)

func (*NonDeckCard) SetLong

func (c *NonDeckCard) SetLong(s *string)

func (*NonDeckCard) SetLongB

func (n *NonDeckCard) SetLongB(l *string)

func (*NonDeckCard) SetName

func (c *NonDeckCard) SetName(name *string)

func (*NonDeckCard) SetRegexp

func (c *NonDeckCard) SetRegexp(reg *string)

func (*NonDeckCard) SetResolve

func (c *NonDeckCard) SetResolve(r *string)

func (*NonDeckCard) SetResolveB

func (n *NonDeckCard) SetResolveB(r *string)

func (*NonDeckCard) SetSTypes

func (c *NonDeckCard) SetSTypes(t []string)

func (*NonDeckCard) SetShort

func (c *NonDeckCard) SetShort(s *string)

func (*NonDeckCard) SetShortB

func (n *NonDeckCard) SetShortB(s *string)

func (*NonDeckCard) SetSpeed

func (c *NonDeckCard) SetSpeed(s *int)

func (*NonDeckCard) SetSpeedB

func (n *NonDeckCard) SetSpeedB(s *int)

func (*NonDeckCard) SetType

func (c *NonDeckCard) SetType(t *string)

func (*NonDeckCard) Short

func (c *NonDeckCard) Short() string

func (*NonDeckCard) Speed

func (c *NonDeckCard) Speed() int

func (*NonDeckCard) String

func (n *NonDeckCard) String() string

func (*NonDeckCard) Type

func (c *NonDeckCard) Type() string

func (NonDeckCard) UEJSON

func (n NonDeckCard) UEJSON(ident bool) ([]byte, error)

TODO(sbrow): Fix UECardJSON

func (*NonDeckCard) XML

func (c *NonDeckCard) XML() ([]byte, error)

Directories

Path Synopsis
cmd
skir command
Skir is a tool for developing the Skirmish card game.
Skir is a tool for developing the Skirmish card game.
skir/internal/help
Package help implements the “skir help” command.
Package help implements the “skir help” command.
skir/internal/version
Package version implements the “go version” command.
Package version implements the “go version” command.
ps
cmd command

Jump to

Keyboard shortcuts

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