import { Fragment } from 'inferno';
import { useBackend } from '../backend';
import { Box, Button, Dimmer, Flex, Icon, Knob, LabeledList, ProgressBar, Section, Tabs } from '../components';
import { Window } from '../layouts';
import { ComplexModal } from './common/ComplexModal';
const stats = [
['good', 'Alive'],
['average', 'Unconscious'],
['bad', 'DEAD'],
];
const operations = [
['ui', 'Modify U.I.', 'dna'],
['se', 'Modify S.E.', 'dna'],
['buffer', 'Transfer Buffers', 'syringe'],
['rejuvenators', 'Rejuvenators', 'flask'],
];
const rejuvenatorsDoses = [5, 10, 20, 30, 50];
export const DNAModifier = (props, context) => {
const { act, data } = useBackend(context);
const { irradiating, dnaBlockSize, occupant } = data;
context.dnaBlockSize = dnaBlockSize;
context.isDNAInvalid = !occupant.isViableSubject || !occupant.uniqueIdentity || !occupant.structuralEnzymes;
let radiatingModal;
if (irradiating) {
radiatingModal = ;
}
return (
{radiatingModal}
);
};
const DNAModifierOccupant = (props, context) => {
const { act, data } = useBackend(context);
const { locked, hasOccupant, occupant } = data;
return (
Door Lock:
);
};
const DNAModifierMain = (props, context) => {
const { act, data } = useBackend(context);
const { selectedMenuKey, hasOccupant, occupant } = data;
if (!hasOccupant) {
return (
No occupant in DNA modifier.
);
} else if (context.isDNAInvalid) {
return (
No operation possible on this subject.
);
}
let body;
if (selectedMenuKey === 'ui') {
body = (
);
} else if (selectedMenuKey === 'se') {
body = (
);
} else if (selectedMenuKey === 'buffer') {
body = ;
} else if (selectedMenuKey === 'rejuvenators') {
body = ;
}
return (
{operations.map((op, i) => (
act('selectMenuKey', { key: op[0] })}>
{op[1]}
))}
{body}
);
};
const DNAModifierMainUI = (props, context) => {
const { act, data } = useBackend(context);
const { selectedUIBlock, selectedUISubBlock, selectedUITarget, occupant } = data;
return (
value.toString(16).toUpperCase()}
ml="0"
onChange={(e, val) => act('changeUITarget', { value: val })}
/>
act('pulseUIRadiation')} />
);
};
const DNAModifierMainSE = (props, context) => {
const { act, data } = useBackend(context);
const { selectedSEBlock, selectedSESubBlock, occupant } = data;
return (
act('pulseSERadiation')} />
);
};
const DNAModifierMainRadiationEmitter = (props, context) => {
const { act, data } = useBackend(context);
const { radiationIntensity, radiationDuration } = data;
return (
act('radiationIntensity', { value: val })}
/>
act('radiationDuration', { value: val })}
/>
act('pulseRadiation')}
/>
);
};
const DNAModifierMainBuffers = (props, context) => {
const { act, data } = useBackend(context);
const { buffers } = data;
let bufferElements = buffers.map((buffer, i) => (
));
return (
);
};
const DNAModifierMainBuffersElement = (props, context) => {
const { act, data } = useBackend(context);
const { id, name, buffer } = props;
const isInjectorReady = data.isInjectorReady;
const realName = name + (buffer.data ? ' - ' + buffer.label : '');
return (
act('bufferOption', {
option: 'clear',
id: id,
})
}
/>
act('bufferOption', {
option: 'changeLabel',
id: id,
})
}
/>
act('bufferOption', {
option: 'saveDisk',
id: id,
})
}
/>
}>
act('bufferOption', {
option: 'saveUI',
id: id,
})
}
/>
act('bufferOption', {
option: 'saveUIAndUE',
id: id,
})
}
/>
act('bufferOption', {
option: 'saveSE',
id: id,
})
}
/>
act('bufferOption', {
option: 'loadDisk',
id: id,
})
}
/>
{buffer.data ? (
{buffer.owner || Unknown}
{buffer.type === 'ui' ? 'Unique Identifiers' : 'Structural Enzymes'}
{!!buffer.ue && ' and Unique Enzymes'}
act('bufferOption', {
option: 'createInjector',
id: id,
})
}
/>
act('bufferOption', {
option: 'createInjector',
id: id,
block: 1,
})
}
/>
act('bufferOption', {
option: 'transfer',
id: id,
})
}
/>
) : null}
{!buffer.data && (
This buffer is empty.
)}
);
};
const DNAModifierMainBuffersDisk = (props, context) => {
const { act, data } = useBackend(context);
const { hasDisk, disk } = data;
return (
act('wipeDisk')}
/>
act('ejectDisk')} />
}>
{hasDisk ? (
disk.data ? (
{disk.label ? disk.label : 'No label'}
{disk.owner ? disk.owner : Unknown}
{disk.type === 'ui' ? 'Unique Identifiers' : 'Structural Enzymes'}
{!!disk.ue && ' and Unique Enzymes'}
) : (
Disk is blank.
)
) : (
No disk inserted.
)}
);
};
const DNAModifierMainRejuvenators = (props, context) => {
const { act, data } = useBackend(context);
const { isBeakerLoaded, beakerVolume, beakerLabel } = data;
return (
act('ejectBeaker')} />}>
{isBeakerLoaded ? (
{rejuvenatorsDoses.map((a, i) => (
beakerVolume}
icon="syringe"
content={a}
onClick={() =>
act('injectRejuvenators', {
amount: a,
})
}
/>
))}
act('injectRejuvenators', {
amount: beakerVolume,
})
}
/>
{beakerLabel ? beakerLabel : 'No label'}
{beakerVolume ? (
{beakerVolume} unit{beakerVolume === 1 ? '' : 's'} remaining
) : (
Empty
)}
) : (
No beaker loaded.
)}
);
};
const DNAModifierIrradiating = (props, context) => {
return (
Irradiating occupant
For {props.duration} second{props.duration === 1 ? '' : 's'}
);
};
const DNAModifierBlocks = (props, context) => {
const { act, data } = useBackend(context);
const { dnaString, selectedBlock, selectedSubblock, blockSize, action } = props;
const characters = dnaString.split('');
let curBlock = 0;
let dnaBlocks = [];
for (let block = 0; block < characters.length; block += blockSize) {
const realBlock = block / blockSize + 1;
let subBlocks = [];
for (let subblock = 0; subblock < blockSize; subblock++) {
const realSubblock = subblock + 1;
subBlocks.push(
act(action, {
block: realBlock,
subblock: realSubblock,
})
}
/>
);
}
dnaBlocks.push(
{realBlock}
{subBlocks}
);
}
return {dnaBlocks};
};