game

package
v0.0.0-...-f175000 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GAME = iota
	OVER
	WIN

	HIDE  = '~'
	MINE  = '*'
	FLAG  = '!'
	GESS  = '?'
	BOOM  = 'X'
	EMPTY = ' '

	ZERO = '0'
)

Variables

This section is empty.

Functions

func FromGob

func FromGob[T any](from []byte, to *T)

func ToGob

func ToGob[T any](from T) []byte

Types

type Difficulty

type Difficulty int
const (
	EASY Difficulty = iota
	NORMAL
	HARD
)

type Event

type Event struct {
	Type     EventType
	Position Point
}

func NewEvent

func NewEvent(t EventType, pos Point) *Event

func NewEventFromBytes

func NewEventFromBytes(bs []byte) *Event

func (*Event) Bytes

func (e *Event) Bytes() []byte

func (*Event) String

func (e *Event) String() string

type EventType

type EventType int
const (
	NoOp EventType = iota
	CursorMove
	OpenCell
)

type Game

type Game struct {
	M          *Model
	Difficulty Difficulty
	// contains filtered or unexported fields
}

func NewGame

func NewGame(difficulty Difficulty, dbg bool) *Game

func (*Game) Bytes

func (g *Game) Bytes() []byte

func (*Game) OpenCell

func (g *Game) OpenCell(p Point)

func (Game) String

func (g Game) String() string

type Logger

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

func NewLogger

func NewLogger() Logger

func (Logger) GetLogs

func (l Logger) GetLogs() []string

func (Logger) Write

func (l Logger) Write(p []byte) (n int, err error)

type Model

type Model struct {
	Field, Mines [][]rune
	N, M         int
	LeftToOpen   int
	State        int

	Dbg bool
}

func NewModel

func NewModel(n, m, minesCount int, dbg bool) Model

type Point

type Point [2]int

func (*Point) FromGob

func (p *Point) FromGob(from []byte)

func (*Point) String

func (p *Point) String() string

func (*Point) ToGob

func (p *Point) ToGob() []byte

Jump to

Keyboard shortcuts

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