Skip to content

Commit

Permalink
Added --black-market to buy/sell
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed May 4, 2015
1 parent 95b0cd0 commit 0f2fed2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
11 changes: 6 additions & 5 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ CACHE BUILD REQUIRED (trade.py buildcache -fi)
existing local data and only removes entries when there is an explicit
entry for it with 0 prices.
- Changed "--reset" to "--reset-all" because it's a scary command,
. (kfsone) Various commands:
- Consistency:
"demand" refers to what a station will buy,
"supply" refers to what a station is selling,
. (kfsone) Consistency of various commands:
- "demand" refers to what a station will buy,
- "supply" refers to what a station is selling,
- Changed several command options from "--stock" to "--supply",
- "--black-market" is now consistently spelled with a hyphen
(or just --black for short),
(or just --black for short),
- "--bm" now has two hyphens in all uses (it was -bm in some cases),
. (kfsone) "market" command:
- Only show the age of items once,
. (kfsone) "nav" command:
- Fixed --refuel-jumps
- Added --pad-size to limit which stations will be listed/refuelled at,
. (kfsone) "buy" and "sell" commands:
- Added "--black-market" (--bm) option,
. (kfsone) Performance:
- Re-unified the StationBuying/StationSelling tables into StationItem,
- Added StationBuying and StationSelling views,
Expand Down
8 changes: 6 additions & 2 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
type=int,
),
PadSizeArgument(),
BlackMarketSwitch(),
MutuallyExclusiveGroup(
ParseArgument(
'--one-stop', '-1',
Expand Down Expand Up @@ -227,6 +228,7 @@ def run(results, cmdenv, tdb):

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

stations = defaultdict(list)
stationByID = tdb.stationByID
Expand All @@ -236,6 +238,8 @@ def run(results, cmdenv, tdb):
station = stationByID[stationID]
if padSize and not station.checkPadSize(padSize):
continue
if wantBlackMarket and station.blackMarket != 'Y':
continue
row = ResultRow()
row.station = station
if distanceFn:
Expand Down Expand Up @@ -310,7 +314,7 @@ def render(results, cmdenv, tdb):
key=lambda row: row.dist)

if mode is not SHIP_MODE:
stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
stnRowFmt.addColumn('Age/days', '>', 7,
key=lambda row: row.age)
stnRowFmt.addColumn("StnLs", '>', 10,
key=lambda row: row.station.distFromStar())
Expand All @@ -331,4 +335,4 @@ def render(results, cmdenv, tdb):
"-- Ship Cost" if mode is SHIP_MODE else "-- Average",
results.summary.avg,
lnl=maxStnLen,
))
))
9 changes: 7 additions & 2 deletions commands/sell_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
type=float,
),
PadSizeArgument(),
BlackMarketSwitch(),
ParseArgument('--limit',
help='Maximum number of results to list.',
default=None,
Expand Down Expand Up @@ -120,10 +121,14 @@ def run(results, cmdenv, tdb):

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

for (stationID, priceCr, demand) in cur:
station = stationByID[stationID]
if padSize and not station.checkPadSize(padSize):
continue
if wantBlackMarket and station.blackMarket != 'Y':
continue
row = ResultRow()
row.station = station
if distanceFn:
Expand Down Expand Up @@ -174,7 +179,7 @@ def render(results, cmdenv, tdb):
stnRowFmt.addColumn('DistLy', '>', 6, '.2f',
key=lambda row: row.dist)

stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
stnRowFmt.addColumn('Age/days', '>', 7,
key=lambda row: row.age)
stnRowFmt.addColumn('StnLs', '>', 10,
key=lambda row: row.station.distFromStar())
Expand All @@ -195,4 +200,4 @@ def render(results, cmdenv, tdb):
"-- Average",
results.summary.avg,
lnl=longestNameLen,
))
))
4 changes: 2 additions & 2 deletions scripts/td-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ _td_buy()
;;
*)
_td_common && return 0
opts="--quantity --near --ly --limit --pad-size --one-stop --price-sort --supply-sort --gt --lt ${common_opts}"
opts="--quantity --near --ly --limit --pad-size --black-market --one-stop --price-sort --supply-sort --gt --lt ${common_opts}"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;;
esac
Expand Down Expand Up @@ -267,7 +267,7 @@ _td_sell()
;;
*)
_td_common && return 0
opts="--near --ly-per --limit --price-sort --pad-size --gt --lt ${common_opts}"
opts="--near --ly-per --limit --price-sort --pad-size --black-market --gt --lt ${common_opts}"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;;
esac
Expand Down

0 comments on commit 0f2fed2

Please sign in to comment.