1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Fix for Electronic Countermeasure in ship loadout.

This commit is contained in:
Jonathan Harris 2015-08-01 23:46:05 +01:00
parent c5c0845390
commit d9d6856ce9
2 changed files with 39 additions and 33 deletions

View File

@ -1,4 +1,4 @@
# Export ship loadout
# Export ship loadout in E:D Shipyard format
from collections import defaultdict
import os
@ -47,34 +47,35 @@ def export(data):
for slot in sorted(data['ship']['modules']):
v = data['ship']['modules'][slot]
if not v or not v.get('module'):
continue
try:
if not v: continue
module = outfitting.lookup(v['module'])
if not module: continue
cr = class_rating(module)
# Specials
if module['name'] in ['Fuel Tank', 'Cargo Rack']:
name = '%s (Capacity: %d)' % (module['name'], 2**int(module['class']))
else:
name = module['name']
for s in slot_map:
if slot.startswith(s):
loadout[slot_map[s]].append(cr + name)
break
else:
if slot.startswith('Slot'):
loadout[slot[-1]].append(cr + name)
elif __debug__: print 'Loadout: Unknown slot %s' % slot
except AssertionError as e:
if __debug__: print 'Loadout: %s' % e
continue # Silently skip unrecognized modules
except:
if __debug__: raise
cr = class_rating(module)
# Specials
if module['name'] in ['Fuel Tank', 'Cargo Rack']:
name = '%s (Capacity: %d)' % (module['name'], 2**int(module['class']))
else:
name = module['name']
for s in slot_map:
if slot.startswith(s):
loadout[slot_map[s]].append(cr + name)
break
else:
if slot.startswith('Slot'):
loadout[slot[-1]].append(cr + name)
elif __debug__: print 'Loadout: Unknown slot %s' % slot
# Construct description
string = '[%s]\n' % ship
for slot in ['H', 'L', 'M', 'S', 'U', None, 'BH', 'RB', 'TM', 'FH', 'EC', 'PC', 'SS', 'FS', None, '9', '8', '7', '6', '5', '4', '3', '2', '1']:

View File

@ -29,7 +29,7 @@ weapon_map = {
'BeamLaser' : 'Beam Laser',
('BeamLaser','Heat') : 'Retributor Beam Laser',
'Cannon' : 'Cannon',
'DrunkMissileRack' : 'Pack-hound Missile Rack',
'DrunkMissileRack' : 'Pack-Hound Missile Rack',
'DumbfireMissileRack' : 'Missile Rack',
'MineLauncher' : 'Mine Launcher',
('MineLauncher','Impulse') : 'Impulse Mine Launcher', # Not seen in game?
@ -152,14 +152,17 @@ weaponoldvariant_map = {
'SS' : 'Scatter Spray',
}
countermeasure_map = {
'ChaffLauncher' : ('Chaff Launcher', 'I'),
'ElectronicCountermeasure' : ('Electronic Countermeasure', 'F'),
'HeatSinkLauncher' : ('Heat Sink Launcher', 'I'),
'PlasmaPointDefence' : ('Point Defence', 'I'),
}
utility_map = {
'CargoScanner' : 'Cargo Scanner',
'ChaffLauncher' : 'Chaff Launcher',
'CloudScanner' : 'Frame Shift Wake Scanner',
'CrimeScanner' : 'Kill Warrant Scanner',
'ElectronicCountermeasure' : 'Electronic Countermeasure',
'HeatSinkLauncher' : 'Heat Sink Launcher',
'PlasmaPointDefence' : 'Point Defence',
'ShieldBooster' : 'Shield Booster',
}
@ -172,7 +175,7 @@ rating_map = {
}
standard_map = {
'Armour' : 'Bulkheads',
# 'Armour' : handled separately
'Engine' : 'Thrusters',
'FuelTank' : 'Fuel Tank',
'Hyperdrive' : 'Frame Shift Drive',
@ -260,17 +263,19 @@ def lookup(module):
new['guidance'] = missiletype_map[name[1]]
new['class'] = weaponclass_map[name[3]]
# Countermeasures - e.g. Hpt_PlasmaPointDefence_Turret_Tiny
elif name[0]=='Hpt' and name[1] in countermeasure_map:
new['category'] = 'utility'
new['name'], new['rating'] = countermeasure_map[len(name)>4 and (name[1],name[4]) or name[1]]
new['class'] = weaponclass_map[name[-1]]
# Utility - e.g. Hpt_CargoScanner_Size0_Class1
elif name[0]=='Hpt' and name[1] in utility_map:
new['category'] = 'utility'
new['name'] = utility_map[len(name)>4 and (name[1],name[4]) or name[1]]
if name[-1] in weaponclass_map: # e.g. Hpt_PlasmaPointDefence_Turret_Tiny
new['class'] = weaponclass_map[name[-1]]
new['rating'] = 'I'
else:
if not name[2].startswith('Size') or not name[3].startswith('Class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3]))
new['class'] = name[2][4:]
new['rating'] = rating_map[name[3][5:]]
if not name[2].startswith('Size') or not name[3].startswith('Class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3]))
new['class'] = name[2][4:]
new['rating'] = rating_map[name[3][5:]]
elif name[0]=='Hpt':
raise AssertionError('%s: Unknown weapon "%s"' % (module['id'], name[1]))