wip: generate report
This commit is contained in:
@@ -50,19 +50,23 @@ func (c *Cache) FleetState(fleetID uuid.UUID) (game.ShipGroupState, *uint, *game
|
||||
}
|
||||
|
||||
// TODO: Hello! Wanna know fleet's speed? Good. Implement & test this func first.
|
||||
func (c *Cache) FleetSpeed(fl game.Fleet) float64 {
|
||||
result := math.MaxFloat64
|
||||
for sg := range c.ShipGroupsIndex() {
|
||||
if c.ShipGroup(sg).FleetID == nil || *c.ShipGroup(sg).FleetID != fl.ID {
|
||||
func (c *Cache) FleetSpeedAndMass(fi int) (float64, float64) {
|
||||
c.validateFleetIndex(fi)
|
||||
speed := math.MaxFloat64
|
||||
mass := 0.
|
||||
for sgi := range c.ShipGroupsIndex() {
|
||||
if c.ShipGroup(sgi).FleetID == nil || *c.ShipGroup(sgi).FleetID != c.g.Fleets[fi].ID {
|
||||
continue
|
||||
}
|
||||
st := c.ShipGroupShipClass(sg)
|
||||
typeSpeed := c.ShipGroup(sg).Speed(st)
|
||||
if typeSpeed < result {
|
||||
result = typeSpeed
|
||||
sg := c.ShipGroup(sgi)
|
||||
st := c.ShipGroupShipClass(sgi)
|
||||
typeSpeed := sg.Speed(st)
|
||||
if typeSpeed < speed {
|
||||
speed = typeSpeed
|
||||
}
|
||||
mass += sg.FullMass(st)
|
||||
}
|
||||
return result
|
||||
return speed, mass
|
||||
}
|
||||
|
||||
func (c *Controller) JoinShipGroupToFleet(raceName, fleetName string, group, count uint) error {
|
||||
|
||||
Reference in New Issue
Block a user