Skip to content

Commit

Permalink
Merged kfsone/tradedangerous into master
Browse files Browse the repository at this point in the history
  • Loading branch information
maddavo committed Jan 1, 2015
2 parents f865874 + 97046dc commit 0b0514a
Show file tree
Hide file tree
Showing 16 changed files with 18,443 additions and 17,097 deletions.
9 changes: 8 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

WIP:
v6.4.0 Jan 01 2015
. (kfsone) Added "rare" sub-command,
. (kfsone) Added RareItem table,
. (kfsone) Imported systems from EDStarCoord,
. (kfsone) Added a LOT of stations,
. (kfsone) Converted all SYSTEM names to upper case in the database,

v6.3.2 Dec 31 2014
. (kfsone) Added experimental "upload-to-maddavo" (misc/madupload.py)
. (kfsone) Improved the feedback from run when routes go wrong.
. (kfsone) fixed "--link-ly" causing a 'TypeError' in various places,
Expand Down
52 changes: 52 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,58 @@ Advanced Commands:
Exports data from the db to .csv files



RARE sub-command:

This command looks for known rare items within the space around
a specified system.

trade.py rare [-q] <system> [--ly N.NN] [--limit N] [--price-sort]

<system>
System to center search on
e.g.
Lave
@Sol

--ly N.NN
DEFAULT: 42
Maximum distance to search from center system.
e.g.
--ly 0 (unlimited)
--ly 21.2

--limit N
Maximum number of results to show
e.g.
--limit 10

--price-sort
-P
Sort by price rather than proximity

--quiet
-q
Don't include the header lines


Examples:

$ trade.py rare sol --ly 10
Station Rare Cost DistLy Alloc
------------------------------------------------------------------------
ALPHA CENTAURI/Hutton Orbital Centauri Mega Gin 3,319 4.38 7

$ trade.py rare @neto --ly 50 --price --limit 5
Station Rare Cost DistLy Alloc
-----------------------------------------------------------------------------
XIHE/Zhen Dock Xihe Biomorphic Companions 4,482 48.10 7
VEGA/Taylor City Vega Slimweed 2,398 33.44 0
LFT 1421/Ehrlich Orbital Void Extract Coffee 2,357 26.45 0
ALTAIR/Solo Orbiter Altairian Skin 489 39.78 18
V1090 HERCULIS/Kaku Plant Herculis Body Rub 160 37.33 20


RUN sub-command:

This command provides the primary trade run calculator functionality (it provides
Expand Down
1 change: 1 addition & 0 deletions commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import commands.local_cmd
import commands.nav_cmd
import commands.olddata_cmd
import commands.rare_cmd
import commands.run_cmd
import commands.sell_cmd
import commands.update_cmd
Expand Down
106 changes: 106 additions & 0 deletions commands/rare_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
from commands.exceptions import *
from commands.parsing import MutuallyExclusiveGroup, ParseArgument
from tradedb import TradeDB

import math

######################################################################
# Parser config

help='Find rares near your current local.'
name='rare'
epilog=None
wantsTradeDB=True
arguments = [
ParseArgument('near', help='Your current system.', type=str),
]
switches = [
ParseArgument('--ly',
help='Maximum distance to search.',
metavar='LY',
type=float,
default=42,
dest='maxLyPer',
),
ParseArgument('--limit',
help='Maximum number of results to list.',
default=None,
type=int,
),
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance',
action='store_true',
default=False,
dest='sortByPrice',
),
]

######################################################################
# Perform query and populate result set

def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

start = cmdenv.nearSystem

results.summary = ResultRow()
results.summary.near = start
results.summary.ly = cmdenv.maxLyPer

maxLySq = cmdenv.maxLyPer ** 2

for rare in tdb.rareItemByID.values():
dist = start.distToSq(rare.station.system)
if maxLySq > 0 and dist > maxLySq:
continue

row = ResultRow()
row.rare = rare
row.dist = math.sqrt(dist)
results.rows.append(row)

