import { useBackend } from '../backend';
import { Box, Button, ColorBox, Section, Table } from '../components';
import { COLORS } from '../constants';
const HEALTH_COLOR_BY_LEVEL = [
'#17d568',
'#2ecc71',
'#e67e22',
'#ed5100',
'#e74c3c',
'#ed2814',
];
const jobIsHead = jobId => jobId % 10 === 0;
const jobToColor = jobId => {
if (jobId === 0) {
return COLORS.department.captain;
}
if (jobId >= 10 && jobId < 20) {
return COLORS.department.security;
}
if (jobId >= 20 && jobId < 30) {
return COLORS.department.medbay;
}
if (jobId >= 30 && jobId < 40) {
return COLORS.department.science;
}
if (jobId >= 40 && jobId < 50) {
return COLORS.department.engineering;
}
if (jobId >= 50 && jobId < 60) {
return COLORS.department.cargo;
}
if (jobId >= 200 && jobId < 230) {
return COLORS.department.centcom;
}
return COLORS.department.other;
};
const healthToColor = (oxy, tox, burn, brute) => {
const healthSum = oxy + tox + burn + brute;
const level = Math.min(Math.max(Math.ceil(healthSum / 25), 0), 5);
return HEALTH_COLOR_BY_LEVEL[level];
};
const HealthStat = props => {
const { type, value } = props;
return (
{value}
);
};
export const CrewConsole = props => {
const { act, data } = useBackend(props);
const sensors = data.sensors || [];
return (
Name
Vitals
Position
{!!data.link_allowed && (
Tracking
)}
{sensors.map(sensor => (
{sensor.name} ({sensor.assignment})
{sensor.oxydam !== null ? (
{'/'}
{'/'}
{'/'}
) : (
sensor.life_status ? 'Alive' : 'Dead'
)}
{sensor.pos_x !== null ? sensor.area : 'N/A'}
{!!data.link_allowed && (
)}
))}
);
};