forked from cwren/davesgalaxy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
runturn
executable file
·60 lines (51 loc) · 1.85 KB
/
runturn
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
#!/usr/bin/env python
from optparse import OptionParser
import sys
import game
from buildarcs import buildarcs
from buildmerchantmen import buildmerchantmen
from collectsteel import collectsteel
from scrapidle import scrapidle
def main():
parser = OptionParser()
parser.add_option("-U", "--username", dest="username",
help="username of login")
parser.add_option("-P", "--password", dest="password",
help="password for login")
parser.add_option("-t", "--type", dest="type",
help="type of ship to build", default="frigates")
parser.add_option("-q", "--quick",
action="store_true", dest="quick", default=False,
help="skip interactive elements: full auto.")
parser.add_option("-s", "--skip_level", dest="skip_level",
help="maximum society level to initiate a skip arc",
default=20,
type="int")
parser.add_option("-r", "--radius", dest="radius",
help="maximum distance from sink to initiate a build",
default=5.0,
type="float")
(options, args) = parser.parse_args()
sink_opt = args[0]
g=game.Galaxy()
if options.username and options.password:
# explicit login
g.login(options.username, options.password, force=True)
else:
# try to pick up stored credentials
g.login()
try:
sink = g.get_planet(int(sink_opt))
except ValueError:
sink = g.find_planet(sink_opt)
sink.load()
print "using planet %d with name %s" % (sink.planetid, sink.name)
if not options.quick:
buildarcs(g, options.skip_level)
buildmerchantmen(g, options.skip_level)
collectsteel(g, sink, options.radius, options.type)
scrapidle(g, sink, options.type)
g.write_planet_cache()
g.write_fleet_cache()
if __name__ == "__main__":
main()