-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathsend_discovery_fleet.go
61 lines (57 loc) · 1.68 KB
/
send_discovery_fleet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
origin = "3:92:12"
systemsRange = 10
//---------------------------
strings = import("strings")
c = GetCachedCelestial(origin)
cCoord = c.GetCoordinate()
systems = GetSystemsInRangeAsc(cCoord.System, systemsRange)
// Get how many slots we can use for discovery
func getUpdatedSlots() {
slots = GetSlots()
return slots.Total - slots.InUse - GetFleetSlotsReserved()
}
totalSlots = getUpdatedSlots()
for system in systems {
availCoords, err = CoordinatesAvailableForDiscoveryFleet(c, cCoord.Galaxy, system)
if err != nil {
LogError(err)
SleepSec(5)
continue
}
if len(availCoords) == 0 {
LogDebug("no available coords in [" + cCoord.Galaxy + ", " + system + "]")
continue
}
i = 0
for {
if totalSlots == 0 {
LogDebug("no slots available, wait 8-10min")
SleepRandMin(8, 10)
totalSlots = getUpdatedSlots()
continue
}
destination = availCoords[i]
err = SendDiscoveryFleet(origin, destination)
if err != nil {
LogError(err)
if strings.Contains(err.Error(), "Maximum number of fleets reached") {
SleepRandMin(8, 10)
totalSlots = getUpdatedSlots()
}
if strings.Contains(err.Error(), "Not enough resources") {
SleepRandMin(8, 10)
totalSlots = getUpdatedSlots()
}
SleepSec(5)
continue
}
LogDebug("Sent discovery fleet to " + destination)
totalSlots--
SleepRandMs(1000, 2000)
i++
if i >= len(availCoords) {
break
}
}
SleepRandMs(1500, 3000)
}