-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.rb
41 lines (37 loc) · 979 Bytes
/
run.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require './src/Game/Engine'
require './src/Game/Exceptions/CoordinatesAlreadyTaken'
require './src/Game/Exceptions/CoordinatesOutOfGrid'
require './src/Game/Grid'
require './src/Game/Grid/Coordinates'
require './src/Game/Ship'
require './src/Game/Ship/Orientation'
require './src/UserInterface/Renderer'
require './src/UserInterface/Console'
require './src/Utils/Calculator'
grid_size = 10
grid = Game::Grid.new(grid_size)
engine = Game::Engine.new(grid)
sizes = [5, 4, 4]
while sizes.length > 0
begin
grid.add_ship(
Game::Ship.new(
sizes.first,
Game::Ship::Orientation.all[rand(0..1)],
Game::Grid::Coordinates.new(
rand(0..(grid_size - 1)),
rand(0..(grid_size - 1))
)
)
)
sizes.shift
rescue Game::Exceptions::CoordinatesAlreadyTaken, Game::Exceptions::CoordinatesOutOfGrid
# just continue
end
end
UserInterface::Console.new(
engine,
UserInterface::Renderer.new(
grid
)
).run