gameboard 2.0.0 → 2.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/lib/gameboard.rb +1 -1
- data/lib/gameboard/board.rb +9 -9
- data/lib/gameboard/cell.rb +1 -1
- data/lib/gameboard/coordinate.rb +1 -1
- data/lib/gameboard/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: bcfddb51f3639e1373ef17d1d4a881dd9dded868
|
4
|
+
data.tar.gz: 69e07edf0d00b39334265b1d5f8abb4ada46b31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2d86c808b6f71b017a4f721d22cfc2bced6c3c1ab2cea591ef69e32c46a43cacce0d6e58188ba357a6b0250a2a7c6eb7836290d12960395c7367ee6c6fe94db
|
7
|
+
data.tar.gz: 58e1c58dafb7e3c0a8213f7d5ab8cb2e9b904c8515573a855d7de6093a7a107ffa32c959ccbed8140c8dc56fae86e917f8c1f32cccf178e43dc7435262c29d38
|
data/lib/gameboard.rb
CHANGED
data/lib/gameboard/board.rb
CHANGED
@@ -39,11 +39,11 @@ module Gameboard
|
|
39
39
|
def diagonal(coords = false)
|
40
40
|
diagonals = []
|
41
41
|
|
42
|
-
height.times do |i|
|
42
|
+
height.times do |i|
|
43
43
|
diagonals << get_diagonal([0, i], coords)
|
44
44
|
diagonals << get_diagonal([0, height - 1 - i], coords, false)
|
45
45
|
end
|
46
|
-
(1...width).each do
|
46
|
+
(1...width).each do
|
47
47
|
|i| diagonals << get_diagonal([i, 0], coords)
|
48
48
|
diagonals << get_diagonal([i, height - 1], coords, false)
|
49
49
|
end
|
@@ -62,8 +62,8 @@ module Gameboard
|
|
62
62
|
def horizontal(coords = false)
|
63
63
|
columns = []
|
64
64
|
height.times do |y|
|
65
|
-
columns << board.select { |cell| cell.coord.y == y }.map do |cell|
|
66
|
-
coords ? cell.coord.position : cell.value
|
65
|
+
columns << board.select { |cell| cell.coord.y == y }.map do |cell|
|
66
|
+
coords ? cell.coord.position : cell.value
|
67
67
|
end
|
68
68
|
end
|
69
69
|
columns
|
@@ -83,7 +83,7 @@ module Gameboard
|
|
83
83
|
|
84
84
|
def neighbors(coord, points = false)
|
85
85
|
temp = Coordinate.new(coord[0], coord[1])
|
86
|
-
valid_neighbors(temp).map do |cell|
|
86
|
+
valid_neighbors(temp).map do |cell|
|
87
87
|
points ? cell.coord.position : cell.value
|
88
88
|
end
|
89
89
|
end
|
@@ -100,8 +100,8 @@ module Gameboard
|
|
100
100
|
def vertical(coords = false)
|
101
101
|
columns = []
|
102
102
|
width.times do |x|
|
103
|
-
columns << board.select { |cell| cell.coord.x == x }.map do |cell|
|
104
|
-
coords ? cell.coord.position : cell.value
|
103
|
+
columns << board.select { |cell| cell.coord.x == x }.map do |cell|
|
104
|
+
coords ? cell.coord.position : cell.value
|
105
105
|
end
|
106
106
|
end
|
107
107
|
columns
|
@@ -112,13 +112,13 @@ module Gameboard
|
|
112
112
|
|
113
113
|
def get_diagonal(start, coords, slope = true)
|
114
114
|
oper = (slope == true ? :+ : :-)
|
115
|
-
diagonal = (0...height).map do |i|
|
115
|
+
diagonal = (0...height).map do |i|
|
116
116
|
position = [start[0] + i, start[1].send(oper, i)]
|
117
117
|
if ((0...width).include?(start[0] + i) && (0...height).include?(start[1].send(oper, i)))
|
118
118
|
board.find {|cell| cell.coord.position == position}
|
119
119
|
end
|
120
120
|
end
|
121
|
-
diagonal.compact.map{|cell| coords ? cell.coord.position : cell.value }
|
121
|
+
diagonal.compact.map{|cell| coords ? cell.coord.position : cell.value }
|
122
122
|
end
|
123
123
|
|
124
124
|
def valid_neighbors(coord)
|
data/lib/gameboard/cell.rb
CHANGED
data/lib/gameboard/coordinate.rb
CHANGED
data/lib/gameboard/version.rb
CHANGED