minesweeper-curses 0.2.1 → 0.3.0
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/.rubocop.yml +13 -0
- data/Gemfile.lock +1 -1
- data/lib/minesweeper/base_cell.rb +1 -1
- data/lib/minesweeper/board.rb +13 -14
- data/lib/minesweeper/board_builder.rb +10 -10
- data/lib/minesweeper/bomb_cell.rb +1 -1
- 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: 72a271c6a7011e3729fe7f9afc4ad0300e511dff
|
4
|
+
data.tar.gz: 2bbefb3ff25068f81b003bec8e2c995f4e941e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66916578e24ee520662ee5c69f4f55da5f7403602d7177a265d443aa4695b05cb7657fea7a20a766bbe67e056841556824fdb30d676a9d6a3fa74c47167ce7a4
|
7
|
+
data.tar.gz: 226ffa6c95f0ff892dfefd11db791e858789cc1be5a58ee3ccd35590a4ca31a4a9090fb93e0f634343c642b30a1db47c1b1004ae664d88e5b4a8e3b57496e534
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- Rakefile
|
4
|
+
- config.ru
|
5
|
+
Excludes:
|
6
|
+
- db/**
|
7
|
+
- config/**
|
8
|
+
- script/**
|
9
|
+
- minesweeper.gemspec
|
10
|
+
|
11
|
+
Documentation:
|
12
|
+
Enabled: false
|
13
|
+
|
1
14
|
Metrics/LineLength:
|
2
15
|
Max: 120
|
3
16
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
data/Gemfile.lock
CHANGED
data/lib/minesweeper/board.rb
CHANGED
@@ -10,12 +10,12 @@ module Minesweeper
|
|
10
10
|
SPACE = ' '
|
11
11
|
|
12
12
|
def_delegators :@window, :curx, :cury
|
13
|
+
def_delegators :board_params, :height, :width
|
13
14
|
|
14
|
-
attr_reader :
|
15
|
+
attr_reader :board_params, :cells, :window
|
15
16
|
|
16
|
-
def initialize(
|
17
|
-
@
|
18
|
-
@width = width
|
17
|
+
def initialize(board_params:, window:)
|
18
|
+
@board_params = board_params
|
19
19
|
@window = window
|
20
20
|
@cells = []
|
21
21
|
end
|
@@ -38,12 +38,11 @@ module Minesweeper
|
|
38
38
|
when KEY_RIGHT
|
39
39
|
move_right
|
40
40
|
when ENTER
|
41
|
-
open_cell
|
42
|
-
play(cury, curx)
|
41
|
+
open_cell
|
43
42
|
when SPACE
|
44
|
-
toggle_bomb_flag
|
45
|
-
play(cury, curx)
|
43
|
+
toggle_bomb_flag
|
46
44
|
end
|
45
|
+
play(cury, curx)
|
47
46
|
end
|
48
47
|
rescue GameWon, GameOver => e
|
49
48
|
end_game(e)
|
@@ -67,14 +66,14 @@ module Minesweeper
|
|
67
66
|
window.setpos(0, 1)
|
68
67
|
end
|
69
68
|
|
70
|
-
def open_cell
|
71
|
-
cell_x =
|
72
|
-
open_original(
|
69
|
+
def open_cell
|
70
|
+
cell_x = curx / STEP
|
71
|
+
open_original(cury, cell_x)
|
73
72
|
end
|
74
73
|
|
75
|
-
def toggle_bomb_flag
|
76
|
-
cell_x =
|
77
|
-
cell = cells[
|
74
|
+
def toggle_bomb_flag
|
75
|
+
cell_x = curx / STEP
|
76
|
+
cell = cells[cury][cell_x]
|
78
77
|
cell.toggle_bomb_flag!
|
79
78
|
raise GameWon if game_won?
|
80
79
|
end
|
@@ -13,30 +13,30 @@ module Minesweeper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def build
|
16
|
-
params_builder.prepare
|
17
|
-
board = create_board
|
18
|
-
fill_with_cells
|
19
|
-
inject_bombs
|
16
|
+
@board_params = params_builder.prepare
|
17
|
+
@board = create_board
|
18
|
+
fill_with_cells
|
19
|
+
inject_bombs
|
20
20
|
board
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
attr_reader :window, :flush_params
|
25
|
+
attr_reader :window, :flush_params, :board_params, :board
|
26
26
|
|
27
|
-
def_delegators :
|
27
|
+
def_delegators :board_params, :height, :width, :level
|
28
28
|
|
29
29
|
def create_board
|
30
|
-
Minesweeper::Board.new(
|
30
|
+
Minesweeper::Board.new(board_params: board_params, window: window)
|
31
31
|
end
|
32
32
|
|
33
|
-
def fill_with_cells
|
33
|
+
def fill_with_cells
|
34
34
|
height.times do
|
35
35
|
board.cells << Array.new(width) { Cell.new }
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def inject_bombs
|
39
|
+
def inject_bombs
|
40
40
|
bomb_injector.inject(board, level)
|
41
41
|
end
|
42
42
|
|
@@ -45,7 +45,7 @@ module Minesweeper
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def params_builder
|
48
|
-
|
48
|
+
Minesweeper::ParamsBuilder.new(window, flush_params)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/minesweeper/version.rb
CHANGED