set

package
v0.0.0-...-5cc4ecd Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Total number of cards in game
	DeckSize int = 81
	// Default size of game layout
	StartLayoutSize int = 12
	// Number of cards in set
	SetSize int = 3
	// Max possible game layout size (in this size is guaranteed to be a set)
	MaxLayerSize int = 21
)

Variables

View Source
var (
	Deck = generateCards()
)

Functions

This section is empty.

Types

type Card

type Card struct {
	Id      int    `json:"_id"`
	Number  int    `json:"number"`
	Shape   string `json:"shape"`
	Color   string `json:"color"`
	Shading string `json:"shading"`
}

type Core

type Core struct {
	FreeCards    []Card   `json:"freeCards"`
	Layout       []Card   `json:"layout"`
	PossibleSets [][]Card `json:"possibleSets"`
	WonCards     []Card   `json:"wonCards"`
	State        string   `json:"state"`
}

func NewCore

func NewCore() *Core

Create a new instance of Set Core

func (*Core) AddCards

func (sc *Core) AddCards() error

Add 3 random cards to Core.layout from Core.FreeCards

func (*Core) FindSets

func (sc *Core) FindSets() string

Find possible sets in current Core.Layout and paste them in Core.PossibleSets

func (*Core) LoadState

func (sc *Core) LoadState(state string) error

Load state of the game by passing state-string

func (*Core) RemoveSet

func (sc *Core) RemoveSet(set []int) error

Remove a set from Core.Layout by passing an array of card IDs

func (*Core) Start

func (sc *Core) Start()

Start a new game with 12 randomly selected cards for Core.Layout

Jump to

Keyboard shortcuts

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