battle_boats 0.0.20 → 0.1.0
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/bin/battle_boats +4 -3
- data/lib/battle_boats/engine.rb +25 -9
- data/lib/battle_boats/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: 61b60dbcbc5c2bacf5a9690767c0e8cb0fb63b93
|
4
|
+
data.tar.gz: 2fd42e2e42aee3d500a4d80025183e5f545c82b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97c3219a5f1dfa994cc2aabb0a4c716f5b044296a7a5f3efb862c5ecc5f889c68becb3a746ffece89770227137b9728c91e27c944636ad59549894cd371070a0
|
7
|
+
data.tar.gz: 5b165df1380372d778d6c5708a063de0269912f6c28bc85efe6444d1db770ecf990b0fc8892e30106ba6985c75c27ed88ec77e47c3d12948563c90bda119c2f1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.1.0
|
2
|
+
### New Features
|
3
|
+
- At the start of the game, the user will be prompted to place their ships on their board
|
4
|
+
- After all ships are place, the game will continue as it previously had
|
5
|
+
|
1
6
|
# 0.0.20
|
2
7
|
### Breaking Change
|
3
8
|
- `battle_boats "dev"` is not longer available
|
data/Gemfile.lock
CHANGED
data/bin/battle_boats
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
require 'battle_boats/engine'
|
4
4
|
require 'battle_boats/board'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
enemy_board = BattleBoats::Board.new
|
7
|
+
enemy_board.place_ships_randomly
|
8
8
|
|
9
|
-
engine = BattleBoats::Engine.new(
|
9
|
+
engine = BattleBoats::Engine.new(enemy_board: enemy_board)
|
10
|
+
engine.place_ships_manually
|
10
11
|
engine.start
|
11
12
|
|
data/lib/battle_boats/engine.rb
CHANGED
@@ -4,28 +4,44 @@ require_relative "console_ui"
|
|
4
4
|
module BattleBoats
|
5
5
|
class Engine
|
6
6
|
def initialize(interface: BattleBoats::ConsoleUI.new,
|
7
|
-
|
7
|
+
enemy_board: BattleBoats::Board.new,
|
8
|
+
ally_board: BattleBoats::Board.new)
|
8
9
|
@interface = interface
|
9
|
-
@
|
10
|
+
@enemy_board = enemy_board
|
11
|
+
@ally_board = ally_board
|
12
|
+
end
|
13
|
+
|
14
|
+
def place_ships_manually
|
15
|
+
ally_board.fleet.ships.each do |ship|
|
16
|
+
until ally_board.ship_deployed?(ship: ship)
|
17
|
+
interface.display_ally_board(ally_board)
|
18
|
+
interface.display_ship_data(ship: ship)
|
19
|
+
coordinate = interface.get_coordinate
|
20
|
+
orientation = interface.get_orientation
|
21
|
+
ally_board.attempt_to_deploy_ship(ship: ship,
|
22
|
+
coordinate: coordinate,
|
23
|
+
orientation: orientation)
|
24
|
+
end
|
25
|
+
end
|
10
26
|
end
|
11
27
|
|
12
28
|
def start
|
13
29
|
interface.greet
|
14
|
-
until
|
15
|
-
interface.display_board(
|
30
|
+
until enemy_board.game_over?
|
31
|
+
interface.display_board(enemy_board)
|
16
32
|
coordinate = interface.get_coordinate
|
17
|
-
until
|
18
|
-
interface.display_status_report(
|
33
|
+
until enemy_board.strike_position(coordinate: coordinate)
|
34
|
+
interface.display_status_report(enemy_board.status_report)
|
19
35
|
coordinate = interface.get_coordinate
|
20
36
|
end
|
21
|
-
interface.display_status_report(
|
37
|
+
interface.display_status_report(enemy_board.status_report)
|
22
38
|
end
|
23
39
|
interface.win
|
24
|
-
interface.display_board(
|
40
|
+
interface.display_board(enemy_board)
|
25
41
|
end
|
26
42
|
|
27
43
|
private
|
28
44
|
|
29
|
-
attr_reader :interface, :
|
45
|
+
attr_reader :interface, :enemy_board, :ally_board
|
30
46
|
end
|
31
47
|
end
|
data/lib/battle_boats/version.rb
CHANGED