mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
Merge branch 'release/2.2.2'
This commit is contained in:
20
ChangeLog.md
Normal file
20
ChangeLog.md
Normal file
@@ -0,0 +1,20 @@
|
||||
#2.2.x
|
||||
* Update DPS/HPS/EPS in real-time as modifiers change
|
||||
* Use coriolis-data 2.2.2:
|
||||
* Add distributor draw modifier to shield generators
|
||||
* Remove modifiers for sensors
|
||||
* Add initial loadout passenger cabins for Beluga
|
||||
* Add initial loadout passenger cabins for Orca
|
||||
* Update costs and initial loadouts for Keelback and Type-7
|
||||
* Add resistances for hull reinforcement packages
|
||||
* Added modifier actions to create modifications from raw data
|
||||
* Show modification icon for modified modules
|
||||
* Take modifications in to account when deciding whether to issue a warning on a standard module
|
||||
* Fix hardpoint comparison DPS number when selecting an alternate module
|
||||
* Ensure that retrofit tab only shows changed modules
|
||||
* Fix import and export of ships with modifications, bump schema version to 4
|
||||
* Enable boost display even if power distributor is disabled
|
||||
* Calculate breakdown of ship offensive and defensive stats
|
||||
* Add 'Offence summary' and 'Defence summary' components
|
||||
* Add ability to import from companion API output through import feature
|
||||
* Add ability to import from companion API output through URL
|
||||
313
__tests__/fixtures/anaconda-test-detailed-export-v4.json
Normal file
313
__tests__/fixtures/anaconda-test-detailed-export-v4.json
Normal file
@@ -0,0 +1,313 @@
|
||||
{
|
||||
"$schema": "http://cdn.coriolis.io/schemas/ship-loadout/4.json#",
|
||||
"name": "Test My Ship",
|
||||
"ship": "Anaconda",
|
||||
"references": [
|
||||
{
|
||||
"name": "Coriolis.io",
|
||||
"url": "http://localhost:3300/outfit/anaconda/48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4zNKqA==.CwBhCYzBGW9qCTSqs5xA.H4sIAAAAAAAAA2MUe8HMwPD-PwDDhxeuCAAAAA==?bn=Test%20My%20Ship",
|
||||
"old-code": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4zNKqA==.CwBhCYzBGW9qCTSqs5xA.H4sIAAAAAAAAA2MUe8HMwPD-PwDDhxeuCAAAAA==",
|
||||
"code": "4putkFklkdzsuf52c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4zNKqA==.CwBhCYzBGW9qCTSqs5xA.H4sIAAAAAAAAA2MUe8HMwPD-PwDDhxeuCAAAAA==",
|
||||
"shipId": "anaconda"
|
||||
}
|
||||
],
|
||||
"components": {
|
||||
"standard": {
|
||||
"bulkheads": "Reactive Surface Composite",
|
||||
"cargoHatch": {
|
||||
"enabled": false,
|
||||
"priority": 5
|
||||
},
|
||||
"powerPlant": {
|
||||
"class": 8,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"modifications": {
|
||||
"pgen": 1000
|
||||
}
|
||||
},
|
||||
"thrusters": {
|
||||
"class": 6,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1
|
||||
},
|
||||
"frameShiftDrive": {
|
||||
"class": 6,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 3
|
||||
},
|
||||
"lifeSupport": {
|
||||
"class": 5,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1
|
||||
},
|
||||
"powerDistributor": {
|
||||
"class": 8,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1
|
||||
},
|
||||
"sensors": {
|
||||
"class": 8,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1
|
||||
},
|
||||
"fuelTank": {
|
||||
"class": 5,
|
||||
"rating": "C",
|
||||
"enabled": true,
|
||||
"priority": 1
|
||||
}
|
||||
},
|
||||
"hardpoints": [
|
||||
{
|
||||
"class": 4,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Plasma Accelerator",
|
||||
"mount": "Fixed"
|
||||
},
|
||||
{
|
||||
"class": 3,
|
||||
"rating": "D",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Beam Laser",
|
||||
"mount": "Turret"
|
||||
},
|
||||
{
|
||||
"class": 3,
|
||||
"rating": "D",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Beam Laser",
|
||||
"mount": "Turret"
|
||||
},
|
||||
{
|
||||
"class": 3,
|
||||
"rating": "D",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Beam Laser",
|
||||
"mount": "Turret"
|
||||
},
|
||||
{
|
||||
"class": 2,
|
||||
"rating": "E",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Cannon",
|
||||
"mount": "Turret"
|
||||
},
|
||||
{
|
||||
"class": 2,
|
||||
"rating": "E",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Cannon",
|
||||
"mount": "Turret"
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"rating": "F",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Beam Laser",
|
||||
"mount": "Turret"
|
||||
},
|
||||
{
|
||||
"class": 1,
|
||||
"rating": "F",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Beam Laser",
|
||||
"mount": "Turret"
|
||||
}
|
||||
],
|
||||
"utility": [
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Shield Booster"
|
||||
},
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Shield Booster"
|
||||
},
|
||||
null,
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "C",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Kill Warrant Scanner"
|
||||
},
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "C",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Cargo Scanner"
|
||||
},
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "F",
|
||||
"enabled": false,
|
||||
"priority": 1,
|
||||
"group": "Electronic Countermeasure",
|
||||
"name": "Electronic Countermeasure"
|
||||
},
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "I",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Chaff Launcher",
|
||||
"name": "Chaff Launcher"
|
||||
},
|
||||
{
|
||||
"class": 0,
|
||||
"rating": "I",
|
||||
"enabled": true,
|
||||
"priority": 2,
|
||||
"group": "Point Defence",
|
||||
"name": "Point Defence"
|
||||
}
|
||||
],
|
||||
"internal": [
|
||||
{
|
||||
"class": 7,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Shield Generator"
|
||||
},
|
||||
{
|
||||
"class": 6,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Shield Cell Bank"
|
||||
},
|
||||
{
|
||||
"class": 6,
|
||||
"rating": "E",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Cargo Rack"
|
||||
},
|
||||
{
|
||||
"class": 5,
|
||||
"rating": "D",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Hull Reinforcement Package"
|
||||
},
|
||||
{
|
||||
"class": 5,
|
||||
"rating": "E",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Cargo Rack"
|
||||
},
|
||||
null,
|
||||
null,
|
||||
{
|
||||
"class": 4,
|
||||
"rating": "E",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Cargo Rack"
|
||||
},
|
||||
{
|
||||
"class": 4,
|
||||
"rating": "E",
|
||||
"enabled": true,
|
||||
"priority": 1,
|
||||
"group": "Cargo Rack"
|
||||
},
|
||||
{
|
||||
"class": 4,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 3,
|
||||
"group": "Fuel Scoop"
|
||||
},
|
||||
{
|
||||
"class": 2,
|
||||
"rating": "A",
|
||||
"enabled": true,
|
||||
"priority": 3,
|
||||
"group": "Frame Shift Drive Interdictor"
|
||||
}
|
||||
]
|
||||
},
|
||||
"stats": {
|
||||
"class": 3,
|
||||
"fighterHangars": 1,
|
||||
"hullCost": 141889930,
|
||||
"speed": 180,
|
||||
"topSpeed": 186.5,
|
||||
"boost": 240,
|
||||
"boostEnergy": 27,
|
||||
"topBoost": 248.62,
|
||||
"topSpeed": 186.46,
|
||||
"totalCost": 882362058,
|
||||
"totalDpe": 127.26,
|
||||
"totalDps": 97.74,
|
||||
"totalEps": 22.71,
|
||||
"totalHps": 677.29,
|
||||
"totalExplDpe": 0,
|
||||
"totalExplDps": 0,
|
||||
"totalExplSDps": 0,
|
||||
"totalHps": 33.28,
|
||||
"totalKinDpe": 103.97,
|
||||
"totalKinDps": 28.92,
|
||||
"totalKinSDps": 21.23,
|
||||
"totalSDps": 85.77,
|
||||
"totalThermDpe": 23.29,
|
||||
"totalThermDps": 68.82,
|
||||
"totalThermSDps": 64.53,
|
||||
"agility": 2,
|
||||
"baseShieldStrength": 350,
|
||||
"baseArmour": 945,
|
||||
"hullExplRes": 0.78,
|
||||
"hullKinRes": 0.73,
|
||||
"hullMass": 400,
|
||||
"hullThermRes": 1.37,
|
||||
"masslock": 23,
|
||||
"pipSpeed": 0.14,
|
||||
"moduleCostMultiplier": 1,
|
||||
"fuelCapacity": 32,
|
||||
"cargoCapacity": 128,
|
||||
"ladenMass": 1339.2,
|
||||
"armour": 2227.5,
|
||||
"baseArmour": 525,
|
||||
"unladenMass": 1179.2,
|
||||
"powerAvailable": 39.6,
|
||||
"powerRetracted": 23.33,
|
||||
"powerDeployed": 34.76,
|
||||
"unladenRange": 18.49,
|
||||
"fullTankRange": 18.12,
|
||||
"ladenRange": 16.39,
|
||||
"unladenFastestRange": 73.21,
|
||||
"ladenFastestRange": 66.15,
|
||||
"maxJumpCount": 4,
|
||||
"shield": 833,
|
||||
"shieldCells": 1840,
|
||||
"shieldExplRes": 0.5,
|
||||
"shieldKinRes": 0.6,
|
||||
"shieldThermRes": 1.2
|
||||
}
|
||||
}
|
||||
1288
__tests__/fixtures/companion-api-import-1.json
Normal file
1288
__tests__/fixtures/companion-api-import-1.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,31 +2,31 @@
|
||||
{
|
||||
"shipId": "anaconda",
|
||||
"buildName": "Imported Anaconda",
|
||||
"buildCode": "0pyttFolodDsyf5------1717--------05044j-03--2h--00.Iw18ZlA=.Aw18ZlA=",
|
||||
"buildCode": "0pyttFolodDsyf5------1717--------05044j-03--2h--00.Iw18ZlA=.Aw18ZlA=.",
|
||||
"buildText": "[Anaconda]\nS: 1F/F Pulse Laser\nS: 1F/F Pulse Laser\n\nBH: 1I Lightweight Alloy\nRB: 8E Power Plant\nTM: 7E Thrusters\nFH: 6E Frame Shift Drive\nEC: 5E Life Support\nPC: 8E Power Distributor\nSS: 8E Sensors\nFS: 5C Fuel Tank (Capacity: 32)\n\n7: 6E Cargo Rack (Capacity: 64)\n6: 5E Cargo Rack (Capacity: 32)\n6: 6E Shield Generator\n5: 4E Cargo Rack (Capacity: 16)\n4: 1E Basic Discovery Scanner\n2: 1E Cargo Rack (Capacity: 2)\n"
|
||||
},
|
||||
{
|
||||
"shipId": "anaconda",
|
||||
"buildName": "Imported Anaconda",
|
||||
"buildCode": "0pyttFolodDsyf5------1717--------05044j-03--2h--00.Iw18ZlA=.Aw18ZlA=",
|
||||
"buildCode": "0pyttFolodDsyf5------1717--------05044j-03--2h--00.Iw18ZlA=.Aw18ZlA=.",
|
||||
"buildText": "\n\n \t[Anaconda]\nS: 1F/F Pulse Laser\nS: 1F/F Pulse Laser\n\nBH: 1I Lightweight Alloy\nRB: 8E Power Plant\nTM: 7E Thrusters\nFH: 6E Frame Shift Drive\nEC: 5E Life Support\nPC: 8E Power Distributor\nSS: 8E Sensors\nFS: 5C Fuel Tank (Capacity: 32)\n\n7: 6E Cargo Rack (Capacity: 64)\n6: 5E Cargo Rack (Capacity: 32)\n6: 6E Shield Generator\n5: 4E Cargo Rack (Capacity: 16)\n4: 1E Basic Discovery Scanner\n2: 1E Cargo Rack (Capacity: 2)\n"
|
||||
},
|
||||
{
|
||||
"shipId": "cobra_mk_iii",
|
||||
"buildName": "Imported Cobra Mk III",
|
||||
"buildCode": "0patcFeldd5sdf41712222503040202490f242h.Iw1-kA==.Aw1-kA==",
|
||||
"buildCode": "0patcFeldd5sdf41712222503040202490f242h.Iw1-kA==.Aw1-kA==.",
|
||||
"buildText": "[Cobra Mk III]\nM: 1F/F Pulse Laser\nM: 1G/G Burst Laser\nS: 1E/T Fragment Cannon\nS: 1G/T Multi-cannon\nU: 0I Point Defence\nU: 0A Shield Booster\n\nBH: 1I Lightweight Alloy\nRB: 4A Power Plant\nTM: 4C Thrusters\nFH: 4E Frame Shift Drive\nEC: 3D Life Support\nPC: 2A Power Distributor\nSS: 3D Sensors\nFS: 4C Fuel Tank (Capacity: 16)\n\n4: 3E Cargo Rack (Capacity: 8)\n4: 3E Cargo Rack (Capacity: 8)\n4: 4E Shield Generator\n2: 2C Auto Field-Maintenance Unit\n2: 1E Standard Docking Computer\n2: 1E Basic Discovery Scanner\n---\nShield: 112.29 MJ\nPower : 10.45 MW retracted (67%)\n 12.16 MW deployed (78%)\n 15.60 MW available\nCargo : 16 T\nFuel : 16 T\nMass : 235.5 T empty\n 267.5 T full\nRange : 10.69 LY unladen\n 10.05 LY laden\nPrice : 2,929,040 CR\nRe-Buy: 146,452 CR @ 95% insurance\n"
|
||||
},
|
||||
{
|
||||
"shipId": "type_9_heavy",
|
||||
"buildName": "Imported Type-9 Heavy",
|
||||
"buildCode": "3pftsFklkdisif57e2k2f2h110001020306054j03022f01242i.Iw18eQ==.Aw18eQ==",
|
||||
"buildCode": "3pftsFklkdisif57e2k2f2h110001020306054j03022f01242i.Iw18eQ==.Aw18eQ==.",
|
||||
"buildText": "[Type-9 Heavy]\nM: 2D/G Fragment Cannon\nM: 2I/F Mine Launcher\nM: 2B/FD Missile Rack\nS: 1I/FS Torpedo Pylon\nS: 1F/F Burst Laser\nU: 0I Chaff Launcher\nU: 0F Electronic Countermeasure\nU: 0I Heat Sink Launcher\nU: 0I Point Defence\n\nBH: 1I Mirrored Surface Composite\nRB: 5A Power Plant\nTM: 7D Thrusters\nFH: 6A Frame Shift Drive\nEC: 5A Life Support\nPC: 4D Power Distributor\nSS: 4D Sensors\nFS: 5C Fuel Tank (Capacity: 32)\n\n8: 7E Cargo Rack (Capacity: 128)\n7: 6E Cargo Rack (Capacity: 64)\n6: 6E Shield Generator\n5: 4E Cargo Rack (Capacity: 16)\n4: 3E Cargo Rack (Capacity: 8)\n4: 1C Advanced Discovery Scanner\n3: 2E Cargo Rack (Capacity: 4)\n3: 1E Standard Docking Computer\n2: 1C Detailed Surface Scanner\n"
|
||||
},
|
||||
{
|
||||
"shipId": "vulture",
|
||||
"buildName": "Imported Vulture",
|
||||
"buildCode": "4patfFalddksif31e1e0e0j04044a0n532jf1.Iw19kA==.Aw19kA==",
|
||||
"buildCode": "4patfFalddksif31e1e0e0j04044a0n532jf1.Iw19kA==.Aw19kA==.",
|
||||
"buildText": "[Vulture]\nL: 3E/G Pulse Laser\nL: 3E/G Pulse Laser\nU: 0A Frame Shift Wake Scanner\nU: 0A Kill Warrant Scanner\nU: 0A Shield Booster\nU: 0A Shield Booster\n\nBH: 1I Reactive Surface Composite\nRB: 4A Power Plant\nTM: 5A Thrusters\nFH: 4A Frame Shift Drive\nEC: 3D Life Support\nPC: 5A Power Distributor\nSS: 4D Sensors\nFS: 3C Fuel Tank (Capacity: 8)\n\n5: 5A Shield Generator\n4: 4A Auto Field-Maintenance Unit\n2: 2A Shield Cell Bank\n1: 1A Fuel Scoop\n1: 1C Fuel Tank (Capacity: 2)"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
{
|
||||
"type_6_transporter": {
|
||||
"Cargo": "0p0tdFal8d8s8f4-----04040303430101.Iw1-kA==.Aw1-kA==",
|
||||
"Miner": "0p5tdFal8d8s8f42l2l---040403451q0101.Iw1-kA==.Aw1-kA==",
|
||||
"Hopper": "0p0tdFal8d0s8f41717---030302024300-.Iw1-kA==.Aw1-kA=="
|
||||
"Cargo": "0p0tdFal8d8s8f4-----04040303430101.Iw1-kA==.Aw1-kA==.",
|
||||
"Miner": "0p5tdFal8d8s8f42l2l---040403451q0101.Iw1-kA==.Aw1-kA==.",
|
||||
"Hopper": "0p0tdFal8d0s8f41717---030302024300-.Iw1-kA==.Aw1-kA==."
|
||||
},
|
||||
"type_7_transport": {
|
||||
"Cargo": "0p0tiFfliddsdf5--------0505040403480101.Iw18aQ==.Aw18aQ==",
|
||||
"Miner": "0pdtiFflid8sdf5--2l2l----0505041v03450000.Iw18aQ==.Aw18aQ=="
|
||||
"Cargo": "0p0tiFfliddsdf5--------0505040403480101.Iw18aQ==.Aw18aQ==.",
|
||||
"Miner": "0pdtiFflid8sdf5--2l2l----0505041v03450000.Iw18aQ==.Aw18aQ==."
|
||||
},
|
||||
"federal_dropship": {
|
||||
"Cargo": "0pdtiFflnddsif4-1717------05040448020201.Iw18aQ==.Aw18aQ=="
|
||||
"Cargo": "0pdtiFflnddsif4-1717------05040448020201.Iw18aQ==.Aw18aQ==."
|
||||
},
|
||||
"asp": {
|
||||
"Miner": "2pftfFflidfskf50s0s24242l2l---04054a1q02022o27.Iw18WQ==.Aw18WQ=="
|
||||
"Miner": "2pftfFflidfskf50s0s24242l2l---04054a1q02022o27.Iw18WQ==.Aw18WQ==."
|
||||
},
|
||||
"imperial_clipper": {
|
||||
"Cargo": "0p5tiFflndisnf4--0s0s----0605450302020101.Iw18aQ==.Aw18aQ==",
|
||||
"Dream": "2pktkFflndpskf40v0v0s0s0404040n4k5n5d2b29292o-.Iw18aQ==.Aw18aQ==",
|
||||
"Current": "0patkFflndfskf4----------------.Iw18aQ==.Aw18aQ=="
|
||||
"Cargo": "0p5tiFflndisnf4--0s0s----0605450302020101.Iw18aQ==.Aw18aQ==.",
|
||||
"Dream": "2pktkFflndpskf40v0v0s0s0404040n4k5n5d2b29292o-.Iw18aQ==.Aw18aQ==.",
|
||||
"Current": "0patkFflndfskf4----------------.Iw18aQ==.Aw18aQ==."
|
||||
},
|
||||
"type_9_heavy": {
|
||||
"Current": "0patsFklndnsif6---------0706054a0303020224.Iw18eQ==.Aw18eQ=="
|
||||
"Current": "0patsFklndnsif6---------0706054a0303020224.Iw18eQ==.Aw18eQ==."
|
||||
},
|
||||
"python": {
|
||||
"Cargo": "0patnFflidsssf5---------050505040448020201.Iw18eQ==.Aw18eQ==",
|
||||
"Miner": "0pktkFflidpspf50v0v0v2m2m0404--050505Ce4a1v02022o.Iw18eQ==.Aw18eQ==",
|
||||
"Dream": "2pptkFfliduspf50v0v0v27270404040m5n5n4f2d2d032t0201.Iw18eQ==.Aw18eQ==",
|
||||
"Missile": "0pttoFjljdystf52f2g2d2ePh----04044j03---002h.Iw18eQ==.Aw18eQ=="
|
||||
"Cargo": "0patnFflidsssf5---------050505040448020201.Iw18eQ==.Aw18eQ==.",
|
||||
"Miner": "0pktkFflidpspf50v0v0v2m2m0404--050505Ce4a1v02022o.Iw18eQ==.Aw18eQ==.",
|
||||
"Dream": "2pptkFfliduspf50v0v0v27270404040m5n5n4f2d2d032t0201.Iw18eQ==.Aw18eQ==.",
|
||||
"Missile": "0pttoFjljdystf52f2g2d2ePh----04044j03---002h.Iw18eQ==.Aw18eQ==."
|
||||
},
|
||||
"anaconda": {
|
||||
"Dream": "4putpFklndzsuf52c0o0o0o1m1m0q0q0404040l0b0100004k5n5n112d2d040303326b.Iw18ZlA=.Aw18ZlA=",
|
||||
"Cargo": "0patnFklndnsxf5----------------0605050504040445030301.Iw18ZlA=.Aw18ZlA=",
|
||||
"Current": "0patnFklndksxf5----------------0605050504040403034524.Iw18ZlA=.Aw18ZlA=",
|
||||
"Explorer": "0patnFklndksxf5--------0202------f7050505040s372f2i4524.Iw18ZlA=.Aw18ZlA=",
|
||||
"Test": "4putkFklkdzsuf52c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18ZlA=.Aw18ZlA="
|
||||
"Dream": "4putpFklndzsuf52c0o0o0o1m1m0q0q0404040l0b0100004k5n5n112d2d040303326b.Iw18ZlA=.Aw18ZlA=.",
|
||||
"Cargo": "0patnFklndnsxf5----------------0605050504040445030301.Iw18ZlA=.Aw18ZlA=.",
|
||||
"Current": "0patnFklndksxf5----------------0605050504040403034524.Iw18ZlA=.Aw18ZlA=.",
|
||||
"Explorer": "0patnFklndksxf5--------0202------f7050505040s372f2i4524.Iw18ZlA=.Aw18ZlA=.",
|
||||
"Test": "4putkFklkdzsuf52c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18ZlA=.Aw18ZlA=."
|
||||
},
|
||||
"diamondback_explorer": {
|
||||
"Explorer": "0p0tdFfldddsdf5---0202--320p432i2f.Iw1-kA==.Aw1-kA=="
|
||||
"Explorer": "0p0tdFfldddsdf5---0202--320p432i2f.Iw1-kA==.Aw1-kA==."
|
||||
},
|
||||
"vulture": {
|
||||
"Bounty Hunter": "3patcFalddksff31e1e0404-0l4a5d27662j.Iw19kA==.Aw19kA=="
|
||||
"Bounty Hunter": "3patcFalddksff31e1e0404-0l4a5d27662j.Iw19kA==.Aw19kA==."
|
||||
},
|
||||
"fer_de_lance": {
|
||||
"Attack": "2pfthFalidpsff31r0s0s0s0s000404-04-4a-5d27-.Iw18aQ==.Aw18aQ=="
|
||||
"Attack": "2pfthFalidpsff31r0s0s0s0s000404-04-4a-5d27-.Iw18aQ==.Aw18aQ==."
|
||||
},
|
||||
"eagle": {
|
||||
"Figther": "4p0t5F5l3d5s5f20p0p24-40532j-.Iw1-EA==.Aw1-EA=="
|
||||
"Figther": "4p0t5F5l3d5s5f20p0p24-40532j-.Iw1-EA==.Aw1-EA==."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
},
|
||||
"anaconda": {
|
||||
"Dream": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404040l0b0100034k5n05050404040303326b.AwRj4yo5dig=.MwBhEYy6duwEziA=",
|
||||
"Cargo": "03A7D6A5D4D8D5C----------------060505054d040403030301.AwRj4yuqg===.Aw18ZlA="
|
||||
"Cargo": "03A7D6A5D4D8D5C----------------060505054d040403030301.AwRj4yuqg===.Aw18ZlA=",
|
||||
"Modified": "0pyttFolodDsyf5------1717--------05044j-03----2h00.Iw18ZlA=.Aw18ZlA=.H4sIAAAAAAAAA2MUe8HMwPD-PwDDhxeuCAAAAA=="
|
||||
},
|
||||
"diamondback_explorer": {
|
||||
"Explorer": "02A4D5A3D3D3D5C-------320p432i2f.AwRj4zTI.AwiMIypI"
|
||||
@@ -63,4 +64,4 @@
|
||||
1,
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ describe('Import Modal', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Import Detailed Build', function() {
|
||||
describe('Import Detailed V3 Build', function() {
|
||||
|
||||
beforeEach(reset);
|
||||
|
||||
@@ -142,7 +142,7 @@ describe('Import Modal', function() {
|
||||
expect(modal.state.singleBuild).toBe(true);
|
||||
clickProceed();
|
||||
expect(MockRouter.go.mock.calls.length).toBe(1);
|
||||
expect(MockRouter.go.mock.calls[0][0]).toBe('/outfit/anaconda/4putkFklkdzsuf52c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4zNKqA==.CwBhCYzBGW9qCTSqs5xA?bn=Test%20My%20Ship');
|
||||
expect(MockRouter.go.mock.calls[0][0]).toBe('/outfit/anaconda/4putkFklkdzsuf52c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4zNKqA==.CwBhCYzBGW9qCTSqs5xA.?bn=Test%20My%20Ship');
|
||||
});
|
||||
|
||||
it('catches an invalid build', function() {
|
||||
@@ -154,6 +154,23 @@ describe('Import Modal', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Import Detailed V4 Build', function() {
|
||||
|
||||
beforeEach(reset);
|
||||
|
||||
it('imports a valid v4 build', function() {
|
||||
const importData = require('./fixtures/anaconda-test-detailed-export-v4');
|
||||
pasteText(JSON.stringify(importData));
|
||||
|
||||
expect(modal.state.importValid).toBeTruthy();
|
||||
expect(modal.state.errorMsg).toEqual(null);
|
||||
expect(modal.state.singleBuild).toBe(true);
|
||||
clickProceed();
|
||||
expect(MockRouter.go.mock.calls.length).toBe(1);
|
||||
expect(MockRouter.go.mock.calls[0][0]).toBe('/outfit/anaconda/4putkFklkdzsuf52c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4zNKqA==.CwBhCYzBGW9qCTSqs5xA.H4sIAAAAAAAAA2MUe8HMwPD-PwDDhxeuCAAAAA==?bn=Test%20My%20Ship');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Import Detaild Builds Array', function() {
|
||||
|
||||
beforeEach(reset);
|
||||
@@ -179,6 +196,23 @@ describe('Import Modal', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Import Companion API Build', function() {
|
||||
|
||||
beforeEach(reset);
|
||||
|
||||
it('imports a valid v4 build', function() {
|
||||
const importData = require('./fixtures/companion-api-import-1');
|
||||
pasteText(JSON.stringify(importData));
|
||||
|
||||
expect(modal.state.importValid).toBeTruthy();
|
||||
expect(modal.state.errorMsg).toEqual(null);
|
||||
expect(modal.state.singleBuild).toBe(true);
|
||||
clickProceed();
|
||||
expect(MockRouter.go.mock.calls.length).toBe(1);
|
||||
expect(MockRouter.go.mock.calls[0][0]).toBe('/outfit/federal_corvette/2putsFklndzsxf50x0x7l28281919040404040402020l06p05sf63c5ifhv66g2f.AwRj4zNaKA==.CwRgDBldUExuBiQqA===.H4sIAAAAAAAAAx2Rzy4DURTGz7TuzHRu47ZjWreKlg5iQ9KFZ9CENyBWtWo8gIUFsamteAIJi0qEWIhdN11ZEN1IwyNYVKRpcXzH5su553f_XyfvKiLTYma-TkScyHVcokoYEdmbBNDsiDla-WUOT5LgyfAshHdvyGyjFFHUQCSrBU8TLT4gYq4DNL_LhNTFN3PwiqdZQyX2C-sekep-Mrs1RIbnDppsIogD1UAtN7JEM9eIzZg8hmhsEU32gFmrdgB_UARvjYEr4QMUMffoxGnV-M8X3hZ_lAO-gmWq2Eq2IVtDOzZ2Hbbuws6KxCKmKUUydgRb3woSiUXMs6Cs7Qt6FCQSi5hxkNKhj6qhfcPU_kU4wYrFMseSOmFXMKbuwZsViUWMlq1sbhvJ_lKyfqTqEJGJyoC5eIpU9x2TRnUswYXyF77BW4Z3qQuv05GDTpfvcDzvSbxJ5DtV_aHS1I4clyB2A5_b-pAL8x_enn626gEAAA==?bn=Imported%20Federal%20Corvette');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Import E:D Shipyard Builds', function() {
|
||||
|
||||
it('imports a valid builds', function() {
|
||||
|
||||
@@ -4,16 +4,16 @@ import * as Serializer from '../src/app/shipyard/Serializer';
|
||||
import jsen from 'jsen';
|
||||
|
||||
describe("Serializer", function() {
|
||||
const anacondaTestExport = require.requireActual('./fixtures/anaconda-test-detailed-export-v3');
|
||||
const anacondaTestExport = require.requireActual('./fixtures/anaconda-test-detailed-export-v4');
|
||||
const code = anacondaTestExport.references[0].code;
|
||||
const anaconda = Ships.anaconda;
|
||||
const validate = jsen(require('../src/schemas/ship-loadout/3'));
|
||||
const validate = jsen(require('../src/schemas/ship-loadout/4'));
|
||||
|
||||
describe("To Detailed Build", function() {
|
||||
let testBuild = new Ship('anaconda', anaconda.properties, anaconda.slots).buildFrom(code);
|
||||
let exportData = Serializer.toDetailedBuild('Test My Ship', testBuild);
|
||||
|
||||
it("conforms to the v3 ship-loadout schema", function() {
|
||||
it("conforms to the v4 ship-loadout schema", function() {
|
||||
expect(validate(exportData)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("Serializer", function() {
|
||||
const builds = require('./fixtures/expected-builds');
|
||||
const exportData = Serializer.toDetailedExport(builds);
|
||||
|
||||
it("conforms to the v3 ship-loadout schema", function() {
|
||||
it("conforms to the v4 ship-loadout schema", function() {
|
||||
expect(exportData instanceof Array).toBe(true);
|
||||
|
||||
for (let detailedBuild of exportData) {
|
||||
|
||||
@@ -24,7 +24,7 @@ describe("Ship", function() {
|
||||
expect(ship.fuelCapacity).toBeGreaterThan(0, s + ' fuelCapacity');
|
||||
expect(ship.unladenFastestRange).toBeGreaterThan(0, s + ' unladenFastestRange');
|
||||
expect(ship.ladenFastestRange).toBeGreaterThan(0, s + ' ladenFastestRange');
|
||||
expect(ship.shieldStrength).toBeGreaterThan(0, s + ' shieldStrength');
|
||||
expect(ship.shield).toBeGreaterThan(0, s + ' shield');
|
||||
expect(ship.armour).toBeGreaterThan(0, s + ' armour');
|
||||
expect(ship.topSpeed).toBeGreaterThan(0, s + ' topSpeed');
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coriolis_shipyard",
|
||||
"version": "2.2.1",
|
||||
"version": "2.2.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/EDCD/coriolis"
|
||||
@@ -84,12 +84,13 @@
|
||||
"dependencies": {
|
||||
"babel-polyfill": "*",
|
||||
"classnames": "^2.2.0",
|
||||
"browserify-zlib": "ipfs/browserify-zlib",
|
||||
"coriolis-data": "EDCD/coriolis-data",
|
||||
"d3": "3.5.16",
|
||||
"fbemitter": "^2.0.0",
|
||||
"lodash": "^4.15.0",
|
||||
"lz-string": "^1.4.4",
|
||||
"react-number-editor": "^4.0.2",
|
||||
"react-number-editor": "Athanasius/react-number-editor.git#miggy",
|
||||
"react": "^15.0.1",
|
||||
"react-dom": "^15.0.1",
|
||||
"superagent": "^1.4.0"
|
||||
|
||||
@@ -7,6 +7,8 @@ import Persist from './stores/Persist';
|
||||
import Header from './components/Header';
|
||||
import Tooltip from './components/Tooltip';
|
||||
import ModalImport from './components/ModalImport';
|
||||
import * as CompanionApiUtils from './utils/CompanionApiUtils';
|
||||
import { outfitURL } from './utils/UrlGenerators'
|
||||
|
||||
import AboutPage from './pages/AboutPage';
|
||||
import NotFoundPage from './pages/NotFoundPage';
|
||||
@@ -15,6 +17,8 @@ import ComparisonPage from './pages/ComparisonPage';
|
||||
import ShipyardPage from './pages/ShipyardPage';
|
||||
import ErrorDetails from './pages/ErrorDetails';
|
||||
|
||||
const zlib = require('zlib');
|
||||
|
||||
/**
|
||||
* Coriolis App
|
||||
*/
|
||||
@@ -52,6 +56,7 @@ export default class Coriolis extends React.Component {
|
||||
this._onLanguageChange = this._onLanguageChange.bind(this);
|
||||
this._onSizeRatioChange = this._onSizeRatioChange.bind(this);
|
||||
this._keyDown = this._keyDown.bind(this);
|
||||
this._importBuild = this._importBuild.bind(this);
|
||||
|
||||
this.emitter = new EventEmitter();
|
||||
this.state = {
|
||||
@@ -63,13 +68,36 @@ export default class Coriolis extends React.Component {
|
||||
};
|
||||
|
||||
Router('', (r) => this._setPage(ShipyardPage, r));
|
||||
Router('/import?', (r) => this._importBuild(r));
|
||||
Router('/import/:data', (r) => this._importBuild(r));
|
||||
Router('/outfit/?', (r) => this._setPage(OutfittingPage, r));
|
||||
Router('/outfit/:ship/?', (r) => this._setPage(OutfittingPage, r));
|
||||
Router('/outfit/:ship/:code?', (r) => this._setPage(OutfittingPage, r));
|
||||
Router('/compare/:name?', (r) => this._setPage(ComparisonPage, r));
|
||||
Router('/comparison?', (r) => this._setPage(ComparisonPage, r));
|
||||
Router('/comparison/:code', (r) => this._setPage(ComparisonPage, r));
|
||||
Router('/about', (r) => this._setPage(AboutPage, r));
|
||||
Router('*', (r) => this._setPage(null, r));
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a build directly
|
||||
* @param {Object} r The current route
|
||||
*/
|
||||
_importBuild(r) {
|
||||
try {
|
||||
// Need to decode and gunzip the data, then build the ship
|
||||
const data = zlib.gunzipSync(new Buffer(r.params.data, 'base64'));
|
||||
const json = JSON.parse(data);
|
||||
const ship = CompanionApiUtils.shipFromJson(json);
|
||||
r.params.ship = ship.id;
|
||||
r.params.code = ship.toString();
|
||||
this._setPage(OutfittingPage, r);
|
||||
} catch (err) {
|
||||
this._onError('Failed to import ship', r.path, 0, 0, err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates / Sets the page and route context
|
||||
* @param {[type]} page The page to be shown
|
||||
|
||||
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import TranslatedComponent from './TranslatedComponent';
|
||||
import Link from './Link';
|
||||
import cn from 'classnames';
|
||||
import { outfitURL } from '../utils/UrlGenerators';
|
||||
import { SizeMap } from '../shipyard/Constants';
|
||||
|
||||
|
||||
@@ -71,7 +72,7 @@ export default class ComparisonTable extends TranslatedComponent {
|
||||
* @return {React.Component} Table row
|
||||
*/
|
||||
_buildRow(build, facets, formats, units) {
|
||||
let url = `/outfit/${build.id}/${build.toString()}?bn=${build.buildName}`;
|
||||
let url = outfitURL(build.id, build.toString(), build.buildName)
|
||||
let cells = [
|
||||
<td key='s' className='tl'><Link href={url}>{build.name}</Link></td>,
|
||||
<td key='bn' className='tl'><Link href={url}>{build.buildName}</Link></td>
|
||||
|
||||
@@ -379,7 +379,7 @@ export default class CostSection extends TranslatedComponent {
|
||||
<td colSpan='4' className='lbl cap' >{translate('retrofit from')}</td>
|
||||
<td className='val cen' style={{ borderRight: 'none', width: '1em' }}><u className='primary-disabled'>▾</u></td>
|
||||
<td className='val' style={{ borderLeft:'none', padding: 0 }}>
|
||||
<select style={{ width: '100%', padding: 0 }} value={retrofitName} onChange={this._onBaseRetrofitChange}>
|
||||
<select style={{ width: '100%', padding: 0 }} value={retrofitName || translate('Stock')} onChange={this._onBaseRetrofitChange}>
|
||||
{options}
|
||||
</select>
|
||||
</td>
|
||||
@@ -419,7 +419,9 @@ export default class CostSection extends TranslatedComponent {
|
||||
let retroSlotGroup = retrofitShip[g];
|
||||
let slotGroup = ship[g];
|
||||
for (i = 0, l = slotGroup.length; i < l; i++) {
|
||||
if (slotGroup[i].m != retroSlotGroup[i].m) {
|
||||
const modId = slotGroup[i].m ? slotGroup[i].m.eddbID : null;
|
||||
const retroModId = retroSlotGroup[i].m ? retroSlotGroup[i].m.eddbID : null;
|
||||
if (modId != retroModId) {
|
||||
item = { netCost: 0, retroItem: retroSlotGroup[i] };
|
||||
if (slotGroup[i].m) {
|
||||
item.buyName = slotGroup[i].m.name || slotGroup[i].m.grp;
|
||||
@@ -505,19 +507,19 @@ export default class CostSection extends TranslatedComponent {
|
||||
scoop = true;
|
||||
break;
|
||||
case 'scb':
|
||||
q = slotGroup[i].m.cells;
|
||||
q = slotGroup[i].m.getCells();
|
||||
break;
|
||||
case 'am':
|
||||
q = slotGroup[i].m.ammo;
|
||||
q = slotGroup[i].m.getAmmo();
|
||||
break;
|
||||
case 'pv':
|
||||
srvs += slotGroup[i].m.vehicles;
|
||||
srvs += slotGroup[i].m.getBays();
|
||||
break;
|
||||
case 'fx': case 'hb': case 'cc': case 'pc':
|
||||
limpets = ship.cargoCapacity;
|
||||
break;
|
||||
default:
|
||||
q = slotGroup[i].m.clip + slotGroup[i].m.ammo;
|
||||
q = slotGroup[i].m.getClip() + slotGroup[i].m.getAmmo();
|
||||
}
|
||||
// Calculate ammo costs only if a cost is specified
|
||||
if (slotGroup[i].m.ammocost > 0) {
|
||||
@@ -530,6 +532,17 @@ export default class CostSection extends TranslatedComponent {
|
||||
ammoCosts.push(item);
|
||||
ammoTotal += item.total;
|
||||
}
|
||||
// Add fighters
|
||||
if (slotGroup[i].m.grp === 'fh') {
|
||||
item = {
|
||||
m: slotGroup[i].m,
|
||||
max: slotGroup[i].m.getRebuildsPerBay() * slotGroup[i].m.getBays(),
|
||||
cost: slotGroup[i].m.fightercost,
|
||||
total: slotGroup[i].m.getRebuildsPerBay() * slotGroup[i].m.getBays() * slotGroup[i].m.fightercost
|
||||
};
|
||||
ammoCosts.push(item);
|
||||
ammoTotal += item.total;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,12 +563,13 @@ export default class CostSection extends TranslatedComponent {
|
||||
item = {
|
||||
m: { name: 'SRVs', class: '', rating: '' },
|
||||
max: srvs,
|
||||
cost: 6005,
|
||||
total: srvs * 6005
|
||||
cost: 1030,
|
||||
total: srvs * 1030
|
||||
};
|
||||
ammoCosts.push(item);
|
||||
ammoTotal += item.total;
|
||||
}
|
||||
|
||||
// Calculate refuel costs if no scoop present
|
||||
if (!scoop) {
|
||||
item = {
|
||||
|
||||
75
src/app/components/DefenceSummary.jsx
Normal file
75
src/app/components/DefenceSummary.jsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import React from 'react';
|
||||
import cn from 'classnames';
|
||||
import TranslatedComponent from './TranslatedComponent';
|
||||
import { DamageKinetic, DamageThermal, DamageExplosive } from './SvgIcons';
|
||||
|
||||
/**
|
||||
* Defence summary
|
||||
*/
|
||||
export default class DefenceSummary extends TranslatedComponent {
|
||||
static PropTypes = {
|
||||
ship: React.PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param {Object} props React Component properties
|
||||
*/
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render defence summary
|
||||
* @return {React.Component} contents
|
||||
*/
|
||||
render() {
|
||||
let ship = this.props.ship;
|
||||
let { language, tooltip, termtip } = this.context;
|
||||
let { formats, translate, units } = language;
|
||||
let hide = tooltip.bind(null, null);
|
||||
|
||||
return (
|
||||
<span>
|
||||
<h1>{translate('defence summary')}</h1>
|
||||
<table className='summary' style={{ marginLeft: 'auto', marginRight: 'auto', lineHeight: '1em', backgroundColor: 'transparent' }}>
|
||||
<tbody>
|
||||
{ship.shield ?
|
||||
<tr>
|
||||
<td colSpan='4' className='summary'><h2>{translate('shields')}: {formats.int(ship.shield)} {units.MJ}</h2></td>
|
||||
</tr> : null }
|
||||
{ship.shield ?
|
||||
<tr>
|
||||
<td className='ri' onMouseEnter={termtip.bind(null, 'PHRASE_SG_RECOVER', { cap: 0 })} onMouseLeave={hide}>{translate('recovery')}</td>
|
||||
<td className='le'>{formats.time(ship.calcShieldRecovery())}</td>
|
||||
<td className='ri' onMouseEnter={termtip.bind(null, 'PHRASE_SG_RECHARGE', { cap: 0 })} onMouseLeave={hide}>{translate('recharge')}</td>
|
||||
<td className='le'>{formats.time(ship.calcShieldRecharge())}</td>
|
||||
</tr> : null }
|
||||
{ship.shield ?
|
||||
<tr>
|
||||
<td className='le'>{translate('damage from')}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /> {formats.pct1(ship.shieldExplRes || 1)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /> {formats.pct1(ship.shieldKinRes || 1)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /> {formats.pct1(ship.shieldThermRes || 1)}</td>
|
||||
</tr> : null }
|
||||
|
||||
{ ship.shield && ship.shieldCells ?
|
||||
<tr>
|
||||
<td colSpan='4'><h2>{translate('shield cells')}: {formats.int(ship.shieldCells)} {units.MJ}</h2></td>
|
||||
</tr> : null }
|
||||
|
||||
<tr>
|
||||
<td colSpan='4'><h2>{translate('armour')}: {formats.int(ship.armour)}</h2></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='le'>{translate('damage from')}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /> {formats.pct1(ship.hullExplRes || 1)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /> {formats.pct1(ship.hullKinRes || 1)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /> {formats.pct1(ship.hullThermRes || 1)}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import Slot from './Slot';
|
||||
import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications } from './SvgIcons';
|
||||
import Persist from '../stores/Persist';
|
||||
import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications, Modified } from './SvgIcons';
|
||||
import { Modifications } from 'coriolis-data/dist';
|
||||
import { stopCtxPropagation } from '../utils/UtilityFunctions';
|
||||
|
||||
@@ -41,6 +42,7 @@ export default class HardpointSlot extends Slot {
|
||||
let { drag, drop } = this.props;
|
||||
let { termtip, tooltip } = this.context;
|
||||
let validMods = Modifications.validity[m.grp] || [];
|
||||
let showModuleResistances = Persist.showModuleResistances();
|
||||
|
||||
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
||||
<div className={'cb'}>
|
||||
@@ -51,7 +53,9 @@ export default class HardpointSlot extends Slot {
|
||||
{m.type && m.type.match('K') ? <span onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /></span> : ''}
|
||||
{m.type && m.type.match('T') ? <span onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /></span> : ''}
|
||||
{m.type && m.type.match('E') ? <span onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /></span> : ''}
|
||||
{classRating} {translate(m.name || m.grp)}</div>
|
||||
{classRating} {translate(m.name || m.grp)}{ m.mods && Object.keys(m.mods).length > 0 ? <span className='r' onMouseOver={termtip.bind(null, 'modified')} onMouseOut={tooltip.bind(null, null)}><Modified /></span> : null }
|
||||
</div>
|
||||
|
||||
<div className={'r'}>{formats.round(m.getMass())}{u.T}</div>
|
||||
</div>
|
||||
<div className={'cb'}>
|
||||
@@ -60,10 +64,15 @@ export default class HardpointSlot extends Slot {
|
||||
{ m.getHps() ? <div className={'l'} onMouseOver={termtip.bind(null, m.getClip() ? 'hpsshps' : 'hps')} onMouseOut={tooltip.bind(null, null)}>{translate('HPS')}: {formats.round1(m.getHps())} { m.getClip() ? <span>({formats.round1((m.getClip() * m.getHps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) })</span> : null }</div> : null }
|
||||
{ m.getDps() && m.getEps() ? <div className={'l'} onMouseOver={termtip.bind(null, 'dpe')} onMouseOut={tooltip.bind(null, null)}>{translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}</div> : null }
|
||||
{ m.getRoF() ? <div className={'l'} onMouseOver={termtip.bind(null, 'rof')} onMouseOut={tooltip.bind(null, null)}>{translate('ROF')}: {formats.f1(m.getRoF())}{u.ps}</div> : null }
|
||||
{ m.getRange() && !m.getDps() ? <div className={'l'}>{translate('Range')} : {formats.round(m.getRange() / 1000)}{u.km}</div> : null }
|
||||
{ m.getRange() ? <div className={'l'}>{translate('range')} {formats.f1(m.getRange() / 1000)}{u.km}</div> : null }
|
||||
{ m.getShieldBoost() ? <div className={'l'}>+{formats.pct1(m.getShieldBoost())}</div> : null }
|
||||
{ m.getAmmo() ? <div className={'l'}>{translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}</div> : null }
|
||||
{ m.getJitter() ? <div className={'l'}>{translate('jitter')}: {formats.f2(m.getJitter())}°</div> : null }
|
||||
{ showModuleResistances && m.getExplosiveResistance() ? <div className='l'>{translate('explres')}: {formats.pct(m.getExplosiveResistance())}</div> : null }
|
||||
{ showModuleResistances && m.getKineticResistance() ? <div className='l'>{translate('kinres')}: {formats.pct(m.getKineticResistance())}</div> : null }
|
||||
{ showModuleResistances && m.getThermalResistance() ? <div className='l'>{translate('thermres')}: {formats.pct(m.getThermalResistance())}</div> : null }
|
||||
{ m && validMods.length > 0 ? <div className='r' ><button onClick={this._toggleModifications.bind(this)} onContextMenu={stopCtxPropagation} onMouseOver={termtip.bind(null, 'modifications')} onMouseOut={tooltip.bind(null, null)}><ListModifications /></button></div> : null }
|
||||
|
||||
</div>
|
||||
</div>;
|
||||
} else {
|
||||
|
||||
@@ -203,6 +203,13 @@ export default class Header extends TranslatedComponent {
|
||||
Persist.showTooltips(!Persist.showTooltips());
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle module resistances setting
|
||||
*/
|
||||
_toggleModuleResistances() {
|
||||
Persist.showModuleResistances(!Persist.showModuleResistances());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show delete all modal
|
||||
* @param {SyntheticEvent} e Event
|
||||
@@ -359,6 +366,7 @@ export default class Header extends TranslatedComponent {
|
||||
_getSettingsMenu() {
|
||||
let translate = this.context.language.translate;
|
||||
let tips = Persist.showTooltips();
|
||||
let moduleResistances = Persist.showModuleResistances();
|
||||
|
||||
return (
|
||||
<div className='menu-list no-wrap cap' onClick={ (e) => e.stopPropagation() }>
|
||||
@@ -376,6 +384,10 @@ export default class Header extends TranslatedComponent {
|
||||
<td>{translate('tooltips')}</td>
|
||||
<td className={cn('ri', { disabled: !tips, 'primary-disabled': tips })}>{(tips ? '✓' : '✗')}</td>
|
||||
</tr>
|
||||
<tr className='cap ptr' onClick={this._toggleModuleResistances} >
|
||||
<td>{translate('module resistances')}</td>
|
||||
<td className={cn('ri', { disabled: !moduleResistances, 'primary-disabled': moduleResistances })}>{(moduleResistances ? '✓' : '✗')}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{translate('insurance')}</td>
|
||||
<td className='ri'>
|
||||
@@ -438,6 +450,7 @@ export default class Header extends TranslatedComponent {
|
||||
Persist.addListener('deletedAll', update);
|
||||
Persist.addListener('builds', update);
|
||||
Persist.addListener('tooltips', update);
|
||||
Persist.addListener('moduleresistances', update);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import Slot from './Slot';
|
||||
import { ListModifications } from './SvgIcons';
|
||||
import Persist from '../stores/Persist';
|
||||
import { ListModifications, Modified } from './SvgIcons';
|
||||
import { Modifications } from 'coriolis-data/dist';
|
||||
import { stopCtxPropagation } from '../utils/UtilityFunctions';
|
||||
|
||||
@@ -23,11 +24,12 @@ export default class InternalSlot extends Slot {
|
||||
let { drag, drop, ship } = this.props;
|
||||
let { termtip, tooltip } = this.context;
|
||||
let validMods = Modifications.validity[m.grp] || [];
|
||||
let showModuleResistances = Persist.showModuleResistances();
|
||||
|
||||
let mass = m.getMass() || m.cargo || m.fuel || 0;
|
||||
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
||||
<div className={'cb'}>
|
||||
<div className={'l'}>{classRating} {translate(m.name || m.grp)}</div>
|
||||
<div className={'l'}>{classRating} {translate(m.name || m.grp)}{m.mods && Object.keys(m.mods).length > 0 ? <span onMouseOver={termtip.bind(null, 'modified')} onMouseOut={tooltip.bind(null, null)}><Modified /></span> : ''}</div>
|
||||
<div className={'r'}>{formats.round(mass)}{u.T}</div>
|
||||
</div>
|
||||
<div className={'cb'}>
|
||||
@@ -38,7 +40,7 @@ export default class InternalSlot extends Slot {
|
||||
{ m.rate ? <div className={'l'}>{translate('rate')}: {m.rate}{u.kgs} {translate('refuel time')}: {formats.time(this.props.fuel * 1000 / m.rate)}</div> : null }
|
||||
{ m.getAmmo() ? <div className={'l'}>{translate('ammunition')}: {formats.gen(m.getAmmo())}</div> : null }
|
||||
{ m.cells ? <div className={'l'}>{translate('cells')}: {m.cells}</div> : null }
|
||||
{ m.recharge ? <div className={'l'}>{translate('recharge')}: {m.recharge} <u>MJ</u> {translate('total')}: {m.cells * m.recharge}{u.MJ}</div> : null }
|
||||
{ m.shieldreinforcement ? <div className={'l'}>{translate('shieldreinforcement')}: {formats.int(m.getShieldReinforcement())} <u>MJ</u> {translate('total')}: {formats.int(m.cells * m.getShieldReinforcement())}{u.MJ}</div> : null }
|
||||
{ m.repair ? <div className={'l'}>{translate('repair')}: {m.repair}</div> : null }
|
||||
{ m.getFacingLimit() ? <div className={'l'}>{translate('facinglimit')} {formats.f1(m.getFacingLimit())}°</div> : null }
|
||||
{ m.getRange() ? <div className={'l'}>{translate('range')} {formats.f2(m.getRange())}{u.km}</div> : null }
|
||||
@@ -49,8 +51,12 @@ export default class InternalSlot extends Slot {
|
||||
{ m.rangeLS ? <div className={'l'}>{translate('range')}: {m.rangeLS}{u.Ls}</div> : null }
|
||||
{ m.rangeLS === null ? <div className={'l'}>∞{u.Ls}</div> : null }
|
||||
{ m.rangeRating ? <div className={'l'}>{translate('range')}: {m.rangeRating}</div> : null }
|
||||
{ m.getHullReinforcement() ? <div className={'l'}>+{formats.int(m.getHullReinforcement() + ship.baseArmour * m.getModValue('hullboost'))} <u className='cap'>{translate('armour')}</u></div> : null }
|
||||
{ m.getHullReinforcement() ? <div className={'l'}>+{formats.int(m.getHullReinforcement() + ship.baseArmour * m.getModValue('hullboost') / 10000)} <u className='cap'>{translate('armour')}</u></div> : null }
|
||||
{ m.passengers ? <div className={'l'}>{translate('passengers')}: {m.passengers}</div> : null }
|
||||
{ showModuleResistances && m.getExplosiveResistance() ? <div className='l'>{translate('explres')}: {formats.pct(m.getExplosiveResistance())}</div> : null }
|
||||
{ showModuleResistances && m.getKineticResistance() ? <div className='l'>{translate('kinres')}: {formats.pct(m.getKineticResistance())}</div> : null }
|
||||
{ showModuleResistances && m.getThermalResistance() ? <div className='l'>{translate('thermres')}: {formats.pct(m.getThermalResistance())}</div> : null }
|
||||
|
||||
{ m && validMods.length > 0 ? <div className='r' ><button onClick={this._toggleModifications.bind(this)} onContextMenu={stopCtxPropagation} onMouseOver={termtip.bind(null, 'modifications')} onMouseOut={tooltip.bind(null, null)}><ListModifications /></button></div> : null }
|
||||
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ import * as ModuleUtils from '../shipyard/ModuleUtils';
|
||||
import { fromDetailedBuild } from '../shipyard/Serializer';
|
||||
import { Download } from './SvgIcons';
|
||||
import { outfitURL } from '../utils/UrlGenerators';
|
||||
import * as CompanionApiUtils from '../utils/CompanionApiUtils';
|
||||
|
||||
const textBuildRegex = new RegExp('^\\[([\\w \\-]+)\\]\n');
|
||||
const lineRegex = new RegExp('^([\\dA-Z]{1,2}): (\\d)([A-I])[/]?([FGT])?([SD])? ([\\w\\- ]+)');
|
||||
@@ -112,6 +113,7 @@ export default class ModalImport extends TranslatedComponent {
|
||||
this._importBackup = this._importBackup.bind(this);
|
||||
this._importDetailedArray = this._importDetailedArray.bind(this);
|
||||
this._importTextBuild = this._importTextBuild.bind(this);
|
||||
this._importCompanionApiBuild = this._importCompanionApiBuild.bind(this);
|
||||
this._validateImport = this._validateImport.bind(this);
|
||||
}
|
||||
|
||||
@@ -183,6 +185,21 @@ export default class ModalImport extends TranslatedComponent {
|
||||
this.setState({ builds });
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a build direct from the companion API
|
||||
* @param {string} build JSON from the companion API information
|
||||
* @throws {string} if parse/import fails
|
||||
*/
|
||||
_importCompanionApiBuild(build) {
|
||||
const shipModel = CompanionApiUtils.shipModelFromJson(build);
|
||||
const ship = CompanionApiUtils.shipFromJson(build);
|
||||
|
||||
let builds = {};
|
||||
builds[shipModel] = {};
|
||||
builds[shipModel]['Imported ' + Ships[shipModel].properties.name] = ship.toString();
|
||||
this.setState({ builds, singleBuild: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a text build from ED Shipyard
|
||||
* @param {string} buildStr Build string
|
||||
@@ -315,7 +332,11 @@ export default class ModalImport extends TranslatedComponent {
|
||||
throw 'Must be an object or array!';
|
||||
}
|
||||
|
||||
if (importData instanceof Array) { // Must be detailed export json
|
||||
if (importData.modules != null && importData.modules.Armour != null) { // Only the companion API has this information
|
||||
this._importCompanionApiBuild(importData); // Single sihp definition
|
||||
} else if (importData.ship != null && importData.ship.modules != null && importData.ship.modules.Armour != null) { // Only the companion API has this information
|
||||
this._importCompanionApiBuild(importData.ship); // Complete API dump
|
||||
} else if (importData instanceof Array) { // Must be detailed export json
|
||||
this._importDetailedArray(importData);
|
||||
} else if (importData.ship && typeof importData.name !== undefined) { // Using JSON from a single ship build export
|
||||
this._importDetailedArray([importData]); // Convert to array with singleobject
|
||||
|
||||
@@ -7,7 +7,7 @@ import NumberEditor from 'react-number-editor';
|
||||
/**
|
||||
* Modification
|
||||
*/
|
||||
export default class ModificationsMenu extends TranslatedComponent {
|
||||
export default class Modification extends TranslatedComponent {
|
||||
|
||||
static propTypes = {
|
||||
ship: React.PropTypes.object.isRequired,
|
||||
@@ -24,26 +24,30 @@ export default class ModificationsMenu extends TranslatedComponent {
|
||||
constructor(props, context) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
this.state.value = this.props.m.getModValue(this.props.name) * 100 || 0;
|
||||
this.state.value = this.props.m.getModValue(this.props.name) / 100 || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update modification given a value.
|
||||
* @param {Number} value The value to set
|
||||
* @param {Number} value The value to set. This comes in as a string and must be stored in state as a string,
|
||||
* because it needs to allow illegal 'numbers' ('-', '1.', etc) when the user is typing
|
||||
* in a value by hand
|
||||
*/
|
||||
_updateValue(value) {
|
||||
let scaledValue = Math.floor(Number(value) * 100) / 10000;
|
||||
const name = this.props.name;
|
||||
|
||||
let scaledValue = Math.round(Number(value) * 100);
|
||||
// Limit to +1000% / -100%
|
||||
if (scaledValue > 10) {
|
||||
scaledValue = 10;
|
||||
if (scaledValue > 100000) {
|
||||
scaledValue = 100000;
|
||||
value = 1000;
|
||||
}
|
||||
if (scaledValue < -1) {
|
||||
scaledValue = -1;
|
||||
if (scaledValue < -10000) {
|
||||
scaledValue = -10000;
|
||||
value = -100;
|
||||
}
|
||||
|
||||
let m = this.props.m;
|
||||
let name = this.props.name;
|
||||
let ship = this.props.ship;
|
||||
ship.setModification(m, name, scaledValue);
|
||||
|
||||
@@ -62,7 +66,7 @@ export default class ModificationsMenu extends TranslatedComponent {
|
||||
return (
|
||||
<div className={'cb'} key={name}>
|
||||
<div className={'cb'}>{translate(name)}{name === 'jitter' ? ' (°)' : ' (%)'}</div>
|
||||
<NumberEditor className={'cb'} style={{ width: '100%', textAlign: 'center' }} step={0.01} stepModifier={1} decimals={2} value={this.state.value} onValueChange={this._updateValue.bind(this)} />
|
||||
<NumberEditor className={'cb'} style={{ width: '90%', textAlign: 'center' }} step={0.01} stepModifier={1} decimals={2} value={this.state.value} onValueChange={this._updateValue.bind(this)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,11 +50,13 @@ export default class ModificationsMenu extends TranslatedComponent {
|
||||
* @return {React.Component} List
|
||||
*/
|
||||
render() {
|
||||
let { tooltip, termtip } = this.context;
|
||||
return (
|
||||
<div
|
||||
className={cn('select', this.props.className)}
|
||||
onClick={(e) => e.stopPropagation() }
|
||||
onContextMenu={stopCtxPropagation}
|
||||
onMouseOver={termtip.bind(null, 'HELP_MODIFICATIONS_MENU')} onMouseOut={tooltip.bind(null, null)}
|
||||
>
|
||||
{this.state.list}
|
||||
</div>
|
||||
|
||||
70
src/app/components/OffenceSummary.jsx
Normal file
70
src/app/components/OffenceSummary.jsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import React from 'react';
|
||||
import cn from 'classnames';
|
||||
import TranslatedComponent from './TranslatedComponent';
|
||||
import { DamageKinetic, DamageThermal, DamageExplosive } from './SvgIcons';
|
||||
|
||||
/**
|
||||
* Offence summary
|
||||
*/
|
||||
export default class OffenceSummary extends TranslatedComponent {
|
||||
static PropTypes = {
|
||||
ship: React.PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param {Object} props React Component properties
|
||||
*/
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render offence summary
|
||||
* @return {React.Component} contents
|
||||
*/
|
||||
render() {
|
||||
let ship = this.props.ship;
|
||||
let { language, tooltip, termtip } = this.context;
|
||||
let { formats, translate } = language;
|
||||
|
||||
return (
|
||||
<span>
|
||||
<h1>{translate('offence summary')}</h1>
|
||||
<table className='summary' style={{ marginLeft: 'auto', marginRight: 'auto', lineHeight: '1em', backgroundColor: 'transparent' }}>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colSpan='4' className='summary'><h2>{translate('dps')}: {formats.f1(ship.totalDps)}</h2></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='le'>{translate('damage by')}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /> {formats.f1(ship.totalExplDps)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /> {formats.f1(ship.totalKinDps)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /> {formats.f1(ship.totalThermDps)}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colSpan='4' className='summary'><h2>{translate('sdps')}: {formats.f1(ship.totalSDps)}</h2></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='le'>{translate('damage by')}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /> {formats.f1(ship.totalExplSDps)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /> {formats.f1(ship.totalKinSDps)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /> {formats.f1(ship.totalThermSDps)}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colSpan='4' className='summary'><h2>{translate('dpe')}: {formats.f1(ship.totalDpe)}</h2></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='le'>{translate('damage by')}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'explosive')} onMouseOut={tooltip.bind(null, null)}><DamageExplosive /> {formats.f1(ship.totalExplDpe)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'kinetic')} onMouseOut={tooltip.bind(null, null)}><DamageKinetic /> {formats.f1(ship.totalKinDpe)}</td>
|
||||
<td className='ri' onMouseOver={termtip.bind(null, 'thermal')} onMouseOut={tooltip.bind(null, null)}><DamageThermal /> {formats.f1(ship.totalThermDpe)}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -34,20 +34,6 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
sgRecharge = time(ship.calcShieldRecharge());
|
||||
}
|
||||
|
||||
// <th colSpan={3}>{translate('shield resistance')}</th>
|
||||
// <th colSpan={3}>{translate('hull resistance')}</th>
|
||||
// <th className='lft'>{translate('explosive')}</th>
|
||||
// <th className='lft'>{translate('kinetic')}</th>
|
||||
// <th className='lft'>{translate('thermal')}</th>
|
||||
// <th className='lft'>{translate('explosive')}</th>
|
||||
// <th className='lft'>{translate('kinetic')}</th>
|
||||
// <th className='lft'>{translate('thermal')}</th>
|
||||
// <td>{pct(ship.shieldExplRes)}</td>
|
||||
// <td>{pct(ship.shieldKinRes)}</td>
|
||||
// <td>{pct(ship.shieldThermRes)}</td>
|
||||
// <td>{pct(ship.hullExplRes)}</td>
|
||||
// <td>{pct(ship.hullKinRes)}</td>
|
||||
// <td>{pct(ship.hullThermRes)}</td>
|
||||
return <div id='summary'>
|
||||
<table id='summaryTable'>
|
||||
<thead>
|
||||
@@ -58,7 +44,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
<th onMouseEnter={termtip.bind(null, 'energy per second')} onMouseLeave={hide} rowSpan={2}>{translate('EPS')}</th>
|
||||
<th onMouseEnter={termtip.bind(null, 'heat per second')} onMouseLeave={hide} rowSpan={2}>{translate('HPS')}</th>
|
||||
<th rowSpan={2}>{translate('armour')}</th>
|
||||
<th colSpan={3}>{translate('shields')}</th>
|
||||
<th rowSpan={2}>{translate('shields')}</th>
|
||||
<th colSpan={3}>{translate('mass')}</th>
|
||||
<th rowSpan={2}>{translate('cargo')}</th>
|
||||
<th rowSpan={2}>{translate('fuel')}</th>
|
||||
@@ -67,9 +53,6 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
<th onMouseEnter={termtip.bind(null, 'mass lock factor')} onMouseLeave={hide} rowSpan={2}>{translate('MLF')}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th className='lft'>{translate('strength')}</th>
|
||||
<th onMouseEnter={termtip.bind(null, 'PHRASE_SG_RECOVER', { cap: 0 })} onMouseLeave={hide}>{translate('recovery')}</th>
|
||||
<th onMouseEnter={termtip.bind(null, 'PHRASE_SG_RECHARGE', { cap: 0 })} onMouseLeave={hide}>{translate('recharge')}</th>
|
||||
<th className='lft'>{translate('hull')}</th>
|
||||
<th onMouseEnter={termtip.bind(null, 'PHRASE_UNLADEN', { cap: 0 })} onMouseLeave={hide}>{translate('unladen')}</th>
|
||||
<th onMouseEnter={termtip.bind(null, 'PHRASE_LADEN', { cap: 0 })} onMouseLeave={hide}>{translate('laden')}</th>
|
||||
@@ -90,8 +73,6 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
||||
<td>{f1(ship.totalHps)}</td>
|
||||
<td>{int(ship.armour)}</td>
|
||||
<td className={sgClassNames}>{int(ship.shield)} {u.MJ}</td>
|
||||
<td className={sgClassNames}>{sgRecover}</td>
|
||||
<td className={sgClassNames}>{sgRecharge}</td>
|
||||
<td>{ship.hullMass} {u.T}</td>
|
||||
<td>{int(ship.unladenMass)} {u.T}</td>
|
||||
<td>{int(ship.ladenMass)} {u.T}</td>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import React from 'react';
|
||||
import cn from 'classnames';
|
||||
import Persist from '../stores/Persist';
|
||||
import TranslatedComponent from './TranslatedComponent';
|
||||
import { jumpRange } from '../shipyard/Calculations';
|
||||
import { diffDetails } from '../utils/SlotFunctions';
|
||||
import AvailableModulesMenu from './AvailableModulesMenu';
|
||||
import ModificationsMenu from './ModificationsMenu';
|
||||
import { ListModifications } from './SvgIcons';
|
||||
import { ListModifications, Modified } from './SvgIcons';
|
||||
import { Modifications } from 'coriolis-data/dist';
|
||||
import { stopCtxPropagation } from '../utils/UtilityFunctions';
|
||||
|
||||
@@ -46,6 +47,7 @@ export default class StandardSlot extends TranslatedComponent {
|
||||
let classRating = m.class + m.rating;
|
||||
let menu;
|
||||
let validMods = m == null ? [] : (Modifications.validity[m.grp] || []);
|
||||
let showModuleResistances = Persist.showModuleResistances();
|
||||
let mass = m.getMass() || m.cargo || m.fuel || 0;
|
||||
|
||||
if (!selected) {
|
||||
@@ -79,11 +81,10 @@ export default class StandardSlot extends TranslatedComponent {
|
||||
<div className={cn('details-container', { warning: warning && warning(slot.m) })}>
|
||||
<div className={'sz'}>{slot.maxClass}</div>
|
||||
<div>
|
||||
<div className='l'>{classRating} {translate(m.grp == 'bh' ? m.grp : m.name || m.grp)}</div>
|
||||
<div className={'l'}>{classRating} {translate(m.name || m.grp)}{m.mods && Object.keys(m.mods).length > 0 ? <span className='r' onMouseOver={termtip.bind(null, 'modified')} onMouseOut={tooltip.bind(null, null)}><Modified /></span> : null }</div>
|
||||
<div className={'r'}>{formats.round(mass)}{units.T}</div>
|
||||
<div/>
|
||||
<div className={'cb'}>
|
||||
{ m.grp == 'bh' && m.name ? <div className='l'>{translate(m.name)}</div> : null }
|
||||
{ m.getOptimalMass() ? <div className='l'>{translate('optimal mass')}: {formats.int(m.getOptimalMass())}{units.T}</div> : null }
|
||||
{ m.getMaxMass() ? <div className='l'>{translate('max mass')}: {formats.int(m.getMaxMass())}{units.T}</div> : null }
|
||||
{ m.getRange() ? <div className='l'>{translate('range')}: {formats.f2(m.getRange())}{units.km}</div> : null }
|
||||
@@ -94,6 +95,9 @@ export default class StandardSlot extends TranslatedComponent {
|
||||
{ m.getWeaponsCapacity() ? <div className='l'>{translate('WEP')}: {formats.f1(m.getWeaponsCapacity())}{units.MJ} / {formats.f1(m.getWeaponsRechargeRate())}{units.MW}</div> : null }
|
||||
{ m.getSystemsCapacity() ? <div className='l'>{translate('SYS')}: {formats.f1(m.getSystemsCapacity())}{units.MJ} / {formats.f1(m.getSystemsRechargeRate())}{units.MW}</div> : null }
|
||||
{ m.getEnginesCapacity() ? <div className='l'>{translate('ENG')}: {formats.f1(m.getEnginesCapacity())}{units.MJ} / {formats.f1(m.getEnginesRechargeRate())}{units.MW}</div> : null }
|
||||
{ showModuleResistances && m.getExplosiveResistance() ? <div className='l'>{translate('explres')}: {formats.pct(m.getExplosiveResistance())}</div> : null }
|
||||
{ showModuleResistances && m.getKineticResistance() ? <div className='l'>{translate('kinres')}: {formats.pct(m.getKineticResistance())}</div> : null }
|
||||
{ showModuleResistances && m.getThermalResistance() ? <div className='l'>{translate('thermres')}: {formats.pct(m.getThermalResistance())}</div> : null }
|
||||
|
||||
{ validMods.length > 0 ? <div className='r' ><button onClick={this._toggleModifications.bind(this)} onContextMenu={stopCtxPropagation} onMouseOver={termtip.bind(null, 'modifications')} onMouseOut={tooltip.bind(null, null)}><ListModifications /></button></div> : null }
|
||||
</div>
|
||||
|
||||
@@ -2,8 +2,8 @@ import React from 'react';
|
||||
import cn from 'classnames';
|
||||
import SlotSection from './SlotSection';
|
||||
import StandardSlot from './StandardSlot';
|
||||
import Module from '../shipyard/Module';
|
||||
import { diffDetails } from '../utils/SlotFunctions';
|
||||
import * as ModuleUtils from '../shipyard/ModuleUtils';
|
||||
import * as ShipRoles from '../shipyard/ShipRoles';
|
||||
import { stopCtxPropagation } from '../utils/UtilityFunctions';
|
||||
|
||||
@@ -114,7 +114,7 @@ export default class StandardSlotSection extends SlotSection {
|
||||
selected={currentMenu == st[0]}
|
||||
onChange={this.props.onChange}
|
||||
ship={ship}
|
||||
warning={m => m.pgen < ship.powerRetracted}
|
||||
warning={m => m instanceof Module ? m.getPowerGeneration() < ship.powerRetracted : m.pgen < ship.powerRetracted}
|
||||
/>;
|
||||
|
||||
slots[2] = <StandardSlot
|
||||
@@ -126,7 +126,7 @@ export default class StandardSlotSection extends SlotSection {
|
||||
selected={currentMenu == st[1]}
|
||||
onChange={this.props.onChange}
|
||||
ship={ship}
|
||||
warning={m => m.maxmass < (ship.ladenMass - st[1].mass + m.mass)}
|
||||
warning={m => m instanceof Module ? m.getMaxMass() < (ship.ladenMass - st[1].mass + m.mass) : m.maxmass < (ship.ladenMass - st[1].mass + m.mass)}
|
||||
/>;
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ export default class StandardSlotSection extends SlotSection {
|
||||
selected={currentMenu == st[4]}
|
||||
onChange={this.props.onChange}
|
||||
ship={ship}
|
||||
warning= {m => m.engcap < ship.boostEnergy}
|
||||
warning={m => m instanceof Module ? m.getEnginesCapacity() < ship.boostEnergy : m.engcap < ship.boostEnergy}
|
||||
/>;
|
||||
|
||||
slots[6] = <StandardSlot
|
||||
|
||||
@@ -497,7 +497,19 @@ export class ListModifications extends SvgIcon {
|
||||
* @return {String} view box
|
||||
*/
|
||||
viewBox() { return '0 0 200 200'; }
|
||||
|
||||
/**
|
||||
* Render the Icon
|
||||
* @return {React.Component} SVG Icon
|
||||
*/
|
||||
render() {
|
||||
return (
|
||||
<svg className={cn('modicon', this.props.className)} style={this.props.style} viewBox={this.viewBox()}>
|
||||
{this.svg()}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the SVG
|
||||
* @return {React.Component} SVG Contents
|
||||
@@ -507,6 +519,40 @@ export class ListModifications extends SvgIcon {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modified (engineers)
|
||||
*/
|
||||
export class Modified extends SvgIcon {
|
||||
/**
|
||||
* Overriden view box
|
||||
* @return {String} view box
|
||||
*/
|
||||
viewBox() { return '0 0 200 200'; }
|
||||
|
||||
/**
|
||||
* Render the Icon
|
||||
* @return {React.Component} SVG Icon
|
||||
*/
|
||||
render() {
|
||||
return (
|
||||
<svg className={cn('modicon', this.props.className)} style={this.props.style} viewBox={this.viewBox()}>
|
||||
{this.svg()}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the SVG
|
||||
* @return {React.Component} SVG Contents
|
||||
*/
|
||||
svg() {
|
||||
return <g>
|
||||
<path d="M100,5L18,52.5L18,147.5L100,195L182,147.5L182,52.5L100,5Z"/>
|
||||
<path d="M100,70L74,85L74,115L100,130L126,115L126,85L100,70Z"/>
|
||||
</g>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hammer
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as ES from './es';
|
||||
import * as FR from './fr';
|
||||
import * as IT from './it';
|
||||
import * as RU from './ru';
|
||||
import * as PL from './pl';
|
||||
import d3 from 'd3';
|
||||
|
||||
let fallbackTerms = EN.terms;
|
||||
@@ -23,6 +24,7 @@ export function getLanguage(langCode) {
|
||||
case 'fr': lang = FR; break;
|
||||
case 'it': lang = IT; break;
|
||||
case 'ru': lang = RU; break;
|
||||
case 'pl': lang = PL; break;
|
||||
default:
|
||||
lang = EN;
|
||||
}
|
||||
@@ -82,5 +84,6 @@ export const Languages = {
|
||||
it: 'Italiano',
|
||||
es: 'Español',
|
||||
fr: 'Français',
|
||||
ru: 'ру́сский'
|
||||
ru: 'ру́сский',
|
||||
pl: 'polski'
|
||||
};
|
||||
|
||||
@@ -29,6 +29,8 @@ export const terms = {
|
||||
PHRASE_UNLADEN: 'Ship mass excluding fuel and cargo',
|
||||
PHRASE_UPDATE_RDY: 'Update Available! Click to refresh',
|
||||
|
||||
HELP_MODIFICATIONS_MENU: 'Click on a number to enter a new value, or drag along the bar for small changes',
|
||||
|
||||
// Other languages fallback to these values
|
||||
// Only Translate to other languages if the name is different in-game
|
||||
am: 'Auto Field-Maintenance Unit',
|
||||
@@ -92,14 +94,18 @@ export const terms = {
|
||||
// Unit for seconds
|
||||
secs: 's',
|
||||
|
||||
// Hardpoint abbreviations
|
||||
// Weapon, offence and defence
|
||||
dpe: 'Damage per MJ of energy',
|
||||
dps: 'Damage per second',
|
||||
sdps: 'Sustained damage per second',
|
||||
dpssdps: 'Damage per second (sustained damage per second)',
|
||||
eps: 'Energy per second',
|
||||
epsseps: 'Energy per second (sustained energy per second)',
|
||||
hps: 'Heat per second',
|
||||
hpsshps: 'Heat per second (sustained heat per second)',
|
||||
'damage by': 'Damage by',
|
||||
'damage from': 'Damage from',
|
||||
'shield cells': 'Shield cells',
|
||||
|
||||
// Modifications
|
||||
ammo: 'Ammunition maximum',
|
||||
@@ -134,6 +140,7 @@ export const terms = {
|
||||
rof: 'Rate of fire',
|
||||
shield: 'Shield',
|
||||
shieldboost: 'Shield boost',
|
||||
shieldreinforcement: 'Shield reinforcement',
|
||||
spinup: 'Spin up time',
|
||||
syscap: 'Systems capacity',
|
||||
sysrate: 'Systems recharge rate',
|
||||
|
||||
77
src/app/i18n/pl.js
Normal file
77
src/app/i18n/pl.js
Normal file
@@ -0,0 +1,77 @@
|
||||
export const formats = {
|
||||
decimal: '.',
|
||||
thousands: ',',
|
||||
grouping: [3],
|
||||
currency: ['$', ''],
|
||||
dateTime: '%a %b %e %X %Y',
|
||||
date: '%m/%d/%Y',
|
||||
time: '%H:%M:%S',
|
||||
periods: ['AM', 'PM'],
|
||||
days: ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'],
|
||||
shortDays: ['Nie', 'Pon', 'Wt', 'Śr', 'Czw', 'Pt', 'Sob'],
|
||||
months: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
|
||||
shortMonths: ['Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru']
|
||||
};
|
||||
|
||||
export const terms = {
|
||||
PHRASE_ALT_ALL: 'Alt + kliknięcie by wypełnić wszystkie sloty',
|
||||
PHRASE_BACKUP_DESC: 'Kopia zapasowa wszystkich danych Coriolis w celu zapisu lub przeniesienia na inne urządzenie/przeglądarkę',
|
||||
PHRASE_CONFIRMATION: 'Czy jesteś pewien?',
|
||||
PHRASE_EXPORT_DESC: 'Szczegółowy eksport schematu w formacie JSON w celu użycia na innych stronach i narzędziach',
|
||||
PHRASE_FASTEST_RANGE: 'Maksymalna ilość skoków na najwyższym zasięgu',
|
||||
PHRASE_IMPORT: 'Wklej tu JSON lub importuj',
|
||||
PHRASE_LADEN: 'Masa statku + paliwo + ładunek',
|
||||
PHRASE_NO_BUILDS: 'Nie dodano schematu do porównania!',
|
||||
PHRASE_NO_RETROCH: 'Brak zmian retrofit',
|
||||
PHRASE_SELECT_BUILDS: 'Wybierz schematy do porównania',
|
||||
PHRASE_SG_RECHARGE: 'Czas od 50% do 100% naładowania',
|
||||
PHRASE_SG_RECOVER: 'Odnowienie (do 50%) po upadku',
|
||||
PHRASE_UNLADEN: 'Masa statku z wyłączeniem paliwa i ładunku',
|
||||
PHRASE_UPDATE_RDY: 'Dostępna aktualizacja! Naciśnij by odświeżyć',
|
||||
|
||||
// Other languages fallback to these values
|
||||
// Only Translate to other languages if the name is different in-game
|
||||
am: 'Auto Field-Maintenance Unit',
|
||||
bh: 'Bulkheads',
|
||||
bl: 'Beam Laser',
|
||||
bsg: 'Bi-Weave Shield Generator',
|
||||
c: 'Cannon',
|
||||
cc: 'Collector Limpet Controller',
|
||||
cm: 'Countermeasure',
|
||||
cr: 'Cargo Rack',
|
||||
cs: 'Cargo Scanner',
|
||||
dc: 'Docking Computer',
|
||||
fc: 'Fragment Cannon',
|
||||
fi: 'FSD Interdictor',
|
||||
fs: 'Fuel Scoop',
|
||||
fsd: 'Frame Shift Drive',
|
||||
ft: 'Fuel Tank',
|
||||
fx: 'Fuel Transfer Limpet Controller',
|
||||
hb: 'Hatch Breaker Limpet Controller',
|
||||
hr: 'Hull Reinforcement Package',
|
||||
kw: 'Kill Warrant Scanner',
|
||||
ls: 'Life Support',
|
||||
mc: 'Multi-cannon',
|
||||
ml: 'Mining Laser',
|
||||
mr: 'Missile Rack',
|
||||
nl: 'Mine Launcher',
|
||||
pa: 'Plasma Accelerator',
|
||||
pas: 'Planetary Approach Suite',
|
||||
pc: 'Prospector Limpet Controller',
|
||||
pd: 'power distributor',
|
||||
pl: 'Pulse Laser',
|
||||
pp: 'Power Plant',
|
||||
psg: 'Prismatic Shield Generator',
|
||||
pv: 'Planetary Vehicle Hangar',
|
||||
rf: 'Refinery',
|
||||
rg: 'Rail Gun',
|
||||
s: 'Sensors',
|
||||
sb: 'Shield Booster',
|
||||
sc: 'Scanner',
|
||||
scb: 'Shield Cell Bank',
|
||||
sg: 'Shield Generator',
|
||||
t: 'thrusters',
|
||||
tp: 'Torpedo Pylon',
|
||||
ul: 'Burst Laser',
|
||||
ws: 'Frame Shift Wake Scanner'
|
||||
};
|
||||
@@ -345,7 +345,7 @@ export default class ComparisonPage extends Page {
|
||||
|
||||
let code = fromComparison(name, builds, selectedFacets, predicate, desc);
|
||||
let loc = window.location;
|
||||
return `${loc.protocol}//${loc.host}/comparison/${code}`;
|
||||
return loc.protocol + '//' + loc.host + '/comparison?code=' + encodeURIComponent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ export default class ErrorDetails extends React.Component {
|
||||
if (ed) {
|
||||
content = <div style={{ textAlign:'left', fontSize:'0.8em', width: '43em', margin: '0 auto' }}>
|
||||
<div className='cen'>
|
||||
<a href='https://github.com/cmmcleod/coriolis/issues' target='_blank' title='Coriolis Github Project'>Create an issue on Github</a>
|
||||
<a href='https://github.com/edcd/coriolis/issues' target='_blank' title='Coriolis Github Project'>Create an issue on Github</a>
|
||||
{' if this keeps happening. Add these details:'}
|
||||
</div>
|
||||
<div style={{ marginTop: '2em' }}>
|
||||
|
||||
@@ -8,13 +8,14 @@ import Persist from '../stores/Persist';
|
||||
import Ship from '../shipyard/Ship';
|
||||
import { toDetailedBuild } from '../shipyard/Serializer';
|
||||
import { outfitURL } from '../utils/UrlGenerators';
|
||||
|
||||
import { FloppyDisk, Bin, Switch, Download, Reload, Fuel } from '../components/SvgIcons';
|
||||
import ShipSummaryTable from '../components/ShipSummaryTable';
|
||||
import StandardSlotSection from '../components/StandardSlotSection';
|
||||
import HardpointsSlotSection from '../components/HardpointsSlotSection';
|
||||
import InternalSlotSection from '../components/InternalSlotSection';
|
||||
import UtilitySlotSection from '../components/UtilitySlotSection';
|
||||
import OffenceSummary from '../components/OffenceSummary';
|
||||
import DefenceSummary from '../components/DefenceSummary';
|
||||
import LineChart from '../components/LineChart';
|
||||
import PowerManagement from '../components/PowerManagement';
|
||||
import CostSection from '../components/CostSection';
|
||||
@@ -288,12 +289,14 @@ export default class OutfittingPage extends Page {
|
||||
sStr = ship.getStandardString() + '.' + ship.getModificationsString(),
|
||||
iStr = ship.getInternalString() + '.' + ship.getModificationsString();
|
||||
|
||||
Router.replace(outfitURL(ship.id, code, buildName));
|
||||
|
||||
return (
|
||||
<div id='outfit' className={'page'} style={{ fontSize: (sizeRatio * 0.9) + 'em' }}>
|
||||
<div id='overview'>
|
||||
<h1>{ship.name}</h1>
|
||||
<div id='build'>
|
||||
<input value={newBuildName} onChange={this._buildNameChange} placeholder={translate('Enter Name')} maxLength={50} />
|
||||
<input value={newBuildName || ''} onChange={this._buildNameChange} placeholder={translate('Enter Name')} maxLength={50} />
|
||||
<button onClick={canSave && this._saveBuild} disabled={!canSave} onMouseOver={termtip.bind(null, 'save')} onMouseOut={hide}>
|
||||
<FloppyDisk className='lg' />
|
||||
</button>
|
||||
@@ -324,31 +327,11 @@ export default class OutfittingPage extends Page {
|
||||
<CostSection ship={ship} buildName={buildName} code={sStr + hStr + iStr} />
|
||||
|
||||
<div ref='chartThird' className='group third'>
|
||||
<h1>{translate('jump range')}</h1>
|
||||
<LineChart
|
||||
width={chartWidth}
|
||||
xMax={ship.cargoCapacity}
|
||||
yMax={ship.unladenRange}
|
||||
xUnit={translate('T')}
|
||||
yUnit={translate('LY')}
|
||||
yLabel={translate('jump range')}
|
||||
xLabel={translate('cargo')}
|
||||
func={state.jumpRangeChartFunc}
|
||||
/>
|
||||
<OffenceSummary ship={ship} code={code}/>
|
||||
</div>
|
||||
|
||||
<div className='group third'>
|
||||
<h1>{translate('total range')}</h1>
|
||||
<LineChart
|
||||
width={chartWidth}
|
||||
xMax={ship.cargoCapacity}
|
||||
yMax={ship.unladenFastestRange}
|
||||
xUnit={translate('T')}
|
||||
yUnit={translate('LY')}
|
||||
yLabel={translate('fastest range')}
|
||||
xLabel={translate('cargo')}
|
||||
func={state.fastestRangeChartFunc}
|
||||
/>
|
||||
<DefenceSummary ship={ship} code={code}/>
|
||||
</div>
|
||||
|
||||
<div className='group third'>
|
||||
@@ -397,3 +380,16 @@ export default class OutfittingPage extends Page {
|
||||
);
|
||||
}
|
||||
}
|
||||
// <div ref='chartThird' className='group third'>
|
||||
// <h1>{translate('jump range')}</h1>
|
||||
// <LineChart
|
||||
// width={chartWidth}
|
||||
// xMax={ship.cargoCapacity}
|
||||
// yMax={ship.unladenRange}
|
||||
// xUnit={translate('T')}
|
||||
// yUnit={translate('LY')}
|
||||
// yLabel={translate('jump range')}
|
||||
// xLabel={translate('cargo')}
|
||||
// func={state.jumpRangeChartFunc}
|
||||
// />
|
||||
// </div>
|
||||
|
||||
@@ -55,6 +55,7 @@ function shipSummary(shipId, shipData) {
|
||||
ship.optimizeMass({ th: ship.standard[1].maxClass + 'A', fsd: '2D', ft: '1C' }); // Optmize mass with Max Thrusters
|
||||
summary.topSpeed = ship.topSpeed;
|
||||
summary.topBoost = ship.topBoost;
|
||||
summary.baseArmour = ship.armour;
|
||||
|
||||
return summary;
|
||||
}
|
||||
@@ -141,7 +142,7 @@ export default class ShipyardPage extends Page {
|
||||
<td>{s.agility}</td>
|
||||
<td className='ri'>{fInt(s.speed)}{u['m/s']}</td>
|
||||
<td className='ri'>{fInt(s.boost)}{u['m/s']}</td>
|
||||
<td className='ri'>{s.baseArmour}</td>
|
||||
<td className='ri'>{fInt(s.baseArmour)}</td>
|
||||
<td className='ri'>{fInt(s.baseShieldStrength)}{u.MJ}</td>
|
||||
<td className='ri'>{fInt(s.topSpeed)}{u['m/s']}</td>
|
||||
<td className='ri'>{fInt(s.topBoost)}{u['m/s']}</td>
|
||||
|
||||
@@ -51,15 +51,19 @@ export const ModuleGroupToName = {
|
||||
bl: 'Beam Laser',
|
||||
ul: 'Burst Laser',
|
||||
c: 'Cannon',
|
||||
ch: 'Chaff Launcher',
|
||||
cs: 'Cargo Scanner',
|
||||
cm: 'Countermeasure',
|
||||
ec: 'Electronic Countermeasure',
|
||||
fc: 'Fragment Cannon',
|
||||
hs: 'Heat Sink Launcher',
|
||||
ws: 'Frame Shift Wake Scanner',
|
||||
kw: 'Kill Warrant Scanner',
|
||||
nl: 'Mine Launcher',
|
||||
ml: 'Mining Laser',
|
||||
mr: 'Missile Rack',
|
||||
pa: 'Plasma Accelerator',
|
||||
po: 'Point Defence',
|
||||
mc: 'Multi-cannon',
|
||||
pl: 'Pulse Laser',
|
||||
rg: 'Rail Gun',
|
||||
@@ -121,7 +125,7 @@ export const ShipFacets = [
|
||||
},
|
||||
{ // 3
|
||||
title: 'shields',
|
||||
props: ['shieldStrength'],
|
||||
props: ['shield'],
|
||||
unit: 'MJ',
|
||||
fmt: 'int',
|
||||
i: 3
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class Module {
|
||||
* @param {Object} params Module parameters. Either grp/id or template
|
||||
*/
|
||||
constructor(params) {
|
||||
let properties = Object.assign({ grp: null, id: null, template: null }, params);
|
||||
let properties = Object.assign({ grp: null, id: null, template: null, }, params);
|
||||
|
||||
let template;
|
||||
if (properties.template == undefined) {
|
||||
@@ -23,48 +23,65 @@ export default class Module {
|
||||
for (let p in template) { this[p] = template[p]; }
|
||||
}
|
||||
}
|
||||
this.mods = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value for a given modification
|
||||
* @param {Number} name The name of the modification
|
||||
* @return {Number} The value of the modification, as a decimal value where 1 is 100%
|
||||
* @return {Number} The value of the modification, as an integer value scaled so that 1.23% == 123
|
||||
*/
|
||||
getModValue(name) {
|
||||
return this.mods && this.mods[name] ? this.mods[name] / 10000 : null;
|
||||
return this.mods && this.mods[name] ? this.mods[name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value for a given modification ID
|
||||
* @param {Number} name The name of the modification
|
||||
* @param {Number} value The value of the modification, as a decimal value where 1 is 100%
|
||||
* @param {Number} value The value of the modification, as an integer scaled so that -2.34% == -234
|
||||
*/
|
||||
setModValue(name, value) {
|
||||
if (!this.mods) {
|
||||
this.mods = {};
|
||||
}
|
||||
|
||||
if (value == null || value == 0) {
|
||||
delete this.mods[name];
|
||||
} else {
|
||||
// Store value with 2dp
|
||||
this.mods[name] = Math.round(value * 10000);
|
||||
// Round just to be sure
|
||||
this.mods[name] = Math.round(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to obtain a modified value using standard multipliers
|
||||
* @param {String} name the name of the modifier to obtain
|
||||
* @return {Number} the mass of this module
|
||||
* @param {String} name the name of the modifier to obtain
|
||||
* @param {Boolean} additive Optional true if the value is additive rather than multiplicative
|
||||
* @return {Number} the mass of this module
|
||||
*/
|
||||
_getModifiedValue(name) {
|
||||
let result = 0;
|
||||
if (this[name]) {
|
||||
result = this[name];
|
||||
if (result) {
|
||||
let mult = this.getModValue(name);
|
||||
if (mult) { result = result * (1 + mult); }
|
||||
_getModifiedValue(name, additive) {
|
||||
let result = this[name] || (additive ? 0 : null); // Additive NULL === 0
|
||||
if (result != null) {
|
||||
// Jitter is special, being the only non-percentage value (it is in fact degrees)
|
||||
const modValue = name === 'jitter' ? this.getModValue(name) / 100 : this.getModValue(name) / 10000;
|
||||
if (modValue) {
|
||||
if (additive) {
|
||||
result = result + modValue;
|
||||
} else {
|
||||
result = result * (1 + modValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is a shield generator
|
||||
* @return {Boolean} if this is a shield generator
|
||||
*/
|
||||
isShieldGenerator() {
|
||||
return (this.grp === 'sg' || this.grp === 'psg' || this.grp === 'bsg');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power generation of this module, taking in to account modifications
|
||||
* @return {Number} the power generation of this module
|
||||
@@ -190,7 +207,7 @@ export default class Module {
|
||||
* @return {Number} the kinetic resistance of this module
|
||||
*/
|
||||
getKineticResistance() {
|
||||
return this._getModifiedValue('kinres');
|
||||
return this._getModifiedValue('kinres', true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +215,7 @@ export default class Module {
|
||||
* @return {Number} the thermal resistance of this module
|
||||
*/
|
||||
getThermalResistance() {
|
||||
return this._getModifiedValue('thermres');
|
||||
return this._getModifiedValue('thermres', true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +223,7 @@ export default class Module {
|
||||
* @return {Number} the explosive resistance of this module
|
||||
*/
|
||||
getExplosiveResistance() {
|
||||
return this._getModifiedValue('explres');
|
||||
return this._getModifiedValue('explres', true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,7 +308,7 @@ export default class Module {
|
||||
if (this['minmass']) {
|
||||
result = this['minmass'];
|
||||
if (result) {
|
||||
let mult = this.getModValue('optmass');
|
||||
let mult = this.getModValue('optmass') / 10000;
|
||||
if (mult) { result = result * (1 + mult); }
|
||||
}
|
||||
}
|
||||
@@ -316,7 +333,7 @@ export default class Module {
|
||||
if (this['maxmass']) {
|
||||
result = this['maxmass'];
|
||||
if (result) {
|
||||
let mult = this.getModValue('optmass');
|
||||
let mult = this.getModValue('optmass') / 10000;
|
||||
if (mult) { result = result * (1 + mult); }
|
||||
}
|
||||
}
|
||||
@@ -333,7 +350,7 @@ export default class Module {
|
||||
if (this['minmul']) {
|
||||
result = this['minmul'];
|
||||
if (result) {
|
||||
let mult = this.getModValue('optmul');
|
||||
let mult = this.getModValue('optmul') / 10000;
|
||||
if (mult) { result = result * (1 + mult); }
|
||||
}
|
||||
}
|
||||
@@ -358,7 +375,7 @@ export default class Module {
|
||||
if (this['maxmul']) {
|
||||
result = this['maxmul'];
|
||||
if (result) {
|
||||
let mult = this.getModValue('optmul');
|
||||
let mult = this.getModValue('optmul') / 10000;
|
||||
if (mult) { result = result * (1 + mult); }
|
||||
}
|
||||
}
|
||||
@@ -484,4 +501,44 @@ export default class Module {
|
||||
return this._getModifiedValue('hullboost');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shield reinforcement for this module, taking in to account modifications
|
||||
* @return {Number} the shield reinforcement for this module
|
||||
*/
|
||||
getShieldReinforcement() {
|
||||
return this._getModifiedValue('shieldreinforcement');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bays for this module, taking in to account modifications
|
||||
* @return {Number} the bays for this module
|
||||
*/
|
||||
getBays() {
|
||||
return this._getModifiedValue('bays');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rebuilds per bay for this module, taking in to account modifications
|
||||
* @return {Number} the rebuilds per bay for this module
|
||||
*/
|
||||
getRebuildsPerBay() {
|
||||
return this._getModifiedValue('rebuildsperbay');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cells for this module, taking in to account modifications
|
||||
* @return {Number} the cells for this module
|
||||
*/
|
||||
getCells() {
|
||||
return this._getModifiedValue('cells');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the jitter for this module, taking in to account modifications
|
||||
* @return {Number} the jitter for this module
|
||||
*/
|
||||
getJitter() {
|
||||
return this._getModifiedValue('jitter', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,16 @@ export function findHardpoint(groupName, clss, rating, name, mount, missile) {
|
||||
*/
|
||||
export function findHardpointId(groupName, clss, rating, name, mount, missile) {
|
||||
let h = this.findHardpoint(groupName, clss, rating, name, mount, missile);
|
||||
if (h) {
|
||||
return h.id;
|
||||
}
|
||||
|
||||
// Countermeasures used to be lumped in a single group but have been broken, out. If we have been given a groupName of 'Countermeasure' then
|
||||
// rely on the unique name to find it
|
||||
if (groupName === 'cm' || groupName === 'Countermeasure') {
|
||||
h = this.findHardpoint(null, clss, rating, name, mount, missile);
|
||||
}
|
||||
|
||||
return h ? h.id : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ import { ModuleGroupToName, MountMap, BulkheadNames } from './Constants';
|
||||
import { Ships } from 'coriolis-data/dist';
|
||||
import Ship from './Ship';
|
||||
import * as ModuleUtils from './ModuleUtils';
|
||||
import * as Utils from '../utils/UtilityFunctions';
|
||||
import LZString from 'lz-string';
|
||||
import { outfitURL } from '../utils/UrlGenerators';
|
||||
|
||||
const STANDARD = ['powerPlant', 'thrusters', 'frameShiftDrive', 'lifeSupport', 'powerDistributor', 'sensors', 'fuelTank'];
|
||||
|
||||
@@ -83,7 +85,7 @@ export function toDetailedBuild(buildName, ship) {
|
||||
ship: ship.name,
|
||||
references: [{
|
||||
name: 'Coriolis.io',
|
||||
url: `https://coriolis.edcd.io/outfit/${ship.id}/${code}?bn=${encodeURIComponent(buildName)}`,
|
||||
url: 'https://coriolis.edcd.io' + outfitURL(ship.id, code, buildName),
|
||||
code,
|
||||
shipId: ship.id
|
||||
}],
|
||||
@@ -115,32 +117,12 @@ export function toDetailedBuild(buildName, ship) {
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a ship from a ship-loadout object, using the code
|
||||
* @param {Object} detailedBuild ship-loadout object
|
||||
* @return {Ship} Ship instance
|
||||
*/
|
||||
export function fromDetailedBuild(detailedBuild) {
|
||||
let shipId = Object.keys(Ships).find((shipId) => Ships[shipId].properties.name.toLowerCase() == detailedBuild.ship.toLowerCase());
|
||||
|
||||
if (!shipId) {
|
||||
throw 'No such ship: ' + detailedBuild.ship;
|
||||
}
|
||||
|
||||
let comps = detailedBuild.components;
|
||||
let stn = comps.standard;
|
||||
let shipData = Ships[shipId];
|
||||
let ship = new Ship(shipId, shipData.properties, shipData.slots);
|
||||
|
||||
return ship.buildFrom(detailedBuild.references[0].code);
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a ship from a ship-loadout object
|
||||
* @param {Object} detailedBuild ship-loadout object
|
||||
* @return {Ship} Ship instance
|
||||
*/
|
||||
export function oldfromDetailedBuild(detailedBuild) {
|
||||
export function fromDetailedBuild(detailedBuild) {
|
||||
let shipId = Object.keys(Ships).find((shipId) => Ships[shipId].properties.name.toLowerCase() == detailedBuild.ship.toLowerCase());
|
||||
|
||||
if (!shipId) {
|
||||
@@ -154,6 +136,7 @@ export function oldfromDetailedBuild(detailedBuild) {
|
||||
let shipData = Ships[shipId];
|
||||
let ship = new Ship(shipId, shipData.properties, shipData.slots);
|
||||
let bulkheads = ModuleUtils.bulkheadIndex(stn.bulkheads);
|
||||
let modifications = new Array(stn.bulkheads.modifications);
|
||||
|
||||
if (bulkheads < 0) {
|
||||
throw 'Invalid bulkheads: ' + stn.bulkheads;
|
||||
@@ -165,6 +148,7 @@ export function oldfromDetailedBuild(detailedBuild) {
|
||||
}
|
||||
priorities.push(stn[c].priority === undefined ? 0 : stn[c].priority - 1);
|
||||
enabled.push(stn[c].enabled === undefined ? true : stn[c].enabled);
|
||||
modifications.push(stn[c].modifications);
|
||||
return stn[c].class + stn[c].rating;
|
||||
});
|
||||
|
||||
@@ -185,8 +169,13 @@ export function oldfromDetailedBuild(detailedBuild) {
|
||||
comps.utility.map(c => (!c || c.enabled === undefined) ? true : c.enabled * 1),
|
||||
comps.internal.map(c => (!c || c.enabled === undefined) ? true : c.enabled * 1)
|
||||
);
|
||||
modifications = modifications.concat(
|
||||
comps.hardpoints.map(c => (c && c.m ? c.m.modifications : null)),
|
||||
comps.utility.map(c => (c && c.m ? c.m.modifications : null)),
|
||||
comps.internal.map(c => (c && c.m ? c.m.modifications : null))
|
||||
);
|
||||
|
||||
ship.buildWith({ bulkheads, standard, hardpoints, internal }, priorities, enabled);
|
||||
ship.buildWith({ bulkheads, standard, hardpoints, internal }, priorities, enabled, modifications);
|
||||
|
||||
return ship;
|
||||
};
|
||||
@@ -228,7 +217,7 @@ export function fromComparison(name, builds, facets, predicate, desc) {
|
||||
f: facets,
|
||||
p: predicate,
|
||||
d: desc ? 1 : 0
|
||||
})).replace(/\//g, '-');
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -237,5 +226,5 @@ export function fromComparison(name, builds, facets, predicate, desc) {
|
||||
* @return {Object} Comparison data object
|
||||
*/
|
||||
export function toComparison(code) {
|
||||
return JSON.parse(LZString.decompressFromBase64(code.replace(/-/g, '/')));
|
||||
return JSON.parse(LZString.decompressFromBase64(Utils.fromUrlSafe(code)));
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Calc from './Calculations';
|
||||
import * as ModuleUtils from './ModuleUtils';
|
||||
import * as Utils from '../utils/UtilityFunctions';
|
||||
import Module from './Module';
|
||||
import LZString from 'lz-string';
|
||||
import isEqual from 'lodash/lang';
|
||||
@@ -126,7 +127,6 @@ export default class Ship {
|
||||
*/
|
||||
canBoost() {
|
||||
return this.canThrust() && // Thrusters operational
|
||||
this.getSlotStatus(this.standard[4]) == 3 && // Power distributor operational
|
||||
this.boostEnergy <= this.standard[4].m.getEnginesCapacity(); // PD capacitor is sufficient for boost
|
||||
}
|
||||
|
||||
@@ -194,10 +194,12 @@ export default class Ship {
|
||||
*/
|
||||
calcShieldRecovery() {
|
||||
if (this.shield > 0) {
|
||||
let sgSlot = this.findInternalByGroup('sg');
|
||||
let brokenRegenRate = 1 + sgSlot.m.getModValue('brokenregen');
|
||||
// 50% of shield strength / recovery recharge rate + 15 second delay before recharge starts
|
||||
return ((this.shield / 2) / (sgSlot.m.recover * brokenRegenRate)) + 15;
|
||||
const sgSlot = this.findInternalByGroup('sg');
|
||||
if (sgSlot != null) {
|
||||
let brokenRegenRate = 1 + sgSlot.m.getModValue('brokenregen') / 10000;
|
||||
// 50% of shield strength / recovery recharge rate + 15 second delay before recharge starts
|
||||
return ((this.shield / 2) / (sgSlot.m.recover * brokenRegenRate)) + 15;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -210,10 +212,12 @@ export default class Ship {
|
||||
*/
|
||||
calcShieldRecharge() {
|
||||
if (this.shield > 0) {
|
||||
let sgSlot = this.findInternalByGroup('sg');
|
||||
let regenRate = 1 + sgSlot.m.getModValue('regen');
|
||||
// 50% -> 100% recharge time, Bi-Weave shields charge at 1.8 MJ/s
|
||||
return (this.shield / 2) / ((sgSlot.m.grp == 'bsg' ? 1.8 : 1) * regenRate);
|
||||
const sgSlot = this.findInternalByGroup('sg');
|
||||
if (sgSlot != null) {
|
||||
let regenRate = 1 + sgSlot.m.getModValue('regen') / 10000;
|
||||
// 50% -> 100% recharge time, Bi-Weave shields charge at 1.8 MJ/s
|
||||
return (this.shield / 2) / ((sgSlot.m.grp == 'bsg' ? 1.8 : 1) * regenRate);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -233,9 +237,8 @@ export default class Ship {
|
||||
sg = sgSlot.m;
|
||||
}
|
||||
|
||||
// TODO obtain shield boost
|
||||
// return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, this.shieldMultiplier + (multiplierDelta || 0));
|
||||
return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 0 + (multiplierDelta || 0));
|
||||
// TODO Not accurate if the ship has modified shield boosters
|
||||
return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 1 + (multiplierDelta || 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,19 +400,24 @@ export default class Ship {
|
||||
* Set a modification value
|
||||
* @param {Object} m The module to change
|
||||
* @param {Object} name The name of the modification to change
|
||||
* @param {Number} value The new value of the modification
|
||||
* @param {Number} value The new value of the modification. The value of the modification is scaled to provide two decimal places of precision in an integer. For example 1.23% is stored as 123
|
||||
*/
|
||||
setModification(m, name, value) {
|
||||
if (isNaN(value)) {
|
||||
// Value passed is invalid; reset it to 0
|
||||
value = 0;
|
||||
}
|
||||
|
||||
// Handle special cases
|
||||
if (name == 'pgen') {
|
||||
if (name === 'pgen') {
|
||||
// Power generation
|
||||
m.setModValue(name, value);
|
||||
this.updatePowerGenerated();
|
||||
} else if (name == 'power') {
|
||||
} else if (name === 'power') {
|
||||
// Power usage
|
||||
m.setModValue(name, value);
|
||||
this.updatePowerUsed();
|
||||
} else if (name == 'mass') {
|
||||
} else if (name === 'mass') {
|
||||
// Mass
|
||||
let oldMass = m.getMass();
|
||||
m.setModValue(name, value);
|
||||
@@ -418,25 +426,40 @@ export default class Ship {
|
||||
this.ladenMass = this.ladenMass - oldMass + newMass;
|
||||
this.updateTopSpeed();
|
||||
this.updateJumpStats();
|
||||
} else if (name == 'maxfuel') {
|
||||
} else if (name === 'maxfuel') {
|
||||
m.setModValue(name, value);
|
||||
this.updateJumpStats();
|
||||
} else if (name == 'optmass') {
|
||||
} else if (name === 'optmass') {
|
||||
m.setModValue(name, value);
|
||||
// Could be for either thrusters or FSD
|
||||
// Could be for any of thrusters, FSD or shield
|
||||
this.updateTopSpeed();
|
||||
this.updateJumpStats();
|
||||
} else if (name == 'optmul') {
|
||||
this.recalculateShield();
|
||||
} else if (name === 'optmul') {
|
||||
m.setModValue(name, value);
|
||||
// Could be for either thrusters or FSD
|
||||
// Could be for any of thrusters, FSD or shield
|
||||
this.updateTopSpeed();
|
||||
this.updateJumpStats();
|
||||
} else if (name == 'shieldboost') {
|
||||
this.recalculateShield();
|
||||
} else if (name === 'shieldboost') {
|
||||
m.setModValue(name, value);
|
||||
this.updateShield();
|
||||
} else if (name == 'hullboost') {
|
||||
this.recalculateShield();
|
||||
} else if (name === 'hullboost' || name === 'hullreinforcement') {
|
||||
m.setModValue(name, value);
|
||||
this.updateArmour();
|
||||
this.recalculateArmour();
|
||||
} else if (name === 'shieldreinforcement') {
|
||||
m.setModValue(name, value);
|
||||
this.recalculateShieldCells();
|
||||
} else if (name === 'burst' || name === 'clip' || name === 'damage' || name === 'distdraw' || name === 'jitter' || name === 'piercing' || name === 'range' || name === 'reload' || name === 'rof' || name === 'thermload') {
|
||||
m.setModValue(name, value);
|
||||
this.recalculateDps();
|
||||
this.recalculateHps();
|
||||
this.recalculateEps();
|
||||
} else if (name === 'explres' || name === 'kinres' || name === 'thermres') {
|
||||
m.setModValue(name, value);
|
||||
// Could be for shields or armour
|
||||
this.recalculateArmour();
|
||||
this.recalculateShield();
|
||||
} else {
|
||||
// Generic
|
||||
m.setModValue(name, value);
|
||||
@@ -464,9 +487,21 @@ export default class Ship {
|
||||
this.ladenMass = 0;
|
||||
this.armour = this.baseArmour;
|
||||
this.shield = this.baseShieldStrength;
|
||||
this.shieldCells = 0;
|
||||
this.totalCost = this.m.incCost ? this.m.discountedCost : 0;
|
||||
this.unladenMass = this.hullMass;
|
||||
this.totalDpe = 0;
|
||||
this.totalExplDpe = 0;
|
||||
this.totalKinDpe = 0;
|
||||
this.totalThermDpe = 0;
|
||||
this.totalDps = 0;
|
||||
this.totalExplDps = 0;
|
||||
this.totalKinDps = 0;
|
||||
this.totalThermDps = 0;
|
||||
this.totalSDps = 0;
|
||||
this.totalExplSDps = 0;
|
||||
this.totalKinSDps = 0;
|
||||
this.totalThermSDps = 0;
|
||||
this.totalEps = 0;
|
||||
this.totalHps = 0;
|
||||
this.shieldExplRes = 0;
|
||||
@@ -481,7 +516,6 @@ export default class Ship {
|
||||
this.bulkheads.m.mods = mods && mods[0] ? mods[0] : {};
|
||||
this.cargoHatch.priority = priorities ? priorities[0] * 1 : 0;
|
||||
this.cargoHatch.enabled = enabled ? enabled[0] * 1 : true;
|
||||
this.cargoHatch.mods = mods ? mods[0] : {};
|
||||
|
||||
for (i = 0; i < cl; i++) {
|
||||
standard[i].cat = 0;
|
||||
@@ -538,8 +572,12 @@ export default class Ship {
|
||||
this.updatePowerGenerated()
|
||||
.updatePowerUsed()
|
||||
.updateJumpStats()
|
||||
.updateShield()
|
||||
.updateArmour()
|
||||
.recalculateShield()
|
||||
.recalculateShieldCells()
|
||||
.recalculateArmour()
|
||||
.recalculateDps()
|
||||
.recalculateEps()
|
||||
.recalculateHps()
|
||||
.updateTopSpeed();
|
||||
}
|
||||
|
||||
@@ -557,27 +595,27 @@ export default class Ship {
|
||||
let standard = new Array(this.standard.length),
|
||||
hardpoints = new Array(this.hardpoints.length),
|
||||
internal = new Array(this.internal.length),
|
||||
mods = new Array(1 + this.standard.length + this.hardpoints.length + this.internal.length),
|
||||
modifications = new Array(1 + this.standard.length + this.hardpoints.length + this.internal.length),
|
||||
parts = serializedString.split('.'),
|
||||
priorities = null,
|
||||
enabled = null,
|
||||
code = parts[0];
|
||||
|
||||
if (parts[1]) {
|
||||
enabled = LZString.decompressFromBase64(parts[1].replace(/-/g, '/')).split('');
|
||||
enabled = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[1])).split('');
|
||||
}
|
||||
|
||||
if (parts[2]) {
|
||||
priorities = LZString.decompressFromBase64(parts[2].replace(/-/g, '/')).split('');
|
||||
priorities = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[2])).split('');
|
||||
}
|
||||
|
||||
if (parts[3]) {
|
||||
const modstr = parts[3].replace(/-/g, '/');
|
||||
const modstr = parts[3];
|
||||
if (modstr.match(':')) {
|
||||
this.decodeModificationsString(modstr, mods);
|
||||
this.decodeModificationsString(modstr, modifications);
|
||||
} else {
|
||||
try {
|
||||
this.decodeModificationsStruct(zlib.gunzipSync(new Buffer(modstr, 'base64')), mods);
|
||||
this.decodeModificationsStruct(zlib.gunzipSync(new Buffer(Utils.fromUrlSafe(modstr), 'base64')), modifications);
|
||||
} catch (err) {
|
||||
// Could be out-of-date URL; ignore
|
||||
}
|
||||
@@ -595,7 +633,7 @@ export default class Ship {
|
||||
},
|
||||
priorities,
|
||||
enabled,
|
||||
mods
|
||||
modifications
|
||||
);
|
||||
};
|
||||
|
||||
@@ -681,21 +719,27 @@ export default class Ship {
|
||||
if (slot.enabled != enabled) { // Enabled state is changing
|
||||
slot.enabled = enabled;
|
||||
if (slot.m) {
|
||||
if (ModuleUtils.isShieldGenerator(slot.m.grp) || slot.m.grp == 'sb') {
|
||||
this.updateShield();
|
||||
if (ModuleUtils.isShieldGenerator(slot.m.grp) || slot.m.grp === 'sb') {
|
||||
this.recalculateShield();
|
||||
}
|
||||
if (slot.m.getDps()) {
|
||||
this.totalDps += slot.m.getDps() * (enabled ? 1 : -1);
|
||||
}
|
||||
if (slot.m.getEps()) {
|
||||
this.totalEps += slot.m.getEps() * (enabled ? 1 : -1);
|
||||
}
|
||||
if (slot.m.getHps()) {
|
||||
this.totalHps += slot.m.getHps() * (enabled ? 1 : -1);
|
||||
if (slot.m.grp === 'scb') {
|
||||
this.recalculateShieldCells();
|
||||
}
|
||||
|
||||
this.updatePowerUsed();
|
||||
this.updatePowerEnabledString();
|
||||
|
||||
if (slot.m.getDps()) {
|
||||
this.recalculateDps();
|
||||
}
|
||||
|
||||
if (slot.m.getHps()) {
|
||||
this.recalculateHps();
|
||||
}
|
||||
|
||||
if (slot.m.getEps()) {
|
||||
this.recalculateEps();
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -732,10 +776,15 @@ export default class Ship {
|
||||
updateStats(slot, n, old, preventUpdate) {
|
||||
let powerGeneratedChange = slot == this.standard[0];
|
||||
let powerUsedChange = false;
|
||||
let dpsChanged = n && n.getDps() || old && old.getDps();
|
||||
let epsChanged = n && n.getEps() || old && old.getEps();
|
||||
let hpsChanged = n && n.getHps() || old && old.getHps();
|
||||
|
||||
let armourChange = (slot == this.bulkheads) || (n && n.grp == 'hr') || (old && old.grp == 'hr');
|
||||
let armourChange = (slot === this.bulkheads) || (n && n.grp === 'hr') || (old && old.grp === 'hr');
|
||||
|
||||
let shieldChange = (n && n.grp == 'bsg') || (old && old.grp == 'bsg') || (n && n.grp == 'psg') || (old && old.grp == 'psg') || (n && n.grp == 'sg') || (old && old.grp == 'sg') || (n && n.grp == 'sb') || (old && old.grp == 'sb');
|
||||
let shieldChange = (n && n.grp === 'bsg') || (old && old.grp === 'bsg') || (n && n.grp === 'psg') || (old && old.grp === 'psg') || (n && n.grp === 'sg') || (old && old.grp === 'sg') || (n && n.grp === 'sb') || (old && old.grp === 'sb');
|
||||
|
||||
let shieldCellsChange = (n && n.grp === 'scb') || (old && old.grp === 'scb');
|
||||
|
||||
if (old) { // Old modul now being removed
|
||||
switch (old.grp) {
|
||||
@@ -755,16 +804,6 @@ export default class Ship {
|
||||
powerUsedChange = true;
|
||||
}
|
||||
|
||||
if (old.getDps()) {
|
||||
this.totalDps -= old.getDps();
|
||||
}
|
||||
if (old.getEps()) {
|
||||
this.totalEps -= old.getEps();
|
||||
}
|
||||
if (old.getHps()) {
|
||||
this.totalHps -= old.getHps();
|
||||
}
|
||||
|
||||
this.unladenMass -= old.getMass() || 0;
|
||||
}
|
||||
|
||||
@@ -786,22 +825,21 @@ export default class Ship {
|
||||
powerUsedChange = true;
|
||||
}
|
||||
|
||||
if (n.getDps()) {
|
||||
this.totalDps += n.getDps();
|
||||
}
|
||||
if (n.getEps()) {
|
||||
this.totalEps += n.getEps();
|
||||
}
|
||||
if (n.getHps()) {
|
||||
this.totalHps += n.getHps();
|
||||
}
|
||||
|
||||
this.unladenMass += n.getMass() || 0;
|
||||
}
|
||||
|
||||
this.ladenMass = this.unladenMass + this.cargoCapacity + this.fuelCapacity;
|
||||
|
||||
if (!preventUpdate) {
|
||||
if (dpsChanged) {
|
||||
this.recalculateDps();
|
||||
}
|
||||
if (epsChanged) {
|
||||
this.recalculateEps();
|
||||
}
|
||||
if (hpsChanged) {
|
||||
this.recalculateHps();
|
||||
}
|
||||
if (powerGeneratedChange) {
|
||||
this.updatePowerGenerated();
|
||||
}
|
||||
@@ -809,10 +847,13 @@ export default class Ship {
|
||||
this.updatePowerUsed();
|
||||
}
|
||||
if (armourChange) {
|
||||
this.updateArmour();
|
||||
this.recalculateArmour();
|
||||
}
|
||||
if (shieldChange) {
|
||||
this.updateShield();
|
||||
this.recalculateShield();
|
||||
}
|
||||
if (shieldCellsChange) {
|
||||
this.recalculateShieldCells();
|
||||
}
|
||||
this.updateTopSpeed();
|
||||
this.updateJumpStats();
|
||||
@@ -820,6 +861,148 @@ export default class Ship {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate diminishing returns value, where values below a given limit are returned
|
||||
* as-is, and values between the lower and upper limit of the diminishing returns are
|
||||
* given at half value.
|
||||
* Commonly used for resistances.
|
||||
* @param {Number} val The value
|
||||
* @param {Number} drll The lower limit for diminishing returns
|
||||
* @param {Number} drul The upper limit for diminishing returns
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
diminishingReturns(val, drll, drul) {
|
||||
if (val > drll) {
|
||||
val = drll + (val - drll) / 2;
|
||||
}
|
||||
if (val > drul) {
|
||||
val = drul;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate damage per second for weapons
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
recalculateDps() {
|
||||
let totalDpe = 0;
|
||||
let totalExplDpe = 0;
|
||||
let totalKinDpe = 0;
|
||||
let totalThermDpe = 0;
|
||||
let totalDps = 0;
|
||||
let totalExplDps = 0;
|
||||
let totalKinDps = 0;
|
||||
let totalThermDps = 0;
|
||||
let totalSDps = 0;
|
||||
let totalExplSDps = 0;
|
||||
let totalKinSDps = 0;
|
||||
let totalThermSDps = 0;
|
||||
|
||||
for (let slotNum in this.hardpoints) {
|
||||
const slot = this.hardpoints[slotNum];
|
||||
if (slot.m && slot.enabled && slot.m.getDps()) {
|
||||
const dpe = slot.m.getDps() / slot.m.getEps();
|
||||
const dps = slot.m.getDps();
|
||||
const sdps = slot.m.getClip() ? (slot.m.getClip() * slot.m.getDps() / slot.m.getRoF()) / ((slot.m.getClip() / slot.m.getRoF()) + slot.m.getReload()) : dps;
|
||||
|
||||
totalDpe += dpe;
|
||||
totalDps += dps;
|
||||
totalSDps += sdps;
|
||||
if (slot.m.type === 'E') {
|
||||
totalExplDpe += dpe;
|
||||
totalExplDps += dps;
|
||||
totalExplSDps += sdps;
|
||||
}
|
||||
if (slot.m.type === 'K') {
|
||||
totalKinDpe += dpe;
|
||||
totalKinDps += dps;
|
||||
totalKinSDps += sdps;
|
||||
}
|
||||
if (slot.m.type === 'T') {
|
||||
totalThermDpe += dpe;
|
||||
totalThermDps += dps;
|
||||
totalThermSDps += sdps;
|
||||
}
|
||||
if (slot.m.type === 'EK') {
|
||||
totalExplDpe += dpe / 2;
|
||||
totalKinDpe += dpe / 2;
|
||||
totalExplDps += dps / 2;
|
||||
totalKinDps += dps / 2;
|
||||
totalExplSDps += sdps / 2;
|
||||
totalKinSDps += sdps / 2;
|
||||
}
|
||||
if (slot.m.type === 'ET') {
|
||||
totalExplDpe += dpe / 2;
|
||||
totalThermDpe += dpe / 2;
|
||||
totalExplDps += dps / 2;
|
||||
totalThermDps += dps / 2;
|
||||
totalExplSDps += sdps / 2;
|
||||
totalThermSDps += sdps / 2;
|
||||
}
|
||||
if (slot.m.type === 'KT') {
|
||||
totalKinDpe += dpe / 2;
|
||||
totalThermDpe += dpe / 2;
|
||||
totalKinDps += dps / 2;
|
||||
totalThermDps += dps / 2;
|
||||
totalKinSDps += sdps / 2;
|
||||
totalThermSDps += sdps / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.totalDpe = totalDpe;
|
||||
this.totalExplDpe = totalExplDpe;
|
||||
this.totalKinDpe = totalKinDpe;
|
||||
this.totalThermDpe = totalThermDpe;
|
||||
this.totalDps = totalDps;
|
||||
this.totalExplDps = totalExplDps;
|
||||
this.totalKinDps = totalKinDps;
|
||||
this.totalThermDps = totalThermDps;
|
||||
this.totalSDps = totalSDps;
|
||||
this.totalExplSDps = totalExplSDps;
|
||||
this.totalKinSDps = totalKinSDps;
|
||||
this.totalThermSDps = totalThermSDps;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate heat per second for weapons
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
recalculateHps() {
|
||||
let totalHps = 0;
|
||||
|
||||
for (let slotNum in this.hardpoints) {
|
||||
const slot = this.hardpoints[slotNum];
|
||||
if (slot.m && slot.enabled && slot.m.getHps()) {
|
||||
totalHps += slot.m.getHps();
|
||||
}
|
||||
}
|
||||
this.totalHps = totalHps;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate energy per second for weapons
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
recalculateEps() {
|
||||
let totalEps = 0;
|
||||
|
||||
for (let slotNum in this.hardpoints) {
|
||||
const slot = this.hardpoints[slotNum];
|
||||
if (slot.m && slot.enabled && slot.m.getEps()) {
|
||||
totalEps += slot.m.getEps();
|
||||
}
|
||||
}
|
||||
this.totalEps = totalEps;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update power calculations when amount generated changes
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
@@ -898,44 +1081,88 @@ export default class Ship {
|
||||
* Update shield
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
updateShield() {
|
||||
// Base shield from generator
|
||||
let baseShield = 0;
|
||||
let sgSlot = this.findInternalByGroup('sg');
|
||||
recalculateShield() {
|
||||
let shield = 0;
|
||||
let shieldExplRes = null;
|
||||
let shieldKinRes = null;
|
||||
let shieldThermRes = null;
|
||||
|
||||
const sgSlot = this.findInternalByGroup('sg');
|
||||
if (sgSlot && sgSlot.enabled) {
|
||||
baseShield = Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sgSlot.m, 1);
|
||||
}
|
||||
// Shield from generator
|
||||
const baseShield = Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sgSlot.m, 1);
|
||||
shield = baseShield;
|
||||
shieldExplRes = 1 - sgSlot.m.getExplosiveResistance();
|
||||
shieldKinRes = 1 - sgSlot.m.getKineticResistance();
|
||||
shieldThermRes = 1 - sgSlot.m.getThermalResistance();
|
||||
|
||||
let shield = baseShield;
|
||||
|
||||
// Shield from boosters
|
||||
for (let slot of this.hardpoints) {
|
||||
if (slot.m && slot.m.grp == 'sb') {
|
||||
shield += baseShield * slot.m.getShieldBoost();
|
||||
// Shield from boosters
|
||||
for (let slot of this.hardpoints) {
|
||||
if (slot.m && slot.m.grp == 'sb') {
|
||||
shield += baseShield * slot.m.getShieldBoost();
|
||||
shieldExplRes *= (1 - slot.m.getExplosiveResistance());
|
||||
shieldKinRes *= (1 - slot.m.getKineticResistance());
|
||||
shieldThermRes *= (1 - slot.m.getThermalResistance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.shield = shield;
|
||||
this.shieldExplRes = shieldExplRes ? 1 - this.diminishingReturns(1 - shieldExplRes, 0.5, 0.75) : null;
|
||||
this.shieldKinRes = shieldKinRes ? 1 - this.diminishingReturns(1 - shieldKinRes, 0.5, 0.75) : null;
|
||||
this.shieldThermRes = shieldThermRes ? 1 - this.diminishingReturns(1 - shieldThermRes, 0.5, 0.75) : null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update armour
|
||||
* Update shield cells
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
updateArmour() {
|
||||
recalculateShieldCells() {
|
||||
let shieldCells = 0;
|
||||
|
||||
for (let slot of this.internal) {
|
||||
if (slot.m && slot.m.grp == 'scb') {
|
||||
shieldCells += slot.m.getShieldReinforcement() * slot.m.getCells();
|
||||
}
|
||||
}
|
||||
|
||||
this.shieldCells = shieldCells;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update armour and hull resistances
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
recalculateArmour() {
|
||||
// Armour from bulkheads
|
||||
let bulkhead = this.bulkheads.m;
|
||||
let armour = this.baseArmour + (this.baseArmour * bulkhead.getHullBoost());
|
||||
let hullExplRes = 1 - bulkhead.getExplosiveResistance();
|
||||
let hullKinRes = 1 - bulkhead.getKineticResistance();
|
||||
let hullThermRes = 1 - bulkhead.getThermalResistance();
|
||||
|
||||
// Armour from HRPs
|
||||
for (let slot of this.internal) {
|
||||
if (slot.m && slot.m.grp == 'hr') {
|
||||
armour += slot.m.getHullReinforcement();
|
||||
// Hull boost for HRPs is applied against the ship's base armour
|
||||
armour += this.baseArmour * slot.m.getModValue('hullboost');
|
||||
armour += this.baseArmour * slot.m.getModValue('hullboost') / 10000;
|
||||
|
||||
hullExplRes *= (1 - slot.m.getExplosiveResistance());
|
||||
hullKinRes *= (1 - slot.m.getKineticResistance());
|
||||
hullThermRes *= (1 - slot.m.getThermalResistance());
|
||||
}
|
||||
}
|
||||
|
||||
this.armour = armour;
|
||||
this.hullExplRes = 1 - this.diminishingReturns(1 - hullExplRes, 0.5, 0.75);
|
||||
this.hullKinRes = 1 - this.diminishingReturns(1 - hullKinRes, 0.5, 0.75);
|
||||
this.hullThermRes = 1 - this.diminishingReturns(1 - hullThermRes, 0.5, 0.75);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -972,7 +1199,7 @@ export default class Ship {
|
||||
priorities.push(slot.priority);
|
||||
}
|
||||
|
||||
this.serialized.priorities = LZString.compressToBase64(priorities.join('')).replace(/\//g, '-');
|
||||
this.serialized.priorities = LZString.compressToBase64(priorities.join(''));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -993,21 +1220,21 @@ export default class Ship {
|
||||
enabled.push(slot.enabled ? 1 : 0);
|
||||
}
|
||||
|
||||
this.serialized.enabled = LZString.compressToBase64(enabled.join('')).replace(/\//g, '-');
|
||||
this.serialized.enabled = LZString.compressToBase64(enabled.join(''));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the modifications string
|
||||
* Update the modifications string in a human-readable format
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
oldupdateModificationsString() {
|
||||
debugupdateModificationsString() {
|
||||
let allMods = new Array();
|
||||
|
||||
let bulkheadMods = new Array();
|
||||
if (this.bulkheads.m && this.bulkheads.m.mods) {
|
||||
for (let modKey in this.bulkheads.m.mods) {
|
||||
bulkheadMods.push(Modifications.modifiers.indexOf(modKey) + ':' + Math.round(this.bulkheads.m.getModValue(modKey) * 10000));
|
||||
bulkheadMods.push(Modifications.modifications.indexOf(modKey) + ':' + this.bulkheads.m.getModValue(modKey));
|
||||
}
|
||||
}
|
||||
allMods.push(bulkheadMods.join(';'));
|
||||
@@ -1016,7 +1243,7 @@ export default class Ship {
|
||||
let slotMods = new Array();
|
||||
if (slot.m && slot.m.mods) {
|
||||
for (let modKey in slot.m.mods) {
|
||||
slotMods.push(Modifications.modifiers.indexOf(modKey) + ':' + Math.round(slot.m.getModValue(modKey) * 10000));
|
||||
slotMods.push(Modifications.modifications.indexOf(modKey) + ':' + slot.m.getModValue(modKey));
|
||||
}
|
||||
}
|
||||
allMods.push(slotMods.join(';'));
|
||||
@@ -1025,7 +1252,7 @@ export default class Ship {
|
||||
let slotMods = new Array();
|
||||
if (slot.m && slot.m.mods) {
|
||||
for (let modKey in slot.m.mods) {
|
||||
slotMods.push(Modifications.modifiers.indexOf(modKey) + ':' + Math.round(slot.m.getModValue(modKey) * 10000));
|
||||
slotMods.push(Modifications.modifications.indexOf(modKey) + ':' + slot.m.getModValue(modKey));
|
||||
}
|
||||
}
|
||||
allMods.push(slotMods.join(';'));
|
||||
@@ -1034,12 +1261,12 @@ export default class Ship {
|
||||
let slotMods = new Array();
|
||||
if (slot.m && slot.m.mods) {
|
||||
for (let modKey in slot.m.mods) {
|
||||
slotMods.push(Modifications.modifiers.indexOf(modKey) + ':' + Math.round(slot.m.getModValue(modKey) * 10000));
|
||||
slotMods.push(Modifications.modifications.indexOf(modKey) + ':' + slot.m.getModValue(modKey));
|
||||
}
|
||||
}
|
||||
allMods.push(slotMods.join(';'));
|
||||
}
|
||||
this.serialized.modifications = LZString.compressToBase64(allMods.join(',').replace(/,+$/, '')).replace(/\//g, '-');
|
||||
this.serialized.modifications = LZString.compressToBase64(allMods.join(',').replace(/,+$/, ''));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1057,7 +1284,7 @@ export default class Ship {
|
||||
for (let j = 0; j < mods.length; j++) {
|
||||
let modElements = mods[j].split(':');
|
||||
if (modElements[0].match('[0-9]+')) {
|
||||
arr[i][Modifications.modifiers[modElements[0]]] = Number(modElements[1]);
|
||||
arr[i][Modifications.modifications[modElements[0]]] = Number(modElements[1]);
|
||||
} else {
|
||||
arr[i][modElements[0]] = Number(modElements[1]);
|
||||
}
|
||||
@@ -1071,7 +1298,7 @@ export default class Ship {
|
||||
* This is a binary structure. It starts with a byte that identifies a slot, with bulkheads being ID 0 and moving through
|
||||
* standard modules, hardpoints, and finally internal modules. It then contains one or more modifications, with each
|
||||
* modification being a one-byte modification ID and at two-byte modification value. Modification IDs are based on the array
|
||||
* in Modifications.modifiers. The list of modifications is terminated by a modification ID of -1. The structure then repeats
|
||||
* in Modifications.modifications. The list of modifications is terminated by a modification ID of -1. The structure then repeats
|
||||
* for the next module, and the next, and is terminated by a slot ID of -1.
|
||||
* @return {this} The ship instance (for chaining operations)
|
||||
*/
|
||||
@@ -1082,7 +1309,10 @@ export default class Ship {
|
||||
let bulkheadMods = new Array();
|
||||
if (this.bulkheads.m && this.bulkheads.m.mods) {
|
||||
for (let modKey in this.bulkheads.m.mods) {
|
||||
bulkheadMods.push({ id: Modifications.modifiers.indexOf(modKey), value: Math.round(this.bulkheads.m.getModValue(modKey) * 10000) });
|
||||
// Filter out invalid modifications
|
||||
if (Modifications.validity['bh'] && Modifications.validity['bh'].indexOf(modKey) != -1) {
|
||||
bulkheadMods.push({ id: Modifications.modifications.indexOf(modKey), value: this.bulkheads.m.getModValue(modKey) });
|
||||
}
|
||||
}
|
||||
}
|
||||
slots.push(bulkheadMods);
|
||||
@@ -1091,7 +1321,10 @@ export default class Ship {
|
||||
let slotMods = new Array();
|
||||
if (slot.m && slot.m.mods) {
|
||||
for (let modKey in slot.m.mods) {
|
||||
slotMods.push({ id: Modifications.modifiers.indexOf(modKey), value: Math.round(slot.m.getModValue(modKey) * 10000) });
|
||||
// Filter out invalid modifications
|
||||
if (Modifications.validity[slot.m.grp] && Modifications.validity[slot.m.grp].indexOf(modKey) != -1) {
|
||||
slotMods.push({ id: Modifications.modifications.indexOf(modKey), value: slot.m.getModValue(modKey) });
|
||||
}
|
||||
}
|
||||
}
|
||||
slots.push(slotMods);
|
||||
@@ -1101,7 +1334,10 @@ export default class Ship {
|
||||
let slotMods = new Array();
|
||||
if (slot.m && slot.m.mods) {
|
||||
for (let modKey in slot.m.mods) {
|
||||
slotMods.push({ id: Modifications.modifiers.indexOf(modKey), value: Math.round(slot.m.getModValue(modKey) * 10000) });
|
||||
// Filter out invalid modifications
|
||||
if (Modifications.validity[slot.m.grp] && Modifications.validity[slot.m.grp].indexOf(modKey) != -1) {
|
||||
slotMods.push({ id: Modifications.modifications.indexOf(modKey), value: slot.m.getModValue(modKey) });
|
||||
}
|
||||
}
|
||||
}
|
||||
slots.push(slotMods);
|
||||
@@ -1111,7 +1347,10 @@ export default class Ship {
|
||||
let slotMods = new Array();
|
||||
if (slot.m && slot.m.mods) {
|
||||
for (let modKey in slot.m.mods) {
|
||||
slotMods.push({ id: Modifications.modifiers.indexOf(modKey), value: Math.round(slot.m.getModValue(modKey) * 10000) });
|
||||
// Filter out invalid modifications
|
||||
if (Modifications.validity[slot.m.grp] && Modifications.validity[slot.m.grp].indexOf(modKey) != -1) {
|
||||
slotMods.push({ id: Modifications.modifications.indexOf(modKey), value: slot.m.getModValue(modKey) });
|
||||
}
|
||||
}
|
||||
}
|
||||
slots.push(slotMods);
|
||||
@@ -1137,6 +1376,7 @@ export default class Ship {
|
||||
for (let slotMod of slot) {
|
||||
buffer.writeInt8(slotMod.id, curpos++);
|
||||
buffer.writeInt32LE(slotMod.value, curpos);
|
||||
// console.log('ENCODE Slot ' + i + ': ' + Modifications.modifications[slotMod.id] + ' = ' + slotMod.value);
|
||||
curpos += 4;
|
||||
}
|
||||
buffer.writeInt8(-1, curpos++);
|
||||
@@ -1147,7 +1387,7 @@ export default class Ship {
|
||||
buffer.writeInt8(-1, curpos++);
|
||||
}
|
||||
|
||||
this.serialized.modifications = zlib.gzipSync(buffer).toString('base64').replace(/\//g, '-');
|
||||
this.serialized.modifications = zlib.gzipSync(buffer).toString('base64');
|
||||
} else {
|
||||
this.serialized.modifications = null;
|
||||
}
|
||||
@@ -1169,7 +1409,8 @@ export default class Ship {
|
||||
while (modificationId != -1) {
|
||||
let modificationValue = buffer.readInt32LE(curpos);
|
||||
curpos += 4;
|
||||
modifications[Modifications.modifiers[modificationId]] = modificationValue;
|
||||
// console.log('DECODE Slot ' + slot + ': ' + Modifications.modifications[modificationId] + ' = ' + modificationValue);
|
||||
modifications[Modifications.modifications[modificationId]] = modificationValue;
|
||||
modificationId = buffer.readInt8(curpos++);
|
||||
}
|
||||
arr[slot] = modifications;
|
||||
@@ -1219,7 +1460,6 @@ export default class Ship {
|
||||
case 1: this.serialized.hardpoints = null; break;
|
||||
case 2: this.serialized.internal = null;
|
||||
}
|
||||
this.serialized.modifications = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ const LS_KEY_MOD_DISCOUNT = 'moduleDiscount';
|
||||
const LS_KEY_STATE = 'state';
|
||||
const LS_KEY_SIZE_RATIO = 'sizeRatio';
|
||||
const LS_KEY_TOOLTIPS = 'tooltips';
|
||||
const LS_KEY_MODULE_RESISTANCES = 'moduleResistances';
|
||||
|
||||
let LS;
|
||||
|
||||
@@ -81,6 +82,7 @@ export class Persist extends EventEmitter {
|
||||
LS = null;
|
||||
}
|
||||
|
||||
let moduleResistances = _get(LS_KEY_MODULE_RESISTANCES);
|
||||
let tips = _get(LS_KEY_TOOLTIPS);
|
||||
let insurance = _getString(LS_KEY_INSURANCE);
|
||||
let shipDiscount = _get(LS_KEY_SHIP_DISCOUNT);
|
||||
@@ -99,6 +101,7 @@ export class Persist extends EventEmitter {
|
||||
this.state = _get(LS_KEY_STATE);
|
||||
this.sizeRatio = _get(LS_KEY_SIZE_RATIO) || 1;
|
||||
this.tooltipsEnabled = tips === null ? true : tips;
|
||||
this.moduleResistancesEnabled = moduleResistances === null ? true : moduleResistances;
|
||||
|
||||
if (LS) {
|
||||
window.addEventListener('storage', this.onStorageChange);
|
||||
@@ -143,6 +146,10 @@ export class Persist extends EventEmitter {
|
||||
this.tooltipsEnabled = !!newValue && newValue.toLowerCase() == 'true';
|
||||
this.emit('tooltips', this.tooltipsEnabled);
|
||||
break;
|
||||
case LS_KEY_MODULE_RESISTANCES:
|
||||
this.moduleResistancesEnabled = !!newValue && newValue.toLowerCase() == 'true';
|
||||
this.emit('moduleresistances', this.moduleResistancesEnabled);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
// On JSON.Parse Error - don't sync or do anything
|
||||
@@ -183,6 +190,21 @@ export class Persist extends EventEmitter {
|
||||
return this.tooltipsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show module resistances setting
|
||||
* @param {boolean} show Optional - update setting
|
||||
* @return {boolean} True if module resistances should be shown
|
||||
*/
|
||||
showModuleResistances(show) {
|
||||
if (show !== undefined) {
|
||||
this.moduleResistancesEnabled = !!show;
|
||||
_put(LS_KEY_MODULE_RESISTANCES, this.moduleResistancesEnabled);
|
||||
this.emit('moduleresistances', this.moduleResistancesEnabled);
|
||||
}
|
||||
|
||||
return this.moduleResistancesEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a ship build in local storage.
|
||||
*
|
||||
|
||||
367
src/app/utils/CompanionApiUtils.js
Normal file
367
src/app/utils/CompanionApiUtils.js
Normal file
@@ -0,0 +1,367 @@
|
||||
import React from 'react';
|
||||
import { Modifications, Modules, Ships } from 'coriolis-data/dist';
|
||||
import Module from '../shipyard/Module';
|
||||
import Ship from '../shipyard/Ship';
|
||||
|
||||
// mapping from fd's ship model names to coriolis'
|
||||
const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
|
||||
'Adder': 'adder',
|
||||
'Anaconda': 'anaconda',
|
||||
'Asp': 'asp',
|
||||
'Asp_Scout': 'asp_scout',
|
||||
'BelugaLiner': 'beluga',
|
||||
'CobraMkIII': 'cobra_mk_iii',
|
||||
'CobraMkIV': 'cobra_mk_iv',
|
||||
'Cutter': 'imperial_cutter',
|
||||
'DiamondBack': 'diamondback_explorer',
|
||||
'DiamondBackXL': 'diamondback',
|
||||
'Eagle': 'eagle',
|
||||
'Empire_Courier': 'imperial_courier',
|
||||
'Empire_Eagle': 'imperial_eagle',
|
||||
'Empire_Trader': 'imperial_clipper',
|
||||
'Federation_Corvette': 'federal_corvette',
|
||||
'Federation_Dropship': 'federal_dropship',
|
||||
'Federation_Dropship_MkII': 'federal_assault_ship',
|
||||
'Federation_Gunship': 'federal_gunship',
|
||||
'FerDeLance': 'fer_de_lance',
|
||||
'Hauler': 'hauler',
|
||||
'Independant_Trader': 'keelback',
|
||||
'Orca': 'orca',
|
||||
'Python': 'python',
|
||||
'SideWinder': 'sidewinder',
|
||||
'Type6': 'type_6_transporter',
|
||||
'Type7': 'type_7_transport',
|
||||
'Type9': 'type_9_heavy',
|
||||
'Viper': 'viper',
|
||||
'Viper_MKIV': 'viper_mk_iv',
|
||||
'Vulture': 'vulture'
|
||||
};
|
||||
|
||||
// Mapping from hardpoint class to name in companion API
|
||||
const HARDPOINT_NUM_TO_CLASS = {
|
||||
0: 'Tiny',
|
||||
1: 'Small',
|
||||
2: 'Medium',
|
||||
3: 'Large',
|
||||
4: 'Huge'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Obtain a module given its ED ID
|
||||
* @param {Integer} edId the Elite ID of the module
|
||||
* @return {Module} the module
|
||||
*/
|
||||
function _moduleFromEdId(edId) {
|
||||
if (!edId) return null;
|
||||
|
||||
// Check standard modules
|
||||
for (const grp in Modules.standard) {
|
||||
if (Modules.standard.hasOwnProperty(grp)) {
|
||||
for (const i in Modules.standard[grp]) {
|
||||
if (Modules.standard[grp][i].edID === edId) {
|
||||
// Found it
|
||||
return new Module({ template: Modules.standard[grp][i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check hardpoint modules
|
||||
for (const grp in Modules.hardpoints) {
|
||||
if (Modules.hardpoints.hasOwnProperty(grp)) {
|
||||
for (const i in Modules.hardpoints[grp]) {
|
||||
if (Modules.hardpoints[grp][i].edID === edId) {
|
||||
// Found it
|
||||
return new Module({ template: Modules.hardpoints[grp][i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check internal modules
|
||||
for (const grp in Modules.internal) {
|
||||
if (Modules.internal.hasOwnProperty(grp)) {
|
||||
for (const i in Modules.internal[grp]) {
|
||||
if (Modules.internal[grp][i].edID === edId) {
|
||||
// Found it
|
||||
return new Module({ template: Modules.internal[grp][i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not found
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the model of a ship given its ED name
|
||||
* @param {string} edName the Elite name of the ship
|
||||
* @return {string} the Coriolis model of the ship
|
||||
*/
|
||||
function _shipModelFromEDName(edName) {
|
||||
return SHIP_FD_NAME_TO_CORIOLIS_NAME[edName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a ship's model from the companion API JSON
|
||||
* @param {object} json the companion API JSON
|
||||
* @return {string} the Coriolis model of the ship
|
||||
*/
|
||||
export function shipModelFromJson(json) {
|
||||
return _shipModelFromEDName(json.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a ship from the companion API JSON
|
||||
* @param {object} json the companion API JSON
|
||||
* @return {Ship} the built ship
|
||||
*/
|
||||
export function shipFromJson(json) {
|
||||
// Start off building a basic ship
|
||||
const shipModel = shipModelFromJson(json);
|
||||
if (!shipModel) {
|
||||
throw 'No such ship found: "' + json.name + '"';
|
||||
}
|
||||
const shipTemplate = Ships[shipModel];
|
||||
|
||||
let ship = new Ship(shipModel, shipTemplate.properties, shipTemplate.slots);
|
||||
ship.buildWith(null);
|
||||
|
||||
// Set the cargo hatch. We don't have any information on it so guess it's priority 5 and disabled
|
||||
ship.cargoHatch.enabled = false;
|
||||
ship.cargoHatch.priority = 4;
|
||||
|
||||
// Add the bulkheads
|
||||
const armourJson = json.modules.Armour.module;
|
||||
if (armourJson.name.endsWith('_Armour_Grade1')) {
|
||||
ship.useBulkhead(0, true);
|
||||
} else if (armourJson.name.endsWith('_Armour_Grade2')) {
|
||||
ship.useBulkhead(1, true);
|
||||
} else if (armourJson.name.endsWith('_Armour_Grade3')) {
|
||||
ship.useBulkhead(2, true);
|
||||
} else if (armourJson.name.endsWith('_Armour_Mirrored')) {
|
||||
ship.useBulkhead(3, true);
|
||||
} else if (armourJson.name.endsWith('_Armour_Reactive')) {
|
||||
ship.useBulkhead(4, true);
|
||||
} else {
|
||||
throw 'Unknown bulkheads "' + armourJson.name + '"';
|
||||
}
|
||||
ship.bulkheads.enabled = true;
|
||||
if (armourJson.modifiers) _addModifications(ship.bulkheads.m, armourJson.modifiers);
|
||||
|
||||
// Add the standard modules
|
||||
// Power plant
|
||||
const powerplantJson = json.modules.PowerPlant.module;
|
||||
const powerplant = _moduleFromEdId(powerplantJson.id);
|
||||
if (powerplantJson.modifiers) _addModifications(powerplant, powerplantJson.modifiers);
|
||||
ship.use(ship.standard[0], powerplant, true);
|
||||
ship.standard[0].enabled = powerplantJson.on === true;
|
||||
ship.standard[0].priority = powerplantJson.priority;
|
||||
|
||||
// Thrusters
|
||||
const thrustersJson = json.modules.MainEngines.module;
|
||||
const thrusters = _moduleFromEdId(thrustersJson.id);
|
||||
if (thrustersJson.modifiers) _addModifications(thrusters, thrustersJson.modifiers);
|
||||
ship.use(ship.standard[1], thrusters, true);
|
||||
ship.standard[1].enabled = thrustersJson.on === true;
|
||||
ship.standard[1].priority = thrustersJson.priority;
|
||||
|
||||
// FSD
|
||||
const frameshiftdriveJson = json.modules.FrameShiftDrive.module;
|
||||
const frameshiftdrive = _moduleFromEdId(frameshiftdriveJson.id);
|
||||
if (frameshiftdriveJson.modifiers) _addModifications(frameshiftdrive, frameshiftdriveJson.modifiers);
|
||||
ship.use(ship.standard[2], frameshiftdrive, true);
|
||||
ship.standard[2].enabled = frameshiftdriveJson.on === true;
|
||||
ship.standard[2].priority = frameshiftdriveJson.priority;
|
||||
|
||||
// Life support
|
||||
const lifesupportJson = json.modules.LifeSupport.module;
|
||||
const lifesupport = _moduleFromEdId(lifesupportJson.id);
|
||||
if (lifesupportJson.modifiers)_addModifications(lifesupport, lifesupportJson.modifiers);
|
||||
ship.use(ship.standard[3], lifesupport, true);
|
||||
ship.standard[3].enabled = lifesupportJson.on === true;
|
||||
ship.standard[3].priority = lifesupportJson.priority;
|
||||
|
||||
// Power distributor
|
||||
const powerdistributorJson = json.modules.PowerDistributor.module;
|
||||
const powerdistributor = _moduleFromEdId(powerdistributorJson.id);
|
||||
if (powerdistributorJson.modifiers) _addModifications(powerdistributor, powerdistributorJson.modifiers);
|
||||
ship.use(ship.standard[4], powerdistributor, true);
|
||||
ship.standard[4].enabled = powerdistributorJson.on === true;
|
||||
ship.standard[4].priority = powerdistributorJson.priority;
|
||||
|
||||
// Sensors
|
||||
const sensorsJson = json.modules.Radar.module;
|
||||
const sensors = _moduleFromEdId(sensorsJson.id);
|
||||
if (sensorsJson.modifiers) _addModifications(sensors, sensorsJson.modifiers);
|
||||
ship.use(ship.standard[5], sensors, true);
|
||||
ship.standard[5].enabled = sensorsJson.on === true;
|
||||
ship.standard[5].priority = sensorsJson.priority;
|
||||
|
||||
// Fuel tank
|
||||
const fueltankJson = json.modules.FuelTank.module;
|
||||
const fueltank = _moduleFromEdId(fueltankJson.id);
|
||||
ship.use(ship.standard[6], fueltank, true);
|
||||
ship.standard[6].enabled = true;
|
||||
ship.standard[6].priority = 0;
|
||||
|
||||
// Add hardpoints
|
||||
let hardpointClassNum = -1;
|
||||
let hardpointSlotNum = -1;
|
||||
let hardpointArrayNum = 0;
|
||||
for (let i in shipTemplate.slots.hardpoints) {
|
||||
if (shipTemplate.slots.hardpoints[i] === hardpointClassNum) {
|
||||
// Another slot of the same class
|
||||
hardpointSlotNum++;
|
||||
} else {
|
||||
// The first slot of a new class
|
||||
hardpointClassNum = shipTemplate.slots.hardpoints[i];
|
||||
hardpointSlotNum = 1;
|
||||
}
|
||||
|
||||
// Now that we know what we're looking for, find it
|
||||
const hardpointName = HARDPOINT_NUM_TO_CLASS[hardpointClassNum] + 'Hardpoint' + hardpointSlotNum;
|
||||
const hardpointSlot = json.modules[hardpointName];
|
||||
if (!hardpointSlot.module) {
|
||||
// No module
|
||||
} else {
|
||||
const hardpointJson = hardpointSlot.module;
|
||||
const hardpoint = _moduleFromEdId(hardpointJson.id);
|
||||
if (hardpointJson.modifiers) _addModifications(hardpoint, hardpointJson.modifiers);
|
||||
ship.use(ship.hardpoints[hardpointArrayNum], hardpoint, true);
|
||||
ship.hardpoints[hardpointArrayNum].enabled = hardpointJson.on === true;
|
||||
ship.hardpoints[hardpointArrayNum].priority = hardpointJson.priority;
|
||||
}
|
||||
hardpointArrayNum++;
|
||||
}
|
||||
|
||||
// Add internal compartments
|
||||
let internalSlotNum = 1;
|
||||
for (let i in shipTemplate.slots.internal) {
|
||||
const internalClassNum = shipTemplate.slots.internal[i];
|
||||
|
||||
let internalSlot = null;
|
||||
while (internalSlot === null && internalSlotNum < 99) {
|
||||
// Slot numbers are not contiguous so handle skips
|
||||
const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '') + internalSlotNum + '_Size' + internalClassNum;
|
||||
if (json.modules[internalName]) {
|
||||
internalSlot = json.modules[internalName];
|
||||
}
|
||||
internalSlotNum++;
|
||||
}
|
||||
if (!internalSlot.module) {
|
||||
// No module
|
||||
} else {
|
||||
const internalJson = internalSlot.module;
|
||||
const internal = _moduleFromEdId(internalJson.id);
|
||||
if (internalJson.modifiers) _addModifications(internal, internalJson.modifiers);
|
||||
ship.use(ship.internal[i], internal, true);
|
||||
ship.internal[i].enabled = internalJson.on === true;
|
||||
ship.internal[i].priority = internalJson.priority;
|
||||
}
|
||||
}
|
||||
|
||||
// Now update the ship's codes before returning it
|
||||
return ship.updatePowerPrioritesString().updatePowerEnabledString().updateModificationsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the modifications for a module
|
||||
* @param {Module} module the module
|
||||
* @param {Object} modifiers the modifiers
|
||||
*/
|
||||
function _addModifications(module, modifiers) {
|
||||
if (!modifiers || !modifiers.modifiers) return;
|
||||
|
||||
for (const i in modifiers.modifiers) {
|
||||
// Look up the modifiers to find what we need to do
|
||||
const modifierActions = Modifications.modifierActions[modifiers.modifiers[i].name];
|
||||
const value = modifiers.modifiers[i].value;
|
||||
|
||||
// Carry out the required changes
|
||||
for (const action in modifierActions) {
|
||||
const actionValue = modifierActions[action] * value;
|
||||
let mod = module.getModValue(action) / 10000;
|
||||
if (!mod) {
|
||||
mod = 0;
|
||||
}
|
||||
module.setModValue(action, ((1 + mod) * (1 + actionValue) - 1) * 10000);
|
||||
}
|
||||
}
|
||||
|
||||
// Need to fix up a few items
|
||||
|
||||
// Shield boosters are treated internally as straight modifiers, so rather than (for example)
|
||||
// being a 4% boost they are a 104% multiplier. Unfortunately this means that our % modification
|
||||
// is incorrect so we fix it
|
||||
if (module.grp === 'sb' && module.getModValue('shieldboost')) {
|
||||
const alteredBoost = (1 + module.shieldboost) * (module.getModValue('shieldboost') / 10000);
|
||||
module.setModValue('shieldboost', alteredBoost * 10000 / module.shieldboost);
|
||||
}
|
||||
|
||||
// Shield booster resistance is actually a damage modifier, so needs to be inverted.
|
||||
if (module.grp === 'sb') {
|
||||
if (module.getModValue('explres')) {
|
||||
module.setModValue('explres', ((module.getModValue('explres') / 10000) * -1) * 10000);
|
||||
}
|
||||
if (module.getModValue('kinres')) {
|
||||
module.setModValue('kinres', ((module.getModValue('kinres') / 10000) * -1) * 10000);
|
||||
}
|
||||
if (module.getModValue('thermres')) {
|
||||
module.setModValue('thermres', ((module.getModValue('thermres') / 10000) * -1) * 10000);
|
||||
}
|
||||
}
|
||||
|
||||
// Shield generator resistance is actually a damage modifier, so needs to be inverted.
|
||||
// In addition, the modification is based off the inherent resistance of the module
|
||||
if (module.isShieldGenerator()) {
|
||||
if (module.getModValue('explres')) {
|
||||
module.setModValue('explres', ((1 - (1 - module.explres) * (1 + module.getModValue('explres') / 10000)) - module.explres) * 10000);
|
||||
}
|
||||
if (module.getModValue('kinres')) {
|
||||
module.setModValue('kinres', ((1 - (1 - module.kinres) * (1 + module.getModValue('kinres') / 10000)) - module.kinres) * 10000);
|
||||
}
|
||||
if (module.getModValue('thermres')) {
|
||||
module.setModValue('thermres', ((1 - (1 - module.thermres) * (1 + module.getModValue('thermres') / 10000)) - module.thermres) * 10000);
|
||||
}
|
||||
}
|
||||
|
||||
// Hull reinforcement package resistance is actually a damage modifier, so needs to be inverted.
|
||||
if (module.grp === 'hr') {
|
||||
if (module.getModValue('explres')) {
|
||||
module.setModValue('explres', ((module.getModValue('explres') / 10000) * -1) * 10000);
|
||||
}
|
||||
if (module.getModValue('kinres')) {
|
||||
module.setModValue('kinres', ((module.getModValue('kinres') / 10000) * -1) * 10000);
|
||||
}
|
||||
if (module.getModValue('thermres')) {
|
||||
module.setModValue('thermres', ((module.getModValue('thermres') / 10000) * -1) * 10000);
|
||||
}
|
||||
}
|
||||
|
||||
// Bulkhead resistance is actually a damage modifier, so needs to be inverted.
|
||||
// In addition, the modification is based off the inherent resistance of the module
|
||||
if (module.grp == 'bh') {
|
||||
if (module.getModValue('explres')) {
|
||||
module.setModValue('explres', ((1 - (1 - module.explres) * (1 + module.getModValue('explres') / 10000)) - module.explres) * 10000);
|
||||
}
|
||||
if (module.getModValue('kinres')) {
|
||||
module.setModValue('kinres', ((1 - (1 - module.kinres) * (1 + module.getModValue('kinres') / 10000)) - module.kinres) * 10000);
|
||||
}
|
||||
if (module.getModValue('thermres')) {
|
||||
module.setModValue('thermres', ((1 - (1 - module.thermres) * (1 + module.getModValue('thermres') / 10000)) - module.thermres) * 10000);
|
||||
}
|
||||
}
|
||||
|
||||
// Jitter is an absolute number, so we need to divide it by 100
|
||||
if (module.getModValue('jitter')) {
|
||||
module.setModValue('jitter', module.getModValue('jitter') / 100);
|
||||
}
|
||||
|
||||
// FD uses interval between bursts internally, so we need to translate this to a real rate of fire
|
||||
if (module.getModValue('rof')) {
|
||||
module.setModValue('rof', ((1 / (1 + module.getModValue('rof') / 10000)) - 1) * 10000);
|
||||
}
|
||||
}
|
||||
@@ -93,69 +93,6 @@ export function slotComparator(translate, propComparator, desc) {
|
||||
};
|
||||
}
|
||||
|
||||
const PROP_BLACKLIST = {
|
||||
eddbID: 1,
|
||||
edID: 1,
|
||||
id: 1,
|
||||
index: 1,
|
||||
'class': 1,
|
||||
rating: 1,
|
||||
maxfuel: 1,
|
||||
fuelmul: 1,
|
||||
fuelpower: 1,
|
||||
optmass: 1,
|
||||
maxmass: 1,
|
||||
minmass: 1,
|
||||
passive: 1,
|
||||
thermload: 1,
|
||||
ammocost: 1,
|
||||
activepower: 1,
|
||||
cooldown: 1,
|
||||
chargeup: 1,
|
||||
optmul: 1,
|
||||
minmul: 1,
|
||||
maxmul: 1,
|
||||
ssdam: 1,
|
||||
mjdps: 1,
|
||||
mjeps: 1,
|
||||
mass: 1,
|
||||
cost: 1,
|
||||
recover: 1,
|
||||
wepcap: 1,
|
||||
weprate: 1,
|
||||
engcap: 1,
|
||||
engrate: 1,
|
||||
syscap: 1,
|
||||
sysrate: 1,
|
||||
breachdps: 1,
|
||||
breachmin: 1,
|
||||
breachmax: 1,
|
||||
integrity: 1
|
||||
};
|
||||
|
||||
const TERM_LOOKUP = {
|
||||
pgen: 'power',
|
||||
armouradd: 'armour',
|
||||
rof: 'ROF',
|
||||
dps: 'DPS'
|
||||
};
|
||||
|
||||
const FORMAT_LOOKUP = {
|
||||
time: 'time'
|
||||
};
|
||||
|
||||
const UNIT_LOOKUP = {
|
||||
fuel: 'T',
|
||||
cargo: 'T',
|
||||
rate: 'kgs',
|
||||
range: 'km',
|
||||
recharge: 'MJ',
|
||||
rangeLS: 'Ls',
|
||||
power: 'MJ',
|
||||
pgen: 'MJ',
|
||||
rof: 'ps'
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine the appropriate class based on diff value
|
||||
* @param {Number} a Potential Module (cannot be null)
|
||||
@@ -214,23 +151,15 @@ export function diffDetails(language, m, mm) {
|
||||
let mmMass = mm ? mm.getMass() : 0;
|
||||
if (mMass != mmMass) propDiffs.push(<div key='mass'>{translate('mass')}: <span className={diffClass(mMass, mmMass, true)}>{diff(formats.round, mMass, mmMass)}{units.T}</span></div>);
|
||||
|
||||
let mPowerGeneration = m.pgen || 0;
|
||||
let mmPowerGeneration = mm ? mm.getPowerGeneration() : 0;
|
||||
if (mPowerGeneration != mmPowerGeneration) propDiffs.push(<div key='pgen'>{translate('pgen')}: <span className={diffClass(mPowerGeneration, mmPowerGeneration, true)}>{diff(formats.round, mPowerGeneration, mmPowerGeneration)}{units.MJ}</span></div>);
|
||||
|
||||
let mPowerUsage = m.power || 0;
|
||||
let mmPowerUsage = mm ? mm.getPowerUsage() : 0;
|
||||
if (mPowerUsage != mmPowerUsage) propDiffs.push(<div key='power'>{translate('power')}: <span className={diffClass(mPowerUsage, mmPowerUsage, true)}>{diff(formats.round, mPowerUsage, mmPowerUsage)}{units.MJ}</span></div>);
|
||||
|
||||
// for (let p in m) {
|
||||
// if (!PROP_BLACKLIST[p] && !isNaN(m[p])) {
|
||||
// let mVal = m[p] === null ? Infinity : m[p];
|
||||
// let mmVal = mm[p] === null ? Infinity : mm[p];
|
||||
// let format = formats[FORMAT_LOOKUP[p]] || formats.round;
|
||||
// propDiffs.push(<div key={p}>
|
||||
// {`${translate(TERM_LOOKUP[p] || p)}: `}
|
||||
// <span className={diffClass(mVal, mmVal, p == 'power')}>{diff(format, mVal, mmVal)}{units[UNIT_LOOKUP[p]]}</span>
|
||||
// </div>);
|
||||
// }
|
||||
// }
|
||||
|
||||
let mDps = m.damage * (m.rpshot || 1) * m.rof || 0;
|
||||
let mDps = m.damage * (m.rpshot || 1) * (m.rof || 1) || 0;
|
||||
let mmDps = mm ? mm.getDps() || 0 : 0;
|
||||
if (mDps != mmDps) propDiffs.push(<div key='dps'>{translate('dps')}: <span className={diffClass(mmDps, mDps, true)}>{diff(formats.round, mDps, mmDps)}</span></div>);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* Generates a URL for the outiffing page
|
||||
* @param {String} shipId Ship Id
|
||||
@@ -7,15 +6,18 @@
|
||||
* @return {String} URL
|
||||
*/
|
||||
export function outfitURL(shipId, code, buildName) {
|
||||
let parts = ['/outfit/', shipId];
|
||||
let path = '/outfit/' + shipId;
|
||||
|
||||
let sepChar = '?';
|
||||
|
||||
if (code) {
|
||||
parts.push('/', code);
|
||||
path = path + sepChar + 'code=' + encodeURIComponent(code);
|
||||
sepChar = '&';
|
||||
}
|
||||
|
||||
if (buildName) {
|
||||
parts.push('?bn=', encodeURIComponent(buildName));
|
||||
path = path + sepChar + 'bn=' + encodeURIComponent(buildName);
|
||||
}
|
||||
return parts.join('');
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -58,3 +58,16 @@ export function shallowEqual(objA, objB) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a URL-safe base-64 encoded string in to a normal version.
|
||||
* Coriolis used to use a different encoding system, and some old
|
||||
* data might be bookmarked or on local storage, so we keep this
|
||||
* around and use it when decoding data from the old-style URLs to
|
||||
* be safe.
|
||||
* @param {string} data the string
|
||||
* @return {string} the converted string
|
||||
*/
|
||||
export function fromUrlSafe(data) {
|
||||
return data ? data.replace(/-/g, '/').replace(/_/g, '+') : null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
// Standard icons
|
||||
.icon {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
@@ -25,3 +26,39 @@
|
||||
height: 2em;
|
||||
}
|
||||
}
|
||||
|
||||
// Modifiction icons - hard-code stroke/fill
|
||||
.modicon {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 1.1em;
|
||||
height: 1em;
|
||||
stoke: @fg;
|
||||
fill: transparent;
|
||||
|
||||
&.sm {
|
||||
width: 0.8em;
|
||||
height: 0.75em;
|
||||
}
|
||||
|
||||
&.tn {
|
||||
width: 0.6em;
|
||||
height: 0.5em;
|
||||
}
|
||||
|
||||
&.lg {
|
||||
width: 1.6em;
|
||||
height: 1.5em;
|
||||
}
|
||||
|
||||
&.xl {
|
||||
width: 2.1em;
|
||||
height: 2em;
|
||||
}
|
||||
}
|
||||
|
||||
.summary {
|
||||
stroke: @fg;
|
||||
stroke-width: 10;
|
||||
fill: @fg;
|
||||
}
|
||||
|
||||
356
src/schemas/ship-loadout/4.json
Normal file
356
src/schemas/ship-loadout/4.json
Normal file
@@ -0,0 +1,356 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"id": "http://cdn.coriolis.io/schemas/ship-loadout/4.json#",
|
||||
"title": "Ship Loadout",
|
||||
"type": "object",
|
||||
"description": "The details for a specific ship build/loadout",
|
||||
"required": ["name", "ship", "components"],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "The name of the build/loadout",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"ship": {
|
||||
"description": "The full display name of the ship",
|
||||
"type": "string",
|
||||
"minimum": 3
|
||||
},
|
||||
"manufacturer": {
|
||||
"description": "The ship manufacturer",
|
||||
"type": "string"
|
||||
},
|
||||
"references" : {
|
||||
"description": "3rd Party references and/or links to this build/loadout",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["name","url"],
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "The name of the 3rd party, .e.g 'Coriolis.io' or 'E:D Shipyard'",
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"description": "The link/url to the 3rd party referencing this build/loadout",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"description": "The components used by this build",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["standard", "internal", "hardpoints", "utility"],
|
||||
"properties": {
|
||||
"standard": {
|
||||
"description": "The set of standard components across all ships",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["bulkheads", "powerPlant", "thrusters", "frameShiftDrive", "lifeSupport", "powerDistributor", "sensors", "fuelTank", "cargoHatch"],
|
||||
"properties": {
|
||||
"bulkheads": {
|
||||
"enum": ["Lightweight Alloy", "Reinforced Alloy", "Military Grade Composite", "Mirrored Surface Composite", "Reactive Surface Composite"]
|
||||
},
|
||||
"cargoHatch": {
|
||||
"required": ["enabled", "priority"],
|
||||
"properties": {
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 }
|
||||
}
|
||||
},
|
||||
"powerPlant": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 2, "maximum": 8 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"thrusters": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 2, "maximum": 8 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"name": {
|
||||
"description": "The name identifing the thrusters (if applicable), e.g. 'Enhanced Performance'",
|
||||
"type": "string"
|
||||
},
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"frameShiftDrive": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 2, "maximum": 8 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"lifeSupport": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 1, "maximum": 6 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"powerDistributor": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 1, "maximum": 8 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"sensors": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 1, "maximum": 8 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"fuelTank": {
|
||||
"required": ["class", "rating", "enabled", "priority"],
|
||||
"properties": {
|
||||
"class": { "type": "integer", "minimum": 1, "maximum": 6 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"internal": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": ["object", "null"],
|
||||
"required": ["class", "rating", "enabled", "priority", "group"],
|
||||
"properties" : {
|
||||
"class": { "type": "integer", "minimum": 1, "maximum": 8 },
|
||||
"rating": { "$ref": "#/definitions/standardRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"group": {
|
||||
"description": "The group of the component, e.g. 'Shield Generator', or 'Cargo Rack'",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name identifying the component (if applicable), e.g. 'Advance Discovery Scanner', or 'Detailed Surface Scanner'",
|
||||
"type": "string"
|
||||
},
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"minItems": 3
|
||||
},
|
||||
"hardpoints": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": ["object", "null"],
|
||||
"required": ["class", "rating", "enabled", "priority", "group", "mount"],
|
||||
"properties" : {
|
||||
"class": { "type": "integer", "minimum": 1, "maximum": 4 },
|
||||
"rating": { "$ref": "#/definitions/allRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"mount": { "type": "string", "enum": ["Fixed", "Gimballed", "Turret"] },
|
||||
"group": {
|
||||
"description": "The group of the component, e.g. 'Beam Laser', or 'Missile Rack'",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name identifing the component (if applicable), e.g. 'Retributor', or 'Mining Lance'",
|
||||
"type": "string"
|
||||
},
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"minItems": 1
|
||||
},
|
||||
"utility": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": ["object", "null"],
|
||||
"required": ["class", "rating", "enabled", "priority", "group"],
|
||||
"properties" : {
|
||||
"class": { "type": "integer", "minimum": 0, "maximum": 0 },
|
||||
"rating": { "$ref": "#/definitions/allRatings" },
|
||||
"enabled": { "type": "boolean" },
|
||||
"priority": { "type": "integer", "minimum": 1, "maximum": 5 },
|
||||
"group": {
|
||||
"description": "The group of the component, e.g. 'Shield Booster', or 'Kill Warrant Scanner'",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "The name identifing the component (if applicable), e.g. 'Point Defence', or 'Electronic Countermeasure'",
|
||||
"type": "string"
|
||||
},
|
||||
"modifications": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"stats": {
|
||||
"description": "Optional statistics from the build",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"agility": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"armour": {
|
||||
"description": "Sum of base armour + any hull reinforcements",
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"armourAdded":{
|
||||
"description": "Armour added through Hull reinforcement",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"baseShieldStrength": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"baseArmour": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"boost": {
|
||||
"description": "Maximum boost speed of the ships (4 pips, straight-line)",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"cargoCapacity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"class": {
|
||||
"description": "Ship Class/Size [Small, Medium, Large]",
|
||||
"enum": [1,2,3]
|
||||
},
|
||||
"totalDps": {
|
||||
"description": "Total damage dealt per second of all weapons",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"totalEps": {
|
||||
"description": "Total energy consumed per second of all weapons",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"totalHps": {
|
||||
"description": "Total heat generated per second of all weapons",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"hullCost": {
|
||||
"description": "Cost of the ship's hull",
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"hullMass": {
|
||||
"description": "Mass of the Ship hull only",
|
||||
"type": "number",
|
||||
"minimum": 1
|
||||
},
|
||||
"hullExplRes": {
|
||||
"description": "Multiplier for explosive damage to hull",
|
||||
"type": "number"
|
||||
},
|
||||
"hullKinRes": {
|
||||
"description": "Multiplier for kinetic damage to hull",
|
||||
"type": "number"
|
||||
},
|
||||
"hullThermRes": {
|
||||
"description": "Multiplier for thermal damage to hull",
|
||||
"type": "number"
|
||||
},
|
||||
"fuelCapacity": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"fullTankRange": {
|
||||
"description": "Single Jump range with a full tank (unladenMass + fuel)",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"ladenMass": {
|
||||
"description": "Mass of the Ship + fuel + cargo (hull + all components + fuel tank + cargo capacity)",
|
||||
"type": "number",
|
||||
"minimum": 1
|
||||
},
|
||||
"ladenRange": {
|
||||
"description": "Single Jump range with full cargo load, see ladenMass",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"masslock": {
|
||||
"description": "Mass Lock Factor of the Ship",
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"shield": {
|
||||
"description": "Shield strength in Mega Joules (Mj)",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"shieldExplRes": {
|
||||
"description": "Multiplier for explosive damage to shields",
|
||||
"type": "number"
|
||||
},
|
||||
"shieldKinRes": {
|
||||
"description": "Multiplier for kinetic damage to shields",
|
||||
"type": "number"
|
||||
},
|
||||
"shieldThermRes": {
|
||||
"description": "Multiplier for thermal damage to shields",
|
||||
"type": "number"
|
||||
},
|
||||
"speed": {
|
||||
"description": "Maximum speed of the ships (4 pips, straight-line)",
|
||||
"type": "number",
|
||||
"minimum": 1
|
||||
},
|
||||
"totalCost": {
|
||||
"description": "Total cost of the loadout, including discounts",
|
||||
"type": "number"
|
||||
},
|
||||
"unladenRange": {
|
||||
"description": "Single Jump range when unladen, see unladenMass",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"unladenMass": {
|
||||
"description": "Mass of the Ship (hull + all components)",
|
||||
"type": "number",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"standardRatings": { "enum": ["A", "B", "C", "D", "E", "F", "G", "H"] },
|
||||
"allRatings": { "enum": ["A", "B", "C", "D", "E", "F", "G", "H", "I" ] }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user