if cmdenv.sortByPrice:
results.rows.sort(key=lambda row: row.dist)
results.rows.sort(key=lambda row: row.rare.costCr, reverse=True)
else:
# order by distance, cost
results.rows.sort(key=lambda row: row.rare.costCr, reverse=True)
results.rows.sort(key=lambda row: row.dist)

limit = cmdenv.limit or 0
if limit > 0:
results.rows = results.rows[:limit]

return results

#######################################################################
## Transform result set into output

def render(results, cmdenv, tdb):
from formatting import RowFormat, ColumnFormat

longestStnName = max(results.rows, key=lambda result: len(result.rare.station.name())).rare.station
longestStnNameLen = len(longestStnName.name())
longestRareName = max(results.rows, key=lambda result: len(result.rare.dbname)).rare
longestRareNameLen = len(longestRareName.dbname)

rowFmt = RowFormat()
rowFmt.addColumn('Station', '<', longestStnNameLen,
key=lambda row: row.rare.station.name())
rowFmt.addColumn('Rare', '<', longestRareNameLen,
key=lambda row: row.rare.name())
rowFmt.addColumn('Cost', '>', 10, 'n',
key=lambda row: row.rare.costCr)
rowFmt.addColumn('DistLy', '>', 6, '.2f',
key=lambda row: row.dist)
rowFmt.addColumn('Alloc', '>', 6, 'n',
key=lambda row: row.rare.maxAlloc)

if not cmdenv.quiet:
heading, underline = rowFmt.heading()
print(heading, underline, sep='\n')

for row in results.rows:
print(rowFmt.format(row))

7 changes: 6 additions & 1 deletion corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
DELETED = -111

systems = {
"ARGETLAMH": "Argetlámh",
"ARGETLAMH": "ARGETLáMH",
"TAVYTERE": "ALRAI SECTOR ON-T B3-2",
"PANTAA CEZISA": "GEORGE PANTAZIS",
"DJALI": "HERCULIS SECTOR QD-T B3-4",
"22 LYNCIS": "PEPPER",

#ADD_SYSTEMS_HERE
}
Expand Down Expand Up @@ -56,6 +60,7 @@
'DOM. APPLIANCES': 'Domestic Appliances',
'FRUIT AND VEGETABLES': 'Fruit And Vegetables',
'NON-LETHAL WPNS': 'Non-Lethal Weapons',
'CENTAURI MEGA GIN': DELETED,

}

