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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc06eb2b5a787b4ffa5f157f737ac4e06c3431dd
4
- data.tar.gz: 2cc0b36fd6542e428b3af420f0abde9debf42347
3
+ metadata.gz: bcfddb51f3639e1373ef17d1d4a881dd9dded868
4
+ data.tar.gz: 69e07edf0d00b39334265b1d5f8abb4ada46b31d
5
5
  SHA512:
6
- metadata.gz: c7824e45aaf8091103d4be8fcbfc8cf394fcbf87d4601edbc1ae1035ceda53e7722b9ad86b7a2be9aebb080371298ea57497c4ab5c9bfc22f9a6acf94782e7e8
7
- data.tar.gz: dfc07732f725670ba6ebdd2e9fe31c2e610bf71a52fabf178027e262333ea85ea26c3b8fddc9c87fab2799ff1615e86b8bb5b1999524ecb83d2cdce973b22a3a
6
+ metadata.gz: e2d86c808b6f71b017a4f721d22cfc2bced6c3c1ab2cea591ef69e32c46a43cacce0d6e58188ba357a6b0250a2a7c6eb7836290d12960395c7367ee6c6fe94db
7
+ data.tar.gz: 58e1c58dafb7e3c0a8213f7d5ab8cb2e9b904c8515573a855d7de6093a7a107ffa32c959ccbed8140c8dc56fae86e917f8c1f32cccf178e43dc7435262c29d38
data/lib/gameboard.rb CHANGED
@@ -3,5 +3,5 @@ require "gameboard/board"
3
3
 
4
4
  module Gameboard
5
5
  # Your code goes here...
6
-
6
+
7
7
  end
@@ -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)
@@ -3,7 +3,7 @@ module Gameboard
3
3
  class Cell
4
4
  attr_accessor :value
5
5
  attr_reader :coord
6
-
6
+
7
7
  def initialize(coord, value: false)
8
8
  raise TypeError unless coord.is_a?(Coordinate)
9
9
  @value = value
@@ -1,7 +1,7 @@
1
1
  module Gameboard
2
2
  class Coordinate
3
3
  attr_reader :position, :x, :y
4
-
4
+
5
5
  def initialize(x,y)
6
6
  invalid_type = "Coordinates must be integers!"
7
7
  raise invalid_type unless (x.is_a?(Integer) && y.is_a?(Integer))
@@ -1,3 +1,3 @@
1
1
  module Gameboard
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gameboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley