package main import "slices" type Sector struct { ID ID Beacon string NavHaz uint8 Warps []ID // Sector Port ID // Port Planets []ID // Planet // Deploy-ables Fighters []ID // DeployedFighter Mines []ID // DeployedMine TrackerMines []ID // DeployedTrackerMine } func (s *Sector) IsWarp(to ID) bool { return slices.Contains(s.Warps, to) } func (s *Sector) WarpCount() int { return len(s.Warps) } func (s *Sector) HasPort() bool { return s.Port != 0 } func (s *Sector) HazChance() int { if s.NavHaz > 5 { return 0 } return int(s.NavHaz) / 2 } func (s *Sector) HazDamage() int { if s.NavHaz > 5 { return 0 } return int(s.NavHaz) * 8 } func (s *Sector) WarpLink(from ID) { if s.IsWarp(from) { return } if s.WarpCount() >= 6 { return } s.Warps = append(s.Warps, from) } func (s *Sector) WarpDeLink(from ID) { if !s.IsWarp(from) { return } wps := make([]ID, s.WarpCount()-1) for _, w := range s.Warps { if w != from { wps = append(wps, w) } } s.Warps = wps }