minesweeper-cli 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/minesweeper/game.rb +1 -1
- data/lib/minesweeper/playfield.rb +9 -9
- data/lib/minesweeper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f0c08e11c5a81900fd32c6bbc6cc8741d7c99d6
|
4
|
+
data.tar.gz: bed5cf67783727d4e705f76fd3c841b55dcb9810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f57c19f8987d78d3e0fdcb5e3e11a14e5af05a32e6eeefdb994c1e9f280c53209f6bca2f6db4d6cc3210196c9a0e17afd44f3a069c608c2d26b0dcc699605375
|
7
|
+
data.tar.gz: 7794734fa037b9aa9a83e247dce7c21614047f2a90a562ca32cbc07f78391147d5cd4a052bcf13bdccac98091af1cb1d0b7cb69d8df4a7b35e13deeb6492b852
|
data/README.md
CHANGED
@@ -13,11 +13,11 @@ It comes conveniently packaged as a gem:
|
|
13
13
|
|
14
14
|
From the command line:
|
15
15
|
|
16
|
-
|
16
|
+
`minesweeper`
|
17
17
|
|
18
18
|
To get some help and options:
|
19
19
|
|
20
|
-
|
20
|
+
`minesweeper -h`
|
21
21
|
|
22
22
|
By default it's a 10x5 grid, with 3 hidden mines.
|
23
23
|
|
data/lib/minesweeper/game.rb
CHANGED
@@ -4,21 +4,21 @@ require_relative 'square'
|
|
4
4
|
module Minesweeper
|
5
5
|
class Playfield
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@display_set = display_set
|
9
|
-
@mine_number = mine_number
|
10
|
-
@rows = rows
|
11
|
-
@cols = cols
|
7
|
+
def initialize(options = {})
|
8
|
+
@display_set = options[:display_set]
|
9
|
+
@mine_number = options[:mine_number]
|
10
|
+
@rows = options[:rows]
|
11
|
+
@cols = options[:cols]
|
12
12
|
|
13
13
|
@revealed_squares = Set.new
|
14
14
|
@mines = Set.new
|
15
|
-
@playfield = Array.new(rows) { Array.new(cols) }
|
15
|
+
@playfield = Array.new(@rows) { Array.new(@cols) }
|
16
16
|
|
17
|
-
until mine_number.zero?
|
18
|
-
mine_position = [rand(rows), rand(cols)]
|
17
|
+
until options[:mine_number].zero?
|
18
|
+
mine_position = [rand(@rows), rand(@cols)]
|
19
19
|
unless @mines.include?(mine_position)
|
20
20
|
@mines << mine_position
|
21
|
-
mine_number -= 1
|
21
|
+
options[:mine_number] -= 1
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/minesweeper/version.rb
CHANGED