board_game_grid 0.1.2 → 0.1.3
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/lib/board_game_grid/square_set.rb +33 -0
- data/lib/board_game_grid/vector.rb +7 -3
- data/lib/board_game_grid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30b06334909c284fa4df43311e971bad13b2d4b03ad0c95e09e5f05ec2240d7b
|
4
|
+
data.tar.gz: f9821c6b664ab4eb5cd0c766e2e4b556eab40067517c9fea3abc38bf53d36205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c290da6cb71e2ef9b9eb2c841f2e86a6f165ebcf1d9fbc433f40d98f9e2117a4b3f5b1bd4bf47662489fc883a0841b67386d6b85d9eaec9d687b99c920b29cd9
|
7
|
+
data.tar.gz: 7be305c897cfb2290e574a6d403f71c60499f7a6315c015e4a3c1822a1f512ee19443424dde9f3e9569917885434923fc78343ae5abea11300c203b7e8305a01
|
@@ -220,6 +220,39 @@ module BoardGameGrid
|
|
220
220
|
select { |square| Vector.new(origin, square).magnitude == distance }
|
221
221
|
end
|
222
222
|
|
223
|
+
|
224
|
+
# Find all squares a certain number of ranks away
|
225
|
+
#
|
226
|
+
# @param [Square] origin
|
227
|
+
# the originating square
|
228
|
+
#
|
229
|
+
# @param [Fixnum] distance
|
230
|
+
# the specified distance from the square
|
231
|
+
#
|
232
|
+
# @return [SquareSet]
|
233
|
+
# ==== Example:
|
234
|
+
# # Get all squares at 2 ranks away from square_a
|
235
|
+
# square_set.ranks_away(square_a, 2)
|
236
|
+
def ranks_away(origin, distance)
|
237
|
+
select { |square| Vector.new(origin, square).dy.abs == distance }
|
238
|
+
end
|
239
|
+
|
240
|
+
# Find all squares a certain number of files away
|
241
|
+
#
|
242
|
+
# @param [Square] origin
|
243
|
+
# the originating square
|
244
|
+
#
|
245
|
+
# @param [Fixnum] distance
|
246
|
+
# the specified distance from the square
|
247
|
+
#
|
248
|
+
# @return [SquareSet]
|
249
|
+
# ==== Example:
|
250
|
+
# # Get all squares at 2 ranks away from square_a
|
251
|
+
# square_set.files_away(square_a, 2)
|
252
|
+
def files_away(origin, distance)
|
253
|
+
select { |square| Vector.new(origin, square).dx.abs == distance }
|
254
|
+
end
|
255
|
+
|
223
256
|
# Find all squares orthogonal from square
|
224
257
|
#
|
225
258
|
# @param [Square] square
|
@@ -73,14 +73,18 @@ module BoardGameGrid
|
|
73
73
|
orthogonal? || diagonal?
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
# The distance on the x axis
|
77
|
+
#
|
78
|
+
# @return [Fixnum]
|
78
79
|
def dx
|
79
80
|
destination.x - origin.x
|
80
81
|
end
|
81
82
|
|
83
|
+
# The distance on the y axis
|
84
|
+
#
|
85
|
+
# @return [Fixnum]
|
82
86
|
def dy
|
83
87
|
destination.y - origin.y
|
84
88
|
end
|
85
89
|
end
|
86
|
-
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: board_game_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Humphreys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|