battle_boats 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/battle_boats/board.rb +7 -5
- data/lib/battle_boats/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd682e0861405e9ba63712042de47b7535a90818
|
4
|
+
data.tar.gz: 0e7466e52726d61e276e96070b8e79784177713c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9760256d3da92abed54880362f771dabcf02dac95b5c43f0e99544ee5dce26458c6dda6c320a5a24e19c9d153adcea5d7d39bb4e96a9174b0806d27188eeb243
|
7
|
+
data.tar.gz: 3f098298b553b2db0e6c950a5743c96e5a36110108a37bb2cf75d143bca1d836eb7b52dc7ca1aefc94fde18414b25fe9223a3aad77ce1217851b85929f91e307
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/battle_boats/board.rb
CHANGED
@@ -3,11 +3,12 @@ require "battle_boats/fleet"
|
|
3
3
|
|
4
4
|
module BattleBoats
|
5
5
|
class Board
|
6
|
-
attr_reader :fleet, :play_area, :status_report
|
6
|
+
attr_reader :fleet, :board_size, :play_area, :status_report
|
7
7
|
|
8
8
|
def initialize(fleet: BattleBoats::Fleet.new)
|
9
9
|
@fleet = fleet
|
10
10
|
@status_report = ""
|
11
|
+
@board_size = 10
|
11
12
|
@play_area = create_play_area
|
12
13
|
end
|
13
14
|
|
@@ -67,15 +68,15 @@ module BattleBoats
|
|
67
68
|
end
|
68
69
|
|
69
70
|
def get_random_coordinate
|
70
|
-
BattleBoats::Coordinate.random(row: 0
|
71
|
+
BattleBoats::Coordinate.random(row: 0...board_size, column: 0...board_size)
|
71
72
|
end
|
72
73
|
|
73
74
|
private
|
74
75
|
|
75
76
|
def create_play_area
|
76
|
-
Array.new(
|
77
|
+
Array.new(board_size) do
|
77
78
|
row = []
|
78
|
-
|
79
|
+
board_size.times do
|
79
80
|
row << BattleBoats::Cell.new
|
80
81
|
end
|
81
82
|
row
|
@@ -87,7 +88,8 @@ module BattleBoats
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def within_range?(coordinate:)
|
90
|
-
|
91
|
+
(0...board_size).cover?(coordinate.row) &&
|
92
|
+
(0...board_size).cover?(coordinate.column)
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
data/lib/battle_boats/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: battle_boats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Countz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|