game

package
v0.0.0-...-2839afe Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color uint8
const (
	ColorBlack Color = iota
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
)

func (Color) String

func (c Color) String() string

type Deck

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

func NewDeck

func NewDeck() *Deck

func (*Deck) Discard

func (d *Deck) Discard(cards ...ICard)

func (*Deck) Draw

func (d *Deck) Draw(n int) []ICard

func (*Deck) Shuffle

func (d *Deck) Shuffle()

type Game

type Game struct {
	Dir              bool
	Players          []IPlayer
	TotalPlayerCount int
	Deck             *Deck
	LastCard         ICard
	WantColor        Color
	WhoseTurn        int
	cellnet.EventQueue
}

func (*Game) NextPlayer

func (game *Game) NextPlayer(location int)

func (*Game) Start

func (game *Game) Start(totalCount, robotCount int)

type HumanPlayer

type HumanPlayer struct {
	cellnet.Session
	// contains filtered or unexported fields
}

func (*HumanPlayer) Draw

func (p *HumanPlayer) Draw(count int)

func (*HumanPlayer) ForeachCards

func (p *HumanPlayer) ForeachCards(f func(card ICard) bool)

func (*HumanPlayer) GetNextPlayer

func (p *HumanPlayer) GetNextPlayer(location int) IPlayer

func (*HumanPlayer) Init

func (r *HumanPlayer) Init(game *Game, location int)

func (*HumanPlayer) IsWin

func (r *HumanPlayer) IsWin() bool

func (*HumanPlayer) Location

func (p *HumanPlayer) Location() int

func (*HumanPlayer) NotifyAddHandCard

func (r *HumanPlayer) NotifyAddHandCard(cards ...ICard)

func (*HumanPlayer) NotifyDeckNum

func (r *HumanPlayer) NotifyDeckNum(count int)

func (*HumanPlayer) NotifyDiscardCard

func (r *HumanPlayer) NotifyDiscardCard(location int, card ICard, args ...uint32)

func (*HumanPlayer) NotifyOtherAddHandCard

func (r *HumanPlayer) NotifyOtherAddHandCard(location int, count int)

func (*HumanPlayer) NotifyTurn

func (r *HumanPlayer) NotifyTurn(location int, dir bool)

func (*HumanPlayer) NotifyWin

func (r *HumanPlayer) NotifyWin(location int)

func (*HumanPlayer) PlayCard

func (p *HumanPlayer) PlayCard(cardId uint32, args ...uint32)

type ICard

type ICard interface {
	Id() uint32
	CanPlay(game *Game, player IPlayer, args ...uint32) bool
	Execute(game *Game, player IPlayer, args ...uint32)
	String() string
	Color() Color
	Number() uint32
}

type IPlayer

type IPlayer interface {
	Init(game *Game, location int)
	Location() int
	NotifyAddHandCard(card ...ICard)
	NotifyOtherAddHandCard(location int, count int)
	NotifyDeckNum(count int)
	NotifyDiscardCard(location int, card ICard, args ...uint32)
	NotifyTurn(location int, dir bool)
	PlayCard(cardId uint32, args ...uint32)
	IsWin() bool
	GetNextPlayer(location int) IPlayer
	NotifyWin(location int)
	Draw(count int)
	ForeachCards(func(card ICard) bool)
}

type RobotPlayer

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

func (*RobotPlayer) Draw

func (p *RobotPlayer) Draw(count int)

func (*RobotPlayer) ForeachCards

func (p *RobotPlayer) ForeachCards(f func(card ICard) bool)

func (*RobotPlayer) GetNextPlayer

func (p *RobotPlayer) GetNextPlayer(location int) IPlayer

func (*RobotPlayer) Init

func (p *RobotPlayer) Init(game *Game, location int)

func (*RobotPlayer) IsWin

func (p *RobotPlayer) IsWin() bool

func (*RobotPlayer) Location

func (p *RobotPlayer) Location() int

func (*RobotPlayer) NotifyAddHandCard

func (p *RobotPlayer) NotifyAddHandCard(_ ...ICard)

func (*RobotPlayer) NotifyDeckNum

func (p *RobotPlayer) NotifyDeckNum(int)

func (*RobotPlayer) NotifyDiscardCard

func (p *RobotPlayer) NotifyDiscardCard(location int, card ICard, _ ...uint32)

func (*RobotPlayer) NotifyOtherAddHandCard

func (p *RobotPlayer) NotifyOtherAddHandCard(int, int)

func (*RobotPlayer) NotifyTurn

func (r *RobotPlayer) NotifyTurn(location int, _ bool)

func (*RobotPlayer) NotifyWin

func (p *RobotPlayer) NotifyWin(int)

func (*RobotPlayer) PlayCard

func (p *RobotPlayer) PlayCard(cardId uint32, args ...uint32)

Jump to

Keyboard shortcuts

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