Expand Down
1 change: 1 addition & 0 deletions data/Added.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ unq:name
'Premium Beta1'
'Premium Beta2'
'undefined-Inferred'
'Release 1.00-EDStar'
9 changes: 4 additions & 5 deletions data/Item.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ unq:[email protected]_id,unq:name,ui_order
'Industrial Materials','Semiconductors',2
'Industrial Materials','Superconductors',3
'Legal Drugs','Beer',1
'Legal Drugs','Centauri Mega Gin',2
'Legal Drugs','Liquor',3
'Legal Drugs','Narcotics',4
'Legal Drugs','Tobacco',5
'Legal Drugs','Wine',6
'Legal Drugs','Liquor',2
'Legal Drugs','Narcotics',3
'Legal Drugs','Tobacco',4
'Legal Drugs','Wine',5
'Machinery','Atmospheric Processors',1
'Machinery','Crop Harvesters',2
'Machinery','Marine Equipment',3
Expand Down
105 changes: 105 additions & 0 deletions data/RareItem.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
[email protected]_id,[email protected]_id,unq:name,cost,max_allocation
'39 TAURI','Porta','Tauri Chimes',938,17
'AEGAEON','Schweickart Station','Chateau De Aegaeon',0,14
'AERIAL','Andrade Legacy','Edan Apples of Aerial',621,15
'ALACARAKMO','Weyl Gateway','Alacarakmo Skin Art',1421,14
'ALPHA CENTAURI','Hutton Orbital','Centauri Mega Gin',3319,7
'ALTAIR','Solo Orbiter','Altairian Skin',489,18
'ALYA','Malaspina Gateway','Alya Body Soup',454,16
'ANDULIGA','Celsius Estate','Anduliga Fire Works',891,0
'ANY NA','Libby Orbital','Any Na Coffee',1790,11
'AROUCA','Shipton Orbital','Arouca Conventula Sweets',1203,0
'AZ CANCRI','Fisher Station','Az Cancri Formula 42',6442,7
'BALTAH''SINE','Baltha''Sine Station','Baltha''sine Vacuum Krill',825,18
'BANKI','Parsons Vista','Banki Amphibious Leather',634,18
'BAST','Hart Station','Bast Snake Gin',1080,10
'BELALANS','Boscovich Ring','Belalans Ray Leather',882,11
'BORASETANI','Katzenstein Terminal','Borasetani Pathogenetics',8269,0
'CD-75 661','Kirk Dock','CD-75 Kitten Brand Coffee',2373,12
'CHERBONES','Chalker Landing','Cherbones Blood Crystals',12550,0
'CHI ERIDANI','Steve Masters','Chi Eridani Marine Paste',784,18
'COQUIM','Hirayama Installation','Coquim Spongiform Victuals',255,20
'DAMNA','Nemere Market','Damna Carapaces',315,0
'DEA MOTRONA','Pinzon Dock','Motrona Experience Jelly',7420,0
'DELTA PHOENICIS','Trading Post','Delta Phoenicis Palms',412,17
'DEURINGAS','Shukor Hub','Deuringas Truffles',1892,0
'DISO','Shifnalport','Diso Ma Corn',180,15
'ELEU','Finney Dock','Eleu Thermals',873,0
'EPSILON INDI','Mansfield Orbiter','Indi Bourbon',978,11
'ERANIN','Azeban City','Eranin Pearl Whiskey',1620,8
'ESHU','Shajn Terminal','Eshu Umbrellas',2050,0
'ESUSEKU','Savinykh Orbital','Esuseku Caviar',2450,0
'ETHGREZE','Bloch Station','Ethgreze Tea Buds',3261,7
'FUJIN','Futen Spaceport','Fujin Tea',1003,10
'GEAWEN','Obruchev Legacy','Geawen Dance Dust',1022,26
'GEORGE PANTAZIS','Zamka Platform','Pantaa Prayer Sticks',1827,9
'GERAS','Yurchikhin Port','Gerasian Gueuze Beer',456,24
'GOMAN','Gustav Sporer Port','Goman Yaupon Coffee',1451,0
'HAIDEN','Searfoss Enterprise','Haiden Black Brew',1347,0
'HAVASUPAI','Lovelace Port','Havasupai Dream Catcher',9636,0
'HECATE','RJH1972','Live Hecate Sea Worms',1190,13
'HEIKE','Brunel City','Ceremonial Heike Tea',0,8
'HELVETITJ','Friend Orbital','Helvetitj Pearls',1810,0
'HIP 10175','Stefanyshyn-Piper Station','HIP 10175 Bush Meat',2105,13
'HIP 41181','Andersson Station','HIP Proto-Squid',1488,0
'HIP 59533','Burnham Beacon','Burnham Bile Distillate',806,0
'HOLVA','Kreutz Orbital','Holva Duelling Blades',6518,0
'HR 7221','Veron City','HR 7221 Wheat',415,0
'IRUKAMA','Blaauw City','Giant Irukama Snails',1810,16
'JARADHARRE','Gohar Station','Jaradharre Puzzle Box',12706,4
'JAROUA','McCool City','Jaroua Rice',0,0
'KACHIRIGIN','Nowak Orbital','Kachirigin Filter Leeches',473,10
'KAMITRA','Hammel Terminal','Kamitra Cigars',6218,6
'KAMORIN','Godwin Vision','Kamorin Historic Weapons',2678,10
'KAPPA FORNACIS','Harvestport','Onion Head',775,17
'KARETII','Sinclair Platform','Karetii Couture',5225,5
'KARSUKI TI','West Market','Karsuki Locusts',915,0
'KINAGO','Fozard Ring','Kinago Violins',7279,3
'KONGGA','Laplace Ring','Kongga Ale',585,16
'KORRO KUNG','Lonchakov Orbital','Koro Kung Pellets',220,20
'LAVE','Lave Station','Lavian Brandy',3500,7
'LEESTI','George Lucas','Azure Milk',3010,7
'LEESTI','George Lucas','Leestian Evil Juice',334,14
'LFT 1421','Ehrlich Orbital','Void Extract Coffee',2357,0
'LP 375-25','King Gateway','Honesty Pills',0,13
'MECHUCOS','Brandenstein Port','Mechucos High Tea',1345,8
'MEDB','Vela Dock','Medb Starlube',416,18
'MOKOJING','Noli Terminal','Mokojing Beast Feast',2681,0
'MOMUS REACH','Tartarus Point','Momus Bog Spaniel',1825,7
'MUKUSUBII','Ledyard Dock','Mukusubii Chitin-os',661,0
'MULACHI','Clark Terminal','Mulachi Giant Fungus',86,0
'NERITUS','Toll Ring','Neritus Berries',850,13
'NGADANDARI','Consolmagno Horizons','Ngadandari Fire Opals',16028,0
'NGUNA','Biggle Hub','Nguna Modern Antiques',930,18
'NJANGARI','Lee Hub','Njangari Saddles',0,10
'OCHOENG','Roddenberry Gateway','Ochoeng Chillies',998,14
'ORRERE','Sharon Lee Free Market','Orrerian Vicious Brew',533,16
'PHIAGRE','Greeboski''s Outpost','Giant Verrix',6552,6
'QUECHUA','Crown Ring','Albino Quechua Mammoth Meat',2538,10
'RAJUKRU','Snyder Terminal','Rajukru Multi-Stoves',682,17
'RAPA BAO','Flagg Gateway','Rapa Bao Snake Skins',550,0
'RUSANI','Fernandes Market','Rusani Old Smokey',5810,0
'SANUMA','Dunyach Gateway','Sanuma Decorative Meat',860,25
'SHINRARTA DEZHRA','Jameson Memorial','Waters of Shintara',7495,5
'TANMARK','Cassie-L-Peia','Tanmark Tranquil Tea',1814,9
'TARACH TOR','Tranquillity','Tarach Spice',1056,8
'THRUTIS','Kingsbury Dock','Thrutis Cream',925,0
'TIOLCE','Gordon Terminal','Tiolce Waste 2 Paste',1153,13
'TOXANDJI','Tsunenaga Orbital','Toxandji Virocide',535,18
'USZAA','Guest Installation','Uszaian Tree Grub',965,14
'UTGAROAR','Fort Klarix','Utgaroar Millennial Eggs',1795,15
'UZUMOKU','Sverdrup Ring','Uzumoku Low-G Wings',8496,0
'V1090 HERCULIS','Kaku Plant','Herculis Body Rub',160,20
'VANAYEQUI','Clauss Hub','Vanayequi Ceratomorpha Fur',615,0
'VEGA','Taylor City','Vega Slimweed',2398,0
'VIDAVANTA','Lee Mines','Vidavantian Lace',6771,0
'VOLKHAB','Vernadsky Dock','Volkhab Bee Drones',3262,6
'WHEEMETE','Eisinga Enterprise','Wheemete Wheat Cakes',262,0
'WITCHHAUL','Hornby Terminal','Witchhaul Kobe Beef',4520,9
'WOLF 1301','Saunders''s Dive','Wolf Fesh',712,13
'WULPA','Williams Gateway','Wulpa Hyperbore Systems',1175,10
'WUTHIELO KU','Tarter Dock','Wuthielo Ku Froth',420,17
'XIHE','Zhen Dock','Xihe Biomorphic Companions',4482,7
'YASO KONDI','Wheeler Market','Yaso Kondi Leaf',6060,5
'ZAONCE','Ridley Scott','Leathery Eggs',23115,1
'ZEESSZE','Nicollier Hanger','Zeessze Ant Grub Glue',380,0
Loading

0 comments on commit 0b0514a

Please sign in to comment.