Skip to content

Commit

Permalink
Utilize big battery in artifact samples (#40)
Browse files Browse the repository at this point in the history
Reduce the duration it takes to process artifact samples when big
battery is plugged in to the science lab and in charged state.
  • Loading branch information
nicou authored Jun 7, 2024
1 parent f99080a commit 47ba4ea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
31 changes: 16 additions & 15 deletions db/redux/misc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const blobs: unknown[] = [
captainsLogText: `Vel et veniam corporis cupiditate in ullam.
Delectus culpa magnam blanditiis. Ipsa aut ipsum nostrum nihil debitis illo aut.
Placeat nobis amet ipsa. Suscipit vero tenetur non et. Ratione magni quam
sunt eaque dolor id nisi magni.`
sunt eaque dolor id nisi magni.`,
},
// Used for artifacts that trigger some actions
{
Expand All @@ -30,27 +30,28 @@ sunt eaque dolor id nisi magni.`
is_usable: false,
is_used: false,
used_at: null,
log_message: 'Jump crystal generator artifact has been activated. Jump crystals are now regenerated during jumps.'
log_message:
'Jump crystal generator artifact has been activated. Jump crystals are now regenerated during jumps.',
},
HEALTH_BOOST: {
is_usable: false,
is_used: false,
used_at: null,
log_message: 'An artifact increased ship hull health to 100%'
}
}
log_message: 'An artifact increased ship hull health to 100%',
},
},
},
// Dynamic HANSCA configs
{
type: 'misc',
id: 'hansca',
analyseBaseTime: 90
analyseBaseTime: 90,
},
// Drone count for Flappy drone
{
type: 'misc',
id: 'flappy_drone',
amount: 10
amount: 10,
},
{
type: 'misc',
Expand All @@ -65,7 +66,7 @@ sunt eaque dolor id nisi magni.`
[SkillLevels.Novice]: Duration.minutes(1),
[SkillLevels.Master]: Duration.minutes(2),
[SkillLevels.Expert]: Duration.minutes(5),
}
},
},
{
type: 'misc',
Expand All @@ -74,23 +75,23 @@ sunt eaque dolor id nisi magni.`
[SkillLevels.Novice]: Duration.minutes(5),
[SkillLevels.Master]: Duration.minutes(2),
[SkillLevels.Expert]: Duration.seconds(15),
// A550 power bank thingy that reduces science analysis time when in a plugged in state
a550_time_reduction: Duration.minutes(15)
}
// Big battery reduces science analysis time when plugged in to the science lab
batteryless_operation_penalty: Duration.minutes(15),
},
},
{
type: 'misc',
id: Stores.ScienceAnalysisInProgress,
analysis_in_progress: []
analysis_in_progress: [],
},
{
type: 'misc',
id: Stores.TagUidToArtifactCatalogId,
tagUidToArtifactCatalogId: {
// TODO: Fill this with actual data
"ABCDEF123456": "BEACON-1",
}
}
ABCDEF123456: 'BEACON-1',
},
},
];

blobs.forEach(saveBlob);
4 changes: 2 additions & 2 deletions src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export const ScienceAnalysisTimes = z.object({
[SkillLevels.Novice]: z.number().min(0).int(),
[SkillLevels.Master]: z.number().min(0).int(),
[SkillLevels.Expert]: z.number().min(0).int(),
"a550_time_reduction": z.number().min(0).int(),
batteryless_operation_penalty: z.number().int(),
}),
});
export type ScienceAnalysisTimes = z.infer<typeof ScienceAnalysisTimes>;

const AnalysisInProgress = z.object({
artifact_catalog_id : z.string(),
artifact_catalog_id: z.string(),
author_name: z.string(),
completes_at: z.number().int(),
operation_additional_type: z.string(),
Expand Down
33 changes: 19 additions & 14 deletions src/utils/science.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getPath } from "@/store/store";
import { SkillLevels, getHighestSkillLevel } from "./groups";
import { ScienceAnalysisTimes, Stores } from "@/store/types";
import { logger } from "@/logger";
import { Duration } from "./time";
import { ArtifactEntry, Artifact } from "@/models/artifact";
import { getPath, store } from '@/store/store';
import { SkillLevels, getHighestSkillLevel } from './groups';
import { ScienceAnalysisTimes, Stores } from '@/store/types';
import { logger } from '@/logger';
import { Duration } from './time';
import { ArtifactEntry, Artifact } from '@/models/artifact';
import Bookshelf from 'bookshelf';
import { BigBatteryLocation, isBatteryConnectedAndCharged } from './bigbattery-helpers';

const EVA_ID = '20263';

Expand Down Expand Up @@ -61,10 +62,12 @@ export const addOperationResultsToArtifactEntry = async (operationResult: Booksh
await entry.save({
artifact_id: artifact.get('id'),
entry: entryText,
person_id: EVA_ID
person_id: EVA_ID,
});
await operationResult.save({ is_complete: true }, { method: 'update', patch: true });
logger.success(`Added #${operationResult.get("id")} ${operationType} results to artifact ${artifact.get('name')} (${artifact.get('catalog_id')})`);
logger.success(
`Added #${operationResult.get('id')} ${operationType} results to artifact ${artifact.get('name')} (${artifact.get('catalog_id')})`
);
};

export const getScienceAnalysisTime = (analysisAuthor: unknown): number => {
Expand All @@ -76,18 +79,20 @@ export const getScienceAnalysisTime = (analysisAuthor: unknown): number => {
return Duration.minutes(20);
}

// TODO: Get data from blob once it's available
const isA550PluggedIn = true;
const analysisTimes = detectionTimes.data.analysis_times;

const addedTime = isA550PluggedIn ? 0 : detectionTimes.data.analysis_times.a550_time_reduction;
// Check if the big battery is connected to the science lab, add penalty if not
const bigBatteryBox = store.getState().data.box.bigbattery;
const hasBigBattery = isBatteryConnectedAndCharged(bigBatteryBox, BigBatteryLocation.SCIENCE);
const penalty = hasBigBattery ? 0 : analysisTimes.batteryless_operation_penalty;

switch (skillLevel) {
case SkillLevels.Expert:
return detectionTimes.data.analysis_times[SkillLevels.Expert] + addedTime;
return analysisTimes[SkillLevels.Expert] + penalty;
case SkillLevels.Master:
return detectionTimes.data.analysis_times[SkillLevels.Master] + addedTime;
return analysisTimes[SkillLevels.Master] + penalty;
case SkillLevels.Novice:
return detectionTimes.data.analysis_times[SkillLevels.Novice]+ addedTime;
return analysisTimes[SkillLevels.Novice] + penalty;
default:
return Duration.minutes(20);
}
Expand Down

0 comments on commit 47ba4ea

Please sign in to comment.