mirror of
https://github.com/calli-eve/eve-pi.git
synced 2026-02-15 20:19:51 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00a06a9681 | ||
|
|
ac56adbcbe | ||
|
|
a738dc4a22 | ||
|
|
efc28f7e36 |
@@ -3,8 +3,6 @@ import { planetCalculations } from "@/planets";
|
|||||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
Checkbox,
|
|
||||||
FormControlLabel,
|
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
TableCell,
|
TableCell,
|
||||||
@@ -20,12 +18,6 @@ import Image from "next/image";
|
|||||||
import { ColorContext, SessionContext } from "@/app/context/Context";
|
import { ColorContext, SessionContext } from "@/app/context/Context";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
|
|
||||||
export type PlanetConfig = {
|
|
||||||
characterId: number;
|
|
||||||
planetId: number;
|
|
||||||
excludeFromTotals: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const PlanetConfigDialog = ({
|
export const PlanetConfigDialog = ({
|
||||||
planet,
|
planet,
|
||||||
character,
|
character,
|
||||||
@@ -35,14 +27,9 @@ export const PlanetConfigDialog = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { colors } = useContext(ColorContext);
|
const { colors } = useContext(ColorContext);
|
||||||
const { piPrices, readPlanetConfig, updatePlanetConfig } =
|
const { piPrices } = useContext(SessionContext);
|
||||||
useContext(SessionContext);
|
|
||||||
const { extractors, localProduction, localImports, localExports } =
|
const { extractors, localProduction, localImports, localExports } =
|
||||||
planetCalculations(planet);
|
planetCalculations(planet);
|
||||||
const planetConfig = readPlanetConfig({
|
|
||||||
characterId: character.character.characterId,
|
|
||||||
planetId: planet.planet_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card style={{ padding: "1rem", margin: "1rem" }}>
|
<Card style={{ padding: "1rem", margin: "1rem" }}>
|
||||||
@@ -189,23 +176,6 @@ export const PlanetConfigDialog = ({
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
<Card style={{ marginTop: "1rem" }}>
|
|
||||||
<Typography>Planet configuration</Typography>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={planetConfig.excludeFromTotals}
|
|
||||||
onChange={() =>
|
|
||||||
updatePlanetConfig({
|
|
||||||
...planetConfig,
|
|
||||||
excludeFromTotals: !planetConfig.excludeFromTotals,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Consumed by production chain"
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export interface ProductionNode {
|
|||||||
quantity: number;
|
quantity: number;
|
||||||
}>;
|
}>;
|
||||||
cycleTime: number;
|
cycleTime: number;
|
||||||
|
factoryCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProductionChainBalance {
|
export interface ProductionChainBalance {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Paper, Typography, Stack } from '@mui/material';
|
import { Box, Paper, Typography, Stack } from '@mui/material';
|
||||||
import { Line } from 'react-chartjs-2';
|
import { Line } from 'react-chartjs-2';
|
||||||
import { useTheme } from '@mui/material';
|
|
||||||
import { getProgramOutputPrediction, ProductionNode } from './ExtractionSimulation';
|
import { getProgramOutputPrediction, ProductionNode } from './ExtractionSimulation';
|
||||||
import { PI_TYPES_MAP } from '@/const';
|
import { PI_TYPES_MAP } from '@/const';
|
||||||
import { ProductionChainVisualization } from './ProductionChainVisualization';
|
import { ProductionChainVisualization } from './ProductionChainVisualization';
|
||||||
@@ -15,6 +14,8 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
Legend
|
Legend
|
||||||
} from 'chart.js';
|
} from 'chart.js';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
import Countdown from 'react-countdown';
|
||||||
|
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
@@ -43,6 +44,7 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
|||||||
extractors,
|
extractors,
|
||||||
productionNodes
|
productionNodes
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
|
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
|
||||||
|
|
||||||
// Calculate program duration and cycles for each extractor
|
// Calculate program duration and cycles for each extractor
|
||||||
@@ -57,6 +59,7 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const maxCycles = Math.max(...extractorPrograms.map(e => e.cycles));
|
const maxCycles = Math.max(...extractorPrograms.map(e => e.cycles));
|
||||||
|
|
||||||
// Get output predictions for each extractor
|
// Get output predictions for each extractor
|
||||||
@@ -156,10 +159,14 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
|||||||
const installedSchematicIds = Array.from(new Set(productionNodes.map(node => node.schematicId)));
|
const installedSchematicIds = Array.from(new Set(productionNodes.map(node => node.schematicId)));
|
||||||
|
|
||||||
// Create factories array with correct counts
|
// Create factories array with correct counts
|
||||||
const factories = installedSchematicIds.map(schematicId => ({
|
const factories = installedSchematicIds.map(schematicId => {
|
||||||
schematic_id: schematicId,
|
const node = productionNodes.find(n => n.schematicId === schematicId);
|
||||||
count: productionNodes.filter(node => node.schematicId === schematicId).length
|
if (!node) return { schematic_id: schematicId, count: 0 };
|
||||||
}));
|
return {
|
||||||
|
schematic_id: schematicId,
|
||||||
|
count: node.factoryCount
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@@ -191,6 +198,12 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
|||||||
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
|
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
|
||||||
• Expiry Time: {new Date(expiryTime).toLocaleString()}
|
• Expiry Time: {new Date(expiryTime).toLocaleString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
|
||||||
|
• Factory Count: {factories.find(f => f.schematic_id === typeId)?.count ?? 0}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
|
||||||
|
• Expires in: <Countdown overtime={true} date={DateTime.fromISO(expiryTime).toMillis()} />
|
||||||
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
@@ -204,7 +217,8 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
|||||||
extractors={extractors.map(e => ({
|
extractors={extractors.map(e => ({
|
||||||
typeId: e.typeId,
|
typeId: e.typeId,
|
||||||
baseValue: e.baseValue,
|
baseValue: e.baseValue,
|
||||||
cycleTime: CYCLE_TIME
|
cycleTime: CYCLE_TIME,
|
||||||
|
expiryTime: e.expiryTime
|
||||||
}))}
|
}))}
|
||||||
factories={factories}
|
factories={factories}
|
||||||
extractorTotals={extractorTotals}
|
extractorTotals={extractorTotals}
|
||||||
|
|||||||
@@ -0,0 +1,207 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Box, Paper, Typography, Stack } from '@mui/material';
|
||||||
|
import { Line } from 'react-chartjs-2';
|
||||||
|
import { getProgramOutputPrediction } from './ExtractionSimulation';
|
||||||
|
import { PI_TYPES_MAP } from '@/const';
|
||||||
|
import {
|
||||||
|
Chart as ChartJS,
|
||||||
|
CategoryScale,
|
||||||
|
LinearScale,
|
||||||
|
PointElement,
|
||||||
|
LineElement,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
Legend
|
||||||
|
} from 'chart.js';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
import Countdown from 'react-countdown';
|
||||||
|
|
||||||
|
ChartJS.register(
|
||||||
|
CategoryScale,
|
||||||
|
LinearScale,
|
||||||
|
PointElement,
|
||||||
|
LineElement,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
Legend
|
||||||
|
);
|
||||||
|
|
||||||
|
interface ExtractorConfig {
|
||||||
|
typeId: number;
|
||||||
|
baseValue: number;
|
||||||
|
cycleTime: number;
|
||||||
|
installTime: string;
|
||||||
|
expiryTime: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ExtractionSimulationTooltipProps {
|
||||||
|
extractors: ExtractorConfig[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ExtractionSimulationTooltip: React.FC<ExtractionSimulationTooltipProps> = ({
|
||||||
|
extractors
|
||||||
|
}) => {
|
||||||
|
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
|
||||||
|
|
||||||
|
// Calculate program duration and cycles for each extractor
|
||||||
|
const extractorPrograms = extractors.map(extractor => {
|
||||||
|
const installDate = new Date(extractor.installTime);
|
||||||
|
const expiryDate = new Date(extractor.expiryTime);
|
||||||
|
const programDuration = (expiryDate.getTime() - installDate.getTime()) / 1000; // Convert to seconds
|
||||||
|
return {
|
||||||
|
...extractor,
|
||||||
|
programDuration,
|
||||||
|
cycles: Math.floor(programDuration / CYCLE_TIME)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const maxCycles = Math.max(...extractorPrograms.map(e => e.cycles));
|
||||||
|
|
||||||
|
// Get output predictions for each extractor
|
||||||
|
const extractorOutputs = extractorPrograms.map(extractor => ({
|
||||||
|
typeId: extractor.typeId,
|
||||||
|
cycleTime: CYCLE_TIME,
|
||||||
|
cycles: extractor.cycles,
|
||||||
|
prediction: getProgramOutputPrediction(
|
||||||
|
extractor.baseValue,
|
||||||
|
CYCLE_TIME,
|
||||||
|
extractor.cycles
|
||||||
|
)
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Create datasets for the chart
|
||||||
|
const datasets = extractorOutputs.map((output, index) => {
|
||||||
|
const hue = (360 / extractors.length) * index;
|
||||||
|
return {
|
||||||
|
label: `${PI_TYPES_MAP[output.typeId]?.name ?? `Resource ${output.typeId}`}`,
|
||||||
|
data: output.prediction,
|
||||||
|
borderColor: `hsl(${hue}, 70%, 50%)`,
|
||||||
|
backgroundColor: `hsl(${hue}, 70%, 80%)`,
|
||||||
|
tension: 0.4
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const chartData = {
|
||||||
|
labels: Array.from({ length: maxCycles }, (_, i) => {
|
||||||
|
return (i % 4 === 0) ? `Cycle ${i + 1}` : '';
|
||||||
|
}),
|
||||||
|
datasets
|
||||||
|
};
|
||||||
|
|
||||||
|
const chartOptions = {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
position: 'top' as const,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Extraction Output Prediction'
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
title: (context: any) => `Cycle ${context[0].dataIndex + 1}`,
|
||||||
|
label: (context: any) => `Output: ${context.raw.toFixed(1)} units`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true,
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Units per Cycle'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
x: {
|
||||||
|
ticks: {
|
||||||
|
autoSkip: true,
|
||||||
|
maxTicksLimit: 24
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper sx={{ p: 1, bgcolor: 'background.paper', minWidth: 800 }}>
|
||||||
|
<Stack direction="row" spacing={2} sx={{ width: '100%' }}>
|
||||||
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<div style={{ height: '200px' }}>
|
||||||
|
<Line data={chartData} options={chartOptions} />
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<Stack spacing={1}>
|
||||||
|
{extractorPrograms.map(({ typeId, cycleTime, cycles, installTime, expiryTime }) => {
|
||||||
|
const prediction = getProgramOutputPrediction(
|
||||||
|
extractors.find(e => e.typeId === typeId)?.baseValue || 0,
|
||||||
|
CYCLE_TIME,
|
||||||
|
cycles
|
||||||
|
);
|
||||||
|
const totalOutput = prediction.reduce((sum, val) => sum + val, 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper key={typeId} sx={{ p: 1, bgcolor: 'background.default' }}>
|
||||||
|
<Typography variant="subtitle2">
|
||||||
|
{PI_TYPES_MAP[typeId]?.name}
|
||||||
|
</Typography>
|
||||||
|
<Stack spacing={0.5}>
|
||||||
|
<Typography variant="body2">
|
||||||
|
• Total Output: {totalOutput.toFixed(1)} units per program
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">
|
||||||
|
• Cycle Time: {(cycleTime / 60).toFixed(1)} minutes
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">
|
||||||
|
• Program Cycles: {cycles}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">
|
||||||
|
• Average per Cycle: {(totalOutput / cycles).toFixed(1)} units
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">
|
||||||
|
• Expires in: <Countdown overtime={true} date={DateTime.fromISO(expiryTime).toMillis()} />
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{extractors.length === 2 && (
|
||||||
|
<Paper sx={{ p: 1, bgcolor: 'background.default' }}>
|
||||||
|
<Typography variant="subtitle2" color="error">
|
||||||
|
Balance
|
||||||
|
</Typography>
|
||||||
|
<Stack spacing={0.5}>
|
||||||
|
{extractors.map((extractor, index) => {
|
||||||
|
const averagePerHour = (extractor.baseValue * 3600) / extractor.cycleTime;
|
||||||
|
return (
|
||||||
|
<Typography key={index} variant="body2">
|
||||||
|
• {PI_TYPES_MAP[extractor.typeId]?.name}: {averagePerHour.toFixed(1)} u/h
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
color="error"
|
||||||
|
sx={{
|
||||||
|
mt: 1,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
borderTop: '1px solid',
|
||||||
|
borderColor: 'divider',
|
||||||
|
pt: 1
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Difference: {Math.abs(
|
||||||
|
(extractors[0].baseValue * 3600 / extractors[0].cycleTime) -
|
||||||
|
(extractors[1].baseValue * 3600 / extractors[1].cycleTime)
|
||||||
|
).toFixed(1)} u/h
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -4,7 +4,7 @@ import { planetCalculations } from "@/planets";
|
|||||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
||||||
import { Button, Tooltip, Typography, useTheme, Menu, MenuItem, IconButton } from "@mui/material";
|
import { Button, Tooltip, Typography, useTheme, Menu, MenuItem, IconButton, Checkbox, FormControlLabel } from "@mui/material";
|
||||||
import AppBar from "@mui/material/AppBar";
|
import AppBar from "@mui/material/AppBar";
|
||||||
import Dialog from "@mui/material/Dialog";
|
import Dialog from "@mui/material/Dialog";
|
||||||
import Slide from "@mui/material/Slide";
|
import Slide from "@mui/material/Slide";
|
||||||
@@ -20,6 +20,7 @@ import { PlanetConfigDialog } from "../PlanetConfig/PlanetConfigDialog";
|
|||||||
import PinsCanvas3D from "./PinsCanvas3D";
|
import PinsCanvas3D from "./PinsCanvas3D";
|
||||||
import { alertModeVisibility, timeColor } from "./timeColors";
|
import { alertModeVisibility, timeColor } from "./timeColors";
|
||||||
import { ExtractionSimulationDisplay } from './ExtractionSimulationDisplay';
|
import { ExtractionSimulationDisplay } from './ExtractionSimulationDisplay';
|
||||||
|
import { ExtractionSimulationTooltip } from './ExtractionSimulationTooltip';
|
||||||
import { ProductionNode } from './ExtractionSimulation';
|
import { ProductionNode } from './ExtractionSimulation';
|
||||||
import { Collapse, Box, Stack } from "@mui/material";
|
import { Collapse, Box, Stack } from "@mui/material";
|
||||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||||
@@ -72,14 +73,15 @@ export const PlanetTableRow = ({
|
|||||||
setPlanetConfigOpen(false);
|
setPlanetConfigOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { piPrices, alertMode } = useContext(SessionContext);
|
const { piPrices, alertMode, updatePlanetConfig, readPlanetConfig, balanceThreshold } = useContext(SessionContext);
|
||||||
const planetInfo = planet.info;
|
const planetInfo = planet.info;
|
||||||
const planetInfoUniverse = planet.infoUniverse;
|
const planetInfoUniverse = planet.infoUniverse;
|
||||||
const { expired, extractors, localProduction, localImports, localExports } =
|
const { expired, extractors, localProduction, localImports, localExports } =
|
||||||
planetCalculations(planet);
|
planetCalculations(planet);
|
||||||
const planetConfig = character.planetConfig.find(
|
const planetConfig = readPlanetConfig({
|
||||||
(p) => p.planetId === planet.planet_id,
|
characterId: character.character.characterId,
|
||||||
);
|
planetId: planet.planet_id,
|
||||||
|
});
|
||||||
const { colors } = useContext(ColorContext);
|
const { colors } = useContext(ColorContext);
|
||||||
// Convert local production to ProductionNode array for simulation
|
// Convert local production to ProductionNode array for simulation
|
||||||
const productionNodes: ProductionNode[] = Array.from(localProduction).map(([schematicId, schematic]) => ({
|
const productionNodes: ProductionNode[] = Array.from(localProduction).map(([schematicId, schematic]) => ({
|
||||||
@@ -94,9 +96,25 @@ export const PlanetTableRow = ({
|
|||||||
typeId: output.type_id,
|
typeId: output.type_id,
|
||||||
quantity: output.quantity
|
quantity: output.quantity
|
||||||
})),
|
})),
|
||||||
cycleTime: schematic.cycle_time
|
cycleTime: schematic.cycle_time,
|
||||||
|
factoryCount: schematic.count || 1
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Calculate extractor averages and check for large differences
|
||||||
|
const extractorAverages = extractors
|
||||||
|
.filter(e => e.extractor_details?.product_type_id && e.extractor_details?.qty_per_cycle)
|
||||||
|
.map(e => {
|
||||||
|
const cycleTime = e.extractor_details?.cycle_time || 3600;
|
||||||
|
const qtyPerCycle = e.extractor_details?.qty_per_cycle || 0;
|
||||||
|
return {
|
||||||
|
typeId: e.extractor_details!.product_type_id!,
|
||||||
|
averagePerHour: (qtyPerCycle * 3600) / cycleTime
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasLargeExtractorDifference = extractorAverages.length === 2 &&
|
||||||
|
Math.abs(extractorAverages[0].averagePerHour - extractorAverages[1].averagePerHour) > balanceThreshold;
|
||||||
|
|
||||||
const storageFacilities = planetInfo.pins.filter(pin =>
|
const storageFacilities = planetInfo.pins.filter(pin =>
|
||||||
STORAGE_IDS().some(storage => storage.type_id === pin.type_id)
|
STORAGE_IDS().some(storage => storage.type_id === pin.type_id)
|
||||||
);
|
);
|
||||||
@@ -130,6 +148,13 @@ export const PlanetTableRow = ({
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleExcludeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
updatePlanetConfig({
|
||||||
|
...planetConfig,
|
||||||
|
excludeFromTotals: event.target.checked,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TableRow
|
<TableRow
|
||||||
@@ -151,7 +176,52 @@ export const PlanetTableRow = ({
|
|||||||
height={theme.custom.cardImageSize / 6}
|
height={theme.custom.cardImageSize / 6}
|
||||||
style={{ marginRight: "5px" }}
|
style={{ marginRight: "5px" }}
|
||||||
/>
|
/>
|
||||||
{planetInfoUniverse?.name}
|
<Tooltip
|
||||||
|
placement="right"
|
||||||
|
title={
|
||||||
|
<ExtractionSimulationTooltip
|
||||||
|
extractors={extractors
|
||||||
|
.filter(e => e.extractor_details?.product_type_id && e.extractor_details?.qty_per_cycle)
|
||||||
|
.map(e => ({
|
||||||
|
typeId: e.extractor_details!.product_type_id!,
|
||||||
|
baseValue: e.extractor_details!.qty_per_cycle!,
|
||||||
|
cycleTime: e.extractor_details!.cycle_time || 3600,
|
||||||
|
installTime: e.install_time ?? "",
|
||||||
|
expiryTime: e.expiry_time ?? ""
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
componentsProps={{
|
||||||
|
tooltip: {
|
||||||
|
sx: {
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
'& .MuiTooltip-arrow': {
|
||||||
|
color: 'background.paper',
|
||||||
|
},
|
||||||
|
maxWidth: 'none',
|
||||||
|
width: 'fit-content'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack spacing={0}>
|
||||||
|
<Typography
|
||||||
|
fontSize={theme.custom.smallText}
|
||||||
|
color={hasLargeExtractorDifference ? 'error' : 'inherit'}
|
||||||
|
>
|
||||||
|
{planetInfoUniverse?.name}
|
||||||
|
</Typography>
|
||||||
|
{hasLargeExtractorDifference && (
|
||||||
|
<Typography
|
||||||
|
fontSize={theme.custom.smallText}
|
||||||
|
color="error"
|
||||||
|
sx={{ opacity: 0.7 }}
|
||||||
|
>
|
||||||
|
off-balance
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
@@ -230,12 +300,17 @@ export const PlanetTableRow = ({
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||||
{localExports.map((exports) => (
|
{localExports.map((exports) => (
|
||||||
<Typography
|
<FormControlLabel
|
||||||
key={`export-excluded-${character.character.characterId}-${planet.planet_id}-${exports.typeId}`}
|
key={`export-excluded-${character.character.characterId}-${planet.planet_id}-${exports.typeId}`}
|
||||||
fontSize={theme.custom.smallText}
|
control={
|
||||||
>
|
<Checkbox
|
||||||
{planetConfig?.excludeFromTotals ? "ex" : ""}
|
checked={planetConfig.excludeFromTotals}
|
||||||
</Typography>
|
onChange={handleExcludeChange}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label=""
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Paper, Typography, Grid, Stack, Divider } from '@mui/material';
|
import { Box, Paper, Typography, Grid, Stack, Divider, Tooltip } from '@mui/material';
|
||||||
import { EVE_IMAGE_URL } from '@/const';
|
import { EVE_IMAGE_URL } from '@/const';
|
||||||
import { PI_TYPES_MAP } from '@/const';
|
import { PI_TYPES_MAP } from '@/const';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
import Countdown from 'react-countdown';
|
||||||
|
|
||||||
interface Factory {
|
interface Factory {
|
||||||
schematic_id: number;
|
schematic_id: number;
|
||||||
@@ -29,6 +31,7 @@ interface ProductionChainVisualizationProps {
|
|||||||
typeId: number;
|
typeId: number;
|
||||||
baseValue: number;
|
baseValue: number;
|
||||||
cycleTime: number;
|
cycleTime: number;
|
||||||
|
expiryTime: string;
|
||||||
}>;
|
}>;
|
||||||
factories: Factory[];
|
factories: Factory[];
|
||||||
extractorTotals: Map<number, number>;
|
extractorTotals: Map<number, number>;
|
||||||
@@ -39,8 +42,10 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
|||||||
extractedTypeIds,
|
extractedTypeIds,
|
||||||
factories,
|
factories,
|
||||||
extractorTotals,
|
extractorTotals,
|
||||||
productionNodes
|
productionNodes,
|
||||||
|
extractors
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
// Get all type IDs involved in the production chain
|
// Get all type IDs involved in the production chain
|
||||||
const allTypeIds = new Set<number>();
|
const allTypeIds = new Set<number>();
|
||||||
const requiredInputs = new Set<number>();
|
const requiredInputs = new Set<number>();
|
||||||
@@ -214,9 +219,15 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
|||||||
|
|
||||||
// Get factory count for a type
|
// Get factory count for a type
|
||||||
const getFactoryCount = (typeId: number): number => {
|
const getFactoryCount = (typeId: number): number => {
|
||||||
const node = nodesByOutput.get(typeId);
|
// First find the node that produces this type
|
||||||
if (!node) return 0;
|
const producingNode = productionNodes.find(node =>
|
||||||
return factories.find(f => f.schematic_id === node.schematicId)?.count ?? 0;
|
node.outputs.some(output => output.typeId === typeId)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!producingNode) return 0;
|
||||||
|
|
||||||
|
// Then find the factory count for this schematic
|
||||||
|
return factories.find(f => f.schematic_id === producingNode.schematicId)?.count ?? 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get input requirements for a type
|
// Get input requirements for a type
|
||||||
@@ -232,6 +243,11 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
|||||||
return node?.cycleTime;
|
return node?.cycleTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get extractor expiry time for a type
|
||||||
|
const getExtractorExpiryTime = (typeId: number): string | undefined => {
|
||||||
|
return extractors.find(e => e.typeId === typeId)?.expiryTime;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper sx={{ p: 2, my: 2 }}>
|
<Paper sx={{ p: 2, my: 2 }}>
|
||||||
<Typography variant="h6" gutterBottom>
|
<Typography variant="h6" gutterBottom>
|
||||||
@@ -258,6 +274,7 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
|||||||
const consumption = consumptionTotals.get(typeId) ?? 0;
|
const consumption = consumptionTotals.get(typeId) ?? 0;
|
||||||
const inputs = getInputRequirements(typeId);
|
const inputs = getInputRequirements(typeId);
|
||||||
const cycleTime = getSchematicCycleTime(typeId);
|
const cycleTime = getSchematicCycleTime(typeId);
|
||||||
|
const expiryTime = getExtractorExpiryTime(typeId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid item key={typeId} xs={12} sm={6} md={4}>
|
<Grid item key={typeId} xs={12} sm={6} md={4}>
|
||||||
@@ -292,19 +309,49 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack spacing={0.5}>
|
<Stack spacing={0.5}>
|
||||||
{production > 0 && (
|
{factoryCount > 0 && (
|
||||||
<>
|
<Typography variant="caption" color="info.main">
|
||||||
<Typography variant="caption" color="success.main">
|
Factories: {factoryCount}
|
||||||
Production: {production.toFixed(1)} units total
|
</Typography>
|
||||||
|
)}
|
||||||
|
{inputs.length > 0 && (
|
||||||
|
<Box>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
Inputs:
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
{inputs.map(input => (
|
||||||
|
<Typography
|
||||||
|
key={input.typeId}
|
||||||
|
variant="caption"
|
||||||
|
sx={{ display: 'block', ml: 1 }}
|
||||||
|
>
|
||||||
|
{PI_TYPES_MAP[input.typeId]?.name}: {input.quantity * factoryCount}/cycle
|
||||||
|
</Typography>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
{expiryTime && (
|
||||||
|
<Box>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
Extractor expires in:
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" sx={{ ml: 1 }}>
|
||||||
|
<Countdown
|
||||||
|
overtime={true}
|
||||||
|
date={DateTime.fromISO(expiryTime).toMillis()}
|
||||||
|
/>
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
{production > 0 && (
|
||||||
|
<Typography variant="caption" color="success.main">
|
||||||
|
Production: {production.toFixed(1)} units total
|
||||||
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{consumption > 0 && (
|
{consumption > 0 && (
|
||||||
<>
|
<Typography variant="caption" color="error.main">
|
||||||
<Typography variant="caption" color="error.main">
|
Consumption: {consumption.toFixed(1)} units total
|
||||||
Consumption: {consumption.toFixed(1)} units total
|
</Typography>
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
{isImported && (
|
{isImported && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
ColorContext,
|
ColorContext,
|
||||||
ColorSelectionType,
|
ColorSelectionType,
|
||||||
|
SessionContext,
|
||||||
} from "@/app/context/Context";
|
} from "@/app/context/Context";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -10,14 +11,16 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Typography,
|
Typography,
|
||||||
|
TextField,
|
||||||
|
Box,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { ColorChangeHandler, ColorResult, CompactPicker } from "react-color";
|
import { ColorChangeHandler, ColorResult, CompactPicker } from "react-color";
|
||||||
import React from "react";
|
import React, { useState, useContext } from "react";
|
||||||
import { useContext } from "react";
|
|
||||||
|
|
||||||
export const SettingsButton = () => {
|
export const SettingsButton = () => {
|
||||||
const { colors, setColors } = useContext(ColorContext);
|
const { colors, setColors } = useContext(ColorContext);
|
||||||
const [open, setOpen] = React.useState(false);
|
const { balanceThreshold, setBalanceThreshold } = useContext(SessionContext);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const handleClickOpen = () => {
|
const handleClickOpen = () => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -26,6 +29,7 @@ export const SettingsButton = () => {
|
|||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleColorSelection = (key: string, currentColors: ColorSelectionType) => (selection: ColorResult) => {
|
const handleColorSelection = (key: string, currentColors: ColorSelectionType) => (selection: ColorResult) => {
|
||||||
console.log(key, selection.hex)
|
console.log(key, selection.hex)
|
||||||
setColors({
|
setColors({
|
||||||
@@ -34,20 +38,44 @@ export const SettingsButton = () => {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleBalanceThresholdChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = parseInt(event.target.value);
|
||||||
|
if (!isNaN(value) && value >= 0 && value <= 100000) {
|
||||||
|
setBalanceThreshold(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title="Toggle settings dialog">
|
<Tooltip title="Toggle settings dialog">
|
||||||
<>
|
<>
|
||||||
<Button onClick={handleClickOpen}>Settings</Button>
|
<Button onClick={handleClickOpen} color="inherit">
|
||||||
|
Settings
|
||||||
|
</Button>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open}
|
open={open}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
aria-labelledby="alert-dialog-title"
|
aria-labelledby="alert-dialog-title"
|
||||||
aria-describedby="alert-dialog-description"
|
aria-describedby="alert-dialog-description"
|
||||||
>
|
>
|
||||||
|
|
||||||
<DialogTitle id="alert-dialog-title">
|
<DialogTitle id="alert-dialog-title">
|
||||||
{"Override default timer colors"}
|
{"Settings"}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
|
|
||||||
<DialogContent style={{ paddingTop: "1rem" }}>
|
<DialogContent style={{ paddingTop: "1rem" }}>
|
||||||
|
<Box sx={{ mt: 2 }}>
|
||||||
|
<Typography variant="subtitle1">Balance Threshold</Typography>
|
||||||
|
<TextField
|
||||||
|
type="number"
|
||||||
|
value={balanceThreshold}
|
||||||
|
onChange={handleBalanceThresholdChange}
|
||||||
|
fullWidth
|
||||||
|
margin="normal"
|
||||||
|
inputProps={{ min: 0, max: 100000 }}
|
||||||
|
helperText="Set the threshold for balance alerts (0-100,000)"
|
||||||
|
error={balanceThreshold < 0 || balanceThreshold > 100000}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
{Object.keys(colors).map((key) => {
|
{Object.keys(colors).map((key) => {
|
||||||
return (
|
return (
|
||||||
<div key={`color-row-${key}`}>
|
<div key={`color-row-${key}`}>
|
||||||
@@ -59,6 +87,7 @@ export const SettingsButton = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={handleClose}>Close</Button>
|
<Button onClick={handleClose}>Close</Button>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { EvePraisalResult } from "@/eve-praisal";
|
import { EvePraisalResult } from "@/eve-praisal";
|
||||||
import { AccessToken, CharacterUpdate } from "@/types";
|
import { AccessToken, CharacterUpdate, PlanetConfig } from "@/types";
|
||||||
import { Dispatch, SetStateAction, createContext } from "react";
|
import { Dispatch, SetStateAction, createContext } from "react";
|
||||||
import { PlanetConfig } from "../components/PlanetConfig/PlanetConfigDialog";
|
|
||||||
|
|
||||||
export const CharacterContext = createContext<{
|
export const CharacterContext = createContext<{
|
||||||
characters: AccessToken[];
|
characters: AccessToken[];
|
||||||
@@ -36,6 +35,8 @@ export const SessionContext = createContext<{
|
|||||||
characterId: number;
|
characterId: number;
|
||||||
planetId: number;
|
planetId: number;
|
||||||
}) => PlanetConfig;
|
}) => PlanetConfig;
|
||||||
|
balanceThreshold: number;
|
||||||
|
setBalanceThreshold: Dispatch<SetStateAction<number>>;
|
||||||
}>({
|
}>({
|
||||||
sessionReady: false,
|
sessionReady: false,
|
||||||
refreshSession: () => {},
|
refreshSession: () => {},
|
||||||
@@ -59,6 +60,8 @@ export const SessionContext = createContext<{
|
|||||||
}) => {
|
}) => {
|
||||||
return { characterId, planetId, excludeFromTotals: true };
|
return { characterId, planetId, excludeFromTotals: true };
|
||||||
},
|
},
|
||||||
|
balanceThreshold: 1000,
|
||||||
|
setBalanceThreshold: () => {},
|
||||||
});
|
});
|
||||||
export type ColorSelectionType = {
|
export type ColorSelectionType = {
|
||||||
defaultColor: string;
|
defaultColor: string;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
import { EvePraisalResult, fetchAllPrices } from "@/eve-praisal";
|
import { EvePraisalResult, fetchAllPrices } from "@/eve-praisal";
|
||||||
import { getPlanet, getPlanetUniverse, getPlanets } from "@/planets";
|
import { getPlanet, getPlanetUniverse, getPlanets } from "@/planets";
|
||||||
import { PlanetConfig } from "./components/PlanetConfig/PlanetConfigDialog";
|
import { PlanetConfig } from "@/types";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@@ -29,6 +29,7 @@ const Home = () => {
|
|||||||
const [piPrices, setPiPrices] = useState<EvePraisalResult | undefined>(
|
const [piPrices, setPiPrices] = useState<EvePraisalResult | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
const [balanceThreshold, setBalanceThreshold] = useState(1000);
|
||||||
|
|
||||||
const [colors, setColors] = useState<ColorSelectionType>(defaultColors);
|
const [colors, setColors] = useState<ColorSelectionType>(defaultColors);
|
||||||
const [alertMode, setAlertMode] = useState(false);
|
const [alertMode, setAlertMode] = useState(false);
|
||||||
@@ -199,6 +200,17 @@ const Home = () => {
|
|||||||
setAlertMode(JSON.parse(storedAlertMode));
|
setAlertMode(JSON.parse(storedAlertMode));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const storedBalanceThreshold = localStorage.getItem("balanceThreshold");
|
||||||
|
if (storedBalanceThreshold) {
|
||||||
|
setBalanceThreshold(parseInt(storedBalanceThreshold));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem("balanceThreshold", balanceThreshold.toString());
|
||||||
|
}, [balanceThreshold]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
localStorage.setItem("compactMode", compactMode ? "true" : "false");
|
localStorage.setItem("compactMode", compactMode ? "true" : "false");
|
||||||
}, [compactMode]);
|
}, [compactMode]);
|
||||||
@@ -264,6 +276,8 @@ const Home = () => {
|
|||||||
toggleAlertMode,
|
toggleAlertMode,
|
||||||
updatePlanetConfig,
|
updatePlanetConfig,
|
||||||
readPlanetConfig,
|
readPlanetConfig,
|
||||||
|
balanceThreshold,
|
||||||
|
setBalanceThreshold,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CharacterContext.Provider
|
<CharacterContext.Provider
|
||||||
|
|||||||
@@ -61,10 +61,19 @@ export const planetCalculations = (planet: PlanetWithInfo) => {
|
|||||||
const schematic = PI_SCHEMATICS.find(
|
const schematic = PI_SCHEMATICS.find(
|
||||||
(s) => s.schematic_id == f.schematic_id,
|
(s) => s.schematic_id == f.schematic_id,
|
||||||
);
|
);
|
||||||
if (schematic) acc.set(f.schematic_id, schematic);
|
if (schematic) {
|
||||||
|
const existing = acc.get(f.schematic_id);
|
||||||
|
if (existing) {
|
||||||
|
// If we already have this schematic, increment its count
|
||||||
|
existing.count = (existing.count || 0) + 1;
|
||||||
|
} else {
|
||||||
|
// First time seeing this schematic, set count to 1
|
||||||
|
acc.set(f.schematic_id, { ...schematic, count: 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, new Map<SchematicId, (typeof PI_SCHEMATICS)[number]>());
|
}, new Map<SchematicId, (typeof PI_SCHEMATICS)[number] & { count: number }>());
|
||||||
|
|
||||||
const locallyProduced = Array.from(localProduction)
|
const locallyProduced = Array.from(localProduction)
|
||||||
.flatMap((p) => p[1].outputs)
|
.flatMap((p) => p[1].outputs)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { PlanetConfig } from "./app/components/PlanetConfig/PlanetConfigDialog";
|
|
||||||
|
|
||||||
export interface AccessToken {
|
export interface AccessToken {
|
||||||
access_token: string;
|
access_token: string;
|
||||||
expires_at: number;
|
expires_at: number;
|
||||||
@@ -119,3 +117,9 @@ export interface Pin {
|
|||||||
amount: number;
|
amount: number;
|
||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PlanetConfig {
|
||||||
|
characterId: number;
|
||||||
|
planetId: number;
|
||||||
|
excludeFromTotals: boolean;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user