fix: ship send without any planets left

This commit is contained in:
Ilia Denisov
2026-02-17 19:57:08 +02:00
parent d42cee9df1
commit f394c105b0
4 changed files with 27 additions and 7 deletions
+11 -6
View File
@@ -7,12 +7,6 @@ import (
"github.com/iliadenisov/galaxy/internal/util"
)
/*
TODO: остались ли планеты у расы
Если у расы не осталось планет, то оставшиеся корабли не смогут
покинуть своего места пребывания.
*/
func (c *Cache) shipGroupSend(ri int, groupID uuid.UUID, planetNumber uint) error {
c.validateRaceIndex(ri)
@@ -22,6 +16,17 @@ func (c *Cache) shipGroupSend(ri int, groupID uuid.UUID, planetNumber uint) erro
}
st := c.ShipGroupShipClass(sgi)
pcount := 0
for i := range c.g.Map.Planet {
if c.g.Map.Planet[i].OwnedBy(c.g.Race[ri].ID) {
pcount++
break
}
}
if pcount == 0 {
return e.NewSendShipOwnerHasNoPlanetsError()
}
if st.DriveBlockMass() == 0 {
return e.NewSendShipHasNoDrivesError()
}