refactor: game funcs moved to controller
This commit is contained in:
@@ -22,16 +22,16 @@ func TestCreateShips(t *testing.T) {
|
||||
e.GenericErrorText(e.ErrInputEntityNotOwned))
|
||||
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Freighter, R0_Planet_0_num, 1))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 1)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 1)
|
||||
|
||||
assert.NoError(t, c.CreateShips(Race_1_idx, Race_1_Freighter, R1_Planet_1_num, 1))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(1)), 1)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(1)), 1)
|
||||
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Freighter, R0_Planet_0_num, 6))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 2)
|
||||
|
||||
assert.NoError(t, c.CreateShips(Race_1_idx, Race_1_Gunship, R1_Planet_1_num, 1))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(1)), 2)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(1)), 2)
|
||||
}
|
||||
|
||||
func TestJoinEqualGroups(t *testing.T) {
|
||||
@@ -43,48 +43,47 @@ func TestJoinEqualGroups(t *testing.T) {
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Gunship, R0_Planet_0_num, 2)) // (3)
|
||||
assert.NoError(t, c.CreateShips(Race_1_idx, Race_1_Gunship, R1_Planet_1_num, 1))
|
||||
|
||||
// g.Race[Race_0_idx].SetTechLevel(game.TechDrive, 1.5)
|
||||
c.RacetTechLevel(Race_0_idx, game.TechDrive, 1.5)
|
||||
c.RaceTechLevel(Race_0_idx, game.TechDrive, 1.5)
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Gunship, R0_Planet_0_num, 9)) // 4 -> 6
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Freighter, R0_Planet_0_num, 7)) // 5 -> 7
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Gunship, R0_Planet_0_num, 4)) // (6)
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Freighter, R0_Planet_0_num, 4)) // (7)
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
|
||||
// g.Race[Race_1_idx].SetTechLevel(game.TechShields, 2.0)
|
||||
c.RacetTechLevel(Race_1_idx, game.TechShields, 2.0)
|
||||
c.RaceTechLevel(Race_1_idx, game.TechShields, 2.0)
|
||||
assert.Equal(t, 2.0, c.Race(Race_1_idx).Tech[game.TechShields])
|
||||
assert.NoError(t, c.CreateShips(1, Race_1_Freighter, R1_Planet_1_num, 1))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_1_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_1_idx)), 3)
|
||||
|
||||
c.JoinEqualGroups(Race_0_idx)
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_1_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 4)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_1_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 4)
|
||||
|
||||
shipTypeID := func(ri int, name string) uuid.UUID {
|
||||
class, _, ok := c.ShipClass(ri, name)
|
||||
if !ok {
|
||||
t.Fatalf("ShipType not found: %s", name)
|
||||
t.Fatalf("ship_class not found: %s", name)
|
||||
return uuid.Nil
|
||||
}
|
||||
return class.ID
|
||||
}
|
||||
|
||||
for sg := range c.ListShipGroups(Race_0_idx) {
|
||||
for sg := range c.RaceShipGroups(Race_0_idx) {
|
||||
switch {
|
||||
case sg.TypeID == shipTypeID(Race_0_idx, Race_0_Freighter) && sg.TechLevel(game.TechDrive) == 1.1:
|
||||
assert.Equal(t, uint(7), sg.Number)
|
||||
assert.Equal(t, uint(2), sg.Index)
|
||||
assert.Equal(t, uint(1), sg.Index)
|
||||
case sg.TypeID == shipTypeID(Race_0_idx, Race_0_Freighter) && sg.TechLevel(game.TechDrive) == 1.5:
|
||||
assert.Equal(t, uint(11), sg.Number)
|
||||
assert.Equal(t, uint(7), sg.Index)
|
||||
assert.Equal(t, uint(4), sg.Index)
|
||||
case sg.TypeID == shipTypeID(Race_0_idx, Race_0_Gunship) && sg.TechLevel(game.TechDrive) == 1.1:
|
||||
assert.Equal(t, uint(2), sg.Number)
|
||||
assert.Equal(t, uint(3), sg.Index)
|
||||
assert.Equal(t, uint(2), sg.Index)
|
||||
case sg.TypeID == shipTypeID(Race_0_idx, Race_0_Gunship) && sg.TechLevel(game.TechDrive) == 1.5:
|
||||
assert.Equal(t, uint(13), sg.Number)
|
||||
assert.Equal(t, uint(6), sg.Index)
|
||||
assert.Equal(t, uint(3), sg.Index)
|
||||
default:
|
||||
t.Error("not all ship groups covered")
|
||||
}
|
||||
@@ -116,12 +115,12 @@ func TestBreakGroup(t *testing.T) {
|
||||
g.BreakGroup(Race_0.Name, 2, 0),
|
||||
e.GenericErrorText(e.ErrShipsBusy))
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.ListFleets(Race_0_idx)), 1)
|
||||
|
||||
// group #1 -> group #3 (5 new, 8 left)
|
||||
assert.NoError(t, c.BreakGroup(Race_0_idx, 1, 5)) // group #3 (2)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 3)
|
||||
assert.Equal(t, uint(8), c.ShipGroup(0).Number)
|
||||
assert.NotNil(t, c.ShipGroup(0).FleetID)
|
||||
assert.Equal(t, uint(5), c.ShipGroup(2).Number)
|
||||
@@ -133,7 +132,7 @@ func TestBreakGroup(t *testing.T) {
|
||||
c.ShipGroup(0).CargoType = game.CargoColonist.Ref()
|
||||
c.ShipGroup(0).Load = 32.8 // 8 ships
|
||||
assert.NoError(t, c.BreakGroup(Race_0_idx, 1, 2)) // group #4 (3)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 4)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 4)
|
||||
assert.Equal(t, uint(6), c.ShipGroup(0).Number)
|
||||
assert.NotNil(t, c.ShipGroup(0).FleetID)
|
||||
assert.Equal(t, uint(2), c.ShipGroup(3).Number)
|
||||
@@ -149,13 +148,13 @@ func TestBreakGroup(t *testing.T) {
|
||||
|
||||
// group #1 -> MAX 6 off the fleet
|
||||
assert.NoError(t, g.BreakGroup(Race_0.Name, 1, 6)) // group #1 (0)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 4)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 4)
|
||||
assert.Equal(t, uint(6), c.ShipGroup(0).Number)
|
||||
assert.Nil(t, c.ShipGroup(0).FleetID)
|
||||
|
||||
// group #4 -> ALL off the fleet
|
||||
assert.NoError(t, g.BreakGroup(Race_0.Name, 4, 0)) // group #1 (0)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 4)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 4)
|
||||
assert.Equal(t, uint(2), c.ShipGroup(3).Number)
|
||||
assert.Nil(t, c.ShipGroup(3).FleetID)
|
||||
}
|
||||
@@ -175,8 +174,8 @@ func TestGiveawayGroup(t *testing.T) {
|
||||
c.ShipGroup(2).CargoType = game.CargoMaterial.Ref()
|
||||
c.ShipGroup(2).Load = 1.234
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_1_idx)), 1)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_1_idx)), 1)
|
||||
|
||||
assert.ErrorContains(t,
|
||||
g.GiveawayGroup("UnknownRace", Race_1.Name, 2, 0),
|
||||
@@ -198,12 +197,9 @@ func TestGiveawayGroup(t *testing.T) {
|
||||
e.GenericErrorText(e.ErrGiveawayGroupShipsTypeNotEqual))
|
||||
|
||||
assert.NoError(t, g.GiveawayGroup(Race_0.Name, Race_1.Name, 2, 11)) // group #2 (3)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_1_idx)), 2)
|
||||
// sto := slices.IndexFunc(g.Race[Race_0_idx].ShipTypes, func(st game.ShipType) bool { return st.Name == Race_0_Gunship })
|
||||
// sti := slices.IndexFunc(g.Race[Race_1_idx].ShipTypes, func(st game.ShipType) bool { return st.Name == Race_0_Gunship })
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 2)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_1_idx)), 2)
|
||||
|
||||
c.MustShipClass(Race_0_idx, Race_0_Gunship)
|
||||
assert.Equal(t, c.MustShipClass(Race_1_idx, Race_0_Gunship).Name, c.MustShipClass(Race_0_idx, Race_0_Gunship).Name)
|
||||
assert.Equal(t, c.MustShipClass(Race_1_idx, Race_0_Gunship).Drive, c.MustShipClass(Race_0_idx, Race_0_Gunship).Drive)
|
||||
assert.Equal(t, c.MustShipClass(Race_1_idx, Race_0_Gunship).Weapons, c.MustShipClass(Race_0_idx, Race_0_Gunship).Weapons)
|
||||
@@ -226,8 +222,8 @@ func TestGiveawayGroup(t *testing.T) {
|
||||
assert.Nil(t, c.ShipGroup(3).FleetID)
|
||||
|
||||
assert.NoError(t, g.GiveawayGroup(Race_1.Name, Race_0.Name, 2, 11))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_1_idx)), 1)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_1_idx)), 1)
|
||||
}
|
||||
|
||||
func TestLoadCargo(t *testing.T) {
|
||||
@@ -255,7 +251,7 @@ func TestLoadCargo(t *testing.T) {
|
||||
assert.NoError(t, c.CreateShips(Race_0_idx, Race_0_Freighter, R0_Planet_0_num, 11))
|
||||
c.ShipGroup(4).Destination = R1_Planet_1_num
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 5)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 5)
|
||||
|
||||
// tests
|
||||
assert.ErrorContains(t,
|
||||
@@ -285,7 +281,6 @@ func TestLoadCargo(t *testing.T) {
|
||||
g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 0, 0),
|
||||
e.GenericErrorText(e.ErrInputCargoLoadNotEnough))
|
||||
// add cargo to planet
|
||||
// g.Map.Planet[0].Material = 100
|
||||
c.PutMaterial(R0_Planet_0_num, 100)
|
||||
// not enough on the planet
|
||||
assert.ErrorContains(t,
|
||||
@@ -296,12 +291,12 @@ func TestLoadCargo(t *testing.T) {
|
||||
g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 0, 1),
|
||||
e.GenericErrorText(e.ErrInputCargoQuantityWithoutGroupBreak))
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 5)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 5)
|
||||
|
||||
// break group and load maximum
|
||||
assert.NoError(t, g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 2, 0))
|
||||
assert.Equal(t, 58.0, c.MustPlanet(R0_Planet_0_num).Material)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 6)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 6)
|
||||
assert.Nil(t, c.ShipGroup(0).CargoType)
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(5).CargoType)
|
||||
assert.Equal(t, uint(9), c.ShipGroup(0).Number)
|
||||
@@ -312,7 +307,7 @@ func TestLoadCargo(t *testing.T) {
|
||||
// break group and load limited
|
||||
assert.NoError(t, g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 2, 18))
|
||||
assert.Equal(t, 40.0, c.MustPlanet(R0_Planet_0_num).Material)
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
assert.Nil(t, c.ShipGroup(0).CargoType)
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(6).CargoType)
|
||||
assert.Equal(t, uint(7), c.ShipGroup(0).Number)
|
||||
@@ -321,27 +316,25 @@ func TestLoadCargo(t *testing.T) {
|
||||
assert.Equal(t, 18.0, c.ShipGroup(6).Load)
|
||||
|
||||
// add cargo to planet
|
||||
// g.Map.Planet[0].Material = 100
|
||||
c.PutMaterial(R0_Planet_0_num, 100)
|
||||
// loading all available cargo
|
||||
assert.NoError(t, g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 0, 0))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
assert.Equal(t, 0.0, c.MustPlanet(R0_Planet_0_num).Material)
|
||||
assert.Equal(t, 100.0, c.ShipGroup(0).Load) // free: 131.0
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(0).CargoType)
|
||||
|
||||
// add cargo to planet
|
||||
// g.Map.Planet[0].Material = 200
|
||||
c.PutMaterial(R0_Planet_0_num, 200)
|
||||
assert.NoError(t, g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 11, 31))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
assert.Equal(t, 169.0, c.MustPlanet(R0_Planet_0_num).Material)
|
||||
assert.Equal(t, 131.0, c.ShipGroup(0).Load) // free: 100.0
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(0).CargoType)
|
||||
|
||||
// load to maximum cargo space left
|
||||
assert.NoError(t, g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 11, 0))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
assert.Equal(t, 153.0, c.MustPlanet(R0_Planet_0_num).Material)
|
||||
assert.Equal(t, 147.0, c.ShipGroup(0).Load) // free: 0.0
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(0).CargoType)
|
||||
@@ -350,7 +343,7 @@ func TestLoadCargo(t *testing.T) {
|
||||
assert.ErrorContains(t,
|
||||
g.LoadCargo(Race_0.Name, 1, game.CargoMaterial.String(), 0, 0),
|
||||
e.GenericErrorText(e.ErrInputCargoLoadNoSpaceLeft))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
}
|
||||
|
||||
func TestUnloadCargo(t *testing.T) {
|
||||
@@ -386,7 +379,7 @@ func TestUnloadCargo(t *testing.T) {
|
||||
c.ShipGroup(5).CargoType = game.CargoMaterial.Ref()
|
||||
c.ShipGroup(5).Load = 100.0
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 6)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 6)
|
||||
|
||||
// tests
|
||||
assert.ErrorContains(t,
|
||||
@@ -416,12 +409,12 @@ func TestUnloadCargo(t *testing.T) {
|
||||
g.UnloadCargo(Race_0.Name, 1, 0, 1),
|
||||
e.GenericErrorText(e.ErrInputCargoQuantityWithoutGroupBreak))
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 6)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 6)
|
||||
|
||||
// unload MAT on foreign planet / break group
|
||||
assert.NoError(t, g.UnloadCargo(Race_0.Name, 6, 3, 0))
|
||||
assert.Equal(t, 27.273, number.Fixed3(c.MustPlanet(R1_Planet_1_num).Material))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 7)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 7)
|
||||
assert.Equal(t, uint(3), c.ShipGroup(6).Number)
|
||||
assert.Nil(t, c.ShipGroup(6).CargoType)
|
||||
assert.Equal(t, 0.0, c.ShipGroup(6).Load)
|
||||
@@ -432,7 +425,7 @@ func TestUnloadCargo(t *testing.T) {
|
||||
// unload MAT on foreign planet / break group / limited MAT
|
||||
assert.NoError(t, g.UnloadCargo(Race_0.Name, 6, 3, 20.0))
|
||||
assert.Equal(t, 47.273, number.Fixed3(c.MustPlanet(R1_Planet_1_num).Material))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 8)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 8)
|
||||
assert.Equal(t, uint(3), c.ShipGroup(7).Number)
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(7).CargoType)
|
||||
assert.Equal(t, 7.273, number.Fixed3(c.ShipGroup(7).Load))
|
||||
@@ -443,7 +436,7 @@ func TestUnloadCargo(t *testing.T) {
|
||||
// unload ALL
|
||||
assert.NoError(t, g.UnloadCargo(Race_0.Name, 1, 0, 0))
|
||||
assert.Equal(t, 100.0, number.Fixed3(c.MustPlanet(R0_Planet_0_num).Colonists))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 8)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 8)
|
||||
assert.Equal(t, uint(10), c.ShipGroup(0).Number)
|
||||
assert.Nil(t, c.ShipGroup(0).CargoType)
|
||||
assert.Equal(t, 0.0, number.Fixed3(c.ShipGroup(0).Load))
|
||||
@@ -479,7 +472,7 @@ func TestDisassembleGroup(t *testing.T) {
|
||||
c.ShipGroup(4).CargoType = game.CargoColonist.Ref()
|
||||
c.ShipGroup(4).Load = 2.345
|
||||
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 5)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 5)
|
||||
|
||||
// tests
|
||||
assert.ErrorContains(t,
|
||||
@@ -496,41 +489,37 @@ func TestDisassembleGroup(t *testing.T) {
|
||||
e.GenericErrorText(e.ErrBeakGroupNumberNotEnough))
|
||||
|
||||
groupEmptyMass := c.ShipGroup(4).EmptyMass(c.MustShipClass(Race_0_idx, Race_0_Freighter))
|
||||
// groupEmptyMass := c.ShipGroup(4).EmptyMass(&g.Race[Race_0_idx].ShipTypes[Race_0_Freighter_idx])
|
||||
// groupLoadCOL := c.ShipGroup(4).Load
|
||||
planetMAT := c.MustPlanet(R1_Planet_1_num).Material
|
||||
planetCOL := c.MustPlanet(R1_Planet_1_num).Colonists
|
||||
|
||||
assert.NoError(t, g.DisassembleGroup(Race_0.Name, 5, 0))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 4)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 4)
|
||||
assert.Equal(t, planetMAT+groupEmptyMass, c.MustPlanet(R1_Planet_1_num).Material)
|
||||
assert.Equal(t, planetCOL, c.MustPlanet(R1_Planet_1_num).Colonists)
|
||||
|
||||
groupEmptyMass = c.ShipGroup(3).EmptyMass(c.MustShipClass(Race_0_idx, Race_0_Freighter))
|
||||
// groupEmptyMass = c.ShipGroup(3).EmptyMass(&g.Race[Race_0_idx].ShipTypes[Race_0_Freighter_idx])
|
||||
groupLoadMAT := c.ShipGroup(3).Load
|
||||
planetMAT = c.MustPlanet(R1_Planet_1_num).Material
|
||||
assert.NoError(t, g.DisassembleGroup(Race_0.Name, 4, 0))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 3)
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 3)
|
||||
assert.Equal(t, planetMAT+groupEmptyMass+groupLoadMAT, c.MustPlanet(R1_Planet_1_num).Material)
|
||||
|
||||
groupEmptyMass = c.ShipGroup(2).EmptyMass(c.MustShipClass(Race_0_idx, Race_0_Freighter))
|
||||
// groupEmptyMass = c.ShipGroup(2).EmptyMass(&g.Race[Race_0_idx].ShipTypes[Race_0_Freighter_idx])
|
||||
planetMAT = c.MustPlanet(R0_Planet_0_num).Material
|
||||
planetCOL = c.MustPlanet(R0_Planet_0_num).Colonists
|
||||
planetPOP := 90.0
|
||||
|
||||
// g.Map.Planet[0].Population = planetPOP
|
||||
c.PutPopulation(R0_Planet_0_num, planetPOP)
|
||||
var shipsDisassembling uint = 3
|
||||
groupEmptyMass = groupEmptyMass / float64(c.ShipGroup(2).Number) * float64(shipsDisassembling)
|
||||
newGroupUnloadedCOL := c.ShipGroup(2).Load / float64(c.ShipGroup(2).Number) * float64(shipsDisassembling)
|
||||
assert.Equal(t, planetPOP, c.MustPlanet(R0_Planet_0_num).Population)
|
||||
var quantity uint = 3
|
||||
groupEmptyMass = groupEmptyMass / float64(c.ShipGroup(2).Number) * float64(quantity)
|
||||
newGroupUnloadedCOL := c.ShipGroup(2).Load / float64(c.ShipGroup(2).Number) * float64(quantity)
|
||||
expectPOPIncrease := newGroupUnloadedCOL * 8
|
||||
freePOPLeft := c.MustPlanet(R0_Planet_0_num).Size - c.MustPlanet(R0_Planet_0_num).Population
|
||||
expectAddedCOL := (expectPOPIncrease - freePOPLeft) / 8
|
||||
expectAddedPOP := freePOPLeft
|
||||
assert.NoError(t, g.DisassembleGroup(Race_0.Name, 3, shipsDisassembling))
|
||||
assert.Len(t, slices.Collect(c.ListShipGroups(Race_0_idx)), 3)
|
||||
assert.NoError(t, g.DisassembleGroup(Race_0.Name, 3, quantity))
|
||||
assert.Len(t, slices.Collect(c.RaceShipGroups(Race_0_idx)), 3)
|
||||
assert.Equal(t, planetCOL+expectAddedCOL, c.MustPlanet(R0_Planet_0_num).Colonists)
|
||||
assert.Equal(t, planetPOP+expectAddedPOP, c.MustPlanet(R0_Planet_0_num).Population)
|
||||
assert.Equal(t, planetMAT+groupEmptyMass, c.MustPlanet(R0_Planet_0_num).Material)
|
||||
|
||||
Reference in New Issue
Block a user