Skip to content

Commit

Permalink
Another indirection removed
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Jul 12, 2014
1 parent 2f17e06 commit 9ea35f2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ class Station(object):
def __init__(self, ID, system, station):
self.ID, self.system, self.station = ID, system.replace(' ', ''), station.replace(' ', '')
self.links = {}
self.stations = []
self.stations = {}

def addTrade(self, dest, item, itemID, costCr, gainCr):
""" Add a Trade entry from this to a destination station """
dstID = dest.ID
if not dstID in self.links:
self.links[dstID] = []
self.stations.append(dest)
self.stations[dest] = None
trade = Trade(item, itemID, costCr, gainCr)
self.links[dstID].append(trade)

def organizeTrades(self):
for station in self.links:
items = self.links[station]
for dstID in self.links:
items = self.links[dstID]
items.sort(key=lambda trade: trade.gainCr, reverse=True)
for dest in self.stations:
self.stations[dest] = self.links[dest.ID]

def __str__(self):
str = self.system + " " + self.station
Expand Down

0 comments on commit 9ea35f2

Please sign in to comment.