gameboard 3.3.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a75a1e26fff0c9732c3ceb2df8bc9560ef11f384
4
- data.tar.gz: 830853508ed74e568473d9e3ae203c712477b6b5
3
+ metadata.gz: 76a2c121404f3a2b813bfea13c03ee703bf80cdc
4
+ data.tar.gz: 87fed90228c76fd036d1dbba598be427e77bfe25
5
5
  SHA512:
6
- metadata.gz: c3c0c783cfa27f534786b4e18aec2b8325cea9c778ce5b55cbace5fb3c8872029b7ef386d85a81b642403e18fe3ebdbae32bbf4c2c35910f5b6e9689cb39a952
7
- data.tar.gz: d4532686715873ca4a71cbc831bbab40770d218a91cef773b9dcf7cd475188d42a819e2420e0b1203f3acc4b9ac69d9355918a4a733e3193eba79876975de94a
6
+ metadata.gz: 260a7d4efc6d7f8fbe6106a912743177727ecfc722edde0a51c9e79f5ef3c18eb8f9296b654e2bb1f3b56890c2086108a57c340261efd6da3a5f64bde56098e6
7
+ data.tar.gz: 1929e29c05557e9cc156d2cc85429586b135fad9ecbff8208b877a1cbc6a969e99d15bfa94b78fd34f86476fa04ba109a3845eff39d476f06d34821deba73bd7
data/README.md CHANGED
@@ -26,6 +26,7 @@
26
26
  - Methods, for modifying Board data:
27
27
  - Gameboard::Board.randomize(value)
28
28
  - Gameboard::Board.set_cell([x,y], value)
29
+ - Gameboard::Board.flip (rage reset the board)
29
30
 
30
31
  - Methods for returning different arrangements of cells of the on the board:
31
32
  - Gameboard::Board.horizontal
@@ -69,6 +69,7 @@ module Gameboard
69
69
  raise ArgumentError unless ((height.is_a?(Integer) && width.is_a?(Integer)) || !!preset)
70
70
  @height = height
71
71
  @width = width
72
+ @nailed = false
72
73
  @cells = cells || nil
73
74
  preset ? load_game(preset) : new_board
74
75
  end
@@ -207,6 +208,10 @@ module Gameboard
207
208
  diagonals
208
209
  end
209
210
 
211
+ def empty?
212
+ board.all? { |cell| cell.value == cells }
213
+ end
214
+
210
215
  # Public: Find a cell at given coordinate.
211
216
  #
212
217
  # coord - An X,Y coordinate passed as an Array.
@@ -235,6 +240,14 @@ module Gameboard
235
240
  board.find {|cell| cell.coord.position == coord}
236
241
  end
237
242
 
243
+ # Public: Resets the board unless nailed down. All pieces will be set
244
+ # to the default value.
245
+ #
246
+ def flip
247
+ raise "The Board is Nailed to the Table" unless !nailed_down?
248
+ board.each {|cell| cell.value = cells}
249
+ end
250
+
238
251
  # Public: Check if the gameboard is full relative to the default cell.
239
252
  #
240
253
  #
@@ -303,10 +316,21 @@ module Gameboard
303
316
  rows
304
317
  end
305
318
 
319
+ # Public: Nail the board down so it can't be flipped.
320
+ def nail_down
321
+ @nailed = true
322
+ end
323
+
324
+ # Public: Return whether the board is nailed down.
325
+ def nailed_down?
326
+ !!nailed
327
+ end
328
+
306
329
  # Public: Return all valid neighbors of a given coordinate.
307
330
  #
308
331
  # point - The X,Y coordinate neighbors should be based off of.
309
- # coords - An optional boolean to return an array of coordinate pairs
332
+ # coords - An optional boolean to return an array of coordinate
333
+ # pairs
310
334
  #
311
335
  #
312
336
  # Examples
@@ -401,6 +425,8 @@ module Gameboard
401
425
  attr_reader :board
402
426
  # Internal: Returns the default gameboard cell value
403
427
  attr_reader :cells
428
+ # Internal: Stores whether the board is nailed down
429
+ attr_reader :nailed
404
430
 
405
431
  # Internal: return a diagonal array given a starting point and a
406
432
  # slope.
@@ -1,3 +1,3 @@
1
1
  module Gameboard
2
- VERSION = "3.3.0"
2
+ VERSION = "3.5.0"
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: 3.3.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley