Pushing all changes
This commit is contained in:
@@ -8,8 +8,8 @@ RSpec.describe Planet do
|
||||
let(:seed) { 12345 }
|
||||
let(:random) { Random.new(seed) }
|
||||
let(:planet) { Planet.new(random) }
|
||||
let(:player_1) {Player.new('tester 01') }
|
||||
let(:player_2) {Player.new('tester 02') }
|
||||
let(:player_1) { Player.new('tester 01') }
|
||||
let(:player_2) { Player.new('tester 02') }
|
||||
|
||||
describe '#initialize' do
|
||||
it 'stores the random off' do
|
||||
@@ -41,4 +41,12 @@ RSpec.describe Planet do
|
||||
expect(planet.instance_variable_get(:@owner)).to eq player_2
|
||||
end
|
||||
end
|
||||
|
||||
describe '#tick' do
|
||||
it 'adds resources to the Players storage' do
|
||||
planet.change_owner(player_1)
|
||||
planet.tick
|
||||
expect(player_1.resources).to eq('')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Nahtan Hinton 3 Oct 2025
|
||||
|
||||
require './player'
|
||||
|
||||
RSpec.describe Player do
|
||||
let(:player_1) { Player.new('tester 01') }
|
||||
describe '#initialize' do
|
||||
it 'sets the player name' do
|
||||
expect(player_1.instance_variable_get(:@name)).to eq 'tester 01'
|
||||
end
|
||||
|
||||
it 'gives initial resources' do
|
||||
expect(player_1.instance_variable_get(:@resources)).to eq ({:ships => 10, :metal => 100})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -147,4 +147,17 @@ RSpec.describe Universe do
|
||||
expect(universe.planets.length).to eq 18
|
||||
end
|
||||
end
|
||||
|
||||
describe '#tick' do
|
||||
it 'runs a tick of the game' do
|
||||
universe.create_universe
|
||||
player_1 = Player.new('test player 01')
|
||||
universe.add_player(player_1)
|
||||
universe.add_ship(player_1, Position.new(3, 5))
|
||||
ships = universe.get_player_ships(player_1)
|
||||
universe.move_ship(player_1, ships[0], Position.new(2, 4))
|
||||
# Now we tick the universe and the ship should move a little and the player should gain resources.
|
||||
expect{universe.tick}.to_not raise_error()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user