minesweeper-cli 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f0c08e11c5a81900fd32c6bbc6cc8741d7c99d6
4
- data.tar.gz: bed5cf67783727d4e705f76fd3c841b55dcb9810
3
+ metadata.gz: d00661ac0c3be43ffbccf878e65ab51b824748c1
4
+ data.tar.gz: 6c2a2855f21521b522d2e481cefac2662f083189
5
5
  SHA512:
6
- metadata.gz: f57c19f8987d78d3e0fdcb5e3e11a14e5af05a32e6eeefdb994c1e9f280c53209f6bca2f6db4d6cc3210196c9a0e17afd44f3a069c608c2d26b0dcc699605375
7
- data.tar.gz: 7794734fa037b9aa9a83e247dce7c21614047f2a90a562ca32cbc07f78391147d5cd4a052bcf13bdccac98091af1cb1d0b7cb69d8df4a7b35e13deeb6492b852
6
+ metadata.gz: c1ad65fc67e7a43daaa123716ce06492c2bb465ee7438963ab3da9de7fa17a15b5ac601d2b8076d14fe071546016ac1501cbda2869267f2e253d9174a6d96e72
7
+ data.tar.gz: acee47e68ebd83cc78a4df97473c19da7004b1ff7ce727bb2e8ff88d1aad57e953a23899887d581d2627b980dd2609729c7891f418d1b785a4caf6d3ef119498
@@ -16,6 +16,8 @@ module Minesweeper
16
16
  if input.include? ','
17
17
  y, x = input.split(',').map &:to_i
18
18
 
19
+ next unless @playfield.within_boundaries?(y, x)
20
+
19
21
  puts
20
22
  if @playfield.has_mine?(y, x)
21
23
  @playfield.display_with_mines
@@ -37,6 +37,10 @@ module Minesweeper
37
37
  display
38
38
  end
39
39
 
40
+ def within_boundaries?(y, x)
41
+ y >= 0 && y < @rows && x >= 0 && x < @cols
42
+ end
43
+
40
44
  def has_mine?(y, x)
41
45
  @mines.include?([y, x])
42
46
  end
@@ -1,3 +1,3 @@
1
1
  module Minesweeper
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minesweeper-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Cruz Horts