Skip to content

Commit

Permalink
Fixes #217 add illegal flag to rares
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed May 2, 2015
1 parent 6e8af5b commit fc804e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 5 additions & 7 deletions commands/rares_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,14 @@ def render(results, cmdenv, tdb):
key=lambda row: row.dist)
rowFmt.addColumn('Alloc', '>', 6, 'n',
key=lambda row: row.rare.maxAlloc)
rowFmt.addColumn('B/mkt', '>', 4,
key=lambda row: TradeDB.marketStates[row.rare.illegal])
rowFmt.addColumn("StnLs", '>', 10,
key=lambda row: row.rare.station.distFromStar())
rowFmt.addColumn('B/mkt', '>', 4,
key=lambda row: \
TradeDB.marketStates[row.rare.station.blackMarket]
)
key=lambda row: TradeDB.marketStates[row.rare.station.blackMarket])
rowFmt.addColumn("Pad", '>', '3',
key=lambda row: \
TradeDB.padSizes[row.rare.station.maxPadSize]
)
key=lambda row: TradeDB.padSizes[row.rare.station.maxPadSize])

# Print a heading summary if the user didn't use '-q'
if not cmdenv.quiet:
Expand All @@ -233,4 +231,4 @@ def render(results, cmdenv, tdb):

# Print out our results.
for row in results.rows:
print(rowFmt.format(row))
print(rowFmt.format(row))
12 changes: 7 additions & 5 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def name(self):


class RareItem(namedtuple('RareItem', (
'ID', 'station', 'dbname', 'costCr', 'maxAlloc',
'ID', 'station', 'dbname', 'costCr', 'maxAlloc', 'illegal',
))):
"""
Describes a RareItem from the database.
Expand All @@ -475,8 +475,9 @@ class RareItem(namedtuple('RareItem', (
ID -- Database ID,
station -- Which Station this is bought from,
dbname -- The name are presented in the database,
costCr -- Buying price
costCr -- Buying price.
maxAlloc -- How many the player can carry at a time,
illegal -- If the item may be considered illegal,
"""

def name(self):
Expand Down Expand Up @@ -1889,16 +1890,17 @@ def _loadRareItems(self):
station_id,
name,
cost,
max_allocation
max_allocation,
illegal
FROM RareItem
"""
self.cur.execute(stmt)

rareItemByID, rareItemByName = {}, {}
stationByID = self.stationByID
for (ID, stnID, name, cost, maxAlloc) in self.cur:
for (ID, stnID, name, cost, maxAlloc, illegal) in self.cur:
station = stationByID[stnID]
rare = RareItem(ID, station, name, cost, maxAlloc)
rare = RareItem(ID, station, name, cost, maxAlloc, illegal)
rareItemByID[ID] = rareItemByName[name] = rare
self.rareItemByID = rareItemByID
self.rareItemByName = rareItemByName
Expand Down

0 comments on commit fc804e3

Please sign in to comment.