mirror of
https://github.com/calli-eve/eve-pi.git
synced 2026-02-11 18:28:49 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b47b34ddf | ||
|
|
e8f69b15a4 | ||
|
|
ebd39243b2 | ||
|
|
0ee129b3ca |
@@ -12,6 +12,7 @@ import { EvePraisalResult } from "@/eve-praisal";
|
|||||||
import { STORAGE_IDS, PI_SCHEMATICS, PI_PRODUCT_VOLUMES, STORAGE_CAPACITIES } from "@/const";
|
import { STORAGE_IDS, PI_SCHEMATICS, PI_PRODUCT_VOLUMES, STORAGE_CAPACITIES } from "@/const";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
import { PlanetCalculations, AlertState, StorageContent, StorageInfo } from "@/types/planet";
|
import { PlanetCalculations, AlertState, StorageContent, StorageInfo } from "@/types/planet";
|
||||||
|
import { getProgramOutputPrediction } from "../PlanetaryInteraction/ExtractionSimulation";
|
||||||
|
|
||||||
interface AccountTotals {
|
interface AccountTotals {
|
||||||
monthlyEstimate: number;
|
monthlyEstimate: number;
|
||||||
@@ -49,18 +50,27 @@ const calculatePlanetDetails = (planet: PlanetWithInfo, piPrices: EvePraisalResu
|
|||||||
]));
|
]));
|
||||||
|
|
||||||
// Calculate extractor averages and check for large differences
|
// Calculate extractor averages and check for large differences
|
||||||
|
const CYCLE_TIME = 30 * 60; // 30 minutes in seconds
|
||||||
const extractorAverages = extractors
|
const extractorAverages = extractors
|
||||||
.filter(e => e.extractor_details?.product_type_id && e.extractor_details?.qty_per_cycle)
|
.filter(e => e.extractor_details?.product_type_id && e.extractor_details?.qty_per_cycle)
|
||||||
.map(e => {
|
.map(e => {
|
||||||
const cycleTime = e.extractor_details?.cycle_time || 3600;
|
const installDate = new Date(e.install_time ?? "");
|
||||||
|
const expiryDate = new Date(e.expiry_time ?? "");
|
||||||
|
const programDuration = (expiryDate.getTime() - installDate.getTime()) / 1000;
|
||||||
|
const cycles = Math.floor(programDuration / CYCLE_TIME);
|
||||||
|
|
||||||
const qtyPerCycle = e.extractor_details?.qty_per_cycle || 0;
|
const qtyPerCycle = e.extractor_details?.qty_per_cycle || 0;
|
||||||
|
const prediction = getProgramOutputPrediction(qtyPerCycle, CYCLE_TIME, cycles);
|
||||||
|
const totalOutput = prediction.reduce((sum, val) => sum + val, 0);
|
||||||
|
const averagePerHour = totalOutput / cycles * 2;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
typeId: e.extractor_details!.product_type_id!,
|
typeId: e.extractor_details!.product_type_id!,
|
||||||
averagePerHour: (qtyPerCycle * 3600) / cycleTime
|
averagePerHour
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasLargeExtractorDifference = extractorAverages.length === 2 &&
|
const hasLargeExtractorDifference = extractorAverages.length === 2 &&
|
||||||
Math.abs(extractorAverages[0].averagePerHour - extractorAverages[1].averagePerHour) > balanceThreshold;
|
Math.abs(extractorAverages[0].averagePerHour - extractorAverages[1].averagePerHour) > balanceThreshold;
|
||||||
|
|
||||||
// Calculate storage info
|
// Calculate storage info
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { GitHubButton } from "../Github/GitHubButton";
|
|||||||
import { LoginButton } from "../Login/LoginButton";
|
import { LoginButton } from "../Login/LoginButton";
|
||||||
import { PartnerCodeButton } from "../PartnerCode/PartnerCodeButton";
|
import { PartnerCodeButton } from "../PartnerCode/PartnerCodeButton";
|
||||||
import { SettingsButton } from "../Settings/SettingsButtons";
|
import { SettingsButton } from "../Settings/SettingsButtons";
|
||||||
|
import { BuyMeCoffeeButton } from "../BuyMeCoffee/BuyMeCoffeeButton";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -132,6 +133,9 @@ function ResponsiveAppBar() {
|
|||||||
<MenuItem onClick={handleCloseNavMenu}>
|
<MenuItem onClick={handleCloseNavMenu}>
|
||||||
<PartnerCodeButton />
|
<PartnerCodeButton />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem onClick={handleCloseNavMenu}>
|
||||||
|
<BuyMeCoffeeButton />
|
||||||
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Box>
|
</Box>
|
||||||
<PublicIcon sx={{ display: { xs: "flex", md: "none" }, mr: 1 }} />
|
<PublicIcon sx={{ display: { xs: "flex", md: "none" }, mr: 1 }} />
|
||||||
@@ -173,6 +177,7 @@ function ResponsiveAppBar() {
|
|||||||
</Button>
|
</Button>
|
||||||
<CCPButton />
|
<CCPButton />
|
||||||
<PartnerCodeButton />
|
<PartnerCodeButton />
|
||||||
|
<BuyMeCoffeeButton />
|
||||||
</Box>
|
</Box>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
17
src/app/components/BuyMeCoffee/BuyMeCoffeeButton.tsx
Normal file
17
src/app/components/BuyMeCoffee/BuyMeCoffeeButton.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Box, Button, Tooltip } from "@mui/material";
|
||||||
|
export const BuyMeCoffeeButton = () => {
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Tooltip title="Support the development of this tool">
|
||||||
|
<Button
|
||||||
|
href="https://buymeacoffee.com/evepi"
|
||||||
|
target="_blank"
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
sx={{ color: "white", display: "block" }}
|
||||||
|
>
|
||||||
|
By me a beer
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -135,7 +135,7 @@ export const ExtractionSimulationTooltip: React.FC<ExtractionSimulationTooltipPr
|
|||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ flex: 1, minWidth: 0 }}>
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
{extractorPrograms.map(({ typeId, cycleTime, cycles, installTime, expiryTime }, idx) => {
|
{extractorPrograms.map(({ typeId, cycleTime, cycles, expiryTime }, idx) => {
|
||||||
const prediction = getProgramOutputPrediction(
|
const prediction = getProgramOutputPrediction(
|
||||||
extractors[idx].baseValue,
|
extractors[idx].baseValue,
|
||||||
CYCLE_TIME,
|
CYCLE_TIME,
|
||||||
@@ -169,7 +169,7 @@ export const ExtractionSimulationTooltip: React.FC<ExtractionSimulationTooltipPr
|
|||||||
: 'inherit'
|
: 'inherit'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
• Average per hour: {((extractors[idx].baseValue * 3600) / extractors[idx].cycleTime).toFixed(1)} units
|
• Average per hour: {(totalOutput / cycles * 2).toFixed(1)} units
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2">
|
<Typography variant="body2">
|
||||||
• Expires in: <Countdown overtime={true} date={DateTime.fromISO(expiryTime).toMillis()} />
|
• Expires in: <Countdown overtime={true} date={DateTime.fromISO(expiryTime).toMillis()} />
|
||||||
@@ -185,17 +185,24 @@ export const ExtractionSimulationTooltip: React.FC<ExtractionSimulationTooltipPr
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Stack spacing={0.5}>
|
<Stack spacing={0.5}>
|
||||||
{extractors.map((extractor, index) => {
|
{extractors.map((extractor, index) => {
|
||||||
const averagePerHour = (extractor.baseValue * 3600) / extractor.cycleTime;
|
const prediction = getProgramOutputPrediction(
|
||||||
|
extractor.baseValue,
|
||||||
|
CYCLE_TIME,
|
||||||
|
extractorPrograms[index].cycles
|
||||||
|
);
|
||||||
|
const totalOutput = prediction.reduce((sum, val) => sum + val, 0);
|
||||||
|
const cycles = extractorPrograms[index].cycles;
|
||||||
|
const averagePerHour = totalOutput / cycles * 2;
|
||||||
return (
|
return (
|
||||||
<Typography key={index} variant="body2">
|
<Typography key={index} variant="body2">
|
||||||
• {PI_TYPES_MAP[extractor.typeId]?.name}: {averagePerHour.toFixed(1)} u/h
|
• {PI_TYPES_MAP[extractor.typeId]?.name}: {averagePerHour.toFixed(1)} u/h
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
color="error"
|
color="error"
|
||||||
sx={{
|
sx={{
|
||||||
mt: 1,
|
mt: 1,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
borderTop: '1px solid',
|
borderTop: '1px solid',
|
||||||
@@ -203,10 +210,27 @@ export const ExtractionSimulationTooltip: React.FC<ExtractionSimulationTooltipPr
|
|||||||
pt: 1
|
pt: 1
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Difference: {Math.abs(
|
Difference: {(() => {
|
||||||
(extractors[0].baseValue * 3600 / extractors[0].cycleTime) -
|
const prediction0 = getProgramOutputPrediction(
|
||||||
(extractors[1].baseValue * 3600 / extractors[1].cycleTime)
|
extractors[0].baseValue,
|
||||||
).toFixed(1)} u/h
|
CYCLE_TIME,
|
||||||
|
extractorPrograms[0].cycles
|
||||||
|
);
|
||||||
|
const totalOutput0 = prediction0.reduce((sum, val) => sum + val, 0);
|
||||||
|
const cycles0 = extractorPrograms[0].cycles;
|
||||||
|
const avg0 = totalOutput0 / cycles0 * 2;
|
||||||
|
|
||||||
|
const prediction1 = getProgramOutputPrediction(
|
||||||
|
extractors[1].baseValue,
|
||||||
|
CYCLE_TIME,
|
||||||
|
extractorPrograms[1].cycles
|
||||||
|
);
|
||||||
|
const totalOutput1 = prediction1.reduce((sum, val) => sum + val, 0);
|
||||||
|
const cycles1 = extractorPrograms[1].cycles;
|
||||||
|
const avg1 = totalOutput1 / cycles1 * 2;
|
||||||
|
|
||||||
|
return Math.abs(avg0 - avg1).toFixed(1);
|
||||||
|
})()} u/h
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
@@ -62,11 +62,9 @@ export const getPlanet = async (
|
|||||||
const cached = planetCache.get(cacheKey);
|
const cached = planetCache.get(cacheKey);
|
||||||
|
|
||||||
if (cached && Date.now() - cached.timestamp < CACHE_DURATION_MS) {
|
if (cached && Date.now() - cached.timestamp < CACHE_DURATION_MS) {
|
||||||
console.log(`[Cache HIT] Planet ${planet.planet_id} for character ${character.character.characterId}`);
|
|
||||||
return cached.data;
|
return cached.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[Cache MISS] Fetching planet ${planet.planet_id} for character ${character.character.characterId}`);
|
|
||||||
const api = new Api();
|
const api = new Api();
|
||||||
const planetInfo = (
|
const planetInfo = (
|
||||||
await api.v3.getCharactersCharacterIdPlanetsPlanetId(
|
await api.v3.getCharactersCharacterIdPlanetsPlanetId(
|
||||||
|
|||||||
Reference in New Issue
Block a user