game

package
v0.0.0-...-67c8daa Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePresentations

func ComparePresentations(a, b []Card) int

ComparePresentations compares the value of two presentations (assumed to be valid), and returns 1 if the value of a is greater, -1 if the value of b is greater, and 0 if they have the same value. This function is usable with the slices.SortFunc function to rank presentations.

func GetValidPresentations

func GetValidPresentations(hand []Card) [][]Card

GetValidPresentations identifies the groups of cards in a hand that could be presented together. The results are sorted from least to most valuable.

func IsValidPresentation

func IsValidPresentation(presentation []Card) bool

Types

type Card

type Card [2]int

func GetDeck

func GetDeck(players int) []Card

func (Card) Flip

func (c Card) Flip() Card

type Game

type Game struct {
	Id                  string
	Round               int
	CurrentPlayer       int
	LastPlayerToPresent int
	Presentation        []Card
	Players             []Player

	Rand *rand.Rand
}

func (*Game) AddPlayer

func (g *Game) AddPlayer(id, name string) error

func (*Game) CanPlayerPresent

func (g *Game) CanPlayerPresent(playerId string) bool

func (*Game) DecideHandOrientation

func (g *Game) DecideHandOrientation(playerId string, flip bool) error

func (*Game) GetCurrentPlayer

func (g *Game) GetCurrentPlayer() *Player

func (*Game) GetPlayerById

func (g *Game) GetPlayerById(id string) *Player

func (*Game) GetPlayerIndex

func (g *Game) GetPlayerIndex(id string) (int, error)

func (*Game) HasEnoughPlayers

func (g *Game) HasEnoughPlayers() bool

func (*Game) HavePlayersDecidedHandOrientation

func (g *Game) HavePlayersDecidedHandOrientation() bool

func (*Game) IsEmpty

func (g *Game) IsEmpty() bool

func (*Game) IsFull

func (g *Game) IsFull() bool

func (*Game) IsGameOver

func (g *Game) IsGameOver() bool

func (*Game) IsLobby

func (g *Game) IsLobby() bool

func (*Game) Pass

func (g *Game) Pass(playerId string) error

Pass on the opportunity to Present after Prospect.

func (*Game) PlayablePresentations

func (g *Game) PlayablePresentations(playerId string) [][]Card

func (*Game) Present

func (g *Game) Present(playerId string, start, end int) error

func (*Game) Prospect

func (g *Game) Prospect(playerId string, left, flip bool, position int) error

func (*Game) RemovePlayer

func (g *Game) RemovePlayer(id string)

func (*Game) Start

func (g *Game) Start() error

type Player

type Player struct {
	Id                        string
	Name                      string
	Hand                      []Card
	Points                    int
	ProspectTokens            int
	ScorePile                 int
	CanProspectAndPresent     bool
	HasDecidedHandOrientation bool
	IsDecidingPresent         bool
}

Jump to

Keyboard shortcuts

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