Skip to content

Commit

Permalink
Merge remote-tracking branch 'TheOneTrue/master' into Beta3Systems
Browse files Browse the repository at this point in the history
Conflicts:
	data/Station.csv
  • Loading branch information
SamMackrill committed Nov 3, 2014
2 parents 2e4d5d2 + 8f1e7a7 commit d89a677
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
16 changes: 16 additions & 0 deletions buildcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
processedStations = {}
processedItems = {}
itemPrefix = ""
DELETED = corrections.DELETED

for line in priceFile:
lineNo += 1
Expand Down Expand Up @@ -382,6 +383,11 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
except KeyError:
systemName = corrections.correctSystem(systemName)
stationName = corrections.correctStation(stationName)
if systemName == DELETED or stationName == DELETED:
if debug > 1:
print("- DELETED: {}".format(facility))
stationID = DELETED
continue
facility = systemName.upper() + '/' + stationName
try:
stationID = systemByName[facility]
Expand All @@ -405,6 +411,9 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
# Need a station to process any other type of line.
raise SyntaxError(priceFile, lineNo,
"Expecting '@ SYSTEM / Station' line", text)
if stationID == DELETED:
# Ignore all values from a deleted station/system.
continue

########################################
### "+ Category" lines.
Expand All @@ -419,6 +428,9 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
categoryID = categoriesByName[categoryName]
except KeyError:
categoryName = corrections.correctCategory(categoryName)
if categoryName == DELETED:
### TODO: Determine correct way to handle this.
raise SyntaxError("Category has been deleted.")
try:
categoryID = categoriesByName[categoryName]
if debug > 1:
Expand Down Expand Up @@ -464,6 +476,10 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
except KeyError:
oldName = itemName
itemName = corrections.correctItem(itemName)
if itemName == DELETED:
if debug > 1:
print("- DELETED {}".format(oldName))
continue
try:
itemID = itemByName[itemPrefix + itemName]
if debug > 1:
Expand Down
13 changes: 9 additions & 4 deletions data/corrections.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Provides an interface for correcting star/station names that
# have changed in recent versions.

# Arbitrary, negative value to denote something that's been removed.
DELETED = -111

systems = {
}

stations = {
'LOUIS DE LACAILLE PROSPECT': 'Lacaille Prospect',
'HOPKINS HANGAR': 'Cori Terminal',
'HOPKINS HANGER': 'Cori Terminal',
'EJETA STATION': DELETED,
}

categories = {
Expand All @@ -28,10 +32,10 @@ def correctSystem(oldName):
return oldName

def correctStation(oldName):
try:
return stations[oldName.upper()]
except KeyError:
return oldName
try:
return stations[oldName.upper()]
except KeyError:
return oldName

def correctCategory(oldName):
try:
Expand All @@ -44,3 +48,4 @@ def correctItem(oldName):
return items[oldName.upper()]
except KeyError:
return oldName

7 changes: 5 additions & 2 deletions tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ def _fitCombos(offset, cr, cap):
# 1 unit per 15 minutes for medium
units = level - 1
interval = (30 / level) * 60
adjustment = units * math.floor(item.srcAge / interval)
maxQty = min(maxQty, item.stock + adjustment)
speculativeRecovery = units * math.floor(item.srcAge / interval)
else:
# Low / Unknown - don't try to guess
speculativeRecovery = 0
maxQty = min(maxQty, item.stock + speculativeRecovery)

if maxQty > 0:
loadItems = [[item, maxQty]]
Expand Down

0 comments on commit d89a677

Please sign in to comment.