game

package
v0.0.0-...-ecfdd64 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hidden   = 0
	Revealed = 1
	Flagged  = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

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

func NewBoard

func NewBoard(numberRows, numberColumns, numberBombs int) *Board

func (*Board) Display

func (b *Board) Display()

func (*Board) DisplayNoHidden

func (b *Board) DisplayNoHidden()

func (*Board) Flag

func (b *Board) Flag(row, column int) bool

return: true if the square is valid, false otherwise

func (*Board) GetSquare

func (b *Board) GetSquare() [][]*Square

func (*Board) Play

func (b *Board) Play(row, column int) PlayReturn

func (*Board) Unflag

func (b *Board) Unflag(row, column int) bool

return: true if the square is valid, false otherwise

type IBoard

type IBoard interface {
	NewBoard(numberRows, numberColumns, numberBombs, numberDugTiles int) *Board // create a new board
	Play(row, column int)                                                       // Play a square
	Flag(row, column int)                                                       // Flag a square
	Unflag(row, column int)                                                     // Unflag a square
	Display()                                                                   // display board with hidden squares
	DisplayNoHidden()                                                           // display board without hidden squares
}

type PlayRecursiveReturn

type PlayRecursiveReturn struct {
	IsPlayed bool
	IsLost   bool
}

type PlayReturn

type PlayReturn struct {
	IsPlayed bool
	IsWin    bool
	IsLost   bool
}

type Square

type Square struct {
	State  int  `json:"state"`
	Value  int  `json:"value"`
	IsBomb bool `json:"isBomb"`
}

Jump to

Keyboard shortcuts

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