-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from tradedb import * | ||
from tradecalc import * | ||
|
||
tdb = TradeDB(".\\TradeDangerous.accdb") | ||
calc = TradeCalc(tdb, capacity=16, margin=0.01, unique=False) | ||
curStation = None | ||
curCredits = 1000 | ||
|
||
def at(station): | ||
global curStation | ||
curStation = tdb.getStation(station) | ||
|
||
def cr(n): | ||
global curCredits | ||
curCredits = int(n) | ||
|
||
def cap(n): | ||
global calc | ||
calc.capacity = int(n) | ||
|
||
def run(dst=None, stn=None, cr=None, cap=None): | ||
global calc | ||
srcStn = stn if stn else curStation | ||
withCr = cr if cr else curCredits | ||
if not dst: | ||
return calc.getBestHopFrom(srcStn, withCr, capacity=cap) | ||
dstStn = dst if isinstance(dst, Station) else tdb.getStation(dst) | ||
print(srcStn, dstStn, withCr, cap) | ||
return calc.getBestTrade(srcStn, dstStn, withCr, capacity=cap) | ||
|
||
def links(stn=None): | ||
srcStn = stn if stn else curStation | ||
if not srcStn: | ||
print("You don't have a station selected. Use at('name') or links(stn='name')") | ||
return None | ||
if isinstance(srcStn, str): | ||
srcStn = tdb.getStation(srcStn) | ||
return srcStn.stations |