Skip to content

Commit

Permalink
Added "planetary" column to station table and maddavo import.
Browse files Browse the repository at this point in the history
Added "--planetary" argument to station command.
Added "--no-planet" switch to buy, local, nav, rares, run and sell command.
Added "Plt: X" output.
  • Loading branch information
bgol committed Dec 21, 2015
1 parent 2a04bd1 commit 349967e
Show file tree
Hide file tree
Showing 13 changed files with 40,881 additions and 40,806 deletions.
6 changes: 6 additions & 0 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
),
AvoidPlacesArgument(),
PadSizeArgument(),
NoPlanetSwitch(),
BlackMarketSwitch(),
MutuallyExclusiveGroup(
ParseArgument(
Expand Down Expand Up @@ -252,6 +253,7 @@ def run(results, cmdenv, tdb):

oneStopMode = cmdenv.oneStop
padSize = cmdenv.padSize
wantNoPlanet = cmdenv.noPlanet
wantBlackMarket = cmdenv.blackMarket

stations = defaultdict(list)
Expand All @@ -262,6 +264,8 @@ def run(results, cmdenv, tdb):
station = stationByID[stationID]
if padSize and not station.checkPadSize(padSize):
continue
if wantNoPlanet and station.planetary == 'Y':
continue
if wantBlackMarket and station.blackMarket != 'Y':
continue
if station in avoidStations:
Expand Down Expand Up @@ -351,6 +355,8 @@ def render(results, cmdenv, tdb):
key=lambda row: TradeDB.marketStates[row.station.blackMarket])
stnRowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.station.maxPadSize])
stnRowFmt.addColumn("Plt", '>', '3',
key=lambda row: TradeDB.marketStates[row.station.planetary])

if not cmdenv.quiet:
heading, underline = stnRowFmt.heading()
Expand Down
8 changes: 8 additions & 0 deletions commands/local_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
default=None,
),
PadSizeArgument(),
NoPlanetSwitch(),
ParseArgument('--stations',
help='Limit to systems which have stations.',
action='store_true',
Expand Down Expand Up @@ -75,6 +76,7 @@ def run(results, cmdenv, tdb):
showStations = cmdenv.detail
wantStations = cmdenv.stations
padSize = cmdenv.padSize
wantNoPlanet = cmdenv.noPlanet
wantTrading = cmdenv.trading
wantShipYard = cmdenv.shipyard
wantBlackMarket = cmdenv.blackMarket
Expand All @@ -85,6 +87,8 @@ def run(results, cmdenv, tdb):

def station_filter(stations):
for station in stations:
if wantNoPlanet and station.planetary == 'Y':
continue
if wantTrading and not station.isTrading:
continue
if wantBlackMarket and station.blackMarket != 'Y':
Expand Down Expand Up @@ -198,6 +202,10 @@ def render(results, cmdenv, tdb):
ColumnFormat("Pad", '>', '3',
key=lambda row: \
TradeDB.padSizes[row.station.maxPadSize])
).append(
ColumnFormat("Plt", '>', '3',
key=lambda row: \
TradeDB.marketStates[row.station.planetary])
)
if cmdenv.detail > 1:
stnRowFmt.append(
Expand Down
8 changes: 8 additions & 0 deletions commands/nav_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
dest='stationInterval',
),
PadSizeArgument(),
NoPlanetSwitch(),
]

######################################################################
Expand Down Expand Up @@ -104,6 +105,7 @@ def run(results, cmdenv, tdb):

lastSys, totalLy, dirLy = srcSystem, 0.00, 0.00
maxPadSize = cmdenv.padSize
noPlanet = cmdenv.noPlanet

for (jumpSys, dist) in route:
jumpLy = lastSys.distanceTo(jumpSys)
Expand All @@ -122,6 +124,8 @@ def run(results, cmdenv, tdb):
for (station) in jumpSys.stations:
if maxPadSize and not station.checkPadSize(maxPadSize):
continue
if noPlanet and station.planetary == 'Y':
continue
rr = ResultRow(
station=station,
age=station.itemDataAgeStr,
Expand Down Expand Up @@ -208,6 +212,10 @@ def render(results, cmdenv, tdb):
ColumnFormat("Pad", '>', '3',
key=lambda row: \
TradeDB.padSizes[row.station.maxPadSize])
).append(
ColumnFormat("Plt", '>', '3',
key=lambda row: \
TradeDB.marketStates[row.station.planetary])
)
if cmdenv.detail > 1:
stnRowFmt.append(
Expand Down
8 changes: 7 additions & 1 deletion commands/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self):
"'--avoid a,b,c' or '--avoid a,b --avoid c'"
),
}


class SwitchArgument(ParseArgument):
def __init__(self, help=None):
Expand Down Expand Up @@ -120,6 +120,12 @@ class RepairSwitch(SwitchArgument):
help = 'Require stations known to offer repairs.'


class NoPlanetSwitch(SwitchArgument):
switches = ['--no-planet']
dest = 'noPlanet'
help = 'Require stations to be in space.'


__tdParserHelpers = {
'credits': CreditParser,
'padsize': PadSizeArgument.PadSizeParser,
Expand Down
8 changes: 7 additions & 1 deletion commands/rares_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
type=int,
),
PadSizeArgument(),
NoPlanetSwitch(),
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance.',
action='store_true',
Expand Down Expand Up @@ -122,8 +123,9 @@ def run(results, cmdenv, tdb):

