Erste Version
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
import csv
|
||||
import os.path
|
||||
|
||||
|
||||
# noinspection SpellCheckingInspection
|
||||
class CsvDialect (csv.Dialect):
|
||||
lineterminator='\r\n'
|
||||
delimiter = ','
|
||||
quotechar = '"'
|
||||
quoting=csv.QUOTE_NONNUMERIC
|
||||
|
||||
|
||||
class ComponentReader:
|
||||
|
||||
def __init__(self):
|
||||
self._inner_structure_data = {}
|
||||
self._reactor_data = {}
|
||||
self._weapon_data = {}
|
||||
with open(os.path.join(os.path.dirname(__file__), 'tabellen', 'bauteile.csv')) as csvfile:
|
||||
component_reader = csv.DictReader(csvfile, dialect=CsvDialect)
|
||||
for row in component_reader:
|
||||
self._inner_structure_data[float(row['GTonnage'])] = row
|
||||
with open(os.path.join(os.path.dirname(__file__), 'tabellen', 'reaktoren.csv')) as csvfile:
|
||||
component_reader = csv.DictReader(csvfile, dialect=CsvDialect)
|
||||
for row in component_reader:
|
||||
self._reactor_data[float(row['RW'])] = row
|
||||
with open(os.path.join(os.path.dirname(__file__), 'tabellen', 'waffen.csv')) as csvfile:
|
||||
component_reader = csv.DictReader(csvfile, dialect=CsvDialect)
|
||||
for row in component_reader:
|
||||
self._weapon_data[row['Waffentyp']] = row
|
||||
|
||||
def inner_structure_from(self, tonnage: float) -> float:
|
||||
return float(self._inner_structure_data.get(tonnage, {}).get('Tonnage IS', 0.0))
|
||||
|
||||
def reactor_tonnage_from(self, reactor_value: int) -> float:
|
||||
return float(self._reactor_data.get(reactor_value, {}).get('Tonnage', 0.0))
|
||||
Reference in New Issue
Block a user