mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
Compare commits
3 Commits
9ef054c271
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e520208ec6 | ||
|
|
29020e64f2 | ||
|
|
16fe3ba9f5 |
22
package-lock.json
generated
22
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "coriolis_shipyard",
|
"name": "coriolis_shipyard",
|
||||||
"version": "2.5.0",
|
"version": "2.5.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -475,6 +475,15 @@
|
|||||||
"integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=",
|
"integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"axios": {
|
||||||
|
"version": "0.17.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.17.1.tgz",
|
||||||
|
"integrity": "sha1-LY4+XQvb1zJ/kbyBT1xXZg+Bgk0=",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "1.4.1",
|
||||||
|
"is-buffer": "1.1.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"babel-code-frame": {
|
"babel-code-frame": {
|
||||||
"version": "6.26.0",
|
"version": "6.26.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
||||||
@@ -4975,6 +4984,14 @@
|
|||||||
"integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=",
|
"integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"follow-redirects": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-uxYePVPogtya1ktGnAAXOacnbIuRMB4dkvqeNz2qTtTQsuzSfbDolV+wMMKxAmCx0bLgAKLbBOkjItMbbkR1vg==",
|
||||||
|
"requires": {
|
||||||
|
"debug": "3.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"for-in": {
|
"for-in": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||||
@@ -6673,8 +6690,7 @@
|
|||||||
"is-buffer": {
|
"is-buffer": {
|
||||||
"version": "1.1.6",
|
"version": "1.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||||
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"is-builtin-module": {
|
"is-builtin-module": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
"uglify-js": "^2.4.11"
|
"uglify-js": "^2.4.11"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.17.1",
|
||||||
"babel-polyfill": "*",
|
"babel-polyfill": "*",
|
||||||
"browserify-zlib-next": "^1.0.1",
|
"browserify-zlib-next": "^1.0.1",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import { Ships } from 'coriolis-data/dist';
|
|||||||
import cn from 'classnames';
|
import cn from 'classnames';
|
||||||
import Page from './Page';
|
import Page from './Page';
|
||||||
import Router from '../Router';
|
import Router from '../Router';
|
||||||
|
import Axios from 'axios';
|
||||||
import Persist from '../stores/Persist';
|
import Persist from '../stores/Persist';
|
||||||
import * as Utils from '../utils/UtilityFunctions';
|
import * as Utils from '../utils/UtilityFunctions';
|
||||||
import Ship from '../shipyard/Ship';
|
import Ship from '../shipyard/Ship';
|
||||||
import { toDetailedBuild } from '../shipyard/Serializer';
|
import { toDetailedBuild } from '../shipyard/Serializer';
|
||||||
import { outfitURL } from '../utils/UrlGenerators';
|
import { outfitURL } from '../utils/UrlGenerators';
|
||||||
|
import { SHIP_FD_NAME_TO_CORIOLIS_NAME } from '../utils/CompanionApiUtils';
|
||||||
import { FloppyDisk, Bin, Switch, Download, Reload, LinkIcon, ShoppingIcon } from '../components/SvgIcons';
|
import { FloppyDisk, Bin, Switch, Download, Reload, LinkIcon, ShoppingIcon } from '../components/SvgIcons';
|
||||||
import LZString from 'lz-string';
|
import LZString from 'lz-string';
|
||||||
import ShipSummaryTable from '../components/ShipSummaryTable';
|
import ShipSummaryTable from '../components/ShipSummaryTable';
|
||||||
@@ -68,51 +70,98 @@ export default class OutfittingPage extends Page {
|
|||||||
*/
|
*/
|
||||||
_initState(props, context) {
|
_initState(props, context) {
|
||||||
let params = context.route.params;
|
let params = context.route.params;
|
||||||
let shipId = params.ship;
|
let remoteID = params.remote;
|
||||||
let code = params.code;
|
|
||||||
let buildName = params.bn;
|
|
||||||
let data = Ships[shipId]; // Retrieve the basic ship properties, slots and defaults
|
|
||||||
let savedCode = Persist.getBuild(shipId, buildName);
|
|
||||||
|
|
||||||
if (!data) {
|
if (remoteID) { // Remote instance, fetch data.
|
||||||
return { error: { message: 'Ship not found: ' + shipId } };
|
Axios.get('http://127.0.0.1:8081/api/ships/' + remoteID + '/fdev')
|
||||||
}
|
.then((response) => {
|
||||||
|
let remote = response.data;
|
||||||
|
let buildName = params.bn;
|
||||||
|
|
||||||
let ship = new Ship(shipId, data.properties, data.slots); // Create a new Ship instance
|
let shipId = SHIP_FD_NAME_TO_CORIOLIS_NAME[remote.Ship];
|
||||||
|
let data = Ships[shipId];
|
||||||
|
|
||||||
if (code) {
|
if (!data) {
|
||||||
ship.buildFrom(code); // Populate modules from serialized 'code' URL param
|
return { error: { message: 'Ship not found: ' + shipId } };
|
||||||
|
}
|
||||||
|
|
||||||
|
let ship = new Ship(shipId, data.properties, data.slots);
|
||||||
|
ship.buildFromLoadout(remote.Modules);
|
||||||
|
|
||||||
|
this._getTitle = getTitle.bind(this, data.properties.name);
|
||||||
|
|
||||||
|
const { sys, eng, wep, boost, fuel, cargo, opponent, opponentBuild, opponentSys, opponentEng, opponentWep, engagementRange } = this._obtainControlFromCode(ship);
|
||||||
|
return {
|
||||||
|
error: null,
|
||||||
|
title: this._getTitle(buildName),
|
||||||
|
costTab: Persist.getCostTab() || 'costs',
|
||||||
|
buildName,
|
||||||
|
newBuildName: buildName,
|
||||||
|
shipId,
|
||||||
|
ship,
|
||||||
|
sys,
|
||||||
|
eng,
|
||||||
|
wep,
|
||||||
|
boost,
|
||||||
|
fuel,
|
||||||
|
cargo,
|
||||||
|
opponent,
|
||||||
|
opponentBuild,
|
||||||
|
opponentSys,
|
||||||
|
opponentEng,
|
||||||
|
opponentWep,
|
||||||
|
engagementRange
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.state = { error: { message: 'Issue communicating with remote server'}};
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
ship.buildWith(data.defaults); // Populate with default components
|
let shipId = params.ship;
|
||||||
|
let data = Ships[shipId]; // Retrieve the basic ship properties, slots and defaults
|
||||||
|
let savedCode = Persist.getBuild(shipId, buildName);
|
||||||
|
let code = params.code;
|
||||||
|
let buildName = params.bn;
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return { error: { message: 'Ship not found: ' + shipId } };
|
||||||
|
}
|
||||||
|
|
||||||
|
let ship = new Ship(shipId, data.properties, data.slots); // Create a new Ship instance
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
ship.buildFrom(code); // Populate modules from serialized 'code' URL param
|
||||||
|
} else {
|
||||||
|
ship.buildWith(data.defaults); // Populate with default components
|
||||||
|
}
|
||||||
|
this._getTitle = getTitle.bind(this, data.properties.name);
|
||||||
|
|
||||||
|
// Obtain ship control from code
|
||||||
|
const { sys, eng, wep, boost, fuel, cargo, opponent, opponentBuild, opponentSys, opponentEng, opponentWep, engagementRange } = this._obtainControlFromCode(ship, code);
|
||||||
|
return {
|
||||||
|
error: null,
|
||||||
|
title: this._getTitle(buildName),
|
||||||
|
costTab: Persist.getCostTab() || 'costs',
|
||||||
|
buildName,
|
||||||
|
newBuildName: buildName,
|
||||||
|
shipId,
|
||||||
|
ship,
|
||||||
|
code,
|
||||||
|
savedCode,
|
||||||
|
sys,
|
||||||
|
eng,
|
||||||
|
wep,
|
||||||
|
boost,
|
||||||
|
fuel,
|
||||||
|
cargo,
|
||||||
|
opponent,
|
||||||
|
opponentBuild,
|
||||||
|
opponentSys,
|
||||||
|
opponentEng,
|
||||||
|
opponentWep,
|
||||||
|
engagementRange
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this._getTitle = getTitle.bind(this, data.properties.name);
|
|
||||||
|
|
||||||
// Obtain ship control from code
|
|
||||||
const { sys, eng, wep, boost, fuel, cargo, opponent, opponentBuild, opponentSys, opponentEng, opponentWep, engagementRange } = this._obtainControlFromCode(ship, code);
|
|
||||||
return {
|
|
||||||
error: null,
|
|
||||||
title: this._getTitle(buildName),
|
|
||||||
costTab: Persist.getCostTab() || 'costs',
|
|
||||||
buildName,
|
|
||||||
newBuildName: buildName,
|
|
||||||
shipId,
|
|
||||||
ship,
|
|
||||||
code,
|
|
||||||
savedCode,
|
|
||||||
sys,
|
|
||||||
eng,
|
|
||||||
wep,
|
|
||||||
boost,
|
|
||||||
fuel,
|
|
||||||
cargo,
|
|
||||||
opponent,
|
|
||||||
opponentBuild,
|
|
||||||
opponentSys,
|
|
||||||
opponentEng,
|
|
||||||
opponentWep,
|
|
||||||
engagementRange
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -785,6 +785,14 @@ export default class Ship {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
buildFromLoadout(Modules) {
|
||||||
|
let internal = this.internal,
|
||||||
|
standard = this.standard,
|
||||||
|
hps = this.hardpoints,
|
||||||
|
cl = standard.length,
|
||||||
|
i, l;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empties all hardpoints and utility slots
|
* Empties all hardpoints and utility slots
|
||||||
* @return {this} The current ship instance for chaining
|
* @return {this} The current ship instance for chaining
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { getBlueprint } from '../utils/BlueprintFunctions';
|
|||||||
import * as ModuleUtils from '../shipyard/ModuleUtils';
|
import * as ModuleUtils from '../shipyard/ModuleUtils';
|
||||||
|
|
||||||
// mapping from fd's ship model names to coriolis'
|
// mapping from fd's ship model names to coriolis'
|
||||||
const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
|
export const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
|
||||||
'Adder': 'adder',
|
'Adder': 'adder',
|
||||||
'Anaconda': 'anaconda',
|
'Anaconda': 'anaconda',
|
||||||
'Asp': 'asp',
|
'Asp': 'asp',
|
||||||
@@ -51,7 +51,6 @@ const HARDPOINT_NUM_TO_CLASS = {
|
|||||||
4: 'Huge'
|
4: 'Huge'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a module given its ED ID
|
* Obtain a module given its ED ID
|
||||||
* @param {Integer} edId the Elite ID of the module
|
* @param {Integer} edId the Elite ID of the module
|
||||||
|
|||||||
Reference in New Issue
Block a user