move exclusion directly to planet list and add more info to simulation
This commit is contained in:
@@ -3,8 +3,6 @@ import { planetCalculations } from "@/planets";
|
||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||
import {
|
||||
Card,
|
||||
Checkbox,
|
||||
FormControlLabel,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
@@ -20,12 +18,6 @@ import Image from "next/image";
|
||||
import { ColorContext, SessionContext } from "@/app/context/Context";
|
||||
import { useContext } from "react";
|
||||
|
||||
export type PlanetConfig = {
|
||||
characterId: number;
|
||||
planetId: number;
|
||||
excludeFromTotals: boolean;
|
||||
};
|
||||
|
||||
export const PlanetConfigDialog = ({
|
||||
planet,
|
||||
character,
|
||||
@@ -35,14 +27,9 @@ export const PlanetConfigDialog = ({
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const { colors } = useContext(ColorContext);
|
||||
const { piPrices, readPlanetConfig, updatePlanetConfig } =
|
||||
useContext(SessionContext);
|
||||
const { piPrices } = useContext(SessionContext);
|
||||
const { extractors, localProduction, localImports, localExports } =
|
||||
planetCalculations(planet);
|
||||
const planetConfig = readPlanetConfig({
|
||||
characterId: character.character.characterId,
|
||||
planetId: planet.planet_id,
|
||||
});
|
||||
|
||||
return (
|
||||
<Card style={{ padding: "1rem", margin: "1rem" }}>
|
||||
@@ -189,23 +176,6 @@ export const PlanetConfigDialog = ({
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</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>
|
||||
);
|
||||
};
|
||||
|
@@ -65,6 +65,7 @@ export interface ProductionNode {
|
||||
quantity: number;
|
||||
}>;
|
||||
cycleTime: number;
|
||||
factoryCount: number;
|
||||
}
|
||||
|
||||
export interface ProductionChainBalance {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Box, Paper, Typography, Stack } from '@mui/material';
|
||||
import { Line } from 'react-chartjs-2';
|
||||
import { useTheme } from '@mui/material';
|
||||
import { getProgramOutputPrediction, ProductionNode } from './ExtractionSimulation';
|
||||
import { PI_TYPES_MAP } from '@/const';
|
||||
import { ProductionChainVisualization } from './ProductionChainVisualization';
|
||||
@@ -15,6 +14,8 @@ import {
|
||||
Tooltip,
|
||||
Legend
|
||||
} from 'chart.js';
|
||||
import { DateTime } from 'luxon';
|
||||
import Countdown from 'react-countdown';
|
||||
|
||||
ChartJS.register(
|
||||
CategoryScale,
|
||||
@@ -43,6 +44,7 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
||||
extractors,
|
||||
productionNodes
|
||||
}) => {
|
||||
|
||||
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
|
||||
|
||||
// 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));
|
||||
|
||||
// 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)));
|
||||
|
||||
// Create factories array with correct counts
|
||||
const factories = installedSchematicIds.map(schematicId => ({
|
||||
schematic_id: schematicId,
|
||||
count: productionNodes.filter(node => node.schematicId === schematicId).length
|
||||
}));
|
||||
const factories = installedSchematicIds.map(schematicId => {
|
||||
const node = productionNodes.find(n => n.schematicId === schematicId);
|
||||
if (!node) return { schematic_id: schematicId, count: 0 };
|
||||
return {
|
||||
schematic_id: schematicId,
|
||||
count: node.factoryCount
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<Box>
|
||||
@@ -191,6 +198,12 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
||||
<Typography variant="body2" component="div" sx={{ pl: 2 }}>
|
||||
• Expiry Time: {new Date(expiryTime).toLocaleString()}
|
||||
</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>
|
||||
))}
|
||||
</Box>
|
||||
@@ -204,7 +217,8 @@ export const ExtractionSimulationDisplay: React.FC<ExtractionSimulationDisplayPr
|
||||
extractors={extractors.map(e => ({
|
||||
typeId: e.typeId,
|
||||
baseValue: e.baseValue,
|
||||
cycleTime: CYCLE_TIME
|
||||
cycleTime: CYCLE_TIME,
|
||||
expiryTime: e.expiryTime
|
||||
}))}
|
||||
factories={factories}
|
||||
extractorTotals={extractorTotals}
|
||||
|
@@ -4,7 +4,7 @@ import { planetCalculations } from "@/planets";
|
||||
import { AccessToken, PlanetWithInfo } from "@/types";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
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 Dialog from "@mui/material/Dialog";
|
||||
import Slide from "@mui/material/Slide";
|
||||
@@ -72,14 +72,15 @@ export const PlanetTableRow = ({
|
||||
setPlanetConfigOpen(false);
|
||||
};
|
||||
|
||||
const { piPrices, alertMode } = useContext(SessionContext);
|
||||
const { piPrices, alertMode, updatePlanetConfig, readPlanetConfig } = useContext(SessionContext);
|
||||
const planetInfo = planet.info;
|
||||
const planetInfoUniverse = planet.infoUniverse;
|
||||
const { expired, extractors, localProduction, localImports, localExports } =
|
||||
planetCalculations(planet);
|
||||
const planetConfig = character.planetConfig.find(
|
||||
(p) => p.planetId === planet.planet_id,
|
||||
);
|
||||
const planetConfig = readPlanetConfig({
|
||||
characterId: character.character.characterId,
|
||||
planetId: planet.planet_id,
|
||||
});
|
||||
const { colors } = useContext(ColorContext);
|
||||
// Convert local production to ProductionNode array for simulation
|
||||
const productionNodes: ProductionNode[] = Array.from(localProduction).map(([schematicId, schematic]) => ({
|
||||
@@ -94,7 +95,8 @@ export const PlanetTableRow = ({
|
||||
typeId: output.type_id,
|
||||
quantity: output.quantity
|
||||
})),
|
||||
cycleTime: schematic.cycle_time
|
||||
cycleTime: schematic.cycle_time,
|
||||
factoryCount: schematic.count || 1
|
||||
}));
|
||||
|
||||
const storageFacilities = planetInfo.pins.filter(pin =>
|
||||
@@ -130,6 +132,13 @@ export const PlanetTableRow = ({
|
||||
};
|
||||
};
|
||||
|
||||
const handleExcludeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
updatePlanetConfig({
|
||||
...planetConfig,
|
||||
excludeFromTotals: event.target.checked,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<TableRow
|
||||
@@ -230,12 +239,17 @@ export const PlanetTableRow = ({
|
||||
<TableCell>
|
||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||
{localExports.map((exports) => (
|
||||
<Typography
|
||||
<FormControlLabel
|
||||
key={`export-excluded-${character.character.characterId}-${planet.planet_id}-${exports.typeId}`}
|
||||
fontSize={theme.custom.smallText}
|
||||
>
|
||||
{planetConfig?.excludeFromTotals ? "ex" : ""}
|
||||
</Typography>
|
||||
control={
|
||||
<Checkbox
|
||||
checked={planetConfig.excludeFromTotals}
|
||||
onChange={handleExcludeChange}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label=""
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</TableCell>
|
||||
|
@@ -1,7 +1,9 @@
|
||||
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 { PI_TYPES_MAP } from '@/const';
|
||||
import { DateTime } from 'luxon';
|
||||
import Countdown from 'react-countdown';
|
||||
|
||||
interface Factory {
|
||||
schematic_id: number;
|
||||
@@ -29,6 +31,7 @@ interface ProductionChainVisualizationProps {
|
||||
typeId: number;
|
||||
baseValue: number;
|
||||
cycleTime: number;
|
||||
expiryTime: string;
|
||||
}>;
|
||||
factories: Factory[];
|
||||
extractorTotals: Map<number, number>;
|
||||
@@ -39,8 +42,10 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
||||
extractedTypeIds,
|
||||
factories,
|
||||
extractorTotals,
|
||||
productionNodes
|
||||
productionNodes,
|
||||
extractors
|
||||
}) => {
|
||||
|
||||
// Get all type IDs involved in the production chain
|
||||
const allTypeIds = new Set<number>();
|
||||
const requiredInputs = new Set<number>();
|
||||
@@ -214,9 +219,15 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
||||
|
||||
// Get factory count for a type
|
||||
const getFactoryCount = (typeId: number): number => {
|
||||
const node = nodesByOutput.get(typeId);
|
||||
if (!node) return 0;
|
||||
return factories.find(f => f.schematic_id === node.schematicId)?.count ?? 0;
|
||||
// First find the node that produces this type
|
||||
const producingNode = productionNodes.find(node =>
|
||||
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
|
||||
@@ -232,6 +243,11 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
||||
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 (
|
||||
<Paper sx={{ p: 2, my: 2 }}>
|
||||
<Typography variant="h6" gutterBottom>
|
||||
@@ -258,6 +274,7 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
||||
const consumption = consumptionTotals.get(typeId) ?? 0;
|
||||
const inputs = getInputRequirements(typeId);
|
||||
const cycleTime = getSchematicCycleTime(typeId);
|
||||
const expiryTime = getExtractorExpiryTime(typeId);
|
||||
|
||||
return (
|
||||
<Grid item key={typeId} xs={12} sm={6} md={4}>
|
||||
@@ -292,19 +309,49 @@ export const ProductionChainVisualization: React.FC<ProductionChainVisualization
|
||||
</Box>
|
||||
</Box>
|
||||
<Stack spacing={0.5}>
|
||||
{production > 0 && (
|
||||
<>
|
||||
<Typography variant="caption" color="success.main">
|
||||
Production: {production.toFixed(1)} units total
|
||||
{factoryCount > 0 && (
|
||||
<Typography variant="caption" color="info.main">
|
||||
Factories: {factoryCount}
|
||||
</Typography>
|
||||
)}
|
||||
{inputs.length > 0 && (
|
||||
<Box>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
Inputs:
|
||||
</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 && (
|
||||
<>
|
||||
<Typography variant="caption" color="error.main">
|
||||
Consumption: {consumption.toFixed(1)} units total
|
||||
</Typography>
|
||||
</>
|
||||
<Typography variant="caption" color="error.main">
|
||||
Consumption: {consumption.toFixed(1)} units total
|
||||
</Typography>
|
||||
)}
|
||||
{isImported && (
|
||||
<>
|
||||
|
@@ -61,10 +61,19 @@ export const planetCalculations = (planet: PlanetWithInfo) => {
|
||||
const schematic = PI_SCHEMATICS.find(
|
||||
(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;
|
||||
}, new Map<SchematicId, (typeof PI_SCHEMATICS)[number]>());
|
||||
}, new Map<SchematicId, (typeof PI_SCHEMATICS)[number] & { count: number }>());
|
||||
|
||||
const locallyProduced = Array.from(localProduction)
|
||||
.flatMap((p) => p[1].outputs)
|
||||
|
Reference in New Issue
Block a user