Skip to content

Commit

Permalink
Issue #50 Interaction between -0 and demand for a sold item
Browse files Browse the repository at this point in the history
Try to honor -0 a little more while trying to avoid the risk of users making items inaccessible.

This change means that -0 will be honored if the "fromStn" price is 0, but if the station is
buying an item (fromStn > 0) then it will revert to using the default (unk) for the demand
field.
  • Loading branch information
kfsone committed Nov 1, 2014
1 parent 159b15c commit b5775e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ files from other commanders to fill out your database.
v5.0.1 In Progress
. (kfsone) Issue #49 Errors in Ambiguity Error
. (kfsone) Issue #51 L and ? items weren't honoring qty limits
. (kfsone) Issue #50 Interaction between -0 and demand for a sold item

v5.0.0 Oct 31/2014
. (kfsone) Initial Beta 3 changes
Expand Down
14 changes: 12 additions & 2 deletions prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ def itemQtyAndLevel(quantity, level):
file.write(" {}".format("Timestamp"))
file.write("\n\n")


naIQL = itemQtyAndLevel(0, 0)
unkIQL = itemQtyAndLevel(-2, -2)
defIQL = itemQtyAndLevel(-1, -1)

for (sysID, stnID, catID, itemID, fromStn, toStn, modified, demand, demandLevel, stock, stockLevel) in cur:
system = systems[sysID]
if system is not lastSys:
Expand All @@ -162,11 +167,16 @@ def itemQtyAndLevel(quantity, level):
if withSupply:
# Is this item on sale?
if toStn > 0:
demandStr = itemQtyAndLevel(-2, -2)
# Zero demand-price gets default demand, which will
# be either unknown or zero depending on -0.
# If there is a price, always default to unknown
# because it can be sold here but the demand is just
# not useful as data.
demandStr = defIQL if fromStn <= 0 else unkIQL
stockStr = itemQtyAndLevel(stock, stockLevel)
else:
demandStr = itemQtyAndLevel(demand, demandLevel)
stockStr = itemQtyAndLevel(0, 0)
stockStr = naIQL
file.write(" {:>{lvlwidth}} {:>{lvlwidth}}".format(
demandStr,
stockStr,
Expand Down

0 comments on commit b5775e1

Please sign in to comment.