Class: BattleBoats::Engine
- Inherits:
-
Object
- Object
- BattleBoats::Engine
- Defined in:
- lib/battle_boats/engine.rb
Instance Method Summary collapse
-
#initialize(interface: BattleBoats::ConsoleUI.new, board: BattleBoats::Board.new) ⇒ Engine
constructor
A new instance of Engine.
- #start ⇒ Object
Constructor Details
#initialize(interface: BattleBoats::ConsoleUI.new, board: BattleBoats::Board.new) ⇒ Engine
Returns a new instance of Engine.
6 7 8 9 10 |
# File 'lib/battle_boats/engine.rb', line 6 def initialize(interface: BattleBoats::ConsoleUI.new, board: BattleBoats::Board.new) @interface = interface @board = board end |
Instance Method Details
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/battle_boats/engine.rb', line 12 def start interface.greet until board.game_over? interface.display_board(board) coordinate = interface.get_coordinate until board.strike_position(coordinate: coordinate) interface.display_errors(board.) coordinate = interface.get_coordinate end interface.display_status_report(board.status_report) end end |