refactor: game funcs moved to controller
This commit is contained in:
@@ -36,7 +36,7 @@ func TestJoinShipGroupToFleet(t *testing.T) {
|
||||
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetOne, groupIndex, 0))
|
||||
fleets := slices.Collect(c.ListFleets(Race_0_idx))
|
||||
groups := slices.Collect(c.ListShipGroups(Race_0_idx))
|
||||
groups := slices.Collect(c.RaceShipGroups(Race_0_idx))
|
||||
assert.Len(t, groups, 1)
|
||||
gi := 0
|
||||
assert.Len(t, fleets, 1)
|
||||
@@ -52,7 +52,7 @@ func TestJoinShipGroupToFleet(t *testing.T) {
|
||||
groupIndex = 2
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetTwo, groupIndex, 2))
|
||||
fleets = slices.Collect(c.ListFleets(Race_0_idx))
|
||||
groups = slices.Collect(c.ListShipGroups(Race_0_idx))
|
||||
groups = slices.Collect(c.RaceShipGroups(Race_0_idx))
|
||||
assert.Len(t, groups, 3)
|
||||
assert.Len(t, fleets, 2)
|
||||
assert.Equal(t, fleets[1].Name, fleetTwo)
|
||||
@@ -75,7 +75,7 @@ func TestJoinShipGroupToFleet(t *testing.T) {
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetOne, groupIndex, 0))
|
||||
fleets = slices.Collect(c.ListFleets(Race_0_idx))
|
||||
assert.Len(t, fleets, 2)
|
||||
groups = slices.Collect(c.ListShipGroups(Race_0_idx))
|
||||
groups = slices.Collect(c.RaceShipGroups(Race_0_idx))
|
||||
assert.NotNil(t, groups[gi].FleetID)
|
||||
assert.Equal(t, fleets[0].ID, *groups[gi].FleetID)
|
||||
state, _, _ = c.FleetState(fleets[0].ID)
|
||||
@@ -94,11 +94,8 @@ func TestJoinShipGroupToFleet(t *testing.T) {
|
||||
c.ShipGroup(gi).StateInSpace = nil
|
||||
|
||||
// existing fleet not on the same planet or in_orbit
|
||||
c.ShipGroup(0).StateInSpace = &game.InSpace{
|
||||
Origin: 2,
|
||||
Range: 1,
|
||||
}
|
||||
c.ShipGroup(2).StateInSpace = c.ShipGroup(0).StateInSpace
|
||||
c.ShipGroup(0).StateInSpace = &game.InSpace{Origin: 2, Range: 1}
|
||||
c.ShipGroup(1).StateInSpace = c.ShipGroup(0).StateInSpace
|
||||
assert.ErrorContains(t,
|
||||
g.JoinShipGroupToFleet(Race_0.Name, fleetOne, c.ShipGroup(gi).Index, 0),
|
||||
e.GenericErrorText(e.ErrShipsNotOnSamePlanet))
|
||||
@@ -116,22 +113,22 @@ func TestJoinFleets(t *testing.T) {
|
||||
// ensure race has no Fleets
|
||||
assert.Len(t, slices.Collect(c.ListFleets(Race_0_idx)), 0)
|
||||
|
||||
fleetPlanet2 := "R0_Fleet_On_Planet_2"
|
||||
fleetSource := "R0_Fleet_one"
|
||||
fleetTarget := "R0_Fleet_two"
|
||||
fleetOnPlanet2 := "R0_Fleet_On_Planet_2"
|
||||
fleetSourceOne := "R0_Fleet_one"
|
||||
fleetTargetTwo := "R0_Fleet_two"
|
||||
|
||||
assert.ErrorContains(t,
|
||||
g.JoinFleets(Race_0.Name, fleetSource, fleetTarget),
|
||||
g.JoinFleets(Race_0.Name, fleetSourceOne, fleetTargetTwo),
|
||||
e.GenericErrorText(e.ErrInputEntityNotExists))
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetSource, 1, 0))
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetSourceOne, 1, 0))
|
||||
assert.ErrorContains(t,
|
||||
g.JoinFleets(Race_0.Name, fleetSource, fleetTarget),
|
||||
g.JoinFleets(Race_0.Name, fleetSourceOne, fleetTargetTwo),
|
||||
e.GenericErrorText(e.ErrInputEntityNotExists))
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetTarget, 3, 0))
|
||||
assert.NoError(t, g.JoinFleets(Race_0.Name, fleetSource, fleetTarget))
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetTargetTwo, 3, 0))
|
||||
assert.NoError(t, g.JoinFleets(Race_0.Name, fleetSourceOne, fleetTargetTwo))
|
||||
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetPlanet2, 2, 0))
|
||||
assert.NoError(t, g.JoinShipGroupToFleet(Race_0.Name, fleetOnPlanet2, 2, 0))
|
||||
assert.ErrorContains(t,
|
||||
g.JoinFleets(Race_0.Name, fleetPlanet2, fleetTarget),
|
||||
g.JoinFleets(Race_0.Name, fleetOnPlanet2, fleetTargetTwo),
|
||||
e.GenericErrorText(e.ErrShipsNotOnSamePlanet))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user