game

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package game handles creating and managing the state of a game

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameConfig

type GameConfig struct {
	NumMines     int
	NumRows      int
	NumCols      int
	FlagsEnabled bool
	Lives        int
	Seed         string
}

type IGame

type IGame interface {
	/*
		Config returns the configuration data for a game.
	*/
	Config() *config
	/*
		StartTime returns the Time object of when the game started.
	*/
	StartTime() time.Time
	/*
		State returns information about the game's state.
		0 = on going
		1 = ended in win
		2 = ended in loss
	*/
	State() int
	/*
		Tile searches for the tile in the requested row and column.
		The row and column coordinates are zero-indexed.
	*/
	Tile(rowIndex int, colIndex int) (minefield.ITile, error)
	/*
		RevealTile reveals the requested tile.
		If the tile is empty the patch it belongs to will be revealed.
	*/
	RevealTile(rowIndex int, colIndex int) ([]int, error)
	/*
		ToggleFlag flips the flag state for the requested tile.
	*/
	ToggleFlag(rowIndex int, colIndex int) error
	/*
		ProcessAdjacentTiles applies to a revealed tile and will check the adjacent
		tiles for flags.
		If the number of adjacent flags is >= the number on the tile it will reveal
		all adjacent tiles without a flag.
	*/
	ProcessAdjacentTiles(rowIndex int, colIndex int) ([]int, error)
	/*
		Stats returns information about the current game.
	*/
	Stats() stats
}

func Generate

func Generate(args GameConfig) IGame

Generate creates a new game with the provided configuration and returns the a game instance

Jump to

Keyboard shortcuts

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