Skip to content

Commit

Permalink
Added TradeDB.getTrade(srcStn, dstStn, item)
Browse files Browse the repository at this point in the history
Returns the Trade, if one exists, describing a transaction between stations.
  • Loading branch information
kfsone committed Aug 21, 2014
1 parent ed44b1a commit c06f94a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ def getShip(self, name):
""" Look up a ship by name """
return self.list_search("Ship", name, self.ships, key=lambda item: item.name)

def getTrade(self, src, dst, item):
""" Returns a Trade object describing purchase of item from src for sale at dst. """
srcStn = self.getStation(src)
dstStn = self.getStation(dst)
trades = srcStn.trades[dstStn.ID]
return trades[item]

def query(self, *args):
""" Perform an SQL query on the DB and return the cursor. """
conn = pypyodbc.connect(self.path)
Expand Down

0 comments on commit c06f94a

Please sign in to comment.