From 38463ad9a65d2f7e4dc3b7f2f6ff4812e5b8a11c Mon Sep 17 00:00:00 2001 From: ExitCode Date: Mon, 23 Apr 2018 01:16:13 +0200 Subject: [PATCH 01/10] Fixed bp preset highlight when specials alter on the same values --- src/app/utils/BlueprintFunctions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index 2367570b..548cfe86 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -361,10 +361,10 @@ export function getPercent(m) { */ function _getValue(m, featureName) { if (Modifications.modifications[featureName].type == 'percentage') { - return m.getModValue(featureName) / 10000; + return m.getModValue(featureName, true) / 10000; } else if (Modifications.modifications[featureName].type == 'numeric') { - return m.getModValue(featureName) / 100; + return m.getModValue(featureName, true) / 100; } else { - return m.getModValue(featureName); + return m.getModValue(featureName, true); } } From 71ddbdfe75350b7d72413156e8b9c3688b1c0a89 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 23 Apr 2018 14:51:45 +1000 Subject: [PATCH 02/10] add specials tooltip --- src/app/components/ModificationsMenu.jsx | 31 ++++++++++-- src/app/utils/BlueprintFunctions.js | 64 ++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 29a85f67..e5ee6616 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -6,7 +6,14 @@ import { isEmpty, stopCtxPropagation } from '../utils/UtilityFunctions'; import cn from 'classnames'; import { Modifications } from 'coriolis-data/dist'; import Modification from './Modification'; -import { getBlueprint, blueprintTooltip, setPercent, getPercent, setRandom } from '../utils/BlueprintFunctions'; +import { + getBlueprint, + blueprintTooltip, + setPercent, + getPercent, + setRandom, + specialToolTip +} from '../utils/BlueprintFunctions' /** * Modifications menu @@ -86,7 +93,6 @@ export default class ModificationsMenu extends TranslatedComponent { const { m } = props; const { language, tooltip, termtip } = context; const translate = language.translate; - const specials = []; const specialsId = m.missile && Modifications.modules[m.grp]['specials_' + m.missile] ? 'specials_' + m.missile : 'specials'; if (Modifications.modules[m.grp][specialsId] && Modifications.modules[m.grp][specialsId].length > 0) { @@ -100,7 +106,20 @@ export default class ModificationsMenu extends TranslatedComponent { active: m.blueprint && m.blueprint.special && m.blueprint.special.edname == specialName }); const close = this._specialSelected.bind(this, specialName); - specials.push(
{translate(Modifications.specials[specialName].name)}
); + if (m.blueprint && m.blueprint.name) { + let tmp = {}; + if (m.blueprint.special) { + tmp = m.blueprint.special; + } else { + tmp = undefined; + } + m.blueprint.special = Modifications.specials[specialName]; + let specialTt = specialToolTip(translate, m.blueprint.grades[m.blueprint.grade], m.grp, m, specialName); + m.blueprint.special = tmp; + specials.push(
{translate(Modifications.specials[specialName].name)}
); + } else { + specials.push(
{translate(Modifications.specials[specialName].name)}
); + } } } return specials; @@ -251,8 +270,10 @@ export default class ModificationsMenu extends TranslatedComponent { } let specialLabel; + let specialTt; if (m.blueprint && m.blueprint.special) { specialLabel = m.blueprint.special.name; + specialTt = specialToolTip(translate, m.blueprint.grades[m.blueprint.grade], m.grp, m, m.blueprint.special.edname); } else { specialLabel = translate('PHRASE_SELECT_SPECIAL'); } @@ -276,7 +297,7 @@ export default class ModificationsMenu extends TranslatedComponent {
{blueprintLabel}
:
{translate('PHRASE_SELECT_BLUEPRINT')}
} { showBlueprintsMenu ? this._renderBlueprints(this.props, this.context) : null } - { showSpecial & !showSpecialsMenu ?
{specialLabel}
: null } + { showSpecial & !showSpecialsMenu ?
{specialLabel}
: null } { showSpecialsMenu ? specials : null } { showReset ?
{ translate('reset') }
: null } { showRolls ? @@ -285,7 +306,7 @@ export default class ModificationsMenu extends TranslatedComponent { { showRolls ? - { translate('roll') }: + { translate('roll') }: { translate('0%') } { translate('50%') } { translate('100%') } diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index 2367570b..996b796e 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -1,6 +1,70 @@ import React from 'react'; import { Modifications } from 'coriolis-data/dist'; +/** + * Generate a tooltip with details of a blueprint's specials + * @param {Object} translate The translate object + * @param {Object} blueprint The blueprint at the required grade + * @param {string} grp The group of the module + * @param {Object} m The module to compare with + * @param specialName + * @returns {Object} The react components + */ +export function specialToolTip(translate, blueprint, grp, m, specialName) { + const effects = []; + console.log(blueprint) + if (!blueprint || !blueprint.features) { + console.log('nah') + return undefined; + } + if (m) { + // We also add in any benefits from specials that aren't covered above + if (m.blueprint) { + for (const feature in Modifications.modifierActions[specialName]) { + // if (!blueprint.features[feature] && !m.mods.feature) { + const featureDef = Modifications.modifications[feature]; + if (featureDef && !featureDef.hidden) { + let symbol = ''; + if (feature === 'jitter') { + symbol = '°'; + } else if (featureDef.type === 'percentage') { + symbol = '%'; + } + const modifierActions = Modifications.modifierActions[specialName]; + let current = m.getModValue(feature) - m.getModValue(feature, true); + if (featureDef.type === 'percentage') { + current = Math.round(current / 10) / 10; + } else if (featureDef.type === 'numeric') { + current /= 100; + } + const currentIsBeneficial = isValueBeneficial(feature, current); + + effects.push( + + {translate(feature, grp)} +   + {current}{symbol} +   + + ); + } + } + + } + } + + return ( +
+ + + {effects} + +
+
+ ); +} + /** * Generate a tooltip with details of a blueprint's effects * @param {Object} translate The translate object From abb0c7f90d606bf892f4c28d6444c85d10c25528 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 23 Apr 2018 18:15:24 +1000 Subject: [PATCH 03/10] remove debug logs --- src/app/utils/BlueprintFunctions.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index 996b796e..c166909f 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -12,9 +12,7 @@ import { Modifications } from 'coriolis-data/dist'; */ export function specialToolTip(translate, blueprint, grp, m, specialName) { const effects = []; - console.log(blueprint) if (!blueprint || !blueprint.features) { - console.log('nah') return undefined; } if (m) { From 32be186ec5beb2e35dad1efcfd1364d9c35ca2c5 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Mon, 23 Apr 2018 18:15:44 +1000 Subject: [PATCH 04/10] remove unused var --- src/app/utils/BlueprintFunctions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index c166909f..18404b01 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -28,7 +28,6 @@ export function specialToolTip(translate, blueprint, grp, m, specialName) { } else if (featureDef.type === 'percentage') { symbol = '%'; } - const modifierActions = Modifications.modifierActions[specialName]; let current = m.getModValue(feature) - m.getModValue(feature, true); if (featureDef.type === 'percentage') { current = Math.round(current / 10) / 10; From f4cc9fc7221a732bc12db1f629a07e786afc2d1a Mon Sep 17 00:00:00 2001 From: willyb321 Date: Wed, 25 Apr 2018 14:20:45 +1000 Subject: [PATCH 05/10] fix typo --- src/app/components/AvailableModulesMenu.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/AvailableModulesMenu.jsx b/src/app/components/AvailableModulesMenu.jsx index 680001ba..7c804ed1 100644 --- a/src/app/components/AvailableModulesMenu.jsx +++ b/src/app/components/AvailableModulesMenu.jsx @@ -199,8 +199,8 @@ export default class AvailableModulesMenu extends TranslatedComponent { /** * Generate React Components for Module Group * @param {Function} translate Translate function - * @param {Objecy} mountedModule Mounted Module - * @param {Funciton} warningFunc Warning function + * @param {Object} mountedModule Mounted Module + * @param {Function} warningFunc Warning function * @param {number} mass Mass * @param {function} onSelect Select/Mount callback * @param {string} grp Group name From b14e7473f373ad59008ae892450d6d0144aa1a1b Mon Sep 17 00:00:00 2001 From: willyb321 Date: Wed, 25 Apr 2018 15:07:13 +1000 Subject: [PATCH 06/10] add guardian powerplant, gauss cannon and also plasma charger --- src/app/components/AvailableModulesMenu.jsx | 20 ++++++++++++++++---- src/app/i18n/en.json | 4 ++++ src/app/shipyard/Constants.js | 8 +++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/app/components/AvailableModulesMenu.jsx b/src/app/components/AvailableModulesMenu.jsx index 7c804ed1..f1f90380 100644 --- a/src/app/components/AvailableModulesMenu.jsx +++ b/src/app/components/AvailableModulesMenu.jsx @@ -56,7 +56,11 @@ const GRPCAT = { 'ch': 'defence', 'po': 'defence', 'ec': 'defence', - 'sfn': 'defence' + 'sfn': 'defence', + // Standard + 'gpp': 'guardian', + 'gpc': 'guardian', + 'ggc': 'guardian' }; // Order here is the order in which items will be shown in the modules menu const CATEGORIES = { @@ -82,7 +86,10 @@ const CATEGORIES = { 'defence': ['ch', 'po', 'ec'], 'scanners': ['sc', 'ss', 'cs', 'kw', 'ws'], // Overloaded with internal scanners // Experimental - 'experimental': ['axmc', 'axmr', 'rfl', 'xs', 'sfn'] + 'experimental': ['axmc', 'axmr', 'rfl', 'xs', 'sfn'], + + // Guardian + 'guardian': ['gpp', 'gpc', 'ggc'] }; /** @@ -208,7 +215,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { * @return {React.Component} Available Module Group contents */ _buildGroup(translate, mountedModule, warningFunc, mass, onSelect, grp, modules) { - let prevClass = null, prevRating = null; + let prevClass = null, prevRating = null, prevName; let elems = []; const sortedModules = modules.sort(this._moduleOrder); @@ -223,6 +230,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { let m = sortedModules[i]; let mount = null; let disabled = false; + prevName = m.name if (ModuleUtils.isShieldGenerator(m.grp)) { // Shield generators care about maximum hull mass disabled = mass > m.maxmass; @@ -258,7 +266,10 @@ export default class AvailableModulesMenu extends TranslatedComponent { case 'G': mount = ; break; case 'T': mount = ; break; } - + if (m.name && m.name === prevName) { + // elems.push(
); + itemsOnThisRow = 0; + } if (itemsOnThisRow == 6 || i > 0 && sortedModules.length > 3 && itemsPerClass > 2 && m.class != prevClass && (m.rating != prevRating || m.mount)) { elems.push(
); itemsOnThisRow = 0; @@ -273,6 +284,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { itemsOnThisRow++; prevClass = m.class; prevRating = m.rating; + prevName = m.name; } return
    {elems}
; diff --git a/src/app/i18n/en.json b/src/app/i18n/en.json index ae9ecea7..72718995 100644 --- a/src/app/i18n/en.json +++ b/src/app/i18n/en.json @@ -117,6 +117,10 @@ "pl": "Pulse Laser", "po": "Point Defence", "pp": "Power Plant", + "gpp": "Guardian Hybrid Power Plant", + "gpd": "Guardian Hybrid Power Distributor", + "gpc": "Guardian Plasma Charger", + "ggc": "Guardian Gauss Cannon", "psg": "Prismatic Shield Generator", "pv": "Planetary Vehicle Hangar", "rf": "Refinery", diff --git a/src/app/shipyard/Constants.js b/src/app/shipyard/Constants.js index 5763923a..55aa8a64 100755 --- a/src/app/shipyard/Constants.js +++ b/src/app/shipyard/Constants.js @@ -9,12 +9,16 @@ export const StandardArray = [ 'pd', // Power Distributor 's', // Sensors 'ft', // Fuel Tank + 'gpp', // Guardian Hybrid Power Plant + 'gpd' // Guardian Hybrid Power Distributor ]; // Map to lookup group labels/names for component grp, used for JSON Serialization export const ModuleGroupToName = { // Standard pp: 'Power Plant', + gpp: 'Guardian Hybrid Power Plant', + gpd: 'Guardian Hybrid Power Distributor', t: 'Thrusters', fsd: 'Frame Shift Drive', ls: 'Life Support', @@ -75,7 +79,9 @@ export const ModuleGroupToName = { sb: 'Shield Booster', tp: 'Torpedo Pylon', sfn: 'Shutdown Field Neutraliser', - xs: 'Xeno Scanner' + xs: 'Xeno Scanner', + gpc: 'Guardian Plasma Charger', + ggc: 'Guardian Gauss Cannon', }; let GrpNameToCodeMap = {}; From b4a82ae7c2f9a96e424d19c76f0ffbebcc7fb2aa Mon Sep 17 00:00:00 2001 From: willyb321 Date: Wed, 25 Apr 2018 18:00:01 +1000 Subject: [PATCH 07/10] fix crash with not having modifications key --- src/app/components/StandardSlot.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/StandardSlot.jsx b/src/app/components/StandardSlot.jsx index 4109fbc9..5e23b485 100644 --- a/src/app/components/StandardSlot.jsx +++ b/src/app/components/StandardSlot.jsx @@ -48,7 +48,7 @@ export default class StandardSlot extends TranslatedComponent { let m = slot.m; let classRating = m.class + m.rating; let menu; - let validMods = m == null ? [] : (Modifications.modules[m.grp].modifications || []); + let validMods = m == null || !Modifications.modules[m.grp] ? [] : (Modifications.modules[m.grp].modifications || []); let showModuleResistances = Persist.showModuleResistances(); let mass = m.getMass() || m.cargo || m.fuel || 0; From e0c0778d82622b4b5f9737c51a4a316cdfe7e43f Mon Sep 17 00:00:00 2001 From: willyb321 Date: Wed, 25 Apr 2018 18:45:24 +1000 Subject: [PATCH 08/10] Lowercase in import --- src/app/utils/JournalUtils.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/app/utils/JournalUtils.js b/src/app/utils/JournalUtils.js index fc2cf10f..9181cc4c 100644 --- a/src/app/utils/JournalUtils.js +++ b/src/app/utils/JournalUtils.js @@ -73,14 +73,14 @@ export function shipFromLoadoutJSON (json) { let opts = []; for (const module of json.Modules) { - switch (module.Slot) { + switch (module.Slot.toLowerCase()) { // Cargo Hatch. - case 'CargoHatch': + case 'cargohatch': ship.cargoHatch.enabled = module.On ship.cargoHatch.priority = module.Priority break // Add the bulkheads - case 'Armour': + case 'armour': if (module.Item.toLowerCase().endsWith('_armour_grade1')) { ship.useBulkhead(0, true) } else if (module.Item.toLowerCase().endsWith('_armour_grade2')) { @@ -97,49 +97,49 @@ export function shipFromLoadoutJSON (json) { ship.bulkheads.enabled = true if (module.Engineering) _addModifications(ship.bulkheads.m, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'PowerPlant': + case 'powerplant': const powerplant = _moduleFromFdName(module.Item) ship.use(ship.standard[0], powerplant, true) ship.standard[0].enabled = module.On ship.standard[0].priority = module.Priority if (module.Engineering) _addModifications(powerplant, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'MainEngines': + case 'mainengines': const thrusters = _moduleFromFdName(module.Item) ship.use(ship.standard[1], thrusters, true) ship.standard[1].enabled = module.On ship.standard[1].priority = module.Priority if (module.Engineering) _addModifications(thrusters, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'FrameShiftDrive': + case 'frameshiftdrive': const frameshiftdrive = _moduleFromFdName(module.Item) ship.use(ship.standard[2], frameshiftdrive, true) ship.standard[2].enabled = module.On ship.standard[2].priority = module.Priority if (module.Engineering) _addModifications(frameshiftdrive, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'LifeSupport': + case 'lifesupport': const lifesupport = _moduleFromFdName(module.Item) ship.use(ship.standard[3], lifesupport, true) ship.standard[3].enabled = module.On === true ship.standard[3].priority = module.Priority if (module.Engineering) _addModifications(lifesupport, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'PowerDistributor': + case 'powerdistributor': const powerdistributor = _moduleFromFdName(module.Item) ship.use(ship.standard[4], powerdistributor, true) ship.standard[4].enabled = module.On ship.standard[4].priority = module.Priority if (module.Engineering) _addModifications(powerdistributor, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'Radar': + case 'radar': const sensors = _moduleFromFdName(module.Item) ship.use(ship.standard[5], sensors, true) ship.standard[5].enabled = module.On ship.standard[5].priority = module.Priority if (module.Engineering) _addModifications(sensors, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level) break - case 'FuelTank': + case 'fueltank': const fueltank = _moduleFromFdName(module.Item) ship.use(ship.standard[6], fueltank, true) ship.standard[6].enabled = true @@ -148,7 +148,7 @@ export function shipFromLoadoutJSON (json) { default: } for (const module of json.Modules) { - if (module.Slot.search(/Hardpoint/) !== -1) { + if (module.Slot.toLowerCase().search(/hardpoint/) !== -1) { // Add hardpoints let hardpoint; let hardpointClassNum = -1 @@ -166,7 +166,7 @@ export function shipFromLoadoutJSON (json) { // Now that we know what we're looking for, find it const hardpointName = HARDPOINT_NUM_TO_CLASS[hardpointClassNum] + 'Hardpoint' + hardpointSlotNum - const hardpointSlot = json.Modules.find(elem => elem.Slot === hardpointName) + const hardpointSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === hardpointName.toLowerCase()) if (!hardpointSlot) { // This can happen with old imports that don't contain new hardpoints } else if (!hardpointSlot) { @@ -181,17 +181,17 @@ export function shipFromLoadoutJSON (json) { hardpointArrayNum++ } } - if (module.Slot.search(/Slot\d/) !== -1) { + if (module.Slot.toLowerCase().search(/slot\d/) !== -1) { let internalSlotNum = 1 let militarySlotNum = 1 for (let i in shipTemplate.slots.internal) { - const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name = 'Military' : false + const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name = 'military' : false // The internal slot might be a standard or a military slot. Military slots have a different naming system let internalSlot = null if (isMilitary) { const internalName = 'Military0' + militarySlotNum - internalSlot = json.Modules.find(elem => elem.Slot === internalName) + internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase()) militarySlotNum++ } else { // Slot numbers are not contiguous so handle skips. @@ -199,8 +199,8 @@ export function shipFromLoadoutJSON (json) { // Slot sizes have no relationship to the actual size, either, so check all possibilities for (let slotsize = 0; slotsize < 9; slotsize++) { const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '') + internalSlotNum + '_Size' + slotsize - if (json.Modules.find(elem => elem.Slot === internalName)) { - internalSlot = json.Modules.find(elem => elem.Slot === internalName); + if (json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase())) { + internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase()); break } } From b62abef6182635a6fd2493d3d22c155d11948edc Mon Sep 17 00:00:00 2001 From: willyb321 Date: Wed, 25 Apr 2018 19:55:05 +1000 Subject: [PATCH 09/10] 2.9.9 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03b02f22..e9a11cf1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.9.7", + "version": "2.9.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 067a1d6d..6bc55be9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.9.8", + "version": "2.9.9", "repository": { "type": "git", "url": "https://github.com/EDCD/coriolis" From 48290b2e75d381dcd6ff052792b70f61c2c0f996 Mon Sep 17 00:00:00 2001 From: willyb321 Date: Wed, 25 Apr 2018 20:00:36 +1000 Subject: [PATCH 10/10] 2.9.10 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e9a11cf1..564b790f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.9.9", + "version": "2.9.10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6bc55be9..717f8c62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.9.9", + "version": "2.9.10", "repository": { "type": "git", "url": "https://github.com/EDCD/coriolis"