Skip to content

Commit

Permalink
Merge branch 'release/2.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jessb321 committed Apr 14, 2018
2 parents 506d027 + 7f494dd commit 928e02c
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 106 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coriolis_shipyard",
"version": "2.5.3",
"version": "2.9.0",
"repository": {
"type": "git",
"url": "https://github.com/EDCD/coriolis"
Expand Down
28 changes: 25 additions & 3 deletions src/app/shipyard/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,29 @@ export default class Module {
}
}
}

// Sanitise the resultant value to 4dp equivalent
return isNaN(result) ? result : Math.round(result);
}
/**
* Set a value for a given modification ID
* @param {Number} name The name of the modification
* @param {object} value The value of the modification. If it is a numeric value then it should be an integer scaled so that -2.34% == -234
*/
setModValueFromJournal(name, value, origVal) {
if (!this.mods) {
this.mods = {};
}
if (!this.origVals) {
this.origVals = {};
}

if (value == null || value == 0) {
delete this.mods[name];
} else {
this.mods[name] = value;
this.origVals[name] = origVal;
}
}

/**
* Set a value for a given modification ID
Expand All @@ -79,6 +98,9 @@ export default class Module {
if (!this.mods) {
this.mods = {};
}
if (!this.origVals) {
this.origVals = {};
}
if (valueiswithspecial && this.blueprint && this.blueprint.special) {
// This module has a special effect, see if we need to alter the stored value
const modifierActions = Modifications.modifierActions[this.blueprint.special.edname];
Expand Down Expand Up @@ -117,7 +139,7 @@ export default class Module {
_getModifiedValue(name) {
const modification = Modifications.modifications[name];
let result = this[name];

// console.log(`${name} = ${this[name]}`)
if (!result) {
if (modification && modification.method === 'additive') {
// Additive modifications start at 0 rather than NULL
Expand All @@ -135,7 +157,7 @@ export default class Module {
if (modification.type === 'percentage') {
modValue = this.getModValue(name) / 10000;
} else if (modification.type === 'numeric') {
modValue = this.getModValue(name) / 100;
modValue = this.getModValue(name)/ 100;
} else {
modValue = this.getModValue(name);
}
Expand Down
3 changes: 1 addition & 2 deletions src/app/shipyard/Ship.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ export default class Ship {
// Value passed is invalid; reset it to 0
value = 0;
}

// Handle special cases
if (name === 'pgen') {
// Power generation
Expand Down Expand Up @@ -771,7 +770,7 @@ export default class Ship {
// Alter as required due to changes in the (build) code from one version to the next
this.upgradeInternals(internal, 1 + this.standard.length + this.hardpoints.length, priorities, enabled, modifications, blueprints, version);
}

return this.buildWith(
{
bulkheads: code.charAt(0) * 1,
Expand Down
8 changes: 7 additions & 1 deletion src/app/utils/BlueprintFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ export function isValueBeneficial(feature, value) {
*/
export function getBlueprint(name, module) {
// Start with a copy of the blueprint
const blueprint = JSON.parse(JSON.stringify(Modifications.blueprints[name]));
const findMod = val => Object.keys(Modifications.blueprints).find(elem => elem.toString().toLowerCase().search(val.toString().toLowerCase().replace(/(OutfittingFieldType_|persecond)/igm, '')) >= 0)
const found = Modifications.blueprints[findMod(name)];
if (!found || !found.fdname) {
return undefined;
}
const blueprint = JSON.parse(JSON.stringify(found));
console.log(blueprint)
if (module) {
if (module.grp === 'bh' || module.grp === 'hr' || module.grp === 'sg' || module.grp === 'psg' || module.grp === 'bsg') {
// Bulkheads, hull reinforcements and shield generators need to have their resistances altered by the base values
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/CompanionApiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function _moduleFromEdId(edId) {
* @return {string} the Coriolis model of the ship
*/
function _shipModelFromEDName(edName) {
return SHIP_FD_NAME_TO_CORIOLIS_NAME[edName];
return SHIP_FD_NAME_TO_CORIOLIS_NAME[Object.keys(SHIP_FD_NAME_TO_CORIOLIS_NAME).find(elem => elem.toLowerCase() === edName.toLowerCase())];
}

/**
Expand Down
Loading

0 comments on commit 928e02c

Please sign in to comment.