Skip to content

Commit

Permalink
Handle absence of credits/insurance values in tdcalc
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Jan 3, 2015
1 parent 1941493 commit 19488f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ def getBestTrade(self, src, dst, credits=None, fitFunction=None):
'fitFunction' lets you specify a function to use for performing the fit.
"""
tdenv = self.tdenv
if credits is None: credits = tdenv.credits - getattr(tdenv, 'insurance', 0)
if credits is None:
credits = getattr(tdenv, 'credits', 0) or 0
credits -= (getattr(tdenv, 'insurance', 0) or 0)
capacity = tdenv.capacity
avoidItems = tdenv.avoidItems
tdenv.DEBUG0("{}/{} -> {}/{} with {:n}cr",
Expand Down

0 comments on commit 19488f3

Please sign in to comment.