mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 14:33:22 +00:00
Merge pull request #60 from Brighter-Applications/issues/776_Fix_Overcharged_Blueprint
Issues/776 fix overcharged blueprint
This commit is contained in:
@@ -57,6 +57,7 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
this.modValDidChange = false; // used to determine if component update was caused by change in modification value.
|
this.modValDidChange = false; // used to determine if component update was caused by change in modification value.
|
||||||
this._handleModChange = this._handleModChange.bind(this);
|
this._handleModChange = this._handleModChange.bind(this);
|
||||||
|
|
||||||
|
// console.log(props.m.blueprint)
|
||||||
this.state = {
|
this.state = {
|
||||||
blueprintMenuOpened: !(props.m.blueprint && props.m.blueprint.name),
|
blueprintMenuOpened: !(props.m.blueprint && props.m.blueprint.name),
|
||||||
specialMenuOpened: false
|
specialMenuOpened: false
|
||||||
@@ -421,15 +422,28 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
let haveBlueprint = false;
|
let haveBlueprint = false;
|
||||||
let blueprintTt;
|
let blueprintTt;
|
||||||
let blueprintCv;
|
let blueprintCv;
|
||||||
|
|
||||||
|
// Set the bprintSearchName value to the fdname of the blueprint for this module
|
||||||
|
let bprintSearchName = m.blueprint.fdname;
|
||||||
|
// If the fdname is Weapon_Overcharged, we need to check if it's an MC
|
||||||
|
if (m.blueprint.fdname === 'Weapon_Overcharged') {
|
||||||
|
// If the module is a MultiCannon, we need to fix the blueprint search name, else it will find the Laser Weapon_Overcharged Blueprint and not the MC Weapon_Overcharged Blueprint
|
||||||
|
if (m.symbol.match(/MultiCannon/i)) {
|
||||||
|
// console.log(Modifications.modules[m.grp].blueprints['MC_Overcharged']);
|
||||||
|
// console.log(m.blueprint.fdname);
|
||||||
|
bprintSearchName = 'MC_Overcharged';
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: Fix this to actually find the correct blueprint.
|
// TODO: Fix this to actually find the correct blueprint.
|
||||||
if (!m.blueprint || !m.blueprint.name || !m.blueprint.fdname || !Modifications.modules[m.grp].blueprints || !Modifications.modules[m.grp].blueprints[m.blueprint.fdname]) {
|
if (!m.blueprint || !m.blueprint.name || !m.blueprint.fdname || !Modifications.modules[m.grp].blueprints || !Modifications.modules[m.grp].blueprints[bprintSearchName]) {
|
||||||
this.props.ship.clearModuleBlueprint(m);
|
this.props.ship.clearModuleBlueprint(m);
|
||||||
this.props.ship.clearModuleSpecial(m);
|
this.props.ship.clearModuleSpecial(m);
|
||||||
}
|
}
|
||||||
if (m.blueprint && m.blueprint.name && Modifications.modules[m.grp].blueprints[m.blueprint.fdname].grades[m.blueprint.grade]) {
|
if (m.blueprint && m.blueprint.name && Modifications.modules[m.grp].blueprints[bprintSearchName].grades[m.blueprint.grade]) {
|
||||||
blueprintLabel = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade;
|
blueprintLabel = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade;
|
||||||
haveBlueprint = true;
|
haveBlueprint = true;
|
||||||
blueprintTt = blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], Modifications.modules[m.grp].blueprints[m.blueprint.fdname].grades[m.blueprint.grade].engineers, m.grp);
|
// console.log(haveBlueprint);
|
||||||
|
blueprintTt = blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], Modifications.modules[m.grp].blueprints[bprintSearchName].grades[m.blueprint.grade].engineers, m.grp);
|
||||||
blueprintCv = getPercent(m);
|
blueprintCv = getPercent(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,10 +307,22 @@ export function isChangeValueBeneficial(feature, value) {
|
|||||||
* @returns {Object} The matching blueprint
|
* @returns {Object} The matching blueprint
|
||||||
*/
|
*/
|
||||||
export function getBlueprint(name, module) {
|
export function getBlueprint(name, module) {
|
||||||
|
// Special case for multi-cannons. Conflicting 'Weapon_Overcharged' Blueprints exist due to FD's naming conventions. If this blueprint is for a multi-cannon, we need to use the correct blueprint.
|
||||||
|
if (name === 'weapon_overcharged') {
|
||||||
|
if (module.symbol.match(/MultiCannon/i)) {
|
||||||
|
name = 'mc_overcharged';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (name === 'Weapon_Overcharged') {
|
||||||
|
if (module.symbol.match(/MultiCannon/i)) {
|
||||||
|
name = 'MC_Overcharged';
|
||||||
|
}
|
||||||
|
}
|
||||||
// Start with a copy of the blueprint
|
// Start with a copy of the blueprint
|
||||||
const findMod = val => Object.keys(Modifications.blueprints).find(elem => elem.toString().toLowerCase().search(val.toString().toLowerCase().replace(/(OutfittingFieldType_|persecond)/igm, '')) >= 0);
|
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)];
|
const found = Modifications.blueprints[findMod(name)];
|
||||||
if (!found || !found.fdname) {
|
if (!found || !found.fdname) {
|
||||||
|
console.error('Blueprint not found:', name);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const blueprint = JSON.parse(JSON.stringify(found));
|
const blueprint = JSON.parse(JSON.stringify(found));
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let powerplant = _moduleFromFdName(module.Item);
|
let powerplant = _moduleFromFdName(module.Item);
|
||||||
// Check the powerplant returned is valid
|
// Check the powerplant returned is valid
|
||||||
if (!_isValidImportedModule(powerplant, 'powerplant'))
|
if (!_isValidImportedModule(powerplant, 'powerplant'))
|
||||||
{
|
{
|
||||||
powerplant = _moduleFromFdName('Int_Missing_Powerplant');
|
powerplant = _moduleFromFdName('Int_Missing_Powerplant');
|
||||||
module.Engineering = null;
|
module.Engineering = null;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let thrusters = _moduleFromFdName(module.Item);
|
let thrusters = _moduleFromFdName(module.Item);
|
||||||
// Check the thrusters returned is valid
|
// Check the thrusters returned is valid
|
||||||
if (!_isValidImportedModule(thrusters, 'thrusters'))
|
if (!_isValidImportedModule(thrusters, 'thrusters'))
|
||||||
{
|
{
|
||||||
thrusters = _moduleFromFdName('Int_Missing_Engine');
|
thrusters = _moduleFromFdName('Int_Missing_Engine');
|
||||||
module.Engineering = null;
|
module.Engineering = null;
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let frameshiftdrive = _moduleFromFdName(module.Item);
|
let frameshiftdrive = _moduleFromFdName(module.Item);
|
||||||
// Check the frameshiftdrive returned is valid
|
// Check the frameshiftdrive returned is valid
|
||||||
if (!_isValidImportedModule(frameshiftdrive, 'frameshiftdrive'))
|
if (!_isValidImportedModule(frameshiftdrive, 'frameshiftdrive'))
|
||||||
{
|
{
|
||||||
frameshiftdrive = _moduleFromFdName('Int_Missing_Hyperdrive');
|
frameshiftdrive = _moduleFromFdName('Int_Missing_Hyperdrive');
|
||||||
module.Engineering = null;
|
module.Engineering = null;
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let lifesupport = _moduleFromFdName(module.Item);
|
let lifesupport = _moduleFromFdName(module.Item);
|
||||||
// Check the lifesupport returned is valid
|
// Check the lifesupport returned is valid
|
||||||
if (!_isValidImportedModule(lifesupport, 'lifesupport'))
|
if (!_isValidImportedModule(lifesupport, 'lifesupport'))
|
||||||
{
|
{
|
||||||
lifesupport = _moduleFromFdName('Int_Missing_LifeSupport');
|
lifesupport = _moduleFromFdName('Int_Missing_LifeSupport');
|
||||||
module.Engineering = null;
|
module.Engineering = null;
|
||||||
}
|
}
|
||||||
@@ -169,8 +169,8 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let powerdistributor = _moduleFromFdName(module.Item);
|
let powerdistributor = _moduleFromFdName(module.Item);
|
||||||
// Check the powerdistributor returned is valid
|
// Check the powerdistributor returned is valid
|
||||||
if (!_isValidImportedModule(powerdistributor, 'powerdistributor'))
|
if (!_isValidImportedModule(powerdistributor, 'powerdistributor'))
|
||||||
{
|
{
|
||||||
powerdistributor = _moduleFromFdName('Int_Missing_PowerDistributor');
|
powerdistributor = _moduleFromFdName('Int_Missing_PowerDistributor');
|
||||||
module.Engineering = null;
|
module.Engineering = null;
|
||||||
}
|
}
|
||||||
ship.use(ship.standard[4], powerdistributor, true);
|
ship.use(ship.standard[4], powerdistributor, true);
|
||||||
@@ -182,7 +182,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let sensors = _moduleFromFdName(module.Item);
|
let sensors = _moduleFromFdName(module.Item);
|
||||||
// Check the sensors returned is valid
|
// Check the sensors returned is valid
|
||||||
if (!_isValidImportedModule(sensors, 'sensors'))
|
if (!_isValidImportedModule(sensors, 'sensors'))
|
||||||
{
|
{
|
||||||
sensors = _moduleFromFdName('Int_Missing_Sensors');
|
sensors = _moduleFromFdName('Int_Missing_Sensors');
|
||||||
module.Engineering = null;
|
module.Engineering = null;
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let fueltank = _moduleFromFdName(module.Item);
|
let fueltank = _moduleFromFdName(module.Item);
|
||||||
// Check the fueltank returned is valid
|
// Check the fueltank returned is valid
|
||||||
if (!_isValidImportedModule(fueltank, 'fueltank'))
|
if (!_isValidImportedModule(fueltank, 'fueltank'))
|
||||||
{
|
{
|
||||||
fueltank = _moduleFromFdName('Int_Missing_FuelTank');
|
fueltank = _moduleFromFdName('Int_Missing_FuelTank');
|
||||||
}
|
}
|
||||||
ship.use(ship.standard[6], fueltank, true);
|
ship.use(ship.standard[6], fueltank, true);
|
||||||
@@ -228,7 +228,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
} else {
|
} else {
|
||||||
hardpoint = _moduleFromFdName(hardpointSlot.Item);
|
hardpoint = _moduleFromFdName(hardpointSlot.Item);
|
||||||
// Check the hardpoint module returned is valid
|
// Check the hardpoint module returned is valid
|
||||||
if (!_isValidImportedModule(hardpoint, 'hardpoint')){
|
if (!_isValidImportedModule(hardpoint, 'hardpoint')){
|
||||||
// Check if it's a Utility or Hardpoint
|
// Check if it's a Utility or Hardpoint
|
||||||
if (hardpointSlot.Slot.toLowerCase().search(/tiny/))
|
if (hardpointSlot.Slot.toLowerCase().search(/tiny/))
|
||||||
{
|
{
|
||||||
@@ -293,12 +293,12 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
let internal = _moduleFromFdName(internalJson.Item);
|
let internal = _moduleFromFdName(internalJson.Item);
|
||||||
// Check the internal module returned is valid
|
// Check the internal module returned is valid
|
||||||
if (!_isValidImportedModule(internal, 'internal'))
|
if (!_isValidImportedModule(internal, 'internal'))
|
||||||
{
|
{
|
||||||
internal = _moduleFromFdName('Int_Missing_Module');
|
internal = _moduleFromFdName('Int_Missing_Module');
|
||||||
ship.use(ship.internal[i], internal, true);
|
ship.use(ship.internal[i], internal, true);
|
||||||
ship.internal[i].enabled = internalJson.On === true;
|
ship.internal[i].enabled = internalJson.On === true;
|
||||||
ship.internal[i].priority = internalJson.Priority;
|
ship.internal[i].priority = internalJson.Priority;
|
||||||
//throw 'Unknown internal module: "' + module.Item + '"';
|
//throw 'Unknown internal module: "' + module.Item + '"';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ship.use(ship.internal[i], internal, true);
|
ship.use(ship.internal[i], internal, true);
|
||||||
@@ -349,6 +349,7 @@ function _addModifications(module, modifiers, quality, blueprint, grade, special
|
|||||||
// Add the blueprint definition, grade and special
|
// Add the blueprint definition, grade and special
|
||||||
if (blueprint) {
|
if (blueprint) {
|
||||||
module.blueprint = getBlueprint(blueprint, module);
|
module.blueprint = getBlueprint(blueprint, module);
|
||||||
|
|
||||||
if (grade) {
|
if (grade) {
|
||||||
module.blueprint.grade = Number(grade);
|
module.blueprint.grade = Number(grade);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user