wip: generate report
This commit is contained in:
@@ -167,49 +167,47 @@ func TestProduceShips(t *testing.T) {
|
||||
|
||||
func TestProduceShip(t *testing.T) {
|
||||
Drone := game.ShipType{
|
||||
ShipTypeReport: game.ShipTypeReport{
|
||||
Name: "Drone",
|
||||
Drive: 1,
|
||||
Armament: 0,
|
||||
Weapons: 0,
|
||||
Shields: 0,
|
||||
Cargo: 0,
|
||||
},
|
||||
Name: "Drone",
|
||||
Drive: 1,
|
||||
Armament: 0,
|
||||
Weapons: 0,
|
||||
Shields: 0,
|
||||
Cargo: 0,
|
||||
}
|
||||
BattleShip := game.ShipType{
|
||||
ShipTypeReport: game.ShipTypeReport{
|
||||
Name: "BattleShip",
|
||||
Drive: 25,
|
||||
Armament: 1,
|
||||
Weapons: 30,
|
||||
Shields: 35,
|
||||
Cargo: 0,
|
||||
},
|
||||
Name: "BattleShip",
|
||||
Drive: 25,
|
||||
Armament: 1,
|
||||
Weapons: 30,
|
||||
Shields: 35,
|
||||
Cargo: 0,
|
||||
}
|
||||
p := controller.NewPlanet(0, "Planet_0", uuid.New(), 1, 1, 1000, 1000, 1000, 10, game.ProductionShip.AsType(uuid.Nil))
|
||||
|
||||
r := controller.ProduceShip(&p, Drone.EmptyMass())
|
||||
r := controller.ProduceShip(&p, p.ProductionCapacity(), Drone.EmptyMass())
|
||||
assert.Equal(t, uint(99), r)
|
||||
assert.InDelta(t, 0.0099, *p.Production.Progress, 0.000001)
|
||||
|
||||
(&p).Production = game.ProductionShip.AsType(uuid.Nil)
|
||||
(&p).Capital = 10.
|
||||
r = controller.ProduceShip(&p, Drone.EmptyMass())
|
||||
r = controller.ProduceShip(&p, p.ProductionCapacity(), Drone.EmptyMass())
|
||||
assert.Equal(t, uint(100), r)
|
||||
assert.Equal(t, 0., *p.Production.Progress)
|
||||
assert.Equal(t, 0., number.Fixed3(p.Capital.F())) // TODO: zero CAP is not actual '0.0' after series of decrements
|
||||
|
||||
(&p).Production = game.ProductionShip.AsType(uuid.Nil)
|
||||
(&p).Capital = 0.
|
||||
r = controller.ProduceShip(&p, BattleShip.EmptyMass())
|
||||
r = controller.ProduceShip(&p, p.ProductionCapacity(), BattleShip.EmptyMass())
|
||||
assert.Equal(t, uint(1), r)
|
||||
assert.InDelta(t, 0.1, *p.Production.Progress, 0.001)
|
||||
|
||||
(&p).Production = game.ProductionShip.AsType(uuid.Nil)
|
||||
(&p).Capital = 20.
|
||||
r = controller.ProduceShip(&p, BattleShip.EmptyMass())
|
||||
r = controller.ProduceShip(&p, p.ProductionCapacity(), BattleShip.EmptyMass())
|
||||
assert.Equal(t, uint(1), r)
|
||||
assert.Equal(t, 1./9., *p.Production.Progress)
|
||||
|
||||
// TODO: test with insufficient production capacity
|
||||
}
|
||||
|
||||
func TestListProducingPlanets(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user