Skip to content

Commit

Permalink
Merged kfsone/tradedangerous into master
Browse files Browse the repository at this point in the history
  • Loading branch information
orphu committed Dec 24, 2014
2 parents 87587e3 + 20fa573 commit e4f1924
Show file tree
Hide file tree
Showing 27 changed files with 3,323 additions and 2,007 deletions.
28 changes: 26 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,37 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.2.4 [wip]
v6.3.1 [wip]
. (kfsone) Added "--ls-penalty" ("--lsp") for biasing "run" calculations
in favor of shorter supercruise times.
+ Stations, data: kfsone

v6.3.0 Dec 23 2014
. (OpenSS) Script for Windows users (see scripts/README.txt)!
. (kfsone) Added support for pad sizes at stations,
. (kfsone) Revamped output from "local", "buy", "sell" and "olddata".
- "--ages" is the default now (so the option is not needed),
- Added pad size display,
- Improved black market display,
- Changed '+' to '/' for consistency on station lines,
. (bgol) Fixed weirdness with rangeCache
. (bgol/kfsone) Fixed jump distances and performance of "nav" command
+ Stations, Data: kfsone

v6.2.4 Dec 21 2014
. (kfsone) Experimental "add-station" command in misc,
. (kfsone) Added "--near" to olddata command,
. (kfsone) Route calculation performance,
. (kfsone) Added "Black Market" flag to station data,
. (kfsone) Added Black Market indicators to "local" command,
. (kfsone) Reorganized Ship and ShipVendor data (prices are ship based now),
. (kfsone) Draft version of "jsonprices",
. (gazelle) Auto-completion for bash users (see scripts/README.txt)
. (gazelle) Nice overhaul of the csv export command
. (kfsone) Fix for UTF-8 decoding error,
. (kfsone) Rebuild cache before .prices file after downloading .csvs
. (maddavo) Combat Stabilisers do exist
+ Systems, Stations, Data: Maddavo, Gazelle
+ Systems, Stations, Data: Maddavo, Gazelle, Kfsone, many others

v6.2.3 Dec 17 2014
. (kfsone) "maddavo" import plugin:
Expand Down
57 changes: 34 additions & 23 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ RUN sub-command:
--max-days-old 7 (data less than a week old)
-MD=2 (data less than 2 days old)

--ls-penalty N.NN
--lsp N.NN
DEFAULT: 0.5
Reduces the score of routes by this percentage for every 1000ls
you have to travel to stations, which helps prioritize routes
with a shorter supercruise time.
e.g.
--ls-penalty 2.5
--lsp=0 (disables this feature)

--unique
--uni
Only show routes which do not visit any station twice
Expand Down Expand Up @@ -547,7 +557,7 @@ LOCAL sub-command:
given a ship, it uses the max dry range of the ship. Use --full if you
want to restrict to systems with a full cargo hold.

trade.py local [-q | -v] [--ly N.NN] [--ages] system
trade.py local [-q | -v] [--ly N.NN] system

--ly N.NN
Constrains local systems to a maximum ly distance
Expand All @@ -556,8 +566,8 @@ LOCAL sub-command:
-v
Show stations + their distance from star

--ages
Show stations + the age of their price data
-vv (or -v -v or --detail --detail)
Include count of items at station

system
Name of the system or a station in the system,
Expand All @@ -571,26 +581,27 @@ LOCAL sub-command:
LHS 3333 5.54

> trade.py local mokosh --ly 6 -v
System Dist
+ Station Dist
------------------------------------------------
MOKOSH 0.00
+ Bethe Station 2500.0ls
+ Lubin Orbital
GRANTHAIMI 2.24
+ Parmitano Colony
LHS 3333 5.54

> trade.py local mokosh --ly 6 --ages
System Dist
+ Station Age/days
----------------------------------------------
MOKOSH 0.00
+ Bethe Station 1.75
+ Lubin Orbital 0.60
GRANTHAIMI 2.24
+ Parmitano Colony 5.03
LHS 3333 5.54
System Dist
/ Station Dist Age/days BMkt Pad
------------------------------------------------------------------
MOKOSH 0.00
/ Bethe Station 2500ls 8.27 N M
/ Lubin Orbital ? 0.85 Y L
GRANTHAIMI 2.24
/ Parmitano Colony ? 5.88 ? ?
LHS 3333 5.54

Mokosh/Bethe Station is 2500ls from its star, the data is 8 days old,
there is no black market, and the largest pad size is Medium

Lubin Orbital's distance is not known, the data is less than a day old,
it has a black market, and it has Large pads.

Parmitano Colony distance unknown, data nearly 6 days old, the
black market status is unknown as is the pad size.

Adding detail ('-vv' or '-v -v' or '--detail --detail') would add
a count of the number of items we have prices for at each station.


EXPORT sub-command:
Expand Down
40 changes: 20 additions & 20 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
from commands.exceptions import *
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
from tradedb import TradeDB

import math

######################################################################
Expand All @@ -18,35 +20,35 @@
help='Require at least this quantity.',
default=0,
type=int,
),
),
ParseArgument('--near',
help='Find sellers within jump range of this system.',
type=str
),
ParseArgument('--ly-per',
help='Maximum light years per jump.',
),
ParseArgument('--ly',
help='[Requires --near] Systems within this range of --near.',
default=None,
dest='maxLyPer',
metavar='N.NN',
type=float,
),
),
ParseArgument('--limit',
help='Maximum number of results to list.',
default=None,
type=int,
),
),
ParseArgument('--ages',
help='Show age of data.',
default=False,
action='store_true',
),
),
MutuallyExclusiveGroup(
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance',
action='store_true',
default=False,
dest='sortByPrice',
),
),
ParseArgument('--stock-sort', '-S',
help='Sort by stock followed by price',
action='store_true',
Expand All @@ -62,6 +64,9 @@
def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

if cmdenv.ages and not cmdenv.quiet:
print("--ages is now enabled by default.")

item = tdb.lookupItem(cmdenv.item)
cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID)

