desert

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

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

Go to latest
Published: Nov 1, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

README

License AGPL Go version GoDoc Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	CardType string     `json:"cardType"`
	Storm    *stormCard `json:"storm,omitempty"`
}

func (Card) String

func (c Card) String() string

type Deck

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

func NewGearDeck

func NewGearDeck() *Deck

Create a default Gear deck

func NewStormDeck

func NewStormDeck() *Deck

Create a default Storm deck

func (*Deck) Add

func (d *Deck) Add(c Card)

Add a card to the deck

func (*Deck) Draw

func (d *Deck) Draw() (Card, bool)

Remove a card from the top of the deck, and return that card

func (*Deck) Shuffle

func (d *Deck) Shuffle()

func (*Deck) Watch

func (d *Deck) Watch(fn func(DeckEvent))

Add a callback function, to be triggered when the deck changes The passed function should accept a DeckEvent

type DeckEvent

type DeckEvent struct {
	Action string `json:"action"`
	Card   *Card  `json:"card"`
	Length int    `json:"length"`
}

A DeckEvent is a notification of a change happening to a Deck Action will be one of "shuffle", "add", or "draw"

type Game

type Game struct {
	Id           GameId
	Name         string
	StormDeck    *Deck
	StormDiscard *Deck

	GearDeck    *Deck
	GearDiscard *Deck
}

func NewGame

func NewGame(id GameId, name string) *Game

func (*Game) DrawGearCard

func (g *Game) DrawGearCard() Card

func (*Game) DrawStormCard

func (g *Game) DrawStormCard() Card

func (*Game) HandleAction

func (g *Game) HandleAction(a GameAction) error

type GameAction

type GameAction struct {
	Action string
}

type GameId

type GameId uint64

type GameManager

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

func (*GameManager) FindGame

func (g *GameManager) FindGame(id GameId) *Game

func (*GameManager) ListGames

func (g *GameManager) ListGames() []*Game

func (*GameManager) NewGame

func (g *GameManager) NewGame(ngd NewGameData) (*Game, error)

type NewGameData

type NewGameData struct {
	Name string `json:"name"`
}

Directories

Path Synopsis
cmd
desert_server command

Jump to

Keyboard shortcuts

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