/minesweeper

Go library minesweeper logic.

Primary LanguageGo



Minesweeper

Game mineswipeer logic.

DependenciesTechnologiesHow To CheckDocumentationContributing

Technologies

Dependencies

Install

With a correctly configured Go toolchain:

go get -u github.com/obarra-dev/minesweeper@latest

Examples

Let's game it out

func main() {
    //start
    mines := []minesweeper.Mine{{Row: 1, Column: 1}}
    game := minesweeper.New(3, 8, mines)
    
    //play
    gameCopy := game.Play(0, 0, minesweeper.TypeMoveClean)
    
    //show game state
    switch gameCopy.State {
    case minesweeper.StateGameNew:
        fmt.Println("Game Start...")
    case minesweeper.StateGameRunning:
        fmt.Println("Running...")
    case minesweeper.StateGameLost:
        fmt.Println("Game lost...")
    case minesweeper.StateGameWon:
        fmt.Println("Game Won...")
    default:
        fmt.Println("Crash...")
    }
}

How To Check

Running the lints

Before running the project lints please ensure that all the dependencies are installed in your system. Then execute the following command:

make lint

Running the tests

In order to run the project tests you need to execute the following command:

make test

Documentation

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes
  4. Run the tests, adding new ones for your own code if necessary (junit5)
  5. Commit your changes (git commit -am 'Added some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request