gameboard 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/gameboard/board.rb +11 -2
- 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: a75a1e26fff0c9732c3ceb2df8bc9560ef11f384
|
4
|
+
data.tar.gz: 830853508ed74e568473d9e3ae203c712477b6b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c0c783cfa27f534786b4e18aec2b8325cea9c778ce5b55cbace5fb3c8872029b7ef386d85a81b642403e18fe3ebdbae32bbf4c2c35910f5b6e9689cb39a952
|
7
|
+
data.tar.gz: d4532686715873ca4a71cbc831bbab40770d218a91cef773b9dcf7cd475188d42a819e2420e0b1203f3acc4b9ac69d9355918a4a733e3193eba79876975de94a
|
data/README.md
CHANGED
@@ -23,6 +23,10 @@
|
|
23
23
|
|
24
24
|
- Includes the Enumerable module.
|
25
25
|
|
26
|
+
- Methods, for modifying Board data:
|
27
|
+
- Gameboard::Board.randomize(value)
|
28
|
+
- Gameboard::Board.set_cell([x,y], value)
|
29
|
+
|
26
30
|
- Methods for returning different arrangements of cells of the on the board:
|
27
31
|
- Gameboard::Board.horizontal
|
28
32
|
- Gameboard::Board.vertical
|
data/lib/gameboard/board.rb
CHANGED
@@ -338,8 +338,17 @@ module Gameboard
|
|
338
338
|
end
|
339
339
|
end
|
340
340
|
|
341
|
+
# Public: Set random cells to a given value.
|
342
|
+
#
|
343
|
+
# piece - A value to set to cells
|
344
|
+
#
|
345
|
+
def randomize(piece)
|
346
|
+
rand(1...board.length).times do
|
347
|
+
board[rand(board.length)].value = piece
|
348
|
+
end
|
349
|
+
end
|
341
350
|
# Public: Set a cells value at a given coordinate
|
342
|
-
#
|
351
|
+
#
|
343
352
|
# coord - A coordinate pair in the form X, Y
|
344
353
|
def set_cell(coord, value)
|
345
354
|
cell = find_cell(coord)
|
@@ -477,7 +486,7 @@ module Gameboard
|
|
477
486
|
|
478
487
|
# Internal: use the Coordinate::neighbors function to collect the
|
479
488
|
# neighbors of a given Coordinate on the existing gameboard
|
480
|
-
#
|
489
|
+
#
|
481
490
|
# point - instance of Coordinate class at a specific x,y point
|
482
491
|
def valid_neighbors(coord)
|
483
492
|
coord.neighbors.collect { |point| find_cell(point) }.compact
|
data/lib/gameboard/version.rb
CHANGED