skirmish

package module
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 21 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).

Installation

1. Install the Go programming language.

Make sure you have version 1.11 of the Go programming language installed. if you are unsure of your version, you can open a command prompt and run this command

$ go version

If you are running 64-bit windows, go version should return

go version go1.11 windows/amd64

2. Download the skirmish package

Run $ go get github.com/sbrow/skirmish. This will download the package to $GOPATH/src/github.com/sbrow/skirmish, on Windows $GOPATH will usually be C:\Users\[Username]\go.

3. Enable go modules

There are two ways you can proceed to accomplish this:

You'll need to move the install folder somewhere else, (it can be anywhere). I moved mine to C:Users/Spencer/gomod/github.com/sbrow/skirmish.

3.b enable GO111MODULES

Set an environment variable for your terminal GO111MODULES=on. This method is not recommended because it breaks go get. In order to download packages with go get, you'll have to temporarily change GO111MODULES back to auto or off.

4. Install the package.

At this point, cd into the project folder and run go install ./.... You should see something like this: installation

Now, you should be all set. You can run skir version to confirm that the program has installed skir version.

TODO

sbrow: Figure out how to handle id. Issue

sbrow: Cameo card flavor text. Issue

sbrow: Figure out how to pass a pointer to card.SetSTypes Issue

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).

Index

Constants

This section is empty.

Variables

View Source
var CfgDir string

CfgDir is the location that config files are saved to.

View Source
var DefaultImage = "ImageNotFound.png"

DefaultImage is the name of the image file to use when a card's image cannot be found.

View Source
var Delim = ","

Delim is the Delimiter to use when Marshalling cards to csv format.

View Source
var ImageDir string

ImageDir is the path to the root directory where card images are located.

View Source
var Leaders leaders

Leaders is the list of valid deck leaders.

View Source
var LocalDB = &Config{
	DB: cfgDB{
		Host: "localhost",
		Port: 5432,
		Name: "postgres",
		User: "postgres",
		Pass: "",
		SSL:  false,
	},
}

LocalDB holds the configuration for connecting to the default, local postgres database. It is primarily used for running tests.

View Source
var Version = "undefined"

Functions

func AutoConnect added in v0.19.0

func AutoConnect() error

func Connect

func Connect(host string, port int, dbname, user, pass, 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.
  • sslmode declares which ssl mode to use.

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

func Dump

func Dump(path string)

Dump runs pg_dump on the connected database, saving the contents to a SQL formatted file at the given path.

func Exec added in v0.13.0

func Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query on the standard database without returning any rows. The args are for any placeholder parameters in the query.

func Query

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

Query returns the results of a query to the standard database. The args are for any placeholder parameters in the query.

func QueryRow added in v0.15.0

func QueryRow(query string, args ...interface{}) *sql.Row

Query returns the results of a query to the standard database with the expectation that the query will return one result. Errors are deferred until Row's Scan method is called. The args are for any placeholder parameters in the query.

func Recover

func Recover(path string) (sql.Result, error)

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

Types

type Card

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

	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)
	MarshalXML(*xml.Encoder, xml.StartElement) 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. [Issue](https://github.com/sbrow/skirmish/issues/33)

TODO(sbrow): Cameo card flavor text. [Issue](https://github.com/sbrow/skirmish/issues/32)

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 Config

type Config struct {
	// PS holds configuration values related to Photoshop.
	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 Holds configuration values related to the PSQL database.
	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.
		Pass string
		SSL  bool // Whether or not to use SSL.
	} `yaml:"database"`
}

Config holds various configuration values for the program, namely the directories of other relevant git repositories: "dreamkeepers-dat" and "dreamkeepers-psd".

var Cfg *Config

Cfg holds the currently loaded configuration settings.

func DefaultCfg

func DefaultCfg() *Config

DefaultCfg returns a full, basic Config.

func (Config) DBArgs

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

DBArgs returns c.DB as a list of args that can be passed to Connect().

func (*Config) Load

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

Load imports Config data from a YAML file at the given path. If the file is not found, a new one is generated by DefaultCfg() and an error is returned, and the program can continue using default values.

func (*Config) Save

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

Save saves the Config to a YAML file at the given path.

type DeckCard

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

DeckCard is a card that goes in a leader's deck.

func NewDeckCard

func NewDeckCard() *DeckCard

NewDeckCard returns a pointer to a new, empty DeckCard.

func (*DeckCard) Bold

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

func (*DeckCard) CSV

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

CSV returns the card in CSV format. If labels is true, the first row of the output will be the contents of d.Labels().

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)

