refactor: group uuid instead of index

This commit is contained in:
IliaDenisov
2026-02-10 20:54:43 +03:00
parent 6c8384ce7a
commit 56998d4c2d
26 changed files with 333 additions and 363 deletions
+6 -5
View File
@@ -5,15 +5,16 @@ import (
"slices"
"strings"
"github.com/google/uuid"
e "github.com/iliadenisov/galaxy/internal/error"
"github.com/iliadenisov/galaxy/internal/model/game"
)
func (c *Cache) shipGroupUpgrade(ri int, groupIndex uint, techInput string, limitShips uint, limitLevel float64) error {
func (c *Cache) shipGroupUpgrade(ri int, groupID uuid.UUID, techInput string, limitShips uint, limitLevel float64) error {
c.validateRaceIndex(ri)
sgi, ok := c.raceShipGroupIndex(ri, groupIndex)
sgi, ok := c.raceShipGroupIndex(ri, groupID)
if !ok {
return e.NewEntityNotExistsError("group #%d", groupIndex)
return e.NewEntityNotExistsError("group %s", groupID)
}
st := c.ShipGroupShipClass(sgi)
sg := c.ShipGroup(sgi)
@@ -24,7 +25,7 @@ func (c *Cache) shipGroupUpgrade(ri int, groupIndex uint, techInput string, limi
p := c.MustPlanet(sg.Destination)
if p.Owned() && !p.OwnedBy(c.g.Race[ri].ID) {
return e.NewEntityNotOwnedError("planet #%d for upgrade group #%d", p.Number, groupIndex)
return e.NewEntityNotOwnedError("planet #%d for upgrade group %s", p.Number, groupID)
}
upgradeValidTech := map[string]game.Tech{
@@ -117,7 +118,7 @@ func (c *Cache) shipGroupUpgrade(ri int, groupIndex uint, techInput string, limi
// break group if needed
if maxUpgradableShips < sg.Number {
nsgi, err := c.breakGroupSafe(ri, groupIndex, maxUpgradableShips)
nsgi, err := c.breakGroupSafe(ri, groupID, maxUpgradableShips)
if err != nil {
return err
}