fix: ship send without any planets left
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user