From 7d8a5a1368f1a205a33dd4e9e42a7087f7c7ec79 Mon Sep 17 00:00:00 2001 From: felixlinker Date: Sun, 19 May 2019 15:58:56 +0200 Subject: [PATCH] Clear original slot if an experimental is copied and exceeds the allowed number References #367 --- src/app/components/SlotSection.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/components/SlotSection.jsx b/src/app/components/SlotSection.jsx index 341fce36..55d1a7c0 100644 --- a/src/app/components/SlotSection.jsx +++ b/src/app/components/SlotSection.jsx @@ -195,6 +195,15 @@ export default class SlotSection extends TranslatedComponent { if (targetSlot && canMount(this.props.ship, targetSlot, m.grp, m.class)) { const mCopy = m.clone(); this.props.ship.use(targetSlot, mCopy, false); + let experimentalNum = this.props.ship.hardpoints + .filter(s => s.m && s.m.experimental).length; + // Remove the module on the last slot if we now exceed the number of + // experimentals allowed + if (m.experimental && 4 < experimentalNum) { + this.props.ship.updateStats(originSlot, null, originSlot.m); + originSlot.m = null; // Empty the slot + originSlot.discountedCost = 0; + } // Copy power info targetSlot.enabled = originSlot.enabled; targetSlot.priority = originSlot.priority;