artifactdeck

package module
v0.0.0-...-a43a39a Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2018 License: MIT Imports: 5 Imported by: 0

README

ArtifactDeckCode port for go.

Uses an Artifact deck code to create a Deck struct with Heroes and Cards. Can also be used to encode a Deck struct into the URL-safe base64 string.

Installing

go get github.com/pvaass/artifactdeck

Usage

import artifact "github.com/pvaass/artifactdeck"

func main() {
  var deckCode string
  var deck artifact.Deck

  // Create Deck from string
  err = deck.UnmarshalText(deckCode)
  if err != nil {
    panic(err)
  }

  // Create string from Deck
  text, err = deck.MarshalText()
  if err != nil {
    panic(err)
  }
}

Docs

https://godoc.org/github.com/pvaass/artifactdeck

Documentation

Index

Constants

View Source
const Prefix = "ADC"

Prefix The prefix for the result string

View Source
const Version = 2

Version Current ADC version

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	ID    int
	Count int
}

Card A card in a Deck

type Deck

type Deck struct {
	Name   string
	Heroes []Hero
	Cards  []Card
}

Deck The unencoded deck

func (*Deck) MarshalText

func (deck *Deck) MarshalText() ([]byte, error)

MarshalText Encodes a Deck struct to a base64 encoded byte array

func (*Deck) UnmarshalText

func (deck *Deck) UnmarshalText(text []byte) error

UnmarshalText Decodes a base64 encoded byte array to a Deck struct

type Hero

type Hero struct {
	ID   int
	Turn int
}

Hero A hero in a deck

Jump to

Keyboard shortcuts

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