Cost returns the DeckCard's cost. Cost always returns a nil 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)

Images returns any and all paths to Images with this card name. Multiple Images may exist to account for cameos, etc.

func (*DeckCard) JSON

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

func (*DeckCard) Labels

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

Labels returns the column labels to use when marshaling d into to csv format.

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(enc *xml.Encoder, start xml.StartElement) error

func (*DeckCard) Name

func (c *DeckCard) Name() string

func (*DeckCard) NormalBorder

func (d *DeckCard) NormalBorder() bool

NormalBorder returns whether or not to show the normal border when applying this card to the Photoshop template.

NormalBorder will return false for any card with one of the following attributes:

  • "Rare" rarity.
  • "Action" card type.
  • "Item" card type.
  • "Continuous" super type.

func (*DeckCard) Rarity

func (d *DeckCard) Rarity() string

Rarity returns the string representation of d.Copies().

func (*DeckCard) Regexp

func (c *DeckCard) Regexp() string

Regexp returns the regular expression that matches bold words in the card's short text.

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)

SetCost sets the DeckCard's cost to the given value.

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)

SetRarity sets the DeckCard's copies to *r. If r is nil, d remains unchanged.

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

String returns the string representation of the DeckCard.

func (*DeckCard) Type

func (c *DeckCard) Type() string

func (DeckCard) UEJSON

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

UEJSON returns the card formatted into JSON files that are readable by Unreal Engine.

func (*DeckCard) XML

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

type Leader added in v0.14.0

type Leader struct {
	Name      string  // The Leader's name.
	Banner    []uint8 // The leader's Banner color (in hexadecimal format).
	Indicator []uint8 // The leader's Indicator color (in hexadecimal format).
}

Leader represents a deck leader

type NonDeckCard

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

NonDeckCard represents a Leader or Partner card.

func (*NonDeckCard) Bold

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

func (*NonDeckCard) CSV

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

CSV returns the card in CSV format. If labels is true, the first row of the output will be the contents of n.Labels().

func (*NonDeckCard) Card

func (c *NonDeckCard) Card() card

func (*NonDeckCard) Copies added in v0.14.0

func (c *NonDeckCard) Copies() int

Copies returns the number of times this card appears in the game.

func (*NonDeckCard) Damage

func (c *NonDeckCard) Damage() int

func (*NonDeckCard) DamageB

func (n *NonDeckCard) DamageB() int

DamageB returns n's Halo side damage.

If n doesn't have a Halo side, DamageB returns 0.

func (*NonDeckCard) Faction

func (n *NonDeckCard) Faction() string

Faction returns the faction that n is aligned to.

func (*NonDeckCard) Flavor

func (c *NonDeckCard) Flavor() string

func (*NonDeckCard) FullType

func (c *NonDeckCard) FullType() string

func (*NonDeckCard) ID

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

ID returns this card's unique identifier.

func (*NonDeckCard) Images

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

Images returns the path's to n's front side and Halo side images (if applicable).

func (*NonDeckCard) JSON

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

func (*NonDeckCard) Labels

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

Labels returns the column labels to use when marshaling n into to csv format.

func (*NonDeckCard) Leader

func (c *NonDeckCard) Leader() string

func (*NonDeckCard) Life

func (c *NonDeckCard) Life() int

func (*NonDeckCard) LifeB

func (n *NonDeckCard) LifeB() string

LifeB returns n's Halo side life.

If n doesn't have a Halo side, LifeB returns 0.

func (*NonDeckCard) Long

func (c *NonDeckCard) Long() string

func (*NonDeckCard) LongB

func (n *NonDeckCard) LongB() string

LongB returns n's Halo side long text.