# Lookup the system we're currently in.
start = cmdenv.nearSystem
# Hoist the padSize parameter for convenience
# Hoist the padSize and noPlanet parameter for convenience
padSize = cmdenv.padSize
noPlanet = cmdenv.noPlanet
# How far we're want to cast our net.
maxLy = float(cmdenv.maxLyPer or 0.)

Expand Down Expand Up @@ -160,6 +162,8 @@ def run(results, cmdenv, tdb):
if padSize: # do we care about pad size?
if not rare.station.checkPadSize(padSize):
continue
if noPlanet and rare.station.planetary == 'Y':
continue
rareSys = rare.station.system
# Find the un-sqrt'd distance to the system.
dist = distCheckFn(rareSys)
Expand Down Expand Up @@ -238,6 +242,8 @@ def render(results, cmdenv, tdb):
key=lambda row: TradeDB.marketStates[row.rare.station.blackMarket])
rowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.rare.station.maxPadSize])
rowFmt.addColumn("Plt", '>', '3',
key=lambda row: TradeDB.marketStates[row.rare.station.planetary])

# Print a heading summary if the user didn't use '-q'
if not cmdenv.quiet:
Expand Down
13 changes: 12 additions & 1 deletion commands/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
dest='maxAge',
),
PadSizeArgument(),
NoPlanetSwitch(),
BlackMarketSwitch(),
ParseArgument('--ls-penalty', '--lsp',
help="Penalty per 1kls stations are from their stars.",
Expand Down Expand Up @@ -509,12 +510,13 @@ def checkAnchorNotInVia(hops, anchorName, place, viaSet):

def checkStationSuitability(cmdenv, calc, station, src=None):
cmdenv.DEBUG2(
"checking {} (ls={}, bm={}, pad={}, mkt={}, shp={}) "
"checking {} (ls={}, bm={}, pad={}, plt={}, mkt={}, shp={}) "
"for {} suitability",
station.name(),
station.lsFromStar,
station.blackMarket,
station.maxPadSize,
station.planetary,
station.market,
station.shipyard,
src or "any",
Expand Down Expand Up @@ -576,6 +578,15 @@ def checkStationSuitability(cmdenv, calc, station, src=None):
TradeDB.padSizesExt[station.maxPadSize],
))
return False
np = cmdenv.noPlanet
if np and station.planetary == 'Y':
if src and src != "--from":
raise CommandLineError(
"{} station {} does not meet no-planet "
"requirement.".format(
src, station.name(),
))
return False
bm = cmdenv.blackMarket
if bm and station.blackMarket != 'Y':
if src and src != "--from":
Expand Down
6 changes: 6 additions & 0 deletions commands/sell_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
),
AvoidPlacesArgument(),
PadSizeArgument(),
NoPlanetSwitch(),
BlackMarketSwitch(),
ParseArgument('--limit',
help='Maximum number of results to list.',
Expand Down Expand Up @@ -133,12 +134,15 @@ def run(results, cmdenv, tdb):

stationByID = tdb.stationByID
padSize = cmdenv.padSize
wantNoPlanet = cmdenv.noPlanet
wantBlackMarket = cmdenv.blackMarket

for (stationID, priceCr, demand) in cur:
station = stationByID[stationID]
if padSize and not station.checkPadSize(padSize):
continue
if wantNoPlanet and station.planetary == 'Y':
continue
if wantBlackMarket and station.blackMarket != 'Y':
continue
if station in avoidStations:
Expand Down Expand Up @@ -204,6 +208,8 @@ def render(results, cmdenv, tdb):
key=lambda row: TradeDB.marketStates[row.station.blackMarket])
stnRowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.station.maxPadSize])
stnRowFmt.addColumn("Plt", '>', '3',
key=lambda row: TradeDB.marketStates[row.station.planetary])

if not cmdenv.quiet:
heading, underline = stnRowFmt.heading()
Expand Down
8 changes: 8 additions & 0 deletions commands/station_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
help='Does the station provide repairs (Y or N) or ? if unknown.',
choices=['Y', 'y', 'N', 'n', '?'],
),
ParseArgument(
'--planetary',
help='Is the station on a planet (Y or N) or ? if unknown.',
choices=['Y', 'y', 'N', 'n', '?'],
),
ParseArgument(
'--confirm',
help='For confirmation suspicious looking station names.',
Expand Down Expand Up @@ -261,6 +266,7 @@ def addStation(tdb, cmdenv, system, stationName):
refuel=cmdenv.refuel or '?',
repair=cmdenv.repair or '?',
maxPadSize=cmdenv.padSize or '?',
planetary=cmdenv.planetary or '?',
commit=True,
)

Expand All @@ -277,6 +283,7 @@ def updateStation(tdb, cmdenv, station):
refuel=cmdenv.refuel,
repair=cmdenv.repair,
maxPadSize=cmdenv.padSize,
planetary=cmdenv.planetary or '?',
force=True,
commit=True,
)
Expand Down Expand Up @@ -414,6 +421,7 @@ def _detail(value, source):
print("Rearm.....:", _detail(station.rearm, TradeDB.marketStates))
print("Refuel....:", _detail(station.refuel, TradeDB.marketStates))
print("Repair....:", _detail(station.repair, TradeDB.marketStates))
print("Planetary.:", _detail(station.planetary, TradeDB.marketStates))
print("Prices....:", station.itemCount or 'None')

if station.itemCount == 0:
Expand Down
Loading

0 comments on commit 349967e

Please sign in to comment.