Expand All @@ -83,20 +88,14 @@ def run(results, cmdenv, tdb):
'ss.station_id',
'ss.price',
'ss.units',
"JULIANDAY('NOW') - JULIANDAY(ss.modified)",
]
bindValues = [ ]

if cmdenv.quantity:
constraints.append("(units = -1 or units >= ?)")
bindValues.append(cmdenv.quantity)

if cmdenv.ages:
columns.append(
"julianday('now') - julianday(ss.modified)"
)
else:
columns.append('0')

nearSystem = cmdenv.nearSystem
if nearSystem:
maxLy = cmdenv.maxLyPer or tdb.maxSystemLinkLy
Expand Down Expand Up @@ -182,15 +181,16 @@ def render(results, cmdenv, tdb):
stnRowFmt.addColumn('Cost', '>', 10, 'n',
key=lambda row: row.price)
stnRowFmt.addColumn('Stock', '>', 10,
key=lambda row: '{:n}'.format(row.stock) if row.stock >= 0 else 'unknown')
key=lambda row: '{:n}'.format(row.stock) if row.stock >= 0 else '?')

if cmdenv.nearSystem:
stnRowFmt.addColumn('Dist', '>', 6, '.2f',
key=lambda row: row.dist)

if cmdenv.ages:
stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
key=lambda row: row.age)
stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
key=lambda row: row.age)
stnRowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.station.maxPadSize])

if not cmdenv.quiet:
heading, underline = stnRowFmt.heading()
Expand Down
53 changes: 34 additions & 19 deletions commands/local_cmd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
import math
from tradedb import TradeDB
from tradeexcept import TradeException

import itertools
import math

######################################################################
# Parser config
Expand All @@ -16,7 +18,7 @@
]
switches = [
ParseArgument('--ly',
help='Maximum light years to measure.',
help='Maximum light years from system.',
dest='maxLyPer',
metavar='N.NN',
type=float,
Expand Down Expand Up @@ -62,22 +64,22 @@ def run(results, cmdenv, tdb):
if distSq <= lySq and destSys is not srcSystem:
distances[destSys] = math.sqrt(distSq)

showStations = cmdenv.detail or cmdenv.ages
ages = {}
if cmdenv.ages:
showStations = cmdenv.detail
if showStations:
stationIDs = ",".join([
",".join(str(stn.ID) for stn in sys.stations)
for sys in distances.keys()
if sys.stations
])
stmt = """
SELECT si.station_id,
JULIANDAY('NOW') - JULIANDAY(MAX(si.modified))
JULIANDAY('NOW') - JULIANDAY(MIN(si.modified))
FROM StationItem AS si
WHERE si.station_id IN ({})
GROUP BY 1
""".format(stationIDs)
cmdenv.DEBUG0("Fetching ages: {}", stmt)
ages = {}
for ID, age in tdb.query(stmt):
ages[ID] = age

Expand All @@ -92,10 +94,14 @@ def run(results, cmdenv, tdb):
age = "{:7.2f}".format(ages[station.ID])
except:
age = "-"
if station.lsFromStar:
ls = '{}ls'.format(station.lsFromStar)
else:
ls = '?'
rr = ResultRow(
station=station,
dist=station.lsFromStar,
age=age
ls=ls,
age=age,
)
row.stations.append(rr)
results.rows.append(row)
Expand All @@ -117,7 +123,7 @@ def render(results, cmdenv, tdb):
# Compare system names so we can tell
longestNamed = max(results.rows,
key=lambda row: len(row.system.name()))
longestNameLen = len(longestNamed.system.name())
longestNameLen = max(len(longestNamed.system.name()), 16)

sysRowFmt = RowFormat().append(
ColumnFormat("System", '<', longestNameLen,
Expand All @@ -127,21 +133,30 @@ def render(results, cmdenv, tdb):
key=lambda row: row.dist)
)

showStations = cmdenv.detail or cmdenv.ages
showStations = cmdenv.detail
if showStations:
stnRowFmt = RowFormat(prefix=' + ').append(
stnRowFmt = RowFormat(prefix=' / ').append(
ColumnFormat("Station", '<', 32,
key=lambda row: row.station.str())
)
if cmdenv.detail:
stnRowFmt.append(
key=lambda row: row.station.str())
).append(
ColumnFormat("Dist", '>', '10',
key=lambda row: '{}ls'.format(row.dist) if row.dist else '')
)
if cmdenv.ages:
stnRowFmt.append(
key=lambda row: row.ls)
).append(
ColumnFormat("Age/days", '>', 7,
key=lambda row: row.age)
).append(
ColumnFormat("BMkt", '>', '4',
key=lambda row: \
TradeDB.marketStates[row.station.blackMarket])
).append(
ColumnFormat("Pad", '>', '3',
key=lambda row: \
TradeDB.padSizes[row.station.maxPadSize])
)
if cmdenv.detail > 1:
stnRowFmt.append(
ColumnFormat("Itms", ">", 4,
key=lambda row: row.station.itemCount)
)

cmdenv.DEBUG0(
Expand Down
Loading

0 comments on commit e4f1924

Please sign in to comment.