If n doesn't have a Halo side, LongB returns 0.

func (*NonDeckCard) MarshalXML

func (c *NonDeckCard) MarshalXML(enc *xml.Encoder, start xml.StartElement) error

func (*NonDeckCard) Name

func (c *NonDeckCard) Name() string

func (*NonDeckCard) Regexp

func (c *NonDeckCard) Regexp() string

Regexp returns the regular expression that matches bold words in the card's short text.

func (*NonDeckCard) Resolve

func (c *NonDeckCard) Resolve() string

func (*NonDeckCard) ResolveB

func (n *NonDeckCard) ResolveB() string

ResolveB returns n's Halo side Resolve.

If n doesn't have a Halo side, ResolveB returns "".

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)

SetDamageB sets n's Halo side damage to d.

If n doesn't have a Halo side, or if d is nil, SetDamageB does nothing.

func (*NonDeckCard) SetFaction

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

SetFaction sets n's Faction to faction.SetFaction

If faction is nil, n is not changed.

func (*NonDeckCard) SetFlavor

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

func (*NonDeckCard) SetFlavorB

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

SetFlavorB sets n's Halo side flavor to f.

If n doesn't have a Halo side, or if f is nil, SetFlavorB does nothing.

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)

SetLifeB sets n's Halo side life to l.

If n doesn't have a Halo side, or if l is nil, SetLifeB does nothing.

func (*NonDeckCard) SetLong

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

func (*NonDeckCard) SetLongB

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

SetLongB sets n's Halo side long text to l.

If n doesn't have a Halo side, or if l is nil, SetLongB does nothing.

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)

SetResolveB sets n's Halo side resolve to r.

If n doesn't have a Halo side, or if r is nil, SetResolveB does nothing.

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)

SetShortB sets n's Halo side short text to s.

If n doesn't have a Halo side, or if s is nil, SetShortB does nothing.

func (*NonDeckCard) SetSpeed

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

func (*NonDeckCard) SetSpeedB

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

SetSpeedB sets n's Halo side speed to s.

If n doesn't have a Halo side, or if s is nil, SetDamageB does nothing.

func (*NonDeckCard) SetType

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

func (*NonDeckCard) Short

func (c *NonDeckCard) Short() string

func (*NonDeckCard) ShortB

func (n *NonDeckCard) ShortB() string

ShortB returns n's Halo side short text.

If n doesn't have a Halo side, ShortB returns 0.

func (*NonDeckCard) Speed

func (c *NonDeckCard) Speed() int

func (*NonDeckCard) SpeedB

func (n *NonDeckCard) SpeedB() int

SpeedB returns n's Halo side speed.

If n doesn't have a Halo side, SpeedB returns 0.

func (*NonDeckCard) StatsB added in v0.12.0

func (n *NonDeckCard) StatsB() string

StatsB returns the string representation of n's Halo side stats.

If n doesn't have a Halo side, an empty string is returned.

func (*NonDeckCard) String

func (n *NonDeckCard) String() string

String returns the string representation of n.

func (*NonDeckCard) Type

func (c *NonDeckCard) Type() string

func (NonDeckCard) UEJSON

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

UEJSON returns the card formatted into JSON files that are readable by Unreal Engine.

func (*NonDeckCard) XML

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

Directories

Path Synopsis
Package ps fills in Photoshop templates with Card information.DeckTemplate ps acts as a bridge between github.com/sbrow/skirmish and github.com/sbrow/ps, allowing the user to fill out Photoshop templates with Card data pulled from an SQL database.
Package ps fills in Photoshop templates with Card information.DeckTemplate ps acts as a bridge between github.com/sbrow/skirmish and github.com/sbrow/ps, allowing the user to fill out Photoshop templates with Card data pulled from an SQL database.
Skir is a tool for developing the Skirmish card game.
Skir is a tool for developing the Skirmish card game.
internal/help
Package help implements the “skir help” command.
Package help implements the “skir help” command.
internal/version
Package version implements the “go version” command.
Package version implements the “go version” command.
internal/xml
Package xml is a test package
Package xml is a test package

Jump to

Keyboard shortcuts

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