mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 15:15:34 +00:00
Handle fighter bays and luxury passenger cabins
This commit is contained in:
@@ -58,7 +58,7 @@ export default class InternalSlotSection extends SlotSection {
|
|||||||
let ship = this.props.ship;
|
let ship = this.props.ship;
|
||||||
let chargeCap = 0; // Capacity of single activation
|
let chargeCap = 0; // Capacity of single activation
|
||||||
ship.internal.forEach(function(slot) {
|
ship.internal.forEach(function(slot) {
|
||||||
if ((!slot.m || (clobber && !ModuleUtils.isShieldGenerator(slot.m.grp))) && (!slot.eligible || slot.eligible.scb)) { // Check eligibility due to Orca special case
|
if ((!slot.m || (clobber && !ModuleUtils.isShieldGenerator(slot.m.grp))) && (!slot.eligible || slot.eligible.scb)) { // Check eligibility due to passenger ships special case
|
||||||
ship.use(slot, ModuleUtils.findInternal('scb', slot.maxClass, 'A'));
|
ship.use(slot, ModuleUtils.findInternal('scb', slot.maxClass, 'A'));
|
||||||
ship.setSlotEnabled(slot, chargeCap <= ship.shieldStrength); // Don't waste cell capacity on overcharge
|
ship.setSlotEnabled(slot, chargeCap <= ship.shieldStrength); // Don't waste cell capacity on overcharge
|
||||||
chargeCap += slot.m.recharge;
|
chargeCap += slot.m.recharge;
|
||||||
@@ -108,7 +108,7 @@ export default class InternalSlotSection extends SlotSection {
|
|||||||
slots.push(<InternalSlot
|
slots.push(<InternalSlot
|
||||||
key={i}
|
key={i}
|
||||||
maxClass={s.maxClass}
|
maxClass={s.maxClass}
|
||||||
availableModules={() => availableModules.getInts(s.maxClass, s.eligible)}
|
availableModules={() => availableModules.getInts(ship, s.maxClass, s.eligible)}
|
||||||
onOpen={this._openMenu.bind(this,s)}
|
onOpen={this._openMenu.bind(this,s)}
|
||||||
onSelect={this._selectModule.bind(this, s)}
|
onSelect={this._selectModule.bind(this, s)}
|
||||||
selected={currentMenu == s}
|
selected={currentMenu == s}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export const terms = {
|
|||||||
cs: 'Cargo Scanner',
|
cs: 'Cargo Scanner',
|
||||||
dc: 'Docking Computer',
|
dc: 'Docking Computer',
|
||||||
fc: 'Fragment Cannon',
|
fc: 'Fragment Cannon',
|
||||||
|
fh: 'Fighter Hangar',
|
||||||
fi: 'FSD Interdictor',
|
fi: 'FSD Interdictor',
|
||||||
fs: 'Fuel Scoop',
|
fs: 'Fuel Scoop',
|
||||||
fsd: 'Frame Shift Drive',
|
fsd: 'Frame Shift Drive',
|
||||||
@@ -58,6 +59,10 @@ export const terms = {
|
|||||||
pa: 'Plasma Accelerator',
|
pa: 'Plasma Accelerator',
|
||||||
pas: 'Planetary Approach Suite',
|
pas: 'Planetary Approach Suite',
|
||||||
pc: 'Prospector Limpet Controller',
|
pc: 'Prospector Limpet Controller',
|
||||||
|
pce: 'Economy Class Passenger Cabin',
|
||||||
|
pci: 'Business Class Passenger Cabin',
|
||||||
|
pcm: 'First Class Passenger Cabin',
|
||||||
|
pcq: 'Luxury Passenger Cabin',
|
||||||
pd: 'power distributor',
|
pd: 'power distributor',
|
||||||
pl: 'Pulse Laser',
|
pl: 'Pulse Laser',
|
||||||
pp: 'Power Plant',
|
pp: 'Power Plant',
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export const ModuleGroupToName = {
|
|||||||
am: 'Auto Field-Maintenance Unit',
|
am: 'Auto Field-Maintenance Unit',
|
||||||
bsg: 'Bi-Weave Shield Generator',
|
bsg: 'Bi-Weave Shield Generator',
|
||||||
cr: 'Cargo Rack',
|
cr: 'Cargo Rack',
|
||||||
|
fh: 'Fighter Hangar',
|
||||||
fi: 'Frame Shift Drive Interdictor',
|
fi: 'Frame Shift Drive Interdictor',
|
||||||
hb: 'Hatch Breaker Limpet Controller',
|
hb: 'Hatch Breaker Limpet Controller',
|
||||||
hr: 'Hull Reinforcement Package',
|
hr: 'Hull Reinforcement Package',
|
||||||
@@ -48,6 +49,10 @@ export const ModuleGroupToName = {
|
|||||||
dc: 'Docking Computer',
|
dc: 'Docking Computer',
|
||||||
fx: 'Fuel Transfer Limpet Controller',
|
fx: 'Fuel Transfer Limpet Controller',
|
||||||
pc: 'Prospector Limpet Controller',
|
pc: 'Prospector Limpet Controller',
|
||||||
|
pce: 'Economy Class Passenger Cabin',
|
||||||
|
pci: 'Business Class Passenger Cabin',
|
||||||
|
pcm: 'First Class Passenger Cabin',
|
||||||
|
pcq: 'Luxury Passenger Cabin',
|
||||||
cc: 'Collector Limpet Controller',
|
cc: 'Collector Limpet Controller',
|
||||||
|
|
||||||
// Hard Points
|
// Hard Points
|
||||||
|
|||||||
@@ -71,16 +71,23 @@ export default class ModuleSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the modules that areeligible for an internal slot
|
* Determine the modules that areeligible for an internal slot
|
||||||
|
* @param {Object} ship The ship
|
||||||
* @param {integer} c The max class module that can be mounted in the slot
|
* @param {integer} c The max class module that can be mounted in the slot
|
||||||
* @param {Object} eligible) The map of eligible internal groups
|
* @param {Object} eligible) The map of eligible internal groups
|
||||||
* @return {object} A map of all eligible modules by group
|
* @return {object} A map of all eligible modules by group
|
||||||
*/
|
*/
|
||||||
getInts(c, eligible) {
|
getInts(ship, c, eligible) {
|
||||||
let o = {};
|
let o = {};
|
||||||
for (let key in this.internal) {
|
for (let key in this.internal) {
|
||||||
if (eligible && !eligible[key]) {
|
if (eligible && !eligible[key]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (key == 'pcq' && !(ship.luxuryCabins && ship.luxuryCabins === true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key == 'fh' && !(ship.fighterHangars && ship.fighterHangars === true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let data = filter(this.internal[key], c, 0, this.mass);
|
let data = filter(this.internal[key], c, 0, this.mass);
|
||||||
if (data.length) { // If group is not empty
|
if (data.length) { // If group is not empty
|
||||||
o[key] = data;
|
o[key] = data;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as Calc from './Calculations';
|
|||||||
import * as ModuleUtils from './ModuleUtils';
|
import * as ModuleUtils from './ModuleUtils';
|
||||||
import LZString from 'lz-string';
|
import LZString from 'lz-string';
|
||||||
|
|
||||||
const UNIQUE_MODULES = ['psg', 'sg', 'bsg', 'rf', 'fs'];
|
const UNIQUE_MODULES = ['psg', 'sg', 'bsg', 'rf', 'fs', 'fh'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the power usage type of a slot and it's particular modul
|
* Returns the power usage type of a slot and it's particular modul
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function multiPurpose(ship, shielded, bulkheadIndex) {
|
|||||||
|
|
||||||
if (shielded) {
|
if (shielded) {
|
||||||
ship.internal.some(function(slot) {
|
ship.internal.some(function(slot) {
|
||||||
if (canMount(slot, 'sg')) { // Assuming largest slot can hold an eligible shield
|
if (canMount(ship, slot, 'sg')) { // Assuming largest slot can hold an eligible shield
|
||||||
ship.use(slot, ModuleUtils.findInternal('sg', slot.maxClass, 'A'));
|
ship.use(slot, ModuleUtils.findInternal('sg', slot.maxClass, 'A'));
|
||||||
ship.setSlotEnabled(slot, true);
|
ship.setSlotEnabled(slot, true);
|
||||||
return true;
|
return true;
|
||||||
@@ -35,7 +35,7 @@ export function trader(ship, shielded, standardOpts) {
|
|||||||
|
|
||||||
for (let i = ship.internal.length; i--;) {
|
for (let i = ship.internal.length; i--;) {
|
||||||
let slot = ship.internal[i];
|
let slot = ship.internal[i];
|
||||||
if (sg && canMount(slot, 'sg', sg.class)) {
|
if (sg && canMount(ship, slot, 'sg', sg.class)) {
|
||||||
ship.use(slot, sg);
|
ship.use(slot, sg);
|
||||||
sg = null;
|
sg = null;
|
||||||
} else {
|
} else {
|
||||||
@@ -77,23 +77,23 @@ export function explorer(ship, planetary) {
|
|||||||
let slot = ship.internal[i];
|
let slot = ship.internal[i];
|
||||||
let nextSlot = (i + 1) < intLength ? ship.internal[i + 1] : null;
|
let nextSlot = (i + 1) < intLength ? ship.internal[i + 1] : null;
|
||||||
// Fit best possible Fuel Scoop
|
// Fit best possible Fuel Scoop
|
||||||
if (!fuelScoopSlot && canMount(slot, 'fs')) {
|
if (!fuelScoopSlot && canMount(ship, slot, 'fs')) {
|
||||||
fuelScoopSlot = slot;
|
fuelScoopSlot = slot;
|
||||||
ship.use(slot, ModuleUtils.findInternal('fs', slot.maxClass, 'A'));
|
ship.use(slot, ModuleUtils.findInternal('fs', slot.maxClass, 'A'));
|
||||||
ship.setSlotEnabled(slot, true);
|
ship.setSlotEnabled(slot, true);
|
||||||
// Mount a Shield generator if possible AND an AFM Unit has been mounted already (Guarantees at least 1 AFM Unit)
|
// Mount a Shield generator if possible AND an AFM Unit has been mounted already (Guarantees at least 1 AFM Unit)
|
||||||
} else if (!sgSlot && shieldNext && canMount(slot, 'sg', sg.class) && !canMount(nextSlot, 'sg', sg.class)) {
|
} else if (!sgSlot && shieldNext && canMount(ship, slot, 'sg', sg.class) && !canMount(ship, nextSlot, 'sg', sg.class)) {
|
||||||
sgSlot = slot;
|
sgSlot = slot;
|
||||||
shieldNext = false;
|
shieldNext = false;
|
||||||
ship.use(slot, sg);
|
ship.use(slot, sg);
|
||||||
ship.setSlotEnabled(slot, true);
|
ship.setSlotEnabled(slot, true);
|
||||||
// if planetary explorer and the next slot cannot mount a PVH or the next modul to mount is a SG
|
// if planetary explorer and the next slot cannot mount a PVH or the next modul to mount is a SG
|
||||||
} else if (planetary && !pvhSlot && canMount(slot, 'pv') && (shieldNext || !canMount(nextSlot, 'pv', 2))) {
|
} else if (planetary && !pvhSlot && canMount(ship, slot, 'pv') && (shieldNext || !canMount(ship, nextSlot, 'pv', 2))) {
|
||||||
pvhSlot = slot;
|
pvhSlot = slot;
|
||||||
ship.use(slot, ModuleUtils.findInternal('pv', Math.min(Math.floor(pvhSlot.maxClass / 2) * 2, 6), 'G'));
|
ship.use(slot, ModuleUtils.findInternal('pv', Math.min(Math.floor(pvhSlot.maxClass / 2) * 2, 6), 'G'));
|
||||||
ship.setSlotEnabled(slot, false); // Disabled power for PVH
|
ship.setSlotEnabled(slot, false); // Disabled power for PVH
|
||||||
shieldNext = !sgSlot;
|
shieldNext = !sgSlot;
|
||||||
} else if (afmUnitCount > 0 && canMount(slot, 'am')) {
|
} else if (afmUnitCount > 0 && canMount(ship, slot, 'am')) {
|
||||||
afmUnitCount--;
|
afmUnitCount--;
|
||||||
ship.use(slot, ModuleUtils.findInternal('am', slot.maxClass, 'A'));
|
ship.use(slot, ModuleUtils.findInternal('am', slot.maxClass, 'A'));
|
||||||
ship.setSlotEnabled(slot, false); // Disabled power for AFM Unit
|
ship.setSlotEnabled(slot, false); // Disabled power for AFM Unit
|
||||||
|
|||||||
@@ -5,14 +5,19 @@ import { Infinite } from '../components/SvgIcons';
|
|||||||
import Persist from '../stores/Persist';
|
import Persist from '../stores/Persist';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a slot can mount a module of a particular class and group
|
* Determine if a slot on a ship can mount a module of a particular class and group
|
||||||
|
* @param {Object} ship Ship object
|
||||||
* @param {Object} slot Slot object
|
* @param {Object} slot Slot object
|
||||||
* @param {String} group Module group/type abbrivation/code
|
* @param {String} group Module group/type abbrivation/code
|
||||||
* @param {Integer} clazz [Optional] Module Class/Size
|
* @param {Integer} clazz [Optional] Module Class/Size
|
||||||
* @return {Boolean} True if the slot can mount the module
|
* @return {Boolean} True if the slot can mount the module
|
||||||
*/
|
*/
|
||||||
export function canMount(slot, group, clazz) {
|
export function canMount(ship, slot, group, clazz) {
|
||||||
if (slot && (!slot.eligible || slot.eligible[group]) && (clazz === undefined || slot.maxClass >= clazz)) {
|
if (slot
|
||||||
|
&& (!slot.eligible || slot.eligible[group])
|
||||||
|
&& (group != 'pcq' || (ship.luxuryCabins && ship.luxuryCabins === true))
|
||||||
|
&& (group != 'fh' || (ship.fighterHangars && ship.fighterHangars === true))
|
||||||
|
&& (clazz === undefined || slot.maxClass >= clazz)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user